28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
36$langs->loadLangs(array(
"bills",
"accountancy",
"compta"));
39$cancel =
GETPOST(
'cancel',
'alpha');
40$action =
GETPOST(
'action',
'aZ09');
42$selectcpt =
GETPOST(
'cpt_bk',
'array');
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
58$offset = $limit * $page;
62if (empty($sortfield)) {
63 $sortfield =
'account_number';
65if (empty($sortorder)) {
70if (!$user->hasRight(
'accounting',
'chartofaccount')) {
82if (!empty($selectcpt)) {
84 foreach ($selectcpt as $selectedoption) {
85 if (!array_key_exists($selectedoption, $cpts)) {
86 $cpts[$selectedoption] =
"'".$selectedoption.
"'";
90 $return = $accountingcategory->updateAccAcc($cat_id, $cpts);
93 setEventMessages($langs->trans(
'errors'), $accountingcategory->errors,
'errors');
95 setEventMessages($langs->trans(
'RecordModifiedSuccessfully'),
null,
'mesgs');
99if ($action ==
'delete') {
101 if ($accountingcategory->deleteCptCat($cpt_id)) {
114$form =
new Form($db);
117$title= $langs->trans(
'AccountingCategory');
118$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
122$linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
123$titlepicto =
'setup';
125print
load_fiche_titre($langs->trans(
'AccountingCategory'), $linkback, $titlepicto);
127print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
128print
'<input type="hidden" name="token" value="'.newToken().
'">';
129print
'<input type="hidden" name="action" value="display">';
133print
'<table class="border centpercent">';
136print
'<tr><td class="titlefield">'.$langs->trans(
"AccountingCategory").
'</td>';
138$s = $formaccounting->select_accounting_category($cat_id,
'account_category', 1, 0, 0, 0);
139if ($formaccounting->nbaccounts_category <= 0) {
140 print
'<span class="opacitymedium">'.$s.
'</span>';
143 print
'<input type="submit" class="button small" value="'.$langs->trans(
"Select").
'">';
153if (!empty($cat_id)) {
154 $return = $accountingcategory->getAccountsWithNoCategory($cat_id);
160 $arraykeyvalue = array();
161 foreach ($accountingcategory->lines_cptbk as $key => $val) {
162 $doc_ref = !empty($val->doc_ref) ? $val->doc_ref :
'';
163 $arraykeyvalue[
length_accountg($val->numero_compte)] =
length_accountg($val->numero_compte) .
' - ' . $val->label_compte . ($doc_ref ?
' '.$doc_ref :
'');
166 if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
167 print
img_picto($langs->trans(
"AccountingAccount"),
'accounting_account',
'class="pictofixedwith"');
168 print $form->multiselectarray(
'cpt_bk', $arraykeyvalue,
GETPOST(
'cpt_bk',
'array'), 0, 0,
'', 0,
"80%",
'',
'', $langs->transnoentitiesnoconv(
"AddAccountFromBookKeepingWithNoCategories"));
169 print
'<input type="submit" class="button button-add small" id="" class="action-delete" value="'.$langs->trans(
"Add").
'"> ';
176if ((empty($action) || $action ==
'display' || $action ==
'delete') && $cat_id > 0) {
177 $param =
'account_category='.((int) $cat_id);
180 print
'<table class="noborder centpercent">'.
"\n";
181 print
'<tr class="liste_titre">';
182 print
getTitleFieldOfList(
'AccountAccounting', 0, $_SERVER[
'PHP_SELF'],
'account_number',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
183 print
getTitleFieldOfList(
'Label', 0, $_SERVER[
'PHP_SELF'],
'label',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
184 print
getTitleFieldOfList(
'', 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
187 if (!empty($cat_id)) {
188 $return = $accountingcategory->display($cat_id);
193 if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
194 $accountingcategory->lines_display =
dol_sort_array($accountingcategory->lines_display, $sortfield, $sortorder, -1, 0, 1);
196 foreach ($accountingcategory->lines_display as $cpt) {
197 print
'<tr class="oddeven">';
198 print
'<td>'.length_accountg($cpt->account_number).
'</td>';
199 print
'<td>'.$cpt->label.
'</td>';
200 print
'<td class="right">';
201 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&account_category='.$cat_id.
'&cptid='.$cpt->rowid.
'">';
202 print $langs->trans(
"DeleteFromCat");
203 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'class="paddingleft"');
209 print
'<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories of an accounting account.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.