Fix: try to use the new message system

This commit is contained in:
Regis Houssin 2012-07-29 12:54:19 +02:00
parent 77a5ef0b22
commit eee5653c54
36 changed files with 233 additions and 389 deletions

View File

@ -113,7 +113,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$langs->load("other"); $langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file); dol_delete_file($file);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -148,10 +148,6 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
$result = dol_delete_file($pathtodelete,1); $result = dol_delete_file($pathtodelete,1);
if ($result >= 0) if ($result >= 0)
{ {
$langs->load("other");
$message = '<div class="ok">'.$langs->trans("FileWasRemoved",$filetodelete).'</div>';
//print_r($_FILES);
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
$formmail = new FormMail($db); $formmail = new FormMail($db);
$formmail->remove_attached_files($keytodelete); $formmail->remove_attached_files($keytodelete);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -43,6 +43,7 @@ class ActionComm extends CommonObject
var $type; var $type;
var $label; var $label;
var $date;
var $datec; // Date creation record (datec) var $datec; // Date creation record (datec)
var $datem; // Date modification record (tms) var $datem; // Date modification record (tms)
var $author; // Object user that create action var $author; // Object user that create action

View File

@ -495,7 +495,7 @@ if (! empty($_POST['addfile']))
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
// Set tmp user directory // Set tmp user directory
$mesg=dol_add_file_process($upload_dir,0,0); dol_add_file_process($upload_dir,0,0);
$action="edit"; $action="edit";
} }
@ -507,7 +507,7 @@ if (! empty($_POST["removedfile"]))
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); 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"; $action="edit";
} }

View File

@ -62,8 +62,6 @@ $search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha');
$sall=GETPOST("sall"); $sall=GETPOST("sall");
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
$mesgs=array();
$year=GETPOST("year"); $year=GETPOST("year");
$month=GETPOST("month"); $month=GETPOST("month");
@ -98,6 +96,7 @@ $object = new Propal($db);
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$ret=$object->fetch($id, $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 // 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')) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>'; setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
} }
else else
{ {
if ($object->fetch($id) > 0) if ($object->id > 0)
{ {
$result=$object->createFromClone($socid, $hookmanager); $result=$object->createFromClone($socid, $hookmanager);
if ($result > 0) if ($result > 0)
@ -133,7 +132,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
} }
else else
{ {
$mesg=$object->error; setEventMessage($object->error, 'errors');
$action=''; $action='';
} }
} }
@ -143,8 +142,6 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
// Suppression de la propale // Suppression de la propale
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propale->supprimer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propale->supprimer)
{ {
$object->fetch($id);
$object->fetch_thirdparty();
$result=$object->delete($user); $result=$object->delete($user);
if ($result > 0) if ($result > 0)
{ {
@ -154,16 +151,13 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop
else else
{ {
$langs->load("errors"); $langs->load("errors");
if ($object->error == 'ErrorFailToDeleteDir') $mesg='<div class="error">'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'</div>'; setEventMessage($langs->trans($object->error), 'errors');
else $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
// Remove line // Remove line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer) else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($lineid); $result = $object->deleteline($lineid);
// reorder lines // reorder lines
if ($result) $object->line_order(true); if ($result) $object->line_order(true);
@ -171,7 +165,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $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 ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
@ -191,16 +185,13 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
// Validation // Validation
else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider) else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider)
{ {
$object->fetch($id);
$object->fetch_thirdparty();
$result=$object->valid($user); $result=$object->valid($user);
if ($result >= 0) if ($result >= 0)
{ {
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $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 ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) 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)) 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); propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
} }
} }
else else
{ {
$mesg='<div class="error">'.$object->error.'</div>'; $langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors');
} }
} }
@ -226,25 +218,22 @@ else if ($action == 'setdate' && $user->rights->propale->creer)
if (empty($datep)) if (empty($datep))
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
} }
if (! $error) if (! $error)
{ {
$object->fetch($id);
$result=$object->set_date($user,$datep); $result=$object->set_date($user,$datep);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
} }
else if ($action == 'setecheance' && $user->rights->propale->creer) 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'])); $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); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setdate_livraison' && $user->rights->propale->creer) 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'])); $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); 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 // Positionne ref client
else if ($action == 'set_ref_client' && $user->rights->propale->creer) else if ($action == 'set_ref_client' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$object->set_ref_client($user, $_POST['ref_client']); $object->set_ref_client($user, $_POST['ref_client']);
} }
else if ($action == 'setnote_public' && $user->rights->propale->creer) 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)); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->propale->creer) else if ($action == 'setnote' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@ -291,7 +277,7 @@ else if ($action == 'add' && $user->rights->propale->creer)
$db->begin(); $db->begin();
// Si on a selectionne une propal a copier, on realise la copie // 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) if ($object->fetch(GETPOST('copie_propal')) > 0)
{ {
@ -318,7 +304,7 @@ else if ($action == 'add' && $user->rights->propale->creer)
} }
else else
{ {
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')).'</div>'; setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors');
} }
} }
else else
@ -359,21 +345,14 @@ else if ($action == 'add' && $user->rights->propale->creer)
if ($id > 0) if ($id > 0)
{ {
$error=0;
// Insertion contact par defaut si defini // Insertion contact par defaut si defini
if (GETPOST('contactidp')) if (GETPOST('contactidp'))
{ {
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
if ($result < 0)
if ($result > 0)
{ {
$error=0; $error++;
} setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
else
{
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$error=1;
} }
} }
@ -413,42 +392,33 @@ else if ($action == 'add' && $user->rights->propale->creer)
// Classify billed // Classify billed
else if ($action == 'classifybilled' && $user->rights->propale->cloturer) else if ($action == 'classifybilled' && $user->rights->propale->cloturer)
{ {
$object->fetch($id);
$object->cloture($user, 4, ''); $object->cloture($user, 4, '');
} }
// Reopen proposal // 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'])
{
$object->fetch($id);
// prevent browser refresh from reopening proposal several times // prevent browser refresh from reopening proposal several times
if ($object->statut==2 || $object->statut==3) if ($object->statut==2 || $object->statut==3)
{ {
$object->setStatut(1); $object->setStatut(1);
} }
}
} }
// Close proposal // 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')) if (! GETPOST('statut'))
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")), 'errors');
$action='statut'; $action='statut';
} }
else else
{ {
$object->fetch($id);
// prevent browser refresh from closing proposal several times // prevent browser refresh from closing proposal several times
if ($object->statut==1) if ($object->statut==1)
{ {
$object->cloture($user, $_REQUEST['statut'], $_REQUEST['note']); $object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
} }
} }
} }
@ -464,16 +434,14 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action='presend';
$_POST["action"]='presend';
} }
/* /*
* Remove file in email form * Remove file in email form
*/ */
if (! empty($_POST['removedfile'])) if (GETPOST('removedfile'))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@ -482,29 +450,19 @@ if (! empty($_POST['removedfile']))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action='presend';
$_POST["action"]='presend';
} }
/* /*
* Send mail * Send mail
*/ */
if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel'))
{ {
$langs->load('mails'); $langs->load('mails');
$result=$object->fetch($_POST["id"]); if ($object->id > 0)
$result=$object->fetch_thirdparty();
if ($result > 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 // Le destinataire a ete fourni via le champ libre
@ -536,8 +494,6 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$sendtocc = $_POST['sendtocc']; $sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt']; $deliveryreceipt = $_POST['deliveryreceipt'];
if ($_POST['action'] == 'send')
{
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
else $subject = $langs->transnoentities('Propal').' '.$object->ref; else $subject = $langs->transnoentities('Propal').' '.$object->ref;
$actiontypecode='AC_PROP'; $actiontypecode='AC_PROP';
@ -549,7 +505,6 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$actionmsg.=$message; $actionmsg.=$message;
} }
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode); $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
}
// Create form object // Create form object
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
@ -565,17 +520,13 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->error) if ($mailfile->error)
{ {
$mesg='<div class="error">'.$mailfile->error.'</div>'; setEventMessage($mailfile->error, 'errors');
} }
else else
{ {
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result) if ($result)
{ {
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
$error=0;
// Initialisation donnees // Initialisation donnees
$object->sendtoid = $sendtoid; $object->sendtoid = $sendtoid;
$object->actiontypecode = $actiontypecode; $object->actiontypecode = $actiontypecode;
@ -588,25 +539,28 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf); $result=$interface->run_triggers('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers // Fin appel triggers
if ($error) if (! $error)
{
dol_print_error($db);
}
else
{ {
// Redirect here // Redirect here
// This avoid sending mail twice if going out and then back to page // This avoid sending mail twice if going out and then back to page
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg)); $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
setEventMessage($mesg);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
else
{
dol_print_error($db);
}
} }
else else
{ {
$langs->load("other"); $langs->load("other");
$mesg='<div class="error">';
if ($mailfile->error) if ($mailfile->error)
{ {
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
@ -616,37 +570,28 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
{ {
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
} }
$mesg.='</div>'; setEventMessage($mesg, 'errors');
} }
} }
} }
else else
{ {
$langs->load("other"); $langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>'; setEventMessage($langs->trans('ErrorMailRecipientIsEmpty').'!', 'errors');
dol_syslog('Recipient email is empty'); dol_syslog($langs->trans('ErrorMailRecipientIsEmpty'));
} }
/* }
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dol_syslog('Failed to read file: '.$file);
}*/
} }
else else
{ {
$langs->load("other"); $langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")).'</div>'; setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")), 'errors');
dol_syslog('Impossible de lire les donnees de la facture. Le fichier propal n\'a peut-etre pas ete genere.'); dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")));
} }
} }
// Go back to draft // Go back to draft
if ($action == 'modif' && $user->rights->propale->creer) if ($action == 'modif' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$object->fetch_thirdparty();
$object->set_draft($user); $object->set_draft($user);
// Define output language // Define output language
@ -667,49 +612,33 @@ else if ($action == "setabsolutediscount" && $user->rights->propale->creer)
{ {
if ($_POST["remise_id"]) if ($_POST["remise_id"])
{ {
$object->id=$id; if ($object->id > 0)
$ret=$object->fetch($id);
if ($ret > 0)
{ {
$result=$object->insert_discount($_POST["remise_id"]); $result=$object->insert_discount($_POST["remise_id"]);
if ($result < 0) if ($result < 0)
{ {
$mesg='<div class="error">'.$object->error.'</div>'; setEventMessage($object->error, 'errors');
} }
} }
else
{
dol_print_error($db,$object->error);
}
} }
} }
//Ajout d'une ligne produit dans la propale //Ajout d'une ligne produit dans la propale
else if ($action == "addline" && $user->rights->propale->creer) else if ($action == "addline" && $user->rights->propale->creer)
{ {
$result=0;
if (empty($_POST['idprod']) && GETPOST('type') < 0) if (empty($_POST['idprod']) && GETPOST('type') < 0)
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors');
$result = -1 ; $error++;
} }
if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not '' if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not ''
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
$result = -1 ; $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_ht=0;
$pu_ttc=0; $pu_ttc=0;
$price_min=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); $tva_npr = get_default_npr($mysoc,$object->client,$prod->id);
// On defini prix unitaire // 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_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$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))) if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>' ; $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency));
setEventMessage($mesg, 'errors');
} }
else else
{ {
@ -852,7 +782,7 @@ else if ($action == "addline" && $user->rights->propale->creer)
} }
else else
{ {
$mesg='<div class="error">'.$object->error.'</div>'; 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 // Mise a jour d'une ligne dans la propale
else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('save') == $langs->trans("Save")) 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 // Define info_bits
$info_bits=0; $info_bits=0;
if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01; if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01;
@ -879,13 +802,6 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
$localtax2_rate=get_localtax($vat_rate,2,$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 // Define special_code for special lines
$special_code=0; $special_code=0;
if (empty($_POST['qty'])) $special_code=3; if (empty($_POST['qty'])) $special_code=3;
@ -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))) if ($productid && $price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>' ; $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency));
setEventMessage($mesg, 'errors');
} }
else else
{ {
@ -919,8 +836,8 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
$special_code, $special_code,
$_POST['fk_parent_line'], $_POST['fk_parent_line'],
0, 0,
$fk_fournprice, GETPOST('fournprice'),
$pa_ht GETPOST('buying_price')
); );
// Define output language // Define output language
@ -951,12 +868,9 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('s
// Generation doc (depuis lien ou depuis cartouche doc) // Generation doc (depuis lien ou depuis cartouche doc)
else if ($action == 'builddoc' && $user->rights->propale->creer) else if ($action == 'builddoc' && $user->rights->propale->creer)
{ {
$object->fetch($id); if (GETPOST('model'))
$object->fetch_thirdparty();
if ($_REQUEST['model'])
{ {
$object->setDocModel($user, $_REQUEST['model']); $object->setDocModel($user, GETPOST('model'));
} }
// Define output language // Define output language
@ -983,66 +897,56 @@ else if ($action == 'builddoc' && $user->rights->propale->creer)
} }
// Remove file in doc form // 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"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty();
$langs->load("other"); $langs->load("other");
$upload_dir = $conf->propal->dir_output; $upload_dir = $conf->propal->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
// Set project // Set project
else if ($action == 'classin' && $user->rights->propale->creer) else if ($action == 'classin' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$object->setProject($_POST['projectid']); $object->setProject($_POST['projectid']);
} }
// Delai de livraison // Delai de livraison
else if ($action == 'setavailability' && $user->rights->propale->creer) else if ($action == 'setavailability' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->availability($_POST['availability_id']); $result = $object->availability($_POST['availability_id']);
} }
// Origine de la propale // Origine de la propale
else if ($action == 'setdemandreason' && $user->rights->propale->creer) else if ($action == 'setdemandreason' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->demand_reason($_POST['demand_reason_id']); $result = $object->demand_reason($_POST['demand_reason_id']);
} }
// Conditions de reglement // Conditions de reglement
else if ($action == 'setconditions' && $user->rights->propale->creer) else if ($action == 'setconditions' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int')); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
} }
else if ($action == 'setremisepercent' && $user->rights->propale->creer) else if ($action == 'setremisepercent' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->set_remise_percent($user, $_POST['remise_percent']); $result = $object->set_remise_percent($user, $_POST['remise_percent']);
} }
else if ($action == 'setremiseabsolue' && $user->rights->propale->creer) else if ($action == 'setremiseabsolue' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']); $result = $object->set_remise_absolue($user, $_POST['remise_absolue']);
} }
// Mode de reglement // Mode de reglement
else if ($action == 'setmode' && $user->rights->propale->creer) else if ($action == 'setmode' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); $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) else if ($action == 'up' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$object->fetch_thirdparty();
$object->line_up(GETPOST('rowid')); $object->line_up(GETPOST('rowid'));
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $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 ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
@ -1074,14 +976,12 @@ else if ($action == 'up' && $user->rights->propale->creer)
else if ($action == 'down' && $user->rights->propale->creer) else if ($action == 'down' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$object->fetch_thirdparty();
$object->line_down(GETPOST('rowid')); $object->line_down(GETPOST('rowid'));
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $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 ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
@ -1094,16 +994,14 @@ else if ($action == 'down' && $user->rights->propale->creer)
exit; 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 ($object->id > 0)
if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $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) if ($result >= 0)
@ -1116,17 +1014,17 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; setEventMessage($object->error, 'errors');
} }
} }
} }
// Bascule du statut d'un contact // Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer) else if ($action == 'swapstatut')
{ {
if ($object->fetch($id) > 0) if ($object->fetch($id) > 0)
{ {
@ -1139,7 +1037,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer) else if ($action == 'deletecontact')
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
@ -1175,8 +1073,6 @@ $now=dol_now();
* Show object in view mode * Show object in view mode
*/ */
dol_htmloutput_mesg($mesg,$mesgs);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($object->socid); $soc->fetch($object->socid);
@ -1863,7 +1759,7 @@ if ($action == 'presend')
$formmail->withtosocid=$soc->id; $formmail->withtosocid=$soc->id;
$formmail->withtocc=1; $formmail->withtocc=1;
$formmail->withtoccsocid=0; $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->withtocccsocid=0;
$formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__');
$formmail->withfile=2; $formmail->withfile=2;

View File

@ -1845,7 +1845,6 @@ class Propal extends CommonObject
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error='ErrorFailToDeleteFile';
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }

View File

@ -125,7 +125,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); $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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -2344,7 +2344,6 @@ class Commande extends CommonOrder
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }

View File

@ -122,7 +122,6 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); $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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -1005,7 +1005,6 @@ else if ($action == 'remove_file')
$upload_dir = $conf->commande->dir_output; $upload_dir = $conf->commande->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
@ -1020,8 +1019,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action ='presend';
} }
@ -1037,8 +1035,7 @@ if (GETPOST('removedfile'))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action ='presend';
} }

View File

@ -1323,8 +1323,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action='presend';
} }
@ -1340,8 +1339,7 @@ if (! empty($_POST['removedfile']))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action='presend';
} }
@ -1566,7 +1564,6 @@ else if ($action == 'remove_file')
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesgs[] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }

View File

@ -1263,7 +1263,6 @@ class Facture extends CommonInvoice
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }

View File

@ -125,7 +125,6 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); $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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -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). $file = $upload_dir . '/' . GETPOST("urlfile"); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file); $result=dol_delete_file($file);
//if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
} }
$head=tax_prepare_head($object, $user); $head=tax_prepare_head($object, $user);

View File

@ -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). $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); $ret=dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }

View File

@ -671,6 +671,9 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
{ {
global $db, $conf, $user, $langs; global $db, $conf, $user, $langs;
$langs->load("other");
$langs->load("errors");
$error=0; $error=0;
//print "x".$file." ".$disableglob; //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 else $ok=unlink($filename); // The unlink encapsulated by dolibarr
if ($ok) 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 (! $notrigger)
{ {
if (! is_object($object)) $object=(object) 'dummy'; 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 // 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 else
{ {
if ($nophperrors) $ok=@unlink($file_osencoded); // The unlink encapsulated by dolibarr if ($nophperrors) $ok=@unlink($file_osencoded); // The unlink encapsulated by dolibarr
else $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); if ($ok) {
else dol_syslog("Failed to remove file ".$file_osencoded,LOG_WARNING); 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; return $ok;
} }
@ -917,14 +930,12 @@ function dol_init_file_process($pathtoscan='')
* @param string $upload_dir Directory to store upload files * @param string $upload_dir Directory to store upload files
* @param int $allowoverwrite 1=Allow overwrite existing file * @param int $allowoverwrite 1=Allow overwrite existing file
* @param int $donotupdatesession 1=Do no edit _SESSION variable * @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) function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=0)
{ {
global $db,$user,$conf,$langs,$_FILES; global $db,$user,$conf,$langs,$_FILES;
$mesg='';
if (! empty($_FILES['addedfile']['tmp_name'])) if (! empty($_FILES['addedfile']['tmp_name']))
{ {
if (dol_mkdir($upload_dir) >= 0) 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']); $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) if (is_numeric($resupload) && $resupload > 0)
{ {
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>'; setEventMessage($langs->trans("FileTransferComplete"));
if (empty($donotupdatesession)) if (empty($donotupdatesession))
{ {
@ -946,15 +957,15 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
$langs->load("errors"); $langs->load("errors");
if ($resupload < 0) // Unknown error if ($resupload < 0) // Unknown error
{ {
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>'; setEventMessage($langs->trans("ErrorFileNotUploaded"), 'errors');
} }
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{ {
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>'; setEventMessage($langs->trans("ErrorFileIsInfectedWithAVirus"), 'errors');
} }
else // Known error else // Known error
{ {
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>'; setEventMessage($langs->trans($resupload), 'errors');
} }
} }
} }
@ -962,10 +973,8 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
else else
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="warning">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("File")).'</div>'; 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 $filenb File nb to delete
* @param int $donotupdatesession 1=Do not edit _SESSION variable * @param int $donotupdatesession 1=Do not edit _SESSION variable
* @param int $donotdeletefile 1=Do not delete physically file * @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) function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0)
{ {
global $db,$user,$conf,$langs,$_FILES; global $db,$user,$conf,$langs,$_FILES;
$mesg='';
$keytodelete=$filenb; $keytodelete=$filenb;
$keytodelete--; $keytodelete--;
@ -1002,12 +1009,6 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=
else $result=0; else $result=0;
if ($result >= 0) if ($result >= 0)
{ {
if (empty($donotdeletefile))
{
$langs->load("other");
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",$filetodelete).'</div>';
//print_r($_FILES);
}
if (empty($donotupdatesession)) if (empty($donotupdatesession))
{ {
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); 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;
} }
/** /**

View File

@ -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). $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file); $result=dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$result=$ecmdir->changeNbOfFiles('-'); $result=$ecmdir->changeNbOfFiles('-');
} }

View File

@ -81,7 +81,6 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
$langs->load("other"); $langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file); dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
} }

View File

@ -167,8 +167,6 @@ if ($action == 'confirm_deletefile')
$result=dol_delete_file($file); $result=dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$result=$ecmdir->changeNbOfFiles('-'); $result=$ecmdir->changeNbOfFiles('-');
clearstatcache(); clearstatcache();

View File

@ -547,10 +547,7 @@ class Expedition extends CommonObject
$file = $dir . "/" . $expeditionref . ".pdf"; $file = $dir . "/" . $expeditionref . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
if (!dol_delete_file($file)) dol_delete_file($file);
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
}
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
@ -794,9 +791,8 @@ class Expedition extends CommonObject
$file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf"; $file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
if (!dol_delete_file($file)) if (! dol_delete_file($file))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0; return 0;
} }
} }

View File

@ -331,8 +331,7 @@ if (GETPOST('addfile','alpha'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action ='presend';
} }
@ -348,8 +347,7 @@ if (GETPOST('removedfile','alpha'))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action ='presend';
} }

View File

@ -651,7 +651,6 @@ class Fichinter extends CommonObject
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0; return 0;
} }
} }

View File

@ -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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -213,7 +213,6 @@ else if ($action == 'remove_file')
$upload_dir = $conf->ficheinter->dir_output; $upload_dir = $conf->ficheinter->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
@ -467,8 +466,7 @@ if (GETPOST('addfile','alpha'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action='presend';
} }
@ -484,8 +482,7 @@ if (GETPOST('removedfile','alpha'))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action='presend';
} }

View File

@ -1322,7 +1322,6 @@ class CommandeFournisseur extends CommonOrder
{ {
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error='ErrorFailToDeleteFile';
$error++; $error++;
} }
} }

View File

@ -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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -615,7 +615,6 @@ else if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer
$upload_dir = $conf->fournisseur->commande->dir_output; $upload_dir = $conf->fournisseur->commande->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
@ -668,8 +667,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action='presend';
} }
@ -685,8 +683,7 @@ if (GETPOST('removedfile'))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action='presend';
} }

View File

@ -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). $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file); dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans('FileWasRemoved',GETPOST('urlfile')).'</div>';
} }
} }

View File

@ -617,8 +617,7 @@ if (GETPOST('addfile'))
$vardir=$conf->user->dir_output."/".$user->id; $vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; $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'; $action='presend';
} }
@ -632,8 +631,7 @@ if (! empty($_POST['removedfile']))
$upload_dir_tmp = $vardir.'/temp'; $upload_dir_tmp = $vardir.'/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action='presend';
} }
@ -832,7 +830,6 @@ elseif ($action == 'remove_file')
$upload_dir = $conf->fournisseur->facture->dir_output . "/"; $upload_dir = $conf->fournisseur->facture->dir_output . "/";
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file); dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }

View File

@ -397,15 +397,14 @@ class Livraison extends CommonObject
$file = $dir . "/" . $numref . ".pdf"; $file = $dir . "/" . $numref . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
if (!dol_delete_file($file)) if (! dol_delete_file($file))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0; return 0;
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
if (!dol_delete_dir($dir)) if (! dol_delete_dir($dir))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
return 0; return 0;
@ -581,7 +580,6 @@ class Livraison extends CommonObject
{ {
if (!dol_delete_file($file)) if (!dol_delete_file($file))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0; return 0;
} }
} }

View File

@ -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). $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$result=dol_delete_file($file); $result=dol_delete_file($file);
//if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
} }
$head=product_prepare_head($object, $user); $head=product_prepare_head($object, $user);

View File

@ -115,7 +115,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->s
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); $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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }

View File

@ -252,7 +252,6 @@ if ($action == 'remove_file' && $user->rights->projet->creer)
$upload_dir = $conf->projet->dir_output . "/"; $upload_dir = $conf->projet->dir_output . "/";
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file); dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }

View File

@ -112,7 +112,6 @@ if ($action=='delete')
$langs->load("other"); $langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file); dol_delete_file($file);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@ -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). $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); dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }

View File

@ -463,7 +463,6 @@ if (empty($reshook))
$upload_dir = $conf->societe->dir_output; $upload_dir = $conf->societe->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
} }