27include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
38 public $name =
'DolibarrUsers';
43 public $desc =
'Dolibarr users with emails';
48 public $require_module = array();
53 public $require_admin = 1;
58 public $picto =
'user';
84 $langs->load(
"users");
87 $sql =
"SELECT '".$this->db->escape($langs->trans(
"DolibarrUsers")).
"' as label,";
88 $sql .=
" count(distinct(u.email)) as nb";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
90 $sql .=
" WHERE u.email != ''";
91 $sql .=
" AND u.entity IN (0,".((int)
$conf->entity).
")";
111 $sql =
"SELECT count(distinct(u.email)) as nb";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
113 $sql .=
" WHERE u.email != ''";
114 $sql .=
" AND u.entity IN (0,".((int)
$conf->entity).
")";
118 return parent::getNbOfRecipients($sql);
131 $langs->load(
"users");
134 $s .=
'<select id="filter_pomme"" name="filter" class="flat minwidth100">';
135 $s .=
'<option value="-1">'.$langs->trans(
"Status").
'</option>';
136 $s .=
'<option value="1">'.$langs->trans(
"Enabled").
'</option>';
137 $s .=
'<option value="0">'.$langs->trans(
"Disabled").
'</option>';
142 $s .=
'<select id="filteremployee_pomme" name="filteremployee" class="flat minwidth100">';
143 $s .=
'<option value="-1">'.$langs->trans(
"Employee").
'</option>';
144 $s .=
'<option value="1">'.$langs->trans(
"Yes").
'</option>';
145 $s .=
'<option value="0">'.$langs->trans(
"No").
'</option>';
161 return '<a href="'.DOL_URL_ROOT.
'/user/card.php?id='.
$id.
'">'.
img_object(
'',
"user").
'</a>';
175 global
$conf, $langs;
176 $langs->load(
"companies");
181 $sql =
"SELECT u.rowid as id, u.email as email, null as fk_contact,";
182 $sql .=
" u.lastname, u.firstname as firstname, u.civility as civility_id, u.login, u.office_phone";
183 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
184 $sql .=
" WHERE u.email <> ''";
185 $sql .=
" AND u.entity IN (0,".((int)
$conf->entity).
")";
186 $sql .=
" AND u.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX.
"mailing_cibles WHERE fk_mailing=".((int) $mailing_id).
")";
187 if (GETPOSTISSET(
"filter") &&
GETPOST(
"filter") ==
'1') {
188 $sql .=
" AND u.statut=1";
190 if (GETPOSTISSET(
"filter") &&
GETPOST(
"filter") ==
'0') {
191 $sql .=
" AND u.statut=0";
193 if (GETPOSTISSET(
"filteremployee") &&
GETPOST(
"filteremployee") ==
'1') {
194 $sql .=
" AND u.employee=1";
196 if (GETPOSTISSET(
"filteremployee") &&
GETPOST(
"filteremployee") ==
'0') {
197 $sql .=
" AND u.employee=0";
200 $sql .=
" ORDER BY u.email";
203 $result = $this->db->query($sql);
205 $num = $this->db->num_rows($result);
209 dol_syslog(get_class($this).
"::add_to_target mailing ".$num.
" targets found");
213 $obj = $this->db->fetch_object($result);
214 if ($old != $obj->email) {
216 'email' => $obj->email,
217 'fk_contact' => (
int) $obj->fk_contact,
218 'lastname' => $obj->lastname,
219 'firstname' => $obj->firstname,
221 ($langs->transnoentities(
"Login").
'='.$obj->login).
';'.
222 ($langs->transnoentities(
"UserTitle").
'='.$obj->civility_id).
';'.
223 ($langs->transnoentities(
"PhonePro").
'='.$obj->office_phone),
224 'source_url' => $this->url($obj->id),
225 'source_id' => (
int) $obj->id,
226 'source_type' =>
'user'
236 $this->error = $this->db->error();
240 return parent::addTargetsToDatabase($mailing_id, $cibles);
$id
Support class for third parties, contacts, members, users or resources.
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.
getSqlToExcludeUnsubscribed($emailfield)
Return the SQL fragment that excludes email addresses which opted out of emailings for the current en...
Class to offer a selector of emailing targets with Rule 'Pomme'.
formFilter()
Display filter form shown on the mailing recipient selection page.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
__construct($db)
Constructor.
url($id)
Provide the URL to the car of the source information of the recipient for the mailing.
add_to_target($mailing_id)
Ajoute destinataires dans table des cibles.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)