43 require
'../../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
50 $langs->loadLangs(array(
"banks",
"other"));
52 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
53 $massaction =
GETPOST(
'massaction',
'alpha');
54 $show_files =
GETPOST(
'show_files',
'int');
55 $confirm =
GETPOST(
'confirm',
'alpha');
56 $cancel =
GETPOST(
'cancel',
'alpha');
57 $toselect =
GETPOST(
'toselect',
'array');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'cashcontrol';
59 $backtopage =
GETPOST(
'backtopage',
'alpha');
60 $optioncss =
GETPOST(
'optioncss',
'aZ');
65 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
66 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
67 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
70 $offset = $limit * $page;
71 $pageprev = $page - 1;
72 $pagenext = $page + 1;
79 $diroutputmassaction = $conf->monmodule->dir_output.
'/temp/massgeneration/'.$user->id;
80 $hookmanager->initHooks(array(
'cashcontrol'));
83 $extrafields->fetch_name_optionals_label($object->table_element);
85 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
88 if (!$sortfield) $sortfield =
"t.".key($object->fields);
89 if (!$sortorder) $sortorder =
"ASC";
101 $search_all =
GETPOST(
"search_all",
'alpha');
103 foreach ($object->fields as $key => $val)
105 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
109 $fieldstosearchall = array();
110 foreach ($object->fields as $key => $val)
112 if ($val[
'searchall']) $fieldstosearchall[
't.'.$key] = $val[
'label'];
116 $arrayfields = array();
117 foreach ($object->fields as $key => $val)
120 if (!empty($val[
'visible'])) $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled'],
'position'=>$val[
'position']);
123 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
134 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
135 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
137 $parameters = array();
138 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
139 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
144 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
147 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
149 foreach ($object->fields as $key => $val)
154 $search_array_options = array();
156 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
157 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha'))
163 $objectclass =
'CashControl';
164 $objectlabel =
'CashControl';
165 $permissiontoread = ($user->rights->cashdesk->run || $user->rights->takepos->run);
166 $permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run);
178 $form =
new Form($db);
184 $title = $langs->trans(
'CashControl');
190 foreach ($object->fields as $key => $val)
192 $sql .=
't.'.$key.
', ';
195 if (!empty($extrafields->attributes[$object->table_element][
'label']))
197 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
' as options_'.$key.
', ' :
'');
200 $parameters = array();
201 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
202 $sql .= $hookmanager->resPrint;
203 $sql = preg_replace(
'/, $/',
'', $sql);
204 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
205 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
206 if ($object->ismultientitymanaged == 1) $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
207 else $sql .=
" WHERE 1 = 1";
208 foreach ($search as $key => $val)
210 if ($key ==
'status' && $search[$key] == -1)
continue;
211 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
212 if ($search[$key] !=
'') $sql .=
natural_search($key, $search[$key], (($key ==
'status') ? 2 : $mode_search));
214 if ($search_all) $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
216 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
218 $parameters = array();
219 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
220 $sql .= $hookmanager->resPrint;
238 $sql .= $db->order($sortfield, $sortorder);
241 $nbtotalofrecords =
'';
242 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
244 $resql = $db->query($sql);
245 $nbtotalofrecords = $db->num_rows(
$resql);
246 if (($page * $limit) > $nbtotalofrecords)
253 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
255 $num = $nbtotalofrecords;
257 $sql .= $db->plimit($limit + 1, $offset);
259 $resql = $db->query($sql);
266 $num = $db->num_rows(
$resql);
270 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
272 $obj = $db->fetch_object(
$resql);
274 header(
"Location: ".
dol_buildpath(
'/compta/cashcontrol/cashcontrol_card.php', 1).
'?id='.$id);
285 print '<script type="text/javascript" language="javascript">
286 jQuery(document).ready(function() {
287 function init_myfunc()
289 jQuery("#myid").removeAttr(\'disabled\');
290 jQuery("#myid").attr(\'disabled\',\'disabled\');
293 jQuery("#mybutton").click(function() {
299 $arrayofselected = is_array($toselect) ? $toselect : array();
302 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
303 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
304 foreach ($search as $key => $val)
306 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
308 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
310 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
313 $arrayofmassactions = array(
318 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
319 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
321 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
322 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
323 print '<input type="hidden" name="token" value="'.newToken().
'">';
324 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
325 print '<input type="hidden" name="action" value="list">';
326 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
327 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
328 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
330 $permforcashfence = 1;
332 $newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode(
$_SERVER[
'PHP_SELF']),
'', $permforcashfence);
334 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'cash-register', 0, $newcardbutton,
'', $limit, 0, 0, 1);
337 $topicmail =
"SendCashControlRef";
338 $modelmail =
"cashcontrol";
340 $trackid =
'cashfence'.$object->id;
341 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
345 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
346 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
354 $parameters = array();
355 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
356 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
357 else $moreforfilter = $hookmanager->resPrint;
359 if (!empty($moreforfilter))
361 print '<div class="liste_titre liste_titre_bydiv centpercent">';
362 print $moreforfilter;
366 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
367 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
368 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
370 print '<div class="div-table-responsive">';
371 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
376 print '<tr class="liste_titre">';
377 foreach ($object->fields as $key => $val)
379 $cssforfield = (empty($val[
'css']) ?
'' : $val[
'css']);
380 if ($key ==
'status') $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
381 elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
382 elseif (in_array($val['
type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
383 elseif (in_array($val['type'], array('
double(24,8)', '
double(6,3)', 'integer', 'real', '
price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
384 if (!empty($arrayfields['t.'.$key]['checked']))
386 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'">';
387 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) print $form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], $search[$key], $val[
'notnull'], 0, 0,
'', 1, 0, 0,
'',
'maxwidth100', 1);
388 else print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag($search[$key]).
'">';
393 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
396 $parameters = array(
'arrayfields'=>$arrayfields);
397 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
398 print $hookmanager->resPrint;
400 print
'<td class="liste_titre maxwidthsearch">';
401 $searchpicto = $form->showFilterButtons();
409 print
'<tr class="liste_titre">';
410 foreach ($object->fields as $key => $val)
412 $cssforfield = (empty($val[
'css']) ?
'' : $val[
'css']);
413 if ($key ==
'status') $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
414 elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
415 elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
416 elseif (in_array($val['type'], array('
double(24,8)', '
double(6,3)', 'integer', 'real', '
price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
417 if (!empty($arrayfields['t.'.$key]['checked']))
419 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0,
$_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
423 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
425 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
426 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
427 print $hookmanager->resPrint;
428 print
getTitleFieldOfList($selectedfields, 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
433 $needToFetchEachLine = 0;
434 if (is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0)
436 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val)
438 if (preg_match(
'/\$object/', $val)) $needToFetchEachLine++;
446 $totalarray = array();
447 while ($i < min($num, $limit))
449 $obj = $db->fetch_object(
$resql);
450 if (empty($obj))
break;
453 $object->id = $obj->rowid;
454 foreach ($object->fields as $key => $val)
456 if (property_exists($obj, $key)) $object->$key = $obj->$key;
460 print
'<tr class="oddeven">';
461 foreach ($object->fields as $key => $val)
463 $cssforfield = (empty($val[
'css']) ?
'' : $val[
'css']);
464 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
465 elseif ($key ==
'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
467 if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
468 elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
470 if (in_array($val['type'], array('
double(24,8)', '
double(6,3)', 'integer', 'real', '
price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
472 if (!empty($arrayfields['t.'.$key]['checked']))
474 print
'<td'.($cssforfield ?
' class="'.$cssforfield.
'"' :
'').
'>';
475 if ($key ==
'status') print $object->getLibStatut(5);
476 elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
477 else print $object->showOutputField($val, $key, $obj->$key, '');
479 if (!$i) $totalarray['nbfield']++;
480 if (!empty($val['isameasure']))
482 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
483 $totalarray[
'val'][
't.'.$key] += $obj->$key;
488 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
490 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
491 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
492 print $hookmanager->resPrint;
494 print
'<td class="nowrap" align="center">';
495 if ($massactionbutton || $massaction)
498 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
499 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
502 if (!$i) $totalarray[
'nbfield']++;
510 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
517 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
518 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
523 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
524 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
525 print $hookmanager->resPrint;
527 print
'</table>'.
"\n";
530 print
'</form>'.
"\n";
532 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords))
534 $hidegeneratedfilelistifempty = 1;
535 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
537 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
541 $urlsource =
$_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
542 $urlsource .= str_replace(
'&',
'&', $param);
544 $filedir = $diroutputmassaction;
545 $genallowed = $user->rights->monmodule->read;
546 $delallowed = $user->rights->monmodule->create;
548 print $formfile->showdocuments(
'massfilesarea_monmodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
Class to manage cash fence.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...