diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index d555ed46092..51517993bb5 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -23,12 +23,14 @@ * \brief Card accounting account */ require '../../main.inc.php'; - + // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +$error=0; + // Langs $langs->load("bills"); $langs->load("accountancy"); @@ -41,7 +43,7 @@ $rowid = GETPOST('rowid', 'int'); // Security check if (!$user->admin) accessforbidden(); - + $accounting = new AccountingAccount($db); // Action @@ -49,11 +51,11 @@ if ($action == 'add') { if (! GETPOST('cancel', 'alpha')) { $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result = $db->query($sql); $obj = $db->fetch_object($result); - + $accounting->fk_pcg_version = $obj->pcg_version; $accounting->pcg_type = GETPOST('pcg_type'); $accounting->pcg_subtype = GETPOST('pcg_subtype'); @@ -61,17 +63,17 @@ if ($action == 'add') $accounting->account_parent = GETPOST('account_parent', 'int'); $accounting->label = GETPOST('label', 'alpha'); $accounting->active = 1; - + $res = $accounting->create($user); - + if ($res == 0) { } else { if ($res == - 3) { - $_error = 1; + $error = 1; $action = "create"; } if ($res == - 4) { - $_error = 2; + $error = 2; $action = "create"; } } @@ -82,22 +84,22 @@ else if ($action == 'edit') { if (! GETPOST('cancel', 'alpha')) { $result = $accounting->fetch($id); - + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); $obj = $db->fetch_object($result2); - + $accounting->fk_pcg_version = $obj->pcg_version; $accounting->pcg_type = GETPOST('pcg_type'); $accounting->pcg_subtype = GETPOST('pcg_subtype'); $accounting->account_number = GETPOST('account_number', 'int'); $accounting->account_parent = GETPOST('account_parent', 'int'); $accounting->label = GETPOST('label', 'alpha'); - + $result = $accounting->update($user); - + if ($result > 0) { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); @@ -112,15 +114,15 @@ else if ($action == 'edit') else if ($action == 'delete') { $result = $accounting->fetch($id); - + if (! empty($accounting->id)) { $result = $accounting->delete($user); - + if ($result > 0) { Header("Location: account.php"); } } - + if ($result < 0) { setEventMessage($accounting->error, 'errors'); } @@ -137,7 +139,7 @@ $htmlacc = new FormVentilation($db); if ($action == 'create') { print_fiche_titre($langs->trans('NewAccount')); - + print '
'; } else if ($id) { $rowid = $id; $account = $accounting->fetch($rowid); - + if ($account > 0) { dol_htmloutput_mesg($mesg); - + $head = accounting_prepare_head($accounting); - + if ($action == 'update') { $soc = new Societe($db); if ($object->socid) { $soc->fetch($object->socid); } - + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - + print ''; } else { $linkback = '' . $langs->trans("BackToChartofaccounts") . ''; - + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - + print '| ' . $langs->trans("AccountNumber") . ' | '; print '' . $accounting->account_number . ' | '; print '' . $linkback . ' |
| ' . $langs->trans("Label") . ' | '; print '' . $accounting->label . ' | |
| ' . $langs->trans("Accountparent") . ' | '; print '' . $accp->account_number . ' - ' . $accp->label . ' | |
| ' . $langs->trans("Pcgtype") . ' | '; print '' . $accounting->pcg_type . ' | |
| ' . $langs->trans("Pcgsubtype") . ' | '; print '' . $accounting->pcg_subtype . ' | |
| ' . $langs->trans("Active") . ' | '; print ''; - + if (empty($accounting->active)) { print img_picto($langs->trans("Disabled"), 'switch_off'); } else { print img_picto($langs->trans("Activated"), 'switch_on'); } - + print ' | |