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';
47$langs->loadLangs(array(
"errors",
"admin",
"companies",
"resource",
"holiday",
"accountancy",
"hrm"));
49$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
50$confirm =
GETPOST(
'confirm',
'alpha');
52$rowid =
GETPOST(
'rowid',
'alpha');
53$code =
GETPOST(
'code',
'alpha');
56if (!$user->hasRight(
'accounting',
'chartofaccount')) {
64$actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="size15x"');
65$actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="size15x"');
67$listoffset =
GETPOST(
'listoffset',
'alpha');
70$sortfield =
GETPOST(
"sortfield",
'aZ09comma');
71$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
73if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
77$offset = $listlimit * $page;
81$search_country_id =
GETPOST(
'search_country_id',
'int');
84$hookmanager->initHooks(array(
'admin'));
94$tabname[32] = MAIN_DB_PREFIX.
"c_accounting_category";
98$tablib[32] =
"DictionaryAccountancyCategory";
102$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";
105$tabsqlsort = array();
106$tabsqlsort[32] =
"position ASC";
110$tabfield[32] =
"code,label,range_account,category_type,formula,position,country";
113$tabfieldvalue = array();
114$tabfieldvalue[32] =
"code,label,range_account,category_type,formula,position,country_id";
117$tabfieldinsert = array();
118$tabfieldinsert[32] =
"code,label,range_account,category_type,formula,position,fk_country";
128$tabcond[32] = isModEnabled(
'accounting');
132$tabhelp[32] = array(
'code' => $langs->trans(
"EnterAnyCode"),
'category_type' => $langs->trans(
"SetToYesIfGroupIsComputationOfOtherGroups"),
'formula' => $langs->trans(
"EnterCalculationRuleIfPreviousFieldIsYes"));
135$tabfieldcheck = array();
136$tabfieldcheck[32] = array();
139complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
148if (
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter_x',
'alpha')) {
149 $search_country_id =
'';
153if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
154 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
155 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
156 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
157 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
161 foreach ($listfield as $f => $value) {
162 if ($value ==
'formula' && !
GETPOST(
'formula')) {
165 if ($value ==
'range_account' && !
GETPOST(
'range_account')) {
168 if (($value ==
'country' || $value ==
'country_id') &&
GETPOST(
'country_id')) {
171 if (!GETPOSTISSET($value) ||
GETPOST($value) ==
'') {
173 $fieldnamekey = $listfield[$f];
175 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
176 $fieldnamekey =
'Label';
178 if ($fieldnamekey ==
'code') {
179 $fieldnamekey =
'Code';
181 if ($fieldnamekey ==
'note') {
182 $fieldnamekey =
'Note';
184 if ($fieldnamekey ==
'type') {
185 $fieldnamekey =
'Type';
187 if ($fieldnamekey ==
'position') {
188 $fieldnamekey =
'Position';
190 if ($fieldnamekey ==
'category_type') {
191 $fieldnamekey =
'Calculated';
193 if ($fieldnamekey ==
'country') {
194 $fieldnamekey =
'Country';
197 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
200 if (GETPOSTISSET(
"code")) {
203 setEventMessages($langs->transnoentities(
'ErrorCodeCantContainZero'),
null,
'errors');
206 if (
GETPOST(
'position') && !is_numeric(
GETPOST(
'position',
'alpha'))) {
207 $langs->loadLangs(array(
"errors"));
209 setEventMessages($langs->transnoentities(
'ErrorFieldMustBeANumeric', $langs->transnoentities(
"Position")),
null,
'errors');
213 if ($ok &&
GETPOST(
'actionadd',
'alpha')) {
216 if ($tabrowid[$id]) {
218 $sql =
"SELECT MAX(".$db->sanitize($tabrowid[$id]).
") newid FROM ".$db->sanitize($tabname[$id]);
219 $result = $db->query($sql);
221 $obj = $db->fetch_object($result);
222 $newid = ($obj->newid + 1);
229 $sql =
"INSERT INTO ".$db->sanitize($tabname[$id]).
" (";
231 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
232 $sql .= $db->sanitize($tabrowid[$id]).
",";
234 $sql .= $db->sanitize($tabfieldinsert[$id]);
239 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
243 foreach ($listfieldinsert as $f => $value) {
244 if ($value ==
'entity') {
245 $_POST[$listfieldvalue[$i]] =
$conf->entity;
250 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'formula') {
253 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
260 $result = $db->query($sql);
263 $_POST = array(
'id' => $id);
265 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
266 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
274 if ($ok &&
GETPOST(
'actionmodify',
'alpha')) {
275 if ($tabrowid[$id]) {
276 $rowidcol = $tabrowid[
$id];
282 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET ";
284 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
285 $sql .= $db->sanitize($tabrowid[$id]).
" = ";
286 $sql .=
"'".$db->escape($rowid).
"', ";
289 foreach ($listfieldmodify as $field) {
290 if ($field ==
'fk_country' &&
GETPOST(
'country') > 0) {
291 $_POST[$listfieldvalue[$i]] =
GETPOST(
'country');
292 } elseif ($field ==
'entity') {
293 $_POST[$listfieldvalue[$i]] =
$conf->entity;
299 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'range_account') {
302 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
306 $sql .=
" WHERE ".$rowidcol.
" = ".((int) $rowid);
310 $resql = $db->query($sql);
317if ($action ==
'confirm_delete' && $confirm ==
'yes') {
320 $sql =
"DELETE from ".$db->sanitize($tabname[$id]).
" WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
323 $result = $db->query($sql);
325 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
326 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
334if ($action == $acts[0]) {
339 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 1 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
341 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 1 WHERE code = '".$db->escape($code).
"'";
345 $result = $db->query($sql);
353if ($action == $acts[1]) {
358 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 0 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
360 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 0 WHERE code = '".$db->escape($code).
"'";
364 $result = $db->query($sql);
372if ($action ==
'activate_favorite') {
377 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 1 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
379 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 1 WHERE code = '".$db->escape($code).
"'";
383 $result = $db->query($sql);
391if ($action ==
'disable_favorite') {
396 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 0 WHERE ".$db->sanitize($rowidcol).
" = ".((int) $rowid);
398 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET favorite = 0 WHERE code = '".$db->escape($code).
"'";
402 $result = $db->query($sql);
414$form =
new Form($db);
417$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
419llxHeader(
'', $langs->trans(
'DictionaryAccountancyCategory'), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy page-admin_categories_list');
421$titre = $langs->trans($tablib[$id]);
423$titlepicto =
'setup';
427print
'<span class="opacitymedium">'.$langs->trans(
"AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv(
"ByPersonalizedAccountGroups")).
'</span><br><br>';
430if ($action ==
'delete') {
431 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);
437if ($search_country_id > 0) {
438 if (preg_match(
'/ WHERE /', $sql)) {
443 $sql .=
" (a.fk_country = ".((int) $search_country_id).
" OR a.fk_country = 0)";
447if ($sortfield ==
'country') {
448 $sortfield =
'country_code';
450if (empty($sortfield)) {
451 $sortfield =
'position';
454$sql .= $db->order($sortfield, $sortorder);
455$sql .= $db->plimit($listlimit + 1, $offset);
458$fieldlist = explode(
',', $tabfield[$id]);
461if ($search_country_id > 0) {
462 $param .=
'&search_country_id='.urlencode((
string) ($search_country_id));
464$paramwithsearch = $param;
466 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
469 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
472 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
475 $paramwithsearch .=
'&listlimit='.urlencode((
string) (
GETPOSTINT(
'listlimit')));
477print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$id.
'" method="POST">';
478print
'<input type="hidden" name="token" value="'.newToken().
'">';
479print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
480print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
481print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
484print
'<div class="div-table-responsive-no-min">';
485print
'<table class="noborder centpercent">';
489 $fieldlist = explode(
',', $tabfield[$id]);
492 print
'<tr class="liste_titre">';
497 foreach ($fieldlist as $field => $value) {
500 $valuetoshow = ucfirst($fieldlist[$field]);
501 $valuetoshow = $langs->trans($valuetoshow);
503 if ($fieldlist[$field] ==
'type') {
504 if ($tabname[$id] == MAIN_DB_PREFIX.
"c_paiement") {
505 $valuetoshow = $form->textwithtooltip($langs->trans(
"Type"), $langs->trans(
"TypePaymentDesc"), 2, 1,
img_help(1,
''));
507 $valuetoshow = $langs->trans(
"Type");
510 if ($fieldlist[$field] ==
'code') {
511 $valuetoshow = $langs->trans(
"Code");
514 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
515 $valuetoshow = $langs->trans(
"Label");
517 if ($fieldlist[$field] ==
'libelle_facture') {
518 $valuetoshow = $langs->trans(
"LabelOnDocuments");
520 if ($fieldlist[$field] ==
'country') {
521 $valuetoshow = $langs->trans(
"Country");
523 if ($fieldlist[$field] ==
'accountancy_code') {
524 $valuetoshow = $langs->trans(
"AccountancyCode");
526 if ($fieldlist[$field] ==
'accountancy_code_sell') {
527 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
529 if ($fieldlist[$field] ==
'accountancy_code_buy') {
530 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
532 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
533 $valuetoshow = $langs->trans(
"Pcg_version");
535 if ($fieldlist[$field] ==
'range_account') {
536 $valuetoshow = $langs->trans(
"Comment");
539 if ($fieldlist[$field] ==
'category_type') {
540 $valuetoshow = $langs->trans(
"Calculated");
543 if ($valuetoshow !=
'') {
544 print
'<td class="'.$class.
'">';
545 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
546 print
'<a href="'.$tabhelp[
$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
547 } elseif (!empty($tabhelp[$id][$value])) {
548 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
557 print
'<input type="hidden" name="id" value="'.$id.
'">';
567 print
'<tr class="oddeven nodrag nodrop nohover">';
576 if (
GETPOST(
'actionadd',
'alpha')) {
577 foreach ($fieldlist as $key => $val) {
584 $tmpaction =
'create';
585 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
586 $reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
587 $error = $hookmanager->error;
588 $errors = $hookmanager->errors;
590 if (empty($reshook)) {
594 print
'<td colspan="2" class="right">';
595 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
605 $colspan = count($fieldlist) + 3;
614print
'<div class="div-table-responsive">';
615print
'<table class="noborder centpercent">';
618dol_syslog(
"htdocs/accountancy/admin/categories_list.php", LOG_DEBUG);
620$resql = $db->query($sql);
622 $num = $db->num_rows($resql);
626 if ($num > $listlimit) {
627 print
'<tr class="none"><td class="right" colspan="'.(2 + count($fieldlist)).
'">';
628 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
633 foreach ($fieldlist as $field => $value) {
635 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
639 if ($value ==
'country') {
646 print
'<tr class="liste_titre liste_titre_filter">';
650 print
'<td class="liste_titre center">';
652 $searchpicto = $form->showFilterAndCheckAddButtons(0);
659 foreach ($fieldlist as $field => $value) {
662 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
667 if ($value ==
'country') {
668 print
'<td class="liste_titre">';
669 print $form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth150 maxwidthonsmartphone');
673 print
'<td class="liste_titre"></td>';
677 print
'<td class="liste_titre"></td>';
678 print
'<td class="liste_titre"></td>';
681 print
'<td class="liste_titre center">';
683 $searchpicto = $form->showFilterAndCheckAddButtons(0);
691 print
'<tr class="liste_titre">';
696 foreach ($fieldlist as $field => $value) {
704 $valuetoshow = ucfirst($fieldlist[$field]);
705 $valuetoshow = $langs->trans($valuetoshow);
706 if ($fieldlist[$field] ==
'source') {
707 $valuetoshow = $langs->trans(
"Contact");
709 if ($fieldlist[$field] ==
'price') {
710 $valuetoshow = $langs->trans(
"PriceUHT");
712 if ($fieldlist[$field] ==
'taux') {
713 if ($tabname[$id] != MAIN_DB_PREFIX.
"c_revenuestamp") {
714 $valuetoshow = $langs->trans(
"Rate");
716 $valuetoshow = $langs->trans(
"Amount");
720 if ($fieldlist[$field] ==
'type') {
721 $valuetoshow = $langs->trans(
"Type");
723 if ($fieldlist[$field] ==
'code') {
724 $valuetoshow = $langs->trans(
"Code");
726 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
727 $valuetoshow = $langs->trans(
"Label");
729 if ($fieldlist[$field] ==
'country') {
730 $valuetoshow = $langs->trans(
"Country");
732 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
735 if ($fieldlist[$field] ==
'accountancy_code') {
736 $valuetoshow = $langs->trans(
"AccountancyCode");
738 if ($fieldlist[$field] ==
'accountancy_code_sell') {
739 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
742 if ($fieldlist[$field] ==
'accountancy_code_buy') {
743 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
746 if ($fieldlist[$field] ==
'fk_pcg_version') {
747 $valuetoshow = $langs->trans(
"Pcg_version");
749 if ($fieldlist[$field] ==
'account_parent') {
750 $valuetoshow = $langs->trans(
"Accountsparent");
752 if ($fieldlist[$field] ==
'pcg_type') {
753 $valuetoshow = $langs->trans(
"Pcg_type");
755 if ($fieldlist[$field] ==
'type_template') {
756 $valuetoshow = $langs->trans(
"TypeOfTemplate");
758 if ($fieldlist[$field] ==
'range_account') {
759 $valuetoshow = $langs->trans(
"Comment");
761 if ($fieldlist[$field] ==
'category_type') {
762 $valuetoshow = $langs->trans(
"Calculated");
766 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"", $sortfield, $sortorder, $class.
' ');
769 print
getTitleFieldOfList($langs->trans(
"ListOfAccounts"), 0, $_SERVER[
"PHP_SELF"],
"", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
770 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
779 $imaxinloop = ($listlimit ? min($num, $listlimit) : $num);
782 while ($i < $imaxinloop) {
783 $obj = $db->fetch_object($resql);
786 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
787 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
789 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
790 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
791 $error = $hookmanager->error;
792 $errors = $hookmanager->errors;
800 if (empty($reshook)) {
805 print
'<td class="center">';
806 print
'<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"></div>';
807 print
'<input type="hidden" name="page" value="'.$page.
'">';
808 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
809 print
'<input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
810 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
821 if (isset($obj->code)) {
822 if (($obj->code ==
'0' || $obj->code ==
'' || preg_match(
'/unknown/i', $obj->code))) {
827 $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) :
'');
833 $canbemodified = $iserasable;
836 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
837 $reshook = $hookmanager->executeHooks(
'viewDictionaryFieldlist', $parameters, $obj, $tmpaction);
839 $error = $hookmanager->error;
840 $errors = $hookmanager->errors;
844 print
'<td class="center">';
845 if ($canbemodified) {
846 print
'<a class="reposition editfielda marginleftonly marginrightonly" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
850 print
'<a class="marginleftonly marginrightonly" href="'.$url.
'action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
856 if (empty($reshook)) {
857 foreach ($fieldlist as $field => $value) {
862 $tmpvar = $fieldlist[$field];
863 $valuetoshow = $obj->$tmpvar;
864 if ($value ==
'category_type') {
865 $valuetoshow =
yn($valuetoshow);
866 } elseif ($valuetoshow ==
'all') {
867 $valuetoshow = $langs->trans(
'All');
868 } elseif ($fieldlist[$field] ==
'country') {
869 if (empty($obj->country_code)) {
872 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
873 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
875 } elseif (in_array($fieldlist[$field], array(
'label',
'formula'))) {
876 $class =
"tdoverflowmax250";
877 $title = $valuetoshow;
878 } elseif (in_array($fieldlist[$field], array(
'range_account'))) {
879 $class =
"tdoverflowmax250 small";
880 $title = $valuetoshow;
881 } elseif ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
887 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'"'.($title ?
' title="'.dol_escape_htmltag($title).
'"' :
'').
'>'.
dol_escape_htmltag($valuetoshow).
'</td>';
894 if (empty($obj->formula)) {
896 $nbofaccountintogroup = 0;
897 $listofaccountintogroup = $accountingcategory->getCptsCat($obj->rowid);
898 $nbofaccountintogroup = count($listofaccountintogroup);
900 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.
'">';
901 print $langs->trans(
"NAccounts", $nbofaccountintogroup);
904 print
'<span class="opacitymedium">'.$langs->trans(
"Formula").
'</span>';
909 print
'<td class="center" class="nowrap">';
910 if ($canbedisabled) {
911 print
'<a class="reposition" href="'.$url.
'action='.urlencode($acts[$obj->active]).
'&token='.
newToken().
'">'.$actl[$obj->active].
'</a>';
913 print $langs->trans(
"AlwaysActive");
919 print
'<td class="center">';
920 if ($canbemodified) {
921 print
'<a class="reposition editfielda paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a>';
925 print
'<a class="paddingleft marginleftonly marginrightonly paddingright" href="'.$url.
'action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
936 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
965 global $form, $mysoc;
967 foreach ($fieldlist as $field => $value) {
968 if ($fieldlist[$field] ==
'country') {
970 $fieldname =
'country';
972 $fieldname =
'country_id';
973 $preselectcountrycode = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : $mysoc->country_code;
974 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
976 $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code);
977 print $form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
980 } elseif ($fieldlist[$field] ==
'country_id') {
981 if (!in_array(
'country', $fieldlist)) {
982 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
984 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
987 } elseif ($fieldlist[$field] ==
'category_type') {
989 print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
''), 1);
991 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
992 print
'<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
'').
'" name="'.$fieldlist[$field].
'"></td>';
996 if (in_array($fieldlist[$field], array(
'code',
'formula'))) {
997 $class =
'maxwidth75';
999 if (in_array($fieldlist[$field], array(
'label',
'range_account'))) {
1000 $class =
'maxwidth150';
1002 if ($fieldlist[$field] ==
'position') {
1003 $class =
'maxwidth50';
1005 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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $selectlimitsuffix='', $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
getDolGlobalString($key, $default='')
Return a 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$context
@method int call_trigger(string $triggerName, User $user)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.