2019-10-29 14:57:13 +01:00
|
|
|
<?php
|
2019-10-30 00:30:39 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of PHP CS Fixer.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace models;
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
class DataBase extends \descartes\Model
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES SENDEDS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les SMS envoyés depuis une date.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25)
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tableau avec tous les SMS depuis la date
|
|
|
|
*/
|
|
|
|
public function getNbSendedsSinceGroupDay($date)
|
|
|
|
{
|
|
|
|
$query = "
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT COUNT(id) as nb, DATE_FORMAT(at, '%Y-%m-%d') as at_ymd
|
|
|
|
FROM sended
|
|
|
|
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d')
|
|
|
|
GROUP BY at_ymd
|
|
|
|
";
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère SMS envoyé à partir de son id.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param int $id = L'id du SMS
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Retourne le SMS
|
|
|
|
*/
|
|
|
|
public function getSendedFromId($id)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM sended
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id = :id';
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
'id' => $id,
|
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les sendeds dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $sendeds_ids : Tableau des id des sendeds à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteSendedsIn($sendeds_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM sended
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($sendeds_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES RECEIVEDS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Insert un nouveau SMS reçu.
|
|
|
|
*
|
|
|
|
* @param string $date : La date d'envoie du message
|
|
|
|
* @param string $send_by : Numéro auquel depuis lequel le message a ete envoye
|
|
|
|
* @param string $content : Texte du message
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param string $is_command : Commande reconnue
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : le nombre de SMS créés
|
|
|
|
*/
|
|
|
|
public function insertReceived($date, $send_by, $content, $is_command)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
INSERT INTO received(at, send_by, content, is_command)
|
|
|
|
VALUES (:date, :send_by, :content, :is_command)
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
|
|
|
'send_by' => $send_by,
|
|
|
|
'content' => $content,
|
|
|
|
'is_command' => $is_command,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT); //On retourne le nombre de lignes ajoutés
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les SMS reçus depuis une date.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25)
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tableau avec tous les SMS depuis la date
|
|
|
|
*/
|
|
|
|
public function getNbReceivedsSinceGroupDay($date)
|
|
|
|
{
|
|
|
|
$query = "
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT COUNT(id) as nb, DATE_FORMAT(at, '%Y-%m-%d') as at_ymd
|
|
|
|
FROM received
|
|
|
|
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d')
|
|
|
|
GROUP BY at_ymd
|
|
|
|
";
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les SMS reçus depuis une date.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25 20:10:05)
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tableau avec tous les SMS depuis la date
|
|
|
|
*/
|
|
|
|
public function getReceivedsSince($date)
|
|
|
|
{
|
|
|
|
$query = "
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM received
|
|
|
|
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d %h:%i:%s')
|
|
|
|
";
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les SMS reçus depuis une date pour un numero.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25 20:10:05)
|
|
|
|
* @param $number : Le numéro
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tableau avec tous les SMS depuis la date
|
|
|
|
*/
|
|
|
|
public function getReceivedsSinceForNumberOrderByDate($date, $number)
|
|
|
|
{
|
|
|
|
$query = "
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM received
|
|
|
|
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d %h:%i:%s')
|
|
|
|
AND send_by = :number
|
|
|
|
ORDER BY at ASC
|
|
|
|
";
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
2019-10-30 00:30:39 +01:00
|
|
|
'number' => $number,
|
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les receiveds dont l'id fait partie de la liste fournie.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param array $receiveds_ids = Tableau des id des receiveds voulus
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Retourne un tableau avec les receiveds adaptés
|
|
|
|
*/
|
|
|
|
public function getReceivedsIn($receiveds_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM received
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($receiveds_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les receivedss dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $receiveds_ids : Tableau des id des receiveds à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteReceivedsIn($receiveds_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM received
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($receiveds_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES CONTACTS
|
|
|
|
//
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les contacts dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $contacts_ids : Tableau des id des contacts à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteContactsIn($contacts_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM contact
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($contacts_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les contacts dont l'id fait partie de la liste fournie.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param array $contacts_ids = Tableau des id des contacts voulus
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Retourne un tableau avec les contacts adaptés
|
|
|
|
*/
|
|
|
|
public function getContactsIn($contacts_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM contact
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($contacts_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES GROUPS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Insert un group.
|
|
|
|
*
|
|
|
|
* @param string $nom : Le nom du nouveau group
|
|
|
|
* @param mixed $name
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : le nombre de lignes crées
|
|
|
|
*/
|
|
|
|
public function insertGroup($name)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
INSERT INTO group(name)
|
|
|
|
VALUES (:name)
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'name' => $name,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les groups dont l'id fait partie de la liste fournie.
|
|
|
|
*
|
2019-10-30 00:17:10 +01:00
|
|
|
* @param array $groups_ids = Tableau des id des groups voulus
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-30 00:17:10 +01:00
|
|
|
* @return array : Retourne un tableau avec les groups adaptés
|
2019-10-29 18:33:49 +01:00
|
|
|
*/
|
|
|
|
public function getGroupsIn($groups_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM group
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($groups_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les groups dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $contacts_ids : Tableau des id des groups à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
* @param mixed $groups_ids
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteGroupsIn($groups_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM group
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($groups_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES GROUPS_CONTACTS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Retourne tous les contacts pour un group donnée.
|
|
|
|
*
|
2019-10-30 00:17:10 +01:00
|
|
|
* @param int $id_group : L'id du group
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-30 00:17:10 +01:00
|
|
|
* @return array : Tous les contacts compris dans le group
|
2019-10-29 18:33:49 +01:00
|
|
|
*/
|
|
|
|
public function getContactsForGroup($id_group)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT con.id as id, con.name as name, con.number as number
|
|
|
|
FROM group_contact as g_c
|
|
|
|
JOIN contact as con
|
|
|
|
ON (g_c.id_contact = con.id)
|
|
|
|
WHERE(g_c.id_group = :id_group)
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'id_group' => $id_group,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 14:57:13 +01:00
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
2019-10-29 14:57:13 +01:00
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère tout les groups, avec le nombre de contact dans chacun.
|
|
|
|
*
|
|
|
|
* @param mixed $order_by
|
|
|
|
* @param mixed $desc
|
|
|
|
* @param mixed $limit
|
|
|
|
* @param mixed $offset
|
|
|
|
*
|
2019-10-30 00:17:10 +01:00
|
|
|
* @return array : Tableau avec tous les groups et le nombre de contacts liés
|
2019-10-29 18:33:49 +01:00
|
|
|
*/
|
|
|
|
public function getGroupsWithContactsNb($order_by = '', $desc = false, $limit = false, $offset = false)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT gro.id as id, gro.name as name, COUNT(g_c.id) as nb_contacts
|
|
|
|
FROM group as gro
|
|
|
|
LEFT JOIN group_contact as g_c
|
|
|
|
ON (g_c.id_group = gro.id)
|
|
|
|
GROUP BY id
|
2019-10-30 00:30:39 +01:00
|
|
|
';
|
2019-10-29 14:57:13 +01:00
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
if ($order_by)
|
|
|
|
{
|
2019-10-29 18:33:49 +01:00
|
|
|
$orders = [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'number',
|
|
|
|
];
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
if (\in_array($order_by, $orders, true))
|
|
|
|
{
|
|
|
|
$query .= ' ORDER BY '.$order_by;
|
|
|
|
if ($desc)
|
|
|
|
{
|
2019-10-29 18:33:49 +01:00
|
|
|
$query .= ' DESC';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
if (false !== $limit)
|
|
|
|
{
|
2019-10-29 18:33:49 +01:00
|
|
|
$query .= ' LIMIT :limit';
|
2019-10-30 00:30:39 +01:00
|
|
|
if (false !== $offset)
|
|
|
|
{
|
2019-10-29 18:33:49 +01:00
|
|
|
$query .= ' OFFSET :offset';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$req = $this->pdo->prepare($query);
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
if (false !== $limit)
|
|
|
|
{
|
2019-10-29 18:33:49 +01:00
|
|
|
$req->bindParam(':limit', $limit, \PDO::PARAM_INT);
|
2019-10-30 00:30:39 +01:00
|
|
|
if (false !== $offset)
|
|
|
|
{
|
2019-10-29 18:33:49 +01:00
|
|
|
$req->bindParam(':offset', $offset, \PDO::PARAM_INT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$req->execute();
|
2019-10-30 00:30:39 +01:00
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
return $req->fetchAll();
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES SCHEDULEDS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère tout les sms programmés non en cours, et dont la date d'envoie inférieure à celle renseignée.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param string $date : \Date avant laquelle on veux les sms
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tableau avec les sms programmés demandés
|
|
|
|
*/
|
|
|
|
public function getScheduledsNotInProgressBefore($date)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM scheduled
|
|
|
|
WHERE progress = 0
|
|
|
|
AND at <= :date
|
2019-10-30 00:30:39 +01:00
|
|
|
';
|
2019-10-29 14:57:13 +01:00
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Insert un sms.
|
|
|
|
*
|
|
|
|
* @param string $date : La date d'envoi du SMS
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param string $content : Le contenu du SMS
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : le nombre de lignes crées
|
|
|
|
*/
|
|
|
|
public function insertScheduleds($date, $content)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
INSERT INTO scheduled(at, content, progress)
|
|
|
|
VALUES (:date, :content, :progress)
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
|
|
|
'content' => $content,
|
|
|
|
'progress' => false,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les sms programmés dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $contacts_ids : Tableau des id des sms à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
* @param mixed $scheduleds_ids
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteScheduledsIn($scheduleds_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM scheduled
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($scheduleds_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Cette fonction retourne les sms programmés pour un numéro donné et avant une date.
|
|
|
|
*
|
|
|
|
* @param string $date : La date avant laquel on veux les numéros (format yyyy-mm-dd hh:mm:ss)
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param string $number : Le numéro cible
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Les scheduleds correspondants
|
|
|
|
*/
|
|
|
|
public function getScheduledsBeforeDateForNumber($date, $number)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM scheduled
|
|
|
|
WHERE at <= :date
|
|
|
|
AND (
|
|
|
|
id IN (
|
|
|
|
SELECT id_scheduled
|
|
|
|
FROM scheduled_number
|
|
|
|
WHERE number = :number
|
|
|
|
)
|
|
|
|
OR id IN (
|
|
|
|
SELECT id_scheduled
|
|
|
|
FROM scheduled_contact
|
|
|
|
WHERE id_contact IN (
|
|
|
|
SELECT id
|
|
|
|
FROM contact
|
|
|
|
WHERE number = :number
|
|
|
|
)
|
|
|
|
)
|
|
|
|
OR id IN (
|
|
|
|
SELECT id_scheduled
|
|
|
|
FROM scheduled_group
|
|
|
|
WHERE id_group IN (
|
|
|
|
SELECT id_group
|
|
|
|
FROM group_contact
|
|
|
|
WHERE id_contact IN (
|
|
|
|
SELECT id
|
|
|
|
FROM contact
|
|
|
|
WHERE number = :number
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2019-10-30 00:30:39 +01:00
|
|
|
';
|
|
|
|
|
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'date' => $date,
|
|
|
|
'number' => $number,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES COMMANDS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère les commands dont l'id fait partie de la liste fournie.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param array $commands_ids = Tableau des id des commands voulus
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Retourne un tableau avec les commands adaptés
|
|
|
|
*/
|
|
|
|
public function getCommandsIn($commands_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM command
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($commands_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les commands dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $commands_ids : Tableau des id des commands à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteCommandsIn($commands_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM command
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($commands_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES SCHEDULEDS_CONTACTS
|
|
|
|
//
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Retourne tous les contacts pour un sms programmé donnée.
|
|
|
|
*
|
|
|
|
* @param int $id_sms : L'id du sms
|
|
|
|
* @param mixed $id_scheduled
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tous les contacts compris dans le schedulede
|
|
|
|
*/
|
|
|
|
public function getContactsForScheduled($id_scheduled)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT con.id as id, con.name as name, con.number as number
|
|
|
|
FROM scheduled_contact as s_c
|
|
|
|
JOIN contact as con
|
|
|
|
ON (s_c.id_contact = con.id)
|
|
|
|
WHERE(s_c.id_scheduled = :id_scheduled)
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'id_scheduled' => $id_scheduled,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les scheduleds_contacts pour un sms donné.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param int $id_scheduled : L'id du sms pour lequel on doit supprimer les scheduleds_contacts
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int Le nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteScheduleds_contactsForScheduled($id_scheduled)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM scheduled_contact
|
|
|
|
WHERE id_scheduled = :id_scheduled
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
|
|
|
'id_scheduled' => $id_scheduled,
|
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Change le statut des scheduleds dont l'id est fourni dans $scheduleds_id.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param array $scheduleds_ids = Tableau des id des sms voulus
|
2019-10-30 00:30:39 +01:00
|
|
|
* @param mixed $progress
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Retourne le nombre de lignes mises à jour
|
|
|
|
*/
|
|
|
|
public function updateProgressScheduledsIn($scheduleds_ids, $progress)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
UPDATE scheduled
|
|
|
|
SET progress = :progress
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($scheduleds_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
2019-10-30 00:30:39 +01:00
|
|
|
$params['progress'] = (bool) $progress;
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES SCHEDULEDS_NUMBERS
|
|
|
|
//
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les scheduleds_numbers pour un sms donné.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param int $id_scheduled : L'id du sms pour lequel on doit supprimer les scheduleds_numbers
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int Le nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteScheduleds_numbersForScheduled($id_scheduled)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM scheduled_number
|
|
|
|
WHERE id_scheduled = :id_scheduled
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
|
|
|
'id_scheduled' => $id_scheduled,
|
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Retourne tous les numéros pour un scheduled donné.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param int $id_scheduled : L'id du scheduled
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Tous les numéro compris dans le scheduled
|
|
|
|
*/
|
|
|
|
public function getNumbersForScheduled($id_scheduled)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM scheduled_number
|
|
|
|
WHERE id_scheduled = :id_scheduled
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'id_scheduled' => $id_scheduled,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES SCHEDULEDS_GROUPS
|
|
|
|
//
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les scheduleds_groups pour un sms donné.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param int $id_scheduled : L'id du sms pour lequel on doit supprimer les scheduleds_groups
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int Le nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteScheduleds_groupsForScheduled($id_scheduled)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM scheduled_group
|
|
|
|
WHERE id_scheduled = :id_scheduled
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
|
|
|
'id_scheduled' => $id_scheduled,
|
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Retourne tous les groups pour un scheduled donnée.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param int $id_scheduled : L'id du schedulede
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-30 00:17:10 +01:00
|
|
|
* @return array : Tous les groups compris dans le scheduled
|
2019-10-29 18:33:49 +01:00
|
|
|
*/
|
|
|
|
public function getGroupsForScheduled($id_scheduled)
|
|
|
|
{
|
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT gro.id as id, gro.name as name
|
|
|
|
FROM scheduled_group as s_g
|
|
|
|
JOIN group as gro
|
|
|
|
ON (s_g.id_group = gro.id)
|
|
|
|
WHERE(s_g.id_scheduled = :id_scheduled)
|
|
|
|
';
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
$params = [
|
2019-10-29 18:33:49 +01:00
|
|
|
'id_scheduled' => $id_scheduled,
|
2019-10-30 00:30:39 +01:00
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES USERS
|
|
|
|
//
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Récupère un utilisateur à partir de son email.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param string $email = L'email de l'utilisateur
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return array : Retourne l'utilisateur
|
|
|
|
*/
|
|
|
|
public function getUserFromEmail($email)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
SELECT *
|
|
|
|
FROM user
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE email = :email';
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
'email' => $email,
|
|
|
|
];
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::FETCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les users dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $users_ids : Tableau des id des users à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteUsersIn($users_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM user
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($users_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES TRANSFERS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Change le statut des tranfers dont l'id est fourni dans $transfers_id.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param array $transfers_ids = Tableau des id des transfers voulus
|
2019-10-30 00:30:39 +01:00
|
|
|
* @param mixed $progress
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Retourne le nombre de lignes mises à jour
|
|
|
|
*/
|
|
|
|
public function updateProgressTransfersIn($transfers_ids, $progress)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
UPDATE transfer
|
|
|
|
SET progress = :progress
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($transfers_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
2019-10-30 00:30:39 +01:00
|
|
|
$params['progress'] = (bool) $progress;
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les transfers dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $transfers_ids : Tableau des id des transfers à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteTransfersIn($transfers_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM transfer
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($transfers_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES EVENTS
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les events dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $events_ids : Tableau des id des events à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteEventsIn($events_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM event
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($events_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
|
2019-10-30 00:30:39 +01:00
|
|
|
//
|
|
|
|
// PARTIE DES REQUETES SMS STOP
|
|
|
|
//
|
2019-10-29 18:33:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 00:30:39 +01:00
|
|
|
* Supprime tous les sms_stops dont l'id fait partie du tableau fourni.
|
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @param $sms_stops_ids : Tableau des id des sms_stops à supprimer
|
2019-10-30 00:30:39 +01:00
|
|
|
*
|
2019-10-29 18:33:49 +01:00
|
|
|
* @return int : Nombre de lignes supprimées
|
|
|
|
*/
|
|
|
|
public function deleteSmsStopsIn($sms_stops_ids)
|
|
|
|
{
|
2019-10-30 00:30:39 +01:00
|
|
|
$query = '
|
2019-10-29 14:57:13 +01:00
|
|
|
DELETE FROM sms_stop
|
2019-10-30 00:30:39 +01:00
|
|
|
WHERE id ';
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
|
|
|
$generted_in = $this->_generate_in_from_array($sms_stops_ids);
|
|
|
|
$query .= $generted_in['QUERY'];
|
|
|
|
$params = $generted_in['PARAMS'];
|
|
|
|
|
|
|
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
|
|
}
|
|
|
|
}
|