28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
39$langs->loadLangs(array(
"errors",
"admin",
"companies",
"resource",
"holiday",
"accountancy",
"hrm"));
41$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
42$confirm =
GETPOST(
'confirm',
'alpha');
44$rowid =
GETPOST(
'rowid',
'alpha');
45$code =
GETPOST(
'code',
'alpha');
48if (!$user->hasRight(
'accounting',
'chartofaccount')) {
56$actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="size15x"');
57$actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="size15x"');
59$listoffset =
GETPOST(
'listoffset',
'alpha');
62$sortfield =
GETPOST(
"sortfield",
'aZ09comma');
63$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
65if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
69$offset = $listlimit * $page;
73$search_country_id =
GETPOST(
'search_country_id',
'int');
76$hookmanager->initHooks(array(
'admin'));
86$tabname[32] = MAIN_DB_PREFIX.
"c_accounting_category";
90$tablib[32] =
"DictionaryAccountancyCategory";
94$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";
98$tabsqlsort[32] =
"position ASC";
102$tabfield[32] =
"code,label,range_account,category_type,formula,position,country";
105$tabfieldvalue = array();
106$tabfieldvalue[32] =
"code,label,range_account,category_type,formula,position,country_id";
109$tabfieldinsert = array();
110$tabfieldinsert[32] =
"code,label,range_account,category_type,formula,position,fk_country";
120$tabcond[32] = isModEnabled(
'accounting');
124$tabhelp[32] = array(
'code' => $langs->trans(
"EnterAnyCode"),
'category_type' => $langs->trans(
"SetToYesIfGroupIsComputationOfOtherGroups"),
'formula' => $langs->trans(
"EnterCalculationRuleIfPreviousFieldIsYes"));
127$tabfieldcheck = array();
128$tabfieldcheck[32] = array();
131complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
140if (
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter_x',
'alpha')) {
141 $search_country_id =
'';
145if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
146 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
147 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
148 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
149 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
153 foreach ($listfield as $f => $value) {
154 if ($value ==
'formula' && !
GETPOST(
'formula')) {
157 if ($value ==
'range_account' && !
GETPOST(
'range_account')) {
160 if (($value ==
'country' || $value ==
'country_id') &&
GETPOST(
'country_id')) {
163 if (!GETPOSTISSET($value) ||
GETPOST($value) ==
'') {
165 $fieldnamekey = $listfield[$f];
167 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
168 $fieldnamekey =
'Label';
170 if ($fieldnamekey ==
'code') {
171 $fieldnamekey =
'Code';
173 if ($fieldnamekey ==
'note') {
174 $fieldnamekey =
'Note';
176 if ($fieldnamekey ==
'type') {
177 $fieldnamekey =
'Type';
179 if ($fieldnamekey ==
'position') {
180 $fieldnamekey =
'Position';
182 if ($fieldnamekey ==
'category_type') {
183 $fieldnamekey =
'Calculated';
185 if ($fieldnamekey ==
'country') {
186 $fieldnamekey =
'Country';
189 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
192 if (GETPOSTISSET(
"code")) {
195 setEventMessages($langs->transnoentities(
'ErrorCodeCantContainZero'),
null,
'errors');
198 if (
GETPOST(
'position') && !is_numeric(
GETPOST(
'position',
'alpha'))) {
199 $langs->loadLangs(array(
"errors"));
201 setEventMessages($langs->transnoentities(
'ErrorFieldMustBeANumeric', $langs->transnoentities(
"Position")),
null,
'errors');
205 if ($ok &&
GETPOST(
'actionadd',
'alpha')) {
208 if ($tabrowid[$id]) {
210 $sql =
"SELECT MAX(".$db->sanitize($tabrowid[$id]).
") newid FROM ".$db->sanitize($tabname[$id]);
211 $result = $db->query($sql);
213 $obj = $db->fetch_object($result);
214 $newid = ($obj->newid + 1);
221 $sql =
"INSERT INTO ".$db->sanitize($tabname[$id]).
" (";
223 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
224 $sql .= $db->sanitize($tabrowid[$id]).
",";
226 $sql .= $db->sanitize($tabfieldinsert[$id]);
231 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
235 foreach ($listfieldinsert as $f => $value) {
236 if ($value ==
'entity') {
237 $_POST[$listfieldvalue[$i]] = $conf->entity;
242 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'formula') {
245 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
252 $result = $db->query($sql);
255 $_POST = array(
'id' => $id);
257 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
258 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
266 if ($ok &&
GETPOST(
'actionmodify',
'alpha')) {
267 if ($tabrowid[$id]) {
268 $rowidcol = $tabrowid[$id];
274 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET ";
276 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
277 $sql .= $db->sanitize($tabrowid[$id]).
" = ";
278 $sql .=
"'".$db->escape($rowid).
"', ";
281 foreach ($listfieldmodify as $field) {
282 if ($field ==
'fk_country' &&
GETPOST(
'country') > 0) {
283 $_POST[$listfieldvalue[$i]] =
GETPOST(
'country');
284 } elseif ($field ==
'entity') {
285 $_POST[$listfieldvalue[$i]] = $conf->entity;
291 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'range_account') {
294 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
298 $sql .=
" WHERE ".$rowidcol.
" = ".((int) $rowid);
302 $resql = $db->query($sql);
309if ($action ==
'confirm_delete' && $confirm ==
'yes') {
312 $sql =
"DELETE from ".$db->sanitize($tabname[$id]).
" WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
315 $result = $db->query($sql);
317 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
318 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
326if ($action == $acts[0]) {
331 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 1 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
333 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 1 WHERE code = '".$db->escape($code).
"'";
337 $result = $db->query($sql);
345if ($action == $acts[1]) {
350 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 0 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
352 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 0 WHERE code = '".$db->escape($code).
"'";
356 $result = $db->query($sql);
364if ($action ==
'activate_favorite') {
369 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 1 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
371 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 1 WHERE code = '".$db->escape($code).
"'";
375 $result = $db->query($sql);
383if ($action ==
'disable_favorite') {
388 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 0 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
390 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 0 WHERE code = '".$db->escape($code).
"'";
394 $result = $db->query($sql);
406$form =
new Form($db);
409$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
411llxHeader(
'', $langs->trans(
'DictionaryAccountancyCategory'), $help_url);
413$titre = $langs->trans($tablib[$id]);
415$titlepicto =
'setup';
419print
'<span class="opacitymedium">'.$langs->trans(
"AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv(
"ByPersonalizedAccountGroups")).
'</span><br><br>';
422if ($action ==
'delete') {
423 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);
429if ($search_country_id > 0) {
430 if (preg_match(
'/ WHERE /', $sql)) {
435 $sql .=
" (a.fk_country = ".((int) $search_country_id).
" OR a.fk_country = 0)";
439if ($sortfield ==
'country') {
440 $sortfield =
'country_code';
442if (empty($sortfield)) {
443 $sortfield =
'position';
446$sql .= $db->order($sortfield, $sortorder);
447$sql .= $db->plimit($listlimit + 1, $offset);
450$fieldlist = explode(
',', $tabfield[$id]);
453if ($search_country_id > 0) {
454 $param .=
'&search_country_id='.urlencode((
string) ($search_country_id));
456$paramwithsearch = $param;
458 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
461 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
464 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
467 $paramwithsearch .=
'&listlimit='.urlencode((
string) (
GETPOSTINT(
'listlimit')));
469print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
470print
'<input type="hidden" name="token" value="'.newToken().
'">';
471print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
472print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
473print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
476print
'<div class="div-table-responsive-no-min">';
477print
'<table class="noborder centpercent">';
481 $fieldlist = explode(
',', $tabfield[$id]);
484 print
'<tr class="liste_titre">';
489 foreach ($fieldlist as $field => $value) {
492 $valuetoshow = ucfirst($fieldlist[$field]);
493 $valuetoshow = $langs->trans($valuetoshow);
495 if ($fieldlist[$field] ==
'type') {
496 if ($tabname[$id] == MAIN_DB_PREFIX.
"c_paiement") {
497 $valuetoshow = $form->textwithtooltip($langs->trans(
"Type"), $langs->trans(
"TypePaymentDesc"), 2, 1,
img_help(1,
''));
499 $valuetoshow = $langs->trans(
"Type");
502 if ($fieldlist[$field] ==
'code') {
503 $valuetoshow = $langs->trans(
"Code");
506 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
507 $valuetoshow = $langs->trans(
"Label");
509 if ($fieldlist[$field] ==
'libelle_facture') {
510 $valuetoshow = $langs->trans(
"LabelOnDocuments");
512 if ($fieldlist[$field] ==
'country') {
513 $valuetoshow = $langs->trans(
"Country");
515 if ($fieldlist[$field] ==
'accountancy_code') {
516 $valuetoshow = $langs->trans(
"AccountancyCode");
518 if ($fieldlist[$field] ==
'accountancy_code_sell') {
519 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
521 if ($fieldlist[$field] ==
'accountancy_code_buy') {
522 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
524 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
525 $valuetoshow = $langs->trans(
"Pcg_version");
527 if ($fieldlist[$field] ==
'range_account') {
528 $valuetoshow = $langs->trans(
"Comment");
531 if ($fieldlist[$field] ==
'category_type') {
532 $valuetoshow = $langs->trans(
"Calculated");
535 if ($valuetoshow !=
'') {
536 print
'<td class="'.$class.
'">';
537 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
538 print
'<a href="'.$tabhelp[$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
539 } elseif (!empty($tabhelp[$id][$value])) {
540 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
549 print
'<input type="hidden" name="id" value="'.$id.
'">';
559 print
'<tr class="oddeven nodrag nodrop nohover">';
568 if (
GETPOST(
'actionadd',
'alpha')) {
569 foreach ($fieldlist as $key => $val) {
576 $tmpaction =
'create';
577 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
578 $reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
579 $error = $hookmanager->error;
580 $errors = $hookmanager->errors;
582 if (empty($reshook)) {
586 print
'<td colspan="2" class="right">';
587 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
597 $colspan = count($fieldlist) + 3;
606print
'<div class="div-table-responsive">';
607print
'<table class="noborder centpercent">';
610dol_syslog(
"htdocs/accountancy/admin/categories_list.php", LOG_DEBUG);
612$resql = $db->query($sql);
614 $num = $db->num_rows($resql);
618 if ($num > $listlimit) {
619 print
'<tr class="none"><td class="right" colspan="'.(2 + count($fieldlist)).
'">';
620 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
625 foreach ($fieldlist as $field => $value) {
627 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
631 if ($value ==
'country') {
638 print
'<tr class="liste_titre liste_titre_add liste_titre_filter">';
642 print
'<td class="liste_titre center">';
644 $searchpicto = $form->showFilterAndCheckAddButtons(0);
651 foreach ($fieldlist as $field => $value) {
654 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
659 if ($value ==
'country') {
660 print
'<td class="liste_titre">';
661 print $form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth150 maxwidthonsmartphone');
665 print
'<td class="liste_titre"></td>';
669 print
'<td class="liste_titre"></td>';
670 print
'<td class="liste_titre"></td>';
673 print
'<td class="liste_titre center">';
675 $searchpicto = $form->showFilterAndCheckAddButtons(0);
683 print
'<tr class="liste_titre">';
688 foreach ($fieldlist as $field => $value) {
696 $valuetoshow = ucfirst($fieldlist[$field]);
697 $valuetoshow = $langs->trans($valuetoshow);
698 if ($fieldlist[$field] ==
'source') {
699 $valuetoshow = $langs->trans(
"Contact");
701 if ($fieldlist[$field] ==
'price') {
702 $valuetoshow = $langs->trans(
"PriceUHT");
704 if ($fieldlist[$field] ==
'taux') {
705 if ($tabname[$id] != MAIN_DB_PREFIX.
"c_revenuestamp") {
706 $valuetoshow = $langs->trans(
"Rate");
708 $valuetoshow = $langs->trans(
"Amount");
712 if ($fieldlist[$field] ==
'type') {
713 $valuetoshow = $langs->trans(
"Type");
715 if ($fieldlist[$field] ==
'code') {
716 $valuetoshow = $langs->trans(
"Code");
718 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
719 $valuetoshow = $langs->trans(
"Label");
721 if ($fieldlist[$field] ==
'country') {
722 $valuetoshow = $langs->trans(
"Country");
724 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
727 if ($fieldlist[$field] ==
'accountancy_code') {
728 $valuetoshow = $langs->trans(
"AccountancyCode");
730 if ($fieldlist[$field] ==
'accountancy_code_sell') {
731 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
734 if ($fieldlist[$field] ==
'accountancy_code_buy') {
735 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
738 if ($fieldlist[$field] ==
'fk_pcg_version') {
739 $valuetoshow = $langs->trans(
"Pcg_version");
741 if ($fieldlist[$field] ==
'account_parent') {
742 $valuetoshow = $langs->trans(
"Accountsparent");
744 if ($fieldlist[$field] ==
'pcg_type') {
745 $valuetoshow = $langs->trans(
"Pcg_type");
747 if ($fieldlist[$field] ==
'type_template') {
748 $valuetoshow = $langs->trans(
"TypeOfTemplate");
750 if ($fieldlist[$field] ==
'range_account') {
751 $valuetoshow = $langs->trans(
"Comment");
753 if ($fieldlist[$field] ==
'category_type') {
754 $valuetoshow = $langs->trans(
"Calculated");
758 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"", $sortfield, $sortorder, $class.
' ');
761 print
getTitleFieldOfList($langs->trans(
"ListOfAccounts"), 0, $_SERVER[
"PHP_SELF"],
"", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
762 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
771 $imaxinloop = ($listlimit ? min($num, $listlimit) : $num);
774 while ($i < $imaxinloop) {
775 $obj = $db->fetch_object($resql);
778 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
779 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
781 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
782 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
783 $error = $hookmanager->error;
784 $errors = $hookmanager->errors;
792 if (empty($reshook)) {
797 print
'<td class="center">';
798 print
'<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"></div>';
799 print
'<input type="hidden" name="page" value="'.$page.
'">';
800 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
801 print
'<input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
802 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
813 if (isset($obj->code)) {
814 if (($obj->code ==
'0' || $obj->code ==
'' || preg_match(
'/unknown/i', $obj->code))) {
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;
832 $errors = $hookmanager->errors;
836 print
'<td class="center">';
837 if ($canbemodified) {
838 print
'<a class="reposition editfielda marginleftonly marginrightonly" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
842 print
'<a class="marginleftonly marginrightonly" href="'.$url.
'action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
848 if (empty($reshook)) {
849 foreach ($fieldlist as $field => $value) {
854 $tmpvar = $fieldlist[$field];
855 $valuetoshow = $obj->$tmpvar;
856 if ($value ==
'category_type') {
857 $valuetoshow =
yn($valuetoshow);
858 } elseif ($valuetoshow ==
'all') {
859 $valuetoshow = $langs->trans(
'All');
860 } elseif ($fieldlist[$field] ==
'country') {
861 if (empty($obj->country_code)) {
864 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
865 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
867 } elseif (in_array($fieldlist[$field], array(
'label',
'formula'))) {
868 $class =
"tdoverflowmax250";
869 $title = $valuetoshow;
870 } elseif (in_array($fieldlist[$field], array(
'range_account'))) {
871 $class =
"tdoverflowmax250 small";
872 $title = $valuetoshow;
873 } elseif ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
879 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'"'.($title ?
' title="'.dol_escape_htmltag($title).
'"' :
'').
'>'.
dol_escape_htmltag($valuetoshow).
'</td>';
886 if (empty($obj->formula)) {
888 $nbofaccountintogroup = 0;
889 $listofaccountintogroup = $accountingcategory->getCptsCat($obj->rowid);
890 $nbofaccountintogroup = count($listofaccountintogroup);
892 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.
'">';
893 print $langs->trans(
"NAccounts", $nbofaccountintogroup);
896 print
'<span class="opacitymedium">'.$langs->trans(
"Formula").
'</span>';
901 print
'<td class="center" class="nowrap">';
902 if ($canbedisabled) {
903 print
'<a href="'.$url.
'action='.$acts[$obj->active].
'">'.$actl[$obj->active].
'</a>';
905 print $langs->trans(
"AlwaysActive");
911 print
'<td class="center">';
912 if ($canbemodified) {
913 print
'<a class="reposition editfielda paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
917 print
'<a class="paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
928 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
957 global $conf, $langs, $db;
958 global $form, $mysoc;
962 if (isModEnabled(
'accounting')) {
966 foreach ($fieldlist as $field => $value) {
967 if ($fieldlist[$field] ==
'country') {
969 $fieldname =
'country';
970 if ($context ==
'add') {
971 $fieldname =
'country_id';
972 $preselectcountrycode = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : $mysoc->country_code;
973 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
975 $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code);
976 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
979 } elseif ($fieldlist[$field] ==
'country_id') {
980 if (!in_array(
'country', $fieldlist)) {
981 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
983 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
986 } elseif ($fieldlist[$field] ==
'category_type') {
988 print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
''), 1);
990 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
991 print
'<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
'').
'" name="'.$fieldlist[$field].
'"></td>';
995 if (in_array($fieldlist[$field], array(
'code',
'formula'))) {
996 $class =
'maxwidth75';
998 if (in_array($fieldlist[$field], array(
'label',
'range_account'))) {
999 $class =
'maxwidth150';
1001 if ($fieldlist[$field] ==
'position') {
1002 $class =
'maxwidth50';
1004 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($title, $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.
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.
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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.