12include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
22 public $name =
'mailing_mymodule_selector1';
24 public $desc =
'Emailing target selector1';
30 public $require_admin = 0;
32 public $enabled =
'isModEnabled("mymodule")';
37 public $require_module = array();
42 public $picto =
'generic';
70 $langs->load(
"members");
72 $arraystatus = array(1 =>
'Option 1', 2 =>
'Option 2');
75 $s .= $langs->trans(
"Status").
': ';
76 $s .=
'<select name="filter" class="flat">';
77 $s .=
'<option value="none"> </option>';
78 foreach ($arraystatus as $status) {
79 $s .=
'<option value="'.$status.
'">'.$status.
'</option>';
96 return '<a href="'.dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.
$id.
'">'.
img_object(
'',
"generic").
'</a>';
113 $sql =
"SELECT rowid as id, firstname, lastname, email";
114 $sql .=
" FROM ".MAIN_DB_PREFIX.
"myobject";
115 $sql .=
" WHERE email IS NOT NULL AND email <> ''";
116 if (GETPOSTISSET(
'filter') &&
GETPOST(
'filter',
'alphanohtml') !=
'none') {
117 $sql .=
" AND status = '".$this->db->escape(
GETPOST(
'filter',
'alphanohtml')).
"'";
119 $sql .=
" ORDER BY email";
122 $result = $this->db->query($sql);
124 $num = $this->db->num_rows($result);
127 dol_syslog(__METHOD__.
":add_to_target ".$num.
" targets found");
131 $obj = $this->db->fetch_object($result);
132 if ($old != $obj->email) {
134 'email' => (
string) $obj->email,
135 'id' => (
int) $obj->id,
136 'firstname' => (
string) $obj->firstname,
137 'lastname' => (
string) $obj->lastname,
139 'source_url' => $this->url($obj->id),
140 'source_id' => (
int) $obj->id,
141 'source_type' =>
'myobject@mymodule'
151 $this->error = $this->db->error();
164 return parent::addTargetsToDatabase($mailing_id, $target);
197 $sql =
"SELECT COUNT(DISTINCT(email)) as nb";
198 $sql .=
" FROM ".MAIN_DB_PREFIX.
"myobject as p";
199 $sql .=
" WHERE email IS NOT NULL AND email <> ''";
201 $a = parent::getNbOfRecipients($sql);
Parent class of emailing target selectors modules.
mailing_mailinglist_mymodule
getNbOfRecipients($sql='')
Return the number of distinct emails returned by your selector.
formFilter()
Display the filter form that appears in the mailing recipient selection page.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
add_to_target($mailing_id)
This is the main function that returns the array of emails.
url($id)
Return URL link to file of the source of the recipient of the mailing.
__construct($db)
Constructor.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.