|
@@ -1,5 +1,6 @@
|
|
|
<?php
|
|
|
-/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
|
|
+/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
|
|
+ * Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
|
|
*
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
@@ -16,24 +17,24 @@
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * \file htdocs/accountancy/admin/categories.php
|
|
|
+ * \file htdocs/accountancy/admin/categories.php
|
|
|
* \ingroup Advanced accountancy
|
|
|
- * \brief Page to assign mass categories to accounts
|
|
|
+ * \brief Page to assign mass categories to accounts
|
|
|
*/
|
|
|
require '../../main.inc.php';
|
|
|
-
|
|
|
-// Class
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
|
|
|
|
|
$error = 0;
|
|
|
|
|
|
-// Langs
|
|
|
$langs->load("bills");
|
|
|
$langs->load("accountancy");
|
|
|
|
|
|
$mesg = '';
|
|
|
+$id = GETPOST('id', 'int');
|
|
|
+$rowid = GETPOST('rowid', 'int');
|
|
|
+$cancel = GETPOST('cancel');
|
|
|
$action = GETPOST('action');
|
|
|
$cat_id = GETPOST('account_category');
|
|
|
$selectcpt = GETPOST('cpt_bk', 'array');
|
|
@@ -43,36 +44,31 @@ if ($cat_id == 0) {
|
|
|
$cat_id = null;
|
|
|
}
|
|
|
|
|
|
-$id = GETPOST('id', 'int');
|
|
|
-$rowid = GETPOST('rowid', 'int');
|
|
|
-$cancel = GETPOST('cancel');
|
|
|
-
|
|
|
// Security check
|
|
|
-if (! $user->admin)
|
|
|
- accessforbidden();
|
|
|
+if (! $user->admin) accessforbidden();
|
|
|
|
|
|
-$AccCat = new AccountancyCategory($db);
|
|
|
+$accountingcategory = new AccountancyCategory($db);
|
|
|
|
|
|
// si ajout de comptes
|
|
|
if (! empty($selectcpt)) {
|
|
|
$cpts = array ();
|
|
|
- foreach ( $selectcpt as $selectedOption ) {
|
|
|
- if (! array_key_exists($selectedOption, $cpts))
|
|
|
- $cpts[$selectedOption] = "'" . $selectedOption . "'";
|
|
|
+ foreach ( $selectcpt as $selectedoption ) {
|
|
|
+ if (! array_key_exists($selectedoption, $cpts))
|
|
|
+ $cpts[$selectedoption] = "'" . $selectedoption . "'";
|
|
|
}
|
|
|
|
|
|
- $return= $AccCat->updateAccAcc($cat_id, $cpts);
|
|
|
+ $return= $accountingcategory->updateAccAcc($cat_id, $cpts);
|
|
|
|
|
|
if ($return<0) {
|
|
|
- setEventMessages($langs->trans('errors'), $AccCat->errors, 'errors');
|
|
|
+ setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
|
|
|
} else {
|
|
|
setEventMessages($langs->trans('Saved'), null, 'mesgs');
|
|
|
}
|
|
|
}
|
|
|
if ($action == 'delete') {
|
|
|
if ($cpt_id) {
|
|
|
- if ($AccCat->deleteCptCat($cpt_id)) {
|
|
|
- setEventMessages($langs->trans('Deleted'), null, 'mesgs');
|
|
|
+ if ($accountingcategory->deleteCptCat($cpt_id)) {
|
|
|
+ setEventMessages($langs->trans('CategoryDeleted'), null, 'mesgs');
|
|
|
} else {
|
|
|
setEventMessages($langs->trans('errors'), null, 'errors');
|
|
|
}
|
|
@@ -83,12 +79,11 @@ if ($action == 'delete') {
|
|
|
/*
|
|
|
* View
|
|
|
*/
|
|
|
+$form = new Form($db);
|
|
|
+$formaccounting = new FormAccounting($db);
|
|
|
|
|
|
llxheader('', $langs->trans('AccountAccounting'));
|
|
|
|
|
|
-$formaccounting = new FormAccounting($db);
|
|
|
-$form = new Form($db);
|
|
|
-
|
|
|
print load_fiche_titre($langs->trans('Categories'));
|
|
|
|
|
|
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
|
@@ -102,22 +97,23 @@ print '<table class="border" width="100%">';
|
|
|
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
|
|
|
print '<td>';
|
|
|
$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
|
|
|
-print '<input class="button" type="submit" value="' . $langs->trans("Display") . '">';
|
|
|
+print '<input class="button" type="submit" value="' . $langs->trans("Show") . '">';
|
|
|
print '</td></tr>';
|
|
|
|
|
|
if (! empty($cat_id)) {
|
|
|
- $return = $AccCat->getCptBK($cat_id);
|
|
|
+ $return = $accountingcategory->getCptBK($cat_id);
|
|
|
if ($return < 0) {
|
|
|
- setEventMessages(null, $AccCat->errors, 'errors');
|
|
|
+ setEventMessages(null, $accountingcategory->errors, 'errors');
|
|
|
}
|
|
|
- print '<tr><td>' . $langs->trans("AddCompteFromBK") . '</td>';
|
|
|
+ print '<tr><td>' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '</td>';
|
|
|
print '<td>';
|
|
|
- if (is_array($AccCat->lines_cptbk) && count($AccCat->lines_cptbk) > 0) {
|
|
|
+ if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
|
|
|
print '<select size="' . count($obj) . '" name="cpt_bk[]" multiple>';
|
|
|
- foreach ( $AccCat->lines_cptbk as $cpt ) {
|
|
|
+ foreach ( $accountingcategory->lines_cptbk as $cpt ) {
|
|
|
print '<option value="' . length_accountg($cpt->numero_compte) . '">' . length_accountg($cpt->numero_compte) . ' (' . $cpt->label_compte . ' ' . $cpt->doc_ref . ')</option>';
|
|
|
}
|
|
|
- print '</select> - <input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("add") . '"> ';
|
|
|
+ print '</select>';
|
|
|
+ print '<input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("Add") . '"> ';
|
|
|
}
|
|
|
print '</td></tr>';
|
|
|
}
|
|
@@ -131,26 +127,30 @@ print '</form>';
|
|
|
|
|
|
if ($action == 'display' || $action == 'delete') {
|
|
|
|
|
|
- print '<table class="noborder" width="100%">';
|
|
|
-
|
|
|
- print '<tr class="liste_titre"><th class="liste_titre">' . $langs->trans("Numerocompte") . '</th><th class="liste_titre">' . $langs->trans("Description") . '</th><th class="liste_titre" width="60" align="center">Action</th></tr>';
|
|
|
+ print "<table class='noborder' width='100%'>\n";
|
|
|
+ print '<tr class="liste_titre">';
|
|
|
+ print '<td>'.$langs->trans("AccountAccounting")."</td>";
|
|
|
+ print '<td colspan="2">'.$langs->trans("Label")."</td>";
|
|
|
+ print "</tr>\n";
|
|
|
|
|
|
if (! empty($cat_id)) {
|
|
|
- $return = $AccCat->display($cat_id);
|
|
|
+ $return = $accountingcategory->display($cat_id);
|
|
|
if ($return < 0) {
|
|
|
- setEventMessages(null, $AccCat->errors, 'errors');
|
|
|
+ setEventMessages(null, $accountingcategory->errors, 'errors');
|
|
|
}
|
|
|
- $j = 1;
|
|
|
- if (is_array($AccCat->lines_display) && count($AccCat->lines_display) > 0) {
|
|
|
- foreach ( $AccCat->lines_display as $cpt ) {
|
|
|
+
|
|
|
+ if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
|
|
|
+ foreach ( $accountingcategory->lines_display as $cpt ) {
|
|
|
$var = ! $var;
|
|
|
print '<tr' . $bc[$var] . '>';
|
|
|
print '<td>' . length_accountg($cpt->account_number) . '</td>';
|
|
|
print '<td>' . $cpt->label . '</td>';
|
|
|
- print $form->formconfirm($_SERVER["PHP_SELF"] . "?account_category=$cat_id&cptid=" . $cpt->rowid, $langs->trans("DeleteCptCategory"), $langs->trans("ConfirmDeleteCptCategory"), "delete", '', 0, "action-delete" . $j);
|
|
|
- print '<td><input class="button" type="button" id="action-delete' . $j . '" value="' . $langs->trans("Delete") . '"></td>';
|
|
|
+ print '<td align="right">';
|
|
|
+ print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
|
|
|
+ print img_delete($langs->trans("DeleteFromCat")).' ';
|
|
|
+ print $langs->trans("DeleteFromCat")."</a>";
|
|
|
+ print "</td>";
|
|
|
print "</tr>\n";
|
|
|
- $j ++;
|
|
|
}
|
|
|
}
|
|
|
}
|