diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 0ba89db6895..c21aa98f188 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -113,7 +113,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index ad6fc2284ed..657e0cd17af 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -89,13 +89,13 @@ $sql.= " d.datefin,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " t.libelle as type, t.cotisation"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; -if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ +if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_adherent_type = t.rowid "; -if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$catid; -if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; -if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$search_categ; -if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; +if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$catid; +if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; +if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$search_categ; +if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; $sql.= " AND d.entity = ".$conf->entity; if ($sall) { diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 1b60e197126..4c97bcefd58 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2011 Philippe Grand * @@ -28,21 +28,22 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'); -if ($conf->projet->enabled) -{ +if (! empty($conf->projet->enabled)) { require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); } $langs->load("propal"); -if ($conf->projet->enabled) $langs->load("projects"); +if (! empty($conf->projet->enabled)) + $langs->load("projects"); $langs->load("companies"); $langs->load("bills"); $langs->load("orders"); $langs->load("deliveries"); -$action=GETPOST('action'); -$mesg=GETPOST('mesg'); +$action=GETPOST('action','alpha'); +$origin=GETPOST('origin','alpha'); +$originid=GETPOST('originid','int'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); @@ -67,8 +68,6 @@ print_fiche_titre($langs->trans("NewProp")); $form=new Form($db); -dol_htmloutput_mesg($mesg); - // Add new proposal if ($action == 'create') { @@ -117,16 +116,19 @@ if ($action == 'create') print ''; print ''; - if (isset($_GET["origin"]) && $_GET["origin"] != 'project' && isset($_GET["originid"])) + if ($origin != 'project' && $originid) { - print ''; - print ''; + print ''; + print ''; } print ''; // Ref - print ''; + print ''; + print ''; + print ''; + print ''; // Ref customer print ''; // Ligne info remises tiers @@ -175,12 +177,12 @@ if ($action == 'create') // What trigger creation print ''; // Delivery delay print ''; // Delivery date (or manufacturing) @@ -213,7 +215,7 @@ if ($action == 'create') if ($conf->projet->enabled) { $projectid = 0; - if (isset($_GET["origin"]) && $_GET["origin"] == 'project') $projectid = ($_GET["originid"]?$_GET["originid"]:0); + if ($origin == 'project') $projectid = ($originid?$originid:0); print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Ref").''.$numpr.'
'.$langs->trans('RefCustomer').''; @@ -141,7 +143,7 @@ if ($action == 'create') // Contacts print "
".$langs->trans("DefaultContact")."\n"; - $form->select_contacts($soc->id,$setcontact,'contactidp',1); + $form->select_contacts($soc->id,'','contactidp',1); print '
'.$langs->trans('Source').''; - $form->select_demand_reason($object->demand_reason,'demand_reason_id',"SRC_PROP",1); + $form->select_demand_reason('','demand_reason_id',"SRC_PROP",1); print '
'.$langs->trans('AvailabilityPeriod').''; - $form->select_availability($object->availability,'availability_id','',1); + $form->select_availability('','availability_id','',1); print '
'.$langs->trans("Project").''; @@ -228,7 +230,7 @@ if ($action == 'create') } // Other attributes - $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); + $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -341,6 +343,9 @@ if ($action == 'create') print ""; } -$db->close(); +dol_htmloutput_events($mesgs,$errors,$warnings); + llxFooter(); + +$db->close(); ?> diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index 3f507b3a452..0631a22383d 100755 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -53,8 +53,8 @@ $search_compta=GETPOST("search_compta"); // Load sale and categ filters $search_sale = GETPOST("search_sale"); -$search_categ = GETPOST("search_categ",'int'); -$catid = GETPOST("catid",'int'); +$search_categ = GETPOST("search_categ",'int'); +$catid = GETPOST("catid",'int'); /* * Actions @@ -102,10 +102,10 @@ $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid; -if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid; +if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; +if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'"; if ($search_ville) $sql.= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'"; if ($search_code) $sql.= " AND s.code_client LIKE '%".$db->escape(strtolower($search_code))."%'"; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index e7ed17f5e04..ff3d4afc1b2 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -555,7 +555,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes') { $object->valid($user); - $_SESSION['dol_message']='
'.$langs->trans("MailingSuccessfullyValidated").'
'; + $_SESSION['dol_events']['mesgs']='
'.$langs->trans("MailingSuccessfullyValidated").'
'; Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b8f03a32b38..b0b19210362 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -276,14 +276,14 @@ else if ($action == 'add' && $user->rights->propale->creer) $object->socid=$socid; $object->fetch_thirdparty(); - $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $date_delivery=dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); + $datep=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $date_delivery=dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); if (empty($datep)) { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'
'; - header("Location: ".DOL_URL_ROOT.'/comm/addpropal.php?socid='.$socid.'&action=create&mesg='.urlencode($mesg)); + $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")); + $_SESSION['dol_events']['errors']=$errors; + header("Location: ".DOL_URL_ROOT.'/comm/addpropal.php?socid='.$socid.'&action=create'); exit; } @@ -292,57 +292,57 @@ else if ($action == 'add' && $user->rights->propale->creer) $db->begin(); // Si on a selectionne une propal a copier, on realise la copie - if($_POST['createmode']=='copy' && $_POST['copie_propal']) + if(GETPOST('createmode')=='copy' && GETPOST('copie_propal')) { - if ($object->fetch($_POST['copie_propal']) > 0) + if ($object->fetch(GETPOST('copie_propal')) > 0) { - $object->ref = $_POST['ref']; + $object->ref = GETPOST('ref'); $object->datep = $datep; $object->date_livraison = $date_delivery; - $object->availability_id = $_POST['availability_id']; - $object->demand_reason_id = $_POST['demand_reason_id']; - $object->fk_delivery_address = $_POST['fk_address']; - $object->duree_validite = $_POST['duree_validite']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->remise_percent = $_POST['remise_percent']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->socid = $_POST['socid']; - $object->contactid = $_POST['contactidp']; - $object->fk_project = $_POST['projectid']; - $object->modelpdf = $_POST['model']; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = GETPOST('duree_validite'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); + $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = $_POST['note']; + $object->note = GETPOST('note'); $object->statut = 0; $id = $object->create_from($user); } else { - $mesg = '
'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'
'; + $mesg = '
'.$langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')).'
'; } } else { - $object->ref = $_POST['ref']; - $object->ref_client = $_POST['ref_client']; + $object->ref = GETPOST('ref'); + $object->ref_client = GETPOST('ref_client'); $object->datep = $datep; $object->date_livraison = $date_delivery; - $object->availability_id = $_POST['availability_id']; - $object->demand_reason_id = $_POST['demand_reason_id']; - $object->fk_delivery_address = $_POST['fk_address']; - $object->duree_validite = $_POST['duree_validite']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = GETPOST('duree_validite'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->contactid = $_POST['contactidp']; - $object->fk_project = $_POST['projectid']; - $object->modelpdf = $_POST['model']; + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated - $object->note = $_POST['note']; + $object->note = GETPOST('note'); - $object->origin = $_POST['origin']; - $object->origin_id = $_POST['originid']; + $object->origin = GETPOST('origin'); + $object->origin_id = GETPOST('originid'); for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) { @@ -363,9 +363,9 @@ else if ($action == 'add' && $user->rights->propale->creer) $error=0; // Insertion contact par defaut si defini - if ($_POST["contactidp"]) + if (GETPOST('contactidp')) { - $result=$object->add_contact($_POST["contactidp"],'CUSTOMER','external'); + $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); if ($result > 0) { diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 861e41d8ff4..75546f01fb1 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -125,7 +125,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index a2f7e57a05a..c80bb788eb3 100755 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -43,8 +43,8 @@ $search_nom = GETPOST("search_nom"); $search_ville = GETPOST("search_ville"); $search_departement = GETPOST("search_departement"); $search_datec = GETPOST("search_datec"); -$search_categ = GETPOST("search_categ",'int'); -$catid = GETPOST("catid",'int'); +$search_categ = GETPOST("search_categ",'int'); +$catid = GETPOST("catid",'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -178,10 +178,10 @@ $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; if ($user->societe_id) $sql.= " AND s.rowid = " .$user->societe_id; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm; -if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid; -if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid; +if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; +if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_nom) $sql .= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'"; if ($search_ville) $sql .= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'"; if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'"; diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index ded13509385..80df980eb5b 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -122,7 +122,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 6ecbb4c5b80..5e6ba0d999c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1437,14 +1437,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); if ($mailfile->error) { - $mesg='
'.$mailfile->error.'
'; + $mesgs[]='
'.$mailfile->error.'
'; } else { $result=$mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " + $mesgs[]=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " $error=0; @@ -1471,7 +1471,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { // Redirect here // This avoid sending mail twice if going out and then back to page - $_SESSION['dol_message'] = $mesg; + $_SESSION['dol_events']['mesgs'] = $mesgs; Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id); exit; } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e023a0dd242..0e3f75efc45 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -125,7 +125,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 2c09a9b94c3..9646d97d90e 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -122,7 +122,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 291616266cf..2c5fca61300 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -286,56 +286,56 @@ class CMailFile $this->smtps=$smtps; } // TODO not stable, in progress - else if ($conf->global->MAIN_MAIL_SENDMODE == 'phpmailer') - { - // Use PHPMailer library - // ------------------------------------------ - - require_once(DOL_DOCUMENT_ROOT."/includes/phpmailer/class.phpmailer.php"); - $this->phpmailer = new PHPMailer(); - $this->phpmailer->CharSet = $conf->file->character_set_client; - - $this->phpmailer->Subject($this->encodetorfc2822($subject)); - $this->phpmailer->setTO($this->getValidAddress($to,0,1)); - $this->phpmailer->SetFrom($this->getValidAddress($from,0,1)); - - if (! empty($this->html)) - { - if (!empty($css)) - { - $this->css = $css; - $this->styleCSS = $this->buildCSS(); - } - $msg = $this->html; - $msg = $this->checkIfHTML($msg); - } - - if ($this->msgishtml) $smtps->setBodyContent($msg,'html'); - else $smtps->setBodyContent($msg,'plain'); - - if ($this->atleastoneimage) - { - foreach ($this->images_encoded as $img) - { - $smtps->setImageInline($img['image_encoded'],$img['name'],$img['content_type'],$img['cid']); - } - } - - if ($this->atleastonefile) - { - foreach ($filename_list as $i => $val) - { - $content=file_get_contents($filename_list[$i]); - $smtps->setAttachment($content,$mimefilename_list[$i],$mimetype_list[$i]); - } - } - - $smtps->setCC($addr_cc); - $smtps->setBCC($addr_bcc); - $smtps->setErrorsTo($errors_to); - $smtps->setDeliveryReceipt($deliveryreceipt); - - $this->smtps=$smtps; + else if ($conf->global->MAIN_MAIL_SENDMODE == 'phpmailer') + { + // Use PHPMailer library + // ------------------------------------------ + + require_once(DOL_DOCUMENT_ROOT."/includes/phpmailer/class.phpmailer.php"); + $this->phpmailer = new PHPMailer(); + $this->phpmailer->CharSet = $conf->file->character_set_client; + + $this->phpmailer->Subject($this->encodetorfc2822($subject)); + $this->phpmailer->setTO($this->getValidAddress($to,0,1)); + $this->phpmailer->SetFrom($this->getValidAddress($from,0,1)); + + if (! empty($this->html)) + { + if (!empty($css)) + { + $this->css = $css; + $this->styleCSS = $this->buildCSS(); + } + $msg = $this->html; + $msg = $this->checkIfHTML($msg); + } + + if ($this->msgishtml) $smtps->setBodyContent($msg,'html'); + else $smtps->setBodyContent($msg,'plain'); + + if ($this->atleastoneimage) + { + foreach ($this->images_encoded as $img) + { + $smtps->setImageInline($img['image_encoded'],$img['name'],$img['content_type'],$img['cid']); + } + } + + if ($this->atleastonefile) + { + foreach ($filename_list as $i => $val) + { + $content=file_get_contents($filename_list[$i]); + $smtps->setAttachment($content,$mimefilename_list[$i],$mimetype_list[$i]); + } + } + + $smtps->setCC($addr_cc); + $smtps->setBCC($addr_bcc); + $smtps->setErrorsTo($errors_to); + $smtps->setDeliveryReceipt($deliveryreceipt); + + $this->smtps=$smtps; } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bbc54bb4471..bce43c8c5d8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3448,6 +3448,43 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='') return $out; } +/** + * Print formated messages to output (Used to show messages on html output). + * + * @param array $mesgs Messages array + * @param array $errors Errors array + * @param array $warnings Warnings array + * @return void + * + * @see dol_htmloutput_mesg + */ +function dol_htmloutput_events($mesgs=array(),$errors=array(),$warnings=array()) +{ + if (isset($_SESSION['dol_events'])) + { + if (is_array($mesgs) && isset($_SESSION['dol_events']['mesgs'])) { + $mesgs = array_merge($mesgs, $_SESSION['dol_events']['mesgs']); + } + if (is_array($errors) && isset($_SESSION['dol_events']['errors'])) { + $errors = array_merge($errors, $_SESSION['dol_events']['errors']); + } + if (is_array($warnings) && isset($_SESSION['dol_events']['warnings'])) { + $warnings = array_merge($warnings, $_SESSION['dol_events']['warnings']); + } + + unset($_SESSION['dol_events']); + } + + if (is_array($mesgs) && ! empty($mesgs)) { + dol_htmloutput_mesg('',$mesgs); + } + if (is_array($errors) && ! empty($errors)) { + dol_htmloutput_mesg('',$errors, 'error'); + } + if (is_array($warnings) && ! empty($warnings)) { + dol_htmloutput_mesg('',$warnings, 'warning'); + } +} /** * Get formated messages to output (Used to show messages on html output). @@ -3469,18 +3506,6 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb $out=''; $divstart=$divend=''; - // Use session mesg - if (isset($_SESSION['mesg'])) - { - $mesgstring=$_SESSION['mesg']; - unset($_SESSION['mesg']); - } - if (isset($_SESSION['mesgarray'])) - { - $mesgarray=$_SESSION['mesgarray']; - unset($_SESSION['mesgarray']); - } - // If inline message with no format, we add it. if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
/i',$out)) { diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index fc8c2ed7855..324c9ebb775 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -124,7 +124,7 @@ if ($action == 'add') $idl = "idl".$i; $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); if ($entrepot_id < 0) $entrepot_id=''; - + $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); if ($ret < 0) { @@ -437,7 +437,7 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile' $result=$mailfile->sendfile(); if ($result) { - $_SESSION['mesg']=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + $_SESSION['dol_events']['mesgs']=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); $error=0; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 03ecf75522c..f40b4dfa9ec 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -121,7 +121,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 94483274ef7..bc995bab264 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -122,7 +122,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/fourn/liste.php b/htdocs/fourn/liste.php index e7216a01146..2e002773441 100644 --- a/htdocs/fourn/liste.php +++ b/htdocs/fourn/liste.php @@ -37,8 +37,8 @@ $search_ville = GETPOST("search_ville"); $search_code_fournisseur = GETPOST("search_code_fournisseur"); $search_compta_fournisseur = GETPOST("search_compta_fournisseur"); $search_datec = GETPOST("search_datec"); -$search_categ = GETPOST('search_categ','int'); -$catid = GETPOST("catid",'int'); +$search_categ = GETPOST('search_categ','int'); +$catid = GETPOST("catid",'int'); // Security check $socid = GETPOST('socid','int'); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 89e2baef38a..420055a89a7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -723,10 +723,22 @@ $bcnd=array(0=>'class="impair nodrag nodrop"',1=>'class="pair nodrag nodrop"'); // Define messages variables $mesg=''; $mesgs=array(); $warning=''; $warnings=array(); $error=0; $errors=array(); -if (isset($_SESSION['dol_message'])) + +// TODO For backward compatibility, see dol_htmloutput_events() in functions.lib.php +if (isset($_SESSION['dol_events'])) { - $mesgs[]=$_SESSION['dol_message']; - unset($_SESSION['dol_message']); + if (is_array($mesgs) && isset($_SESSION['dol_events']['mesgs'])) { + $mesgs = array_merge($mesgs, $_SESSION['dol_events']['mesgs']); + } + if (is_array($errors) && isset($_SESSION['dol_events']['errors'])) { + $errors = array_merge($errors, $_SESSION['dol_events']['errors']); + $mesgs = array_merge($mesgs, $_SESSION['dol_events']['errors']); // For backward compatibility + } + if (is_array($warnings) && isset($_SESSION['dol_events']['warnings'])) { + $warnings = array_merge($warnings, $_SESSION['dol_events']['warnings']); + } + + unset($_SESSION['dol_events']); } // Constants used to defined number of lines in textarea diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index ee07aed7804..be43af054bf 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -115,7 +115,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index d2ebfa79362..c0b0119f475 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -112,7 +112,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index a5cdd9efb0e..b9ea0e4150a 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -124,7 +124,7 @@ 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); - $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_events']['mesgs'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; }