27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33$langs->loadLangs(array(
"accountancy",
"admin",
"bills",
"compta",
"errors",
"hrm",
"salaries"));
36$action =
GETPOST(
'action',
'aZ09');
37$cancel =
GETPOST(
'cancel',
'alpha');
39$rowid =
GETPOST(
'rowid',
'int');
40$massaction =
GETPOST(
'massaction',
'aZ09');
41$optioncss =
GETPOST(
'optioncss',
'alpha');
43$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'accountingsubaccountlist';
45$search_subaccount =
GETPOST(
'search_subaccount',
'alpha');
46$search_label =
GETPOST(
'search_label',
'alpha');
47$search_type =
GETPOST(
'search_type',
'int');
50if ($user->socid > 0) {
53if (!$user->hasRight(
'accounting',
'chartofaccount')) {
58$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
62if (empty($page) || $page == -1) {
65$offset = $limit * $page;
76 'subaccount'=>array(
'label'=>$langs->trans(
"AccountNumber"),
'checked'=>1),
77 'label'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
78 'type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1),
79 'reconcilable'=>array(
'label'=>$langs->trans(
"Reconcilable"),
'checked'=>1)
83 unset($arrayfields[
'reconcilable']);
91if (
GETPOST(
'cancel',
'alpha')) {
92 $action =
'list'; $massaction =
'';
94if (!
GETPOST(
'confirmmassaction',
'alpha')) {
99$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104if (empty($reshook)) {
105 if (!empty($cancel)) {
109 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
111 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
112 $search_subaccount =
"";
115 $search_array_options = array();
124$form =
new Form($db);
128$help_url =
'EN:Module_Double_Entry_Accounting#Setup';
129$title = $langs->trans(
'ChartOfIndividualAccountsOfSubsidiaryLedger');
134$sql =
"SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature";
135$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe sa";
136$sql .=
" WHERE sa.entity IN (".getEntity(
'societe').
")";
137$sql .=
" AND sa.code_compta <> ''";
139if (strlen(trim($search_subaccount))) {
140 $lengthpaddingaccount = 0;
144 $search_subaccount_tmp = $search_subaccount;
145 $weremovedsomezero = 0;
146 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
147 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
148 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
149 $weremovedsomezero++;
150 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
156 if ($search_subaccount_tmp) {
157 if ($weremovedsomezero) {
158 $search_subaccount_tmp_clean = $search_subaccount_tmp;
159 $search_subaccount_clean = $search_subaccount;
161 if (strpos($search_subaccount_tmp,
'^') === 0) {
163 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
164 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
166 $sql .=
" AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
167 $sql .=
" OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
173if (strlen(trim($search_label))) {
176if (!empty($search_type) && $search_type >= 0) {
177 $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
182$sql .=
" SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, '0' as nature FROM ".MAIN_DB_PREFIX.
"societe sa";
183$sql .=
" WHERE sa.entity IN (".getEntity(
'societe').
")";
184$sql .=
" AND sa.code_compta_fournisseur <> ''";
186if (strlen(trim($search_subaccount))) {
187 $lengthpaddingaccount = 0;
191 $search_subaccount_tmp = $search_subaccount;
192 $weremovedsomezero = 0;
193 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
194 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
195 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
196 $weremovedsomezero++;
197 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
203 if ($search_subaccount_tmp) {
204 if ($weremovedsomezero) {
205 $search_subaccount_tmp_clean = $search_subaccount_tmp;
206 $search_subaccount_clean = $search_subaccount;
208 if (strpos($search_subaccount_tmp,
'^') === 0) {
210 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
211 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
213 $sql .=
" AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
214 $sql .=
" OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
216 $sql .=
natural_search(
"sa.code_compta_fournisseur", $search_subaccount_tmp);
220if (strlen(trim($search_label))) {
223if (!empty($search_type) && $search_type >= 0) {
224 $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
229$sql .=
" SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature FROM ".MAIN_DB_PREFIX.
"user u";
230$sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
231$sql .=
" AND u.accountancy_code <> ''";
233if (strlen(trim($search_subaccount))) {
234 $lengthpaddingaccount = 0;
238 $search_subaccount_tmp = $search_subaccount;
239 $weremovedsomezero = 0;
240 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
241 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
242 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
243 $weremovedsomezero++;
244 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
250 if ($search_subaccount_tmp) {
251 if ($weremovedsomezero) {
252 $search_subaccount_tmp_clean = $search_subaccount_tmp;
253 $search_subaccount_clean = $search_subaccount;
255 if (strpos($search_subaccount_tmp,
'^') === 0) {
257 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
258 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
260 $sql .=
" AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
261 $sql .=
" OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
263 $sql .=
natural_search(
"u.accountancy_code", $search_subaccount_tmp);
267if (strlen(trim($search_label))) {
270if (!empty($search_type) && $search_type >= 0) {
271 $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
274$sql .= $db->order($sortfield, $sortorder);
277$nbtotalofrecords =
'';
279 $resql = $db->query($sql);
280 $nbtotalofrecords = $db->num_rows($resql);
281 if (($page * $limit) > $nbtotalofrecords) {
287$sql .= $db->plimit($limit + 1, $offset);
289dol_syslog(
'accountancy/admin/subaccount.php:: $sql='.$sql);
290$resql = $db->query($sql);
293 $num = $db->num_rows($resql);
296 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
297 $param .=
'&contextpage='.urlencode($contextpage);
299 if ($limit > 0 && $limit != $conf->liste_limit) {
300 $param .=
'&limit='.((int) $limit);
302 if ($search_subaccount) {
303 $param .=
'&search_subaccount='.urlencode($search_subaccount);
306 $param .=
'&search_label='.urlencode($search_label);
308 if ($optioncss !=
'') {
309 $param .=
'&optioncss='.urlencode($optioncss);
313 $arrayofmassactions = array();
315 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
316 if ($optioncss !=
'') {
317 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
319 print
'<input type="hidden" name="token" value="'.newToken().
'">';
320 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
321 print
'<input type="hidden" name="action" value="list">';
322 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
323 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
324 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
326 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit, 0, 0, 1);
328 print
'<div class="info">'.$langs->trans(
"WarningCreateSubAccounts").
'</div>';
330 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
331 $selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
332 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
335 $massactionbutton =
'';
337 print
'<div class="div-table-responsive">';
338 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
341 print
'<tr class="liste_titre_filter">';
344 print
'<td class="liste_titre center maxwidthsearch">';
345 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
349 if (!empty($arrayfields[
'subaccount'][
'checked'])) {
350 print
'<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.
'"></td>';
352 if (!empty($arrayfields[
'label'][
'checked'])) {
353 print
'<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.
'"></td>';
355 if (!empty($arrayfields[
'type'][
'checked'])) {
356 print
'<td class="liste_titre center">'.$form->selectarray(
'search_type', array(
'1'=>$langs->trans(
'Customer'),
'2'=>$langs->trans(
'Supplier'),
'3'=>$langs->trans(
'Employee')), $search_type, 1).
'</td>';
358 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
359 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
360 print
'<td class="liste_titre"> </td>';
365 print
'<td class="liste_titre maxwidthsearch">';
366 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
372 print
'<tr class="liste_titre">';
375 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
377 if (!empty($arrayfields[
'subaccount'][
'checked'])) {
378 print_liste_field_titre($arrayfields[
'subaccount'][
'label'], $_SERVER[
"PHP_SELF"],
"subaccount",
"", $param,
'', $sortfield, $sortorder);
380 if (!empty($arrayfields[
'label'][
'checked'])) {
381 print_liste_field_titre($arrayfields[
'label'][
'label'], $_SERVER[
"PHP_SELF"],
"label",
"", $param,
'', $sortfield, $sortorder);
383 if (!empty($arrayfields[
'type'][
'checked'])) {
384 print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
"PHP_SELF"],
"type",
"", $param,
'', $sortfield, $sortorder,
'center ');
386 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
387 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
388 print_liste_field_titre($arrayfields[
'reconcilable'][
'label'], $_SERVER[
"PHP_SELF"],
'reconcilable',
'', $param,
'', $sortfield, $sortorder,
'center ');
393 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
397 $totalarray = array();
398 $totalarray[
'nbfield'] = 0;
400 while ($i < min($num, $limit)) {
401 $obj = $db->fetch_object($resql);
403 print
'<tr class="oddeven">';
407 print
'<td class="center">';
411 if ($obj->type == 1) {
412 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Customer").
'" href="'.DOL_URL_ROOT.
'/societe/card.php?action=edit&token='.newToken().
'&socid='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
413 } elseif ($obj->type == 2) {
415 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Supplier").
'" href="'.DOL_URL_ROOT.
'/societe/card.php?action=edit&token='.newToken().
'&socid='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
416 } elseif ($obj->type == 3) {
418 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Employee").
'" href="'.DOL_URL_ROOT.
'/user/card.php?action=edit&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
423 $totalarray[
'nbfield']++;
428 if (!empty($arrayfields[
'subaccount'][
'checked'])) {
433 $totalarray[
'nbfield']++;
438 if (!empty($arrayfields[
'label'][
'checked'])) {
443 $totalarray[
'nbfield']++;
448 if (!empty($arrayfields[
'type'][
'checked'])) {
449 print
'<td class="center">';
453 if ($obj->type == 1) {
454 $s .=
'<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans(
"Customer").
'" href="'.DOL_URL_ROOT.
'/comm/card.php?socid='.$obj->rowid.
'">'.$langs->trans(
"Customer").
'</a>';
455 } elseif ($obj->type == 2) {
457 $s .=
'<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans(
"Supplier").
'" href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->rowid.
'">'.$langs->trans(
"Supplier").
'</a>';
458 } elseif ($obj->type == 3) {
460 $s .=
'<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans(
"Employee").
'" href="'.DOL_URL_ROOT.
'/user/card.php?id='.$obj->rowid.
'">'.$langs->trans(
"Employee").
'</a>';
463 if ($obj->nature == 2) {
464 print
' <span class="warning bold">('.$langs->trans(
"Prospect").
')</span>';
468 $totalarray[
'nbfield']++;
472 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
474 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
475 print
'<td class="center">';
476 if (empty($obj->reconcilable)) {
477 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=enable&mode=1&token='.newToken().
'">';
478 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
481 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=disable&mode=1&token='.newToken().
'">';
482 print
img_picto($langs->trans(
"Activated"),
'switch_on');
487 $totalarray[
'nbfield']++;
494 print
'<td class="center">';
498 if ($obj->type == 1) {
499 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Customer").
'" href="'.DOL_URL_ROOT.
'/societe/card.php?action=edit&token='.newToken().
'&socid='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
500 } elseif ($obj->type == 2) {
502 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Supplier").
'" href="'.DOL_URL_ROOT.
'/societe/card.php?action=edit&token='.newToken().
'&socid='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
503 } elseif ($obj->type == 3) {
505 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Employee").
'" href="'.DOL_URL_ROOT.
'/user/card.php?action=edit&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
510 $totalarray[
'nbfield']++;
521 foreach ($arrayfields as $key => $val) {
522 if (!empty($val[
'checked'])) {
526 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
531 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
532 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
533 print $hookmanager->resPrint;
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.