11include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
21 public $name =
'mailinglist_mymodule_myobject';
23 public $desc =
'My object emailing target selector';
25 public $require_admin = 0;
27 public $enabled =
'isModEnabled("mymodule")';
29 public $require_module = array();
34 public $picto =
'fa-file';
62 $langs->load(
"members");
64 $form =
new Form($this->db);
66 $arraystatus = array(1=>
'Option 1', 2=>
'Option 2');
69 $s .= $langs->trans(
"Status").
': ';
70 $s .=
'<select name="filter" class="flat">';
71 $s .=
'<option value="none"> </option>';
72 foreach ($arraystatus as $status) {
73 $s .=
'<option value="'.$status.
'">'.$status.
'</option>';
88 public function url($id)
90 return '<a href="'.dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id.
'">'.
img_object(
'',
"generic").
'</a>';
107 $sql =
" select rowid as id, label, firstname, lastname";
108 $sql .=
" from ".MAIN_DB_PREFIX.
"myobject";
109 $sql .=
" where email IS NOT NULL AND email <> ''";
110 if (GETPOSTISSET(
'filter') &&
GETPOST(
'filter',
'alphanohtml') !=
'none') {
111 $sql .=
" AND status = '".$this->db->escape(
GETPOST(
'filter',
'alphanohtml')).
"'";
113 $sql .=
" ORDER BY email";
116 $result = $this->db->query($sql);
118 $num = $this->db->num_rows($result);
121 dol_syslog(
"mailinglist_mymodule_myobject.modules.php: mailing ".$num.
" targets found");
125 $obj = $this->db->fetch_object($result);
126 if ($old != $obj->email) {
128 'email' => $obj->email,
129 'name' => $obj->lastname,
131 'firstname' => $obj->firstname,
132 'other' => $obj->label,
133 'source_url' => $this->url($obj->id),
134 'source_id' => $obj->id,
135 'source_type' =>
'myobject@mymodule'
145 $this->error = $this->db->error();
158 return parent::addTargetsToDatabase($mailing_id, $target);
191 $sql =
"select count(distinct(email)) as nb from ".MAIN_DB_PREFIX.
"myobject as p where email IS NOT NULL AND email != ''";
193 $a = parent::getNbOfRecipients($sql);
Parent class of emailing target selectors modules.
mailing_mailinglist_mymodule
__construct($db)
Constructor.
formFilter()
Displays the filter form that appears in the mailing recipient selection page.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $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.