diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php
index ee17976ca30..c7ebb5ed5af 100644
--- a/htdocs/accountancy/expensereport/list.php
+++ b/htdocs/accountancy/expensereport/list.php
@@ -114,11 +114,11 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
}
// Mass actions
-$objectclass='Skeleton';
-$objectlabel='Skeleton';
-$permtoread = $user->rights->accounting->read;
-$permtodelete = $user->rights->accounting->delete;
-$uploaddir = $conf->accounting->dir_output;
+$objectclass='ExpenseReport';
+$objectlabel='ExpenseReport';
+$permtoread = $user->rights->expensereport->read;
+$permtodelete = $user->rights->expensereport->delete;
+$uploaddir = $conf->expensereport->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') {
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index e0f1caafc81..41002eb9e71 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -96,8 +96,8 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield='p.ref';
if (! $sortorder) $sortorder='DESC';
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$contextpage='proposallist';
+// Initialize technical object to manage context to save list fields
+$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist';
// Security check
$module='propal';
@@ -413,6 +413,7 @@ if ($resql)
print '';
print '';
print '';
+ print '';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index ea1f93d22fb..927460c511a 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -83,6 +83,7 @@ $result = restrictedArea($user, 'commande', $id,'');
$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id;
+// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@@ -206,7 +207,8 @@ if (empty($reshook))
$permtoread = $user->rights->commande->lire;
$permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output;
- include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+ $trigger_name='ORDER_SENTBYMAIL';
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// TODO Move this into mass action include
if ($massaction == 'confirm_createbills') {
@@ -994,8 +996,6 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
- print '
';
-
$notshippable=0;
$warning = 0;
$text_info='';
@@ -1018,6 +1018,8 @@ if ($resql)
$generic_commande->total_tva = $obj->total_tva;
$generic_commande->total_ttc = $obj->total_ttc;
+ print '
';
+
// Ref
if (! empty($arrayfields['c.ref']['checked']))
{
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 9dd6b8adbe1..5a59b61e8a3 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -110,8 +110,8 @@ if (! $sortfield) $sortfield='f.datef';
$pageprev = $page - 1;
$pagenext = $page + 1;
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$contextpage='invoicelist';
+// Initialize technical object to manage context to save list fields
+$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist';
// Security check
$fieldid = (! empty($ref)?'facnumber':'rowid');
@@ -606,6 +606,7 @@ if ($resql)
print '';
print '';
print '';
+ print '';
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);
diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php
index e5a5c21c00b..9d1db86ded6 100644
--- a/htdocs/contrat/services.php
+++ b/htdocs/contrat/services.php
@@ -285,7 +285,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) &&
llxHeader(null, $langs->trans("Services"));
$param='';
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
+if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_contract) $param.='&search_contract='.urlencode($search_contract);
if ($search_name) $param.='&search_name='.urlencode($search_name);
@@ -326,6 +326,7 @@ print '';
print '';
print '';
print '';
+print '';
$title=$langs->trans("ListOfServices");
if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0"
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 4c3fe6af317..f2881544c54 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -73,6 +73,8 @@ if (! $error && $massaction == 'confirm_presend')
if (! $error)
{
$thirdparty=new Societe($db);
+ if ($objecttmp->element == 'expensereport') $thirdparty=new User($db);
+
$objecttmp=new $objectclass($db);
$listofobjectid=array();
$listofobjectthirdparties=array();
@@ -86,6 +88,7 @@ if (! $error && $massaction == 'confirm_presend')
$listofobjectid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id;
+ if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author;
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
}
@@ -203,8 +206,17 @@ if (! $error && $massaction == 'confirm_presend')
// Test recipient
if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send)
{
- $object->fetch_thirdparty();
- $sendto = $object->thirdparty->email;
+ if ($object->element == 'expensereport')
+ {
+ $fuser = new User($db);
+ $fuser->fetch($object->fk_user_author);
+ $sendto = $fuser->email;
+ }
+ else
+ {
+ $object->fetch_thirdparty();
+ $sendto = $object->thirdparty->email;
+ }
}
if (empty($sendto))
@@ -357,18 +369,32 @@ if (! $error && $massaction == 'confirm_presend')
$object->fk_element = $objid;
$object->elementtype = $object->element;
- // Appel des triggers
- include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
- $interface=new Interfaces($db);
- $result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf);
- if ($result < 0) { $error++; $errors=$interface->errors; }
- // Fin appel triggers
+ $triggername = strtoupper(get_class($object)) .'_SENTBYMAIL';
+ if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL';
+ if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL';
+ if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL';
+ if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYEMAIL';
+ if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL';
+ if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
+ if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL';
+ if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL';
- if ($error)
+ if (! empty($trigger_name))
{
- setEventMessages($db->lasterror(), $errors, 'errors');
- dol_syslog("Error in trigger BILL_SENTBYMAIL ".$db->lasterror(), LOG_ERR);
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+ $interface=new Interfaces($db);
+ $result=$interface->run_triggers($trigger_name, $object, $user, $langs, $conf);
+ if ($result < 0) { $error++; $errors=$interface->errors; }
+ // Fin appel triggers
+
+ if ($error)
+ {
+ setEventMessages($db->lasterror(), $errors, 'errors');
+ dol_syslog("Error in trigger ".$trigger_name.' '.$db->lasterror(), LOG_ERR);
+ }
}
+
$nbsent++;
}
}
diff --git a/htdocs/core/tpl/massactions_form.tpl.php b/htdocs/core/tpl/massactions_form.tpl.php
index 72eb62db9be..c428d144245 100644
--- a/htdocs/core/tpl/massactions_form.tpl.php
+++ b/htdocs/core/tpl/massactions_form.tpl.php
@@ -42,6 +42,8 @@ if (! GETPOST('cancel', 'alpha'))
$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
if ($objecttmp->element == 'societe')
$thirdpartyid = $objecttmp->id;
+ if ($objecttmp->element == 'expensereport')
+ $thirdpartyid = $objecttmp->fk_user_author;
$listofselectedthirdparties[$thirdpartyid] = $thirdpartyid;
$listofselectedref[$thirdpartyid][$toselectid] = $objecttmp->ref;
}
@@ -80,10 +82,19 @@ if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selec
{
$liste = array();
$thirdpartyid = array_shift($listofselectedthirdparties);
- $soc = new Societe($db);
- $soc->fetch($thirdpartyid);
- foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) {
- $liste[$key] = $value;
+ if ($objecttmp->element == 'expensereport')
+ {
+ $fuser = new User($db);
+ $fuser->fetch($thirdpartyid);
+ $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">";
+ }
+ else
+ {
+ $soc = new Societe($db);
+ $soc->fetch($thirdpartyid);
+ foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) {
+ $liste[$key] = $value;
+ }
}
$formmail->withtoreadonly = 0;
} else {
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index 01be3eb04cc..682ecf44839 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -36,14 +36,14 @@ $langs->load("companies");
$langs->load("users");
$langs->load("trips");
-$action=GETPOST('action','alpha');
+$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
// Security check
-$socid = $_GET["socid"]?$_GET["socid"]:'';
+$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'expensereport','','');
@@ -79,8 +79,8 @@ $optioncss = GETPOST('optioncss','alpha');
if ($search_status == '') $search_status=-1;
if ($search_user == '') $search_user=-1;
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$contextpage='expensereportlist';
+// Initialize technical object to manage context to save list fields
+$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'expensereportlist';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('expensereportlist'));
@@ -139,25 +139,31 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
-// Purge search criteria
-if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test must be present to be compatible with all browsers
-{
- $search_ref="";
- $search_user="";
- $search_amount_ht="";
- $search_amount_vat="";
- $search_amount_ttc="";
- $search_status="";
- $month_start="";
- $year_start="";
- $month_end="";
- $year_end="";
- $toselect='';
- $search_array_options=array();
-}
-
if (empty($reshook))
{
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test must be present to be compatible with all browsers
+ {
+ $search_ref="";
+ $search_user="";
+ $search_amount_ht="";
+ $search_amount_vat="";
+ $search_amount_ttc="";
+ $search_status="";
+ $month_start="";
+ $year_start="";
+ $month_end="";
+ $year_end="";
+ $toselect='';
+ $search_array_options=array();
+ }
+ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
+ || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
+ {
+ $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
+ }
+
+ // Mass actions
$objectclass='ExpenseReport';
$objectlabel='ExpenseReport';
$permtoread = $user->rights->expensereport->lire;
@@ -167,7 +173,6 @@ if (empty($reshook))
}
-
/*
* View
*/
@@ -176,7 +181,8 @@ $form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
-llxHeader('', $langs->trans("ListOfTrips"));
+$title = $langs->trans("ListOfTrips");
+llxHeader('', $title);
$max_year = 5;
$min_year = 5;
@@ -184,7 +190,7 @@ $min_year = 5;
$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.statut, u.photo";
+$sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@@ -267,6 +273,7 @@ $sql.=$hookmanager->resPrint;
$sql.= $db->order($sortfield,$sortorder);
+// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
@@ -276,14 +283,14 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql.= $db->plimit($limit+1, $offset);
//print $sql;
-$resql=$db->query($sql);
+$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
- $param="";
+ $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.="&sall=".$sall;
@@ -303,20 +310,22 @@ if ($resql)
// List of mass actions available
$arrayofmassactions = array(
- //'presend'=>$langs->trans("SendByMail"),
+ 'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->expensereport->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
- print '