diff --git a/ChangeLog b/ChangeLog index 148e8fa1df3..60de63f63ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ For users: - New: Can use a cache for xcal exports. - New: Option for faster confirmation process with one ajax popup. - New: Complete theme bluelagoon and rodolphe +- New: Can select third parties emails in emailing module for all + third parties with expired contract's lines. - Fix: Customer code was not correct on PDF it if contains special characters. - Fix: Can update price even with "NPR" VAT rates. diff --git a/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php b/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php new file mode 100644 index 00000000000..9e2452dbf6e --- /dev/null +++ b/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php @@ -0,0 +1,209 @@ + + * + * This file is an example to follow to add your own email selector inside + * the Dolibarr email tool. + * Follow instructions given in README file to know what to change to build + * your own emailing list selector. + * Code that need to be changed in this file are marked by "CHANGE THIS" tag. + */ + +include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'; + + +class mailing_dolibarr_services_expired extends MailingTargets +{ + var $name='DolibarrContractsLinesExpired'; + var $desc='Third parties with expired contract\'s lines'; + var $require_admin=0; + + var $require_module=array('contrat'); + var $picto='company'; + var $db; + var $arrayofproducts=array(); + + + function mailing_dolibarr_services_expired($DB) + { + $this->db=$DB; + + $this->arrayofproducts=array(); + + // List of services + $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE fk_product_type = 1"; + $sql.= " ORDER BY ref"; + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + dolibarr_syslog("dolibarr_services_expired.modules.php:mailing_dolibarr_services_expired ".$num." services found"); + + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + $i++; + $this->arrayofproducts[$i]=$obj->ref; + } + + } + else + { + dol_print_error($this->db); + } + } + + + /** + * \brief This is the main function that returns the array of emails + * \param mailing_id Id of mailing. No need to use it. + * \param filterarray If you used the formFilter function. Empty otherwise. + * \return int <0 if error, number of emails added if ok + */ + function add_to_target($mailing_id,$filtersarray=array()) + { + $target = array(); + + // ----- Your code start here ----- + + $cibles = array(); + $j = 0; + + $product=''; + foreach($filtersarray as $key) + { + if ($key == '0') return "Error: You must choose a filter"; + $product=$this->arrayofproducts[$key]; + } + + // La requete doit retourner: id, email, name + $sql = " select s.rowid, s.email, s.nom as name, cd.rowid as cdid, cd.date_ouverture, cd.date_fin_validite, cd.fk_contrat"; + $sql.= " from ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c,"; + $sql.= " ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; + $sql.= " where s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; + $sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid AND p.ref = '".$product."'"; + $sql.= " AND cd.date_fin_validite < '".$this->db->idate(gmmktime())."'"; + $sql.= " ORDER BY s.email"; + + // Stocke destinataires dans cibles + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + dolibarr_syslog("dolibarr_services_expired.modules.php:add_to_target ".$num." targets found"); + + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $cibles[$j] = array( + 'email' => $obj->email, + 'name' => $obj->name, + 'id' => $obj->id, + 'other' => dol_print_date($this->db->jdate($obj->date_ouverture),'day').';'.dol_print_date($this->db->jdate($obj->date_fin_validite),'day').';'.$obj->fk_contrat.';'.$obj->cdid, + 'url' => $this->url($obj->rowid) + ); + $old = $obj->email; + $j++; + } + + $i++; + } + } + else + { + dolibarr_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } + + // ----- Your code end here ----- + + return parent::add_to_target($mailing_id, $cibles); + } + + + /** + * \brief On the main mailing area, there is a box with statistics. + * If you want to add a line in this report you must provide an + * array of SQL request that returns two field: + * One called "label", One called "nb". + * \return array + */ + function getSqlArrayForStats() + { + + //var $statssql=array(); + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + + return array(); + } + + + /** + * \brief Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * \return int + */ + function getNbOfRecipients($filter=1,$option='') + { + + // Example: return parent::getNbOfRecipients("SELECT count(*) as nb from dolibarr_table"); + // Example: return 500; + $sql = " select count(*) as nb"; + $sql.= " from ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c,"; + $sql.= " ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; + $sql.= " where s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; + $sql.= " AND cd.statut= 4 AND cd.fk_product=p.rowid"; + $sql.= " AND p.ref in ('".join("','",$this->arrayofproducts)."')"; + $sql.= " AND cd.date_fin_validite < '".$this->db->idate(gmmktime())."'"; + $sql.= " ORDER BY s.email"; + //print $sql; + $a=parent::getNbOfRecipients($sql); + + return $a; + } + + /** + * \brief This is to add a form filter to provide variant of selector + * If used, the HTML select must be called "filter" + * \return string A html select zone + */ + function formFilter() + { + + $s=''; + $s.=''; + return $s; + } + + + /** + * \brief Can include an URL link on each record provided by selector + * shown on target page. + * \return string Url link + */ + function url($id) + { + //$companystatic=new Societe($this->db); + //$companystatic->id=$id; + //$companystatic->nom=''; + //return $companystatic->getNomUrl(1); // Url too long + return ''.img_object('',"company").''; + } + +} + +?> diff --git a/htdocs/includes/modules/mailings/kiwi.modules.php b/htdocs/includes/modules/mailings/kiwi.modules.php index 1f4d6de0cb7..3cb03e6219a 100644 --- a/htdocs/includes/modules/mailings/kiwi.modules.php +++ b/htdocs/includes/modules/mailings/kiwi.modules.php @@ -10,11 +10,11 @@ */ /** - \file htdocs/includes/modules/mailings/kiwi.modules.php - \ingroup mailing - \brief Example file to provide a list of recipients for mailing module - \version $Revision$ -*/ + \file htdocs/includes/modules/mailings/kiwi.modules.php + \ingroup mailing + \brief Example file to provide a list of recipients for mailing module + \version $Revision$ + */ include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'; @@ -26,39 +26,39 @@ include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php' class mailing_kiwi extends MailingTargets { // CHANGE THIS: Put here a name not already used - var $name='ContactsCategories'; - // CHANGE THIS: Put here a description of your selector module. - // This label is used if no translation found for key MailingModuleDescXXX where XXX=name is found - var $desc="Third parties (by categories)"; + var $name='ContactsCategories'; + // CHANGE THIS: Put here a description of your selector module. + // This label is used if no translation found for key MailingModuleDescXXX where XXX=name is found + var $desc="Third parties (by categories)"; // CHANGE THIS: Set to 1 if selector is available for admin users only - var $require_admin=0; + var $require_admin=0; - var $require_module=array("categorie"); - var $picto='company'; - var $db; + var $require_module=array("categorie"); + var $picto='company'; + var $db; - // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector - function mailing_categories($DB) - { - $this->db=$DB; - } + // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector + function mailing_categories($DB) + { + $this->db=$DB; + } - /** - * \brief This is the main function that returns the array of emails - * \param mailing_id Id of mailing. No need to use it. - * \param filterarray If you used the formFilter function. Empty otherwise. - * \return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf, $langs; + /** + * \brief This is the main function that returns the array of emails + * \param mailing_id Id of mailing. No need to use it. + * \param filterarray If you used the formFilter function. Empty otherwise. + * \return int <0 if error, number of emails added if ok + */ + function add_to_target($mailing_id,$filtersarray=array()) + { + global $conf, $langs; - $cibles = array(); - - // CHANGE THIS - // Select the contacts from category + $cibles = array(); + + // CHANGE THIS + // Select the contacts from category $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname,"; if ($_POST['filter']) $sql.= " llx_categorie.label as label"; else $sql.=" null as label"; @@ -68,51 +68,51 @@ class mailing_kiwi extends MailingTargets $sql.= " WHERE s.email != ''"; $sql.= " AND s.entity = ".$conf->entity; if ($_POST['filter']) $sql.= " AND llx_categorie.rowid='".$_POST['filter']."'"; - $sql.= " ORDER BY s.email"; + $sql.= " ORDER BY s.email"; - // Stocke destinataires dans cibles - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - $j = 0; + // Stocke destinataires dans cibles + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + $j = 0; - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $cibles[$j] = array( + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''), 'url' => $this->url($obj->id) - ); - $old = $obj->email; - $j++; - } - - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } - - return parent::add_to_target($mailing_id, $cibles); - } + ); + $old = $obj->email; + $j++; + } + + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } + + return parent::add_to_target($mailing_id, $cibles); + } - /** + /** * \brief On the main mailing area, there is a box with statistics. * If you want to add a line in this report you must provide an * array of SQL request that returns two field: @@ -121,92 +121,92 @@ class mailing_kiwi extends MailingTargets */ function getSqlArrayForStats() { - // CHANGE THIS: Optionnal + // CHANGE THIS: Optionnal //var $statssql=array(); - //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; return array(); } - /* - * \brief Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. - * \return int - */ - function getNbOfRecipients() - { - global $conf; - - $sql = "SELECT count(distinct(s.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.email != ''"; - $sql.= " AND s.entity = ".$conf->entity; + /* + * \brief Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * \return int + */ + function getNbOfRecipients() + { + global $conf; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } + $sql = "SELECT count(distinct(s.email)) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.email != ''"; + $sql.= " AND s.entity = ".$conf->entity; - /** - * \brief This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter" - * \return string A html select zone - */ - function formFilter() - { - global $conf, $langs; + // La requete doit retourner un champ "nb" pour etre comprise + // par parent::getNbOfRecipients + return parent::getNbOfRecipients($sql); + } - $s=''; - $s.=''; $s.=''; - # Show categories - $sql = "SELECT rowid, label, type"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE visible > 0 AND type > 0"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " ORDER BY label"; + # Show categories + $sql = "SELECT rowid, label, type"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE visible > 0 AND type > 0"; + $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY label"; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - $type=''; - if ($obj->type == 1) $type=$langs->trans("Supplier"); - if ($obj->type == 2) $type=$langs->trans("Customer"); - $s.=''; + $type=''; + if ($obj->type == 1) $type=$langs->trans("Supplier"); + if ($obj->type == 2) $type=$langs->trans("Customer"); + $s.=''; $i++; } } - $s.=''; - return $s; + $s.=''; + return $s; - } + } - /** - * \brief Can include an URL link on each record provided by selector - * shown on target page. - * \return string Url link - */ - function url($id) - { - //$companystatic=new Societe($this->db); - //$companystatic->id=$id; - //$companystatic->nom=''; - //return $companystatic->getNomUrl(1); // Url too long - return ''.img_object('',"company").''; - } + /** + * \brief Can include an URL link on each record provided by selector + * shown on target page. + * \return string Url link + */ + function url($id) + { + //$companystatic=new Societe($this->db); + //$companystatic->id=$id; + //$companystatic->nom=''; + //return $companystatic->getNomUrl(1); // Url too long + return ''.img_object('',"company").''; + } } diff --git a/htdocs/includes/modules/mailings/poire.modules.php b/htdocs/includes/modules/mailings/poire.modules.php index c7d931de831..63f9e321792 100644 --- a/htdocs/includes/modules/mailings/poire.modules.php +++ b/htdocs/includes/modules/mailings/poire.modules.php @@ -20,146 +20,146 @@ */ /** - \file htdocs/includes/modules/mailings/poire.modules.php - \ingroup mailing - \brief Fichier de la classe permettant de générer la liste de destinataires Poire - \version $Id$ -*/ + \file htdocs/includes/modules/mailings/poire.modules.php + \ingroup mailing + \brief Fichier de la classe permettant de g�n�rer la liste de destinataires Poire + \version $Id$ + */ include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'; /** - \class mailing_poire - \brief Classe permettant de générer la liste des destinataires Poire -*/ + \class mailing_poire + \brief Classe permettant de g�n�rer la liste des destinataires Poire + */ class mailing_poire extends MailingTargets { - var $name='ContactCompanies'; // Identifiant du module mailing - var $desc='Contacts des tiers (prospects, clients, fournisseurs...)'; // Libellé utilisé si aucune traduction pour MailingModuleDescXXX ou XXX=name trouvée - var $require_module=array("commercial"); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='contact'; + var $name='ContactCompanies'; // Identifiant du module mailing + var $desc='Contacts des tiers (prospects, clients, fournisseurs...)'; // Libell� utilis� si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + var $require_module=array("societe"); // Module mailing actif si modules require_module actifs + var $require_admin=0; // Module mailing actif pour user admin ou non + var $picto='contact'; - var $db; + var $db; - function mailing_poire($DB) - { - $this->db=$DB; - } + function mailing_poire($DB) + { + $this->db=$DB; + } function getSqlArrayForStats() { global $conf, $langs; - - $langs->load("commercial"); - $statssql=array(); - $statssql[0] = "SELECT '".$langs->trans("NbOfCompaniesContacts")."' as label"; - $statssql[0].= ", count(distinct(c.email)) as nb"; - $statssql[0].= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $statssql[0].= ", ".MAIN_DB_PREFIX."societe as s"; - $statssql[0].= " WHERE s.rowid = c.fk_soc"; - $statssql[0].= " AND s.entity = ".$conf->entity; - $statssql[0].= " AND c.entity = ".$conf->entity; - $statssql[0].= " AND s.client = 1"; - $statssql[0].= " AND c.email != ''"; + $langs->load("commercial"); + + $statssql=array(); + $statssql[0] = "SELECT '".$langs->trans("NbOfCompaniesContacts")."' as label"; + $statssql[0].= ", count(distinct(c.email)) as nb"; + $statssql[0].= " FROM ".MAIN_DB_PREFIX."socpeople as c"; + $statssql[0].= ", ".MAIN_DB_PREFIX."societe as s"; + $statssql[0].= " WHERE s.rowid = c.fk_soc"; + $statssql[0].= " AND s.entity = ".$conf->entity; + $statssql[0].= " AND c.entity = ".$conf->entity; + $statssql[0].= " AND s.client = 1"; + $statssql[0].= " AND c.email != ''"; return $statssql; } - /** - * \brief Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. - * \return int - */ - function getNbOfRecipients() - { - global $conf; - - $sql = "SELECT count(distinct(c.email)) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.rowid = c.fk_soc"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND s.entity = ".$conf->entity; - $sql .= " AND c.email != ''"; + /** + * \brief Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * \return int + */ + function getNbOfRecipients() + { + global $conf; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } + $sql = "SELECT count(distinct(c.email)) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid = c.fk_soc"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND s.entity = ".$conf->entity; + $sql .= " AND c.email != ''"; + + // La requete doit retourner un champ "nb" pour etre comprise + // par parent::getNbOfRecipients + return parent::getNbOfRecipients($sql); + } - /** - * \brief Affiche formulaire de filtre qui apparait dans page de selection - * des destinataires de mailings - * \return string Retourne zone select - */ - function formFilter() - { - global $langs; - $langs->load("companies"); - $langs->load("commercial"); - $langs->load("suppliers"); + /** + * \brief Affiche formulaire de filtre qui apparait dans page de selection + * des destinataires de mailings + * \return string Retourne zone select + */ + function formFilter() + { + global $langs; + $langs->load("companies"); + $langs->load("commercial"); + $langs->load("suppliers"); - $s=''; - $s.=''; + $s.=''; + $s.=''; + # Add prospect of a particular level $sql = "SELECT code, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; - $sql.= " WHERE active > 0"; - $sql.= " ORDER BY label"; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; + $sql.= " WHERE active > 0"; + $sql.= " ORDER BY label"; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); $level=$langs->trans($obj->code); if ($level == $obj->code) $level=$langs->trans($obj->label); $s.=''; $i++; } } - $s.=''; - //$s.=''; - $s.=''; - $s.=''; - return $s; - } + $s.=''; + //$s.=''; + $s.=''; + $s.=''; + return $s; + } - /** - * \brief Renvoie url lien vers fiche de la source du destinataire du mailing - * \return string Url lien - */ - function url($id) - { - return ''.img_object('',"contact").''; - } + /** + * \brief Renvoie url lien vers fiche de la source du destinataire du mailing + * \return string Url lien + */ + function url($id) + { + return ''.img_object('',"contact").''; + } - /** - * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concerné - * \param filterarray Requete sql de selection des destinataires - * \return int <0 si erreur, nb ajout si ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf, $langs; + /** + * \brief Ajoute destinataires dans table des cibles + * \param mailing_id Id du mailing concern� + * \param filterarray Requete sql de selection des destinataires + * \return int <0 si erreur, nb ajout si ok + */ + function add_to_target($mailing_id,$filtersarray=array()) + { + global $conf, $langs; - $cibles = array(); + $cibles = array(); # List prospects levels $prospectlevel=array(); @@ -182,69 +182,69 @@ class mailing_poire extends MailingTargets else dol_print_error($this->db); // La requete doit retourner: id, email, fk_contact, name, firstname, other - $sql = "SELECT c.rowid as id, c.email as email, c.rowid as fk_contact,"; - $sql.= " c.name as name, c.firstname as firstname, c.civilite,"; - $sql.= " s.nom as companyname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid = c.fk_soc"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND s.entity = ".$conf->entity; - $sql.= " AND c.email != ''"; - foreach($filtersarray as $key) - { - if ($key == 'prospects') $sql.= " AND s.client=2"; + $sql = "SELECT c.rowid as id, c.email as email, c.rowid as fk_contact,"; + $sql.= " c.name as name, c.firstname as firstname, c.civilite,"; + $sql.= " s.nom as companyname"; + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.rowid = c.fk_soc"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND c.email != ''"; + foreach($filtersarray as $key) + { + if ($key == 'prospects') $sql.= " AND s.client=2"; //print "xx".$key; foreach($prospectlevel as $codelevel=>$valuelevel) if ($key == 'prospectslevel'.$codelevel) $sql.= " AND s.fk_prospectlevel='".$codelevel."'"; - if ($key == 'customers') $sql.= " AND s.client=1"; - if ($key == 'suppliers') $sql.= " AND s.fournisseur=1"; - } - $sql.= " ORDER BY c.email"; + if ($key == 'customers') $sql.= " AND s.client=1"; + if ($key == 'suppliers') $sql.= " AND s.fournisseur=1"; + } + $sql.= " ORDER BY c.email"; //print "x".$sql; - // Stocke destinataires dans cibles - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - $j = 0; + // Stocke destinataires dans cibles + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + $j = 0; - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $other=''; - if ($obj->companyname) { if ($other) $other.=';'; $other.=$langs->transnoentities("ThirdParty").'='.$obj->companyname; } - if ($obj->civilite) { if ($other) $other.=';'; $other.=$langs->transnoentities("Civility".$obj->civilite); } - $cibles[$j] = array( + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $other=''; + if ($obj->companyname) { if ($other) $other.=';'; $other.=$langs->transnoentities("ThirdParty").'='.$obj->companyname; } + if ($obj->civilite) { if ($other) $other.=';'; $other.=$langs->transnoentities("Civility".$obj->civilite); } + $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => $other, 'url' => $this->url($obj->id) - ); - $old = $obj->email; - $j++; - } + ); + $old = $obj->email; + $j++; + } - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } - return parent::add_to_target($mailing_id, $cibles); - } + return parent::add_to_target($mailing_id, $cibles); + } } diff --git a/htdocs/includes/modules/mailings/pomme.modules.php b/htdocs/includes/modules/mailings/pomme.modules.php index 8459ebf5180..9bdc762b86f 100644 --- a/htdocs/includes/modules/mailings/pomme.modules.php +++ b/htdocs/includes/modules/mailings/pomme.modules.php @@ -19,171 +19,171 @@ */ /** - \file htdocs/includes/modules/mailings/pomme.modules.php - \ingroup mailing - \brief Fichier de la classe permettant de générer la liste de destinataires Pomme - \version $Id$ -*/ + \file htdocs/includes/modules/mailings/pomme.modules.php + \ingroup mailing + \brief Fichier de la classe permettant de g�n�rer la liste de destinataires Pomme + \version $Id$ + */ include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'; /** - \class mailing_pomme - \brief Classe permettant de générer la liste des destinataires Pomme -*/ + \class mailing_pomme + \brief Classe permettant de g�n�rer la liste des destinataires Pomme + */ class mailing_pomme extends MailingTargets { var $name='DolibarrUsers'; // Identifiant du module mailing - var $desc='Utilisateurs de Dolibarr avec emails'; // Libellé utilisé si aucune traduction pour MailingModuleDescXXX ou XXX=name trouvée - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=1; // Module mailing actif pour user admin ou non - var $picto='user'; + var $desc='Utilisateurs de Dolibarr avec emails'; // Libell� utilis� si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + var $require_module=array(); // Module mailing actif si modules require_module actifs + var $require_admin=1; // Module mailing actif pour user admin ou non + var $picto='user'; - var $db; + var $db; - function mailing_pomme($DB) - { - $this->db=$DB; - } + function mailing_pomme($DB) + { + $this->db=$DB; + } function getSqlArrayForStats() { global $conf, $langs; - + $langs->load("users"); - + $statssql=array(); - $sql = "SELECT '".$langs->trans("DolibarrUsers")."' as label"; - $sql.= ", count(distinct(u.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test - $sql.= " AND u.entity IN (0,".$conf->entity.")"; - $statssql[0]=$sql; + $sql = "SELECT '".$langs->trans("DolibarrUsers")."' as label"; + $sql.= ", count(distinct(u.email)) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test + $sql.= " AND u.entity IN (0,".$conf->entity.")"; + $statssql[0]=$sql; return $statssql; } - /* - * \brief Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. - * \return int - */ - function getNbOfRecipients() - { - global $conf; - - $sql = "SELECT count(distinct(u.email)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test - $sql.= " AND u.entity IN (0,".$conf->entity.")"; + /* + * \brief Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * \return int + */ + function getNbOfRecipients() + { + global $conf; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients - return parent::getNbOfRecipients($sql); - } + $sql = "SELECT count(distinct(u.email)) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test + $sql.= " AND u.entity IN (0,".$conf->entity.")"; - - /** - * \brief Affiche formulaire de filtre qui apparait dans page de selection - * des destinataires de mailings - * \return string Retourne zone select - */ - function formFilter() - { - global $langs; - - $langs->load("users"); - - $s=''; - $s.=''; - return $s; - } + // La requete doit retourner un champ "nb" pour etre comprise + // par parent::getNbOfRecipients + return parent::getNbOfRecipients($sql); + } /** - * \brief Renvoie url lien vers fiche de la source du destinataire du mailing - * \return string Url lien - */ - function url($id) - { - return ''.img_object('',"user").''; - } + * \brief Affiche formulaire de filtre qui apparait dans page de selection + * des destinataires de mailings + * \return string Retourne zone select + */ + function formFilter() + { + global $langs; + + $langs->load("users"); + + $s=''; + $s.=''; + return $s; + } - /** - * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concerné - * \param filterarray Requete sql de selection des destinataires - * \return int < 0 si erreur, nb ajout si ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $conf, $langs; + /** + * \brief Renvoie url lien vers fiche de la source du destinataire du mailing + * \return string Url lien + */ + function url($id) + { + return ''.img_object('',"user").''; + } - $cibles = array(); - // La requete doit retourner: id, email, fk_contact, name, firstname - $sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,"; - $sql.= " u.name as name, u.firstname as firstname, u.login, u.office_phone"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test - $sql.= " AND u.entity IN (0,".$conf->entity.")"; - foreach($filtersarray as $key) - { - if ($key == '1') $sql.= " AND u.statut=1"; - if ($key == '0') $sql.= " AND u.statut=0"; - } - $sql.= " ORDER BY u.email"; + /** + * \brief Ajoute destinataires dans table des cibles + * \param mailing_id Id du mailing concern� + * \param filterarray Requete sql de selection des destinataires + * \return int < 0 si erreur, nb ajout si ok + */ + function add_to_target($mailing_id,$filtersarray=array()) + { + global $conf, $langs; - // Stocke destinataires dans cibles - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - $j = 0; + $cibles = array(); - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + // La requete doit retourner: id, email, fk_contact, name, firstname + $sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,"; + $sql.= " u.name as name, u.firstname as firstname, u.login, u.office_phone"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test + $sql.= " AND u.entity IN (0,".$conf->entity.")"; + foreach($filtersarray as $key) + { + if ($key == '1') $sql.= " AND u.statut=1"; + if ($key == '0') $sql.= " AND u.statut=0"; + } + $sql.= " ORDER BY u.email"; - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $cibles[$j] = array( + // Stocke destinataires dans cibles + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + $j = 0; + + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => $langs->transnoentities("Login").'='.$obj->login.';'.$langs->transnoentities("PhonePro").'='.$obj->office_phone, 'url' => $this->url($obj->id) - ); - $old = $obj->email; - $j++; - } + ); + $old = $obj->email; + $j++; + } - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } - return parent::add_to_target($mailing_id, $cibles); - } + return parent::add_to_target($mailing_id, $cibles); + } } diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 06b1946c2fa..6f3638e7f5e 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -68,6 +68,7 @@ MailingModuleDescDolibarrUsers=All Dolibarr users with emails MailingModuleDescFundationMembers=Fundation members with emails MailingModuleDescEmailsFromFile=EMails from a text file (email;name;surname;comments) MailingModuleDescContactsCategories=Third parties with emails (by category) +MailingModuleDescDolibarrContractsLinesExpired=Third parties with expired contract's lines LineInFile=Line %s in file RecipientSelectionModules=Defined requests for recipients' selection diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index ccfaa68d5b5..5b8a6b68e46 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -68,6 +68,7 @@ MailingModuleDescDolibarrUsers=Utilisateurs de Dolibarr avec e-mail MailingModuleDescFundationMembers=Adhérents avec e-mail MailingModuleDescEmailsFromFile=EMails issus d'un fichier texte (email;nom;prenom;divers) MailingModuleDescContactsCategories=Tiers avec e-mail (par categorie) +MailingModuleDescDolibarrContractsLinesExpired=Tiers avec lignes de contrats de services expirées LineInFile=Ligne %s du fichier RecipientSelectionModules=Modules de sélection des destinataires diff --git a/htdocs/product.class.php b/htdocs/product.class.php index d5ef78a1839..c423f12af0a 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -60,7 +60,7 @@ class Product extends CommonObject var $multiprices_base_type=array(); //! Taux de TVA var $tva_tx; - //! Type 0 for regural product, 1 for service, 2 for assembly kit, 3 for stock kit + //! Type 0 for regular product, 1 for service, 2 for assembly kit, 3 for stock kit var $type; var $typestring; var $stock_reel; diff --git a/mysql/tables/llx_product.sql b/mysql/tables/llx_product.sql index 526ab4263e7..74dc0e94d33 100644 --- a/mysql/tables/llx_product.sql +++ b/mysql/tables/llx_product.sql @@ -38,7 +38,7 @@ create table llx_product tva_tx double(6,3), fk_user_author integer, envente tinyint DEFAULT 1, - fk_product_type integer DEFAULT 0, + fk_product_type integer DEFAULT 0, -- Type 0 for regular product, 1 for service duration varchar(6), seuil_stock_alerte integer DEFAULT 0, stock_loc varchar(10), -- emplacement dans le stock