26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
37$langs->loadLangs(array(
"errors",
"admin",
"companies",
"resource",
"holiday",
"accountancy",
"hrm"));
39$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
40$confirm =
GETPOST(
'confirm',
'alpha');
42$rowid =
GETPOST(
'rowid',
'alpha');
43$code =
GETPOST(
'code',
'alpha');
46if (!$user->hasRight(
'accounting',
'chartofaccount')) {
52$actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="size15x"');
53$actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="size15x"');
55$listoffset =
GETPOST(
'listoffset',
'alpha');
56$listlimit =
GETPOST(
'listlimit',
'int') > 0 ?
GETPOST(
'listlimit',
'int') : 1000;
58$sortfield =
GETPOST(
"sortfield",
'aZ09comma');
59$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
60$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
61if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
65$offset = $listlimit * $page;
69$search_country_id =
GETPOST(
'search_country_id',
'int');
72$hookmanager->initHooks(array(
'admin'));
82$tabname[32] = MAIN_DB_PREFIX.
"c_accounting_category";
86$tablib[32] =
"DictionaryAccountancyCategory";
90$tabsql[32] =
"SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX.
"c_accounting_category as a, ".MAIN_DB_PREFIX.
"c_country as c WHERE a.fk_country=c.rowid and c.active=1";
94$tabsqlsort[32] =
"position ASC";
98$tabfield[32] =
"code,label,range_account,category_type,formula,position,country";
101$tabfieldvalue = array();
102$tabfieldvalue[32] =
"code,label,range_account,category_type,formula,position,country_id";
105$tabfieldinsert = array();
106$tabfieldinsert[32] =
"code,label,range_account,category_type,formula,position,fk_country";
116$tabcond[32] = isModEnabled(
'accounting');
120$tabhelp[32] = array(
'code'=>$langs->trans(
"EnterAnyCode"),
'category_type'=>$langs->trans(
"SetToYesIfGroupIsComputationOfOtherGroups"),
'formula'=>$langs->trans(
"EnterCalculationRuleIfPreviousFieldIsYes"));
123$tabfieldcheck = array();
124$tabfieldcheck[32] = array();
127complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
136if (
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter_x',
'alpha')) {
137 $search_country_id =
'';
141if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
142 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
143 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
144 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
145 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
149 foreach ($listfield as $f => $value) {
150 if ($value ==
'formula' && !
GETPOST(
'formula')) {
153 if ($value ==
'range_account' && !
GETPOST(
'range_account')) {
156 if (($value ==
'country' || $value ==
'country_id') &&
GETPOST(
'country_id')) {
159 if (!GETPOSTISSET($value) ||
GETPOST($value) ==
'') {
161 $fieldnamekey = $listfield[$f];
163 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
164 $fieldnamekey =
'Label';
166 if ($fieldnamekey ==
'code') {
167 $fieldnamekey =
'Code';
169 if ($fieldnamekey ==
'note') {
170 $fieldnamekey =
'Note';
172 if ($fieldnamekey ==
'type') {
173 $fieldnamekey =
'Type';
175 if ($fieldnamekey ==
'position') {
176 $fieldnamekey =
'Position';
178 if ($fieldnamekey ==
'category_type') {
179 $fieldnamekey =
'Calculated';
181 if ($fieldnamekey ==
'country') {
182 $fieldnamekey =
'Country';
185 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
188 if (GETPOSTISSET(
"code")) {
191 setEventMessages($langs->transnoentities(
'ErrorCodeCantContainZero'),
null,
'errors');
194 if (
GETPOST(
'position') && !is_numeric(
GETPOST(
'position',
'alpha'))) {
195 $langs->loadLangs(array(
"errors"));
197 setEventMessages($langs->transnoentities(
'ErrorFieldMustBeANumeric', $langs->transnoentities(
"Position")),
null,
'errors');
201 if ($ok &&
GETPOST(
'actionadd',
'alpha')) {
202 if ($tabrowid[$id]) {
205 $sql =
"SELECT MAX(".$tabrowid[$id].
") newid from ".$tabname[$id];
206 $result = $db->query($sql);
208 $obj = $db->fetch_object($result);
209 $newid = ($obj->newid + 1);
216 $sql =
"INSERT INTO ".$tabname[$id].
" (";
218 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
219 $sql .= $tabrowid[$id].
",";
221 $sql .= $tabfieldinsert[$id];
226 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
230 foreach ($listfieldinsert as $f => $value) {
231 if ($value ==
'entity') {
232 $_POST[$listfieldvalue[$i]] = $conf->entity;
237 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'formula') {
240 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
247 $result = $db->query($sql);
250 $_POST = array(
'id'=>$id);
252 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
253 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
261 if ($ok &&
GETPOST(
'actionmodify',
'alpha')) {
262 if ($tabrowid[$id]) {
263 $rowidcol = $tabrowid[$id];
269 $sql =
"UPDATE ".$tabname[$id].
" SET ";
271 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
272 $sql .= $tabrowid[$id].
"=";
273 $sql .=
"'".$db->escape($rowid).
"', ";
276 foreach ($listfieldmodify as $field) {
277 if ($field ==
'fk_country' &&
GETPOST(
'country') > 0) {
278 $_POST[$listfieldvalue[$i]] =
GETPOST(
'country');
279 } elseif ($field ==
'entity') {
280 $_POST[$listfieldvalue[$i]] = $conf->entity;
286 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'range_account') {
289 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
293 $sql .=
" WHERE ".$rowidcol.
" = ".((int) $rowid);
297 $resql = $db->query($sql);
304if ($action ==
'confirm_delete' && $confirm ==
'yes') {
305 if ($tabrowid[$id]) {
306 $rowidcol = $tabrowid[$id];
311 $sql =
"DELETE from ".$tabname[$id].
" WHERE ".$rowidcol.
" = ".((int) $rowid);
314 $result = $db->query($sql);
316 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
317 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
325if ($action == $acts[0]) {
326 if ($tabrowid[$id]) {
327 $rowidcol = $tabrowid[$id];
333 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
335 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE code = '".$db->escape($code).
"'";
338 $result = $db->query($sql);
345if ($action == $acts[1]) {
346 if ($tabrowid[$id]) {
347 $rowidcol = $tabrowid[$id];
353 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
355 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE code = '".$db->escape($code).
"'";
358 $result = $db->query($sql);
365if ($action ==
'activate_favorite') {
366 if ($tabrowid[$id]) {
367 $rowidcol = $tabrowid[$id];
373 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
375 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE code = '".$db->escape($code).
"'";
378 $result = $db->query($sql);
385if ($action ==
'disable_favorite') {
386 if ($tabrowid[$id]) {
387 $rowidcol = $tabrowid[$id];
393 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
395 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE code = '".$db->escape($code).
"'";
398 $result = $db->query($sql);
409$form =
new Form($db);
412$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
414llxHeader(
'', $langs->trans(
'DictionaryAccountancyCategory'), $help_url);
416$titre = $langs->trans($tablib[$id]);
418$titlepicto =
'setup';
422print
'<span class="opacitymedium">'.$langs->trans(
"AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv(
"ByPersonalizedAccountGroups")).
'</span><br><br>';
425if ($action ==
'delete') {
426 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?'.($page ?
'page='.$page.
'&' :
'').
'sortfield='.$sortfield.
'&sortorder='.$sortorder.
'&rowid='.$rowid.
'&code='.$code.
'&id='.$id.($search_country_id > 0 ?
'&search_country_id='.$search_country_id :
''), $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_delete',
'', 0, 1);
432if ($search_country_id > 0) {
433 if (preg_match(
'/ WHERE /', $sql)) {
438 $sql .=
" (a.fk_country = ".((int) $search_country_id).
" OR a.fk_country = 0)";
442if ($sortfield ==
'country') {
443 $sortfield =
'country_code';
445if (empty($sortfield)) {
446 $sortfield =
'position';
449$sql .= $db->order($sortfield, $sortorder);
450$sql .= $db->plimit($listlimit + 1, $offset);
453$fieldlist = explode(
',', $tabfield[$id]);
456if ($search_country_id > 0) {
457 $param .=
'&search_country_id='.urlencode($search_country_id);
459$paramwithsearch = $param;
461 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
464 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
467 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
470 $paramwithsearch .=
'&listlimit='.urlencode(
GETPOST(
'listlimit',
'int'));
472print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
473print
'<input type="hidden" name="token" value="'.newToken().
'">';
474print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
475print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
476print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
479print
'<div class="div-table-responsive-no-min">';
480print
'<table class="noborder centpercent">';
484 $fieldlist = explode(
',', $tabfield[$id]);
487 print
'<tr class="liste_titre">';
492 foreach ($fieldlist as $field => $value) {
495 $valuetoshow = ucfirst($fieldlist[$field]);
496 $valuetoshow = $langs->trans($valuetoshow);
498 if ($fieldlist[$field] ==
'type') {
499 if ($tabname[$id] == MAIN_DB_PREFIX.
"c_paiement") {
500 $valuetoshow = $form->textwithtooltip($langs->trans(
"Type"), $langs->trans(
"TypePaymentDesc"), 2, 1,
img_help(1,
''));
502 $valuetoshow = $langs->trans(
"Type");
505 if ($fieldlist[$field] ==
'code') {
506 $valuetoshow = $langs->trans(
"Code");
509 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
510 $valuetoshow = $langs->trans(
"Label");
512 if ($fieldlist[$field] ==
'libelle_facture') {
513 $valuetoshow = $langs->trans(
"LabelOnDocuments");
515 if ($fieldlist[$field] ==
'country') {
516 $valuetoshow = $langs->trans(
"Country");
518 if ($fieldlist[$field] ==
'accountancy_code') {
519 $valuetoshow = $langs->trans(
"AccountancyCode");
521 if ($fieldlist[$field] ==
'accountancy_code_sell') {
522 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
524 if ($fieldlist[$field] ==
'accountancy_code_buy') {
525 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
527 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
528 $valuetoshow = $langs->trans(
"Pcg_version");
530 if ($fieldlist[$field] ==
'range_account') {
531 $valuetoshow = $langs->trans(
"Comment");
534 if ($fieldlist[$field] ==
'category_type') {
535 $valuetoshow = $langs->trans(
"Calculated");
538 if ($valuetoshow !=
'') {
539 print
'<td class="'.$class.
'">';
540 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
541 print
'<a href="'.$tabhelp[$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
542 } elseif (!empty($tabhelp[$id][$value])) {
543 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
552 print
'<input type="hidden" name="id" value="'.$id.
'">';
562 print
'<tr class="oddeven nodrag nodrop nohover">';
571 if (
GETPOST(
'actionadd',
'alpha')) {
572 foreach ($fieldlist as $key => $val) {
579 $tmpaction =
'create';
580 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
581 $reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
582 $error = $hookmanager->error;
583 $errors = $hookmanager->errors;
585 if (empty($reshook)) {
589 print
'<td colspan="2" class="right">';
590 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
600 $colspan = count($fieldlist) + 3;
609print
'<div class="div-table-responsive">';
610print
'<table class="noborder centpercent">';
613dol_syslog(
"htdocs/accountancy/admin/categories_list.php", LOG_DEBUG);
615$resql = $db->query($sql);
617 $num = $db->num_rows($resql);
621 if ($num > $listlimit) {
622 print
'<tr class="none"><td class="right" colspan="'.(2 + count($fieldlist)).
'">';
623 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
628 foreach ($fieldlist as $field => $value) {
630 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
634 if ($value ==
'country') {
641 print
'<tr class="liste_titre liste_titre_add liste_titre_filter">';
645 print
'<td class="liste_titre center">';
647 $searchpicto = $form->showFilterAndCheckAddButtons(0);
654 foreach ($fieldlist as $field => $value) {
657 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
662 if ($value ==
'country') {
663 print
'<td class="liste_titre">';
664 print $form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth150 maxwidthonsmartphone');
668 print
'<td class="liste_titre"></td>';
672 print
'<td class="liste_titre"></td>';
673 print
'<td class="liste_titre"></td>';
676 print
'<td class="liste_titre center">';
678 $searchpicto = $form->showFilterAndCheckAddButtons(0);
686 print
'<tr class="liste_titre">';
691 foreach ($fieldlist as $field => $value) {
699 $valuetoshow = ucfirst($fieldlist[$field]);
700 $valuetoshow = $langs->trans($valuetoshow);
701 if ($fieldlist[$field] ==
'source') {
702 $valuetoshow = $langs->trans(
"Contact");
704 if ($fieldlist[$field] ==
'price') {
705 $valuetoshow = $langs->trans(
"PriceUHT");
707 if ($fieldlist[$field] ==
'taux') {
708 if ($tabname[$id] != MAIN_DB_PREFIX.
"c_revenuestamp") {
709 $valuetoshow = $langs->trans(
"Rate");
711 $valuetoshow = $langs->trans(
"Amount");
715 if ($fieldlist[$field] ==
'type') {
716 $valuetoshow = $langs->trans(
"Type");
718 if ($fieldlist[$field] ==
'code') {
719 $valuetoshow = $langs->trans(
"Code");
721 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
722 $valuetoshow = $langs->trans(
"Label");
724 if ($fieldlist[$field] ==
'country') {
725 $valuetoshow = $langs->trans(
"Country");
727 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
730 if ($fieldlist[$field] ==
'accountancy_code') {
731 $valuetoshow = $langs->trans(
"AccountancyCode");
733 if ($fieldlist[$field] ==
'accountancy_code_sell') {
734 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
737 if ($fieldlist[$field] ==
'accountancy_code_buy') {
738 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
741 if ($fieldlist[$field] ==
'fk_pcg_version') {
742 $valuetoshow = $langs->trans(
"Pcg_version");
744 if ($fieldlist[$field] ==
'account_parent') {
745 $valuetoshow = $langs->trans(
"Accountsparent");
747 if ($fieldlist[$field] ==
'pcg_type') {
748 $valuetoshow = $langs->trans(
"Pcg_type");
750 if ($fieldlist[$field] ==
'type_template') {
751 $valuetoshow = $langs->trans(
"TypeOfTemplate");
753 if ($fieldlist[$field] ==
'range_account') {
754 $valuetoshow = $langs->trans(
"Comment");
756 if ($fieldlist[$field] ==
'category_type') {
757 $valuetoshow = $langs->trans(
"Calculated");
761 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"", $sortfield, $sortorder, $class.
' ');
764 print
getTitleFieldOfList($langs->trans(
"ListOfAccounts"), 0, $_SERVER[
"PHP_SELF"],
"", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
765 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
774 $imaxinloop = ($listlimit ? min($num, $listlimit) : $num);
777 while ($i < $imaxinloop) {
778 $obj = $db->fetch_object($resql);
781 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
782 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
784 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
785 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
786 $error = $hookmanager->error;
787 $errors = $hookmanager->errors;
795 if (empty($reshook)) {
800 print
'<td class="center">';
801 print
'<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"></div>';
802 print
'<input type="hidden" name="page" value="'.$page.
'">';
803 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
804 print
'<input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
805 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
816 if (isset($obj->code)) {
817 if (($obj->code ==
'0' || $obj->code ==
'' || preg_match(
'/unknown/i', $obj->code))) {
822 $url = $_SERVER[
"PHP_SELF"].
'?'.($page ?
'page='.$page.
'&' :
'').
'sortfield='.$sortfield.
'&sortorder='.$sortorder.
'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code :
'')).
'&code='.(!empty($obj->code) ? urlencode($obj->code) :
'');
828 $canbemodified = $iserasable;
831 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
832 $reshook = $hookmanager->executeHooks(
'viewDictionaryFieldlist', $parameters, $obj, $tmpaction);
834 $error = $hookmanager->error;
835 $errors = $hookmanager->errors;
839 print
'<td class="center">';
840 if ($canbemodified) {
841 print
'<a class="reposition editfielda marginleftonly marginrightonly" href="'.$url.
'action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
845 print
'<a class="marginleftonly marginrightonly" href="'.$url.
'action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
851 if (empty($reshook)) {
852 foreach ($fieldlist as $field => $value) {
857 $tmpvar = $fieldlist[$field];
858 $valuetoshow = $obj->$tmpvar;
859 if ($value ==
'category_type') {
860 $valuetoshow =
yn($valuetoshow);
861 } elseif ($valuetoshow ==
'all') {
862 $valuetoshow = $langs->trans(
'All');
863 } elseif ($fieldlist[$field] ==
'country') {
864 if (empty($obj->country_code)) {
867 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
868 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
870 } elseif (in_array($fieldlist[$field], array(
'label',
'formula'))) {
871 $class =
"tdoverflowmax250";
872 $title = $valuetoshow;
873 } elseif (in_array($fieldlist[$field], array(
'range_account'))) {
874 $class =
"tdoverflowmax250 small";
875 $title = $valuetoshow;
876 } elseif ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
882 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'"'.($title ?
' title="'.dol_escape_htmltag($title).
'"' :
'').
'>'.
dol_escape_htmltag($valuetoshow).
'</td>';
889 if (empty($obj->formula)) {
891 $nbofaccountintogroup = 0;
892 $listofaccountintogroup = $accountingcategory->getCptsCat($obj->rowid);
893 $nbofaccountintogroup = count($listofaccountintogroup);
895 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.
'">';
896 print $langs->trans(
"NAccounts", $nbofaccountintogroup);
899 print
'<span class="opacitymedium">'.$langs->trans(
"Formula").
'</span>';
904 print
'<td class="center" class="nowrap">';
905 if ($canbedisabled) {
906 print
'<a href="'.$url.
'action='.$acts[$obj->active].
'">'.$actl[$obj->active].
'</a>';
908 print $langs->trans(
"AlwaysActive");
914 print
'<td class="center">';
915 if ($canbemodified) {
916 print
'<a class="reposition editfielda paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
920 print
'<a class="paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
931 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
960 global $conf, $langs, $db;
961 global $form, $mysoc;
965 if (isModEnabled(
'accounting')) {
969 foreach ($fieldlist as $field => $value) {
970 if ($fieldlist[$field] ==
'country') {
972 $fieldname =
'country';
973 if ($context ==
'add') {
974 $fieldname =
'country_id';
975 $preselectcountrycode = GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_code;
976 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
978 $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code);
979 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
982 } elseif ($fieldlist[$field] ==
'country_id') {
983 if (!in_array(
'country', $fieldlist)) {
984 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
986 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
989 } elseif ($fieldlist[$field] ==
'category_type') {
991 print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
''), 1);
993 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
994 print
'<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
'').
'" name="'.$fieldlist[$field].
'"></td>';
998 if (in_array($fieldlist[$field], array(
'code',
'formula'))) {
999 $class =
'maxwidth75';
1001 if (in_array($fieldlist[$field], array(
'label',
'range_account'))) {
1002 $class =
'maxwidth150';
1004 if ($fieldlist[$field] ==
'position') {
1005 $class =
'maxwidth50';
1007 print
'<input type="text" class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
'').
'" name="'.$fieldlist[$field].
'">';
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
Add external modules to list of dictionaries.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
fieldListAccountingCategories($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
Class to manage categories of an accounting account.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.