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);
305if (
GETPOST(
'actioncancel',
'alpha')) {
309if ($action ==
'confirm_delete' && $confirm ==
'yes') {
310 if ($tabrowid[$id]) {
311 $rowidcol = $tabrowid[$id];
316 $sql =
"DELETE from ".$tabname[$id].
" WHERE ".$rowidcol.
" = ".((int) $rowid);
319 $result = $db->query($sql);
321 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
322 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
330if ($action == $acts[0]) {
331 if ($tabrowid[$id]) {
332 $rowidcol = $tabrowid[$id];
338 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
340 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE code = '".$db->escape($code).
"'";
343 $result = $db->query($sql);
350if ($action == $acts[1]) {
351 if ($tabrowid[$id]) {
352 $rowidcol = $tabrowid[$id];
358 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
360 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE code = '".$db->escape($code).
"'";
363 $result = $db->query($sql);
370if ($action ==
'activate_favorite') {
371 if ($tabrowid[$id]) {
372 $rowidcol = $tabrowid[$id];
378 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
380 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE code = '".$db->escape($code).
"'";
383 $result = $db->query($sql);
390if ($action ==
'disable_favorite') {
391 if ($tabrowid[$id]) {
392 $rowidcol = $tabrowid[$id];
398 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
400 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE code = '".$db->escape($code).
"'";
403 $result = $db->query($sql);
414$form =
new Form($db);
417llxHeader(
'', $langs->trans(
'DictionaryAccountancyCategory'));
419$titre = $langs->trans($tablib[$id]);
421$titlepicto =
'setup';
425print
'<span class="opacitymedium">'.$langs->trans(
"AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv(
"ByPersonalizedAccountGroups")).
'</span><br><br>';
428if ($action ==
'delete') {
429 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);
435if ($search_country_id > 0) {
436 if (preg_match(
'/ WHERE /', $sql)) {
441 $sql .=
" (a.fk_country = ".((int) $search_country_id).
" OR a.fk_country = 0)";
445if ($sortfield ==
'country') {
446 $sortfield =
'country_code';
448if (empty($sortfield)) {
449 $sortfield =
'position';
452$sql .= $db->order($sortfield, $sortorder);
453$sql .= $db->plimit($listlimit + 1, $offset);
456$fieldlist = explode(
',', $tabfield[$id]);
459if ($search_country_id > 0) {
460 $param .=
'&search_country_id='.urlencode($search_country_id);
462$paramwithsearch = $param;
464 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
467 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
470 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
473 $paramwithsearch .=
'&listlimit='.urlencode(
GETPOST(
'listlimit',
'int'));
475print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
476print
'<input type="hidden" name="token" value="'.newToken().
'">';
477print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
478print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
479print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
482print
'<div class="div-table-responsive-no-min">';
483print
'<table class="noborder centpercent">';
487 $fieldlist = explode(
',', $tabfield[$id]);
490 print
'<tr class="liste_titre">';
495 foreach ($fieldlist as $field => $value) {
498 $valuetoshow = ucfirst($fieldlist[$field]);
499 $valuetoshow = $langs->trans($valuetoshow);
501 if ($fieldlist[$field] ==
'type') {
502 if ($tabname[$id] == MAIN_DB_PREFIX.
"c_paiement") {
503 $valuetoshow = $form->textwithtooltip($langs->trans(
"Type"), $langs->trans(
"TypePaymentDesc"), 2, 1,
img_help(1,
''));
505 $valuetoshow = $langs->trans(
"Type");
508 if ($fieldlist[$field] ==
'code') {
509 $valuetoshow = $langs->trans(
"Code");
511 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
512 $valuetoshow = $langs->trans(
"Label");
514 if ($fieldlist[$field] ==
'libelle_facture') {
515 $valuetoshow = $langs->trans(
"LabelOnDocuments");
517 if ($fieldlist[$field] ==
'country') {
518 $valuetoshow = $langs->trans(
"Country");
520 if ($fieldlist[$field] ==
'accountancy_code') {
521 $valuetoshow = $langs->trans(
"AccountancyCode");
523 if ($fieldlist[$field] ==
'accountancy_code_sell') {
524 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
526 if ($fieldlist[$field] ==
'accountancy_code_buy') {
527 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
529 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
530 $valuetoshow = $langs->trans(
"Pcg_version");
532 if ($fieldlist[$field] ==
'range_account') {
533 $valuetoshow = $langs->trans(
"Comment");
536 if ($fieldlist[$field] ==
'category_type') {
537 $valuetoshow = $langs->trans(
"Calculated");
540 if ($valuetoshow !=
'') {
541 print
'<td class="'.$class.
'">';
542 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
543 print
'<a href="'.$tabhelp[$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
544 } elseif (!empty($tabhelp[$id][$value])) {
545 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
554 print
'<input type="hidden" name="id" value="'.$id.
'">';
564 print
'<tr class="oddeven nodrag nodrop nohover">';
571 $obj =
new stdClass();
573 if (
GETPOST(
'actionadd',
'alpha')) {
574 foreach ($fieldlist as $key => $val) {
581 $tmpaction =
'create';
582 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
583 $reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
584 $error = $hookmanager->error; $errors = $hookmanager->errors;
586 if (empty($reshook)) {
590 print
'<td colspan="2" class="right">';
591 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
601 $colspan = count($fieldlist) + 3;
610print
'<div class="div-table-responsive">';
611print
'<table class="noborder centpercent">';
614dol_syslog(
"htdocs/accountancy/admin/categories_list.php", LOG_DEBUG);
616$resql = $db->query($sql);
618 $num = $db->num_rows($resql);
622 if ($num > $listlimit) {
623 print
'<tr class="none"><td class="right" colspan="'.(2 + count($fieldlist)).
'">';
624 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
629 foreach ($fieldlist as $field => $value) {
631 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
635 if ($value ==
'country') {
642 print
'<tr class="liste_titre liste_titre_add liste_titre_filter">';
646 print
'<td class="liste_titre center">';
648 $searchpicto = $form->showFilterAndCheckAddButtons(0);
655 foreach ($fieldlist as $field => $value) {
658 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
663 if ($value ==
'country') {
664 print
'<td class="liste_titre">';
665 print $form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth150 maxwidthonsmartphone');
669 print
'<td class="liste_titre"></td>';
673 print
'<td class="liste_titre"></td>';
674 print
'<td class="liste_titre"></td>';
677 print
'<td class="liste_titre center">';
679 $searchpicto = $form->showFilterAndCheckAddButtons(0);
687 print
'<tr class="liste_titre">';
692 foreach ($fieldlist as $field => $value) {
700 $valuetoshow = ucfirst($fieldlist[$field]);
701 $valuetoshow = $langs->trans($valuetoshow);
702 if ($fieldlist[$field] ==
'source') {
703 $valuetoshow = $langs->trans(
"Contact");
705 if ($fieldlist[$field] ==
'price') {
706 $valuetoshow = $langs->trans(
"PriceUHT");
708 if ($fieldlist[$field] ==
'taux') {
709 if ($tabname[$id] != MAIN_DB_PREFIX.
"c_revenuestamp") {
710 $valuetoshow = $langs->trans(
"Rate");
712 $valuetoshow = $langs->trans(
"Amount");
716 if ($fieldlist[$field] ==
'type') {
717 $valuetoshow = $langs->trans(
"Type");
719 if ($fieldlist[$field] ==
'code') {
720 $valuetoshow = $langs->trans(
"Code");
722 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
723 $valuetoshow = $langs->trans(
"Label");
725 if ($fieldlist[$field] ==
'country') {
726 $valuetoshow = $langs->trans(
"Country");
728 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
731 if ($fieldlist[$field] ==
'accountancy_code') {
732 $valuetoshow = $langs->trans(
"AccountancyCode");
734 if ($fieldlist[$field] ==
'accountancy_code_sell') {
735 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
738 if ($fieldlist[$field] ==
'accountancy_code_buy') {
739 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
742 if ($fieldlist[$field] ==
'fk_pcg_version') {
743 $valuetoshow = $langs->trans(
"Pcg_version");
745 if ($fieldlist[$field] ==
'account_parent') {
746 $valuetoshow = $langs->trans(
"Accountsparent");
748 if ($fieldlist[$field] ==
'pcg_type') {
749 $valuetoshow = $langs->trans(
"Pcg_type");
751 if ($fieldlist[$field] ==
'type_template') {
752 $valuetoshow = $langs->trans(
"TypeOfTemplate");
754 if ($fieldlist[$field] ==
'range_account') {
755 $valuetoshow = $langs->trans(
"Comment");
757 if ($fieldlist[$field] ==
'category_type') {
758 $valuetoshow = $langs->trans(
"Calculated");
762 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"", $sortfield, $sortorder, $class.
' ');
765 print
getTitleFieldOfList($langs->trans(
"ListOfAccounts"), 0, $_SERVER[
"PHP_SELF"],
"", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
766 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
775 $imaxinloop = ($listlimit ? min($num, $listlimit) : $num);
778 while ($i < $imaxinloop) {
779 $obj = $db->fetch_object($resql);
782 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
783 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
785 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
786 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
787 $error = $hookmanager->error; $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").
'">';
813 $iserasable = 1; $canbedisabled = 1; $canbemodified = 1;
814 if (isset($obj->code)) {
815 if (($obj->code ==
'0' || $obj->code ==
'' || preg_match(
'/unknown/i', $obj->code))) {
816 $iserasable = 0; $canbedisabled = 0;
819 $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) :
'');
825 $canbemodified = $iserasable;
828 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
829 $reshook = $hookmanager->executeHooks(
'viewDictionaryFieldlist', $parameters, $obj, $tmpaction);
831 $error = $hookmanager->error; $errors = $hookmanager->errors;
835 print
'<td class="center">';
836 if ($canbemodified) {
837 print
'<a class="reposition editfielda marginleftonly marginrightonly" href="'.$url.
'action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
841 print
'<a class="marginleftonly marginrightonly" href="'.$url.
'action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
847 if (empty($reshook)) {
848 foreach ($fieldlist as $field => $value) {
853 $tmpvar = $fieldlist[$field];
854 $valuetoshow = $obj->$tmpvar;
855 if ($value ==
'category_type') {
856 $valuetoshow =
yn($valuetoshow);
857 } elseif ($valuetoshow ==
'all') {
858 $valuetoshow = $langs->trans(
'All');
859 } elseif ($fieldlist[$field] ==
'country') {
860 if (empty($obj->country_code)) {
863 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
864 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
866 } elseif (in_array($fieldlist[$field], array(
'label',
'range_account',
'formula'))) {
867 $class =
"tdoverflowmax250";
868 $title = $valuetoshow;
869 } elseif ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
875 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'"'.($title ?
' title="'.dol_escape_htmltag($title).
'"':
'').
'>'.
dol_escape_htmltag($valuetoshow).
'</td>';
882 if (empty($obj->formula)) {
884 $nbofaccountintogroup = 0;
885 $listofaccountintogroup = $accountingcategory->getCptsCat($obj->rowid);
886 $nbofaccountintogroup = count($listofaccountintogroup);
888 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.
'">';
889 print $langs->trans(
"NAccounts", $nbofaccountintogroup);
892 print
'<span class="opacitymedium">'.$langs->trans(
"Formula").
'</span>';
897 print
'<td class="center" class="nowrap">';
898 if ($canbedisabled) {
899 print
'<a href="'.$url.
'action='.$acts[$obj->active].
'">'.$actl[$obj->active].
'</a>';
901 print $langs->trans(
"AlwaysActive");
907 print
'<td class="center">';
908 if ($canbemodified) {
909 print
'<a class="reposition editfielda paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
913 print
'<a class="paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
924 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
953 global $conf, $langs, $db;
954 global $form, $mysoc;
958 if (isModEnabled(
'accounting')) {
962 foreach ($fieldlist as $field => $value) {
963 if ($fieldlist[$field] ==
'country') {
965 $fieldname =
'country';
966 if ($context ==
'add') {
967 $fieldname =
'country_id';
968 $preselectcountrycode = GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_code;
969 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
971 $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code);
972 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
975 } elseif ($fieldlist[$field] ==
'country_id') {
976 if (!in_array(
'country', $fieldlist)) {
977 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
979 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
982 } elseif ($fieldlist[$field] ==
'category_type') {
984 print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
''), 1);
986 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
987 print
'<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
'').
'" name="'.$fieldlist[$field].
'"></td>';
991 if (in_array($fieldlist[$field], array(
'code',
'range_account',
'label',
'formula'))) {
992 $class =
'maxwidth100';
994 if ($fieldlist[$field] ==
'position') {
995 $class =
'maxwidth50';
997 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='', $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.