Go to the documentation of this file.
19 include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
27 public $name =
'PartnershipThirdartiesOrMembers';
29 public $desc =
"Thirdparties or members included into a partnership program";
30 public $require_admin = 0;
32 public $require_module = array();
37 public $picto =
'partnership';
44 public $enabled =
'$conf->partnership->enabled';
55 $langs->load(
"companies");
76 $sql =
"SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, pt.label as label, 'thirdparty' as source";
77 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"partnership as p, ".MAIN_DB_PREFIX.
"c_partnership_type as pt";
78 $sql .=
" WHERE s.email <> ''";
79 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
80 $sql .=
" AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE fk_mailing=".((int) $mailing_id).
")";
81 $sql .=
" AND p.fk_soc = s.rowid";
82 $sql .=
" AND pt.rowid = p.fk_type";
83 if (
GETPOST(
'filter',
'int') > 0) {
84 $sql .=
" AND pt.rowid=".((int)
GETPOST(
'filter',
'int'));
89 $sql .=
"SELECT s.rowid as id, s.email as email, s.lastname as name, null as fk_contact, s.firstname as firstname, pt.label as label, 'member' as source";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as s, ".MAIN_DB_PREFIX.
"partnership as p, ".MAIN_DB_PREFIX.
"c_partnership_type as pt";
91 $sql .=
" WHERE s.email <> ''";
92 $sql .=
" AND s.entity IN (".getEntity(
'member').
")";
93 $sql .=
" AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE fk_mailing=".((int) $mailing_id).
")";
94 $sql .=
" AND p.fk_member = s.rowid";
95 $sql .=
" AND pt.rowid = p.fk_type";
96 if (
GETPOST(
'filter',
'int') > 0) {
97 $sql .=
" AND pt.rowid=".((int)
GETPOST(
'filter',
'int'));
100 $sql .=
" ORDER BY email";
103 $result = $this->
db->query($sql);
105 $num = $this->
db->num_rows($result);
109 dol_syslog(get_class($this).
"::add_to_target mailing ".$num.
" targets found");
113 $obj = $this->
db->fetch_object($result);
114 if ($old <> $obj->email) {
115 $otherTxt = ($obj->label ? $langs->transnoentities(
"PartnershipType").
'='.$obj->label :
'');
116 if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) {
119 $otherTxt .= $addDescription;
121 'email' => $obj->email,
122 'fk_contact' => $obj->fk_contact,
123 'lastname' => $obj->name,
125 'other' => $otherTxt,
126 'source_url' => $this->url($obj->id, $obj->source),
127 'source_id' => $obj->id,
128 'source_type' => $obj->source
138 $this->error = $this->
db->error();
142 return parent::addTargetsToDatabase($mailing_id, $cibles);
176 $sql =
"SELECT count(distinct(s.email)) as nb";
177 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership as p, ".MAIN_DB_PREFIX.
"societe as s";
178 $sql .=
" WHERE s.rowid = p.fk_soc AND s.email <> ''";
179 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
183 $sql .=
"SELECT count(distinct(s.email)) as nb";
184 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership as p, ".MAIN_DB_PREFIX.
"adherent as s";
185 $sql .=
" WHERE s.rowid = p.fk_member AND s.email <> ''";
186 $sql .=
" AND s.entity IN (".getEntity(
'member').
")";
191 return parent::getNbOfRecipients($sql);
202 global $conf, $langs;
204 $langs->load(
"companies");
206 $s =
'<select id="filter_partnership" name="filter" class="flat">';
209 $sql =
"SELECT rowid, label, code, active";
210 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_partnership_type";
211 $sql .=
" WHERE active = 1";
212 $sql .=
" AND entity = ".$conf->entity;
213 $sql .=
" ORDER BY label";
220 if (empty($conf->partnership->enabled)) {
225 $s .=
'<option value="-1">'.$langs->trans(
"PartnershipType").
'</option>';
230 $obj = $this->
db->fetch_object(
$resql);
254 public function url($id, $sourcetype =
'thirdparty')
256 if ($sourcetype ==
'thirparty') {
257 return '<a href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.((int) $id).
'">'.
img_object(
'',
"societe").
'</a>';
259 if ($sourcetype ==
'member') {
260 return '<a href="'.DOL_URL_ROOT.
'/adherent/card.php?id='.((int) $id).
'">'.
img_object(
'',
"member").
'</a>';
add_to_target($mailing_id)
This is the main function that returns the array of emails.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
$conf db
API class for accounts.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
url($id, $sourcetype='thirdparty')
Can include an URL link on each record provided by selector shown on target page.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Parent class of emailing target selectors modules.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Class to manage a list of personalised recipients for mailing feature.
__construct($db)
Constructor.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
formFilter()
This is to add a form filter to provide variant of selector If used, the HTML select must be called "...