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");
$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;
}

View File

@ -148,10 +148,6 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
$result = dol_delete_file($pathtodelete,1);
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');
$formmail = new FormMail($db);
$formmail->remove_attached_files($keytodelete);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* 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>
*
* 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

View File

@ -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";
}

View File

@ -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='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
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='<div class="error">'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'</div>';
else $mesg='<div class="error">'.$object->error.'</div>';
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='<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))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>';
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 = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')).'</div>';
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 = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$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='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'</div>';
$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='<div class="error">'.$mailfile->error.'</div>';
}
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='<div class="error">';
if ($mailfile->error)
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
}
}
// 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='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
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.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
setEventMessage($mesg, 'errors');
}
}
/* }
}
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
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='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")).'</div>';
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='<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
else if ($action == "addline" && $user->rights->propale->creer)
{
$result=0;
if (empty($_POST['idprod']) && GETPOST('type') < 0)
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$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='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>';
$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 = '<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
{
@ -852,7 +782,7 @@ else if ($action == "addline" && $user->rights->propale->creer)
}
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
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 = '<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
{
@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
// 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 = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
@ -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';
}

View File

@ -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[] = '<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
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback();
return 0;
}

View File

@ -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;
}

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

View File

@ -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 = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
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 = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
setEventMessage($langs->trans("ErrorFileNotUploaded"), 'errors');
}
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
{
$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
{
$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 $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 = '<div class="ok">'.$langs->trans("FileWasRemoved",$filetodelete).'</div>';
//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;
}
/**

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).
$result=dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$result=$ecmdir->changeNbOfFiles('-');
}

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
}

View File

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

View File

@ -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;
}
}

View File

@ -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';
}

View File

@ -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);

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

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
@ -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';
}

View File

@ -1322,7 +1322,6 @@ class CommandeFournisseur extends CommonOrder
{
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->error='ErrorFailToDeleteFile';
$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).
dol_delete_file($file,0,0,0,$object);
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
@ -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';
}

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).
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;
$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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}

View File

@ -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;
}
}

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).
$result=dol_delete_file($file);
//if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
}
$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);
$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;
}

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}

View File

@ -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;
}

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

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
}