2
0
forked from Wavyzz/dolibarr

Fix: try to use another method for messages

This commit is contained in:
Regis Houssin
2012-07-28 22:07:27 +02:00
parent 8a19946e4a
commit c7bacecf10
22 changed files with 198 additions and 156 deletions

View File

@@ -113,7 +113,7 @@ 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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -89,13 +89,13 @@ $sql.= " d.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.cotisation"; $sql.= " t.libelle as type, t.cotisation";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $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.= ", ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE d.fk_adherent_type = t.rowid "; $sql.= " WHERE d.fk_adherent_type = t.rowid ";
if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$catid; if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$catid;
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$search_categ; if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
$sql.= " AND d.entity = ".$conf->entity; $sql.= " AND d.entity = ".$conf->entity;
if ($sall) if ($sall)
{ {

View File

@@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-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-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* *
@@ -28,21 +28,22 @@
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php');
require_once(DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.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."/projet/class/project.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php');
} }
$langs->load("propal"); $langs->load("propal");
if ($conf->projet->enabled) $langs->load("projects"); if (! empty($conf->projet->enabled))
$langs->load("projects");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("orders"); $langs->load("orders");
$langs->load("deliveries"); $langs->load("deliveries");
$action=GETPOST('action'); $action=GETPOST('action','alpha');
$mesg=GETPOST('mesg'); $origin=GETPOST('origin','alpha');
$originid=GETPOST('originid','int');
// 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
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
@@ -67,8 +68,6 @@ print_fiche_titre($langs->trans("NewProp"));
$form=new Form($db); $form=new Form($db);
dol_htmloutput_mesg($mesg);
// Add new proposal // Add new proposal
if ($action == 'create') if ($action == 'create')
{ {
@@ -117,16 +116,19 @@ if ($action == 'create')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
if (isset($_GET["origin"]) && $_GET["origin"] != 'project' && isset($_GET["originid"])) if ($origin != 'project' && $originid)
{ {
print '<input type="hidden" name="origin" value="'.$_GET["origin"].'">'; print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$_GET["originid"].'">'; print '<input type="hidden" name="originid" value="'.$originid.'">';
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">'.$numpr.'</td>';
print '<input type="hidden" name="ref" value="'.$numpr.'">';
print '</tr>';
// Ref customer // Ref customer
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('RefCustomer').'</td><td colspan="2">';
@@ -141,7 +143,7 @@ if ($action == 'create')
// Contacts // Contacts
print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n"; print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n";
$form->select_contacts($soc->id,$setcontact,'contactidp',1); $form->select_contacts($soc->id,'','contactidp',1);
print '</td></tr>'; print '</td></tr>';
// Ligne info remises tiers // Ligne info remises tiers
@@ -175,12 +177,12 @@ if ($action == 'create')
// What trigger creation // What trigger creation
print '<tr><td>'.$langs->trans('Source').'</td><td>'; print '<tr><td>'.$langs->trans('Source').'</td><td>';
$form->select_demand_reason($object->demand_reason,'demand_reason_id',"SRC_PROP",1); $form->select_demand_reason('','demand_reason_id',"SRC_PROP",1);
print '</td></tr>'; print '</td></tr>';
// Delivery delay // Delivery delay
print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td colspan="2">';
$form->select_availability($object->availability,'availability_id','',1); $form->select_availability('','availability_id','',1);
print '</td></tr>'; print '</td></tr>';
// Delivery date (or manufacturing) // Delivery date (or manufacturing)
@@ -213,7 +215,7 @@ if ($action == 'create')
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$projectid = 0; $projectid = 0;
if (isset($_GET["origin"]) && $_GET["origin"] == 'project') $projectid = ($_GET["originid"]?$_GET["originid"]:0); if ($origin == 'project') $projectid = ($originid?$originid:0);
print '<tr>'; print '<tr>';
print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">'; print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">';
@@ -228,7 +230,7 @@ if ($action == 'create')
} }
// Other attributes // 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 $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)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
@@ -341,6 +343,9 @@ if ($action == 'create')
print "</form>"; print "</form>";
} }
$db->close(); dol_htmloutput_events($mesgs,$errors,$warnings);
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@@ -53,8 +53,8 @@ $search_compta=GETPOST("search_compta");
// Load sale and categ filters // Load sale and categ filters
$search_sale = GETPOST("search_sale"); $search_sale = GETPOST("search_sale");
$search_categ = GETPOST("search_categ",'int'); $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
/* /*
* Actions * 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 (!$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 ($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 ($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 > 0) $sql.= " AND cs.fk_categorie = ".$catid;
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; 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_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_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))."%'"; if ($search_code) $sql.= " AND s.code_client LIKE '%".$db->escape(strtolower($search_code))."%'";

View File

@@ -555,7 +555,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes')
{ {
$object->valid($user); $object->valid($user);
$_SESSION['dol_message']='<div class="ok">'.$langs->trans("MailingSuccessfullyValidated").'</div>'; $_SESSION['dol_events']['mesgs']='<div class="ok">'.$langs->trans("MailingSuccessfullyValidated").'</div>';
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;

View File

@@ -276,14 +276,14 @@ else if ($action == 'add' && $user->rights->propale->creer)
$object->socid=$socid; $object->socid=$socid;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datep=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$date_delivery=dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); $date_delivery=dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
if (empty($datep)) if (empty($datep))
{ {
$error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>'; $_SESSION['dol_events']['errors']=$errors;
header("Location: ".DOL_URL_ROOT.'/comm/addpropal.php?socid='.$socid.'&action=create&mesg='.urlencode($mesg)); header("Location: ".DOL_URL_ROOT.'/comm/addpropal.php?socid='.$socid.'&action=create');
exit; exit;
} }
@@ -292,57 +292,57 @@ 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($_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->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;
$object->availability_id = $_POST['availability_id']; $object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = $_POST['demand_reason_id']; $object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = $_POST['fk_address']; $object->fk_delivery_address = GETPOST('fk_address');
$object->duree_validite = $_POST['duree_validite']; $object->duree_validite = GETPOST('duree_validite');
$object->cond_reglement_id = $_POST['cond_reglement_id']; $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = $_POST['mode_reglement_id']; $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->remise_percent = $_POST['remise_percent']; $object->remise_percent = GETPOST('remise_percent');
$object->remise_absolue = $_POST['remise_absolue']; $object->remise_absolue = GETPOST('remise_absolue');
$object->socid = $_POST['socid']; $object->socid = GETPOST('socid');
$object->contactid = $_POST['contactidp']; $object->contactid = GETPOST('contactidp');
$object->fk_project = $_POST['projectid']; $object->fk_project = GETPOST('projectid');
$object->modelpdf = $_POST['model']; $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note = $_POST['note']; $object->note = GETPOST('note');
$object->statut = 0; $object->statut = 0;
$id = $object->create_from($user); $id = $object->create_from($user);
} }
else else
{ {
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')).'</div>';
} }
} }
else else
{ {
$object->ref = $_POST['ref']; $object->ref = GETPOST('ref');
$object->ref_client = $_POST['ref_client']; $object->ref_client = GETPOST('ref_client');
$object->datep = $datep; $object->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;
$object->availability_id = $_POST['availability_id']; $object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = $_POST['demand_reason_id']; $object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = $_POST['fk_address']; $object->fk_delivery_address = GETPOST('fk_address');
$object->duree_validite = $_POST['duree_validite']; $object->duree_validite = GETPOST('duree_validite');
$object->cond_reglement_id = $_POST['cond_reglement_id']; $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = $_POST['mode_reglement_id']; $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->contactid = $_POST['contactidp']; $object->contactid = GETPOST('contactidp');
$object->fk_project = $_POST['projectid']; $object->fk_project = GETPOST('projectid');
$object->modelpdf = $_POST['model']; $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note = $_POST['note']; $object->note = GETPOST('note');
$object->origin = $_POST['origin']; $object->origin = GETPOST('origin');
$object->origin_id = $_POST['originid']; $object->origin_id = GETPOST('originid');
for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) 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; $error=0;
// Insertion contact par defaut si defini // 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) if ($result > 0)
{ {

View File

@@ -125,7 +125,7 @@ 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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -43,8 +43,8 @@ $search_nom = GETPOST("search_nom");
$search_ville = GETPOST("search_ville"); $search_ville = GETPOST("search_ville");
$search_departement = GETPOST("search_departement"); $search_departement = GETPOST("search_departement");
$search_datec = GETPOST("search_datec"); $search_datec = GETPOST("search_datec");
$search_categ = GETPOST("search_categ",'int'); $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'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 ($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 ($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 (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm;
if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid; if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid;
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; 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_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_ville) $sql .= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'";
if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'"; if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'";

View File

@@ -122,7 +122,7 @@ 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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -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); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
if ($mailfile->error) if ($mailfile->error)
{ {
$mesg='<div class="error">'.$mailfile->error.'</div>'; $mesgs[]='<div class="error">'.$mailfile->error.'</div>';
} }
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 " $mesgs[]=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
$error=0; $error=0;
@@ -1471,7 +1471,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
{ {
// 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
$_SESSION['dol_message'] = $mesg; $_SESSION['dol_events']['mesgs'] = $mesgs;
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id);
exit; exit;
} }

View File

@@ -125,7 +125,7 @@ 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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -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). $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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }

View File

@@ -286,56 +286,56 @@ class CMailFile
$this->smtps=$smtps; $this->smtps=$smtps;
} }
// TODO not stable, in progress // TODO not stable, in progress
else if ($conf->global->MAIN_MAIL_SENDMODE == 'phpmailer') else if ($conf->global->MAIN_MAIL_SENDMODE == 'phpmailer')
{ {
// Use PHPMailer library // Use PHPMailer library
// ------------------------------------------ // ------------------------------------------
require_once(DOL_DOCUMENT_ROOT."/includes/phpmailer/class.phpmailer.php"); require_once(DOL_DOCUMENT_ROOT."/includes/phpmailer/class.phpmailer.php");
$this->phpmailer = new PHPMailer(); $this->phpmailer = new PHPMailer();
$this->phpmailer->CharSet = $conf->file->character_set_client; $this->phpmailer->CharSet = $conf->file->character_set_client;
$this->phpmailer->Subject($this->encodetorfc2822($subject)); $this->phpmailer->Subject($this->encodetorfc2822($subject));
$this->phpmailer->setTO($this->getValidAddress($to,0,1)); $this->phpmailer->setTO($this->getValidAddress($to,0,1));
$this->phpmailer->SetFrom($this->getValidAddress($from,0,1)); $this->phpmailer->SetFrom($this->getValidAddress($from,0,1));
if (! empty($this->html)) if (! empty($this->html))
{ {
if (!empty($css)) if (!empty($css))
{ {
$this->css = $css; $this->css = $css;
$this->styleCSS = $this->buildCSS(); $this->styleCSS = $this->buildCSS();
} }
$msg = $this->html; $msg = $this->html;
$msg = $this->checkIfHTML($msg); $msg = $this->checkIfHTML($msg);
} }
if ($this->msgishtml) $smtps->setBodyContent($msg,'html'); if ($this->msgishtml) $smtps->setBodyContent($msg,'html');
else $smtps->setBodyContent($msg,'plain'); else $smtps->setBodyContent($msg,'plain');
if ($this->atleastoneimage) if ($this->atleastoneimage)
{ {
foreach ($this->images_encoded as $img) foreach ($this->images_encoded as $img)
{ {
$smtps->setImageInline($img['image_encoded'],$img['name'],$img['content_type'],$img['cid']); $smtps->setImageInline($img['image_encoded'],$img['name'],$img['content_type'],$img['cid']);
} }
} }
if ($this->atleastonefile) if ($this->atleastonefile)
{ {
foreach ($filename_list as $i => $val) foreach ($filename_list as $i => $val)
{ {
$content=file_get_contents($filename_list[$i]); $content=file_get_contents($filename_list[$i]);
$smtps->setAttachment($content,$mimefilename_list[$i],$mimetype_list[$i]); $smtps->setAttachment($content,$mimefilename_list[$i],$mimetype_list[$i]);
} }
} }
$smtps->setCC($addr_cc); $smtps->setCC($addr_cc);
$smtps->setBCC($addr_bcc); $smtps->setBCC($addr_bcc);
$smtps->setErrorsTo($errors_to); $smtps->setErrorsTo($errors_to);
$smtps->setDeliveryReceipt($deliveryreceipt); $smtps->setDeliveryReceipt($deliveryreceipt);
$this->smtps=$smtps; $this->smtps=$smtps;
} }
else else
{ {

View File

@@ -3448,6 +3448,43 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
return $out; 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). * 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=''; $out='';
$divstart=$divend=''; $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 inline message with no format, we add it.
if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/<div class=".*">/i',$out)) if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/<div class=".*">/i',$out))
{ {

View File

@@ -124,7 +124,7 @@ if ($action == 'add')
$idl = "idl".$i; $idl = "idl".$i;
$entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
if ($entrepot_id < 0) $entrepot_id=''; if ($entrepot_id < 0) $entrepot_id='';
$ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int'));
if ($ret < 0) if ($ret < 0)
{ {
@@ -437,7 +437,7 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result) 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; $error=0;

View File

@@ -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). $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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -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). $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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -37,8 +37,8 @@ $search_ville = GETPOST("search_ville");
$search_code_fournisseur = GETPOST("search_code_fournisseur"); $search_code_fournisseur = GETPOST("search_code_fournisseur");
$search_compta_fournisseur = GETPOST("search_compta_fournisseur"); $search_compta_fournisseur = GETPOST("search_compta_fournisseur");
$search_datec = GETPOST("search_datec"); $search_datec = GETPOST("search_datec");
$search_categ = GETPOST('search_categ','int'); $search_categ = GETPOST('search_categ','int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
// Security check // Security check
$socid = GETPOST('socid','int'); $socid = GETPOST('socid','int');

View File

@@ -723,10 +723,22 @@ $bcnd=array(0=>'class="impair nodrag nodrop"',1=>'class="pair nodrag nodrop"');
// Define messages variables // Define messages variables
$mesg=''; $mesgs=array(); $warning=''; $warnings=array(); $error=0; $errors=array(); $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']; if (is_array($mesgs) && isset($_SESSION['dol_events']['mesgs'])) {
unset($_SESSION['dol_message']); $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 // Constants used to defined number of lines in textarea

View File

@@ -115,7 +115,7 @@ 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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }

View File

@@ -112,7 +112,7 @@ 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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }

View File

@@ -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). $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);
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }