26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
31 $langs->loadLangs(array(
"compta",
"bills",
"admin",
"accountancy",
"salaries",
"hrm",
"errors"));
34 $action =
GETPOST(
'action',
'aZ09');
35 $cancel =
GETPOST(
'cancel',
'alpha');
37 $rowid =
GETPOST(
'rowid',
'int');
38 $massaction =
GETPOST(
'massaction',
'aZ09');
39 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'accountingsubaccountlist';
41 $search_subaccount =
GETPOST(
'search_subaccount',
'alpha');
42 $search_label =
GETPOST(
'search_label',
'alpha');
43 $search_type =
GETPOST(
'search_type',
'int');
50 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
51 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54 if (empty($page) || $page == -1) { $page = 0; }
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
58 if (!$sortfield) $sortfield =
"label";
59 if (!$sortorder) $sortorder =
"ASC";
62 'subaccount'=>array(
'label'=>$langs->trans(
"AccountNumber"),
'checked'=>1),
63 'label'=>array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
64 'type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1),
65 'reconcilable'=>array(
'label'=>$langs->trans(
"Reconcilable"),
'checked'=>1)
68 if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields[
'reconcilable']);
74 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
75 if (!
GETPOST(
'confirmmassaction',
'alpha')) { $massaction =
''; }
77 $parameters = array();
78 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
79 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
83 if (!empty($cancel)) $action =
'';
85 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
87 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
89 $search_subaccount =
"";
92 $search_array_options = array();
101 $form =
new Form($db);
103 $title = $langs->trans(
'ChartOfIndividualAccountsOfSubsidiaryLedger');
108 $sql =
"SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity";
109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe sa";
110 $sql .=
" WHERE sa.entity IN (".getEntity(
'societe').
")";
111 $sql .=
" AND sa.code_compta <> ''";
113 if (strlen(trim($search_subaccount))) {
114 $lengthpaddingaccount = 0;
115 if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
116 $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
118 $search_subaccount_tmp = $search_subaccount;
119 $weremovedsomezero = 0;
120 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
121 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
122 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
123 $weremovedsomezero++;
124 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
130 if ($search_subaccount_tmp) {
131 if ($weremovedsomezero) {
132 $search_subaccount_tmp_clean = $search_subaccount_tmp;
133 $search_subaccount_clean = $search_subaccount;
135 if (strpos($search_subaccount_tmp,
'^') === 0)
138 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
139 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
141 $sql .=
" AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
142 $sql .=
" OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
143 }
else $sql .=
natural_search(
"sa.code_compta", $search_subaccount_tmp);
146 if (strlen(trim($search_label))) $sql .=
natural_search(
"sa.nom", $search_label);
147 if (!empty($search_type) && $search_type >= 0) $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
151 $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";
152 $sql .=
" WHERE sa.entity IN (".getEntity(
'societe').
")";
153 $sql .=
" AND sa.code_compta_fournisseur <> ''";
155 if (strlen(trim($search_subaccount))) {
156 $lengthpaddingaccount = 0;
157 if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
158 $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
160 $search_subaccount_tmp = $search_subaccount;
161 $weremovedsomezero = 0;
162 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
163 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
164 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
165 $weremovedsomezero++;
166 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
172 if ($search_subaccount_tmp) {
173 if ($weremovedsomezero) {
174 $search_subaccount_tmp_clean = $search_subaccount_tmp;
175 $search_subaccount_clean = $search_subaccount;
177 if (strpos($search_subaccount_tmp,
'^') === 0)
180 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
181 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
183 $sql .=
" AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
184 $sql .=
" OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
185 }
else $sql .=
natural_search(
"sa.code_compta_fournisseur", $search_subaccount_tmp);
188 if (strlen(trim($search_label))) $sql .=
natural_search(
"sa.nom", $search_label);
189 if (!empty($search_type) && $search_type >= 0) $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
193 $sql .=
" SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity FROM ".MAIN_DB_PREFIX.
"user u";
194 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
195 $sql .=
" AND u.accountancy_code <> ''";
197 if (strlen(trim($search_subaccount))) {
198 $lengthpaddingaccount = 0;
199 if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
200 $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
202 $search_subaccount_tmp = $search_subaccount;
203 $weremovedsomezero = 0;
204 if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
205 for ($i = 0; $i < $lengthpaddingaccount; $i++) {
206 if (preg_match(
'/0$/', $search_subaccount_tmp)) {
207 $weremovedsomezero++;
208 $search_subaccount_tmp = preg_replace(
'/0$/',
'', $search_subaccount_tmp);
214 if ($search_subaccount_tmp) {
215 if ($weremovedsomezero) {
216 $search_subaccount_tmp_clean = $search_subaccount_tmp;
217 $search_subaccount_clean = $search_subaccount;
219 if (strpos($search_subaccount_tmp,
'^') === 0)
222 $search_subaccount_tmp_clean = preg_replace(
'/^\^/',
'', $search_subaccount_tmp);
223 $search_subaccount_clean = preg_replace(
'/^\^/',
'', $search_subaccount);
225 $sql .=
" AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean).
"'";
226 $sql .=
" OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean).
"%')";
227 }
else $sql .=
natural_search(
"u.accountancy_code", $search_subaccount_tmp);
230 if (strlen(trim($search_label))) $sql .=
natural_search(
"u.lastname", $search_label);
231 if (!empty($search_type) && $search_type >= 0) $sql .=
" HAVING type LIKE '".$db->escape($search_type).
"'";
233 $sql .= $db->order($sortfield, $sortorder);
236 $nbtotalofrecords =
'';
237 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
239 $resql = $db->query($sql);
240 $nbtotalofrecords = $db->num_rows(
$resql);
241 if (($page * $limit) > $nbtotalofrecords)
248 $sql .= $db->plimit($limit + 1, $offset);
250 dol_syslog(
'accountancy/admin/subaccount.php:: $sql='.$sql);
251 $resql = $db->query($sql);
255 $num = $db->num_rows(
$resql);
258 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
259 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
260 if ($search_subaccount) $param .=
'&search_subaccount='.urlencode($search_subaccount);
261 if ($search_label) $param .=
'&search_label='.urlencode($search_label);
262 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
264 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
265 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
266 print '<input type="hidden" name="token" value="'.newToken().
'">';
267 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
268 print '<input type="hidden" name="action" value="list">';
269 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
270 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
271 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
273 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit, 0, 0, 1);
275 print '<div class="warning">'.$langs->trans(
"WarningCreateSubAccounts").
'</div>';
277 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
278 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
281 $massactionbutton =
'';
283 print '<div class="div-table-responsive">';
284 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
287 print '<tr class="liste_titre_filter">';
288 if (!empty($arrayfields[
'subaccount'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.
'"></td>';
289 if (!empty($arrayfields[
'label'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.
'"></td>';
290 if (!empty($arrayfields[
'type'][
'checked'])) 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>';
291 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (!empty($arrayfields[
'reconcilable'][
'checked'])) print
'<td class="liste_titre"> </td>'; }
292 print
'<td class="liste_titre maxwidthsearch">';
293 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
298 print
'<tr class="liste_titre">';
299 if (!empty($arrayfields[
'subaccount'][
'checked']))
print_liste_field_titre($arrayfields[
'subaccount'][
'label'],
$_SERVER[
"PHP_SELF"],
"subaccount",
"", $param,
'', $sortfield, $sortorder);
300 if (!empty($arrayfields[
'label'][
'checked']))
print_liste_field_titre($arrayfields[
'label'][
'label'],
$_SERVER[
"PHP_SELF"],
"label",
"", $param,
'', $sortfield, $sortorder);
301 if (!empty($arrayfields[
'type'][
'checked']))
print_liste_field_titre($arrayfields[
'type'][
'label'],
$_SERVER[
"PHP_SELF"],
"type",
"", $param,
'', $sortfield, $sortorder,
'center ');
302 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (!empty($arrayfields[
'reconcilable'][
'checked']))
print_liste_field_titre($arrayfields[
'reconcilable'][
'label'],
$_SERVER[
"PHP_SELF"],
'reconcilable',
'', $param,
'', $sortfield, $sortorder,
'center '); }
306 $totalarray = array();
308 while ($i < min($num, $limit))
310 $obj = $db->fetch_object(
$resql);
312 print
'<tr class="oddeven">';
315 if (!empty($arrayfields[
'subaccount'][
'checked']))
320 if (!$i) $totalarray[
'nbfield']++;
324 if (!empty($arrayfields[
'label'][
'checked']))
329 if (!$i) $totalarray[
'nbfield']++;
333 if (!empty($arrayfields[
'type'][
'checked']))
335 print
'<td class="center">';
340 $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>';
343 elseif ($obj->type == 2)
345 $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>';
348 elseif ($obj->type == 3)
350 $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->id.
'">'.$langs->trans(
"Employee").
'</a>';
354 if (!$i) $totalarray[
'nbfield']++;
357 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
359 if (!empty($arrayfields[
'reconcilable'][
'checked'])) {
360 print
'<td class="center">';
361 if (empty($obj->reconcilable)) {
362 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=enable&mode=1">';
363 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
366 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=disable&mode=1">';
367 print
img_picto($langs->trans(
"Activated"),
'switch_on');
372 $totalarray[
'nbfield']++;
378 print
'<td class="center">';
383 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Customer").
'" href="'.DOL_URL_ROOT.
'/societe/card.php?action=edit&socid='.$obj->rowid.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
386 elseif ($obj->type == 2)
388 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Supplier").
'" href="'.DOL_URL_ROOT.
'/societe/card.php?action=edit&socid='.$obj->rowid.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
391 elseif ($obj->type == 3)
393 $e .=
'<a class="editfielda" title="'.$langs->trans(
"Employee").
'" href="'.DOL_URL_ROOT.
'/user/card.php?action=edit&id='.$obj->rowid.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"]).
'">'.
img_edit().
'</a>';
397 if (!$i) $totalarray[
'nbfield']++;
405 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
406 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
407 print $hookmanager->resPrint;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 Calling this function terminate execution ...
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...
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.