NEW Send by email available in bulk for expense report
This commit is contained in:
parent
b4eab24490
commit
e014ac6ea9
@ -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') {
|
||||
|
||||
@ -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 '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
|
||||
|
||||
|
||||
@ -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 '<tr class="oddeven">';
|
||||
|
||||
$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 '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
if (! empty($arrayfields['c.ref']['checked']))
|
||||
{
|
||||
|
||||
@ -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 '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
|
||||
@ -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 '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
$title=$langs->trans("ListOfServices");
|
||||
if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0"
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
// Lines of title fields
|
||||
print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
$title = $langs->trans("ListTripsAndExpenses");
|
||||
@ -324,9 +333,9 @@ if ($resql)
|
||||
|
||||
if ($massaction == 'presend')
|
||||
{
|
||||
$topicmail="SendInterventionRef";
|
||||
$modelmail="fichinter_send";
|
||||
$objecttmp=new Intervention($db);
|
||||
$topicmail="SendExpenseReport";
|
||||
$modelmail="expensereport";
|
||||
$objecttmp=new ExpenseReport($db);
|
||||
$trackid='int'.$object->id;
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
|
||||
@ -580,6 +589,7 @@ if ($resql)
|
||||
$usertmp->login=$obj->login;
|
||||
$usertmp->statut=$obj->statut;
|
||||
$usertmp->photo=$obj->photo;
|
||||
$usertmp->email=$obj->email;
|
||||
print $usertmp->getNomUrl(-1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
@ -119,8 +119,8 @@ $pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="f.datef,f.rowid";
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$contextpage='supplierinvoicelist';
|
||||
// Initialize technical object to manage context to save list fields
|
||||
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierinvoicelist';
|
||||
|
||||
$diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user