27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/zapier/class/hook.class.php';
34 $langs->loadLangs(array(
"zapier",
"other"));
37 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
39 $massaction =
GETPOST(
'massaction',
'alpha');
40 $show_files =
GETPOST(
'show_files',
'int');
41 $confirm =
GETPOST(
'confirm',
'alpha');
42 $cancel =
GETPOST(
'cancel',
'alpha');
43 $toselect =
GETPOST(
'toselect',
'array');
44 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'zapierlist';
45 $backtopage =
GETPOST(
'backtopage',
'alpha');
46 $optioncss =
GETPOST(
'optioncss',
'aZ');
51 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
52 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
59 $offset = $limit * $page;
60 $pageprev = $page - 1;
61 $pagenext = $page + 1;
66 $object =
new Hook($db);
68 $diroutputmassaction = $conf->zapier->dir_output.
'/temp/massgeneration/'.$user->id;
70 $hookmanager->initHooks(array(
'zapierhooklist'));
73 $extrafields->fetch_name_optionals_label($object->table_element);
75 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
80 $sortfield =
"t.".key($object->fields);
88 if ($user->socid > 0) {
96 $search_all =
GETPOST(
"search_all",
'alpha');
98 foreach ($object->fields as $key => $val) {
99 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
103 $fieldstosearchall = array();
104 foreach ($object->fields as $key => $val) {
105 if ($val[
'searchall']) $fieldstosearchall[
't.'.$key] = $val[
'label'];
109 $arrayfields = array();
110 foreach ($object->fields as $key => $val) {
112 if (!empty($val[
'visible'])) $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled'],
'position'=>$val[
'position']);
115 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
126 if (
GETPOST(
'cancel',
'alpha')) {
130 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
134 $parameters = array();
135 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
136 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
138 if (empty($reshook)) {
140 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
143 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
145 foreach ($object->fields as $key => $val) {
149 $search_array_options = array();
151 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
152 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
157 $objectclass =
'Hook';
158 $objectlabel =
'Hook';
159 $permissiontoread = $user->rights->zapier->read;
160 $permissiontodelete = $user->rights->zapier->delete;
161 $uploaddir = $conf->zapier->dir_output;
162 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
171 $form =
new Form($db);
177 $title = $langs->trans(
'ListOf', $langs->transnoentitiesnoconv(
"Hooks"));
183 foreach ($object->fields as $key => $val) {
184 $sql .=
't.'.$key.
', ';
187 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
188 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
189 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
' as options_'.$key.
', ' :
'');
193 $parameters = array();
194 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
195 $sql .= $hookmanager->resPrint;
196 $sql = preg_replace(
'/, $/',
'', $sql);
197 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
198 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)";
199 if ($object->ismultientitymanaged == 1) {
200 $sql .=
" WHERE t.entity IN (".getEntity($object->element).
")";
202 $sql .=
" WHERE 1 = 1";
204 foreach ($search as $key => $val) {
205 if ($key ==
'status' && $search[$key] == -1) {
208 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
209 if ($search[$key] !=
'') {
210 $sql .=
natural_search($key, $search[$key], (($key ==
'status') ? 2 : $mode_search));
214 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
217 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
219 $parameters = array();
220 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
221 $sql .= $hookmanager->resPrint;
239 $sql .= $db->order($sortfield, $sortorder);
242 $nbtotalofrecords =
'';
243 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) {
254 $num = $nbtotalofrecords;
256 $sql .= $db->plimit($limit + 1, $offset);
258 $resql = $db->query($sql);
264 $num = $db->num_rows(
$resql);
268 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
269 $obj = $db->fetch_object(
$resql);
271 header(
"Location: ".
dol_buildpath(
'/zapierfordolibarr/hook_card.php', 1).
'?id='.$id);
296 $arrayofselected = is_array($toselect) ? $toselect : array();
299 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
300 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
301 foreach ($search as $key => $val) {
302 if (is_array($search[$key]) && count($search[$key])) {
303 foreach ($search[$key] as $skey) {
304 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
307 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
310 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
312 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
315 $arrayofmassactions = array(
319 if ($user->rights->zapier->delete) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
320 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
321 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
323 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
324 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
325 print '<input type="hidden" name="token" value="'.newToken().
'">';
326 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
327 print '<input type="hidden" name="action" value="list">';
328 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
329 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
330 print '<input type="hidden" name="page" value="'.$page.
'">';
331 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
336 $newcardbutton =
'<a class="butActionNew" href="hook_card.php?action=create&backtopage='.urlencode(
$_SERVER[
'PHP_SELF']).
'"><span class="valignmiddle text-plus-circle">'.$langs->trans(
'New').
'</span>';
337 $newcardbutton .=
'<span class="fa fa-plus-circle valignmiddle"></span>';
338 $newcardbutton .=
'</a>';
347 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_companies', 0, $newcardbutton,
'', $limit);
350 $topicmail =
"SendHookRef";
352 $objecttmp =
new Hook($db);
353 $trackid =
'zapier'.$object->id;
354 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
357 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
358 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
366 $parameters = array();
367 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
368 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
369 else $moreforfilter = $hookmanager->resPrint;
371 if (!empty($moreforfilter)) {
372 print '<div class="liste_titre liste_titre_bydiv centpercent">';
373 print $moreforfilter;
377 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
378 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
379 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
381 print '<div class="div-table-responsive">';
382 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
387 print '<tr class="liste_titre">';
388 foreach ($object->fields as $key => $val) {
390 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
391 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
393 if (in_array($val[
'type'], array(
'timestamp'))) {
394 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
396 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real'))) {
397 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
399 if ($key ==
'status') {
400 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
402 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
403 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').
'"><input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag($search[$key]).
'"></td>';
407 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
410 $parameters = array(
'arrayfields'=>$arrayfields);
411 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
412 print $hookmanager->resPrint;
414 print
'<td class="liste_titre right">';
415 $searchpicto = $form->showFilterButtons();
423 print
'<tr class="liste_titre">';
424 foreach ($object->fields as $key => $val) {
426 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
427 if (in_array($val[
'type'], array(
'timestamp'))) $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
428 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real'))) $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
429 if ($key ==
'status') {
430 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
432 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
433 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0,
$_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
'')).
"\n";
437 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
440 'arrayfields' => $arrayfields,
442 'sortfield' => $sortfield,
443 'sortorder' => $sortorder,
445 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
446 print $hookmanager->resPrint;
448 print
getTitleFieldOfList($selectedfields, 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
453 $needToFetchEachLine = 0;
454 if (is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
455 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
456 if (preg_match(
'/\$object/', $val)) {
458 $needToFetchEachLine++;
467 $totalarray = array();
468 while ($i < min($num, $limit)) {
469 $obj = $db->fetch_object(
$resql);
475 $object->id = $obj->rowid;
476 foreach ($object->fields as $key => $val) {
477 if (isset($obj->$key)) $object->$key = $obj->$key;
481 print
'<tr class="oddeven">';
482 foreach ($object->fields as $key => $val) {
484 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
485 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
486 } elseif ($key ==
'status') {
487 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
490 if (in_array($val[
'type'], array(
'timestamp'))) $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
491 elseif ($key ==
'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
493 if (in_array($val['
type'], array('
double(24,8)', '
double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
495 if (!empty($arrayfields['t.'.$key]['checked'])) {
497 if ($cssforfield || $val[
'css']) print
' class="';
499 if ($cssforfield && $val[
'css']) print
' ';
501 if ($cssforfield || $val[
'css']) print
'"';
503 if ($key ==
'status') print $object->getLibStatut(5);
504 elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
505 else print $object->showOutputField($val, $key, $obj->$key, '');
507 if (!$i) $totalarray['nbfield']++;
508 if (!empty($val['isameasure'])) {
509 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
510 $totalarray[
'val'][
't.'.$key] += $obj->$key;
515 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
517 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
518 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
519 print $hookmanager->resPrint;
521 print
'<td class="nowrap center">';
522 if ($massactionbutton || $massaction) {
525 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
526 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
529 if (!$i) $totalarray[
'nbfield']++;
537 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
543 foreach ($arrayfields as $key => $val) {
544 if (!empty($val[
'checked'])) {
548 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
555 'arrayfields' => $arrayfields,
558 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
559 print $hookmanager->resPrint;
561 print
'</table>'.
"\n";
564 print
'</form>'.
"\n";
566 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
567 $hidegeneratedfilelistifempty = 1;
568 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
569 $hidegeneratedfilelistifempty = 0;
572 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
576 $urlsource =
$_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
577 $urlsource .= str_replace(
'&',
'&', $param);
579 $filedir = $diroutputmassaction;
580 $genallowed = $user->rights->zapier->read;
581 $delallowed = $user->rights->zapier->create;
583 print $formfile->showdocuments(
'massfilesarea_zapier',
'', $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.
dol_now($mode= 'auto')
Return date for now.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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...