38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
58$langs->loadLangs(array(
'accountancy',
'admin',
'companies',
'compta',
'errors',
'holiday',
'hrm',
'resource'));
60$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
61$confirm =
GETPOST(
'confirm',
'alpha');
63$rowid =
GETPOST(
'rowid',
'alpha');
64$code =
GETPOST(
'code',
'alpha');
70$actl[0] =
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="size15x"');
71$actl[1] =
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="size15x"');
73$listoffset =
GETPOST(
'listoffset',
'alpha');
77$sortfield =
GETPOST(
"sortfield",
'aZ09comma');
78$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
80if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
84$offset = $listlimit * $page;
88$search_country_id =
GETPOST(
'search_country_id',
'int');
92if ($user->socid > 0) {
96$permissiontoeditchart = $user->hasRight(
'accounting',
'chartofaccount');
97if (!$user->hasRight(
'accounting',
'chartofaccount')) {
103$hookmanager->initHooks(array(
'admin'));
111$tabname[31] = MAIN_DB_PREFIX.
"accounting_system";
115$tablib[31] =
"Pcg_version";
119$tabsql[31] =
"SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX.
"accounting_system as s, ".MAIN_DB_PREFIX.
"c_country as c WHERE s.fk_country=c.rowid and c.active=1";
122$tabsqlsort = array();
123$tabsqlsort[31] =
"pcg_version ASC";
127$tabfield[31] =
"pcg_version,label,country_id,country";
130$tabfieldvalue = array();
131$tabfieldvalue[31] =
"pcg_version,label,country";
134$tabfieldinsert = array();
135$tabfieldinsert[31] =
"pcg_version,label,fk_country";
145$tabhelp[31] = array(
'pcg_version' => $langs->trans(
"EnterAnyCode"));
152if (
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter_x',
'alpha')) {
153 $search_country_id =
'';
157if (
GETPOST(
'actionadd',
'alpha') ||
GETPOST(
'actionmodify',
'alpha')) {
158 $listfield = explode(
',', str_replace(
' ',
'', $tabfield[$id]));
159 $listfieldinsert = explode(
',', $tabfieldinsert[$id]);
160 $listfieldmodify = explode(
',', $tabfieldinsert[$id]);
161 $listfieldvalue = explode(
',', $tabfieldvalue[$id]);
165 foreach ($listfield as $f => $value) {
166 if ($value ==
'country_id' && in_array($tablib[$id], array(
'Pcg_version'))) {
169 if ((!GETPOSTISSET($value)) ||
GETPOST($value) ==
'') {
171 $fieldnamekey = $listfield[$f];
174 if ($fieldnamekey ==
'pcg_version') {
175 $fieldnamekey =
'Pcg_version';
177 if ($fieldnamekey ==
'label') {
178 $fieldnamekey =
'Label';
180 if ($fieldnamekey ==
'country') {
181 $fieldnamekey =
"Country";
184 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities($fieldnamekey)),
null,
'errors');
188 if (GETPOSTISSET(
"pcg_version")) {
189 if (
GETPOST(
"pcg_version") ==
'0') {
191 setEventMessages($langs->transnoentities(
'ErrorCodeCantContainZero'),
null,
'errors');
194 if (GETPOSTISSET(
"country") &&
GETPOST(
"country") ==
'0') {
196 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"Country")),
null,
'errors');
200 if ($ok &&
GETPOST(
'actionadd',
'alpha')) {
204 $sql =
"INSERT INTO ".$db->sanitize($tabname[$id]).
" (";
206 $sql .=
$db->sanitize($tabfieldinsert[$id]);
212 foreach ($listfieldinsert as $f => $value) {
213 if ($value ==
'price' || preg_match(
'/^amount/i', $value) || $value ==
'taux') {
214 $_POST[$listfieldvalue[$i]] =
price2num(
GETPOST($listfieldvalue[$i]),
'MU');
215 } elseif ($value ==
'entity') {
216 $_POST[$listfieldvalue[$i]] =
$conf->entity;
221 if (
GETPOST($listfieldvalue[$i]) ==
'') {
224 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
231 $result =
$db->query($sql);
234 $_POST = array(
'id' => $id);
236 if (
$db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
237 setEventMessages($langs->transnoentities(
"ErrorRecordAlreadyExists"),
null,
'errors');
245 if ($ok &&
GETPOST(
'actionmodify',
'alpha')) {
247 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET ";
251 foreach ($listfieldmodify as $field) {
252 if ($field ==
'price' || preg_match(
'/^amount/i', $field) || $field ==
'taux') {
253 $_POST[$listfieldvalue[$i]] =
price2num(
GETPOST($listfieldvalue[$i]),
'MU');
254 } elseif ($field ==
'entity') {
255 $_POST[$listfieldvalue[$i]] =
$conf->entity;
261 if (
GETPOST($listfieldvalue[$i]) ==
'') {
264 $sql .=
"'".$db->escape(
GETPOST($listfieldvalue[$i])).
"'";
268 $sql .=
" WHERE rowid = ".((int) $rowid);
271 $resql =
$db->query($sql);
279if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontoeditchart) {
280 $sql =
"DELETE from ".$db->sanitize($tabname[$id]).
" WHERE rowid = ".((int) $rowid);
283 $result =
$db->query($sql);
285 if (
$db->errno() ==
'DB_ERROR_CHILD_EXISTS') {
286 setEventMessages($langs->transnoentities(
"ErrorRecordIsUsedByChild"),
null,
'errors');
294if ($action ==
'activate' && $permissiontoeditchart) {
295 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 1 WHERE rowid = ".((int) $rowid);
296 $result =
$db->query($sql);
303if ($action == $acts[1] && $permissiontoeditchart) {
304 $sql =
"UPDATE ".$db->sanitize($tabname[$id]).
" SET active = 0 WHERE rowid = ".((int) $rowid);
305 $result =
$db->query($sql);
319$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
321llxHeader(
'', $langs->trans(
"Pcg_version"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy page-admin_accountmodel');
323$titre = $langs->trans($tablib[$id]);
330if ($action ==
'delete') {
331 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'page'=> $page,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'rowid' => $rowid,
'code' => $code,
'id' => $id]), $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_delete',
'', 0, 1);
338if ($search_country_id > 0) {
339 if (preg_match(
'/ WHERE /', $sql)) {
344 $sql .=
" c.rowid = ".((int) $search_country_id);
348if ($sortfield ==
'country') {
349 $sortfield =
'country_code';
351$sql .=
$db->order($sortfield, $sortorder);
352$sql .=
$db->plimit($listlimit + 1, $offset);
354$fieldlist = explode(
',', $tabfield[$id]);
356print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$id.
'" method="POST">';
357print
'<input type="hidden" name="token" value="'.newToken().
'">';
359print
'<div class="div-table-responsive">';
360print
'<table class="noborder centpercent">';
364$fieldlist = explode(
',', $tabfield[$id]);
367print
'<tr class="liste_titre">';
368foreach ($fieldlist as $field => $value) {
371 $valuetoshow = ucfirst($fieldlist[$field]);
372 $valuetoshow = $langs->trans($valuetoshow);
374 if ($fieldlist[$field] ==
'code') {
375 $valuetoshow = $langs->trans(
"Code");
377 if ($fieldlist[$field] ==
'label') {
378 $valuetoshow = $langs->trans(
"Label");
379 $class =
'minwidth300';
381 if ($fieldlist[$field] ==
'country') {
382 if (in_array(
'region_id', $fieldlist)) {
383 print
'<td> </td>';
386 $valuetoshow = $langs->trans(
"Country");
388 if ($fieldlist[$field] ==
'country_id') {
391 if ($fieldlist[$field] ==
'pcg_version' || $fieldlist[$field] ==
'fk_pcg_version') {
392 $valuetoshow = $langs->trans(
"Pcg_version");
395 if ($valuetoshow !=
'') {
396 print
'<td class="'.$class.
'">';
397 if (!empty($tabhelp[$id][$value]) && preg_match(
'/^http(s*):/i', $tabhelp[$id][$value])) {
398 print
'<a href="'.$tabhelp[
$id][$value].
'">'.$valuetoshow.
' '.
img_help(1, $valuetoshow).
'</a>';
399 } elseif (!empty($tabhelp[$id][$value])) {
400 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
409print
'<input type="hidden" name="id" value="'.$id.
'">';
416print
'<tr class="oddeven">';
420if (
GETPOST(
'actionadd',
'alpha')) {
421 foreach ($fieldlist as $key => $val) {
428$tmpaction =
'create';
429$parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
430$reshook = $hookmanager->executeHooks(
'createDictionaryFieldlist', $parameters, $obj, $tmpaction);
431$error = $hookmanager->error;
432$errors = $hookmanager->errors;
434if (empty($reshook)) {
438print
'<td colspan="3" class="right">';
439print
'<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans(
"Add").
'">';
443$colspan = count($fieldlist) + 3;
445print
'<tr><td colspan="'.$colspan.
'"> </td></tr>';
451$resql =
$db->query($sql);
453 $num =
$db->num_rows($resql);
456 $param =
'&id='.urlencode((
string) ($id));
457 if ($search_country_id > 0) {
458 $param .=
'&search_country_id='.urlencode((
string) ($search_country_id));
460 $paramwithsearch = $param;
462 $paramwithsearch .=
'&sortorder='.urlencode($sortorder);
465 $paramwithsearch .=
'&sortfield='.urlencode($sortfield);
469 if ($num > $listlimit) {
470 print
'<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).
'">';
471 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"], $paramwithsearch, ($num > $listlimit ? 1 : 0),
'<li class="pagination"><span>'.$langs->trans(
"Page").
' '.($page + 1).
'</span></li>');
476 print
'<tr class="liste_titre liste_titre_add">';
477 foreach ($fieldlist as $field => $value) {
480 if ($fieldlist[$field] ==
'region_id' || $fieldlist[$field] ==
'country_id') {
485 if ($value ==
'country') {
486 print
'<td class="liste_titre">';
487 print $form->select_country($search_country_id,
'search_country_id',
'', 28,
'maxwidth200 maxwidthonsmartphone');
490 print
'<td class="liste_titre"></td>';
494 print
'<td class="liste_titre"></td>';
495 print
'<td class="liste_titre right" colspan="2">';
496 $searchpicto = $form->showFilterAndCheckAddButtons(0);
502 print
'<tr class="liste_titre">';
503 print
getTitleFieldOfList($langs->trans(
"Pcg_version"), 0, $_SERVER[
"PHP_SELF"],
"pcg_version", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
504 print
getTitleFieldOfList($langs->trans(
"Label"), 0, $_SERVER[
"PHP_SELF"],
"label", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
505 print
getTitleFieldOfList($langs->trans(
"Country"), 0, $_SERVER[
"PHP_SELF"],
"country_code", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'');
506 print
getTitleFieldOfList($langs->trans(
"Status"), 0, $_SERVER[
"PHP_SELF"],
"active", ($page ?
'page='.$page.
'&' :
''), $param,
'', $sortfield, $sortorder,
'center ');
515 $obj =
$db->fetch_object($resql);
518 print
'<tr class="oddeven" id="rowid-'.$obj->rowid.
'">';
519 if ($action ==
'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
520 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$id.
'" method="POST">';
521 print
'<input type="hidden" name="token" value="'.newToken().
'">';
522 print
'<input type="hidden" name="page" value="'.$page.
'">';
523 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
526 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
527 $reshook = $hookmanager->executeHooks(
'editDictionaryFieldlist', $parameters, $obj, $tmpaction);
528 $error = $hookmanager->error;
529 $errors = $hookmanager->errors;
531 if (empty($reshook)) {
535 print
'<td colspan="3" class="right">';
536 print
'<a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).
'"> </a><input type="submit" class="button button-edit smallpaddingimp" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
537 print
' <input type="submit" class="button button-cancel smallpaddingimp" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
541 $parameters = array(
'fieldlist' => $fieldlist,
'tabname' => $tabname[$id]);
542 $reshook = $hookmanager->executeHooks(
'viewDictionaryFieldlist', $parameters, $obj, $tmpaction);
544 $error = $hookmanager->error;
545 $errors = $hookmanager->errors;
547 if (empty($reshook)) {
548 foreach ($fieldlist as $field => $value) {
551 $tmpvar = $fieldlist[$field];
552 $valuetoshow = $obj->$tmpvar;
553 if ($valuetoshow ==
'all') {
554 $valuetoshow = $langs->trans(
'All');
555 } elseif ($fieldlist[$field] ==
'country') {
556 if (empty($obj->country_code)) {
559 $key = $langs->trans(
"Country".strtoupper($obj->country_code));
560 $valuetoshow = ($key !=
"Country".strtoupper($obj->country_code) ? $obj->country_code.
" - ".$key : $obj->country);
562 } elseif ($fieldlist[$field] ==
'country_id') {
567 if ($fieldlist[$field] ==
'tracking') {
568 $class .=
' tdoverflowauto';
572 print
'<!-- '.$fieldlist[$field].
' --><td class="'.$class.
'">'.$valuetoshow.
'</td>';
582 parse_str($param, $query);
583 $query = array_merge($query, [
586 'sortfield' => $sortfield,
587 'sortorder' => $sortorder,
588 'rowid' => (!empty($obj->rowid) ? $obj->rowid :
'')
592 print
'<td class="center nowrap">';
593 $query[
'action'] = $acts[$obj->active];
594 print
'<a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], $query,
true).
'">'.$actl[$obj->active].
'</a>';
598 $query[
'action'] =
'edit';
599 print
'<td class="center"><a class="reposition editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], $query,
true).
'">'.
img_edit().
'</a></td>';
602 $query[
'action'] =
'delete';
603 print
'<td class="center"><a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], $query,
true).
'">'.
img_delete().
'</a></td>';
611 print
'<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
647 foreach ($fieldlist as $field => $value) {
648 if ($fieldlist[$field] ==
'country') {
649 if (in_array(
'region_id', $fieldlist)) {
656 $fieldname =
'country';
657 print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country :
'')), $fieldname,
'', 28,
'maxwidth200 maxwidthonsmartphone');
659 } elseif ($fieldlist[$field] ==
'country_id') {
660 if (!in_array(
'country', $fieldlist)) {
661 $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
663 print
'<input type="hidden" name="'.$fieldlist[$field].
'" value="'.$country_id.
'">';
666 } elseif ($fieldlist[$field] ==
'type_cdr') {
667 print
'<td class="center">';
668 print $form->selectarray($fieldlist[$field], array(0 => $langs->trans(
'None'), 1 => $langs->trans(
'AtEndOfMonth'), 2 => $langs->trans(
'CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
''));
670 } elseif ($fieldlist[$field] ==
'code' && isset($obj->{$fieldlist[$field]})) {
671 print
'<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
'').
'" size="10" name="'.$fieldlist[$field].
'"></td>';
675 if ($fieldlist[$field] ==
'pcg_version') {
678 if ($fieldlist[$field] ==
'label') {
681 print
'<input type="text" class="flat'.($class ?
' '.$class :
'').
'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} :
'').
'" name="'.$fieldlist[$field].
'">';
$id
Support class for third parties, contacts, members, users or resources.
fieldListAccountModel($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
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.
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$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.