From 2ce4ba99fe4893c535c41d72c98aad9128fc2b0c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 1 Feb 2017 06:54:01 +0100 Subject: [PATCH] Fix : [FP17] Correct some fix on category accounting account page --- htdocs/accountancy/admin/categories.php | 82 +++++++++---------- .../class/accountancycategory.class.php | 9 +- htdocs/langs/en_US/accountancy.lang | 2 + 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 12d9a707cbd..d052b4312a7 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2016 Jamal Elbaz + * Copyright (C) 2017 Alexandre Spangaro * * 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 '
' . "\n"; @@ -102,22 +97,23 @@ print ''; print ''; print ''; 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 ''; + print ''; print ''; } @@ -131,26 +127,30 @@ print ''; if ($action == 'display' || $action == 'delete') { - print '
' . $langs->trans("AccountingCategory") . ''; $formaccounting->select_accounting_category($cat_id, 'account_category', 1); -print ''; +print ''; print '
' . $langs->trans("AddCompteFromBK") . '
' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . ''; - if (is_array($AccCat->lines_cptbk) && count($AccCat->lines_cptbk) > 0) { + if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { print ' - '; + print ''; + print ' '; } print '
'; - - print ''; + print "
' . $langs->trans("Numerocompte") . '' . $langs->trans("Description") . 'Action
\n"; + print ''; + print '"; + print '"; + print "\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 ''; print ''; 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 '"; print "\n"; - $j ++; } } } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 40290bd845b..b2564c342e5 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016-2017 Alexandre Spangaro * * 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 @@ -17,9 +17,9 @@ */ /** - * \file htdocs/accountancy/class/accountancycategory.class.php + * \file htdocs/accountancy/class/accountancycategory.class.php * \ingroup Advanced accountancy - * \brief File of class to manage categories of an accounting category_type + * \brief File of class to manage categories of an accounting category_type */ // Class @@ -72,7 +72,6 @@ class AccountancyCategory $this->lines_display[] = $obj; } } - return $num; } else { $this->error = "Error " . $this->db->lasterror(); @@ -84,7 +83,7 @@ class AccountancyCategory } /** - * Function to select accountiing category of an accounting account present in chart of accounts + * Function to select accounting category of an accounting account present in chart of accounts * * @param int $id Id category * diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index dcefae7aecb..5ee68e605cd 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -194,6 +194,8 @@ ChangeBinding=Change the binding ## Admin ApplyMassCategories=Apply mass categories +AddAccountFromBookKeepingWithNoCategories=Add acccount already used with no categories +CategoryDeleted=Category for the accounting account has been removed ## Export Exports=Exports
'.$langs->trans("AccountAccounting")."'.$langs->trans("Label")."
' . length_accountg($cpt->account_number) . '' . $cpt->label . ''; + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + print "