From a618bf2ae604e2be40544210375fffcfb41eb202 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2024 09:54:11 +0200 Subject: [PATCH] Debug v20 --- htdocs/comm/mailing/card.php | 2 +- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/tpl/card_presend.tpl.php | 2 +- htdocs/expensereport/list.php | 1307 +++++++++-------- .../modulebuilder/template/myobject_list.php | 1 + htdocs/webhook/class/target.class.php | 2 +- 6 files changed, 678 insertions(+), 638 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 9a89e57b8b7..4eec3884a27 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -852,8 +852,8 @@ if ($action == 'create') { $formmail = new FormMail($db); $formmail->withfckeditor = 1; - $formmail->withaiprompt = 'html'; $formmail->withlayout = 1; + $formmail->withaiprompt = 'html'; print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 780cb7ca85a..94a520b3c48 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1008,7 +1008,7 @@ class FormMail extends Form $out .= ''; $formmail = $this; - $showlinktolayout = $formmail->withlayout && $formmail->withfckeditor; + $showlinktolayout = $formmail->withlayout && $formmail->withfckeditor && getDolGlobalInt('MAIN_EMAIL_USE_LAYOUT'); $showlinktolayoutlabel = $langs->trans("FillMessageWithALayout"); $showlinktoai = ($formmail->withaiprompt && isModEnabled('ai')) ? 'textgenerationemail' : ''; $showlinktoailabel = $langs->trans("FillMessageWithAIContent"); diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index de9da00a64f..2b61c20c9ed 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -189,7 +189,7 @@ if ($action == 'presend') { $formmail->trackid = empty($trackid) ? '' : $trackid; $formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto; $formmail->withfrom = 1; - $formmail->withlayout = getDolGlobalInt('MAIN_EMAIL_USE_LAYOUT'); + $formmail->withlayout = 1; $formmail->withaiprompt = 'html'; // Define $liste, a list of recipients with email inside <>. diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index ccabebed79f..471c3ffdcc4 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -100,7 +100,7 @@ if (!$sortfield) { } -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alpha'); $search_user = GETPOST('search_user', 'intcomma'); @@ -178,6 +178,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $canedituser = (!empty($user->admin) || $user->hasRight('user', 'user', 'creer')); +$permissiontoread = $user->hasRight('expensereport', 'lire'); +$permissiontodelete = $user->hasRight('expensereport', 'supprimer'); + $objectuser = new User($db); @@ -238,8 +241,6 @@ if (empty($reshook)) { // Mass actions $objectclass = 'ExpenseReport'; $objectlabel = 'ExpenseReport'; - $permissiontoread = $user->hasRight('expensereport', 'lire'); - $permissiontodelete = $user->hasRight('expensereport', 'supprimer'); $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -257,7 +258,9 @@ $formexpensereport = new FormExpenseReport($db); $fuser = new User($db); $title = $langs->trans("TripsAndExpenses"); -llxHeader('', $title); +$help_url = ''; +$morejs = array(); +$morecss = array(); $max_year = 5; $min_year = 10; @@ -274,6 +277,8 @@ if ($id > 0) { $search_user = $user_id; } +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,"; $sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; $sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut as user_status, u.photo"; @@ -285,8 +290,9 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total @@ -297,8 +303,8 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array $sql .= ", ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; // Search all -if (!empty($sall)) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if (!empty($search_all)) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } // Ref if (!empty($search_ref)) { @@ -342,7 +348,7 @@ if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expenserep include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; // Count total nb of records @@ -359,7 +365,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -374,649 +380,682 @@ if ($limit) { //print $sql; $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - $arrayofselected = is_array($toselect) ? $toselect : array(); +$num = $db->num_rows($resql); - $param = ''; - if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); - } - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($sall) { - $param .= "&sall=".urlencode($sall); - } - if ($search_ref) { - $param .= "&search_ref=".urlencode($search_ref); - } - // Start date - if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); - } - if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); - } - if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); - } - if ($search_date_startendday) { - $param .= '&search_date_startendday='.urlencode((string) ($search_date_startendday)); - } - if ($search_date_startendmonth) { - $param .= '&search_date_startendmonth='.urlencode((string) ($search_date_startendmonth)); - } - if ($search_date_startendyear) { - $param .= '&search_date_startendyear='.urlencode((string) ($search_date_startendyear)); - } - // End date - if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); - } - if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); - } - if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); - } - if ($search_date_endendday) { - $param .= '&search_date_endendday='.urlencode((string) ($search_date_endendday)); - } - if ($search_date_endendmonth) { - $param .= '&search_date_endendmonth='.urlencode((string) ($search_date_endendmonth)); - } - if ($search_date_endendyear) { - $param .= '&search_date_endendyear='.urlencode((string) ($search_date_endendyear)); - } - if ($search_user) { - $param .= "&search_user=".urlencode($search_user); - } - if ($search_amount_ht) { - $param .= "&search_amount_ht=".urlencode($search_amount_ht); - } - if ($search_amount_ttc) { - $param .= "&search_amount_ttc=".urlencode($search_amount_ttc); - } - if ($search_status >= 0) { - $param .= "&search_status=".urlencode($search_status); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - // List of mass actions available - $arrayofmassactions = array( - 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), - ); - if ($user->hasRight('expensereport', 'supprimer')) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); - } - if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); - } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); +// Output page +// -------------------------------------------------------------------- - // Lines of title fields - print '
'."\n"; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($id > 0) { - print ''; - } +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, ''); - if ($id > 0) { // For user tab - $title = $langs->trans("User"); - $linkback = ''.$langs->trans("BackToList").''; - $head = user_prepare_head($fuser); +$arrayofselected = is_array($toselect) ? $toselect : array(); - print dol_get_fiche_head($head, 'expensereport', $title, -1, 'user'); +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($search_all) { + $param .= "&search_all=".urlencode($search_all); +} +if ($search_ref) { + $param .= "&search_ref=".urlencode($search_ref); +} +// Start date +if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode((string) ($search_date_startday)); +} +if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth)); +} +if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear)); +} +if ($search_date_startendday) { + $param .= '&search_date_startendday='.urlencode((string) ($search_date_startendday)); +} +if ($search_date_startendmonth) { + $param .= '&search_date_startendmonth='.urlencode((string) ($search_date_startendmonth)); +} +if ($search_date_startendyear) { + $param .= '&search_date_startendyear='.urlencode((string) ($search_date_startendyear)); +} +// End date +if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode((string) ($search_date_endday)); +} +if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth)); +} +if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear)); +} +if ($search_date_endendday) { + $param .= '&search_date_endendday='.urlencode((string) ($search_date_endendday)); +} +if ($search_date_endendmonth) { + $param .= '&search_date_endendmonth='.urlencode((string) ($search_date_endendmonth)); +} +if ($search_date_endendyear) { + $param .= '&search_date_endendyear='.urlencode((string) ($search_date_endendyear)); +} +if ($search_user) { + $param .= "&search_user=".urlencode($search_user); +} +if ($search_amount_ht) { + $param .= "&search_amount_ht=".urlencode($search_amount_ht); +} +if ($search_amount_ttc) { + $param .= "&search_amount_ttc=".urlencode($search_amount_ttc); +} +if ($search_status >= 0) { + $param .= "&search_status=".urlencode($search_status); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - dol_banner_tab($fuser, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin); +// List of mass actions available +$arrayofmassactions = array( + 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); +if ($user->hasRight('expensereport', 'supprimer')) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - print dol_get_fiche_end(); +// Lines of title fields +print ''."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +if ($id > 0) { + print ''; +} - if ($action != 'edit') { - print '
'; +if ($id > 0) { // For user tab + $title = $langs->trans("User"); + $linkback = ''.$langs->trans("BackToList").''; + $head = user_prepare_head($fuser); - $childids = $user->getAllChildIds(1); + print dol_get_fiche_head($head, 'expensereport', $title, -1, 'user'); - $canedit = ((in_array($user_id, $childids) && $user->hasRight('expensereport', 'creer')) - || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->hasRight('expensereport', 'writeall_advance'))); + dol_banner_tab($fuser, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin); - // Buttons for actions - if ($canedit) { - print ''.$langs->trans("AddTrip").''; - } else { - print ''.$langs->trans("AddTrip").''; - } + print dol_get_fiche_end(); - print '
'; + if ($action != 'edit') { + print '
'; + + $childids = $user->getAllChildIds(1); + + $canedit = ((in_array($user_id, $childids) && $user->hasRight('expensereport', 'creer')) + || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->hasRight('expensereport', 'writeall_advance'))); + + // Buttons for actions + if ($canedit) { + print ''.$langs->trans("AddTrip").''; } else { - print $form->buttonsSaveCancel("Save", ''); + print ''.$langs->trans("AddTrip").''; } + + print '
'; } else { - $title = $langs->trans("ListTripsAndExpenses"); - - $url = DOL_URL_ROOT.'/expensereport/card.php?action=create'; - if (!empty($socid)) { - $url .= '&socid='.$socid; - } - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); - $newcardbutton .= dolGetButtonTitleSeparator(); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('expensereport', 'creer')); - - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1); - } - - $topicmail = "SendExpenseReport"; - $modelmail = "expensereport"; - $objecttmp = new ExpenseReport($db); - $trackid = 'exp'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - - if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '
'.$langs->trans("FilterOnInto", $sall).implode(', ', $fieldstosearchall).'
'; - } - - $moreforfilter = ''; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; - } - - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields - $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - - print '
'; - print ''."\n"; - - // Filters - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!empty($arrayfields['d.ref']['checked'])) { - print ''; - } - // User - if (!empty($arrayfields['user']['checked'])) { - if ($user->hasRight('expensereport', 'readall') || $user->hasRight('expensereport', 'lire_tous')) { - print ''; - } else { - print ''; - } - } - // Date start - if (!empty($arrayfields['d.date_debut']['checked'])) { - print ''; - } - // Date end - if (!empty($arrayfields['d.date_fin']['checked'])) { - print ''; - } - // Date valid - if (!empty($arrayfields['d.date_valid']['checked'])) { - print ''; - } - // Date approve - if (!empty($arrayfields['d.date_approve']['checked'])) { - print ''; - } - // Amount with no tax - if (!empty($arrayfields['d.total_ht']['checked'])) { - print ''; - } - if (!empty($arrayfields['d.total_vat']['checked'])) { - print ''; - } - // Amount with all taxes - if (!empty($arrayfields['d.total_ttc']['checked'])) { - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - // Fields from hook - $parameters = array('arrayfields' => $arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['d.date_create']['checked'])) { - print ''; - } - // Date modification - if (!empty($arrayfields['d.tms']['checked'])) { - print ''; - } - // Status - if (!empty($arrayfields['d.fk_statut']['checked'])) { - print ''; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - - print "\n"; - - $totalarray = array(); - $totalarray['nbfield'] = 0; - - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.ref']['checked'])) { - print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['user']['checked'])) { - print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.date_debut']['checked'])) { - print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.date_fin']['checked'])) { - print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.date_valid']['checked'])) { - print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.date_approve']['checked'])) { - print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.total_vat']['checked'])) { - print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (!empty($arrayfields['d.date_create']['checked'])) { - print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, '', $sortfield, $sortorder, 'nowraponall center'); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.tms']['checked'])) { - print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, '', $sortfield, $sortorder, 'nowraponall center'); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['d.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - $totalarray['nbfield']++; - } - print "\n"; - - $total_total_ht = 0; - $total_total_ttc = 0; - $total_total_tva = 0; - - $expensereportstatic = new ExpenseReport($db); - $usertmp = new User($db); - - if ($num > 0) { - $i = 0; - $savnbfield = $totalarray['nbfield']; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $totalarray['val'] = array(); - $totalarray['val']['d.total_ht'] = 0; - $totalarray['val']['d.total_tva'] = 0; - $totalarray['val']['d.total_ttc'] = 0; - $totalarray['totalizable'] = array(); - - $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - - $expensereportstatic->id = $obj->rowid; - $expensereportstatic->ref = $obj->ref; - $expensereportstatic->status = $obj->status; - $expensereportstatic->date_debut = $db->jdate($obj->date_debut); - $expensereportstatic->date_fin = $db->jdate($obj->date_fin); - $expensereportstatic->date_create = $db->jdate($obj->date_create); - $expensereportstatic->date_modif = $db->jdate($obj->date_modif); - $expensereportstatic->date_valid = $db->jdate($obj->date_valid); - $expensereportstatic->date_approve = $db->jdate($obj->date_approve); - $expensereportstatic->note_private = $obj->note_private; - $expensereportstatic->note_public = $obj->note_public; - $expensereportstatic->fk_user = $obj->id_user; - - $usertmp->id = $obj->id_user; - $usertmp->lastname = $obj->lastname; - $usertmp->firstname = $obj->firstname; - $usertmp->login = $obj->login; - $usertmp->statut = $obj->user_status; - $usertmp->status = $obj->user_status; - $usertmp->photo = $obj->photo; - $usertmp->email = $obj->email; - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - } - } else { - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // User - if (!empty($arrayfields['user']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Start date - if (!empty($arrayfields['d.date_debut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // End date - if (!empty($arrayfields['d.date_fin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date validation - if (!empty($arrayfields['d.date_valid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date approval - if (!empty($arrayfields['d.date_approve']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['d.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht'; - } - $totalarray['val']['d.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['d.total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva'; - } - $totalarray['val']['d.total_tva'] += $obj->total_tva; - } - // Amount TTC - if (!empty($arrayfields['d.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc'; - } - $totalarray['val']['d.total_ttc'] += $obj->total_ttc; - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['d.date_create']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['d.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['d.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - print "\n"; - } - - $total_total_ht = $total_total_ht + $obj->total_ht; - $total_total_tva = $total_total_tva + $obj->total_tva; - $total_total_ttc = $total_total_ttc + $obj->total_ttc; - - $i++; - } - } else { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; - } - - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - $db->free($resql); - - $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - print ''; - print ''; - print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - print ' '; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_startend ? $search_date_startend : -1, 'search_date_startend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_endend ? $search_date_endend : -1, 'search_date_endend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - //print ''; - //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year); - print ''; - //print ''; - //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year); - print ''; - print ''; - print ''; - $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1); - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; - print '
'; - } - // TODO Use a cache on user - $usertmp->fetch($obj->id_user); - - // Output Kanban - if ($massactionbutton || $massaction) { - $selected = 0; - - print $expensereportstatic->getKanbanView('', array('userauthor' => $usertmp, 'selected' => in_array($expensereportstatic->id, $arrayofselected))); - } - if ($i == ($imaxinloop - 1)) { - print '
'; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - print ''; - print ''; - // Warning late icon and note - print ''; - print ''; - print '
'; - print $expensereportstatic->getNomUrl(1); - print ''; - if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) { - print img_warning($langs->trans("Late")); - } - if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) { - print img_warning($langs->trans("Late")); - } - if (!empty($obj->note_private) || !empty($obj->note_public)) { - print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; - print ''; - } - print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir); - print '
'; - print '
'; - print $usertmp->getNomUrl(-1); - print ''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; - print dol_print_date($db->jdate($obj->date_create), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_modif), 'dayhour'); - print ''.$expensereportstatic->getLibStatut(5).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$langs->trans("NoRecordFound").'
'."\n"; - print '
'; - - print '
'."\n"; - - if (empty($id)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } - - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $user->hasRight('expensereport', 'lire'); - $delallowed = $user->hasRight('expensereport', 'creer'); - - print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print $form->buttonsSaveCancel("Save", ''); } } else { - dol_print_error($db); + $title = $langs->trans("ListTripsAndExpenses"); + + $url = DOL_URL_ROOT.'/expensereport/card.php?action=create'; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); + $newcardbutton .= dolGetButtonTitleSeparator(); + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('expensereport', 'creer')); + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1); +} + +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "SendExpenseReport"; +$modelmail = "expensereport"; +$objecttmp = new ExpenseReport($db); +$trackid = 'exp'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) { + $setupstring = ''; + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; + } + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'
'."\n"; +} + +$moreforfilter = ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup +$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : ''); +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} +if (!empty($arrayfields['d.ref']['checked'])) { + print ''; +} +// User +if (!empty($arrayfields['user']['checked'])) { + if ($user->hasRight('expensereport', 'readall') || $user->hasRight('expensereport', 'lire_tous')) { + print ''; + } else { + print ''; + } +} +// Date start +if (!empty($arrayfields['d.date_debut']['checked'])) { + print ''; +} +// Date end +if (!empty($arrayfields['d.date_fin']['checked'])) { + print ''; +} +// Date valid +if (!empty($arrayfields['d.date_valid']['checked'])) { + print ''; +} +// Date approve +if (!empty($arrayfields['d.date_approve']['checked'])) { + print ''; +} +// Amount with no tax +if (!empty($arrayfields['d.total_ht']['checked'])) { + print ''; +} +if (!empty($arrayfields['d.total_vat']['checked'])) { + print ''; +} +// Amount with all taxes +if (!empty($arrayfields['d.total_ttc']['checked'])) { + print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields' => $arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (!empty($arrayfields['d.date_create']['checked'])) { + print ''; +} +// Date modification +if (!empty($arrayfields['d.tms']['checked'])) { + print ''; +} +// Status +if (!empty($arrayfields['d.fk_statut']['checked'])) { + print ''; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} + +print ''."\n"; + +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.ref']['checked'])) { + print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['user']['checked'])) { + print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.date_debut']['checked'])) { + print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.date_fin']['checked'])) { + print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.date_valid']['checked'])) { + print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.date_approve']['checked'])) { + print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.total_vat']['checked'])) { + print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (!empty($arrayfields['d.date_create']['checked'])) { + print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, '', $sortfield, $sortorder, 'nowraponall center'); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.tms']['checked'])) { + print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, '', $sortfield, $sortorder, 'nowraponall center'); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['d.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; +} +print ''."\n"; + + +// Loop on record +// -------------------------------------------------------------------- + +$total_total_ht = 0; +$total_total_ttc = 0; +$total_total_tva = 0; + +$expensereportstatic = new ExpenseReport($db); +$usertmp = new User($db); + +if ($num > 0) { + $i = 0; + $savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val'] = array(); + $totalarray['val']['d.total_ht'] = 0; + $totalarray['val']['d.total_tva'] = 0; + $totalarray['val']['d.total_ttc'] = 0; + $totalarray['totalizable'] = array(); + + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + + $expensereportstatic->id = $obj->rowid; + $expensereportstatic->ref = $obj->ref; + $expensereportstatic->status = $obj->status; + $expensereportstatic->date_debut = $db->jdate($obj->date_debut); + $expensereportstatic->date_fin = $db->jdate($obj->date_fin); + $expensereportstatic->date_create = $db->jdate($obj->date_create); + $expensereportstatic->date_modif = $db->jdate($obj->date_modif); + $expensereportstatic->date_valid = $db->jdate($obj->date_valid); + $expensereportstatic->date_approve = $db->jdate($obj->date_approve); + $expensereportstatic->note_private = $obj->note_private; + $expensereportstatic->note_public = $obj->note_public; + $expensereportstatic->fk_user = $obj->id_user; + + $usertmp->id = $obj->id_user; + $usertmp->lastname = $obj->lastname; + $usertmp->firstname = $obj->firstname; + $usertmp->login = $obj->login; + $usertmp->statut = $obj->user_status; + $usertmp->status = $obj->user_status; + $usertmp->photo = $obj->photo; + $usertmp->email = $obj->email; + + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + // Show line of result + $j = 0; + print ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // User + if (!empty($arrayfields['user']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Start date + if (!empty($arrayfields['d.date_debut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // End date + if (!empty($arrayfields['d.date_fin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date validation + if (!empty($arrayfields['d.date_valid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date approval + if (!empty($arrayfields['d.date_approve']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['d.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht'; + } + $totalarray['val']['d.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['d.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva'; + } + $totalarray['val']['d.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['d.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc'; + } + $totalarray['val']['d.total_ttc'] += $obj->total_ttc; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['d.date_create']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['d.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['d.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + print ''."\n"; + } + + $total_total_ht = $total_total_ht + $obj->total_ht; + $total_total_tva = $total_total_tva + $obj->total_tva; + $total_total_ttc = $total_total_ttc + $obj->total_ttc; + + $i++; + } +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} + +$db->free($resql); + +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + print ' '; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_startend ? $search_date_startend : -1, 'search_date_startend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_endend ? $search_date_endend : -1, 'search_date_endend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + //print ''; + //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year); + print ''; + //print ''; + //print $formother->selectyear($year_end,'year_end',1, $min_year, $max_year); + print ''; + print ''; + print ''; + $formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1); + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print '
'; + } + // TODO Use a cache on user + $usertmp->fetch($obj->id_user); + + // Output Kanban + if ($massactionbutton || $massaction) { + $selected = 0; + + print $expensereportstatic->getKanbanView('', array('userauthor' => $usertmp, 'selected' => in_array($expensereportstatic->id, $arrayofselected))); + } + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + print ''; + print ''; + // Warning late icon and note + print ''; + print ''; + print '
'; + print $expensereportstatic->getNomUrl(1); + print ''; + if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) { + print img_warning($langs->trans("Late")); + } + if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) { + print img_warning($langs->trans("Late")); + } + if (!empty($obj->note_private) || !empty($obj->note_public)) { + print ' '; + print ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; + print ''; + } + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir); + print '
'; + print '
'; + print $usertmp->getNomUrl(-1); + print ''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; + print dol_print_date($db->jdate($obj->date_create), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_modif), 'dayhour'); + print ''.$expensereportstatic->getLibStatut(5).''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print ''."\n"; + +if (empty($id)) { + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $user->hasRight('expensereport', 'lire'); + $delallowed = $user->hasRight('expensereport', 'creer'); + + print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 976e3240088..878c32ba9cb 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -776,6 +776,7 @@ while ($i < $imaxinloop) { $totalarray['nbfield']++; } } + // Ref foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index e239d783eb3..bf85177ad4f 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -96,7 +96,7 @@ class Target extends CommonObject 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"), 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 4, 'noteditable' => 1, 'index' => 1, 'searchall' => 1, 'validate' => 1, 'comment' => "Reference of object"), 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'position' => 30, 'notnull' => 0, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'csslist'=>'tdoverflowmax150', 'showoncombobox' => 2, 'validate' => 1,), - 'trigger_codes' => array('type' => 'text', 'label' => 'TriggerCodes', 'enabled' => 1, 'position' => 50, 'notnull' => 1, 'visible' => 1, 'help' => "TriggerCodeInfo", 'tdcss'=>'titlefieldmiddle', 'css' => 'minwidth400', 'arrayofkeyval' => array('defined_in_constructor' => 'defined_from_c_action_trigger'), 'multiinput' => 1,), + 'trigger_codes' => array('type' => 'text', 'label' => 'TriggerCodes', 'enabled' => 1, 'position' => 50, 'notnull' => 1, 'visible' => 1, 'help' => "TriggerCodeInfo", 'tdcss'=>'titlefieldmiddle', 'csslist'=>'tdoverflowmax200', 'css' => 'minwidth400', 'arrayofkeyval' => array('defined_in_constructor' => 'defined_from_c_action_trigger'), 'multiinput' => 1,), 'url' => array('type' => 'varchar(255)', 'label' => 'Url', 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'visible' => 1,), 'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 3, 'validate' => 1,), 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1,),