Add transfer controller and model, remove database model and transfer responsabilities
This commit is contained in:
parent
bda1c7ddfd
commit
c6050f06aa
|
@ -39,6 +39,17 @@ namespace controllers\internals;
|
||||||
return $this->model_command->list($nb_entry, $nb_entry * $page);
|
return $this->model_command->list($nb_entry, $nb_entry * $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all commands.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_all()
|
||||||
|
{
|
||||||
|
//Recupération des commandes
|
||||||
|
return $this->model_command->get_all();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cette fonction retourne une liste des commandes sous forme d'un tableau.
|
* Cette fonction retourne une liste des commandes sous forme d'un tableau.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,13 +15,20 @@ namespace controllers\internals;
|
||||||
class Console extends \descartes\InternalController
|
class Console extends \descartes\InternalController
|
||||||
{
|
{
|
||||||
private $model_command;
|
private $model_command;
|
||||||
private $model_database;
|
private $model_sended;
|
||||||
private $model_sent;
|
|
||||||
private $model_smsstop;
|
private $model_smsstop;
|
||||||
private $model_received;
|
private $model_received;
|
||||||
private $model_scheduled;
|
private $model_scheduled;
|
||||||
private $model_user;
|
private $model_user;
|
||||||
|
private $internal_contact;
|
||||||
|
private $internal_command;
|
||||||
|
private $internal_database;
|
||||||
|
private $internal_sended;
|
||||||
|
private $internal_sms_stop;
|
||||||
|
private $internal_received;
|
||||||
private $internal_scheduled;
|
private $internal_scheduled;
|
||||||
|
private $internal_user;
|
||||||
|
private $internal_transfer;
|
||||||
|
|
||||||
private $internal_event;
|
private $internal_event;
|
||||||
|
|
||||||
|
@ -30,8 +37,7 @@ class Console extends \descartes\InternalController
|
||||||
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
||||||
|
|
||||||
$this->model_command = new \models\Command($bdd);
|
$this->model_command = new \models\Command($bdd);
|
||||||
$this->model_database = new \models\DataBase($bdd);
|
$this->model_sended = new \models\Sended($bdd);
|
||||||
$this->model_sent = new \models\Sent($bdd);
|
|
||||||
$this->model_smsstop = new \models\SmsStop($bdd);
|
$this->model_smsstop = new \models\SmsStop($bdd);
|
||||||
$this->model_received = new \models\Received($bdd);
|
$this->model_received = new \models\Received($bdd);
|
||||||
$this->model_user = new \models\User($bdd);
|
$this->model_user = new \models\User($bdd);
|
||||||
|
@ -80,32 +86,32 @@ class Console extends \descartes\InternalController
|
||||||
$numbers = [];
|
$numbers = [];
|
||||||
|
|
||||||
//On récupère les numéros pour le Sms et on les ajoute
|
//On récupère les numéros pour le Sms et on les ajoute
|
||||||
$target_numbers = $this->model_database->get_numbers_for_scheduled($id_scheduled);
|
$target_numbers = $this->internal_scheduled->get_numbers($id_scheduled);
|
||||||
foreach ($target_numbers as $target_number)
|
foreach ($target_numbers as $target_number)
|
||||||
{
|
{
|
||||||
$numbers[] = $target_number['number'];
|
$numbers[] = $target_number['number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
//On récupère les contacts, et on ajoute les numéros
|
//On récupère les contacts, et on ajoute les numéros
|
||||||
$contacts = $this->model_database->getContactForScheduled($id_scheduled);
|
$contacts = $this->internal_scheduled->get_contacts($id_scheduled);
|
||||||
foreach ($contacts as $contact)
|
foreach ($contacts as $contact)
|
||||||
{
|
{
|
||||||
$numbers[] = $contact['number'];
|
$numbers[] = $contact['number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
//On récupère les groups
|
//On récupère les groups
|
||||||
$groups = $this->model_database->get_groups_for_scheduled($id_scheduled);
|
$groups = $this->internal_scheduled->get_groups($id_scheduled);
|
||||||
foreach ($groups as $group)
|
foreach ($groups as $group)
|
||||||
{
|
{
|
||||||
//On récupère les contacts du group et on les ajoute aux numéros
|
//On récupère les contacts du group et on les ajoute aux numéros
|
||||||
$contacts = $this->model_database->get_by_group($group['id']);
|
$contacts = $this->internal_contact->get_by_group($group['id']);
|
||||||
foreach ($contacts as $contact)
|
foreach ($contacts as $contact)
|
||||||
{
|
{
|
||||||
$numbers[] = $contact['number'];
|
$numbers[] = $contact['number'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$smsStops = $this->model_smsstop->_select('smsstop');
|
$smsStops = $this->internal_sms_stop->get_all();
|
||||||
|
|
||||||
foreach ($numbers as $number)
|
foreach ($numbers as $number)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +138,7 @@ class Console extends \descartes\InternalController
|
||||||
$now = $now->format('Y-m-d H:i:s');
|
$now = $now->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
//On peut maintenant ajouter le Sms
|
//On peut maintenant ajouter le Sms
|
||||||
if (!$id_sended = $this->model_sent->insert(['at' => $now, 'target' => $number, 'content' => $scheduled['content'], 'before_delivered' => ceil(mb_strlen($scheduled['content']) / 160)]))
|
if (!$id_sended = $this->model_sended->insert(['at' => $now, 'target' => $number, 'content' => $scheduled['content'], 'before_delivered' => ceil(mb_strlen($scheduled['content']) / 160)]))
|
||||||
{
|
{
|
||||||
echo 'Impossible d\'inserer le sms pour le numero '.$number."\n";
|
echo 'Impossible d\'inserer le sms pour le numero '.$number."\n";
|
||||||
}
|
}
|
||||||
|
@ -238,7 +244,7 @@ class Console extends \descartes\InternalController
|
||||||
$interval = new \DateInterval('PT12H');
|
$interval = new \DateInterval('PT12H');
|
||||||
$sinceDate = $now->sub($interval)->format('Y-m-d H:i:s');
|
$sinceDate = $now->sub($interval)->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
if (!$sendeds = $this->model_sent->_select('sendeds', ['target' => $number, 'delivered' => false, 'failed' => false, '>at' => $sinceDate], 'at', false, 1))
|
if (!$sendeds = $this->model_sended->_select('sendeds', ['target' => $number, 'delivered' => false, 'failed' => false, '>at' => $sinceDate], 'at', false, 1))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -248,8 +254,8 @@ class Console extends \descartes\InternalController
|
||||||
//On gère les echecs
|
//On gère les echecs
|
||||||
if ('Failed' === trim($text))
|
if ('Failed' === trim($text))
|
||||||
{
|
{
|
||||||
$this->model_sent->update($sended['id'], ['before_delivered' => 0, 'failed' => true]);
|
$this->model_sended->update($sended['id'], ['before_delivered' => 0, 'failed' => true]);
|
||||||
echo 'Sent Sms id '.$sended['id']." pass to failed status\n";
|
echo 'Sended Sms id '.$sended['id']." pass to failed status\n";
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -257,15 +263,15 @@ class Console extends \descartes\InternalController
|
||||||
//On gère le cas des messages de plus de 160 caractères, lesquels impliquent plusieurs accusés
|
//On gère le cas des messages de plus de 160 caractères, lesquels impliquent plusieurs accusés
|
||||||
if ($sended['before_delivered'] > 1)
|
if ($sended['before_delivered'] > 1)
|
||||||
{
|
{
|
||||||
$this->model_database->update($sended['id'], ['before_delivered' => $sended['before_delivered'] - 1]);
|
$this->internal_sended->decrement_before_delivered($sended['id']);
|
||||||
echo 'Sent Sms id '.$sended['id']." before_delivered decrement\n";
|
echo 'Sended Sms id '.$sended['id']." before_delivered decrement\n";
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Si tout est bon, que nous avons assez d'accusés, nous validons !
|
//Si tout est bon, que nous avons assez d'accusés, nous validons !
|
||||||
$this->model_database->update($sended['id'], ['before_delivered' => 0, 'delivered' => true]);
|
$this->internal_sended->set_delivered($sended['id']);
|
||||||
echo 'Sent Sms id '.$sended['id']." to delivered status\n";
|
echo 'Sended Sms id '.$sended['id']." to delivered status\n";
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -280,20 +286,20 @@ class Console extends \descartes\InternalController
|
||||||
$flags = \controllers\internals\Tool::parse_for_flag($text);
|
$flags = \controllers\internals\Tool::parse_for_flag($text);
|
||||||
|
|
||||||
//On créer le tableau qui permettra de stocker les commandes trouvées
|
//On créer le tableau qui permettra de stocker les commandes trouvées
|
||||||
|
|
||||||
$found_commands = [];
|
$found_commands = [];
|
||||||
|
|
||||||
//Si on reçu des identifiants
|
//Si on reçu des identifiants
|
||||||
if (\array_key_exists('LOGIN', $flags) && \array_key_exists('PASSWORD', $flags))
|
if (\array_key_exists('LOGIN', $flags) && \array_key_exists('PASSWORD', $flags))
|
||||||
{
|
{
|
||||||
//Si on a bien un utilisateur avec les identifiants reçus
|
$user = $this->internal_user->check_credentials($flags['LOGIN'], $flags['PASSWORD']);
|
||||||
$user = $this->model_database->get_user_from_email($flags['LOGIN']);
|
|
||||||
error_log('We found '.\count($user).' users');
|
error_log('We found '.\count($user).' users');
|
||||||
if ($user && $user['password'] === sha1($flags['PASSWORD']))
|
if ($user)
|
||||||
{
|
{
|
||||||
error_log('Password is valid');
|
error_log('Password is valid');
|
||||||
|
|
||||||
//On va passer en revue toutes les commandes, pour voir si on en trouve dans ce message
|
//On va passer en revue toutes les commandes, pour voir si on en trouve dans ce message
|
||||||
$commands = $this->model_database->_select('commands');
|
$commands = $this->internal_command->get_all();
|
||||||
|
|
||||||
error_log('We found '.\count($commands).' commands');
|
error_log('We found '.\count($commands).' commands');
|
||||||
foreach ($commands as $command)
|
foreach ($commands as $command)
|
||||||
|
@ -324,7 +330,7 @@ class Console extends \descartes\InternalController
|
||||||
$send_by = $number;
|
$send_by = $number;
|
||||||
$content = $text;
|
$content = $text;
|
||||||
$is_command = \count($found_commands);
|
$is_command = \count($found_commands);
|
||||||
if (!$this->model_received->insert(['at' => $date, 'send_by' => $send_by, 'content' => $content, 'is_command' => $is_command]))
|
if ($id_received = $this->internal_received->create($date, $send_by, $content, $is_command))
|
||||||
{
|
{
|
||||||
echo "Erreur lors de l'enregistrement du Sms\n";
|
echo "Erreur lors de l'enregistrement du Sms\n";
|
||||||
error_log('Unable to process the Sms in file "'.$dir);
|
error_log('Unable to process the Sms in file "'.$dir);
|
||||||
|
@ -332,7 +338,7 @@ class Console extends \descartes\InternalController
|
||||||
}
|
}
|
||||||
|
|
||||||
//On insert le Sms dans le tableau des sms à envoyer par mail
|
//On insert le Sms dans le tableau des sms à envoyer par mail
|
||||||
$this->model_database->_insert('transfers', ['id_received' => $this->model_database->lastId(), 'progress' => false]);
|
$this->internal_transfer->create($id_received);
|
||||||
|
|
||||||
//Chaque commande sera executée.
|
//Chaque commande sera executée.
|
||||||
foreach ($found_commands as $command_name => $command)
|
foreach ($found_commands as $command_name => $command)
|
||||||
|
@ -359,37 +365,32 @@ class Console extends \descartes\InternalController
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$transfers = $this->model_database->_select('transfers', ['progress' => false]);
|
$users = $this->internal_user->gets_by_transfer(true);
|
||||||
|
$transfers = $this->internal_transfer->get_not_in_progress();
|
||||||
|
|
||||||
$ids_transfers = [];
|
|
||||||
$ids_receiveds = [];
|
|
||||||
foreach ($transfers as $transfer)
|
foreach ($transfers as $transfer)
|
||||||
{
|
{
|
||||||
$ids_transfers[] = $transfer['id'];
|
$this->internal_transfer->update($transfer['id'], $transfer['id_received'], true);
|
||||||
$ids_receiveds[] = $transfer['id_received'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->model_database->update_progress_transfers_in($ids_transfers, true);
|
$received = $this->internal_received->get($transfer['id_received']);
|
||||||
|
if (!$received)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$receiveds = $this->model_received->gets($ids_receiveds);
|
foreach ($users as $user)
|
||||||
|
|
||||||
$users = $this->model_user->_select('users', ['transfer' => true]);
|
|
||||||
|
|
||||||
foreach ($users as $user)
|
|
||||||
{
|
|
||||||
foreach ($receiveds as $received)
|
|
||||||
{
|
{
|
||||||
echo "Transfer d'un Sms du ".$received['send_by']." à l'email ".$user['email'];
|
echo "Transfer d'un Sms du ".$received['send_by']." à l'email ".$user['email'];
|
||||||
|
|
||||||
$to = $user['email'];
|
$to = $user['email'];
|
||||||
$subject = '[RaspiSms] - Transfert d\'un Sms du '.$received['send_by'];
|
$subject = '[RaspiSms] - Transfert d\'un Sms du '.$received['send_by'];
|
||||||
$message = 'Le numéro '.$received['send_by']." vous a envoyé un Sms : \n".$received['content'];
|
$message = 'Le numéro '.$received['send_by']." vous a envoyé un Sms : \n".$received['content'];
|
||||||
|
|
||||||
$ok = mail($to, $subject, $message);
|
$success = mail($to, $subject, $message);
|
||||||
|
echo ' ... '.($success ? 'ok' : 'ko')."\n";
|
||||||
echo ' ... '.($ok ? 'OK' : 'KO')."\n";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->model_database->delete_transfers_in($ids_transfers);
|
$this->internal_transfer->delete($transfer['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,10 +182,10 @@ namespace controllers\internals;
|
||||||
*
|
*
|
||||||
* @return array : La liste des scheduledes
|
* @return array : La liste des scheduledes
|
||||||
*/
|
*/
|
||||||
public function get_number($id_scheduled)
|
public function get_numbers($id_scheduled)
|
||||||
{
|
{
|
||||||
//Recupération des scheduledes
|
//Recupération des scheduledes
|
||||||
return $this->model_scheduled->get_number($id_scheduled);
|
return $this->model_scheduled->get_numbers($id_scheduled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,10 +195,10 @@ namespace controllers\internals;
|
||||||
*
|
*
|
||||||
* @return array : La liste des contact
|
* @return array : La liste des contact
|
||||||
*/
|
*/
|
||||||
public function get_contact($id_scheduled)
|
public function get_contacts($id_scheduled)
|
||||||
{
|
{
|
||||||
//Recupération des scheduledes
|
//Recupération des scheduledes
|
||||||
return $this->model_scheduled->get_contact($id_scheduled);
|
return $this->model_scheduled->get_contacts($id_scheduled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,10 +208,10 @@ namespace controllers\internals;
|
||||||
*
|
*
|
||||||
* @return array : La liste des group
|
* @return array : La liste des group
|
||||||
*/
|
*/
|
||||||
public function get_group($id_scheduled)
|
public function get_groups($id_scheduled)
|
||||||
{
|
{
|
||||||
//Recupération des scheduledes
|
//Recupération des scheduledes
|
||||||
return $this->model_scheduled->get_group($id_scheduled);
|
return $this->model_scheduled->get_groups($id_scheduled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,13 +15,13 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Classe des sendedes.
|
* Classe des sendedes.
|
||||||
*/
|
*/
|
||||||
class Sent extends \descartes\InternalController
|
class Sended extends \descartes\InternalController
|
||||||
{
|
{
|
||||||
private $model_sent;
|
private $model_sended;
|
||||||
|
|
||||||
public function __construct(\PDO $bdd)
|
public function __construct(\PDO $bdd)
|
||||||
{
|
{
|
||||||
$this->model_sent = new \models\Sent($bdd);
|
$this->model_sended = new \models\Sended($bdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ namespace controllers\internals;
|
||||||
public function list($nb_entry = false, $page = false)
|
public function list($nb_entry = false, $page = false)
|
||||||
{
|
{
|
||||||
//Recupération des sendedes
|
//Recupération des sendedes
|
||||||
return $this->model_sent->list($nb_entry, $nb_entry * $page);
|
return $this->model_sended->list($nb_entry, $nb_entry * $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ namespace controllers\internals;
|
||||||
public function gets($ids)
|
public function gets($ids)
|
||||||
{
|
{
|
||||||
//Recupération des sendedes
|
//Recupération des sendedes
|
||||||
return $this->model_sent->gets($ids);
|
return $this->model_sended->gets($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,7 @@ namespace controllers\internals;
|
||||||
*/
|
*/
|
||||||
public function get_lasts_by_date($nb_entry = false)
|
public function get_lasts_by_date($nb_entry = false)
|
||||||
{
|
{
|
||||||
return $this->model_sent->get_lasts_by_date($nb_entry);
|
return $this->model_sended->get_lasts_by_date($nb_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +73,7 @@ namespace controllers\internals;
|
||||||
public function get_by_target($target)
|
public function get_by_target($target)
|
||||||
{
|
{
|
||||||
//Recupération des sendeds
|
//Recupération des sendeds
|
||||||
return $this->model_sent->get_by_target($target);
|
return $this->model_sended->get_by_target($target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +86,7 @@ namespace controllers\internals;
|
||||||
*/
|
*/
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
return $this->model_sent->delete($id);
|
return $this->model_sended->delete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +98,7 @@ namespace controllers\internals;
|
||||||
*/
|
*/
|
||||||
public function create($sended)
|
public function create($sended)
|
||||||
{
|
{
|
||||||
return $this->model_sent->create($sended);
|
return $this->model_sended->create($sended);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +108,7 @@ namespace controllers\internals;
|
||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return $this->model_sent->count();
|
return $this->model_sended->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +120,7 @@ namespace controllers\internals;
|
||||||
*/
|
*/
|
||||||
public function count_by_day_since($date)
|
public function count_by_day_since($date)
|
||||||
{
|
{
|
||||||
$counts_by_day = $this->model_sent->count_by_day_since($date);
|
$counts_by_day = $this->model_sended->count_by_day_since($date);
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
foreach ($counts_by_day as $count_by_day)
|
foreach ($counts_by_day as $count_by_day)
|
||||||
|
@ -130,4 +130,28 @@ namespace controllers\internals;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement before delivered.
|
||||||
|
*
|
||||||
|
* @param int $id_sended : id of the sended to decrement delivered for
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function decrement_before_delivered($id_sended)
|
||||||
|
{
|
||||||
|
return $this->model_sended->decrement_before_delivered($id_sended);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update sended to delivered.
|
||||||
|
*
|
||||||
|
* @param int $id_sended : id of the sended to mark as delivered
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function set_delivered($id_sended)
|
||||||
|
{
|
||||||
|
return $this->model_sended->update($id_sended, ['before_delivered' => 0, 'delivered' => true]);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,16 @@ namespace controllers\internals;
|
||||||
$this->model_sms_stop = new \models\SmsStop($bdd);
|
$this->model_sms_stop = new \models\SmsStop($bdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all smsstops.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_all()
|
||||||
|
{
|
||||||
|
return $this->model_sms_stop->get_all();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cette fonction retourne une liste des smsstopes sous forme d'un tableau.
|
* Cette fonction retourne une liste des smsstopes sous forme d'un tableau.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 controllers\internals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe des transfers.
|
||||||
|
*/
|
||||||
|
class Transfer extends \descartes\InternalController
|
||||||
|
{
|
||||||
|
private $model_transfer;
|
||||||
|
private $internal_event;
|
||||||
|
|
||||||
|
public function __construct(\PDO $bdd)
|
||||||
|
{
|
||||||
|
$this->model_transfer = new \models\Transfer($bdd);
|
||||||
|
$this->internal_event = new \controllers\internals\Event($bdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of transfers as an array.
|
||||||
|
*
|
||||||
|
* @param mixed(int|bool) $nb_entry : Le nombre d'entrées à retourner par page
|
||||||
|
* @param mixed(int|bool) $page : Le numéro de page en cours
|
||||||
|
*
|
||||||
|
* @return array : La liste des transfers
|
||||||
|
*/
|
||||||
|
public function list($nb_entry = false, $page = false)
|
||||||
|
{
|
||||||
|
return $this->model_transfer->list($nb_entry, $nb_entry * $page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all transfers.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_all()
|
||||||
|
{
|
||||||
|
//Recupération des transfers
|
||||||
|
return $this->model_transfer->get_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get transfers not in progress.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_not_in_progress()
|
||||||
|
{
|
||||||
|
return $this->model_transfer->get_not_in_progress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction retourne une liste des transfers sous forme d'un tableau.
|
||||||
|
*
|
||||||
|
* @param array int $ids : Les ids des entrées à retourner
|
||||||
|
*
|
||||||
|
* @return array : La liste des transfers
|
||||||
|
*/
|
||||||
|
public function gets($ids)
|
||||||
|
{
|
||||||
|
//Recupération des transfers
|
||||||
|
return $this->model_transfer->gets($ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction permet de compter le nombre de scheduleds.
|
||||||
|
*
|
||||||
|
* @return int : Le nombre d'entrées dans la table
|
||||||
|
*/
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
return $this->model_transfer->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction va supprimer un transfer.
|
||||||
|
*
|
||||||
|
* @param array $id : L'id de la transfer à supprimer
|
||||||
|
*
|
||||||
|
* @return int : Le nombre de transfers supprimées;
|
||||||
|
*/
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
return $this->model_transfer->delete($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function insert a new transfer.
|
||||||
|
*
|
||||||
|
* @param int $id_received : Id of the received message to transfer
|
||||||
|
* @param bool $progress : If we must mark it as in progress
|
||||||
|
*
|
||||||
|
* @return int id of the new inserted transfer
|
||||||
|
*/
|
||||||
|
public function create($id_received, $progress = false)
|
||||||
|
{
|
||||||
|
$transfer = [
|
||||||
|
'id_received' => $id_received,
|
||||||
|
'progress' => $progress,
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = $this->model_transfer->insert($transfer);
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction met à jour un transfer.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param int $id_received
|
||||||
|
* @param bool $progress
|
||||||
|
*
|
||||||
|
* @return int : le nombre de ligne modifiées
|
||||||
|
*/
|
||||||
|
public function update($id, $id_received, $progress)
|
||||||
|
{
|
||||||
|
$transfer = [
|
||||||
|
'id_received' => $id_received,
|
||||||
|
'progress' => $progress,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->model_transfer->update($id, $transfer);
|
||||||
|
}
|
||||||
|
}
|
|
@ -126,6 +126,16 @@ namespace controllers\internals;
|
||||||
return $this->model_user->get_by_email($email);
|
return $this->model_user->get_by_email($email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return users by transfer status.
|
||||||
|
*
|
||||||
|
* @param bool $transfer : transfer status
|
||||||
|
*/
|
||||||
|
public function gets_by_transfer($transfer)
|
||||||
|
{
|
||||||
|
return $this->model_user->get_by_transfer($transfer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cette fonction met à jour une série de users.
|
* Cette fonction met à jour une série de users.
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace controllers\publics;
|
||||||
{
|
{
|
||||||
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
||||||
|
|
||||||
$this->internal_sended = new \controllers\internals\Sent($bdd);
|
$this->internal_sended = new \controllers\internals\Sended($bdd);
|
||||||
$this->internal_received = new \controllers\internals\Received($bdd);
|
$this->internal_received = new \controllers\internals\Received($bdd);
|
||||||
$this->internal_contact = new \controllers\internals\Contact($bdd);
|
$this->internal_contact = new \controllers\internals\Contact($bdd);
|
||||||
$this->internal_group = new \controllers\internals\Group($bdd);
|
$this->internal_group = new \controllers\internals\Group($bdd);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace controllers\publics;
|
||||||
{
|
{
|
||||||
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
||||||
|
|
||||||
$this->internal_sended = new \controllers\internals\Sent($bdd);
|
$this->internal_sended = new \controllers\internals\Sended($bdd);
|
||||||
$this->internal_scheduled = new \controllers\internals\Scheduled($bdd);
|
$this->internal_scheduled = new \controllers\internals\Scheduled($bdd);
|
||||||
$this->internal_received = new \controllers\internals\Received($bdd);
|
$this->internal_received = new \controllers\internals\Received($bdd);
|
||||||
$this->internal_contact = new \controllers\internals\Contact($bdd);
|
$this->internal_contact = new \controllers\internals\Contact($bdd);
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace controllers\publics;
|
||||||
/**
|
/**
|
||||||
* Page des sendeds.
|
* Page des sendeds.
|
||||||
*/
|
*/
|
||||||
class Sent extends \descartes\Controller
|
class Sended extends \descartes\Controller
|
||||||
{
|
{
|
||||||
private $internal_sended;
|
private $internal_sended;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace controllers\publics;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
||||||
$this->internal_sended = new \controllers\internals\Sent($bdd);
|
$this->internal_sended = new \controllers\internals\Sended($bdd);
|
||||||
|
|
||||||
\controllers\internals\Tool::verifyconnect();
|
\controllers\internals\Tool::verifyconnect();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ namespace controllers\publics;
|
||||||
{
|
{
|
||||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
|
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
|
||||||
|
|
||||||
return $this->redirect(\descartes\Router::url('Sent', 'list'));
|
return $this->redirect(\descartes\Router::url('Sended', 'list'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = $_GET['ids'] ?? [];
|
$ids = $_GET['ids'] ?? [];
|
||||||
|
@ -69,6 +69,6 @@ namespace controllers\publics;
|
||||||
$this->internal_sended->delete($id);
|
$this->internal_sended->delete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirect(\descartes\Router::url('Sent', 'list'));
|
return $this->redirect(\descartes\Router::url('Sended', 'list'));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,16 @@ namespace models;
|
||||||
*/
|
*/
|
||||||
class Command extends \descartes\Model
|
class Command extends \descartes\Model
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get all commands.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_all()
|
||||||
|
{
|
||||||
|
return $this->_select('command');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne une entrée par son id.
|
* Retourne une entrée par son id.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
class DataBase extends \descartes\Model
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// PARTIE DES REQUETES SCHEDULEDS_NUMBERS
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retourne tous les numéros pour un scheduled donné.
|
|
||||||
*
|
|
||||||
* @param int $id_scheduled : L'id du scheduled
|
|
||||||
*
|
|
||||||
* @return array : Tous les numéro compris dans le scheduled
|
|
||||||
*/
|
|
||||||
public function get_numbers_for_scheduled($id_scheduled)
|
|
||||||
{
|
|
||||||
$query = '
|
|
||||||
SELECT *
|
|
||||||
FROM scheduled_number
|
|
||||||
WHERE id_scheduled = :id_scheduled
|
|
||||||
';
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'id_scheduled' => $id_scheduled,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->_run_query($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// PARTIE DES REQUETES SCHEDULEDS_GROUPS
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retourne tous les groups pour un scheduled donnée.
|
|
||||||
*
|
|
||||||
* @param int $id_scheduled : L'id du schedulede
|
|
||||||
*
|
|
||||||
* @return array : Tous les groups compris dans le scheduled
|
|
||||||
*/
|
|
||||||
public function get_groups_for_scheduled($id_scheduled)
|
|
||||||
{
|
|
||||||
$query = '
|
|
||||||
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)
|
|
||||||
';
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'id_scheduled' => $id_scheduled,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->_run_query($query, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// PARTIE DES REQUETES USERS
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère un utilisateur à partir de son email.
|
|
||||||
*
|
|
||||||
* @param string $email = L'email de l'utilisateur
|
|
||||||
*
|
|
||||||
* @return array : Retourne l'utilisateur
|
|
||||||
*/
|
|
||||||
public function get_user_from_email($email)
|
|
||||||
{
|
|
||||||
$query = '
|
|
||||||
SELECT *
|
|
||||||
FROM user
|
|
||||||
WHERE email = :email';
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'email' => $email,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->_run_query($query, $params, self::FETCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// PARTIE DES REQUETES TRANSFERS
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change le statut des tranfers dont l'id est fourni dans $transfers_id.
|
|
||||||
*
|
|
||||||
* @param array $transfers_ids = Tableau des id des transfers voulus
|
|
||||||
* @param mixed $progress
|
|
||||||
*
|
|
||||||
* @return int : Retourne le nombre de lignes mises à jour
|
|
||||||
*/
|
|
||||||
public function update_progress_transfers_in($transfers_ids, $progress)
|
|
||||||
{
|
|
||||||
$query = '
|
|
||||||
UPDATE transfer
|
|
||||||
SET progress = :progress
|
|
||||||
WHERE id ';
|
|
||||||
|
|
||||||
//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'];
|
|
||||||
$params['progress'] = (bool) $progress;
|
|
||||||
|
|
||||||
return $this->_run_query($query, $params, self::ROWCOUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Supprime tous les transfers dont l'id fait partie du tableau fourni.
|
|
||||||
*
|
|
||||||
* @param $transfers_ids : Tableau des id des transfers à supprimer
|
|
||||||
*
|
|
||||||
* @return int : Nombre de lignes supprimées
|
|
||||||
*/
|
|
||||||
public function delete_transfers_in($transfers_ids)
|
|
||||||
{
|
|
||||||
$query = '
|
|
||||||
DELETE FROM transfer
|
|
||||||
WHERE id ';
|
|
||||||
|
|
||||||
//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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -197,7 +197,7 @@ namespace models;
|
||||||
*
|
*
|
||||||
* @return array : Les numéros des scheduled
|
* @return array : Les numéros des scheduled
|
||||||
*/
|
*/
|
||||||
public function get_number($id_scheduled)
|
public function get_numbers($id_scheduled)
|
||||||
{
|
{
|
||||||
return $this->_select('scheduled_number', ['id_scheduled' => $id_scheduled]);
|
return $this->_select('scheduled_number', ['id_scheduled' => $id_scheduled]);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ namespace models;
|
||||||
*
|
*
|
||||||
* @return array : Les contact du scheduled
|
* @return array : Les contact du scheduled
|
||||||
*/
|
*/
|
||||||
public function get_contact($id_scheduled)
|
public function get_contacts($id_scheduled)
|
||||||
{
|
{
|
||||||
$query = 'SELECT * FROM contact WHERE id IN (SELECT id_contact FROM scheduled_contact WHERE id_scheduled = :id_scheduled)';
|
$query = 'SELECT * FROM contact WHERE id IN (SELECT id_contact FROM scheduled_contact WHERE id_scheduled = :id_scheduled)';
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ namespace models;
|
||||||
*
|
*
|
||||||
* @return array : Les groups du scheduled
|
* @return array : Les groups du scheduled
|
||||||
*/
|
*/
|
||||||
public function get_group($id_scheduled)
|
public function get_groups($id_scheduled)
|
||||||
{
|
{
|
||||||
$query = 'SELECT * FROM group WHERE id IN (SELECT id_group FROM scheduled_group WHERE id_scheduled = :id_scheduled)';
|
$query = 'SELECT * FROM group WHERE id IN (SELECT id_group FROM scheduled_group WHERE id_scheduled = :id_scheduled)';
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace models;
|
||||||
/**
|
/**
|
||||||
* Cette classe gère les accès bdd pour les sendedes.
|
* Cette classe gère les accès bdd pour les sendedes.
|
||||||
*/
|
*/
|
||||||
class Sent extends \descartes\Model
|
class Sended extends \descartes\Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Retourne une entrée par son id.
|
* Retourne une entrée par son id.
|
||||||
|
@ -170,4 +170,22 @@ namespace models;
|
||||||
|
|
||||||
return $this->_run_query($query, $params);
|
return $this->_run_query($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement before_delivered field.
|
||||||
|
*
|
||||||
|
* @param int $id_sended : id of the sended sms to decrement
|
||||||
|
*/
|
||||||
|
public function decrement_before_delivered($id_sended)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE sended
|
||||||
|
SET before_delivered = before_delivered - 1
|
||||||
|
WHERE id = :id_sended
|
||||||
|
';
|
||||||
|
|
||||||
|
$params = ['id_sended' => $id_sended];
|
||||||
|
|
||||||
|
return $this->_run_query($query, $params);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,16 @@ namespace models;
|
||||||
*/
|
*/
|
||||||
class SmsStop extends \descartes\Model
|
class SmsStop extends \descartes\Model
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get all smsstops.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_all()
|
||||||
|
{
|
||||||
|
return $this->_select('smsstop');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne une entrée par son id.
|
* Retourne une entrée par son id.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette classe gère les accès bdd pour les transferes.
|
||||||
|
*/
|
||||||
|
class Transfer extends \descartes\Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get all transfers.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_all()
|
||||||
|
{
|
||||||
|
return $this->_select('transfer');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get transfers not in progress.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_not_in_progress()
|
||||||
|
{
|
||||||
|
return $this->_select('transfer', ['progress' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne une entrée par son id.
|
||||||
|
*
|
||||||
|
* @param int $id : L'id de l'entrée
|
||||||
|
*
|
||||||
|
* @return array : L'entrée
|
||||||
|
*/
|
||||||
|
public function get($id)
|
||||||
|
{
|
||||||
|
$transfers = $this->_select('transfer', ['id' => $id]);
|
||||||
|
|
||||||
|
return isset($transfers[0]) ? $transfers[0] : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne une liste de transferes sous forme d'un tableau.
|
||||||
|
*
|
||||||
|
* @param int $limit : Nombre de résultat maximum à retourner
|
||||||
|
* @param int $offset : Nombre de résultat à ingnorer
|
||||||
|
*/
|
||||||
|
public function list($limit, $offset)
|
||||||
|
{
|
||||||
|
return $this->_select('transfer', [], '', false, $limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne une liste de transferes sous forme d'un tableau.
|
||||||
|
*
|
||||||
|
* @param array $ids : un ou plusieurs id d'entrées à récupérer
|
||||||
|
*
|
||||||
|
* @return array : La liste des entrées
|
||||||
|
*/
|
||||||
|
public function gets($ids)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT * FROM transfer
|
||||||
|
WHERE id ';
|
||||||
|
|
||||||
|
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
||||||
|
$generated_in = $this->_generate_in_from_array($ids);
|
||||||
|
$query .= $generated_in['QUERY'];
|
||||||
|
$params = $generated_in['PARAMS'];
|
||||||
|
|
||||||
|
return $this->_run_query($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supprime un transfer.
|
||||||
|
*
|
||||||
|
* @param array $id : l'id de l'entrée à supprimer
|
||||||
|
*
|
||||||
|
* @return int : Le nombre de lignes supprimées
|
||||||
|
*/
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
DELETE FROM transfer
|
||||||
|
WHERE id = :id';
|
||||||
|
|
||||||
|
$params = ['id' => $id];
|
||||||
|
|
||||||
|
return $this->_run_query($query, $params, self::ROWCOUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert un transfer.
|
||||||
|
*
|
||||||
|
* @param array $transfer : La transfere à insérer
|
||||||
|
*
|
||||||
|
* @return mixed bool|int : false si echec, sinon l'id de la nouvelle lignée insérée
|
||||||
|
*/
|
||||||
|
public function insert($transfer)
|
||||||
|
{
|
||||||
|
$result = $this->_insert('transfer', $transfer);
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_last_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Met à jour un transfer par son id.
|
||||||
|
*
|
||||||
|
* @param int $id : L'id de la transfer à modifier
|
||||||
|
* @param array $transfer : Les données à mettre à jour pour la transfere
|
||||||
|
*
|
||||||
|
* @return int : le nombre de ligne modifiées
|
||||||
|
*/
|
||||||
|
public function update($id, $transfer)
|
||||||
|
{
|
||||||
|
return $this->_update('transfer', $transfer, ['id' => $id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compte le nombre d'entrées dans la table.
|
||||||
|
*
|
||||||
|
* @return int : Le nombre d'entrées
|
||||||
|
*/
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
return $this->_count('transfer');
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,16 @@ namespace models;
|
||||||
return $this->_select_one('user', ['email' => $email]);
|
return $this->_select_one('user', ['email' => $email]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return users by transfer status.
|
||||||
|
*
|
||||||
|
* @param bool $transfer : transfer status
|
||||||
|
*/
|
||||||
|
public function gets_by_transfer($transfer)
|
||||||
|
{
|
||||||
|
return $this->_select('transfer', ['transfer' => $transfer]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of user.
|
* Return list of user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -166,7 +166,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<a href="<?php echo \Router::url('Sent', 'list'); ?>">Voir tous les SMS envoyés <i class="fa fa-arrow-circle-right"></i></a>
|
<a href="<?php echo \Router::url('Sended', 'list'); ?>">Voir tous les SMS envoyés <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<a href="javascript:;" data-toggle="collapse" data-target="#logs"><i class="fa fa-fw fa-file-text"></i> Logs <i class="fa fa-fw fa-caret-down"></i></a>
|
<a href="javascript:;" data-toggle="collapse" data-target="#logs"><i class="fa fa-fw fa-file-text"></i> Logs <i class="fa fa-fw fa-caret-down"></i></a>
|
||||||
<ul id="logs" class="collapse <?php echo in_array($page, array('sendeds', 'receiveds', 'events', 'smsstop')) ? 'in' : ''; ?>">
|
<ul id="logs" class="collapse <?php echo in_array($page, array('sendeds', 'receiveds', 'events', 'smsstop')) ? 'in' : ''; ?>">
|
||||||
<li <?php echo $page == 'sendeds' ? 'class="active"' : ''; ?>>
|
<li <?php echo $page == 'sendeds' ? 'class="active"' : ''; ?>>
|
||||||
<a href="<?php echo \Router::url('Sent', 'list'); ?>"><i class="fa fa-fw fa-send"></i> SMS envoyés</a>
|
<a href="<?php echo \Router::url('Sended', 'list'); ?>"><i class="fa fa-fw fa-send"></i> SMS envoyés</a>
|
||||||
</li>
|
</li>
|
||||||
<li <?php echo $page == 'receiveds' ? 'class="active"' : ''; ?>>
|
<li <?php echo $page == 'receiveds' ? 'class="active"' : ''; ?>>
|
||||||
<a href="<?php echo \Router::url('Received', 'list'); ?>"><i class="fa fa-fw fa-download"></i> SMS reçus</a>
|
<a href="<?php echo \Router::url('Received', 'list'); ?>"><i class="fa fa-fw fa-download"></i> SMS reçus</a>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
//Template dashboard
|
//Template dashboard
|
||||||
|
|
||||||
$this->render('incs/head', ['title' => 'Sents - Show All'])
|
$this->render('incs/head', ['title' => 'Sendeds - Show All'])
|
||||||
?>
|
?>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<?php
|
<?php
|
||||||
|
@ -72,12 +72,12 @@
|
||||||
<?php if ($_SESSION['user']['admin']) { ?>
|
<?php if ($_SESSION['user']['admin']) { ?>
|
||||||
<div class="text-right col-xs-12 no-padding">
|
<div class="text-right col-xs-12 no-padding">
|
||||||
<strong>Action pour la séléction :</strong>
|
<strong>Action pour la séléction :</strong>
|
||||||
<button class="btn btn-default" type="submit" formaction="<?php echo \Router::url('Sent', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
<button class="btn btn-default" type="submit" formaction="<?php echo \Router::url('Sended', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<ul class="pager">
|
<ul class="pager">
|
||||||
<?php if ($page) { ?>
|
<?php if ($page) { ?>
|
||||||
<li><a href="<?php echo \Router::url('Sent', 'list', array('page' => $page - 1)); ?>"><span aria-hidden="true">←</span> Précèdents</a></li>
|
<li><a href="<?php echo \Router::url('Sended', 'list', array('page' => $page - 1)); ?>"><span aria-hidden="true">←</span> Précèdents</a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
Page : <?php $this->s($page + 1); ?>
|
Page : <?php $this->s($page + 1); ?>
|
||||||
|
|
Loading…
Reference in New Issue