diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 1d0a5ad7e9f..751bfb6ff6c 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -201,7 +201,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS
$search_state="";
$search_type='';
$search_country='';
- $search_type_thirdparty='';
+ $search_type_thirdparty='';
$day='';
$year='';
$month='';
@@ -228,7 +228,7 @@ if (empty($reshook))
setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
$error++;
}
-
+
if (! $error && $massaction == 'confirm_presend' && GETPOST('modelselected')) // If we change the template, we must not send email, but keep on send email form
{
$massaction='presend';
@@ -240,7 +240,7 @@ if (empty($reshook))
$nbignored = 0;
$langs->load("mails");
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
+
if (!$error && !isset($user->email))
{
$error++;
@@ -258,7 +258,7 @@ if (empty($reshook))
{
$objecttmp=new Facture($db); // must create new instance because instance is saved into $listofobjectref array for future use
$result=$objecttmp->fetch($toselectid);
- if ($result > 0)
+ if ($result > 0)
{
$listoinvoicesid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
@@ -267,16 +267,16 @@ if (empty($reshook))
}
}
//var_dump($listofobjectthirdparties);exit;
-
+
foreach ($listofobjectthirdparties as $thirdpartyid)
{
$result = $thirdparty->fetch($thirdpartyid);
- if ($result < 0)
+ if ($result < 0)
{
dol_print_error($db);
exit;
}
-
+
// Define recipient $sendto and $sendtocc
if (trim($_POST['sendto']))
{
@@ -314,9 +314,9 @@ if (empty($reshook))
$sendtocc = $thirdparty->contact_get_property((int) $_POST['receivercc'],'email');
}
}
-
+
//var_dump($listofobjectref[$thirdpartyid]); // Array of invoice for this thirdparty
-
+
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
$listofqualifiedinvoice=array();
$listofqualifiedref=array();
@@ -324,14 +324,14 @@ if (empty($reshook))
{
//var_dump($object);
//var_dump($thirdpartyid.' - '.$objectid.' - '.$object->statut);
-
+
if ($object->statut != Facture::STATUS_VALIDATED)
{
$nbignored++;
$resaction.='
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'
';
continue; // Payment done or started or canceled
}
-
+
// Read document
// TODO Use future field $object->fullpathdoc to know where is stored default file
// TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
@@ -347,39 +347,39 @@ if (empty($reshook))
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
}
-
- if (empty($sendto))
+
+ if (empty($sendto))
{
//print "No recipient for thirdparty ".$object->thirdparty->name;
$nbignored++;
continue;
}
-
+
if (dol_strlen($sendto))
{
// Create form object
$attachedfiles=array(
- 'paths'=>array_merge($attachedfiles['paths'],array($file)),
- 'names'=>array_merge($attachedfiles['names'],array($filename)),
+ 'paths'=>array_merge($attachedfiles['paths'],array($file)),
+ 'names'=>array_merge($attachedfiles['names'],array($filename)),
'mimes'=>array_merge($attachedfiles['mimes'],array($mime))
);
}
-
+
$listofqualifiedinvoice[$objectid]=$object;
$listofqualifiedref[$objectid]=$object->ref;
}
else
- {
+ {
$nbignored++;
$langs->load("errors");
$resaction.=''.$langs->trans('ErrorCantReadFile',$file).'
';
dol_syslog('Failed to read file: '.$file, LOG_WARNING);
continue;
}
-
+
//var_dump($listofqualifiedref);
}
-
+
if (count($listofqualifiedinvoice) > 0)
{
$langs->load("commercial");
@@ -389,7 +389,7 @@ if (empty($reshook))
$message = GETPOST('message');
$sendtocc = GETPOST('sentocc');
$sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO);
-
+
$substitutionarray=array(
'__ID__' => join(', ',array_keys($listofqualifiedinvoice)),
'__EMAIL__' => $thirdparty->email,
@@ -400,16 +400,16 @@ if (empty($reshook))
'__REF__' => join(', ',$listofqualifiedref),
'__REFCLIENT__' => $thirdparty->name
);
-
+
$subject=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray);
-
+
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
-
+
//var_dump($filepath);
-
+
// Send mail
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1);
@@ -423,9 +423,9 @@ if (empty($reshook))
if ($result)
{
$resaction.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)).'
'; // Must not contain "
-
+
$error=0;
-
+
// Insert logs into agenda
foreach($listofqualifiedinvoice as $invid => $object)
{
@@ -438,7 +438,7 @@ if (empty($reshook))
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
-
+
// Initialisation donnees
$object->sendtoid = 0;
$object->actiontypecode = $actiontypecode;
@@ -446,14 +446,14 @@ if (empty($reshook))
$object->actionmsg2 = $actionmsg2; // Short text
$object->fk_element = $invid;
$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
-
+
if ($error)
{
setEventMessages($db->lasterror(), $errors, 'errors');
@@ -484,7 +484,7 @@ if (empty($reshook))
$resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n
";
$resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n
";
$resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n
";
-
+
if ($nbsent)
{
$action=''; // Do not show form post if there was at least one successfull sent
@@ -497,7 +497,7 @@ if (empty($reshook))
setEventMessages($resaction, null, 'warnings');
}
}
-
+
$action='list';
$massaction='';
}
@@ -507,7 +507,7 @@ if (empty($reshook))
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-
+
$objecttmp=new Facture($db);
$listofobjectid=array();
$listofobjectthirdparties=array();
@@ -542,7 +542,7 @@ if (empty($reshook))
}
}
}
-
+
// Define output language (Here it is not used because we do only merging existing PDF)
$outputlangs = $langs;
$newlang='';
@@ -607,12 +607,12 @@ if (empty($reshook))
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
}
}
-
+
// Remove file
if ($action == 'remove_file')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
+
$langs->load("other");
$upload_dir = $diroutputmassaction;
$file = $upload_dir . '/' . GETPOST('file');
@@ -621,10 +621,10 @@ if (empty($reshook))
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
$action='';
}
-
+
}
-
+
/*
* View
@@ -650,7 +650,7 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name";
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
-if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
+if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
// 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
@@ -795,7 +795,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$nbtotalofrecords = $db->num_rows($result);
}
-$sql.= $db->plimit($limit,$offset);
+$sql.= $db->plimit($limit + 1,$offset);
//print $sql;
$resql = $db->query($sql);
@@ -804,7 +804,7 @@ if ($resql)
$num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
-
+
if ($socid)
{
$soc = new Societe($db);
@@ -842,11 +842,12 @@ if ($resql)
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
-
+
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
-
+
$i = 0;
print '\n";
-
+
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
/*
@@ -1492,15 +1493,15 @@ if ($resql)
*/
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&','&',$param);
-
+
$filedir=$diroutputmassaction;
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
-
+
print '
';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')';
-
+
print $formfile->showdocuments('massfilesarea_facture','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index 016984c5382..b4c2c71959b 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -3,7 +3,7 @@
* Copyright (C) 2012-2015 Laurent Destailleur
* Copyright (C) 2012-2016 Regis Houssin
* Copyright (C) 2013 Juanjo Menent
- * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2014-2017 Ferran Marcet
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,7 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
$myparam = GETPOST("myparam");
$action=GETPOST('action', 'alpha');
$id=GETPOST('id', 'int');
-$userid = GETPOST('userid')?GETPOST('userid'):$user->id;
// Protection if external user
if ($user->societe_id > 0) accessforbidden();
@@ -57,7 +56,8 @@ if ($action == 'create')
$cp = new Holiday($db);
// If no right to create a request
- if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all)))
+ $fuserid = GETPOST('fuserid');
+ if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all)))
{
$error++;
setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
@@ -82,7 +82,6 @@ if ($action == 'create')
$valideur = GETPOST('valideur');
$description = trim(GETPOST('description'));
- $userID = GETPOST('userID');
// If no type
if ($type <= 0)
@@ -115,7 +114,7 @@ if ($action == 'create')
}
// Check if there is already holiday for this period
- $verifCP = $cp->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday);
+ $verifCP = $cp->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
if (! $verifCP)
{
setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
@@ -145,7 +144,7 @@ if ($action == 'create')
if (! $error)
{
- $cp->fk_user = $userid;
+ $cp->fk_user = $fuserid;
$cp->description = $description;
$cp->date_debut = $date_debut;
$cp->date_fin = $date_fin;
@@ -689,7 +688,7 @@ llxHeader('', $langs->trans('CPTitreMenu'));
if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create')
{
// Si l'utilisateur n'a pas le droit de faire une demande
- if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all)))
+ if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all)))
{
$errors[]=$langs->trans('CantCreateCP');
}
@@ -769,7 +768,6 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
// Formulaire de demande
print '