25include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
33 public $name =
'DolibarrUsers';
35 public $desc =
'Dolibarr users with emails';
36 public $require_module = array();
37 public $require_admin = 1;
42 public $picto =
'user';
73 $langs->load(
"users");
76 $sql =
"SELECT '".$this->db->escape($langs->trans(
"DolibarrUsers")).
"' as label,";
77 $sql .=
" count(distinct(u.email)) as nb";
78 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
79 $sql .=
" WHERE u.email != ''";
80 $sql .=
" AND u.entity IN (0,".$conf->entity.
")";
100 $sql =
"SELECT count(distinct(u.email)) as nb";
101 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
102 $sql .=
" WHERE u.email != ''";
103 $sql .=
" AND u.entity IN (0,".$conf->entity.
")";
104 if (empty($this->evenunsubscribe)) {
105 $sql .=
" AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe as mu WHERE mu.email = u.email and mu.entity = ".((int) $conf->entity).
")";
109 return parent::getNbOfRecipients($sql);
122 $langs->load(
"users");
125 $s .=
'<select id="filter_pomme"" name="filter" class="flat minwidth100">';
126 $s .=
'<option value="-1">'.$langs->trans(
"Status").
'</option>';
127 $s .=
'<option value="1">'.$langs->trans(
"Enabled").
'</option>';
128 $s .=
'<option value="0">'.$langs->trans(
"Disabled").
'</option>';
133 $s .=
'<select id="filteremployee_pomme" name="filteremployee" class="flat minwidth100">';
134 $s .=
'<option value="-1">'.$langs->trans(
"Employee").
'</option>';
135 $s .=
'<option value="1">'.$langs->trans(
"Yes").
'</option>';
136 $s .=
'<option value="0">'.$langs->trans(
"No").
'</option>';
152 return '<a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$id.
'">'.
img_object(
'',
"user").
'</a>';
166 global $conf, $langs;
167 $langs->load(
"companies");
172 $sql =
"SELECT u.rowid as id, u.email as email, null as fk_contact,";
173 $sql .=
" u.lastname, u.firstname as firstname, u.civility as civility_id, u.login, u.office_phone";
174 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
175 $sql .=
" WHERE u.email <> ''";
176 $sql .=
" AND u.entity IN (0,".$conf->entity.
")";
177 $sql .=
" AND u.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE fk_mailing=".((int) $mailing_id).
")";
178 if (GETPOSTISSET(
"filter") &&
GETPOST(
"filter") ==
'1') {
179 $sql .=
" AND u.statut=1";
181 if (GETPOSTISSET(
"filter") &&
GETPOST(
"filter") ==
'0') {
182 $sql .=
" AND u.statut=0";
184 if (GETPOSTISSET(
"filteremployee") && GETPOSt(
"filteremployee") ==
'1') {
185 $sql .=
" AND u.employee=1";
187 if (GETPOSTISSET(
"filteremployee") &&
GETPOST(
"filteremployee") ==
'0') {
188 $sql .=
" AND u.employee=0";
190 if (empty($this->evenunsubscribe)) {
191 $sql .=
" AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe as mu WHERE mu.email = u.email and mu.entity = ".((int) $conf->entity).
")";
193 $sql .=
" ORDER BY u.email";
196 $result = $this->db->query($sql);
198 $num = $this->db->num_rows($result);
202 dol_syslog(get_class($this).
"::add_to_target mailing ".$num.
" targets found");
206 $obj = $this->db->fetch_object($result);
207 if ($old <> $obj->email) {
209 'email' => $obj->email,
210 'fk_contact' => $obj->fk_contact,
211 'lastname' => $obj->lastname,
212 'firstname' => $obj->firstname,
214 ($langs->transnoentities(
"Login").
'='.$obj->login).
';'.
215 ($langs->transnoentities(
"UserTitle").
'='.$obj->civility_id).
';'.
216 ($langs->transnoentities(
"PhonePro").
'='.$obj->office_phone),
217 'source_url' => $this->url($obj->id),
218 'source_id' => $obj->id,
219 'source_type' =>
'user'
229 $this->error = $this->db->error();
233 return parent::addTargetsToDatabase($mailing_id, $cibles);
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Parent class of emailing target selectors modules.
Class to offer a selector of emailing targets with Rule 'Pomme'.
formFilter()
Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
__construct($db)
Constructor.
url($id)
Renvoie url lien vers fiche de la source du destinataire du mailing.
add_to_target($mailing_id)
Ajoute destinataires dans table des cibles.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.