Add send sms to contacts and groups by grouped actions
This commit is contained in:
parent
c6c65c201f
commit
0ef7a9cc36
|
@ -19,6 +19,8 @@ namespace controllers\publics;
|
|||
private $internal_scheduled;
|
||||
private $internal_phone;
|
||||
private $internal_contact;
|
||||
private $internal_group;
|
||||
private $internal_conditional_group;
|
||||
|
||||
/**
|
||||
* Cette fonction est appelée avant toute les autres :
|
||||
|
@ -32,6 +34,8 @@ namespace controllers\publics;
|
|||
$this->internal_scheduled = new \controllers\internals\Scheduled($bdd);
|
||||
$this->internal_phone = new \controllers\internals\Phone($bdd);
|
||||
$this->internal_contact = new \controllers\internals\Contact($bdd);
|
||||
$this->internal_group = new \controllers\internals\Group($bdd);
|
||||
$this->internal_conditional_group = new \controllers\internals\ConditionalGroup($bdd);
|
||||
|
||||
\controllers\internals\Tool::verifyconnect();
|
||||
}
|
||||
|
@ -82,20 +86,57 @@ namespace controllers\publics;
|
|||
|
||||
/**
|
||||
* Cette fonction retourne la page d'ajout d'un scheduled.
|
||||
* @param $prefilled : If we have prefilled some fields (possible values : 'contacts', 'groups', 'conditional_groups', false)
|
||||
*/
|
||||
public function add()
|
||||
public function add($prefilled = false)
|
||||
{
|
||||
$now = new \DateTime();
|
||||
$less_one_minute = new \DateInterval('PT1M');
|
||||
$now->sub($less_one_minute);
|
||||
|
||||
$contacts = $this->internal_contact->gets_for_user($_SESSION['user']['id']);
|
||||
$phones = $this->internal_phone->gets_for_user($_SESSION['user']['id']);
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
|
||||
$contacts = $this->internal_contact->gets_for_user($id_user);
|
||||
$phones = $this->internal_phone->gets_for_user($id_user);
|
||||
|
||||
$prefilled_contacts = [];
|
||||
$prefilled_groups = [];
|
||||
$prefilled_conditional_groups = [];
|
||||
|
||||
if ($prefilled)
|
||||
{
|
||||
$ids = $_GET['ids'] ?? [];
|
||||
}
|
||||
|
||||
if ($prefilled === 'contacts')
|
||||
{
|
||||
foreach ($this->internal_contact->gets_in_for_user($id_user, $ids) as $contact)
|
||||
{
|
||||
$prefilled_contacts[] = $contact['id'];
|
||||
}
|
||||
}
|
||||
elseif ($prefilled === 'groups')
|
||||
{
|
||||
foreach ($this->internal_group->gets_in_for_user($id_user, $ids) as $group)
|
||||
{
|
||||
$prefilled_groups[] = $group['id'];
|
||||
}
|
||||
}
|
||||
elseif ($prefilled === 'conditional_groups')
|
||||
{
|
||||
foreach ($this->internal_conditional_group->gets_in_for_user($id_user, $ids) as $conditional_group)
|
||||
{
|
||||
$prefilled_conditional_groups[] = $conditional_group['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('scheduled/add', [
|
||||
'now' => $now->format('Y-m-d H:i'),
|
||||
'contacts' => $contacts,
|
||||
'phones' => $phones,
|
||||
'prefilled_contacts' => $prefilled_contacts,
|
||||
'prefilled_groups' => $prefilled_groups,
|
||||
'prefilled_conditional_groups' => $prefilled_conditional_groups,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,15 +79,23 @@ namespace models;
|
|||
*/
|
||||
public function gets_in_for_user(int $id_user, $ids)
|
||||
{
|
||||
if (!$ids)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT * FROM `' . $this->get_table_name() . '`
|
||||
WHERE id_user = :id_user
|
||||
WHERE id_user = :id_user
|
||||
AND id ';
|
||||
|
||||
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
||||
$params = [];
|
||||
|
||||
$generated_in = $this->_generate_in_from_array($ids);
|
||||
$query .= $generated_in['QUERY'];
|
||||
$params = $generated_in['PARAMS'];
|
||||
|
||||
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
|
||||
$params['id_user'] = $id_user;
|
||||
|
||||
return $this->_run_query($query, $params);
|
||||
|
|
|
@ -106,7 +106,10 @@
|
|||
'/scheduled/',
|
||||
'/scheduled/p/{page}/',
|
||||
],
|
||||
'add' => '/scheduled/add/',
|
||||
'add' => [
|
||||
'/scheduled/add/',
|
||||
'/scheduled/add/{prefilled}/',
|
||||
],
|
||||
'create' => '/scheduled/create/{csrf}/',
|
||||
'edit' => '/scheduled/edit/',
|
||||
'update' => '/scheduled/update/{csrf}/',
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<?php if ($groups) { ?>
|
||||
<div class="text-right col-xs-6 no-padding">
|
||||
<strong>Action pour la séléction :</strong>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Scheduled', 'add', ['prefilled' => 'conditional_groups']); ?>"><span class="fa fa-send"></span> Envoyer un message</button>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('ConditionalGroup', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
|
||||
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('ConditionalGroup', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
||||
</div>
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<?php if ($contacts) { ?>
|
||||
<div class="text-right col-xs-6 no-padding">
|
||||
<strong>Action pour la séléction :</strong>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Scheduled', 'add', ['prefilled' => 'contacts']); ?>"><span class="fa fa-send"></span> Envoyer un message</button>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Contact', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
|
||||
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Contact', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
||||
</div>
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<?php if ($groups) { ?>
|
||||
<div class="text-right col-xs-6 no-padding">
|
||||
<strong>Action pour la séléction :</strong>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Scheduled', 'add', ['prefilled' => 'groups']); ?>"><span class="fa fa-send"></span> Envoyer un message</button>
|
||||
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Group', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
|
||||
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Group', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
||||
</div>
|
||||
|
|
|
@ -75,16 +75,16 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>Contacts cibles</label>
|
||||
<input class="add-contacts form-control" name="contacts[]"/>
|
||||
<input class="add-contacts form-control" name="contacts[]" value="<?php $this->s(json_encode($prefilled_contacts)); ?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Groupes cibles</label>
|
||||
<input class="add-groupes form-control" name="groups[]"/>
|
||||
<input class="add-groupes form-control" name="groups[]" value="<?php $this->s(json_encode($prefilled_groups)); ?>" />
|
||||
</div>
|
||||
<?php if ($_SESSION['user']['settings']['conditional_group'] ?? false) { ?>
|
||||
<div class="form-group">
|
||||
<label>Groupes conditionnels cibles</label>
|
||||
<input class="add-conditional-groups form-control" name="conditional_groups[]"/>
|
||||
<input class="add-conditional-groups form-control" name="conditional_groups[]" value="<?php $this->s(json_encode($prefilled_conditional_groups)); ?>"/>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION['user']['settings']['sms_flash']) { ?>
|
||||
|
|
Loading…
Reference in New Issue