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 SCHEDULEDS_NUMBERS
|
|
|
|
//
|
|
|
|
|
2019-10-29 18:33:49 +01:00
|
|
|
/**
|
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
|
|
|
|
*/
|
2019-11-06 18:08:22 +01:00
|
|
|
public function get_numbers_for_scheduled($id_scheduled)
|
2019-10-29 18:33:49 +01:00
|
|
|
{
|
|
|
|
$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
|
|
|
* 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
|
|
|
*/
|
2019-11-06 18:08:22 +01:00
|
|
|
public function get_groups_for_scheduled($id_scheduled)
|
2019-10-29 18:33:49 +01:00
|
|
|
{
|
|
|
|
$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
|
|
|
|
*/
|
2019-11-06 18:08:22 +01:00
|
|
|
public function get_user_from_email($email)
|
2019-10-29 18:33:49 +01:00
|
|
|
{
|
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
|
|
|
//
|
|
|
|
// 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
|
|
|
|
*/
|
2019-11-06 18:08:22 +01:00
|
|
|
public function update_progress_transfers_in($transfers_ids, $progress)
|
2019-10-29 18:33:49 +01:00
|
|
|
{
|
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
|
|
|
|
*/
|
2019-11-06 18:08:22 +01:00
|
|
|
public function delete_transfers_in($transfers_ids)
|
2019-10-29 18:33:49 +01:00
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
}
|