mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-08 18:48:22 +01:00
New: task #10538: Add filter on expiration date of subscription for foundation module email selector.
Fix: Postgresql compatibility.
This commit is contained in:
@@ -5,6 +5,9 @@ English Dolibarr ChangeLog
|
|||||||
For users:
|
For users:
|
||||||
- New: When sending supplier orders by mail, a text is predefined.
|
- New: When sending supplier orders by mail, a text is predefined.
|
||||||
- New: Upgrade process works with Postgresql.
|
- New: Upgrade process works with Postgresql.
|
||||||
|
- New: Task #10538: Add filter on expiration date of subscription for
|
||||||
|
foundation module email selector.
|
||||||
|
- Fix: Better Postgresql compatibility.
|
||||||
|
|
||||||
For developer:
|
For developer:
|
||||||
- Qual: Renamed some fields into database to be more internationnal.
|
- Qual: Renamed some fields into database to be more internationnal.
|
||||||
|
|||||||
@@ -83,9 +83,12 @@ if ($_GET["action"] == 'add')
|
|||||||
{
|
{
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
|
||||||
|
// We fill $filtersarray. Using this variable is now deprecated.
|
||||||
|
// Kept for backward compatibility.
|
||||||
$filtersarray=array();
|
$filtersarray=array();
|
||||||
if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"];
|
if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"];
|
||||||
|
|
||||||
|
// Add targets into database
|
||||||
$obj = new $classname($db);
|
$obj = new $classname($db);
|
||||||
$result=$obj->add_to_target($_GET["rowid"],$filtersarray);
|
$result=$obj->add_to_target($_GET["rowid"],$filtersarray);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,10 +196,12 @@ class mailing_dolibarr_services_expired extends MailingTargets
|
|||||||
*/
|
*/
|
||||||
function formFilter()
|
function formFilter()
|
||||||
{
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
$s.='<select name="filter" class="flat">';
|
$s.='<select name="filter" class="flat">';
|
||||||
$s.='<option value="0"> </option>';
|
if (sizeof($this->arrayofproducts)) $s.='<option value="0"> </option>';
|
||||||
|
else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
||||||
foreach($this->arrayofproducts as $key => $val)
|
foreach($this->arrayofproducts as $key => $val)
|
||||||
{
|
{
|
||||||
$s.='<option value="'.$key.'">'.$val.'</option>';
|
$s.='<option value="'.$key.'">'.$val.'</option>';
|
||||||
|
|||||||
@@ -21,16 +21,17 @@
|
|||||||
/**
|
/**
|
||||||
\file htdocs/includes/modules/mailings/fraise.modules.php
|
\file htdocs/includes/modules/mailings/fraise.modules.php
|
||||||
\ingroup mailing
|
\ingroup mailing
|
||||||
\brief Fichier de la classe permettant de g<>n<EFBFBD>rer la liste de destinataires Fraise
|
\brief File of class to generate target according to rule Fraise
|
||||||
\version $Id$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
|
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class mailing_fraise
|
* \class mailing_fraise
|
||||||
* \brief Classe permettant de generer la liste des destinataires Fraise
|
* \brief Class to generate target according to rule Fraise
|
||||||
*/
|
*/
|
||||||
class mailing_fraise extends MailingTargets
|
class mailing_fraise extends MailingTargets
|
||||||
{
|
{
|
||||||
@@ -97,13 +98,23 @@ class mailing_fraise extends MailingTargets
|
|||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("members");
|
$langs->load("members");
|
||||||
|
|
||||||
|
$form=new Form($this->db);
|
||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
|
$s.=$langs->trans("Status").': ';
|
||||||
$s.='<select name="filter" class="flat">';
|
$s.='<select name="filter" class="flat">';
|
||||||
|
$s.='<option value="none"> </option>';
|
||||||
$s.='<option value="-1">'.$langs->trans("MemberStatusDraft").'</option>';
|
$s.='<option value="-1">'.$langs->trans("MemberStatusDraft").'</option>';
|
||||||
$s.='<option value="1a">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusPaidShort").')</option>';
|
$s.='<option value="1a">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusPaidShort").')</option>';
|
||||||
$s.='<option value="1b">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusActiveLateShort").')</option>';
|
$s.='<option value="1b">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusActiveLateShort").')</option>';
|
||||||
$s.='<option value="0">'.$langs->trans("MemberStatusResiliatedShort").'</option>';
|
$s.='<option value="0">'.$langs->trans("MemberStatusResiliatedShort").'</option>';
|
||||||
$s.='</select>';
|
$s.='</select>';
|
||||||
|
$s.='<br>';
|
||||||
|
$s.=$langs->trans("DateEndSubscription").': ';
|
||||||
|
$s.=$langs->trans("After").' > '.$form->select_date(-1,'subscriptionafter',0,0,1,'fraise',1,0,1,0);
|
||||||
|
$s.=' ';
|
||||||
|
$s.=$langs->trans("Before").' < '.$form->select_date(-1,'subscriptionbefore',0,0,1,'fraise',1,0,1,0);
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,16 +131,20 @@ class mailing_fraise extends MailingTargets
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute destinataires dans table des cibles
|
* \brief Ajoute destinataires dans table des cibles
|
||||||
* \param mailing_id Id du mailing concern<EFBFBD>
|
* \param mailing_id Id du mailing concerne
|
||||||
* \param filterarray Requete sql de selection des destinataires
|
* \param filterarray Param to filter sql request. Deprecated. Should use $_POST instead.
|
||||||
* \return int < 0 si erreur, nb ajout si ok
|
* \return int < 0 si erreur, nb ajout si ok
|
||||||
*/
|
*/
|
||||||
function add_to_target($mailing_id,$filtersarray=array())
|
function add_to_target($mailing_id,$filtersarray=array())
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs,$_POST;
|
||||||
$langs->load("members");
|
$langs->load("members");
|
||||||
|
|
||||||
$cibles = array();
|
$cibles = array();
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
|
$dateendsubscriptionafter=dol_mktime($_POST['subscriptionafterhour'],$_POST['subscriptionaftermin'],$_POST['subscriptionaftersec'],$_POST['subscriptionaftermonth'],$_POST['subscriptionafterday'],$_POST['subscriptionafteryear']);
|
||||||
|
$dateendsubscriptionbefore=dol_mktime($_POST['subscriptionbeforehour'],$_POST['subscriptionbeforemin'],$_POST['subscriptionbeforesec'],$_POST['subscriptionbeforemonth'],$_POST['subscriptionbeforeday'],$_POST['subscriptionbeforeyear']);
|
||||||
|
|
||||||
// La requete doit retourner: id, email, fk_contact, name, firstname
|
// La requete doit retourner: id, email, fk_contact, name, firstname
|
||||||
$sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, ";
|
$sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, ";
|
||||||
@@ -137,16 +152,17 @@ class mailing_fraise extends MailingTargets
|
|||||||
$sql.= " a.datefin"; // Other fields
|
$sql.= " a.datefin"; // Other fields
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||||
$sql.= " WHERE a.email IS NOT NULL";
|
$sql.= " WHERE a.email IS NOT NULL";
|
||||||
foreach($filtersarray as $key)
|
if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1";
|
||||||
{
|
if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND datefin >= '".$this->db->idate($now)."'";
|
||||||
if ($key == '-1') $sql.= " AND a.statut=-1";
|
if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND datefin < '".$this->db->idate($now)."'";
|
||||||
if ($key == '1a') $sql.= " AND a.statut=1 AND datefin >= ".$this->db->idate(mktime());
|
if (isset($_POST["filter"]) && $_POST["filter"] == '0') $sql.= " AND a.statut=0";
|
||||||
if ($key == '1b') $sql.= " AND a.statut=1 AND datefin < ".$this->db->idate(mktime());
|
if ($dateendsubscriptionafter > 0) $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
|
||||||
if ($key == '0') $sql.= " AND a.statut=0";
|
if ($dateendsubscriptionbefore > 0) $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
|
||||||
}
|
|
||||||
$sql.= " ORDER BY a.email";
|
$sql.= " ORDER BY a.email";
|
||||||
|
//print $sql;
|
||||||
|
|
||||||
// Stocke destinataires dans cibles
|
// Add targets into table
|
||||||
|
dol_syslog("fraise.modules.php sql=".$sql);
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ class mailing_framboise extends MailingTargets
|
|||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
$s.='<select name="filter" class="flat">';
|
$s.='<select name="filter" class="flat">';
|
||||||
$s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
|
||||||
|
|
||||||
# Show categories
|
# Show categories
|
||||||
$sql = "SELECT rowid, label, type, visible";
|
$sql = "SELECT rowid, label, type, visible";
|
||||||
@@ -177,6 +176,10 @@ class mailing_framboise extends MailingTargets
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
if ($num) $s.='<option value="0"> </option>';
|
||||||
|
else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ class mailing_kiwi extends MailingTargets
|
|||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
$s.='<select name="filter" class="flat">';
|
$s.='<select name="filter" class="flat">';
|
||||||
$s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
|
||||||
|
|
||||||
# Show categories
|
# Show categories
|
||||||
$sql = "SELECT rowid, label, type, visible";
|
$sql = "SELECT rowid, label, type, visible";
|
||||||
@@ -177,6 +176,10 @@ class mailing_kiwi extends MailingTargets
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
if ($num) $s.='<option value="0"> </option>';
|
||||||
|
else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -144,12 +144,11 @@ class MailingTargets
|
|||||||
$sql .= " nom, prenom, email, other, url)";
|
$sql .= " nom, prenom, email, other, url)";
|
||||||
$sql .= " VALUES (".$mailing_id.",";
|
$sql .= " VALUES (".$mailing_id.",";
|
||||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||||
$sql .= "'".addslashes($cibles[$i]['name'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||||
$sql .= "'".addslashes($cibles[$i]['firstname'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||||
$sql .= "'".addslashes($cibles[$i]['email'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||||
$sql .= "'".addslashes($cibles[$i]['other'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||||
$sql .= "'".addslashes($cibles[$i]['url'])."')";
|
$sql .= "'".$this->db->escape($cibles[$i]['url'])."')";
|
||||||
|
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -109,8 +109,6 @@ class mailing_poire extends MailingTargets
|
|||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
$s.='<select name="filter" class="flat">';
|
$s.='<select name="filter" class="flat">';
|
||||||
$s.='<option value="all">'.$langs->trans("ContactsAllShort").'</option>';
|
|
||||||
$s.='<option value="prospects">'.$langs->trans("ThirdPartyProspects").'</option>';
|
|
||||||
# Add prospect of a particular level
|
# Add prospect of a particular level
|
||||||
$sql = "SELECT code, label";
|
$sql = "SELECT code, label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||||
@@ -120,6 +118,10 @@ class mailing_poire extends MailingTargets
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
|
if ($num) $s.='<option value="all"> </option>';
|
||||||
|
else $s.='<option value="all">'.$langs->trans("ContactsAllShort").'</option>';
|
||||||
|
$s.='<option value="prospects">'.$langs->trans("ThirdPartyProspects").'</option>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ class DoliDb
|
|||||||
*/
|
*/
|
||||||
function escape($stringtoencode)
|
function escape($stringtoencode)
|
||||||
{
|
{
|
||||||
return addslashes($stringtoencode);
|
return pg_escape_string($stringtoencode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user