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->label = GETPOST('label', 'alpha');
|
||||||
$object->nature = GETPOST('nature', 'int');
|
$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);
|
$result = $object->update($user);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
@ -161,15 +170,15 @@ if ($action == 'create')
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Code
|
// 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
|
// 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
|
// Nature
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="fieldrequired">' . $langs->trans("Status") . '</td>';
|
print '<td class="fieldrequired">' . $langs->trans("Type") . '</td>';
|
||||||
print '<td class="valeur">';
|
print '<td class="valeur">';
|
||||||
print $form->selectarray('nature', $type2label, GETPOST('nature'));
|
print $form->selectarray('nature', $type2label, GETPOST('nature'));
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -188,10 +197,10 @@ if ($action == 'create')
|
|||||||
} else if ($id) {
|
} else if ($id) {
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$head = fiscalyear_prepare_head($object);
|
$head = accounting_journal_prepare_head($object);
|
||||||
|
|
||||||
if ($action == 'edit') {
|
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 '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
||||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||||
@ -200,10 +209,10 @@ if ($action == 'create')
|
|||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Code
|
||||||
print "<tr>";
|
print "<tr>";
|
||||||
print '<td class="titlefieldcreate titlefield">' . $langs->trans("Ref") . '</td><td>';
|
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Code") . '</td><td>';
|
||||||
print $object->ref;
|
print '<input name="code" class="flat" size="8" value="' . $object->code . '">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
@ -211,20 +220,9 @@ if ($action == 'create')
|
|||||||
print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
|
print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
|
||||||
print '</td></tr>';
|
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
|
// Nature
|
||||||
print '<tr><td>' . $langs->trans("Type") . '</td><td>';
|
print '<tr><td>' . $langs->trans("Type") . '</td><td>';
|
||||||
// print $form->selectarray('statut', $statut2label, $object->statut);
|
print $form->selectarray('nature', $type2label, $object->nature);
|
||||||
print $object->getLibStatut(4);
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
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");
|
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%">';
|
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
|
// Ref
|
||||||
print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td width="50%">';
|
print '<tr><td class="titlefield">' . $langs->trans("Code") . '</td><td width="50%">';
|
||||||
print $object->ref;
|
print $object->code;
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print $linkback;
|
print $linkback;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -267,7 +265,7 @@ if ($action == 'create')
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Nature
|
// 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>";
|
print "</table>";
|
||||||
|
|
||||||
@ -282,7 +280,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
|
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>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,23 +26,17 @@
|
|||||||
*/
|
*/
|
||||||
class AccountingJournal extends CommonObject
|
class AccountingJournal extends CommonObject
|
||||||
{
|
{
|
||||||
var $db;
|
public $element='accounting_journal';
|
||||||
var $error;
|
public $table_element='accounting_journal';
|
||||||
var $errors;
|
public $fk_element = '';
|
||||||
var $id;
|
protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
|
|
||||||
var $rowid;
|
var $rowid;
|
||||||
var $datec; // Creation date
|
|
||||||
var $fk_pcg_version;
|
var $code;
|
||||||
var $pcg_type;
|
|
||||||
var $pcg_subtype;
|
|
||||||
var $account_number;
|
|
||||||
var $account_parent;
|
|
||||||
var $account_category;
|
|
||||||
var $label;
|
var $label;
|
||||||
var $fk_user_author;
|
var $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 9: has-new
|
||||||
var $fk_user_modif;
|
var $active;
|
||||||
var $active; // duplicate with status
|
|
||||||
var $status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -54,133 +48,75 @@ class AccountingJournal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load record in memory
|
* Load an object from database
|
||||||
*
|
*
|
||||||
* @param int $rowid Id
|
* @param int $id Id of record to load
|
||||||
* @param string $account_number Account number
|
* @return int <0 if KO, >0 if OK
|
||||||
* @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($id)
|
||||||
*/
|
{
|
||||||
function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) {
|
$sql = "SELECT rowid, code, label, nature, active";
|
||||||
global $conf;
|
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
|
||||||
|
$sql.= " WHERE rowid = ".$id;
|
||||||
|
|
||||||
if ($rowid || $account_number) {
|
dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
|
||||||
$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";
|
$result = $this->db->query($sql);
|
||||||
$sql .= ", ca.label as category_label";
|
if ( $result )
|
||||||
$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";
|
$obj = $this->db->fetch_object($result);
|
||||||
$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 . ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
|
$this->id = $obj->rowid;
|
||||||
$result = $this->db->query($sql);
|
|
||||||
if ($result) {
|
|
||||||
$obj = $this->db->fetch_object($result);
|
|
||||||
|
|
||||||
if ($obj) {
|
$this->code = $obj->code;
|
||||||
$this->id = $obj->rowid;
|
$this->ref = $obj->code;
|
||||||
$this->rowid = $obj->rowid;
|
$this->label = $obj->label;
|
||||||
$this->datec = $obj->datec;
|
$this->nature = $obj->nature;
|
||||||
$this->tms = $obj->tms;
|
$this->active = $obj->active;
|
||||||
$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;
|
return 1;
|
||||||
} else {
|
}
|
||||||
return 0;
|
else
|
||||||
}
|
{
|
||||||
} else {
|
$this->error=$this->db->lasterror();
|
||||||
$this->error = "Error " . $this->db->lasterror();
|
return -1;
|
||||||
$this->errors[] = "Error " . $this->db->lasterror();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert new accounting account in chart of accounts
|
* Insert journal in database
|
||||||
*
|
*
|
||||||
* @param User $user Use making action
|
* @param User $user Use making action
|
||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function create($user, $notrigger = 0) {
|
function create($user, $notrigger = 0)
|
||||||
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (isset($this->fk_pcg_version))
|
if (isset($this->code))
|
||||||
$this->fk_pcg_version = trim($this->fk_pcg_version);
|
$this->code = trim($this->code);
|
||||||
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->label))
|
if (isset($this->label))
|
||||||
$this->label = trim($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
|
// Check parameters
|
||||||
// Put here code to add control on parameters values
|
if (empty($this->nature) || $this->nature == '-1')
|
||||||
|
{
|
||||||
|
$this->nature = '0';
|
||||||
|
}
|
||||||
|
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account(";
|
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_journal(";
|
||||||
$sql .= "datec";
|
$sql .= "code";
|
||||||
$sql .= ", entity";
|
|
||||||
$sql .= ", fk_pcg_version";
|
|
||||||
$sql .= ", pcg_type";
|
|
||||||
$sql .= ", pcg_subtype";
|
|
||||||
$sql .= ", account_number";
|
|
||||||
$sql .= ", account_parent";
|
|
||||||
$sql .= ", label";
|
$sql .= ", label";
|
||||||
$sql .= ", fk_accounting_category";
|
$sql .= ", nature";
|
||||||
$sql .= ", fk_user_author";
|
|
||||||
$sql .= ", active";
|
$sql .= ", active";
|
||||||
$sql .= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
$sql .= " '" . $this->db->idate($now) . "'";
|
$sql .= " " . (empty($this->code) ? 'NULL' : "'" . $this->db->escape($this->code) . "'");
|
||||||
$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->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
|
$sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
|
||||||
$sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'");
|
$sql .= ", " . (empty($this->nature) ? '0' : "'" . $this->db->escape($this->nature) . "'");
|
||||||
$sql .= ", " . $user->id;
|
|
||||||
$sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
|
$sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
@ -194,7 +130,7 @@ class AccountingJournal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $error) {
|
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) {
|
// if (! $notrigger) {
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
@ -232,26 +168,17 @@ class AccountingJournal extends CommonObject
|
|||||||
function update($user)
|
function update($user)
|
||||||
{
|
{
|
||||||
// Check parameters
|
// 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();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
|
||||||
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
|
$sql .= " SET code = " . ($this->code ? "'" . $this->db->escape($this->code) . "'" : "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 .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
|
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
|
||||||
$sql .= " , fk_accounting_category = '" . $this->account_category . "'";
|
$sql .= " , nature = " . ($this->nature ? "'" . $this->db->escape($this->nature) . "'" : "0");
|
||||||
$sql .= " , fk_user_modif = " . $user->id;
|
|
||||||
$sql .= " , active = '" . $this->active . "'";
|
$sql .= " , active = '" . $this->active . "'";
|
||||||
$sql .= " WHERE rowid = " . $this->id;
|
$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
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
@ -287,7 +214,7 @@ class AccountingJournal extends CommonObject
|
|||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
if ($num > 0) {
|
if ($num > 0) {
|
||||||
$this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse');
|
$this->error = $langs->trans('ErrorAccountingJournalIsAlreadyUse');
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
@ -329,7 +256,7 @@ class AccountingJournal extends CommonObject
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account";
|
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_journal";
|
||||||
$sql .= " WHERE rowid=" . $this->id;
|
$sql .= " WHERE rowid=" . $this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::delete sql=" . $sql);
|
dol_syslog(get_class($this) . "::delete sql=" . $sql);
|
||||||
@ -360,85 +287,47 @@ class AccountingJournal extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Return clicable name (with picto eventually)
|
* Return clicable name (with picto eventually)
|
||||||
*
|
*
|
||||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||||
* @return string Chaine avec URL
|
* @return string Chaine avec URL
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto = 0) {
|
function getNomUrl($withpicto = 0) {
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result = '';
|
$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>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
$picto = 'billr';
|
$picto = 'billr';
|
||||||
|
|
||||||
$label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label;
|
$label = $langs->trans("Show") . ': ' . $this->code . ' - ' . $this->label;
|
||||||
|
|
||||||
if ($withpicto)
|
if ($withpicto)
|
||||||
$result .= ($link . img_object($label, $picto) . $linkend);
|
$result .= ($link . img_object($label, $picto) . $linkend);
|
||||||
if ($withpicto && $withpicto != 2)
|
if ($withpicto && $withpicto != 2)
|
||||||
$result .= ' ';
|
$result .= ' ';
|
||||||
if ($withpicto != 2)
|
if ($withpicto != 2)
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
$result .= $link . $this->code . ' - ' . $this->label . $linkend;
|
||||||
$result .= $link . length_accountg($this->account_number) . ' - ' . $this->label . $linkend;
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information on record
|
* Deactivate journal
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*
|
*
|
||||||
* @param int $id Id
|
* @param int $id Id
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function account_desactivate($id) {
|
function journal_deactivate($id) {
|
||||||
$result = $this->checkUsage();
|
$result = $this->checkUsage();
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
|
||||||
$sql .= "SET active = '0'";
|
$sql .= "SET active = '0'";
|
||||||
$sql .= " WHERE rowid = " . $this->db->escape($id);
|
$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);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@ -455,15 +344,15 @@ class AccountingJournal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account activate
|
* Activate journal
|
||||||
*
|
*
|
||||||
* @param int $id Id
|
* @param int $id Id
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function account_activate($id) {
|
function journal_activate($id) {
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_journal ";
|
||||||
$sql .= "SET active = '1'";
|
$sql .= "SET active = '1'";
|
||||||
$sql .= " WHERE rowid = " . $this->db->escape($id);
|
$sql .= " WHERE rowid = " . $this->db->escape($id);
|
||||||
|
|
||||||
|
|||||||
@ -91,6 +91,35 @@ function accounting_prepare_head(AccountingAccount $object)
|
|||||||
return $head;
|
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
|
* Return accounting account without zero on the right
|
||||||
*
|
*
|
||||||
|
|||||||
@ -199,13 +199,17 @@ ApplyMassCategories=Apply mass categories
|
|||||||
AddAccountFromBookKeepingWithNoCategories=Add acccount already used with no categories
|
AddAccountFromBookKeepingWithNoCategories=Add acccount already used with no categories
|
||||||
CategoryDeleted=Category for the accounting account has been removed
|
CategoryDeleted=Category for the accounting account has been removed
|
||||||
AccountingJournals=Accounting journals
|
AccountingJournals=Accounting journals
|
||||||
|
AccountingJournal=Accounting journal
|
||||||
NewAccountingJournal=New accounting journal
|
NewAccountingJournal=New accounting journal
|
||||||
ShowAccoutingJournal=Show accounting journal
|
ShowAccoutingJournal=Show accounting journal
|
||||||
|
Code=Code
|
||||||
|
Nature=Nature
|
||||||
AccountingJournalTypeVariousOperation=Various operation
|
AccountingJournalTypeVariousOperation=Various operation
|
||||||
AccountingJournalTypeSale=Sale
|
AccountingJournalTypeSale=Sale
|
||||||
AccountingJournalTypePurchase=Purchase
|
AccountingJournalTypePurchase=Purchase
|
||||||
AccountingJournalTypeBank=Bank
|
AccountingJournalTypeBank=Bank
|
||||||
AccountingJournalTypeHasNew=Has-new
|
AccountingJournalTypeHasNew=Has-new
|
||||||
|
ErrorAccountingJournalIsAlreadyUse=This journal is already use
|
||||||
|
|
||||||
## Export
|
## Export
|
||||||
Exports=Exports
|
Exports=Exports
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user