Go to the documentation of this file.
25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
33 $langs->loadLangs(array(
"bills",
"accountancy"));
36 $cancel =
GETPOST(
'cancel',
'alpha');
37 $action =
GETPOST(
'action',
'aZ09');
38 $cat_id =
GETPOST(
'account_category',
'int');
39 $selectcpt =
GETPOST(
'cpt_bk',
'array');
40 $cpt_id =
GETPOST(
'cptid',
'int');
47 if (empty($user->rights->accounting->chartofaccount)) {
59 if (!empty($selectcpt)) {
61 foreach ($selectcpt as $selectedoption) {
62 if (!array_key_exists($selectedoption, $cpts)) {
63 $cpts[$selectedoption] =
"'".$selectedoption.
"'";
67 $return = $accountingcategory->updateAccAcc($cat_id, $cpts);
70 setEventMessages($langs->trans(
'errors'), $accountingcategory->errors,
'errors');
72 setEventMessages($langs->trans(
'RecordModifiedSuccessfully'),
null,
'mesgs');
76 if ($action ==
'delete') {
78 if ($accountingcategory->deleteCptCat($cpt_id)) {
94 llxheader(
'', $langs->trans(
'AccountingCategory'));
96 $linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
97 $titlepicto =
'setup';
99 print
load_fiche_titre($langs->trans(
'AccountingCategory'), $linkback, $titlepicto);
101 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
102 print
'<input type="hidden" name="token" value="'.newToken().
'">';
103 print
'<input type="hidden" name="action" value="display">';
107 print
'<table class="border centpercent">';
110 print
'<tr><td class="titlefield">'.$langs->trans(
"AccountingCategory").
'</td>';
112 $formaccounting->select_accounting_category($cat_id,
'account_category', 1, 0, 0, 1);
113 print
'<input type="submit" class="button" value="'.$langs->trans(
"Select").
'">';
117 if (!empty($cat_id)) {
118 $return = $accountingcategory->getAccountsWithNoCategory($cat_id);
122 print
'<tr><td>'.$langs->trans(
"AddAccountFromBookKeepingWithNoCategories").
'</td>';
125 $arraykeyvalue = array();
126 foreach ($accountingcategory->lines_cptbk as $key => $val) {
127 $doc_ref = !empty($val->doc_ref) ? $val->doc_ref :
'';
128 $arraykeyvalue[
length_accountg($val->numero_compte)] =
length_accountg($val->numero_compte) .
' - ' . $val->label_compte . ($doc_ref ?
' '.$doc_ref :
'');
131 if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
132 print
$form->multiselectarray(
'cpt_bk', $arraykeyvalue,
GETPOST(
'cpt_bk',
'array'),
null,
null,
null,
null,
"90%");
141 print
'<input type="submit" class="button button-add" id="" class="action-delete" value="'.$langs->trans(
"Add").
'"> ';
153 if ($action ==
'display' || $action ==
'delete') {
154 print
"<table class='noborder' width='100%'>\n";
155 print
'<tr class="liste_titre">';
156 print
'<td class="liste_titre">'.$langs->trans(
"AccountAccounting").
"</td>";
157 print
'<td class="liste_titre" colspan="2">'.$langs->trans(
"Label").
"</td>";
160 if (!empty($cat_id)) {
161 $return = $accountingcategory->display($cat_id);
166 if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
167 foreach ($accountingcategory->lines_display as $cpt) {
168 print
'<tr class="oddeven">';
169 print
'<td>'.length_accountg($cpt->account_number).
'</td>';
170 print
'<td>'.$cpt->label.
'</td>';
171 print
'<td class="right">';
172 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&account_category='.$cat_id.
'&cptid='.$cpt->rowid.
'">';
173 print $langs->trans(
"DeleteFromCat");
174 print
img_picto($langs->trans(
"DeleteFromCat"),
'unlink',
'class="paddingleft"');
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage categories of an accounting account.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
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 Calling this function terminate execution ...