Finish work on multijournal admin part
Need harmonization on rights
This commit is contained in:
parent
fc2b9a858b
commit
06c2f04927
@ -122,6 +122,15 @@ else if ($action == 'update') {
|
||||
$object->label = GETPOST('label', 'alpha');
|
||||
$object->nature = GETPOST('nature', 'int');
|
||||
|
||||
if (empty($object->code)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Code")), null, 'errors');
|
||||
$error ++;
|
||||
}
|
||||
if (empty($object->label)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
$result = $object->update($user);
|
||||
|
||||
if ($result > 0) {
|
||||
@ -161,15 +170,15 @@ if ($action == 'create')
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Code
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Code") . '</td><td><input name="code" size="32" value="' . GETPOST("code") . '"></td></tr>';
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Code") . '</td><td><input name="code" size="10" value="' . GETPOST("code") . '"></td></tr>';
|
||||
|
||||
|
||||
// Label
|
||||
print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="128" value="' . GETPOST("label") . '"></td></tr>';
|
||||
print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="32" value="' . GETPOST("label") . '"></td></tr>';
|
||||
|
||||
// Nature
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">' . $langs->trans("Status") . '</td>';
|
||||
print '<td class="fieldrequired">' . $langs->trans("Type") . '</td>';
|
||||
print '<td class="valeur">';
|
||||
print $form->selectarray('nature', $type2label, GETPOST('nature'));
|
||||
print '</td></tr>';
|
||||
@ -188,10 +197,10 @@ if ($action == 'create')
|
||||
} else if ($id) {
|
||||
$result = $object->fetch($id);
|
||||
if ($result > 0) {
|
||||
$head = fiscalyear_prepare_head($object);
|
||||
$head = accounting_journal_prepare_head($object);
|
||||
|
||||
if ($action == 'edit') {
|
||||
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
|
||||
dol_fiche_head($head, 'card', $langs->trans("AccountingJournal"), 0, 'cron');
|
||||
|
||||
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
@ -200,10 +209,10 @@ if ($action == 'create')
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
// Code
|
||||
print "<tr>";
|
||||
print '<td class="titlefieldcreate titlefield">' . $langs->trans("Ref") . '</td><td>';
|
||||
print $object->ref;
|
||||
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Code") . '</td><td>';
|
||||
print '<input name="code" class="flat" size="8" value="' . $object->code . '">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
@ -211,20 +220,9 @@ if ($action == 'create')
|
||||
print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
|
||||
print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
|
||||
print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
|
||||
print '</td></tr>';
|
||||
|
||||
// Nature
|
||||
print '<tr><td>' . $langs->trans("Type") . '</td><td>';
|
||||
// print $form->selectarray('statut', $statut2label, $object->statut);
|
||||
print $object->getLibStatut(4);
|
||||
print $form->selectarray('nature', $type2label, $object->nature);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
@ -246,15 +244,15 @@ if ($action == 'create')
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
|
||||
}
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
|
||||
dol_fiche_head($head, 'card', $langs->trans("AccountingJournal"), 0, 'cron');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/fiscalyear.php">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/journals.php">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td width="50%">';
|
||||
print $object->ref;
|
||||
print '<tr><td class="titlefield">' . $langs->trans("Code") . '</td><td width="50%">';
|
||||
print $object->code;
|
||||
print '</td><td>';
|
||||
print $linkback;
|
||||
print '</td></tr>';
|
||||
@ -267,7 +265,7 @@ if ($action == 'create')
|
||||
print "</td></tr>";
|
||||
|
||||
// Nature
|
||||
print '<tr><td>' . $langs->trans("Type") . '</td><td>' . $object->getLibType(0) . '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans("Type") . '</td><td colspan="2">' . $object->getLibType(0) . '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -281,9 +279,9 @@ if ($action == 'create')
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
|
||||
|
||||
// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
|
||||
|
||||
|
||||
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,24 +26,18 @@
|
||||
*/
|
||||
class AccountingJournal extends CommonObject
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
var $errors;
|
||||
var $id;
|
||||
public $element='accounting_journal';
|
||||
public $table_element='accounting_journal';
|
||||
public $fk_element = '';
|
||||
protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
var $rowid;
|
||||
var $datec; // Creation date
|
||||
var $fk_pcg_version;
|
||||
var $pcg_type;
|
||||
var $pcg_subtype;
|
||||
var $account_number;
|
||||
var $account_parent;
|
||||
var $account_category;
|
||||
|
||||
var $code;
|
||||
var $label;
|
||||
var $fk_user_author;
|
||||
var $fk_user_modif;
|
||||
var $active; // duplicate with status
|
||||
var $status;
|
||||
|
||||
var $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 9: has-new
|
||||
var $active;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -54,133 +48,75 @@ class AccountingJournal extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Load record in memory
|
||||
*
|
||||
* @param int $rowid Id
|
||||
* @param string $account_number Account number
|
||||
* @param int $limittocurrentchart 1=Do not load record if it is into another accounting system
|
||||
* @return int <0 if KO, Id of record if OK and found
|
||||
*/
|
||||
function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) {
|
||||
global $conf;
|
||||
|
||||
if ($rowid || $account_number) {
|
||||
$sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
|
||||
$sql .= ", ca.label as category_label";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
|
||||
$sql .= " WHERE";
|
||||
if ($rowid) {
|
||||
$sql .= " a.rowid = '" . $rowid . "'";
|
||||
} elseif ($account_number) {
|
||||
$sql .= " a.account_number = '" . $account_number . "'";
|
||||
}
|
||||
if (! empty($limittocurrentchart)) {
|
||||
$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
|
||||
}
|
||||
* Load an object from database
|
||||
*
|
||||
* @param int $id Id of record to load
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT rowid, code, label, nature, active";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->rowid = $obj->rowid;
|
||||
$this->datec = $obj->datec;
|
||||
$this->tms = $obj->tms;
|
||||
$this->fk_pcg_version = $obj->fk_pcg_version;
|
||||
$this->pcg_type = $obj->pcg_type;
|
||||
$this->pcg_subtype = $obj->pcg_subtype;
|
||||
$this->account_number = $obj->account_number;
|
||||
$this->account_parent = $obj->account_parent;
|
||||
$this->label = $obj->label;
|
||||
$this->account_category = $obj->fk_accounting_category;
|
||||
$this->account_category_label = $obj->category_label;
|
||||
$this->fk_user_author = $obj->fk_user_author;
|
||||
$this->fk_user_modif = $obj->fk_user_modif;
|
||||
$this->active = $obj->active;
|
||||
$this->status = $obj->active;
|
||||
|
||||
return $this->id;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
}
|
||||
dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ( $result )
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->code = $obj->code;
|
||||
$this->ref = $obj->code;
|
||||
$this->label = $obj->label;
|
||||
$this->nature = $obj->nature;
|
||||
$this->active = $obj->active;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
return - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert new accounting account in chart of accounts
|
||||
* Insert journal in database
|
||||
*
|
||||
* @param User $user Use making action
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user Use making action
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function create($user, $notrigger = 0) {
|
||||
function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
$now = dol_now();
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_pcg_version))
|
||||
$this->fk_pcg_version = trim($this->fk_pcg_version);
|
||||
if (isset($this->pcg_type))
|
||||
$this->pcg_type = trim($this->pcg_type);
|
||||
if (isset($this->pcg_subtype))
|
||||
$this->pcg_subtype = trim($this->pcg_subtype);
|
||||
if (isset($this->account_number))
|
||||
$this->account_number = trim($this->account_number);
|
||||
if (isset($this->account_parent))
|
||||
$this->account_parent = trim($this->account_parent);
|
||||
if (isset($this->code))
|
||||
$this->code = trim($this->code);
|
||||
if (isset($this->label))
|
||||
$this->label = trim($this->label);
|
||||
if (isset($this->account_category))
|
||||
$this->account_category = trim($this->account_category);
|
||||
if (isset($this->fk_user_author))
|
||||
$this->fk_user_author = trim($this->fk_user_author);
|
||||
if (isset($this->active))
|
||||
$this->active = trim($this->active);
|
||||
|
||||
if (empty($this->pcg_type) || $this->pcg_type == '-1')
|
||||
{
|
||||
$this->pcg_type = 'XXXXXX';
|
||||
}
|
||||
if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
|
||||
{
|
||||
$this->pcg_subtype = 'XXXXXX';
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
if (empty($this->nature) || $this->nature == '-1')
|
||||
{
|
||||
$this->nature = '0';
|
||||
}
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account(";
|
||||
$sql .= "datec";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", fk_pcg_version";
|
||||
$sql .= ", pcg_type";
|
||||
$sql .= ", pcg_subtype";
|
||||
$sql .= ", account_number";
|
||||
$sql .= ", account_parent";
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_journal(";
|
||||
$sql .= "code";
|
||||
$sql .= ", label";
|
||||
$sql .= ", fk_accounting_category";
|
||||
$sql .= ", fk_user_author";
|
||||
$sql .= ", nature";
|
||||
$sql .= ", active";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= " '" . $this->db->idate($now) . "'";
|
||||
$sql .= ", " . $conf->entity;
|
||||
$sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
|
||||
$sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
|
||||
$sql .= ", " . (empty($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'");
|
||||
$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->account_number . "'");
|
||||
$sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
|
||||
$sql .= " " . (empty($this->code) ? 'NULL' : "'" . $this->db->escape($this->code) . "'");
|
||||
$sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
|
||||
$sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'");
|
||||
$sql .= ", " . $user->id;
|
||||
$sql .= ", " . (empty($this->nature) ? '0' : "'" . $this->db->escape($this->nature) . "'");
|
||||
$sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
|
||||
$sql .= ")";
|
||||
|
||||
@ -194,7 +130,7 @@ class AccountingJournal extends CommonObject
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account");
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_journal");
|
||||
|
||||
// if (! $notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
@ -232,26 +168,17 @@ class AccountingJournal extends CommonObject
|
||||
function update($user)
|
||||
{
|
||||
// Check parameters
|
||||
if (empty($this->pcg_type) || $this->pcg_type == '-1')
|
||||
if (empty($this->nature) || $this->nature == '-1')
|
||||
{
|
||||
$this->pcg_type = 'XXXXXX';
|
||||
$this->nature = '0';
|
||||
}
|
||||
if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
|
||||
{
|
||||
$this->pcg_subtype = 'XXXXXX';
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
|
||||
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
|
||||
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
|
||||
$sql .= " , pcg_subtype = " . ($this->pcg_subtype ? "'" . $this->db->escape($this->pcg_subtype) . "'" : "null");
|
||||
$sql .= " , account_number = '" . $this->account_number . "'";
|
||||
$sql .= " , account_parent = '" . $this->account_parent . "'";
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
|
||||
$sql .= " SET code = " . ($this->code ? "'" . $this->db->escape($this->code) . "'" : "null");
|
||||
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
|
||||
$sql .= " , fk_accounting_category = '" . $this->account_category . "'";
|
||||
$sql .= " , fk_user_modif = " . $user->id;
|
||||
$sql .= " , nature = " . ($this->nature ? "'" . $this->db->escape($this->nature) . "'" : "0");
|
||||
$sql .= " , active = '" . $this->active . "'";
|
||||
$sql .= " WHERE rowid = " . $this->id;
|
||||
|
||||
@ -268,7 +195,7 @@ class AccountingJournal extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Check usage of accounting code
|
||||
* Check usage of accounting journal
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
@ -287,7 +214,7 @@ class AccountingJournal extends CommonObject
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num > 0) {
|
||||
$this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse');
|
||||
$this->error = $langs->trans('ErrorAccountingJournalIsAlreadyUse');
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
@ -329,7 +256,7 @@ class AccountingJournal extends CommonObject
|
||||
// }
|
||||
|
||||
if (! $error) {
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account";
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_journal";
|
||||
$sql .= " WHERE rowid=" . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql);
|
||||
@ -360,85 +287,47 @@ class AccountingJournal extends CommonObject
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @return string Chaine avec URL
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
function getNomUrl($withpicto = 0) {
|
||||
global $langs;
|
||||
|
||||
$result = '';
|
||||
|
||||
$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id . '">';
|
||||
$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/journals_card.php?id=' . $this->id . '">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$picto = 'billr';
|
||||
|
||||
$label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label;
|
||||
$label = $langs->trans("Show") . ': ' . $this->code . ' - ' . $this->label;
|
||||
|
||||
if ($withpicto)
|
||||
$result .= ($link . img_object($label, $picto) . $linkend);
|
||||
if ($withpicto && $withpicto != 2)
|
||||
$result .= ' ';
|
||||
if ($withpicto != 2)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
$result .= $link . length_accountg($this->account_number) . ' - ' . $this->label . $linkend;
|
||||
$result .= $link . $this->code . ' - ' . $this->label . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information on record
|
||||
*
|
||||
* @param int $id of record
|
||||
* @return void
|
||||
*/
|
||||
function info($id) {
|
||||
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a';
|
||||
$sql .= ' WHERE a.rowid = ' . $id;
|
||||
|
||||
dol_syslog(get_class($this) . '::info sql=' . $sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db);
|
||||
$muser->fetch($obj->fk_user_modif);
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->tms);
|
||||
}
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Account desactivate
|
||||
* Deactivate journal
|
||||
*
|
||||
* @param int $id Id
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function account_desactivate($id) {
|
||||
function journal_deactivate($id) {
|
||||
$result = $this->checkUsage();
|
||||
|
||||
if ($result > 0) {
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
|
||||
$sql .= "SET active = '0'";
|
||||
$sql .= " WHERE rowid = " . $this->db->escape($id);
|
||||
|
||||
dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
|
||||
dol_syslog(get_class($this) . "::deactivate sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
@ -455,15 +344,15 @@ class AccountingJournal extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Account activate
|
||||
* Activate journal
|
||||
*
|
||||
* @param int $id Id
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function account_activate($id) {
|
||||
function journal_activate($id) {
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
|
||||
$sql .= "SET active = '1'";
|
||||
$sql .= " WHERE rowid = " . $this->db->escape($id);
|
||||
|
||||
|
||||
@ -91,6 +91,35 @@ function accounting_prepare_head(AccountingAccount $object)
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param AccountingAccount $object Accounting account
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function accounting_journal_prepare_head(AccountingJournal $object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array ();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/journals_card.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h ++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_journal');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_journal', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accounting account without zero on the right
|
||||
*
|
||||
|
||||
@ -199,13 +199,17 @@ ApplyMassCategories=Apply mass categories
|
||||
AddAccountFromBookKeepingWithNoCategories=Add acccount already used with no categories
|
||||
CategoryDeleted=Category for the accounting account has been removed
|
||||
AccountingJournals=Accounting journals
|
||||
AccountingJournal=Accounting journal
|
||||
NewAccountingJournal=New accounting journal
|
||||
ShowAccoutingJournal=Show accounting journal
|
||||
Code=Code
|
||||
Nature=Nature
|
||||
AccountingJournalTypeVariousOperation=Various operation
|
||||
AccountingJournalTypeSale=Sale
|
||||
AccountingJournalTypePurchase=Purchase
|
||||
AccountingJournalTypeBank=Bank
|
||||
AccountingJournalTypeHasNew=Has-new
|
||||
ErrorAccountingJournalIsAlreadyUse=This journal is already use
|
||||
|
||||
## Export
|
||||
Exports=Exports
|
||||
|
||||
Loading…
Reference in New Issue
Block a user