25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountancycategory.class.php';
36 $langs->loadLangs(array(
"errors",
"admin",
"companies",
"resource",
"holiday",
"accountancy",
"hrm"));
38 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
39 $confirm =
GETPOST(
'confirm',
'alpha');
41 $rowid =
GETPOST(
'rowid',
'alpha');
42 $code =
GETPOST(
'code',
'alpha');
45 if (empty($user->rights->accounting->chartofaccount)) {
49 $acts[0] =
"activate";
51 $actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="size15x"');
52 $actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="size15x"');
54 $listoffset =
GETPOST(
'listoffset',
'alpha');
55 $listlimit =
GETPOST(
'listlimit',
'int') > 0 ?
GETPOST(
'listlimit',
'int') : 1000;
57 $sortfield =
GETPOST(
"sortfield",
'aZ09comma');
58 $sortorder =
GETPOST(
"sortorder",
'aZ09comma');
60 if (empty($page) || $page == -1) {
63 $offset = $listlimit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
67 $search_country_id =
GETPOST(
'search_country_id',
'int');
70 $hookmanager->initHooks(array(
'admin'));
76 $taborder = array(32);
80 $tabname[32] = MAIN_DB_PREFIX.
"c_accounting_category";
84 $tablib[32] =
"DictionaryAccountancyCategory";
88 $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";
91 $tabsqlsort = array();
92 $tabsqlsort[32] =
"position ASC";
96 $tabfield[32] =
"code,label,range_account,category_type,formula,position,country";
99 $tabfieldvalue = array();
100 $tabfieldvalue[32] =
"code,label,range_account,category_type,formula,position,country_id";
103 $tabfieldinsert = array();
104 $tabfieldinsert[32] =
"code,label,range_account,category_type,formula,position,fk_country";
118 $tabhelp[32] = array(
'code'=>$langs->trans(
"EnterAnyCode"),
'category_type'=>$langs->trans(
"SetToYesIfGroupIsComputationOfOtherGroups"),
'formula'=>$langs->trans(
"EnterCalculationRuleIfPreviousFieldIsYes"));
121 $tabfieldcheck = array();
122 $tabfieldcheck[32] = array();
125 complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
134 if (
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter_x',
'alpha')) {
135 $search_country_id =
'';
139 if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
140 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
141 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
142 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
143 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
147 foreach ($listfield as $f => $value) {
148 if ($value ==
'formula' && !
GETPOST(
'formula')) {
151 if ($value ==
'range_account' && !
GETPOST(
'range_account')) {
154 if (($value ==
'country' || $value ==
'country_id') &&
GETPOST(
'country_id')) {
159 $fieldnamekey = $listfield[$f];
161 if ($fieldnamekey ==
'libelle' || ($fieldnamekey ==
'label')) {
162 $fieldnamekey =
'Label';
164 if ($fieldnamekey ==
'code') {
165 $fieldnamekey =
'Code';
167 if ($fieldnamekey ==
'note') {
168 $fieldnamekey =
'Note';
170 if ($fieldnamekey ==
'type') {
171 $fieldnamekey =
'Type';
173 if ($fieldnamekey ==
'position') {
174 $fieldnamekey =
'Position';
176 if ($fieldnamekey ==
'category_type') {
177 $fieldnamekey =
'Calculated';
179 if ($fieldnamekey ==
'country') {
180 $fieldnamekey =
'Country';
183 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
189 setEventMessages($langs->transnoentities(
'ErrorCodeCantContainZero'),
null,
'errors');
192 if (!is_numeric(
GETPOST(
'position',
'alpha'))) {
193 $langs->loadLangs(array(
"errors"));
195 setEventMessages($langs->transnoentities(
'ErrorFieldMustBeANumeric', $langs->transnoentities(
"Position")),
null,
'errors');
199 if ($ok &&
GETPOST(
'actionadd',
'alpha')) {
200 if ($tabrowid[$id]) {
203 $sql =
"SELECT max(".$tabrowid[$id].
") newid from ".$tabname[$id];
204 $result = $db->query($sql);
206 $obj = $db->fetch_object($result);
207 $newid = ($obj->newid + 1);
214 $sql =
"INSERT INTO ".$tabname[$id].
" (";
216 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
217 $sql .= $tabrowid[$id].
",";
219 $sql .= $tabfieldinsert[$id];
224 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
228 foreach ($listfieldinsert as $f => $value) {
229 if ($value ==
'entity') {
230 $_POST[$listfieldvalue[$i]] = $conf->entity;
235 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'formula') {
238 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
245 $result = $db->query($sql);
248 $_POST = array(
'id'=>$id);
250 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
251 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
259 if ($ok &&
GETPOST(
'actionmodify',
'alpha')) {
260 if ($tabrowid[$id]) {
261 $rowidcol = $tabrowid[$id];
267 $sql =
"UPDATE ".$tabname[$id].
" SET ";
269 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
270 $sql .= $tabrowid[$id].
"=";
271 $sql .=
"'".$db->escape($rowid).
"', ";
274 foreach ($listfieldmodify as $field) {
275 if ($field ==
'fk_country' &&
GETPOST(
'country') > 0) {
276 $_POST[$listfieldvalue[$i]] =
GETPOST(
'country');
277 } elseif ($field ==
'entity') {
278 $_POST[$listfieldvalue[$i]] = $conf->entity;
284 if (
GETPOST($listfieldvalue[$i]) ==
'' && !$listfieldvalue[$i] ==
'range_account') {
287 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
291 $sql .=
" WHERE ".$rowidcol.
" = ".((int) $rowid);
295 $resql = $db->query($sql);
303 if (
GETPOST(
'actioncancel',
'alpha')) {
307 if ($action ==
'confirm_delete' && $confirm ==
'yes') {
308 if ($tabrowid[$id]) {
309 $rowidcol = $tabrowid[$id];
314 $sql =
"DELETE from ".$tabname[$id].
" WHERE ".$rowidcol.
" = ".((int) $rowid);
317 $result = $db->query($sql);
319 if ($db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
320 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
328 if ($action == $acts[0]) {
329 if ($tabrowid[$id]) {
330 $rowidcol = $tabrowid[$id];
336 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
338 $sql =
"UPDATE ".$tabname[$id].
" SET active = 1 WHERE code = '".$db->escape($code).
"'";
341 $result = $db->query($sql);
348 if ($action == $acts[1]) {
349 if ($tabrowid[$id]) {
350 $rowidcol = $tabrowid[$id];
356 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
358 $sql =
"UPDATE ".$tabname[$id].
" SET active = 0 WHERE code = '".$db->escape($code).
"'";
361 $result = $db->query($sql);
368 if ($action ==
'activate_favorite') {
369 if ($tabrowid[$id]) {
370 $rowidcol = $tabrowid[$id];
376 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE ".$rowidcol.
" = ".((int) $rowid);
378 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 1 WHERE code = '".$db->escape($code).
"'";
381 $result = $db->query($sql);
388 if ($action ==
'disable_favorite') {
389 if ($tabrowid[$id]) {
390 $rowidcol = $tabrowid[$id];
396 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE ".$rowidcol.
" = ".((int) $rowid);
398 $sql =
"UPDATE ".$tabname[$id].
" SET favorite = 0 WHERE code = '".$db->escape($code).
"'";
401 $result = $db->query($sql);
415 llxHeader(
'', $langs->trans(
'DictionaryAccountancyCategory'));
417 $titre = $langs->trans($tablib[$id]);
419 $titlepicto =
'setup';
423 print
'<span class="opacitymedium">'.$langs->trans(
"AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv(
"ByPersonalizedAccountGroups")).
'</span><br><br>';
426 if ($action ==
'delete') {
427 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);
433 if ($search_country_id > 0) {
434 if (preg_match(
'/ WHERE /', $sql)) {
439 $sql .=
" (a.fk_country = ".((int) $search_country_id).
" OR a.fk_country = 0)";
443 if ($sortfield ==
'country') {
444 $sortfield =
'country_code';
446 $sql .= $db->order($sortfield, $sortorder);
447 $sql .= $db->plimit($listlimit + 1, $offset);
450 $fieldlist = explode(
',', $tabfield[$id]);
452 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">';
453 print
'<input type="hidden" name="token" value="'.newToken().
'">';
454 print
'<input type="hidden" name="from" value="'.dol_escape_htmltag(
GETPOST(
'from',
'alpha')).
'">';
456 print
'<div class="div-table-responsive">';
457 print
'<table class="noborder centpercent">';
461 $fieldlist = explode(
',', $tabfield[$id]);
464 print
'<tr class="liste_titre">';
465 foreach ($fieldlist as $field => $value) {
468 $valuetoshow = ucfirst($fieldlist[$field]);
469 $valuetoshow = $langs->trans($valuetoshow);
471 if ($fieldlist[$field] ==
'type') {
472 if ($tabname[$id] == MAIN_DB_PREFIX.
"c_paiement") {
473 $valuetoshow =
$form->textwithtooltip($langs->trans(
"Type"), $langs->trans(
"TypePaymentDesc"), 2, 1,
img_help(1,
''));
475 $valuetoshow = $langs->trans(
"Type");
478 if ($fieldlist[$field] ==
'code') {
479 $valuetoshow = $langs->trans(
"Code");
481 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
482 $valuetoshow = $langs->trans(
"Label");
484 if ($fieldlist[$field] ==
'libelle_facture') {
485 $valuetoshow = $langs->trans(
"LabelOnDocuments");
487 if ($fieldlist[$field] ==
'country') {
488 $valuetoshow = $langs->trans(
"Country");
490 if ($fieldlist[$field] ==
'accountancy_code') {
491 $valuetoshow = $langs->trans(
"AccountancyCode");
493 if ($fieldlist[$field] ==
'accountancy_code_sell') {
494 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
496 if ($fieldlist[$field] ==
'accountancy_code_buy') {
497 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
499 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
500 $valuetoshow = $langs->trans(
"Pcg_version");
502 if ($fieldlist[$field] ==
'range_account') {
503 $valuetoshow = $langs->trans(
"Comment");
505 if ($fieldlist[$field] ==
'category_type') {
506 $valuetoshow = $langs->trans(
"Calculated");
509 if ($valuetoshow !=
'') {
510 print
'<td class="'.$class.
'">';
511 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
512 print
'<a href="'.$tabhelp[$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
513 } elseif (!empty($tabhelp[$id][$value])) {
514 print
$form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
523 print
'<input type="hidden" name="id" value="'.$id.
'">';
525 print
'<td style="min-width: 26px;"></td>';
526 print
'<td style="min-width: 26px;"></td>';
527 print
'<td style="min-width: 26px;"></td>';
531 print
'<tr class="oddeven nodrag nodrop nohover">';
533 $obj =
new stdClass();
535 if (
GETPOST(
'actionadd',
'alpha')) {
536 foreach ($fieldlist as $key => $val) {
543 $tmpaction =
'create';
544 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
545 $reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
546 $error = $hookmanager->error; $errors = $hookmanager->errors;
548 if (empty($reshook)) {
552 print
'<td colspan="4" class="right">';
553 print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
557 $colspan = count($fieldlist) + 3;
562 print
'<tr><td colspan="'.$colspan.
'"> </td></tr>';
566 dol_syslog(
"htdocs/accountancy/admin/categories_list.php", LOG_DEBUG);
568 $resql = $db->query($sql);
570 $num = $db->num_rows(
$resql);
574 if ($search_country_id > 0) {
575 $param .=
'&search_country_id='.urlencode($search_country_id);
577 $paramwithsearch = $param;
579 $paramwithsearch .=
'&sortorder='.$sortorder;
582 $paramwithsearch .=
'&sortfield='.$sortfield;
584 if (
GETPOST(
'from',
'alpha')) {
585 $paramwithsearch .=
'&from='.GETPOST(
'from',
'alpha');
588 if ($num > $listlimit) {
589 print
'<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).
'">';
590 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
595 print
'<tr class="liste_titre liste_titre_add liste_titre_filter">';
597 foreach ($fieldlist as $field => $value) {
600 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
605 if ($value ==
'country') {
606 print
'<td class="liste_titre">';
607 print
$form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth200 maxwidthonsmartphone');
611 print
'<td class="liste_titre"></td>';
615 print
'<td class="liste_titre"></td>';
616 print
'<td class="liste_titre"></td>';
617 print
'<td class="liste_titre"></td>';
618 print
'<td class="liste_titre center">';
620 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
627 print
'<tr class="liste_titre">';
628 foreach ($fieldlist as $field => $value) {
636 $valuetoshow = ucfirst($fieldlist[$field]);
637 $valuetoshow = $langs->trans($valuetoshow);
638 if ($fieldlist[$field] ==
'source') {
639 $valuetoshow = $langs->trans(
"Contact");
641 if ($fieldlist[$field] ==
'price') {
642 $valuetoshow = $langs->trans(
"PriceUHT");
644 if ($fieldlist[$field] ==
'taux') {
645 if ($tabname[$id] != MAIN_DB_PREFIX.
"c_revenuestamp") {
646 $valuetoshow = $langs->trans(
"Rate");
648 $valuetoshow = $langs->trans(
"Amount");
652 if ($fieldlist[$field] ==
'type') {
653 $valuetoshow = $langs->trans(
"Type");
655 if ($fieldlist[$field] ==
'code') {
656 $valuetoshow = $langs->trans(
"Code");
658 if ($fieldlist[$field] ==
'libelle' || $fieldlist[$field] ==
'label') {
659 $valuetoshow = $langs->trans(
"Label");
661 if ($fieldlist[$field] ==
'country') {
662 $valuetoshow = $langs->trans(
"Country");
664 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
667 if ($fieldlist[$field] ==
'accountancy_code') {
668 $valuetoshow = $langs->trans(
"AccountancyCode");
670 if ($fieldlist[$field] ==
'accountancy_code_sell') {
671 $valuetoshow = $langs->trans(
"AccountancyCodeSell");
674 if ($fieldlist[$field] ==
'accountancy_code_buy') {
675 $valuetoshow = $langs->trans(
"AccountancyCodeBuy");
678 if ($fieldlist[$field] ==
'fk_pcg_version') {
679 $valuetoshow = $langs->trans(
"Pcg_version");
681 if ($fieldlist[$field] ==
'account_parent') {
682 $valuetoshow = $langs->trans(
"Accountsparent");
684 if ($fieldlist[$field] ==
'pcg_type') {
685 $valuetoshow = $langs->trans(
"Pcg_type");
687 if ($fieldlist[$field] ==
'type_template') {
688 $valuetoshow = $langs->trans(
"TypeOfTemplate");
690 if ($fieldlist[$field] ==
'range_account') {
691 $valuetoshow = $langs->trans(
"Comment");
693 if ($fieldlist[$field] ==
'category_type') {
694 $valuetoshow = $langs->trans(
"Calculated");
698 print
getTitleFieldOfList($valuetoshow, 0, $_SERVER[
"PHP_SELF"], ($sortable ? $fieldlist[$field] :
''), ($page ?
'page='.$page.
'&' :
''), $param,
"", $sortfield, $sortorder, $class.
' ');
701 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
710 $obj = $db->fetch_object(
$resql);
712 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
713 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
715 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
716 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
717 $error = $hookmanager->error; $errors = $hookmanager->errors;
720 if (empty($reshook)) {
726 print
'<td class="center">';
727 print
'<input type="hidden" name="page" value="'.$page.
'">';
728 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
729 print
'<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
730 print
'<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"></div>';
731 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
736 $parameters = array(
'fieldlist'=>$fieldlist,
'tabname'=>$tabname[$id]);
737 $reshook = $hookmanager->executeHooks(
'viewDictionaryFieldlist', $parameters, $obj, $tmpaction);
739 $error = $hookmanager->error; $errors = $hookmanager->errors;
741 if (empty($reshook)) {
742 foreach ($fieldlist as $field => $value) {
745 $valuetoshow = $obj->{$fieldlist[$field]};
746 if ($value ==
'category_type') {
747 $valuetoshow =
yn($valuetoshow);
748 } elseif ($valuetoshow ==
'all') {
749 $valuetoshow = $langs->trans(
'All');
750 } elseif ($fieldlist[$field] ==
'country') {
751 if (empty($obj->country_code)) {
754 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
755 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
757 } elseif ($fieldlist[$field] ==
'label' && $tabname[$id] == MAIN_DB_PREFIX.
'c_country') {
758 $key = $langs->trans(
"Country".strtoupper($obj->code));
759 $valuetoshow = ($obj->code && $key !=
"Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
760 } elseif ($fieldlist[$field] ==
'label' && $tabname[$id] == MAIN_DB_PREFIX.
'c_availability') {
761 $langs->loadLangs(array(
"propal"));
762 $key = $langs->trans(
"AvailabilityType".strtoupper($obj->code));
763 $valuetoshow = ($obj->code && $key !=
"AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
764 } elseif ($fieldlist[$field] ==
'libelle' && $tabname[$id] == MAIN_DB_PREFIX.
'c_actioncomm') {
765 $key = $langs->trans(
"Action".strtoupper($obj->code));
766 $valuetoshow = ($obj->code && $key !=
"Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
767 } elseif ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
774 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'">'.
dol_escape_htmltag($valuetoshow).
'</td>';
780 $iserasable = 1; $canbedisabled = 1; $canbemodified = 1;
781 if (isset($obj->code)) {
782 if (($obj->code ==
'0' || $obj->code ==
'' || preg_match(
'/unknown/i', $obj->code))) {
783 $iserasable = 0; $canbedisabled = 0;
787 $canbemodified = $iserasable;
789 $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) :
'');
796 print
'<td class="center" class="nowrap">';
797 if ($canbedisabled) {
798 print
'<a href="'.$url.
'action='.$acts[$obj->active].
'">'.$actl[$obj->active].
'</a>';
800 print $langs->trans(
"AlwaysActive");
805 if ($canbemodified) {
806 print
'<td class="center"><a class="reposition editfielda" href="'.$url.
'action=edit&token='.
newToken().
'">'.
img_edit().
'</a></td>';
808 print
'<td> </td>';
813 print
'<td class="center">';
820 print
'<td> </td>';
824 print
'<td class="center">';
825 if (empty($obj->formula)) {
826 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.
'">';
827 print $langs->trans(
"ListOfAccounts");
831 $nbofaccountintogroup = 0;
832 $listofaccountintogroup = $accountingcategory->getCptsCat($obj->rowid);
833 $nbofaccountintogroup = count($listofaccountintogroup);
835 print
' <span class="opacitymedium">('.$langs->trans(
"NAccounts", $nbofaccountintogroup).
')</span>';
873 global $conf, $langs, $db;
874 global
$form, $mysoc;
882 foreach ($fieldlist as $field => $value) {
883 if ($fieldlist[$field] ==
'country') {
885 $fieldname =
'country';
886 if ($context ==
'add') {
887 $fieldname =
'country_id';
888 $preselectcountrycode =
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_code;
889 print
$form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth200 maxwidthonsmartphone');
891 $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code);
892 print
$form->select_country($preselectcountrycode, $fieldname,
'', 28,
'maxwidth200 maxwidthonsmartphone');
895 } elseif ($fieldlist[$field] ==
'country_id') {
896 if (!in_array(
'country', $fieldlist)) {
897 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
899 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
902 } elseif ($fieldlist[$field] ==
'category_type') {
904 print
$form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
''), 1);
906 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
907 print
'<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
'').
'" name="'.$fieldlist[$field].
'"></td>';
910 $size =
''; $class =
'';
911 if ($fieldlist[$field] ==
'code') {
912 $class =
'maxwidth100';
914 if ($fieldlist[$field] ==
'position') {
915 $class =
'maxwidth50';
917 if ($fieldlist[$field] ==
'libelle') {
918 $class =
'quatrevingtpercent';
920 if ($fieldlist[$field] ==
'sortorder' || $fieldlist[$field] ==
'category_type') {
923 print
'<input type="text" '.$size.
'class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:
'').
'" name="'.$fieldlist[$field].
'">';