27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
32 $langs->loadLangs(array(
"compta",
"bills",
"admin",
"accountancy",
"salaries",
"hrm",
"errors"));
35 $action =
GETPOST(
'action',
'aZ09');
36 $cancel =
GETPOST(
'cancel',
'alpha');
38 $rowid =
GETPOST(
'rowid',
'int');
39 $massaction =
GETPOST(
'massaction',
'aZ09');
40 $optioncss =
GETPOST(
'optioncss',
'alpha');
41 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'accountingsubaccountlist';
43 $search_subaccount =
GETPOST(
'search_subaccount',
'alpha');
44 $search_label =
GETPOST(
'search_label',
'alpha');
45 $search_type =
GETPOST(
'search_type',
'int');
48 if ($user->socid > 0) {
51 if (!$user->hasRight(
'accounting',
'chartofaccount')) {
56 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60 if (empty($page) || $page == -1) {
63 $offset = $limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
74 'subaccount'=>array(
'label'=>$langs->trans(
"AccountNumber"),
'checked'=>1),
75 'label'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
76 'type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1),
77 'reconcilable'=>array(
'label'=>$langs->trans(
"Reconcilable"),
'checked'=>1)
80 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
81 unset($arrayfields[
'reconcilable']);
88 if (
GETPOST(
'cancel',
'alpha')) {
89 $action =
'list'; $massaction =
'';
91 if (!
GETPOST(
'confirmmassaction',
'alpha')) {
95 $parameters = array();
96 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
101 if (empty($reshook)) {
102 if (!empty($cancel)) {
106 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
108 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
109 $search_subaccount =
"";
112 $search_array_options = array();
124 $title = $langs->trans(
'ChartOfIndividualAccountsOfSubsidiaryLedger');
129 $sql =
"SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity";
130 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe sa";
131 $sql .=
" WHERE sa.entity IN (".getEntity(
'societe').
")";
132 $sql .=
" AND sa.code_compta <> ''";
134 if (strlen(trim($search_subaccount))) {
135 $lengthpaddingaccount = 0;
136 if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
137 $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
139 $search_subaccount_tmp = $search_subaccount;
140 $weremovedsomezero = 0;
141 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
142 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
143 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
144 $weremovedsomezero++;
145 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
151 if ($search_subaccount_tmp) {
152 if ($weremovedsomezero) {
153 $search_subaccount_tmp_clean = $search_subaccount_tmp;
154 $search_subaccount_clean = $search_subaccount;
156 if (strpos($search_subaccount_tmp,
'^') === 0) {
158 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
159 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
161 $sql .=
" AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
162 $sql .=
" OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
168 if (strlen(trim($search_label))) {
171 if (!empty($search_type) && $search_type >= 0) {
172 $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
177 $sql .=
" SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity FROM ".MAIN_DB_PREFIX.
"societe sa";
178 $sql .=
" WHERE sa.entity IN (".getEntity(
'societe').
")";
179 $sql .=
" AND sa.code_compta_fournisseur <> ''";
181 if (strlen(trim($search_subaccount))) {
182 $lengthpaddingaccount = 0;
183 if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
184 $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
186 $search_subaccount_tmp = $search_subaccount;
187 $weremovedsomezero = 0;
188 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
189 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
190 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
191 $weremovedsomezero++;
192 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
198 if ($search_subaccount_tmp) {
199 if ($weremovedsomezero) {
200 $search_subaccount_tmp_clean = $search_subaccount_tmp;
201 $search_subaccount_clean = $search_subaccount;
203 if (strpos($search_subaccount_tmp,
'^') === 0) {
205 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
206 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
208 $sql .=
" AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
209 $sql .=
" OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
211 $sql .=
natural_search(
"sa.code_compta_fournisseur", $search_subaccount_tmp);
215 if (strlen(trim($search_label))) {
218 if (!empty($search_type) && $search_type >= 0) {
219 $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
224 $sql .=
" SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity FROM ".MAIN_DB_PREFIX.
"user u";
225 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
226 $sql .=
" AND u.accountancy_code <> ''";
228 if (strlen(trim($search_subaccount))) {
229 $lengthpaddingaccount = 0;
230 if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
231 $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
233 $search_subaccount_tmp = $search_subaccount;
234 $weremovedsomezero = 0;
235 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
236 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
237 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
238 $weremovedsomezero++;
239 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
245 if ($search_subaccount_tmp) {
246 if ($weremovedsomezero) {
247 $search_subaccount_tmp_clean = $search_subaccount_tmp;
248 $search_subaccount_clean = $search_subaccount;
250 if (strpos($search_subaccount_tmp,
'^') === 0) {
252 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
253 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
255 $sql .=
" AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
256 $sql .=
" OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
258 $sql .=
natural_search(
"u.accountancy_code", $search_subaccount_tmp);
262 if (strlen(trim($search_label))) {
265 if (!empty($search_type) && $search_type >= 0) {
266 $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
269 $sql .= $db->order($sortfield, $sortorder);
273 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
274 $resql = $db->query($sql);
282 $sql .= $db->plimit($limit + 1, $offset);
284 dol_syslog(
'accountancy/admin/subaccount.php:: $sql='.$sql);
285 $resql = $db->query($sql);
288 $num = $db->num_rows(
$resql);
291 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
292 $param .=
'&contextpage='.urlencode($contextpage);
294 if ($limit > 0 && $limit != $conf->liste_limit) {
295 $param .=
'&limit='.urlencode($limit);
297 if ($search_subaccount) {
298 $param .=
'&search_subaccount='.urlencode($search_subaccount);
301 $param .=
'&search_label='.urlencode($search_label);
303 if ($optioncss !=
'') {
304 $param .=
'&optioncss='.urlencode($optioncss);
307 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
308 if ($optioncss !=
'') {
309 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
312 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
313 print
'<input type="hidden" name="action" value="list">';
314 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
315 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
316 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
318 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit, 0, 0, 1);
320 print
'<div class="info">'.$langs->trans(
"WarningCreateSubAccounts").
'</div>';
322 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
323 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
326 $massactionbutton =
'';
328 print
'<div class="div-table-responsive">';
329 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
332 print
'<tr class="liste_titre_filter">';
333 if (!empty($arrayfields[
'subaccount'][
'checked'])) {
334 print
'<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.
'"></td>';
336 if (!empty($arrayfields[
'label'][
'checked'])) {
337 print
'<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.
'"></td>';
339 if (!empty($arrayfields[
'type'][
'checked'])) {
340 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>';
342 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
343 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
344 print
'<td class="liste_titre"> </td>';
347 print
'<td class="liste_titre maxwidthsearch">';
348 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
353 print
'<tr class="liste_titre">';
354 if (!empty($arrayfields[
'subaccount'][
'checked'])) {
355 print_liste_field_titre($arrayfields[
'subaccount'][
'label'], $_SERVER[
"PHP_SELF"],
"subaccount",
"", $param,
'', $sortfield, $sortorder);
357 if (!empty($arrayfields[
'label'][
'checked'])) {
358 print_liste_field_titre($arrayfields[
'label'][
'label'], $_SERVER[
"PHP_SELF"],
"label",
"", $param,
'', $sortfield, $sortorder);
360 if (!empty($arrayfields[
'type'][
'checked'])) {
361 print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
"PHP_SELF"],
"type",
"", $param,
'', $sortfield, $sortorder,
'center ');
363 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
364 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
365 print_liste_field_titre($arrayfields[
'reconcilable'][
'label'], $_SERVER[
"PHP_SELF"],
'reconcilable',
'', $param,
'', $sortfield, $sortorder,
'center ');
368 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
371 $totalarray = array();
372 $totalarray[
'nbfield'] = 0;
374 while ($i < min($num, $limit)) {
375 $obj = $db->fetch_object(
$resql);
377 print
'<tr class="oddeven">';
380 if (!empty($arrayfields[
'subaccount'][
'checked'])) {
385 $totalarray[
'nbfield']++;
390 if (!empty($arrayfields[
'label'][
'checked'])) {
395 $totalarray[
'nbfield']++;
400 if (!empty($arrayfields[
'type'][
'checked'])) {
401 print
'<td class="center">';
404 if ($obj->type == 1) {
405 $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>';
406 } elseif ($obj->type == 2) {
408 $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>';
409 } elseif ($obj->type == 3) {
411 $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>';
416 $totalarray[
'nbfield']++;
420 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
422 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
423 print
'<td class="center">';
424 if (empty($obj->reconcilable)) {
425 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=enable&mode=1&token='.
newToken().
'">';
426 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
429 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=disable&mode=1&token='.
newToken().
'">';
430 print
img_picto($langs->trans(
"Activated"),
'switch_on');
435 $totalarray[
'nbfield']++;
441 print
'<td class="center">';
444 if ($obj->type == 1) {
445 $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>';
446 } elseif ($obj->type == 2) {
448 $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>';
449 } elseif ($obj->type == 3) {
451 $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>';
456 $totalarray[
'nbfield']++;
465 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
466 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
467 print $hookmanager->resPrint;
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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.
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...
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_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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.