26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
34 require_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');
46 if (!$user->hasRight(
'accounting',
'chartofaccount')) {
50 $acts[0] =
"activate";
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');
61 if (empty($page) || $page == -1) {
64 $offset = $listlimit * $page;
65 $pageprev = $page - 1;
66 $pagenext = $page + 1;
68 $search_country_id =
GETPOST(
'search_country_id',
'int');
71 $hookmanager->initHooks(array(
'admin'));
77 $taborder = array(32);
81 $tabname[32] = MAIN_DB_PREFIX.
"c_accounting_category";
85 $tablib[32] =
"DictionaryAccountancyCategory";
89 $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";
92 $tabsqlsort = array();
93 $tabsqlsort[32] =
"position ASC";
97 $tabfield[32] =
"code,label,range_account,category_type,formula,position,country";
100 $tabfieldvalue = array();
101 $tabfieldvalue[32] =
"code,label,range_account,category_type,formula,position,country_id";
104 $tabfieldinsert = array();
105 $tabfieldinsert[32] =
"code,label,range_account,category_type,formula,position,fk_country";
119 $tabhelp[32] = array(
'code'=>$langs->trans(
"EnterAnyCode"),
'category_type'=>$langs->trans(
"SetToYesIfGroupIsComputationOfOtherGroups"),
'formula'=>$langs->trans(
"EnterCalculationRuleIfPreviousFieldIsYes"));
122 $tabfieldcheck = array();
123 $tabfieldcheck[32] = array();
126 complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
135 if (
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter_x',
'alpha')) {
136 $search_country_id =
'';
140 if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
141 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
142 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
143 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
144 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
148 foreach ($listfield as $f => $value) {
149 if ($value ==
'formula' && !
GETPOST(
'formula')) {
152 if ($value ==
'range_account' && !
GETPOST(
'range_account')) {
155 if (($value ==
'country' || $value ==
'country_id') &&
GETPOST(
'country_id')) {
160 $fieldnamekey = $listfield[$f];
162 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
163 $fieldnamekey =
'Label';
165 if ($fieldnamekey ==
'code') {
166 $fieldnamekey =
'Code';
168 if ($fieldnamekey ==
'note') {
169 $fieldnamekey =
'Note';
171 if ($fieldnamekey ==
'type') {
172 $fieldnamekey =
'Type';
174 if ($fieldnamekey ==
'position') {
175 $fieldnamekey =
'Position';
177 if ($fieldnamekey ==
'category_type') {
178 $fieldnamekey =
'Calculated';
180 if ($fieldnamekey ==
'country') {
181 $fieldnamekey =
'Country';
184 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
190 setEventMessages($langs->transnoentities(
'ErrorCodeCantContainZero'),
null,
'errors');
193 if (
GETPOST(
'position') && !is_numeric(
GETPOST(
'position',
'alpha'))) {
194 $langs->loadLangs(array(
"errors"));
196 setEventMessages($langs->transnoentities(
'ErrorFieldMustBeANumeric', $langs->transnoentities(
"Position")),
null,
'errors');
200 if ($ok &&
GETPOST(
'actionadd',
'alpha')) {
201 if ($tabrowid[$id]) {
204 $sql =
"SELECT max(".$tabrowid[$id].
") newid from ".$tabname[$id];
205 $result = $db->query($sql);
207 $obj = $db->fetch_object($result);
208 $newid = ($obj->newid + 1);
215 $sql =
"INSERT INTO ".$tabname[$id].
" (";
217 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
218 $sql .= $tabrowid[$id].
",";
220 $sql .= $tabfieldinsert[$id];
225 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
229 foreach ($listfieldinsert as $f => $value) {
230 if ($value ==
'entity') {
231 $_POST[$listfieldvalue[$i]] = $conf->entity;
236 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'formula') {
239 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
246 $result = $db->query($sql);
249 $_POST = array(
'id'=>$id);
251 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
252 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
260 if ($ok &&
GETPOST(
'actionmodify',
'alpha')) {
261 if ($tabrowid[$id]) {
262 $rowidcol = $tabrowid[$id];
268 $sql =
"UPDATE ".$tabname[$id].
" SET ";
270 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
271 $sql .= $tabrowid[$id].
"=";
272 $sql .=
"'".$db->escape($rowid).
"', ";
275 foreach ($listfieldmodify as $field) {
276 if ($field ==
'fk_country' &&
GETPOST(
'country') > 0) {
277 $_POST[$listfieldvalue[$i]] =
GETPOST(
'country');
278 } elseif ($field ==
'entity') {
279 $_POST[$listfieldvalue[$i]] = $conf->entity;
285 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'range_account') {
288 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
292 $sql .=
" WHERE ".$rowidcol.
" = ".((int) $rowid);
296 $resql = $db->query($sql);
304 if (
GETPOST(
'actioncancel',
'alpha')) {
308 if ($action ==
'confirm_delete' && $confirm ==
'yes') {
309 if ($tabrowid[$id]) {
310 $rowidcol = $tabrowid[$id];
315 $sql =
"DELETE from ".$tabname[$id].
" WHERE ".$rowidcol.
" = ".((int) $rowid);
318 $result = $db->query($sql);
320 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
321 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
329 if ($action == $acts[0]) {
330 if ($tabrowid[$id]) {
331 $rowidcol = $tabrowid[$id];
337 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
339 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE code = '".$db->escape($code).
"'";
342 $result = $db->query($sql);
349 if ($action == $acts[1]) {
350 if ($tabrowid[$id]) {
351 $rowidcol = $tabrowid[$id];
357 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
359 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE code = '".$db->escape($code).
"'";
362 $result = $db->query($sql);
369 if ($action ==
'activate_favorite') {
370 if ($tabrowid[$id]) {
371 $rowidcol = $tabrowid[$id];
377 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
379 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE code = '".$db->escape($code).
"'";
382 $result = $db->query($sql);
389 if ($action ==
'disable_favorite') {
390 if ($tabrowid[$id]) {
391 $rowidcol = $tabrowid[$id];
397 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
399 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE code = '".$db->escape($code).
"'";
402 $result = $db->query($sql);
416 llxHeader(
'', $langs->trans(
'DictionaryAccountancyCategory'));
418 $titre = $langs->trans($tablib[$id]);
420 $titlepicto =
'setup';
424 print
'<span class="opacitymedium">'.$langs->trans(
"AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv(
"ByPersonalizedAccountGroups")).
'</span><br><br>';
427 if ($action ==
'delete') {
428 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);
434 if ($search_country_id > 0) {
435 if (preg_match(
'/ WHERE /', $sql)) {
440 $sql .=
" (a.fk_country = ".((int) $search_country_id).
" OR a.fk_country = 0)";
444 if ($sortfield ==
'country') {
445 $sortfield =
'country_code';
447 if (empty($sortfield)) {
448 $sortfield =
'position';
451 $sql .= $db->order($sortfield, $sortorder);
452 $sql .= $db->plimit($listlimit + 1, $offset);
455 $fieldlist = explode(
',', $tabfield[$id]);
458 if ($search_country_id > 0) {
459 $param .=
'&search_country_id='.urlencode($search_country_id);
461 $paramwithsearch = $param;
463 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
466 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
468 if (
GETPOST(
'from',
'alpha')) {
469 $paramwithsearch .=
'&from='.urlencode(
GETPOST(
'from',
'alpha'));
472 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
473 print
'<input type="hidden" name="token" value="'.newToken().
'">';
474 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
475 print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
476 print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
479 print
'<div class="div-table-responsive">';
480 print
'<table class="noborder centpercent">';
484 $fieldlist = explode(
',', $tabfield[$id]);
487 print
'<tr class="liste_titre">';
488 foreach ($fieldlist as $field => $value) {
491 $valuetoshow = ucfirst($fieldlist[$field]);
492 $valuetoshow = $langs->trans($valuetoshow);
494 if ($fieldlist[$field] ==
'type') {
495 if ($tabname[$id] == MAIN_DB_PREFIX.
"c_paiement") {
496 $valuetoshow =
$form->textwithtooltip($langs->trans(
"Type"), $langs->trans(
"TypePaymentDesc"), 2, 1,
img_help(1,
''));
498 $valuetoshow = $langs->trans(
"Type");
501 if ($fieldlist[$field] ==
'code') {
502 $valuetoshow = $langs->trans(
"Code");
504 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
505 $valuetoshow = $langs->trans(
"Label");
507 if ($fieldlist[$field] ==
'libelle_facture') {
508 $valuetoshow = $langs->trans(
"LabelOnDocuments");
510 if ($fieldlist[$field] ==
'country') {
511 $valuetoshow = $langs->trans(
"Country");
513 if ($fieldlist[$field] ==
'accountancy_code') {
514 $valuetoshow = $langs->trans(
"AccountancyCode");
516 if ($fieldlist[$field] ==
'accountancy_code_sell') {
517 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
519 if ($fieldlist[$field] ==
'accountancy_code_buy') {
520 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
522 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
523 $valuetoshow = $langs->trans(
"Pcg_version");
525 if ($fieldlist[$field] ==
'range_account') {
526 $valuetoshow = $langs->trans(
"Comment");
528 if ($fieldlist[$field] ==
'category_type') {
529 $valuetoshow = $langs->trans(
"Calculated");
532 if ($valuetoshow !=
'') {
533 print
'<td class="'.$class.
'">';
534 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
535 print
'<a href="'.$tabhelp[$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
536 } elseif (!empty($tabhelp[$id][$value])) {
537 print
$form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
546 print
'<input type="hidden" name="id" value="'.$id.
'">';
548 print
'<td style="min-width: 26px;"></td>';
549 print
'<td style="min-width: 26px;"></td>';
550 print
'<td style="min-width: 26px;"></td>';
554 print
'<tr class="oddeven nodrag nodrop nohover">';
556 $obj =
new stdClass();
558 if (
GETPOST(
'actionadd',
'alpha')) {
559 foreach ($fieldlist as $key => $val) {
566 $tmpaction =
'create';
567 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
568 $reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
569 $error = $hookmanager->error; $errors = $hookmanager->errors;
571 if (empty($reshook)) {
575 print
'<td colspan="4" class="right">';
576 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
580 $colspan = count($fieldlist) + 3;
585 print
'<tr><td colspan="'.$colspan.
'"> </td></tr>';
589 dol_syslog(
"htdocs/accountancy/admin/categories_list.php", LOG_DEBUG);
591 $resql = $db->query($sql);
593 $num = $db->num_rows(
$resql);
597 if ($num > $listlimit) {
598 print
'<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).
'">';
599 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
604 print
'<tr class="liste_titre liste_titre_add liste_titre_filter">';
606 foreach ($fieldlist as $field => $value) {
609 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
614 if ($value ==
'country') {
615 print
'<td class="liste_titre">';
616 print
$form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth150 maxwidthonsmartphone');
620 print
'<td class="liste_titre"></td>';
624 print
'<td class="liste_titre"></td>';
625 print
'<td class="liste_titre"></td>';
626 print
'<td class="liste_titre"></td>';
627 print
'<td class="liste_titre center">';
629 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
636 print
'<tr class="liste_titre">';
637 foreach ($fieldlist as $field => $value) {
645 $valuetoshow = ucfirst($fieldlist[$field]);
646 $valuetoshow = $langs->trans($valuetoshow);
647 if ($fieldlist[$field] ==
'source') {
648 $valuetoshow = $langs->trans(
"Contact");
650 if ($fieldlist[$field] ==
'price') {
651 $valuetoshow = $langs->trans(
"PriceUHT");
653 if ($fieldlist[$field] ==
'taux') {
654 if ($tabname[$id] != MAIN_DB_PREFIX.
"c_revenuestamp") {
655 $valuetoshow = $langs->trans(
"Rate");
657 $valuetoshow = $langs->trans(
"Amount");
661 if ($fieldlist[$field] ==
'type') {
662 $valuetoshow = $langs->trans(
"Type");
664 if ($fieldlist[$field] ==
'code') {
665 $valuetoshow = $langs->trans(
"Code");
667 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
668 $valuetoshow = $langs->trans(
"Label");
670 if ($fieldlist[$field] ==
'country') {
671 $valuetoshow = $langs->trans(
"Country");
673 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
676 if ($fieldlist[$field] ==
'accountancy_code') {
677 $valuetoshow = $langs->trans(
"AccountancyCode");
679 if ($fieldlist[$field] ==
'accountancy_code_sell') {
680 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
683 if ($fieldlist[$field] ==
'accountancy_code_buy') {
684 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
687 if ($fieldlist[$field] ==
'fk_pcg_version') {
688 $valuetoshow = $langs->trans(
"Pcg_version");
690 if ($fieldlist[$field] ==
'account_parent') {
691 $valuetoshow = $langs->trans(
"Accountsparent");
693 if ($fieldlist[$field] ==
'pcg_type') {
694 $valuetoshow = $langs->trans(
"Pcg_type");
696 if ($fieldlist[$field] ==
'type_template') {
697 $valuetoshow = $langs->trans(
"TypeOfTemplate");
699 if ($fieldlist[$field] ==
'range_account') {
700 $valuetoshow = $langs->trans(
"Comment");
702 if ($fieldlist[$field] ==
'category_type') {
703 $valuetoshow = $langs->trans(
"Calculated");
707 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"", $sortfield, $sortorder, $class.
' ');
710 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
719 $obj = $db->fetch_object(
$resql);
721 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
722 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
724 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
725 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
726 $error = $hookmanager->error; $errors = $hookmanager->errors;
729 if (empty($reshook)) {
735 print
'<td class="center">';
736 print
'<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"></div>';
737 print
'<input type="hidden" name="page" value="'.$page.
'">';
738 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
739 print
'<input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
740 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
745 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
746 $reshook = $hookmanager->executeHooks(
'viewDictionaryFieldlist', $parameters, $obj, $tmpaction);
748 $error = $hookmanager->error; $errors = $hookmanager->errors;
750 if (empty($reshook)) {
751 foreach ($fieldlist as $field => $value) {
754 $tmpvar = $fieldlist[$field];
755 $valuetoshow = $obj->$tmpvar;
756 if ($value ==
'category_type') {
757 $valuetoshow =
yn($valuetoshow);
758 } elseif ($valuetoshow ==
'all') {
759 $valuetoshow = $langs->trans(
'All');
760 } elseif ($fieldlist[$field] ==
'country') {
761 if (empty($obj->country_code)) {
764 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
765 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
767 } elseif ($fieldlist[$field] ==
'label' && $tabname[$id] == MAIN_DB_PREFIX.
'c_country') {
768 $key = $langs->trans(
"Country".strtoupper($obj->code));
769 $valuetoshow = ($obj->code && $key !=
"Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
770 } elseif ($fieldlist[$field] ==
'label' && $tabname[$id] == MAIN_DB_PREFIX.
'c_availability') {
771 $langs->loadLangs(array(
"propal"));
772 $key = $langs->trans(
"AvailabilityType".strtoupper($obj->code));
773 $valuetoshow = ($obj->code && $key !=
"AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
774 } elseif ($fieldlist[$field] ==
'libelle' && $tabname[$id] == MAIN_DB_PREFIX.
'c_actioncomm') {
775 $key = $langs->trans(
"Action".strtoupper($obj->code));
776 $valuetoshow = ($obj->code && $key !=
"Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
777 } elseif ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
784 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'">'.
dol_escape_htmltag($valuetoshow).
'</td>';
790 $iserasable = 1; $canbedisabled = 1; $canbemodified = 1;
791 if (isset($obj->code)) {
792 if (($obj->code ==
'0' || $obj->code ==
'' || preg_match(
'/unknown/i', $obj->code))) {
793 $iserasable = 0; $canbedisabled = 0;
797 $canbemodified = $iserasable;
799 $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) :
'');
806 print
'<td class="center" class="nowrap">';
807 if ($canbedisabled) {
808 print
'<a href="'.$url.
'action='.$acts[$obj->active].
'">'.$actl[$obj->active].
'</a>';
810 print $langs->trans(
"AlwaysActive");
815 if ($canbemodified) {
816 print
'<td class="center"><a class="reposition editfielda" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a></td>';
818 print
'<td> </td>';
823 print
'<td class="center">';
830 print
'<td> </td>';
835 if (empty($obj->formula)) {
836 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.
'">';
837 print $langs->trans(
"ListOfAccounts");
841 $nbofaccountintogroup = 0;
842 $listofaccountintogroup = $accountingcategory->getCptsCat($obj->rowid);
843 $nbofaccountintogroup = count($listofaccountintogroup);
845 print
' <span class="opacitymedium">('.$langs->trans(
"NAccounts", $nbofaccountintogroup).
')</span>';
883 global $conf, $langs, $db;
884 global
$form, $mysoc;
892 foreach ($fieldlist as $field => $value) {
893 if ($fieldlist[$field] ==
'country') {
895 $fieldname =
'country';
896 if ($context ==
'add') {
897 $fieldname =
'country_id';
898 $preselectcountrycode =
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_code;
899 print
$form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
901 $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code);
902 print
$form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth150 maxwidthonsmartphone');
905 } elseif ($fieldlist[$field] ==
'country_id') {
906 if (!in_array(
'country', $fieldlist)) {
907 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
909 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
912 } elseif ($fieldlist[$field] ==
'category_type') {
914 print
$form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
''), 1);
916 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
917 print
'<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
'').
'" name="'.$fieldlist[$field].
'"></td>';
920 $size =
''; $class =
'';
921 if ($fieldlist[$field] ==
'code') {
922 $class =
'maxwidth100';
924 if ($fieldlist[$field] ==
'position') {
925 $class =
'maxwidth50';
927 if ($fieldlist[$field] ==
'libelle') {
928 $class =
'quatrevingtpercent';
930 if ($fieldlist[$field] ==
'sortorder' || $fieldlist[$field] ==
'category_type') {
933 print
'<input type="text" '.$size.
'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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='')
Function to show navigation arrows into lists.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.