*
* This program is free software; you can redistribute it and/or modify
@@ -43,6 +43,7 @@ class ActionComm extends CommonObject
var $type;
var $label;
+ var $date;
var $datec; // Date creation record (datec)
var $datem; // Date modification record (tms)
var $author; // Object user that create action
diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php
index 596e18b9032..b95cc35a04f 100644
--- a/htdocs/comm/mailing/fiche.php
+++ b/htdocs/comm/mailing/fiche.php
@@ -495,7 +495,7 @@ if (! empty($_POST['addfile']))
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
// Set tmp user directory
- $mesg=dol_add_file_process($upload_dir,0,0);
+ dol_add_file_process($upload_dir,0,0);
$action="edit";
}
@@ -507,7 +507,7 @@ if (! empty($_POST["removedfile"]))
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
- $mesg=dol_remove_file_process($_POST['removedfile'],0);
+ dol_remove_file_process($_POST['removedfile'],0);
$action="edit";
}
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 1d1262b339b..8b024de3442 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -62,8 +62,6 @@ $search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha');
$sall=GETPOST("sall");
-$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
-$mesgs=array();
$year=GETPOST("year");
$month=GETPOST("month");
@@ -98,6 +96,7 @@ $object = new Propal($db);
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
+ $object->fetch_thirdparty();
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
@@ -119,11 +118,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
{
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{
- $mesg=''.$langs->trans("NoCloneOptionsSpecified").'
';
+ setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
}
else
{
- if ($object->fetch($id) > 0)
+ if ($object->id > 0)
{
$result=$object->createFromClone($socid, $hookmanager);
if ($result > 0)
@@ -133,7 +132,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
}
else
{
- $mesg=$object->error;
+ setEventMessage($object->error, 'errors');
$action='';
}
}
@@ -143,8 +142,6 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
// Suppression de la propale
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propale->supprimer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
$result=$object->delete($user);
if ($result > 0)
{
@@ -154,16 +151,13 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop
else
{
$langs->load("errors");
- if ($object->error == 'ErrorFailToDeleteDir') $mesg=''.$langs->trans('ErrorFailedToDeleteJoinedFiles').'
';
- else $mesg=''.$object->error.'
';
+ setEventMessage($langs->trans($object->error), 'errors');
}
}
// Remove line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
$result = $object->deleteline($lineid);
// reorder lines
if ($result) $object->line_order(true);
@@ -171,7 +165,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
// Define output language
$outputlangs = $langs;
$newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
@@ -191,16 +185,13 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
// Validation
else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
-
$result=$object->valid($user);
if ($result >= 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
@@ -209,13 +200,14 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $ret=$object->fetch($id); // Reload to get new records
+ $ret=$object->fetch($object->id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
}
}
else
{
- $mesg=''.$object->error.'
';
+ $langs->load("errors");
+ setEventMessage($langs->trans($object->error), 'errors');
}
}
@@ -226,25 +218,22 @@ else if ($action == 'setdate' && $user->rights->propale->creer)
if (empty($datep))
{
$error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'
';
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
}
if (! $error)
{
- $object->fetch($id);
$result=$object->set_date($user,$datep);
if ($result < 0) dol_print_error($db,$object->error);
}
}
else if ($action == 'setecheance' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setdate_livraison' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']));
if ($result < 0) dol_print_error($db,$object->error);
}
@@ -252,20 +241,17 @@ else if ($action == 'setdate_livraison' && $user->rights->propale->creer)
// Positionne ref client
else if ($action == 'set_ref_client' && $user->rights->propale->creer)
{
- $object->fetch($id);
$object->set_ref_client($user, $_POST['ref_client']);
}
else if ($action == 'setnote_public' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
@@ -291,7 +277,7 @@ else if ($action == 'add' && $user->rights->propale->creer)
$db->begin();
// Si on a selectionne une propal a copier, on realise la copie
- if(GETPOST('createmode')=='copy' && GETPOST('copie_propal'))
+ if (GETPOST('createmode')=='copy' && GETPOST('copie_propal'))
{
if ($object->fetch(GETPOST('copie_propal')) > 0)
{
@@ -318,7 +304,7 @@ else if ($action == 'add' && $user->rights->propale->creer)
}
else
{
- $mesg = ''.$langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')).'
';
+ setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors');
}
}
else
@@ -359,21 +345,14 @@ else if ($action == 'add' && $user->rights->propale->creer)
if ($id > 0)
{
- $error=0;
-
// Insertion contact par defaut si defini
if (GETPOST('contactidp'))
{
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
-
- if ($result > 0)
+ if ($result < 0)
{
- $error=0;
- }
- else
- {
- $mesg = ''.$langs->trans("ErrorFailedToAddContact").'
';
- $error=1;
+ $error++;
+ setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
}
}
@@ -413,44 +392,35 @@ else if ($action == 'add' && $user->rights->propale->creer)
// Classify billed
else if ($action == 'classifybilled' && $user->rights->propale->cloturer)
{
- $object->fetch($id);
$object->cloture($user, 4, '');
}
// Reopen proposal
-else if ($action == 'confirm_reopen' && $user->rights->propale->cloturer)
+else if ($action == 'confirm_reopen' && $user->rights->propale->cloturer && ! GETPOST('cancel'))
{
- if (! $_POST['cancel'])
+ // prevent browser refresh from reopening proposal several times
+ if ($object->statut==2 || $object->statut==3)
{
- $object->fetch($id);
- // prevent browser refresh from reopening proposal several times
- if ($object->statut==2 || $object->statut==3)
- {
- $object->setStatut(1);
- }
+ $object->setStatut(1);
}
}
// Close proposal
-else if ($action == 'setstatut' && $user->rights->propale->cloturer)
+else if ($action == 'setstatut' && $user->rights->propale->cloturer && ! GETPOST('cancel'))
{
- if (! $_POST['cancel'])
- {
- if (! GETPOST('statut'))
- {
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'
';
- $action='statut';
- }
- else
- {
- $object->fetch($id);
- // prevent browser refresh from closing proposal several times
- if ($object->statut==1)
- {
- $object->cloture($user, $_REQUEST['statut'], $_REQUEST['note']);
- }
- }
- }
+ if (! GETPOST('statut'))
+ {
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")), 'errors');
+ $action='statut';
+ }
+ else
+ {
+ // prevent browser refresh from closing proposal several times
+ if ($object->statut==1)
+ {
+ $object->cloture($user, GETPOST('statut'), GETPOST('note'));
+ }
+ }
}
/*
@@ -464,16 +434,14 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesg=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action='presend';
- $_POST["action"]='presend';
}
/*
* Remove file in email form
*/
-if (! empty($_POST['removedfile']))
+if (GETPOST('removedfile'))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@@ -482,171 +450,148 @@ if (! empty($_POST['removedfile']))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesg=dol_remove_file_process($_POST['removedfile'],0);
-
+ dol_remove_file_process($_POST['removedfile'],0);
$action='presend';
- $_POST["action"]='presend';
}
/*
* Send mail
*/
-if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
+if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel'))
{
$langs->load('mails');
- $result=$object->fetch($_POST["id"]);
- $result=$object->fetch_thirdparty();
-
- if ($result > 0)
+ if ($object->id > 0)
{
-// $objectref = dol_sanitizeFileName($object->ref);
-// $file = $conf->propal->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
-
-// if (is_readable($file))
-// {
- if ($_POST['sendto'])
+ if ($_POST['sendto'])
+ {
+ // Le destinataire a ete fourni via le champ libre
+ $sendto = $_POST['sendto'];
+ $sendtoid = 0;
+ }
+ elseif ($_POST['receiver'] != '-1')
+ {
+ // Recipient was provided from combo list
+ if ($_POST['receiver'] == 'thirdparty') // Id of third party
{
- // Le destinataire a ete fourni via le champ libre
- $sendto = $_POST['sendto'];
+ $sendto = $object->client->email;
$sendtoid = 0;
}
- elseif ($_POST['receiver'] != '-1')
+ else // Id du contact
{
- // Recipient was provided from combo list
- if ($_POST['receiver'] == 'thirdparty') // Id of third party
- {
- $sendto = $object->client->email;
- $sendtoid = 0;
- }
- else // Id du contact
- {
- $sendto = $object->client->contact_get_property($_POST['receiver'],'email');
- $sendtoid = $_POST['receiver'];
- }
+ $sendto = $object->client->contact_get_property($_POST['receiver'],'email');
+ $sendtoid = $_POST['receiver'];
}
+ }
- if (dol_strlen($sendto))
+ if (dol_strlen($sendto))
+ {
+ $langs->load("commercial");
+
+ $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
+ $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
+ $message = $_POST['message'];
+ $sendtocc = $_POST['sendtocc'];
+ $deliveryreceipt = $_POST['deliveryreceipt'];
+
+ if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
+ else $subject = $langs->transnoentities('Propal').' '.$object->ref;
+ $actiontypecode='AC_PROP';
+ $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
+ if ($message)
{
- $langs->load("commercial");
+ $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
+ $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
+ $actionmsg.=$message;
+ }
+ $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
- $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
- $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
- $message = $_POST['message'];
- $sendtocc = $_POST['sendtocc'];
- $deliveryreceipt = $_POST['deliveryreceipt'];
+ // Create form object
+ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
+ $formmail = new FormMail($db);
- if ($_POST['action'] == 'send')
- {
- if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
- else $subject = $langs->transnoentities('Propal').' '.$object->ref;
- $actiontypecode='AC_PROP';
- $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
- if ($message)
- {
- $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
- $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
- $actionmsg.=$message;
- }
- $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
- }
+ $attachedfiles=$formmail->get_attached_files();
+ $filepath = $attachedfiles['paths'];
+ $filename = $attachedfiles['names'];
+ $mimetype = $attachedfiles['mimes'];
- // Create form object
- include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
- $formmail = new FormMail($db);
-
- $attachedfiles=$formmail->get_attached_files();
- $filepath = $attachedfiles['paths'];
- $filename = $attachedfiles['names'];
- $mimetype = $attachedfiles['mimes'];
-
- // Envoi de la propal
- require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
- $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
- if ($mailfile->error)
- {
- $mesg=''.$mailfile->error.'
';
- }
- else
- {
- $result=$mailfile->sendfile();
- if ($result)
- {
- $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
-
- $error=0;
-
- // Initialisation donnees
- $object->sendtoid = $sendtoid;
- $object->actiontypecode = $actiontypecode;
- $object->actionmsg = $actionmsg;
- $object->actionmsg2 = $actionmsg2;
- $object->fk_element = $object->id;
- $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('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf);
- if ($result < 0) { $error++; $this->errors=$interface->errors; }
- // Fin appel triggers
-
- if ($error)
- {
- dol_print_error($db);
- }
- else
- {
- // Redirect here
- // This avoid sending mail twice if going out and then back to page
- Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg));
- exit;
- }
- }
- else
- {
- $langs->load("other");
- $mesg='';
- if ($mailfile->error)
- {
- $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
- $mesg.='
'.$mailfile->error;
- }
- else
- {
- $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
- }
- $mesg.='
';
- }
- }
+ // Envoi de la propal
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
+ $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
+ if ($mailfile->error)
+ {
+ setEventMessage($mailfile->error, 'errors');
}
else
{
- $langs->load("other");
- $mesg=''.$langs->trans('ErrorMailRecipientIsEmpty').' !
';
- dol_syslog('Recipient email is empty');
+ $result=$mailfile->sendfile();
+ if ($result)
+ {
+ // Initialisation donnees
+ $object->sendtoid = $sendtoid;
+ $object->actiontypecode = $actiontypecode;
+ $object->actionmsg = $actionmsg;
+ $object->actionmsg2 = $actionmsg2;
+ $object->fk_element = $object->id;
+ $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('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
+ // Fin appel triggers
+
+ if (! $error)
+ {
+ // Redirect here
+ // This avoid sending mail twice if going out and then back to page
+ $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
+ setEventMessage($mesg);
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+ exit;
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ if ($mailfile->error)
+ {
+ $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
+ $mesg.='
'.$mailfile->error;
+ }
+ else
+ {
+ $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
+ }
+ setEventMessage($mesg, 'errors');
+ }
}
-/* }
+ }
else
{
- $langs->load("errors");
- $mesg=''.$langs->trans('ErrorCantReadFile',$file).'
';
- dol_syslog('Failed to read file: '.$file);
- }*/
+ $langs->load("other");
+ setEventMessage($langs->trans('ErrorMailRecipientIsEmpty').'!', 'errors');
+ dol_syslog($langs->trans('ErrorMailRecipientIsEmpty'));
+ }
}
else
{
$langs->load("other");
- $mesg=''.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")).'
';
- dol_syslog('Impossible de lire les donnees de la facture. Le fichier propal n\'a peut-etre pas ete genere.');
+ setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")), 'errors');
+ dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")));
}
}
// Go back to draft
if ($action == 'modif' && $user->rights->propale->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
$object->set_draft($user);
// Define output language
@@ -667,49 +612,33 @@ else if ($action == "setabsolutediscount" && $user->rights->propale->creer)
{
if ($_POST["remise_id"])
{
- $object->id=$id;
- $ret=$object->fetch($id);
- if ($ret > 0)
+ if ($object->id > 0)
{
$result=$object->insert_discount($_POST["remise_id"]);
if ($result < 0)
{
- $mesg=''.$object->error.'
';
+ setEventMessage($object->error, 'errors');
}
}
- else
- {
- dol_print_error($db,$object->error);
- }
}
}
//Ajout d'une ligne produit dans la propale
else if ($action == "addline" && $user->rights->propale->creer)
{
- $result=0;
-
if (empty($_POST['idprod']) && GETPOST('type') < 0)
{
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors');
+ $error++;
}
if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not ''
{
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
+ $error++;
}
- if ($result >= 0 && isset($_POST['qty']) && ((GETPOST('np_price')!='' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod')))
+ if (! $error && isset($_POST['qty']) && ((GETPOST('np_price')!='' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod')))
{
- $ret=$object->fetch($id);
- if ($ret < 0)
- {
- dol_print_error($db,$object->error);
- exit;
- }
- $ret=$object->fetch_thirdparty();
-
$pu_ht=0;
$pu_ttc=0;
$price_min=0;
@@ -729,7 +658,7 @@ else if ($action == "addline" && $user->rights->propale->creer)
$tva_npr = get_default_npr($mysoc,$object->client,$prod->id);
// On defini prix unitaire
- if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level)
+ if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level)
{
$pu_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
@@ -798,7 +727,8 @@ else if ($action == "addline" && $user->rights->propale->creer)
if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- $mesg = ''.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ;
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency));
+ setEventMessage($mesg, 'errors');
}
else
{
@@ -852,7 +782,7 @@ else if ($action == "addline" && $user->rights->propale->creer)
}
else
{
- $mesg=''.$object->error.'
';
+ setEventMessage($object->error, 'errors');
}
}
}
@@ -861,13 +791,6 @@ else if ($action == "addline" && $user->rights->propale->creer)
// Mise a jour d'une ligne dans la propale
else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('save') == $langs->trans("Save"))
{
- if (! $object->fetch($_POST["id"]) > 0)
- {
- dol_print_error($db,$object->error);
- exit;
- }
- $object->fetch_thirdparty();
-
// Define info_bits
$info_bits=0;
if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01;
@@ -877,18 +800,11 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
$vat_rate=str_replace('*','',$vat_rate);
$localtax1_rate=get_localtax($vat_rate,1,$object->client);
$localtax2_rate=get_localtax($vat_rate,2,$object->client);
- $pu_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice');
+ $pu_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice');
- // ajout prix d'achat
- $fk_fournprice = $_POST['fournprice'];
- if ( ! empty($_POST['buying_price']) )
- $pa_ht = $_POST['buying_price'];
- else
- $pa_ht = null;
-
- // Define special_code for special lines
- $special_code=0;
- if (empty($_POST['qty'])) $special_code=3;
+ // Define special_code for special lines
+ $special_code=0;
+ if (empty($_POST['qty'])) $special_code=3;
// On verifie que le prix minimum est respecte
$productid = $_POST['productid'] ;
@@ -901,7 +817,8 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
}
if ($productid && $price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
{
- $mesg = ''.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ;
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency));
+ setEventMessage($mesg, 'errors');
}
else
{
@@ -919,8 +836,8 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
$special_code,
$_POST['fk_parent_line'],
0,
- $fk_fournprice,
- $pa_ht
+ GETPOST('fournprice'),
+ GETPOST('buying_price')
);
// Define output language
@@ -935,15 +852,15 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $ret=$object->fetch($id); // Reload to get new records
- propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
+ $ret=$object->fetch($id); // Reload to get new records
+ propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
- unset($_POST['qty']);
- unset($_POST['type']);
- unset($_POST['np_price']);
- unset($_POST['dp_desc']);
- unset($_POST['np_tva_tx']);
- unset($_POST['np_buying_price']);
+ unset($_POST['qty']);
+ unset($_POST['type']);
+ unset($_POST['np_price']);
+ unset($_POST['dp_desc']);
+ unset($_POST['np_tva_tx']);
+ unset($_POST['np_buying_price']);
}
}
}
@@ -951,12 +868,9 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
// Generation doc (depuis lien ou depuis cartouche doc)
else if ($action == 'builddoc' && $user->rights->propale->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
-
- if ($_REQUEST['model'])
+ if (GETPOST('model'))
{
- $object->setDocModel($user, $_REQUEST['model']);
+ $object->setDocModel($user, GETPOST('model'));
}
// Define output language
@@ -983,66 +897,56 @@ else if ($action == 'builddoc' && $user->rights->propale->creer)
}
// Remove file in doc form
-else if ($action == 'remove_file')
+else if ($action == 'remove_file' && $user->rights->propale->creer)
{
- if ($object->fetch($id))
+ if ($object->id > 0)
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
- $object->fetch_thirdparty();
-
$langs->load("other");
$upload_dir = $conf->propal->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
// Set project
else if ($action == 'classin' && $user->rights->propale->creer)
{
- $object->fetch($id);
$object->setProject($_POST['projectid']);
}
// Delai de livraison
else if ($action == 'setavailability' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->availability($_POST['availability_id']);
}
// Origine de la propale
else if ($action == 'setdemandreason' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->demand_reason($_POST['demand_reason_id']);
}
// Conditions de reglement
else if ($action == 'setconditions' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
}
else if ($action == 'setremisepercent' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->set_remise_percent($user, $_POST['remise_percent']);
}
else if ($action == 'setremiseabsolue' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']);
}
// Mode de reglement
else if ($action == 'setmode' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
}
@@ -1052,14 +956,12 @@ else if ($action == 'setmode' && $user->rights->propale->creer)
else if ($action == 'up' && $user->rights->propale->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
$object->line_up(GETPOST('rowid'));
// Define output language
$outputlangs = $langs;
$newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
@@ -1074,14 +976,12 @@ else if ($action == 'up' && $user->rights->propale->creer)
else if ($action == 'down' && $user->rights->propale->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
$object->line_down(GETPOST('rowid'));
// Define output language
$outputlangs = $langs;
$newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
@@ -1094,16 +994,14 @@ else if ($action == 'down' && $user->rights->propale->creer)
exit;
}
-if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propale->creer)
{
- if ($action == 'addcontact' && $user->rights->propale->creer)
+ if ($action == 'addcontact')
{
- $result = $object->fetch($id);
-
- if ($result > 0 && $id > 0)
+ if ($object->id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
- $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
+ $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
@@ -1116,17 +1014,17 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
- $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
+ setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
}
else
{
- $mesg = ''.$object->error.'
';
+ setEventMessage($object->error, 'errors');
}
}
}
// Bascule du statut d'un contact
- else if ($action == 'swapstatut' && $user->rights->propale->creer)
+ else if ($action == 'swapstatut')
{
if ($object->fetch($id) > 0)
{
@@ -1139,7 +1037,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
}
// Efface un contact
- else if ($action == 'deletecontact' && $user->rights->propale->creer)
+ else if ($action == 'deletecontact')
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
@@ -1175,8 +1073,6 @@ $now=dol_now();
* Show object in view mode
*/
-dol_htmloutput_mesg($mesg,$mesgs);
-
$soc = new Societe($db);
$soc->fetch($object->socid);
@@ -1863,7 +1759,7 @@ if ($action == 'presend')
$formmail->withtosocid=$soc->id;
$formmail->withtocc=1;
$formmail->withtoccsocid=0;
- $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
+ $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false);
$formmail->withtocccsocid=0;
$formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__');
$formmail->withfile=2;
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 5c588bd482b..7e85625ac36 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1845,7 +1845,6 @@ class Propal extends CommonObject
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
- $this->error='ErrorFailToDeleteFile';
$this->db->rollback();
return 0;
}
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 406453a432b..c07282596ba 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -125,7 +125,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index ec114d17414..057f4b04794 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -2344,7 +2344,6 @@ class Commande extends CommonOrder
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback();
return 0;
}
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index 39f83d3f6b9..a4014a6fa17 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -122,7 +122,6 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 43a284f4e20..3470eeeee1d 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1005,7 +1005,6 @@ else if ($action == 'remove_file')
$upload_dir = $conf->commande->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
@@ -1020,8 +1019,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesg=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action ='presend';
}
@@ -1037,8 +1035,7 @@ if (GETPOST('removedfile'))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesg=dol_remove_file_process(GETPOST('removedfile'),0);
-
+ dol_remove_file_process(GETPOST('removedfile'),0);
$action ='presend';
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 18327d85e4b..12d26ccf9bd 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1323,8 +1323,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesgs[]=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action='presend';
}
@@ -1340,8 +1339,7 @@ if (! empty($_POST['removedfile']))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesgs[]=dol_remove_file_process($_POST['removedfile'],0);
-
+ dol_remove_file_process($_POST['removedfile'],0);
$action='presend';
}
@@ -1566,7 +1564,6 @@ else if ($action == 'remove_file')
$upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
- $mesgs[] = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5cd0857f923..f3905deba6e 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1263,7 +1263,6 @@ class Facture extends CommonInvoice
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback();
return 0;
}
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 358fd3477bc..35397aea1f7 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -125,7 +125,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php
index 4d89e43d459..8050f3ba77e 100644
--- a/htdocs/compta/sociales/document.php
+++ b/htdocs/compta/sociales/document.php
@@ -129,7 +129,6 @@ if ($object->id)
{
$file = $upload_dir . '/' . GETPOST("urlfile"); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file);
- //if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
}
$head=tax_prepare_head($object, $user);
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index fdcf3e77922..f58f4d879f1 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -122,7 +122,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index d1eabadedac..b3ceab6376a 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -671,6 +671,9 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
{
global $db, $conf, $user, $langs;
+ $langs->load("other");
+ $langs->load("errors");
+
$error=0;
//print "x".$file." ".$disableglob;
@@ -684,7 +687,8 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
else $ok=unlink($filename); // The unlink encapsulated by dolibarr
if ($ok)
{
- dol_syslog("Removed file ".$filename,LOG_DEBUG);
+ dol_syslog("Removed file ".$filename, LOG_DEBUG);
+ setEventMessage($langs->trans("FileWasRemoved", basename($filename)));
if (! $notrigger)
{
if (! is_object($object)) $object=(object) 'dummy';
@@ -699,15 +703,24 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
// Fin appel triggers
}
}
- else dol_syslog("Failed to remove file ".$filename,LOG_WARNING);
+ else {
+ dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
+ setEventMessage($langs->trans("ErrorFailToDeleteFile", basename($filename)), 'errors');
+ }
}
}
else
{
if ($nophperrors) $ok=@unlink($file_osencoded); // The unlink encapsulated by dolibarr
else $ok=unlink($file_osencoded); // The unlink encapsulated by dolibarr
- if ($ok) dol_syslog("Removed file ".$file_osencoded,LOG_DEBUG);
- else dol_syslog("Failed to remove file ".$file_osencoded,LOG_WARNING);
+ if ($ok) {
+ dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
+ setEventMessage($langs->trans("FileWasRemoved", basename($file_osencoded)));
+ }
+ else {
+ dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
+ setEventMessage($langs->trans("ErrorFailToDeleteFile", basename($file_osencoded)), 'errors');
+ }
}
return $ok;
}
@@ -917,14 +930,12 @@ function dol_init_file_process($pathtoscan='')
* @param string $upload_dir Directory to store upload files
* @param int $allowoverwrite 1=Allow overwrite existing file
* @param int $donotupdatesession 1=Do no edit _SESSION variable
- * @return string Message with result of upload and store.
+ * @return void
*/
function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=0)
{
global $db,$user,$conf,$langs,$_FILES;
- $mesg='';
-
if (! empty($_FILES['addedfile']['tmp_name']))
{
if (dol_mkdir($upload_dir) >= 0)
@@ -932,7 +943,7 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
$resupload = dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],$allowoverwrite,0, $_FILES['addedfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
- $mesg = ''.$langs->trans("FileTransferComplete").'
';
+ setEventMessage($langs->trans("FileTransferComplete"));
if (empty($donotupdatesession))
{
@@ -946,15 +957,15 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
- $mesg = ''.$langs->trans("ErrorFileNotUploaded").'
';
+ setEventMessage($langs->trans("ErrorFileNotUploaded"), 'errors');
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
- $mesg = ''.$langs->trans("ErrorFileIsInfectedWithAVirus").'
';
+ setEventMessage($langs->trans("ErrorFileIsInfectedWithAVirus"), 'errors');
}
else // Known error
{
- $mesg = ''.$langs->trans($resupload).'
';
+ setEventMessage($langs->trans($resupload), 'errors');
}
}
}
@@ -962,10 +973,8 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
else
{
$langs->load("errors");
- $mesg = ''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("File")).'
';
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("File")), 'warnings');
}
-
- return $mesg;
}
@@ -976,14 +985,12 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
* @param int $filenb File nb to delete
* @param int $donotupdatesession 1=Do not edit _SESSION variable
* @param int $donotdeletefile 1=Do not delete physically file
- * @return string Message with result of upload and store.
+ * @return void
*/
function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0)
{
global $db,$user,$conf,$langs,$_FILES;
- $mesg='';
-
$keytodelete=$filenb;
$keytodelete--;
@@ -1002,12 +1009,6 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=
else $result=0;
if ($result >= 0)
{
- if (empty($donotdeletefile))
- {
- $langs->load("other");
- $mesg = ''.$langs->trans("FileWasRemoved",$filetodelete).'
';
- //print_r($_FILES);
- }
if (empty($donotupdatesession))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
@@ -1016,8 +1017,6 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=
}
}
}
-
- return $mesg;
}
/**
diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php
index 9070a53a1cf..c5a98c23f31 100644
--- a/htdocs/ecm/docmine.php
+++ b/htdocs/ecm/docmine.php
@@ -112,8 +112,6 @@ if (GETPOST('action') == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
-
$result=$ecmdir->changeNbOfFiles('-');
}
diff --git a/htdocs/ecm/docother.php b/htdocs/ecm/docother.php
index 634ee0b5605..ca679993b22 100644
--- a/htdocs/ecm/docother.php
+++ b/htdocs/ecm/docother.php
@@ -81,7 +81,6 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
$langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
}
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 49486ffc728..4e78670c400 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -167,8 +167,6 @@ if ($action == 'confirm_deletefile')
$result=dol_delete_file($file);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
-
$result=$ecmdir->changeNbOfFiles('-');
clearstatcache();
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 8abd1f270c8..b4217bff558 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -155,7 +155,7 @@ class Expedition extends CommonObject
function create($user)
{
global $conf, $langs;
-
+
$now=dol_now();
require_once DOL_DOCUMENT_ROOT ."/product/stock/class/mouvementstock.class.php";
@@ -547,10 +547,7 @@ class Expedition extends CommonObject
$file = $dir . "/" . $expeditionref . ".pdf";
if (file_exists($file))
{
- if (!dol_delete_file($file))
- {
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
- }
+ dol_delete_file($file);
}
if (file_exists($dir))
{
@@ -794,9 +791,8 @@ class Expedition extends CommonObject
$file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf";
if (file_exists($file))
{
- if (!dol_delete_file($file))
+ if (! dol_delete_file($file))
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index d57bc9823eb..a5d78c2ade8 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -331,8 +331,7 @@ if (GETPOST('addfile','alpha'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesg=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action ='presend';
}
@@ -348,8 +347,7 @@ if (GETPOST('removedfile','alpha'))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesg=dol_remove_file_process(GETPOST('removedfile','int'),0);
-
+ dol_remove_file_process(GETPOST('removedfile','int'),0);
$action ='presend';
}
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 6862c855c5d..7bb03ff2198 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -164,7 +164,7 @@ class Fichinter extends CommonObject
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
-
+
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
$this->db->commit();
return $this->id;
@@ -210,7 +210,7 @@ class Fichinter extends CommonObject
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
-
+
$this->db->commit();
return 1;
}
@@ -339,7 +339,7 @@ class Fichinter extends CommonObject
if ($this->statut != 1)
{
$this->db->begin();
-
+
$now=dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
@@ -651,7 +651,6 @@ class Fichinter extends CommonObject
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}
@@ -664,7 +663,7 @@ class Fichinter extends CommonObject
}
}
}
-
+
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index 5364fb1f0e2..cd423cc7f68 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -121,7 +121,6 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes')
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 77dc95ad6bc..df699cba865 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -213,7 +213,6 @@ else if ($action == 'remove_file')
$upload_dir = $conf->ficheinter->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
@@ -467,8 +466,7 @@ if (GETPOST('addfile','alpha'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesg=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action='presend';
}
@@ -484,8 +482,7 @@ if (GETPOST('removedfile','alpha'))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesg=dol_remove_file_process(GETPOST('removedfile','alpha'),0);
-
+ dol_remove_file_process(GETPOST('removedfile','alpha'),0);
$action='presend';
}
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 612bfb01ee0..a94b674b3e0 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1322,7 +1322,6 @@ class CommandeFournisseur extends CommonOrder
{
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
- $this->error='ErrorFailToDeleteFile';
$error++;
}
}
diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php
index 1c087f956ac..c37fc310a6b 100644
--- a/htdocs/fourn/commande/document.php
+++ b/htdocs/fourn/commande/document.php
@@ -122,7 +122,6 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes')
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index b5a826e60c2..0572da65ca0 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -615,7 +615,6 @@ else if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer
$upload_dir = $conf->fournisseur->commande->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
@@ -668,8 +667,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesg=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action='presend';
}
@@ -685,8 +683,7 @@ if (GETPOST('removedfile'))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesg=dol_remove_file_process($_POST['removedfile'],0);
-
+ dol_remove_file_process($_POST['removedfile'],0);
$action='presend';
}
diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php
index 0b44c881c4f..7de4ac0652c 100644
--- a/htdocs/fourn/facture/document.php
+++ b/htdocs/fourn/facture/document.php
@@ -124,7 +124,6 @@ if ($action=='delete')
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file);
- $mesg = ''.$langs->trans('FileWasRemoved',GETPOST('urlfile')).'
';
}
}
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index f9fedc97d85..dee76961f64 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -617,8 +617,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp';
- $mesg=dol_add_file_process($upload_dir_tmp,0,0);
-
+ dol_add_file_process($upload_dir_tmp,0,0);
$action='presend';
}
@@ -632,8 +631,7 @@ if (! empty($_POST['removedfile']))
$upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form
- $mesg=dol_remove_file_process($_POST['removedfile'],0);
-
+ dol_remove_file_process($_POST['removedfile'],0);
$action='presend';
}
@@ -832,7 +830,6 @@ elseif ($action == 'remove_file')
$upload_dir = $conf->fournisseur->facture->dir_output . "/";
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 3dcfd88f220..5b9d5446c5b 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -397,15 +397,14 @@ class Livraison extends CommonObject
$file = $dir . "/" . $numref . ".pdf";
if (file_exists($file))
{
- if (!dol_delete_file($file))
+ if (! dol_delete_file($file))
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}
if (file_exists($dir))
{
- if (!dol_delete_dir($dir))
+ if (! dol_delete_dir($dir))
{
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
return 0;
@@ -581,7 +580,6 @@ class Livraison extends CommonObject
{
if (!dol_delete_file($file))
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 4e63ec969bd..059843ab439 100755
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -129,7 +129,6 @@ if ($object->id)
{
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file);
- //if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
}
$head=product_prepare_head($object, $user);
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index 74efec961bd..653e0009b7b 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -115,7 +115,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->s
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index 967d57b4367..be8d437dc53 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -252,7 +252,6 @@ if ($action == 'remove_file' && $user->rights->projet->creer)
$upload_dir = $conf->projet->dir_output . "/";
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index 8e88ba814c4..50f12148314 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -112,7 +112,6 @@ if ($action=='delete')
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php
index cf27d4948a1..bc63741bac1 100644
--- a/htdocs/societe/document.php
+++ b/htdocs/societe/document.php
@@ -124,7 +124,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
- setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 2457bcdce80..f77c4b65f79 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -463,7 +463,6 @@ if (empty($reshook))
$upload_dir = $conf->societe->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
}
}
}