11include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
21 public $name =
'mailing_mymodule_selector1';
23 public $desc =
'Emailing target selector1';
25 public $require_admin = 0;
27 public $enabled =
'isModEnabled("mymodule")';
29 public $require_module = array();
34 public $picto =
'generic';
62 $langs->load(
"members");
64 $arraystatus = array(1=>
'Option 1', 2=>
'Option 2');
67 $s .= $langs->trans(
"Status").
': ';
68 $s .=
'<select name="filter" class="flat">';
69 $s .=
'<option value="none"> </option>';
70 foreach ($arraystatus as $status) {
71 $s .=
'<option value="'.$status.
'">'.$status.
'</option>';
86 public function url($id)
88 return '<a href="'.dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id.
'">'.
img_object(
'',
"generic").
'</a>';
105 $sql =
"SELECT rowid as id, firstname, lastname, email";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"myobject";
107 $sql .=
" WHERE email IS NOT NULL AND email <> ''";
108 if (GETPOSTISSET(
'filter') &&
GETPOST(
'filter',
'alphanohtml') !=
'none') {
109 $sql .=
" AND status = '".$this->db->escape(
GETPOST(
'filter',
'alphanohtml')).
"'";
111 $sql .=
" ORDER BY email";
114 $result = $this->db->query($sql);
116 $num = $this->db->num_rows($result);
119 dol_syslog(__METHOD__.
":add_to_target ".$num.
" targets found");
123 $obj = $this->db->fetch_object($result);
124 if ($old != $obj->email) {
126 'email' => $obj->email,
128 'firstname' => $obj->firstname,
129 'lastname' => $obj->lastname,
131 'source_url' => $this->url($obj->id),
132 'source_id' => $obj->id,
133 'source_type' =>
'myobject@mymodule'
143 $this->error = $this->db->error();
156 return parent::addTargetsToDatabase($mailing_id, $target);
189 $sql =
"SELECT COUNT(DISTINCT(email)) as nb";
190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"myobject as p";
191 $sql .=
" WHERE email IS NOT NULL AND email <> ''";
193 $a = parent::getNbOfRecipients($sql);
Parent class of emailing target selectors modules.
mailing_mailinglist_mymodule
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
formFilter()
Displays 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)
Returns 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.