diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php
index b1836836e84..e1a0e3fe052 100644
--- a/htdocs/accountancy/admin/categories.php
+++ b/htdocs/accountancy/admin/categories.php
@@ -16,9 +16,9 @@
*/
/**
- * \file htdocs/accountancy/admin/categories.php
- * \ingroup Advanced accountancy
- * \brief Page to assign mass categories to accounts
+ * \file htdocs/accountancy/admin/categories.php
+ * \ingroup Advanced accountancy
+ * \brief Page to assign mass categories to accounts
*/
require '../../main.inc.php';
@@ -36,11 +36,11 @@ $langs->load("accountancy");
$mesg = '';
$action = GETPOST('action');
$cat_id = GETPOST('account_category');
-$selectcpt = GETPOST('cpt_bk');
+$selectcpt = GETPOST('cpt_bk', 'array');
$cpt_id = GETPOST('cptid');
-if($cat_id == 0){
- $cat_id = null;
+if ($cat_id == 0) {
+ $cat_id = null;
}
$id = GETPOST('id', 'int');
@@ -54,31 +54,30 @@ if (! $user->admin)
$AccCat = new AccountancyCategory($db);
// si ajout de comptes
-if(!empty($selectcpt)){
- $cpts = array();
- $i = 0;
- foreach ($selectcpt as $selectedOption){
- $cpts[$i] = "'".$selectedOption."'";
- $i++;
+if (! empty($selectcpt)) {
+ $cpts = array ();
+ foreach ( $selectcpt as $selectedOption ) {
+ if (! array_key_exists($selectedOption, $cpts))
+ $cpts[$selectedOption] = "'" . $selectedOption . "'";
}
-
- if($AccCat->updateAccAcc($cat_id, $cpts)){
+
+ $return= $AccCat->updateAccAcc($cat_id, $cpts);
+
+ if ($return<0) {
+ setEventMessages($langs->trans('errors'), $AccCat->errors, 'errors');
+ } else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
- }else{
- setEventMessages($langs->trans('errors'), null, 'errors');
}
-
-
}
if ($action == 'delete') {
- if($cpt_id){
- if($AccCat->deleteCptCat($cpt_id)){
+ if ($cpt_id) {
+ if ($AccCat->deleteCptCat($cpt_id)) {
setEventMessages($langs->trans('Deleted'), null, 'mesgs');
- }else{
+ } else {
setEventMessages($langs->trans('errors'), null, 'errors');
}
}
-}
+}
/*
* View
@@ -88,65 +87,69 @@ llxheader('', $langs->trans('AccountAccounting'));
$formaccounting = new FormAccounting($db);
$form = new Form($db);
- print load_fiche_titre($langs->trans('Categories'));
+print load_fiche_titre($langs->trans('Categories'));
- print '
';
+dol_fiche_end();
+
+print '';
if ($action == 'display' || $action == 'delete') {
print '';
- print '| '.$langs->trans("Numerocompte").' | '.$langs->trans("Description").' | Action |
';
+ print '| ' . $langs->trans("Numerocompte") . ' | ' . $langs->trans("Description") . ' | Action |
';
- if(!empty($cat_id)){
- $obj = $AccCat->display($cat_id);
- $j=1;
- if(!empty($obj)){
- foreach ( $obj as $cpt ) {
+ if (! empty($cat_id)) {
+ $return = $AccCat->display($cat_id);
+ if ($return < 0) {
+ setEventMessages(null, $AccCat->errors, 'errors');
+ }
+ $j = 1;
+ if (is_array($AccCat->lines_display) && count($AccCat->lines_display) > 0) {
+ foreach ( $AccCat->lines_display as $cpt ) {
$var = ! $var;
- print '';
+ print '
';
print '| ' . length_accountg($cpt->account_number) . ' | ';
print '' . $cpt->label . ' | ';
- 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 ' | ';
+ 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 ' | ';
print "
\n";
- $j++;
+ $j ++;
}
- }
+ }
}
print "
";
diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 7293797ecc6..ba3c37f1997 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -18,9 +18,9 @@
*/
/**
- * \file htdocs/accountancy/bookkeeping/card.php
- * \ingroup Advanced accountancy
- * \brief Page to show book-entry
+ * \file htdocs/accountancy/bookkeeping/card.php
+ * \ingroup Advanced accountancy
+ * \brief Page to show book-entry
*/
require '../../main.inc.php';
@@ -62,17 +62,17 @@ if (! empty($update)) {
}
if ($action == "confirm_update") {
-
+
$error = 0;
-
+
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++;
}
-
+
if (empty($error)) {
$book = new BookKeeping($db);
-
+
$result = $book->fetch($id);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@@ -82,7 +82,7 @@ if ($action == "confirm_update") {
$book->label_compte = $label_compte;
$book->debit = $debit;
$book->credit = $credit;
-
+
if (floatval($debit) != 0.0) {
$book->montant = $debit;
$book->sens = 'D';
@@ -91,7 +91,7 @@ if ($action == "confirm_update") {
$book->montant = $credit;
$book->sens = 'C';
}
-
+
$result = $book->update($user);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@@ -101,19 +101,19 @@ if ($action == "confirm_update") {
}
}
}
-}
+}
else if ($action == "add") {
$error = 0;
-
+
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++;
}
-
+
if (empty($error)) {
$book = new BookKeeping($db);
-
+
$book->numero_compte = $account_number;
$book->code_tiers = $code_tiers;
$book->label_compte = $label_compte;
@@ -126,17 +126,17 @@ else if ($action == "add") {
$book->code_journal = GETPOST('code_journal');
$book->fk_doc = GETPOST('fk_doc');
$book->fk_docdet = GETPOST('fk_docdet');
-
+
if (floatval($debit) != 0.0) {
$book->montant = $debit;
$book->sens = 'D';
}
-
+
if (floatval($credit) != 0.0) {
$book->montant = $credit;
$book->sens = 'C';
}
-
+
$result = $book->createStd($user);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@@ -145,15 +145,15 @@ else if ($action == "add") {
$action = '';
}
}
-}
+}
else if ($action == "confirm_delete") {
$book = new BookKeeping($db);
-
+
$result = $book->fetch($id);
-
+
$piece_num = $book->piece_num;
-
+
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
} else {
@@ -163,11 +163,11 @@ else if ($action == "confirm_delete") {
}
}
$action = '';
-}
+}
else if ($action == "confirm_create") {
$book = new BookKeeping($db);
-
+
$book->label_compte = '';
$book->debit = 0;
$book->credit = 0;
@@ -178,9 +178,9 @@ else if ($action == "confirm_create") {
$book->code_journal = GETPOST('code_journal');
$book->fk_doc = 0;
$book->fk_docdet = 0;
-
+
$book->montant = 0;
-
+
$result = $book->createStd($user);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@@ -209,15 +209,15 @@ if ($action == 'delete') {
if ($action == 'create') {
print load_fiche_titre($langs->trans("CreateMvts"));
-
+
$code_journal_array = array (
$conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL,
$conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL,
$conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL,
$conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL,
- $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL
+ $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL
);
-
+
$sql = 'SELECT DISTINCT accountancy_journal FROM ' . MAIN_DB_PREFIX . 'bank_account WHERE clos=0';
$resql = $db->query($sql);
if (! $resql) {
@@ -229,52 +229,52 @@ if ($action == 'create') {
}
}
}
-
+
$book = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt();
-
+
print '';
} else {
$book = new BookKeeping($db);
@@ -283,9 +283,9 @@ if ($action == 'create') {
setEventMessages($book->error, $book->errors, 'errors');
}
if (! empty($book->piece_num)) {
-
+
print load_fiche_titre($langs->trans("UpdateMvts"), '' . $langs->trans('BackToList') . '');
-
+
print '';
print '';
print '| ' . $langs->trans("NumMvts") . ' | ';
@@ -309,14 +309,14 @@ if ($action == 'create') {
print '
';
print '
';
print '
';
-
+
$result = $book->fetch_all_per_mvt($piece_num);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
} else {
-
+
print load_fiche_titre($langs->trans("ListeMvts"));
-
+
print '