|
@@ -46,7 +46,7 @@ $cancel = GETPOST('cancel');
|
|
|
if (! $user->admin)
|
|
|
accessforbidden();
|
|
|
|
|
|
-$accounting = new AccountingAccount($db);
|
|
|
+$object = new AccountingAccount($db);
|
|
|
|
|
|
// Action
|
|
|
if ($action == 'add') {
|
|
@@ -57,16 +57,16 @@ if ($action == 'add') {
|
|
|
$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');
|
|
|
- $accounting->account_number = GETPOST('account_number');
|
|
|
- $accounting->account_parent = GETPOST('account_parent', 'int');
|
|
|
- $accounting->account_category = GETPOST('account_category', 'int');
|
|
|
- $accounting->label = GETPOST('label', 'alpha');
|
|
|
- $accounting->active = 1;
|
|
|
+ $object->fk_pcg_version = $obj->pcg_version;
|
|
|
+ $object->pcg_type = GETPOST('pcg_type');
|
|
|
+ $object->pcg_subtype = GETPOST('pcg_subtype');
|
|
|
+ $object->account_number = GETPOST('account_number');
|
|
|
+ $object->account_parent = GETPOST('account_parent', 'int');
|
|
|
+ $object->account_category = GETPOST('account_category');
|
|
|
+ $object->label = GETPOST('label', 'alpha');
|
|
|
+ $object->active = 1;
|
|
|
|
|
|
- $res = $accounting->create($user);
|
|
|
+ $res = $object->create($user);
|
|
|
|
|
|
if ($res == 0) {
|
|
|
} else {
|
|
@@ -83,7 +83,7 @@ if ($action == 'add') {
|
|
|
Header("Location: account.php");
|
|
|
} else if ($action == 'edit') {
|
|
|
if (! GETPOST('cancel', 'alpha')) {
|
|
|
- $result = $accounting->fetch($id);
|
|
|
+ $result = $object->fetch($id);
|
|
|
|
|
|
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
|
|
|
|
|
@@ -91,15 +91,15 @@ if ($action == 'add') {
|
|
|
$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');
|
|
|
- $accounting->account_parent = GETPOST('account_parent', 'int');
|
|
|
- $accounting->account_category = GETPOST('account_category', 'int');
|
|
|
- $accounting->label = GETPOST('label', 'alpha');
|
|
|
+ $object->fk_pcg_version = $obj->pcg_version;
|
|
|
+ $object->pcg_type = GETPOST('pcg_type');
|
|
|
+ $object->pcg_subtype = GETPOST('pcg_subtype');
|
|
|
+ $object->account_number = GETPOST('account_number');
|
|
|
+ $object->account_parent = GETPOST('account_parent', 'int');
|
|
|
+ $object->account_category = GETPOST('account_category');
|
|
|
+ $object->label = GETPOST('label', 'alpha');
|
|
|
|
|
|
- $result = $accounting->update($user);
|
|
|
+ $result = $object->update($user);
|
|
|
|
|
|
if ($result > 0) {
|
|
|
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
|
|
@@ -112,10 +112,10 @@ if ($action == 'add') {
|
|
|
exit();
|
|
|
}
|
|
|
} else if ($action == 'delete') {
|
|
|
- $result = $accounting->fetch($id);
|
|
|
+ $result = $object->fetch($id);
|
|
|
|
|
|
- if (! empty($accounting->id)) {
|
|
|
- $result = $accounting->delete($user);
|
|
|
+ if (! empty($object->id)) {
|
|
|
+ $result = $object->delete($user);
|
|
|
|
|
|
if ($result > 0) {
|
|
|
Header("Location: account.php");
|
|
@@ -123,7 +123,7 @@ if ($action == 'add') {
|
|
|
}
|
|
|
|
|
|
if ($result < 0) {
|
|
|
- setEventMessages($accounting->error, $accounting->errors, 'errors');
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -150,34 +150,34 @@ if ($action == 'create') {
|
|
|
|
|
|
// Account number
|
|
|
print '<tr><td width="25%"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
|
|
|
- print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
|
|
|
+ print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
|
|
|
|
|
|
// Label
|
|
|
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
|
|
|
- print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
|
|
|
+ print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
|
|
|
|
|
|
// Account parent
|
|
|
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
|
|
print '<td>';
|
|
|
- print $htmlacc->select_account($accounting->account_parent, 'account_parent', 1);
|
|
|
+ print $htmlacc->select_account($object->account_parent, 'account_parent', 1);
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Category
|
|
|
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
|
|
|
print '<td>';
|
|
|
- $formaccounting->select_accounting_category($accounting->fk_accounting_category, 'account_category', 1);
|
|
|
+ $formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Chart of accounts type
|
|
|
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
|
|
print '<td>';
|
|
|
- print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
|
|
|
+ print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type');
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Chart of acounts subtype
|
|
|
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
|
|
print '<td>';
|
|
|
- print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
|
|
|
+ print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype');
|
|
|
print '</td></tr>';
|
|
|
|
|
|
print '</table>';
|
|
@@ -192,13 +192,12 @@ if ($action == 'create') {
|
|
|
|
|
|
print '</form>';
|
|
|
} else if ($id) {
|
|
|
- $rowid = $id;
|
|
|
- $account = $accounting->fetch($rowid);
|
|
|
+ $result = $object->fetch($id);
|
|
|
|
|
|
- if ($account > 0) {
|
|
|
+ if ($result > 0) {
|
|
|
dol_htmloutput_mesg($mesg);
|
|
|
|
|
|
- $head = accounting_prepare_head($accounting);
|
|
|
+ $head = accounting_prepare_head($object);
|
|
|
|
|
|
// Edit mode
|
|
|
if ($action == 'update') {
|
|
@@ -218,34 +217,34 @@ if ($action == 'create') {
|
|
|
|
|
|
// Account number
|
|
|
print '<tr><td width="25%"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
|
|
|
- print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
|
|
|
+ print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
|
|
|
|
|
|
// Label
|
|
|
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
|
|
|
- print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
|
|
|
+ print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
|
|
|
|
|
|
// Account parent
|
|
|
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
|
|
print '<td>';
|
|
|
- print $htmlacc->select_account($accounting->account_parent, 'account_parent', 1);
|
|
|
+ print $htmlacc->select_account($object->account_parent, 'account_parent', 1);
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Category
|
|
|
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
|
|
|
print '<td>';
|
|
|
- $formaccounting->select_accounting_category($accounting->fk_accounting_category, 'account_category', 1);
|
|
|
+ $formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Chart of accounts type
|
|
|
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
|
|
print '<td>';
|
|
|
- print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
|
|
|
+ print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type');
|
|
|
print '</td></tr>';
|
|
|
|
|
|
// Chart of accounts subtype
|
|
|
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
|
|
print '<td>';
|
|
|
- print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
|
|
|
+ print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype');
|
|
|
print '</td></tr>';
|
|
|
|
|
|
print '</table>';
|
|
@@ -270,37 +269,37 @@ if ($action == 'create') {
|
|
|
|
|
|
// Account number
|
|
|
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
|
|
|
- print '<td>' . $accounting->account_number . '</td>';
|
|
|
+ print '<td>' . $object->account_number . '</td>';
|
|
|
print '<td align="right" width="25%">' . $linkback . '</td></tr>';
|
|
|
|
|
|
// Label
|
|
|
print '<tr><td>' . $langs->trans("Label") . '</td>';
|
|
|
- print '<td colspan="2">' . $accounting->label . '</td></tr>';
|
|
|
+ print '<td colspan="2">' . $object->label . '</td></tr>';
|
|
|
|
|
|
// Account parent
|
|
|
$accp = new AccountingAccount($db);
|
|
|
- if (! empty($accounting->account_parent)) {
|
|
|
- $accp->fetch($accounting->account_parent, '');
|
|
|
+ if (! empty($object->account_parent)) {
|
|
|
+ $accp->fetch($object->account_parent, '');
|
|
|
}
|
|
|
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
|
|
print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
|
|
|
|
|
|
// Category
|
|
|
- print "<tr><td>".$langs->trans("AccountingCategory")."</td><td colspan='2'>".$accounting->accounting_category_label."</td>";
|
|
|
+ print "<tr><td>".$langs->trans("AccountingCategory")."</td><td colspan='2'>".$object->account_category_label."</td>";
|
|
|
|
|
|
// Chart of accounts type
|
|
|
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
|
|
- print '<td colspan="2">' . $accounting->pcg_type . '</td></tr>';
|
|
|
+ print '<td colspan="2">' . $object->pcg_type . '</td></tr>';
|
|
|
|
|
|
// Chart of accounts subtype
|
|
|
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
|
|
- print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
|
|
|
+ print '<td colspan="2">' . $object->pcg_subtype . '</td></tr>';
|
|
|
|
|
|
// Active
|
|
|
print '<tr><td>' . $langs->trans("Activated") . '</td>';
|
|
|
print '<td colspan="2">';
|
|
|
|
|
|
- if (empty($accounting->active)) {
|
|
|
+ if (empty($object->active)) {
|
|
|
print img_picto($langs->trans("Disabled"), 'switch_off');
|
|
|
} else {
|
|
|
print img_picto($langs->trans("Activated"), 'switch_on');
|