mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-08 10:38:15 +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:
|
||||
- New: When sending supplier orders by mail, a text is predefined.
|
||||
- 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:
|
||||
- Qual: Renamed some fields into database to be more internationnal.
|
||||
|
||||
@@ -83,9 +83,12 @@ if ($_GET["action"] == 'add')
|
||||
{
|
||||
require_once($file);
|
||||
|
||||
// We fill $filtersarray. Using this variable is now deprecated.
|
||||
// Kept for backward compatibility.
|
||||
$filtersarray=array();
|
||||
if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"];
|
||||
|
||||
// Add targets into database
|
||||
$obj = new $classname($db);
|
||||
$result=$obj->add_to_target($_GET["rowid"],$filtersarray);
|
||||
}
|
||||
|
||||
@@ -196,10 +196,12 @@ class mailing_dolibarr_services_expired extends MailingTargets
|
||||
*/
|
||||
function formFilter()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$s='';
|
||||
$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)
|
||||
{
|
||||
$s.='<option value="'.$key.'">'.$val.'</option>';
|
||||
|
||||
@@ -21,16 +21,17 @@
|
||||
/**
|
||||
\file htdocs/includes/modules/mailings/fraise.modules.php
|
||||
\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$
|
||||
*/
|
||||
|
||||
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
|
||||
* \brief Classe permettant de generer la liste des destinataires Fraise
|
||||
* \brief Class to generate target according to rule Fraise
|
||||
*/
|
||||
class mailing_fraise extends MailingTargets
|
||||
{
|
||||
@@ -97,13 +98,23 @@ class mailing_fraise extends MailingTargets
|
||||
global $langs;
|
||||
$langs->load("members");
|
||||
|
||||
$form=new Form($this->db);
|
||||
|
||||
$s='';
|
||||
$s.=$langs->trans("Status").': ';
|
||||
$s.='<select name="filter" class="flat">';
|
||||
$s.='<option value="none"> </option>';
|
||||
$s.='<option value="-1">'.$langs->trans("MemberStatusDraft").'</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="0">'.$langs->trans("MemberStatusResiliatedShort").'</option>';
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -120,16 +131,20 @@ class mailing_fraise extends MailingTargets
|
||||
|
||||
/**
|
||||
* \brief Ajoute destinataires dans table des cibles
|
||||
* \param mailing_id Id du mailing concern<EFBFBD>
|
||||
* \param filterarray Requete sql de selection des destinataires
|
||||
* \param mailing_id Id du mailing concerne
|
||||
* \param filterarray Param to filter sql request. Deprecated. Should use $_POST instead.
|
||||
* \return int < 0 si erreur, nb ajout si ok
|
||||
*/
|
||||
function add_to_target($mailing_id,$filtersarray=array())
|
||||
{
|
||||
global $langs;
|
||||
global $langs,$_POST;
|
||||
$langs->load("members");
|
||||
|
||||
$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
|
||||
$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.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||
$sql.= " WHERE a.email IS NOT NULL";
|
||||
foreach($filtersarray as $key)
|
||||
{
|
||||
if ($key == '-1') $sql.= " AND a.statut=-1";
|
||||
if ($key == '1a') $sql.= " AND a.statut=1 AND datefin >= ".$this->db->idate(mktime());
|
||||
if ($key == '1b') $sql.= " AND a.statut=1 AND datefin < ".$this->db->idate(mktime());
|
||||
if ($key == '0') $sql.= " AND a.statut=0";
|
||||
}
|
||||
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 (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND datefin < '".$this->db->idate($now)."'";
|
||||
if (isset($_POST["filter"]) && $_POST["filter"] == '0') $sql.= " AND a.statut=0";
|
||||
if ($dateendsubscriptionafter > 0) $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
|
||||
if ($dateendsubscriptionbefore > 0) $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
|
||||
$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);
|
||||
if ($result)
|
||||
{
|
||||
|
||||
@@ -162,7 +162,6 @@ class mailing_framboise extends MailingTargets
|
||||
|
||||
$s='';
|
||||
$s.='<select name="filter" class="flat">';
|
||||
$s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
||||
|
||||
# Show categories
|
||||
$sql = "SELECT rowid, label, type, visible";
|
||||
@@ -177,6 +176,10 @@ class mailing_framboise extends MailingTargets
|
||||
if ($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;
|
||||
while ($i < $num)
|
||||
{
|
||||
|
||||
@@ -162,7 +162,6 @@ class mailing_kiwi extends MailingTargets
|
||||
|
||||
$s='';
|
||||
$s.='<select name="filter" class="flat">';
|
||||
$s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
|
||||
|
||||
# Show categories
|
||||
$sql = "SELECT rowid, label, type, visible";
|
||||
@@ -177,6 +176,10 @@ class mailing_kiwi extends MailingTargets
|
||||
if ($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;
|
||||
while ($i < $num)
|
||||
{
|
||||
|
||||
@@ -144,12 +144,11 @@ class MailingTargets
|
||||
$sql .= " nom, prenom, email, other, url)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||
$sql .= "'".addslashes($cibles[$i]['name'])."',";
|
||||
$sql .= "'".addslashes($cibles[$i]['firstname'])."',";
|
||||
$sql .= "'".addslashes($cibles[$i]['email'])."',";
|
||||
$sql .= "'".addslashes($cibles[$i]['other'])."',";
|
||||
$sql .= "'".addslashes($cibles[$i]['url'])."')";
|
||||
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['url'])."')";
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
|
||||
@@ -109,8 +109,6 @@ class mailing_poire extends MailingTargets
|
||||
|
||||
$s='';
|
||||
$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
|
||||
$sql = "SELECT code, label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
|
||||
@@ -120,6 +118,10 @@ class mailing_poire extends MailingTargets
|
||||
if ($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;
|
||||
while ($i < $num)
|
||||
{
|
||||
|
||||
@@ -623,7 +623,7 @@ class DoliDb
|
||||
*/
|
||||
function escape($stringtoencode)
|
||||
{
|
||||
return addslashes($stringtoencode);
|
||||
return pg_escape_string($stringtoencode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user