class MailingTargets (View source)

Parent class of emailing target selectors modules

Properties

DoliDB $db
string $error
string[] $errors
string $enabled
string $name
string $desc
string $tooltip
string $sql
int<0, 1> $evenunsubscribe

Methods

__construct($db)

Constructor

string
getDesc()

Return description of email selector

getNbOfRecords()

Return number of records for email selector

int|string
getNbOfRecipients(string $sql)

Retourne nombre de destinataires

string
formFilter()

Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings

int
update_nb(int $mailing_id)

Met a jour nombre de destinataires

int
addTargetsToDatabase(int $mailing_id, array<array{fk_contact?: int, lastname: string, firstname: string, email: string, other: string, source_url: string, source_id?: int, source_type: string, id?: int}> $cibles)

Add a list of targets into the database

void
clear_target($mailing_id)

Supprime tous les destinataires de la table des cibles

static 
getEmailingSelectorsList(?string[] $forcedir = null)

Return list of widget. Function used by admin page htdoc/admin/widget.

string[]
getSqlArrayForStats()

On the main mailing area, there is a box with statistics.

int
add_to_target($mailing_id)

Add destinations in the targets table

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

string getDesc()

Return description of email selector

Return Value

string

Return translation of module label. Try translation of $this->name then translation of 'MailingModuleDesc'.$this->name, or $this->desc if not found

getNbOfRecords()

Return number of records for email selector

@return integer Example

int|string getNbOfRecipients(string $sql)

Retourne nombre de destinataires

Parameters

string $sql

Sql request to count

Return Value

int|string

Nb of recipient, or <0 if error, or '' if NA

string formFilter()

Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings

Return Value

string

Retourne zone select

int update_nb(int $mailing_id)

Met a jour nombre de destinataires

Parameters

int $mailing_id

Id of emailing

Return Value

int

Return integer < 0 si erreur, nb destinataires si ok

int addTargetsToDatabase(int $mailing_id, array<array{fk_contact?: int, lastname: string, firstname: string, email: string, other: string, source_url: string, source_id?: int, source_type: string, id?: int}> $cibles)

Add a list of targets into the database

Parameters

int $mailing_id

Id of emailing

array<array{fk_contact?: int, lastname: string, firstname: string, email: string, other: string, source_url: string, source_id?: int, source_type: string, id?: int}> $cibles

Array with targets

Return Value

int

Return integer < 0 if error, nb added if OK

void clear_target($mailing_id)

Supprime tous les destinataires de la table des cibles

@param int $mailing_id Id of emailing

Parameters

$mailing_id

Return Value

void

static getEmailingSelectorsList(?string[] $forcedir = null)

Return list of widget. Function used by admin page htdoc/admin/widget.

List is sorted by widget filename so by priority to run.

Parameters

?string[] $forcedir

null=All default directories. This parameter is used by modulebuilder module only. @return array<array{picto:string,file:string,fullpath:string,relpath:string,iscoreorexternal:'external'|'internal',version:string,status:string,info:string}> Array list of widgets

string[] getSqlArrayForStats()

On the main mailing area, there is a box with statistics.

If you want to add a line in this report you must provide an array of SQL request that returns two field: One called "label", One called "nb".

Return Value

string[]

Array with SQL requests

int add_to_target($mailing_id)

Add destinations in the targets table

@param int $mailing_id Id of emailing

Parameters

$mailing_id

Return Value

int

Return integer < 0 on error, count of added when ok