mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
update queries for extended contacts
This commit is contained in:
parent
82a3ad8796
commit
b380a326b8
1 changed files with 903 additions and 866 deletions
|
@ -243,13 +243,24 @@
|
|||
/**
|
||||
* Récupère les contacts dont l'id fait partie de la liste fournie
|
||||
* @param array $contacts_ids = Tableau des id des contacts voulus
|
||||
* @param boolean $extended_contact : Mode de gestion des contacts avancés activé
|
||||
* @return array : Retourne un tableau avec les contacts adaptés
|
||||
*/
|
||||
public function getContactsIn($contacts_ids)
|
||||
public function getContactsIn($contacts_ids, $extended_contact = false)
|
||||
{
|
||||
if ($extended_contact) {
|
||||
$extended_contact_join = '
|
||||
LEFT JOIN contacts_infos as inf
|
||||
ON (inf.id_contact = contacts.id)
|
||||
';
|
||||
} else {
|
||||
$extended_contact_join = '';
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM contacts
|
||||
".$extended_contact_join."
|
||||
WHERE id ";
|
||||
|
||||
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
||||
|
@ -329,15 +340,28 @@
|
|||
/**
|
||||
* Retourne tous les contacts pour un groupe donnée
|
||||
* @param int $id_group : L'id du groupe
|
||||
* @param boolean $extended_contact : Mode de gestion des contacts avancés activé
|
||||
* @return array : Tous les contacts compris dans le groupe
|
||||
*/
|
||||
public function getContactsForGroup($id_group)
|
||||
public function getContactsForGroup($id_group, $extended_contact = false)
|
||||
{
|
||||
if ($extended_contact) {
|
||||
$contact_fields = 'inf.civility as civility, inf.first_name as first_name, inf.last_name as last_name, inf.birthday as birthday, inf.love_situation as love_situation';
|
||||
$extended_contact_join = '
|
||||
LEFT JOIN contacts_infos as inf
|
||||
ON (inf.id_contact = con.id)
|
||||
';
|
||||
} else {
|
||||
$contact_fields = 'con.name as name';
|
||||
$extended_contact_join = '';
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT con.id as id, con.name as name, con.number as number
|
||||
SELECT con.id as id, ' . $contact_fields . ', con.number as number
|
||||
FROM groups_contacts as g_c
|
||||
JOIN contacts as con
|
||||
ON (g_c.id_contact = con.id)
|
||||
'.$extended_contact_join.'
|
||||
WHERE(g_c.id_group = :id_group)
|
||||
';
|
||||
|
||||
|
@ -585,15 +609,28 @@
|
|||
/**
|
||||
* Retourne tous les contacts pour un sms programmé donnée
|
||||
* @param int $id_sms : L'id du sms
|
||||
* @param boolean $extended_contact : Mode de gestion des contacts avancés activé
|
||||
* @return array : Tous les contacts compris dans le schedulede
|
||||
*/
|
||||
public function getContactsForScheduled($id_scheduled)
|
||||
public function getContactsForScheduled($id_scheduled, $extended_contact = false)
|
||||
{
|
||||
$contact_fields = '';
|
||||
$extended_contact_join = '';
|
||||
|
||||
if ($extended_contact) {
|
||||
$contact_fields = ' inf.civility as civility, inf.first_name as first_name, inf.last_name as last_name, inf.birthday as birthday, inf.love_situation as love_situation';
|
||||
$extended_contact_join = '
|
||||
LEFT JOIN contacts_infos as inf
|
||||
ON (inf.id_contact = con.id)
|
||||
';
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT con.id as id, con.name as name, con.number as number
|
||||
SELECT con.id as id, con.name as name, con.number as number'.$contact_fields.'
|
||||
FROM scheduleds_contacts as s_c
|
||||
JOIN contacts as con
|
||||
ON (s_c.id_contact = con.id)
|
||||
'.$extended_contact_join.'
|
||||
WHERE(s_c.id_scheduled = :id_scheduled)
|
||||
';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue