Add phone
This commit is contained in:
parent
5aec083831
commit
b1c4a1e3aa
|
@ -21,6 +21,19 @@ namespace controllers\internals;
|
|||
$this->model_phone = new \models\Phone($bdd);
|
||||
$this->internal_event = new \controllers\internals\Event($bdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of phones
|
||||
* @param int $id_user : User id
|
||||
* @param mixed(int|bool) $nb_entry : Number of entry to return
|
||||
* @param mixed(int|bool) $page : Numero of page
|
||||
*
|
||||
* @return array|bool : List of user or false
|
||||
*/
|
||||
public function list(int $id_user, ?int $nb_entry = null, ?int $page = null)
|
||||
{
|
||||
return $this->model_phone->list($id_user, $nb_entry, $page * $nb_entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a phone
|
||||
|
@ -29,15 +42,30 @@ namespace controllers\internals;
|
|||
*/
|
||||
public function get (int $id)
|
||||
{
|
||||
$phone = $this->model_phone->get($id);
|
||||
|
||||
if (!$phone)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$phone['plateform_datas'] = json_decode($phone['plateform_datas'], true);
|
||||
return $phone;
|
||||
return $this->model_phone->get($id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by is number
|
||||
* @param string $number : phone number
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number (string $number)
|
||||
{
|
||||
return $this->model_phone->get_by_number($number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his number and user
|
||||
* @param string $number : phone number
|
||||
* @param int $id_user : user id
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number_and_user (string $number, int $id_user)
|
||||
{
|
||||
return $this->model_phone->get_by_number_and_user($number, $id_user);
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,19 +76,7 @@ namespace controllers\internals;
|
|||
*/
|
||||
public function gets_for_user (int $id_user)
|
||||
{
|
||||
$phones = $this->model_phone->gets($id_user);
|
||||
|
||||
if (!$phone)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($phones as &$phone)
|
||||
{
|
||||
$phone['plateform_datas'] = json_decode($phone['plateform_datas'], true);
|
||||
}
|
||||
|
||||
return $phones;
|
||||
return $this->model_phone->gets_for_user($id_user);
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,19 +86,7 @@ namespace controllers\internals;
|
|||
*/
|
||||
public function get_all ()
|
||||
{
|
||||
$phones = $this->model_phone->get_all();
|
||||
|
||||
if (!$phone)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($phones as &$phone)
|
||||
{
|
||||
$phone['plateform_datas'] = json_decode($phone['plateform_datas'], true);
|
||||
}
|
||||
|
||||
return $phones;
|
||||
return $this->model_phone->get_all();
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +95,7 @@ namespace controllers\internals;
|
|||
* @param int $id : Phone id
|
||||
* @return bool
|
||||
*/
|
||||
public function delete (int $id) : boolean
|
||||
public function delete (int $id) : bool
|
||||
{
|
||||
return (bool) $this->model_phone->delete($id);
|
||||
}
|
||||
|
@ -101,17 +105,17 @@ namespace controllers\internals;
|
|||
* Create a phone
|
||||
* @param int $id_user : User to insert phone for
|
||||
* @param string $number : The number of the phone
|
||||
* @param string $platform : The platform to use the phone
|
||||
* @param array $platform_datas : An array of the datas of the platform (for example credentials for an api)
|
||||
* @param string $adapter : The adapter to use the phone
|
||||
* @param ?string json $adapter_datas : A JSON string representing adapter's datas (for example credentials for an api)
|
||||
* @return bool : false on error, true on success
|
||||
*/
|
||||
public function insert (int $id_user, string $number, string $platform, array $platform_datas) : boolean
|
||||
public function create (int $id_user, string $number, string $adapter, ?string $adapter_datas) : bool
|
||||
{
|
||||
$phone = [
|
||||
'id_user' => $id_user,
|
||||
'number' => $number,
|
||||
'platform' => $platform,
|
||||
'platform_datas' => json_encode($platform_datas),
|
||||
'adapter' => $adapter,
|
||||
'adapter_datas' => $adapter_datas,
|
||||
];
|
||||
|
||||
return (bool) $this->model_phone->insert($phone);
|
||||
|
@ -123,17 +127,17 @@ namespace controllers\internals;
|
|||
* @param int $id : Phone id
|
||||
* @param int $id_user : User to insert phone for
|
||||
* @param string $number : The number of the phone
|
||||
* @param string $platform : The platform to use the phone
|
||||
* @param array $platform_datas : An array of the datas of the platform (for example credentials for an api)
|
||||
* @param string $adapter : The adapter to use the phone
|
||||
* @param array $adapter_datas : An array of the datas of the adapter (for example credentials for an api)
|
||||
* @return bool : false on error, true on success
|
||||
*/
|
||||
public function update (int $id, int $id_user, string $number, string $platform, array $platform_datas) : boolean
|
||||
public function update (int $id, int $id_user, string $number, string $adapter, array $adapter_datas) : bool
|
||||
{
|
||||
$phone = [
|
||||
'id_user' => $id_user,
|
||||
'number' => $number,
|
||||
'platform' => $platform,
|
||||
'platform_datas' => json_encode($platform_datas),
|
||||
'adapter' => $adapter,
|
||||
'adapter_datas' => json_encode($adapter_datas),
|
||||
];
|
||||
|
||||
return (bool) $this->model_phone->update($id, $phone);
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of RaspiSMS.
|
||||
*
|
||||
* (c) Pierre-Lin Bonnemaison <plebwebsas@gmail.com>
|
||||
*
|
||||
* This source file is subject to the GPL-3.0 license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace controllers\publics;
|
||||
|
||||
/**
|
||||
* Page des phones.
|
||||
*/
|
||||
class Phone extends \descartes\Controller
|
||||
{
|
||||
private $internal_phone;
|
||||
private $internal_adapter;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
|
||||
$this->internal_phone = new \controllers\internals\Phone($bdd);
|
||||
$this->internal_adapter = new \controllers\internals\Adapter($bdd);
|
||||
|
||||
\controllers\internals\Tool::verifyconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cette fonction retourne tous les phones, sous forme d'un tableau permettant l'administration de ces phones.
|
||||
*
|
||||
* @param mixed $page
|
||||
*/
|
||||
public function list($page = 0)
|
||||
{
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
$page = (int) $page;
|
||||
$phones = $this->internal_phone->list($id_user, 25, $page);
|
||||
|
||||
$adapters = [];
|
||||
$adapters_metas = $this->internal_adapter->list_adapters();
|
||||
foreach ($adapters_metas as $adapter_metas)
|
||||
{
|
||||
$adapters[$adapter_metas['meta_classname']] = $adapter_metas['meta_name'];
|
||||
}
|
||||
|
||||
foreach ($phones as &$phone)
|
||||
{
|
||||
$phone['adapter'] = $adapters[$phone['adapter']] ?? 'Inconnu';
|
||||
}
|
||||
|
||||
$this->render('phone/list', ['phones' => $phones]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cette fonction va supprimer une liste de phones.
|
||||
*
|
||||
* @param array int $_GET['ids'] : Les id des phonees à supprimer
|
||||
* @param mixed $csrf
|
||||
*
|
||||
* @return boolean;
|
||||
*/
|
||||
public function delete($csrf)
|
||||
{
|
||||
if (!$this->verify_csrf($csrf))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Jeton CSRF invalid !');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'list'));
|
||||
}
|
||||
|
||||
if (!\controllers\internals\Tool::is_admin())
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Vous devez être administrateur pour supprimer un utilisateur !');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'list'));
|
||||
}
|
||||
|
||||
$ids = $_GET['ids'] ?? [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$this->internal_phone->delete($id);
|
||||
}
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cette fonction retourne la page d'ajout d'un phone.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$adapters = $this->internal_adapter->list_adapters();
|
||||
return $this->render('phone/add', ['adapters' => $adapters]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new phone
|
||||
* @param $csrf : CSRF token
|
||||
* @param string $_POST['number'] : Phone number
|
||||
* @param string $_POST['adapter'] : Phone adapter
|
||||
* @param boolean $_POST['adapter_datas'] : Phone adapter datas
|
||||
*/
|
||||
public function create($csrf)
|
||||
{
|
||||
if (!$this->verify_csrf($csrf))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Jeton CSRF invalid !');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
$id_user = $_SESSION['user']['id'];
|
||||
$number = $_POST['number'] ?? false;
|
||||
$adapter = $_POST['adapter'] ?? false;
|
||||
$adapter_datas = !empty($_POST['adapter_datas']) ? $_POST['adapter_datas'] : null;
|
||||
|
||||
if (!$number || !$adapter)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Des champs obligatoires sont manquants.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
|
||||
$number = \controllers\internals\Tool::parse_phone($number);
|
||||
if (!$number)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Numéro de téléphone incorrect.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
$number_exist = $this->internal_phone->get_by_number($number);
|
||||
if ($number_exist)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Ce numéro de téléphone est déjà utilisé.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
|
||||
$adapters = $this->internal_adapter->list_adapters();
|
||||
$adapter_exists = false;
|
||||
foreach ($adapters as $metas)
|
||||
{
|
||||
if ($metas['meta_classname'] === $adapter)
|
||||
{
|
||||
$adapter_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$adapter_exists)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Cet adaptateur n\'existe pas.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
|
||||
if (NULL !== $adapter_datas && NULL === json_decode($adapter_datas))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'La chaîne de configuration n\'est pas valide.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
|
||||
$success = $this->internal_phone->create($id_user, $number, $adapter, $adapter_datas);
|
||||
if (!$success)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce téléphone.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'add'));
|
||||
}
|
||||
|
||||
\FlashMessage\FlashMessage::push('success', 'Le téléphone a bien été créé.');
|
||||
return $this->redirect(\descartes\Router::url('Phone', 'list'));
|
||||
}
|
||||
}
|
|
@ -16,6 +16,18 @@ namespace models;
|
|||
*/
|
||||
class Phone extends \descartes\Model
|
||||
{
|
||||
/**
|
||||
* Return list of phones.
|
||||
* @param int $id_user : User id
|
||||
* @param int $limit : Number of user to return
|
||||
* @param int $offset : Number of user to skip
|
||||
*/
|
||||
public function list($id_user, $limit, $offset)
|
||||
{
|
||||
return $this->_select('phone', ['id_user' => $id_user], null, false, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his id
|
||||
* @param int $id : Phone id
|
||||
|
@ -25,6 +37,28 @@ namespace models;
|
|||
{
|
||||
return $this->_select_one('phone', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a phone by his number
|
||||
* @param string $number : phone number
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number (string $number)
|
||||
{
|
||||
return $this->_select_one('phone', ['number' => $number]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a phone by his number and user
|
||||
* @param string $number : phone number
|
||||
* @param int $id_user : user id
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number_and_user (string $number, int $id_user)
|
||||
{
|
||||
return $this->_select_one('phone', ['number' => $number, 'id_user' => $id_user]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find phones of a user
|
||||
|
@ -61,8 +95,8 @@ namespace models;
|
|||
* Create a phone
|
||||
* @param int $id_user : User to insert phone for
|
||||
* @param string $number : The number of the phone
|
||||
* @param string $platform : The platform to use the phone
|
||||
* @param string JSON $platform_datas : A json string representing the datas of the platform (for exemple credentials of an api)
|
||||
* @param string $adapter : The adapter to use the phone
|
||||
* @param string JSON $adapter_datas : A json string representing the datas of the adapter (for exemple credentials of an api)
|
||||
* @return mixed bool : false on error, true on success
|
||||
*/
|
||||
public function insert($phone)
|
||||
|
@ -76,8 +110,8 @@ namespace models;
|
|||
* @param int $id : Id of the phone
|
||||
* @param int $id_user : User to insert phone for
|
||||
* @param string $number : The number of the phone
|
||||
* @param string $platform : The platform to use the phone
|
||||
* @param string JSON $platform_datas : A json string representing the datas of the platform (for exemple credentials of an api)
|
||||
* @param string $adapter : The adapter to use the phone
|
||||
* @param string JSON $adapter_datas : A json string representing the datas of the adapter (for exemple credentials of an api)
|
||||
* @return mixed bool : false on error, true on success
|
||||
*/
|
||||
public function update ($id, $phone)
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
//Template dashboard
|
||||
|
||||
$this->render('incs/head', ['title' => 'Phones - Show All'])
|
||||
?>
|
||||
<div id="wrapper">
|
||||
<?php
|
||||
$this->render('incs/nav', ['page' => 'phones'])
|
||||
?>
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Page Heading -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">
|
||||
Nouveau téléphone
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<i class="fa fa-dashboard"></i> <a href="<?php echo \descartes\Router::url('Dashboard', 'show'); ?>">Dashboard</a>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-phone"></i> <a href="<?php echo \descartes\Router::url('Phone', 'list'); ?>">Téléphones</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<i class="fa fa-plus"></i> Nouveau
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-phone fa-fw"></i> Ajout d'un téléphone</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form action="<?php echo \descartes\Router::url('Phone', 'create', ['csrf' => $_SESSION['csrf']]);?>" method="POST">
|
||||
<div class="form-group">
|
||||
<label>Numéro de téléphone</label>
|
||||
<p class="italic small">
|
||||
Le numéro de téléphone qui enverra et recevra les messages.
|
||||
</p>
|
||||
<div class="form-group">
|
||||
<input name="" class="form-control" type="tel" id="phone-international-input" placeholder="Numéro de téléphone à utiliser.">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adaptateur logiciel du téléphone : </label>
|
||||
<p class="italic small" id="description-adapter">
|
||||
L'adaptateur logiciel utilisé par RaspiSMS pour communiquer avec le téléphone. Pour plus d'information, consultez <a href="https://raspisms.raspberry-pi.fr/documentation" target="_blank">la documentation de RaspiSMS</a> concernant les adaptateurs logiciels.
|
||||
</p>
|
||||
<select name="adapter" class="form-control" id="adapter-select">
|
||||
<?php foreach ($adapters as $adapter) { ?>
|
||||
<option
|
||||
value="<?= $adapter['meta_classname'] ?>"
|
||||
title="<?php $this->s($adapter['meta_description']); ?>"
|
||||
data-description="<?php $this->s($adapter['meta_description']); ?>"
|
||||
data-datas-help="<?php $this->s($adapter['meta_datas_help']); ?>"
|
||||
>
|
||||
<?php $this->s($adapter['meta_name']); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="adapter-datas-container">
|
||||
<label>Configuration de l'adaptateur</label>
|
||||
<p class="italic small" id="description-adapter-datas">
|
||||
Les données à fournir à l'adaptateur pour lui permettre de faire la liaison avec le téléphone. Par exemple des identifiants d'API.<br/>
|
||||
</p>
|
||||
<textarea id="adapter-datas" name="adapter_datas" class="form-control has-error"></textarea>
|
||||
<p class="hidden help-block" id="adapter-datas-error-message">La configuration doit être un JSON valide.</p>
|
||||
</div>
|
||||
<a class="btn btn-danger" href="<?php echo \descartes\Router::url('Phone', 'list'); ?>">Annuler</a>
|
||||
<input type="submit" class="btn btn-success" value="Enregistrer le phone" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
jQuery('document').ready(function($)
|
||||
{
|
||||
var option = jQuery('#adapter-select').find('option:selected');
|
||||
jQuery('#description-adapter').text(option.attr('data-description'));
|
||||
jQuery('#description-adapter-datas').text(option.attr('data-datas-help'));
|
||||
|
||||
jQuery('#adapter-select').on('change', function (e)
|
||||
{
|
||||
var option = jQuery(this).find('option:selected');
|
||||
jQuery('#description-adapter').text(option.attr('data-description'));
|
||||
jQuery('#description-adapter-datas').text(option.attr('data-datas-help'));
|
||||
});
|
||||
|
||||
jQuery('#adapter-datas').on('input', function (e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (jQuery(this).val() !== '')
|
||||
{
|
||||
JSON.parse(jQuery(this).val());
|
||||
}
|
||||
|
||||
jQuery('#adapter-datas-container').removeClass('has-error');
|
||||
jQuery('#adapter-datas-error-message').addClass('hidden');
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
jQuery('#adapter-datas-container').addClass('has-error');
|
||||
jQuery('#adapter-datas-error-message').removeClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
var number_input = jQuery('#phone-international-input')[0];
|
||||
var iti_number_input = window.intlTelInput(number_input, {
|
||||
hiddenInput: 'number',
|
||||
defaultCountry: '<?php $this->s($_SESSION['user']['settings']['default_phone_country']); ?>',
|
||||
preferredCountries: <?php $this->s(json_encode(explode(',', $_SESSION['user']['settings']['preferred_phone_country'])), false, false); ?>,
|
||||
nationalMode: true,
|
||||
utilsScript: '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
$this->render('incs/footer');
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
//Template dashboard
|
||||
|
||||
$this->render('incs/head', ['title' => 'Phones - Show All'])
|
||||
?>
|
||||
<div id="wrapper">
|
||||
<?php
|
||||
$this->render('incs/nav', ['page' => 'phone'])
|
||||
?>
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Page Heading -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">
|
||||
Dashboard <small>Téléphones</small>
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<i class="fa fa-dashboard"></i> <a href="<?php echo \descartes\Router::url('Dashboard', 'show'); ?>">Dashboard</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<i class="fa fa-phone"></i> Téléphones
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-phone fa-fw"></i> Liste des téléphones</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form method="GET">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-striped" id="table-phones">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Numéro</th>
|
||||
<th>Adaptateur</th>
|
||||
<th style="width:5%;">Sélectionner</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($phones as $phone) { ?>
|
||||
<tr>
|
||||
<td><?php $this->s($phone['id']); ?></td>
|
||||
<td><?php $this->s($phone['number']); ?></td>
|
||||
<td><?php $this->s($phone['adapter']); ?></td>
|
||||
<td><input type="checkbox" value="<?php $this->s($phone['id']); ?>" name="ids[]"></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<div class="col-xs-6 no-padding">
|
||||
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Phone', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un téléphone</a>
|
||||
</div>
|
||||
<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('Phone', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(document).ready(function ()
|
||||
{
|
||||
jQuery('.action-dropdown a').on('click', function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var destination = jQuery(this).parents('.action-dropdown').attr('destination');
|
||||
var url = jQuery(this).attr('href');
|
||||
jQuery(destination).find('input:checked').each(function ()
|
||||
{
|
||||
url += '/' + jQuery(this).val();
|
||||
});
|
||||
window.location = url;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
$this->render('incs/footer');
|
Loading…
Reference in New Issue