Change all lists to use ajax data source and high perf datatable + improve all consuming listing queries + add indexes on numbers for perf improvment

This commit is contained in:
osaajani 2020-09-23 03:02:13 +02:00
parent 52ac5b459b
commit b98d5a22ef
34 changed files with 1238 additions and 767 deletions

View File

@ -74,24 +74,11 @@ function playReceptionSound ()
jQuery(document).ready(function()
{
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
});
jQuery('.datatable').on('draw.dt', function (){
jQuery('body :checkbox').off('shiftcheckbox');
jQuery('body :checkbox').shiftcheckbox();
});
var verifReceivedInterval = setInterval(verifReceived, 10000);
jQuery('body').on('click', '.btn-confirm', function (e)

View File

@ -42,8 +42,17 @@ namespace controllers\publics;
*/
public function list()
{
$commands = $this->internal_command->list_for_user($_SESSION['user']['id']);
$this->render('command/list', ['commands' => $commands]);
$this->render('command/list');
}
/**
* Return commands as json
*/
public function list_json()
{
$entities = $this->internal_command->list_for_user($_SESSION['user']['id']);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -48,10 +48,20 @@ namespace controllers\publics;
{
$page = (int) $page;
$groups = $this->internal_conditional_group->list_for_user($_SESSION['user']['id'], 25, $page);
$groups = $this->internal_conditional_group->list_for_user($_SESSION['user']['id']);
$this->render('conditional_group/list', ['groups' => $groups]);
}
/**
* Return conditionnals groups as json
*/
public function list_json()
{
$entities = $this->internal_conditional_group->list_for_user($_SESSION['user']['id']);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**
* Cette fonction va supprimer une liste de groups.
*

View File

@ -40,9 +40,22 @@ namespace controllers\publics;
*/
public function list()
{
$contacts = $this->internal_contact->list_for_user($_SESSION['user']['id']);
return $this->render('contact/list');
}
return $this->render('contact/list', ['contacts' => $contacts]);
/**
* Return contacts as json
*/
public function list_json()
{
$entities = $this->internal_contact->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['number_formatted'] = \controllers\internals\Tool::phone_link($entity['number']);
}
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -46,21 +46,24 @@ namespace controllers\publics;
*/
public function list()
{
$discussions = $this->internal_received->get_discussions_for_user($_SESSION['user']['id']);
foreach ($discussions as $key => $discussion)
{
if (!$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $discussion['number']))
{
continue;
$this->render('discussion/list');
}
$discussions[$key]['contact'] = $contact['name'];
/**
* Return discussions as json
*/
public function list_json()
{
$entities = $this->internal_received->get_discussions_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['number_formatted'] = \controllers\internals\Tool::phone_link($entity['number']);
$entity['link'] = \descartes\Router::url('Discussion', 'show', ['number' => $entity['number']]);
}
$this->render('discussion/list', [
'discussions' => $discussions,
]);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -40,8 +40,22 @@ namespace controllers\publics;
*/
public function list()
{
$events = $this->internal_event->list_for_user($_SESSION['user']['id']);
$this->render('event/list', ['events' => $events, 'nb_results' => \count($events)]);
$this->render('event/list');
}
/**
* Return events as json
*/
public function list_json()
{
$entities = $this->internal_event->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['icon'] = \controllers\internals\Tool::event_type_to_icon($entity['type']);
}
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**
@ -61,6 +75,13 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Event', 'list'));
}
if (!\controllers\internals\Tool::is_admin())
{
\FlashMessage\FlashMessage::push('danger', 'Vous devez être administrateur pour supprimer un event !');
return $this->redirect(\descartes\Router::url('Event', 'list'));
}
$ids = $_GET['ids'] ?? [];
foreach ($ids as $id)
{

View File

@ -42,15 +42,18 @@ namespace controllers\publics;
*/
public function list()
{
$groups = $this->internal_group->list_for_user($_SESSION['user']['id']);
foreach ($groups as $key => $group)
{
$contacts = $this->internal_group->get_contacts($group['id']);
$groups[$key]['nb_contacts'] = \count($contacts);
$this->render('group/list');
}
$this->render('group/list', ['groups' => $groups]);
/**
* Return groups as json
*/
public function list_json()
{
$entities = $this->internal_group->list_for_user($_SESSION['user']['id']);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -72,6 +72,51 @@ class Phone extends \descartes\Controller
$this->render('phone/list', ['phones' => $phones]);
}
/**
* Return phones as json with additionnals datas about callbacks
*/
public function list_json()
{
$id_user = $_SESSION['user']['id'];
$api_key = $_SESSION['user']['api_key'];
$phones = $this->internal_phone->list_for_user($id_user);
$adapters = [];
$adapters = $this->internal_adapter->list_adapters();
foreach ($adapters as $key => $adapter)
{
unset($adapters[$key]);
$adapters[$adapter['meta_classname']] = $adapter;
}
foreach ($phones as &$phone)
{
$adapter = $adapters[$phone['adapter']] ?? false;
if (!$adapter)
{
$phone['adapter'] = 'Inconnu';
continue;
}
$phone['adapter'] = $adapter['meta_name'];
if ($adapter['meta_support_reception'])
{
$phone['callback_reception'] = \descartes\Router::url('Callback', 'reception', ['adapter_uid' => $adapter['meta_uid'], 'id_phone' => $phone['id']], ['api_key' => $api_key]);
}
if ($adapter['meta_support_status_change'])
{
$phone['callback_status'] = \descartes\Router::url('Callback', 'update_sended_status', ['adapter_uid' => $adapter['meta_uid']], ['api_key' => $api_key]);
}
}
header('Content-Type: application/json');
echo json_encode(['data' => $phones]);
}
/**
* Cette fonction va supprimer une liste de phones.
*

View File

@ -41,32 +41,22 @@ namespace controllers\publics;
*/
public function list()
{
$receiveds = $this->internal_received->list_for_user($_SESSION['user']['id']);
foreach ($receiveds as $key => $received)
{
if ('read' !== $received['status'])
{
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $received['id']);
$this->render('received/list', ['is_unread' => false]);
}
if (null !== $received['id_phone'])
/**
* Return received as json
*/
public function list_json()
{
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $received['id_phone']);
if ($phone)
$entities = $this->internal_received->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$receiveds[$key]['phone_name'] = $phone['name'];
}
$entity['origin_formatted'] = \controllers\internals\Tool::phone_link($entity['origin']);
}
$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $received['origin']);
if ($contact)
{
$receiveds[$key]['contact'] = $contact['name'];
}
}
$this->render('received/list', ['receiveds' => $receiveds, 'nb_results' => \count($receiveds)]);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**
@ -74,29 +64,56 @@ namespace controllers\publics;
*/
public function list_unread()
{
$receiveds = $this->internal_received->list_unread_for_user($_SESSION['user']['id']);
$this->render('received/list', ['is_unread' => true]);
}
foreach ($receiveds as $key => $received)
/**
* Return unred received as json
*/
public function list_unread_json()
{
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $received['id']);
$entities = $this->internal_received->list_unread_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['origin_formatted'] = \controllers\internals\Tool::phone_link($entity['origin']);
}
if (null !== $received['id_phone'])
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**
* Mark messages as
*
* @param string $status : New status of the message, read or unread
* @param array int $_GET['ids'] : Ids of receiveds to delete
* @param mixed $csrf
*
* @return boolean;
*/
public function mark_as ($status, $csrf)
{
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $received['id_phone']);
if ($phone)
if (!$this->verify_csrf($csrf))
{
$receiveds[$key]['phone_name'] = $phone['name'];
\FlashMessage\FlashMessage::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Received', 'list'));
}
$ids = $_GET['ids'] ?? [];
foreach ($ids as $id)
{
if ($status === \models\Received::STATUS_UNREAD)
{
$this->internal_received->mark_as_unread_for_user($_SESSION['user']['id'], $id);
}
elseif ($status === \models\Received::STATUS_READ)
{
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $id);
}
}
$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $received['origin']);
if ($contact)
{
$receiveds[$key]['contact'] = $contact['name'];
}
}
$this->render('received/list_unread', ['receiveds' => $receiveds, 'nb_results' => \count($receiveds)]);
return $this->redirect(\descartes\Router::url('Received', 'list'));
}
/**

View File

@ -47,8 +47,18 @@ namespace controllers\publics;
*/
public function list()
{
$scheduleds = $this->internal_scheduled->list_for_user($_SESSION['user']['id']);
$this->render('scheduled/list', ['scheduleds' => $scheduleds]);
$this->render('scheduled/list');
}
/**
* Return scheduleds as json
*/
public function list_json()
{
$entities = $this->internal_scheduled->list_for_user($_SESSION['user']['id']);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -42,29 +42,25 @@ namespace controllers\publics;
*/
public function list()
{
$sendeds = $this->internal_sended->list_for_user($_SESSION['user']['id']);
foreach ($sendeds as $key => $sended)
{
if (null !== $sended['id_phone'])
{
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $sended['id_phone']);
if ($phone)
{
$sendeds[$key]['phone_name'] = $phone['name'];
}
$this->render('sended/list');
}
$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $sended['destination']);
if ($contact)
/**
* Return sendeds as json
*/
public function list_json()
{
$sendeds[$key]['contact'] = $contact['name'];
}
$entities = $this->internal_sended->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['destination_formatted'] = \controllers\internals\Tool::phone_link($entity['destination']);
}
$this->render('sended/list', ['sendeds' => $sendeds, 'nb_results' => \count($sendeds)]);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**
* Cette fonction va supprimer une liste de sendeds.
*

View File

@ -39,8 +39,22 @@ namespace controllers\publics;
*/
public function list()
{
$smsstops = $this->internal_sms_stop->list_for_user($_SESSION['user']['id']);
$this->render('smsstop/list', ['smsstops' => $smsstops, 'nb_results' => \count($smsstops)]);
$this->render('smsstop/list');
}
/**
* Return smsstops as json
*/
public function list_json()
{
$entities = $this->internal_sms_stop->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['number_formatted'] = \controllers\internals\Tool::phone_link($entity['number']);
}
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -42,8 +42,17 @@ class User extends \descartes\Controller
*/
public function list()
{
$users = $this->internal_user->list();
$this->render('user/list', ['users' => $users]);
$this->render('user/list');
}
/**
* Return users as json
*/
public function list_json()
{
$entities = $this->internal_user->list();
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -36,8 +36,17 @@ namespace controllers\publics;
*/
public function list()
{
$webhooks = $this->internal_webhook->list_for_user($_SESSION['user']['id']);
$this->render('webhook/list', ['webhooks' => $webhooks]);
$this->render('webhook/list');
}
/**
* Return commands as json
*/
public function list_json()
{
$entities = $this->internal_webhook->list_for_user($_SESSION['user']['id']);
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**

View File

@ -0,0 +1,46 @@
<?php
use Phinx\Migration\AbstractMigration;
class AddIndexForPerfs extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('contact');
$table->addIndex('number');
$table->update();
$table = $this->table('sended');
$table->addIndex('destination');
$table->update();
$table = $this->table('received');
$table->addIndex('origin');
$table->update();
}
}

View File

@ -13,6 +13,45 @@ namespace models;
class Group extends StandardModel
{
/**
* Return a list of groups for a user.
* Add a column nb_contacts
*
* @param int $id_user : user id
* @param ?int $limit : Number of entry to return or null
* @param ?int $offset : Number of entry to ignore or null
*
* @return array
*/
public function list_for_user(int $id_user, $limit, $offset)
{
$query = '
SELECT g.*, COUNT(gc.id) as nb_contact
FROM `group` as g
LEFT JOIN group_contact as gc
ON g.id = gc.id_group
WHERE id_user = :id_user
GROUP BY g.id
';
if ($limit !== null)
{
$limit = (int) $limit;
$query .= ' LIMIT ' . $limit;
if ($offset !== null)
{
$offset = (int) $offset;
$query .= ' OFFSET ' . $offset;
}
}
$params = [
'id_user' => $id_user,
];
return $this->_run_query($query, $params);
}
/**
* Return a group by his name for a user.
*

View File

@ -20,22 +20,39 @@ namespace models;
const STATUS_READ = 'read';
/**
* Return a list of unread received for a user.
* Return a list of received messages for a user.
* Add a column contact_name and phone_name when available
*
* @param int $id_user : User id
* @param int $limit : Max results to return
* @param int $offset : Number of results to ignore
* @param int $id_user : user id
* @param ?int $limit : Number of entry to return or null
* @param ?int $offset : Number of entry to ignore or null
*
* @return array
*/
public function list_unread_for_user($id_user, $limit, $offset)
public function list_for_user(int $id_user, $limit, $offset)
{
$query = '
SELECT received.*, contact.name as contact_name, phone.name as phone_name
FROM received
LEFT JOIN contact
ON contact.number = received.origin
AND contact.id_user = received.id_user
LEFT JOIN phone
ON phone.id = received.id_phone
WHERE received.id_user = :id_user
';
if ($limit !== null)
{
$limit = (int) $limit;
$offset = (int) $offset;
$query = '
SELECT * FROM received
WHERE status = \'unread\'
AND id_user = :id_user
LIMIT ' . $limit . ' OFFSET ' . $offset;
$query .= ' LIMIT ' . $limit;
if ($offset !== null)
{
$offset = (int) $offset;
$query .= ' OFFSET ' . $offset;
}
}
$params = [
'id_user' => $id_user,
@ -44,6 +61,51 @@ namespace models;
return $this->_run_query($query, $params);
}
/**
* Return a list of unread received messages for a user.
* Add a column contact_name and phone_name when available
*
* @param int $id_user : user id
* @param ?int $limit : Number of entry to return or null
* @param ?int $offset : Number of entry to ignore or null
*
* @return array
*/
public function list_unread_for_user(int $id_user, $limit, $offset)
{
$query = '
SELECT received.*, contact.name as contact_name, phone.name as phone_name
FROM received
LEFT JOIN contact
ON contact.number = received.origin
AND contact.id_user = received.id_user
LEFT JOIN phone
ON phone.id = received.id_phone
WHERE received.id_user = :id_user
AND status = :status
';
if ($limit !== null)
{
$limit = (int) $limit;
$query .= ' LIMIT ' . $limit;
if ($offset !== null)
{
$offset = (int) $offset;
$query .= ' OFFSET ' . $offset;
}
}
$params = [
'id_user' => $id_user,
'status' => self::STATUS_UNREAD,
];
return $this->_run_query($query, $params);
}
/**
* Count number of unread received sms for user.
*
@ -154,7 +216,7 @@ namespace models;
public function get_discussions_for_user(int $id_user)
{
$query = '
SELECT at, number
SELECT discussions.at, discussions.number, contact.name as contact_name
FROM (
SELECT at, destination as number FROM sended
WHERE id_user = :id_user
@ -163,6 +225,8 @@ namespace models;
WHERE id_user = :id_user
)
) as discussions
LEFT JOIN contact
ON discussions.number = contact.number AND id_user = :id_user
GROUP BY number
ORDER BY at DESC
';

View File

@ -20,6 +20,48 @@ namespace models;
const STATUS_DELIVERED = 'delivered';
const STATUS_FAILED = 'failed';
/**
* Return a list of sended messages for a user.
* Add a column contact_name and phone_name when available
*
* @param int $id_user : user id
* @param ?int $limit : Number of entry to return or null
* @param ?int $offset : Number of entry to ignore or null
*
* @return array
*/
public function list_for_user(int $id_user, $limit, $offset)
{
$query = '
SELECT sended.*, contact.name as contact_name, phone.name as phone_name
FROM sended
LEFT JOIN contact
ON contact.number = sended.destination
AND contact.id_user = sended.id_user
LEFT JOIN phone
ON phone.id = sended.id_phone
WHERE sended.id_user = :id_user
';
if ($limit !== null)
{
$limit = (int) $limit;
$query .= ' LIMIT ' . $limit;
if ($offset !== null)
{
$offset = (int) $offset;
$query .= ' OFFSET ' . $offset;
}
}
$params = [
'id_user' => $id_user,
];
return $this->_run_query($query, $params);
}
/**
* Return x last sendeds message for a user, order by date.
*

View File

@ -24,10 +24,8 @@
],
'Command' => [
'list' => [
'/command/',
'/command/p/{page}/',
],
'list' => '/command/',
'list_json' => '/command/json/',
'add' => '/command/add/',
'create' => '/command/create/{csrf}/',
'delete' => '/command/delete/{csrf}/',
@ -36,10 +34,8 @@
],
'Contact' => [
'list' => [
'/contact/',
'/contact/p/{page}/',
],
'list' => '/contact/',
'list_json' => '/contact/json/',
'add' => '/contact/add/',
'create' => '/contact/create/{csrf}/',
'delete' => '/contact/delete/{csrf}/',
@ -55,6 +51,7 @@
'/discussion/',
'/discussion/p/{page}/',
],
'list_json' => '/discussion/json/',
'show' => '/discussion/show/{number}/',
'send' => '/discussion/send/{csrf}/',
'get_messages' => '/discussion/getmessage/{number}/{transaction_id}/',
@ -65,14 +62,13 @@
'/event/',
'/event/p/{page}/',
],
'list_json' => '/event/json/',
'delete' => '/event/delete/{csrf}/',
],
'Group' => [
'list' => [
'/group/',
'/group/p/{page}/',
],
'list' => '/group/',
'list_json' => '/group/json/',
'add' => '/group/add/',
'create' => '/group/create/{csrf}/',
'delete' => '/group/delete/{csrf}/',
@ -82,10 +78,8 @@
],
'ConditionalGroup' => [
'list' => [
'/conditional_group/',
'/conditional_group/p/{page}/',
],
'list' => '/conditional_group/',
'list_json' => '/conditional_group/json/',
'add' => '/conditional_group/add/',
'create' => '/conditional_group/create/{csrf}/',
'delete' => '/conditional_group/delete/{csrf}/',
@ -96,14 +90,11 @@
],
'Received' => [
'list' => [
'/received/',
'/received/p/{page}/',
],
'list_unread' => [
'/unread/',
'/unread/p/{page}/',
],
'list' => '/received/',
'list_json' => '/received/json/',
'list_unread' => '/unread/',
'list_unread_json' => '/unread/json/',
'mark_as' => '/mark/{status}/{csrf}/',
'delete' => '/received/delete/{csrf}/',
'popup' => '/received/popup/',
],
@ -113,6 +104,7 @@
'/scheduled/',
'/scheduled/p/{page}/',
],
'list_json' => '/scheduled/json/',
'add' => [
'/scheduled/add/',
'/scheduled/add/{prefilled}/',
@ -128,6 +120,7 @@
'/sended/',
'/sended/p/{page}/',
],
'list_json' => '/sended/json/',
'delete' => '/sended/delete/{csrf}/',
],
@ -137,10 +130,8 @@
],
'SmsStop' => [
'list' => [
'/smsstop/',
'/smsstop/p/{page}/',
],
'list' => '/smsstop/',
'list_json' => '/smsstop/json/',
'delete' => '/smsstop/delete/{csrf}/',
],
@ -149,10 +140,8 @@
],
'User' => [
'list' => [
'/user/',
'/user/p/{page}/',
],
'list' => '/user/',
'list_json' => '/user/json/',
'add' => '/user/add/',
'create' => '/user/create/{csrf}/',
'delete' => '/user/delete/{csrf}/',
@ -160,20 +149,16 @@
],
'Phone' => [
'list' => [
'/phone/',
'/phone/p/{page}/',
],
'list' => '/phone/',
'list_json' => '/phone/json/',
'add' => '/phone/add/',
'create' => '/phone/create/{csrf}/',
'delete' => '/phone/delete/{csrf}/',
],
'Webhook' => [
'list' => [
'/webhook/',
'/webhook/p/{page}/',
],
'list' => '/webhook/',
'list_json' => '/webhook/json/',
'add' => '/webhook/add/',
'create' => '/webhook/create/{csrf}/',
'delete' => '/webhook/delete/{csrf}/',

View File

@ -35,9 +35,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$commands) { ?>
<p>Aucune commande n'a été créée pour le moment.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-commands">
<thead>
@ -49,29 +46,18 @@
</tr>
</thead>
<tbody>
<?php foreach ($commands as $command) { ?>
<tr>
<td><?php $this->s($command['name']); ?></td>
<td><?php $this->s($command['script']); ?></td>
<td><?php echo $command['admin'] ? 'Oui' : 'Non' ; ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($command['id']); ?>"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<div>
<div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Command', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter une commande</a>
</div>
<?php if ($commands) { ?>
<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('Command', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Command', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
</form>
</div>
@ -81,5 +67,44 @@
</div>
</div>
</div>
<script>
jQuery(document).ready(function ()
{
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Command', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{data: 'script', render: jQuery.fn.dataTable.render.text()},
{
data: 'admin',
render: function (data, type, row, meta) {
return data ? "Oui" : "Non";
},
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php
$this->render('incs/footer');

View File

@ -83,17 +83,34 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('ConditionalGroup', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{data: 'condition', render: jQuery.fn.dataTable.render.text()},
{
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;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -37,9 +37,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$contacts) { ?>
<p>Aucun contact n'est enregistré pour le moment.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-contacts">
<thead>
@ -50,29 +47,19 @@
</tr>
</thead>
<tbody>
<?php foreach ($contacts as $contact) { ?>
<tr>
<td><?php $this->s($contact['name']); ?></td>
<td><?php echo(\controllers\internals\Tool::phone_link($contact['number'])); ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($contact['id']); ?>"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<div>
<div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Contact', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un contact</a>
</div>
<?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>
<?php } ?>
</div>
</form>
</div>
@ -126,6 +113,7 @@
<script>
jQuery(document).ready(function()
{
//Import/export contacts
jQuery('body').on('click', '#btn-import', function ()
{
jQuery('#import-modal').modal({'keyboard': true});
@ -135,6 +123,37 @@
{
jQuery('#export-modal').modal({'keyboard': true});
});
//Datatable
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Contact', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{data: 'number_formatted'},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -34,9 +34,6 @@
<h3 class="panel-title"><i class="fa fa-comments-o fa-fw"></i> Liste des discussions</h3>
</div>
<div class="panel-body">
<?php if (!$discussions) { ?>
Aucune discussion n'est en cours actuellement.
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-discussions">
<thead>
@ -46,16 +43,15 @@
</tr>
</thead>
<tbody>
<?php foreach ($discussions as $discussion) { ?>
<?php /*foreach ($discussions as $discussion) { ?>
<tr class="goto" url="<?php $this->s(\descartes\Router::url('Discussion', 'show', ['number' => $discussion['number']])); ?>">
<td><?php $this->s($discussion['at']); ?></td>
<td><?php $this->s(isset($discussion['contact']) ? $discussion['contact'] . ' (' . \controllers\internals\Tool::phone_format($discussion['number']) . ')' : \controllers\internals\Tool::phone_format($discussion['number'])); ?></td>
</tr>
<?php } ?>
<?php } */?>
</tbody>
</table>
</div>
<?php } ?>
</div>
</div>
</div>
@ -63,5 +59,44 @@
</div>
</div>
</div>
<script>
jQuery(document).ready(function ()
{
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Discussion', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'at', render: jQuery.fn.dataTable.render.text()},
{
data: 'number',
render: function (data, type, row, meta) {
if (row.contact_name) {
return jQuery.fn.dataTable.render.text().display(row.contact_name) + ' (' + row.number_formatted + ')';
}
return row.number_formatted;
},
},
],
"createdRow": function (row, data, dataIndex) {
jQuery(row).addClass('goto').attr('url', data.link);
},
"deferRender": true
});
});
</script>
<?php
$this->render('incs/footer');

View File

@ -136,7 +136,10 @@
var messageInputContainer = jQuery('.message-input-container').outerHeight();
var footerHeight = jQuery('footer').outerHeight();
var containerHeight = Math.floor(windowHeight - (containerPosition.top + footerHeight * 2 + messageInputContainer));
console.log(windowHeight);
console.log(containerPosition.top);
var containerHeight = Math.floor(windowHeight - (containerPosition.top + messageInputContainer) - 20); //-20 px for aesthetic
jQuery('.discussion-container').outerHeight(containerHeight);
}

View File

@ -35,9 +35,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$events) { ?>
<p>Aucun évènement n'a été enregistré pour le moment.</p>
<?php } else { ?>
<div class="table-events">
<table class="table table-bordered table-hover table-striped datatable" id="table-events">
<thead>
@ -45,21 +42,12 @@
<th>Type</th>
<th>Date</th>
<th>Texte</th>
<?php if ($_SESSION['user']['admin']) { ?>
<th class="checkcolumn">&#10003;</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach ($events as $event) { ?>
<tr>
<td><span class="fa fa-fw <?php echo \controllers\internals\Tool::event_type_to_icon($event['type']); ?>"></span></td>
<td><?php $this->s($event['at']); ?></td>
<td><?php $this->s($event['text']); ?></td>
<?php if ($_SESSION['user']['admin']) { ?>
<td><input name="ids[]" type="checkbox" value="<?php $this->s($event['id']); ?>"></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
<tbody></tbody>
</table>
</div>
<div>
@ -70,7 +58,6 @@
</div>
<?php } ?>
</div>
<?php } ?>
</form>
</div>
</div>
@ -82,17 +69,43 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Event', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{
e.preventDefault();
var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href');
jQuery(destination).find('input:checked').each(function ()
data: 'type',
render: function (data, type, row, meta) {
return '<span class="fa fa-fw ' + row.icon + '"></span>';
},
},
{data: 'at', render: jQuery.fn.dataTable.render.text()},
{data: 'text', render: jQuery.fn.dataTable.render.text()},
<?php if ($_SESSION['user']['admin']) { ?>
{
url += '/' + jQuery(this).val();
});
window.location = url;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
<?php } ?>
],
"deferRender": true
});
});
</script>
<?php

View File

@ -35,9 +35,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$groups) { ?>
<p>Aucun groupe n'a été formé pour le moment.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-groupes">
<thead>
@ -58,19 +55,16 @@
</tbody>
</table>
</div>
<?php } ?>
<div>
<div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Group', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un groupe</a>
</div>
<?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>
<?php } ?>
</div>
</form>
</div>
@ -83,17 +77,34 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Group', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{data: 'nb_contact', render: jQuery.fn.dataTable.render.text()},
{
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;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -35,9 +35,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$phones) { ?>
<p>Aucun téléphone utilisable n'a été ajouté pour le moment.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-phones">
<thead>
@ -50,44 +47,17 @@
</tr>
</thead>
<tbody>
<?php foreach ($phones as $phone) { ?>
<tr>
<td><?php $this->s($phone['id']); ?></td>
<td><?php $this->s($phone['name']); ?></td>
<td><?php $this->s($phone['adapter']); ?></td>
<td>
<div class="bold">Reception d'un SMS : </div>
<?php if ($phone['callback_reception'] ?? false) { ?>
<div><code><?= $phone['callback_reception']; ?></code></div>
<?php } else { ?>
<div>Non disponible.</div>
<?php } ?>
<br/>
<div class="bold">Changement de statut d'un SMS : </div>
<?php if ($phone['callback_status'] ?? false) { ?>
<div><code><?= $phone['callback_status']; ?></code></div>
<?php } else { ?>
<div>Non disponible.</div>
<?php } ?>
</td>
<td><input type="checkbox" value="<?php $this->s($phone['id']); ?>" name="ids[]"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<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>
<?php if ($phones) { ?>
<div class="text-right col-xs-6 no-padding">
<strong>Action pour la séléction :</strong>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Phone', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
</div>
</form>
</div>
@ -100,17 +70,59 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Phone', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'id', render: jQuery.fn.dataTable.render.text()},
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{
e.preventDefault();
var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href');
jQuery(destination).find('input:checked').each(function ()
data: '_',
render: function (data, type, row, meta) {
var html = '<div class="bold">Réception d\'un SMS : </div>';
if (row.callback_reception) {
html += '<div><code>' + row.callback_reception + '</code></div>';
} else {
html += '<div>Non disponible.</div>';
}
html += '<br/>';
html += '<div class="bold">Changement de statut d\'un SMS : </div>';
if (row.callback_status) {
html += '<div><code>' + row.callback_status + '</code></div>';
} else {
html += '<div>Non disponible.</div>';
}
return html;
},
},
{
url += '/' + jQuery(this).val();
});
window.location = url;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -1,11 +1,17 @@
<?php
//Template dashboard
$this->render('incs/head', ['title' => 'Receiveds - Show All'])
if ($is_unread)
{
$this->render('incs/head', ['title' => 'Receiveds - Unread']);
}
else
{
$this->render('incs/head', ['title' => 'Receiveds - Show All']);
}
?>
<div id="wrapper">
<?php
$this->render('incs/nav', ['page' => 'receiveds'])
$this->render('incs/nav', ['page' => ($is_unread ? 'receiveds_unread' : 'receiveds')])
?>
<div id="page-wrapper">
<div class="container-fluid">
@ -20,7 +26,7 @@
<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-download "></i> SMS reçus
<i class="fa <?= $is_unread ? 'fa-eye-slash' : 'fa-download' ?> "></i> <?= $is_unread ? 'SMS non lus' : 'SMS reçus' ?>
</li>
</ol>
</div>
@ -31,13 +37,10 @@
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-download fa-fw"></i> Liste des SMS reçus</h3>
<h3 class="panel-title"><i class="fa fa-fw <?= $is_unread ? 'fa-eye-slash' : 'fa-download' ?>"></i> <?= $is_unread ? 'Liste des SMS non lus' : 'Liste des SMS reçus' ?></h3>
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$receiveds) { ?>
<p>Aucun SMS n'a été reçu pour le moment.</p>
<?php } else { ?>
<div class="table-receiveds">
<table class="table table-bordered table-hover table-striped datatable" id="table-receiveds">
<thead>
@ -48,39 +51,21 @@
<th>Date</th>
<th>Status</th>
<th>Commande</th>
<?php if ($_SESSION['user']['admin']) { ?><th class="checkcolumn">&#10003;</th><?php } ?>
<th class="checkcolumn">&#10003;</th>
</tr>
</thead>
<tbody>
<?php foreach ($receiveds as $received) { ?>
<tr>
<td class="no-wrap">
<?php if ($received['contact'] ?? false) { ?>
<?php echo \controllers\internals\Tool::phone_link($received['origin']) . ' (' . $received['contact'] . ')'; ?>
<?php } else { ?>
<?php echo \controllers\internals\Tool::phone_link($received['origin']); ?>
<?php } ?>
</td>
<td class="no-wrap"><?php $this->s($received['phone_name'] ?? 'Inconnu'); ?></td>
<td><?php $this->s($received['text']); ?></td>
<td><?php $this->s($received['at']); ?></td>
<td><?php echo ($received['status'] == 'read' ? 'Lu' : 'Non lu'); ?></td>
<td><?php echo $received['command'] ? 'Oui' : 'Non'; ?></td>
<?php if ($_SESSION['user']['admin']) { ?><td><input name="ids[]" type="checkbox" value="<?php $this->s($received['id']); ?>"></td><?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div>
<?php if ($_SESSION['user']['admin']) { ?>
<div class="text-right col-xs-12 no-padding">
<strong>Action pour la séléction :</strong>
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Received', 'mark_as', ['status' => \models\Received::STATUS_READ, 'csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-eye"></span> Marquer comme lu</button>
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Received', 'mark_as', ['status' => \models\Received::STATUS_UNREAD, 'csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-eye-slash"></span> Marquer comme non lu</button>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Received', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
<?php } ?>
</form>
</div>
</div>
@ -92,17 +77,68 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo $is_unread ? \descartes\Router::url('Received', 'list_unread_json') : \descartes\Router::url('Received', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{
e.preventDefault();
var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href');
jQuery(destination).find('input:checked').each(function ()
data: 'origin',
render: function (data, type, row, meta) {
if (row.contact_name) {
return row.origin_formatted + ' (' + jQuery.fn.dataTable.render.text().display(row.contact_name) + ')';
}
return row.origin_formatted;
},
},
{data: 'phone_name', render: jQuery.fn.dataTable.render.text()},
{data: 'text', render: jQuery.fn.dataTable.render.text()},
{data: 'at', render: jQuery.fn.dataTable.render.text()},
{
url += '/' + jQuery(this).val();
});
window.location = url;
data: 'status',
render: function (data, type, row, meta) {
switch (data) {
case 'read':
return 'Lu';
break;
default:
return 'Non lu';
}
},
},
{
data: 'command',
render: function (data, type, row, meta) {
if (data == 0) {
return "Non";
} else {
return 'Oui';
}
},
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -1,85 +0,0 @@
<?php
//Template dashboard
$this->render('incs/head', ['title' => 'Receiveds - Unread'])
?>
<div id="wrapper">
<?php
$this->render('incs/nav', ['page' => 'receiveds_unread'])
?>
<div id="page-wrapper">
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Dashboard <small>SMS non lus</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-eye-slash "></i> SMS non lus
</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-eye-slash fa-fw"></i> Liste des SMS non lus</h3>
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$receiveds) { ?>
<p>Aucun SMS non lu à afficher.</p>
<?php } else { ?>
<div class="table-receiveds">
<table class="table table-bordered table-hover table-striped datatable" id="table-receiveds">
<thead>
<tr>
<th>De</th>
<th>À</th>
<th>Message</th>
<th>Date</th>
<th>Status</th>
<th>Commande</th>
<?php if ($_SESSION['user']['admin']) { ?><th class="checkcolumn">&#10003;</th><?php } ?>
</tr>
</thead>
<tbody>
<?php foreach ($receiveds as $received) { ?>
<tr>
<td class="no-wrap">
<?php if ($received['contact'] ?? false) { ?>
<?php echo \controllers\internals\Tool::phone_link($received['origin']) . ' (' . $received['contact'] . ')'; ?>
<?php } else { ?>
<?php echo \controllers\internals\Tool::phone_link($received['origin']); ?>
<?php } ?>
</td>
<td class="no-wrap"><?php $this->s($received['phone_name'] ?? 'Inconnu'); ?></td>
<td><?php $this->s($received['text']); ?></td>
<td><?php $this->s($received['at']); ?></td>
<td><?php echo ($received['status'] == 'read' ? 'Lu' : 'Non lu'); ?></td>
<td><?php echo $received['command'] ? 'Oui' : 'Non'; ?></td>
<?php if ($_SESSION['user']['admin']) { ?><td><input name="ids[]" type="checkbox" value="<?php $this->s($received['id']); ?>"></td><?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
$this->render('incs/footer');

View File

@ -35,11 +35,8 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$scheduleds) { ?>
<p>Aucun SMS n'est actuellement programmé.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped" id="table-scheduleds">
<div class="table-scheduleds">
<table class="table table-bordered table-hover table-striped datatable" id="table-scheduleds">
<thead>
<tr>
<th>Date</th>
@ -48,28 +45,19 @@
</tr>
</thead>
<tbody>
<?php foreach ($scheduleds as $scheduled) { ?>
<tr>
<td><?php $this->s($scheduled['at']); ?></td>
<td><?php $this->s($scheduled['text']); ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($scheduled['id']); ?>"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<div>
<div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Scheduled', 'add'); ?>"><span class="fa fa-plus"></span> Créer un nouveau SMS</a>
</div>
<?php if ($scheduleds) { ?>
<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', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Scheduled', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
</div>
</form>
</div>
@ -82,17 +70,34 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Scheduled', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'at', render: jQuery.fn.dataTable.render.text()},
{data: 'text', render: jQuery.fn.dataTable.render.text()},
{
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;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -35,9 +35,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$sendeds) { ?>
<p>Aucun SMS n'a été envoyé pour le moment.</p>
<?php } else { ?>
<div class="table-sendeds">
<table class="table table-bordered table-hover table-striped datatable" id="table-sendeds">
<thead>
@ -47,50 +44,18 @@
<th>Message</th>
<th>Date</th>
<th>Statut</th>
<?php if ($_SESSION['user']['admin']) { ?>
<th class="checkcolumn">&#10003;</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach ($sendeds as $sended) { ?>
<tr>
<td class="no-wrap"><?php $this->s($sended['phone_name'] ?? 'Inconnu'); ?></td>
<td class="no-wrap">
<?php if ($sended['contact'] ?? false) { ?>
<?php echo \controllers\internals\Tool::phone_link($sended['destination']) . ' (' . $sended['contact'] . ')'; ?>
<?php } else { ?>
<?php echo \controllers\internals\Tool::phone_link($sended['destination']); ?>
<?php } ?>
</td>
<td><?php $this->s($sended['text']); ?></td>
<td><?php $this->s($sended['at']); ?></td>
<?php if ($sended['status'] == 'unknown') { ?>
<td>Inconnu</td>
<?php } elseif ($sended['status'] == 'delivered') { ?>
<td>Délivré</td>
<?php } elseif ($sended['status'] == 'failed') { ?>
<td>Échoué</td>
<?php } ?>
<?php if ($_SESSION['user']['admin']) { ?>
<td><input name="ids[]" type="checkbox" value="<?php $this->s($sended['id']); ?>"></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
<tbody></tbody>
</table>
</div>
<div>
<?php if ($_SESSION['user']['admin']) { ?>
<div class="text-right col-xs-12 no-padding">
<strong>Action pour la séléction :</strong>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Sended', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</form>
</div>
@ -102,16 +67,59 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Sended', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'phone_name', render: jQuery.fn.dataTable.render.text()},
{
e.preventDefault();
var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href');
jQuery(destination).find('input:checked').each(function ()
data: 'destination',
render: function (data, type, row, meta) {
if (row.contact_name) {
return row.destination_formatted + ' (' + jQuery.fn.dataTable.render.text().display(row.contact_name) + ')';
}
return row.destination_formatted;
},
},
{data: 'text', render: jQuery.fn.dataTable.render.text()},
{data: 'at', render: jQuery.fn.dataTable.render.text()},
{
url += '/' + jQuery(this).val();
});
window.location = url;
data: 'status',
render: function (data, type, row, meta) {
switch (data) {
case 'failed':
return 'Échec';
break;
case 'delivered':
return 'Délivré';
default:
return 'Inconnu';
}
},
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});

View File

@ -35,26 +35,17 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$smsstops) { ?>
<p>Aucun SMS STOP n'a été reçu pour le moment.</p>
<?php } else { ?>
<div class="table-events">
<table class="table table-bordered table-hover table-striped datatable" id="table-smsstop">
<thead>
<tr>
<th>Numéro</th>
<?php if ($_SESSION['user']['admin']) { ?>
<th class="checkcolumn">&#10003;</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach ($smsstops as $smsstop) { ?>
<tr>
<td><?php echo(\controllers\internals\Tool::phone_link($smsstop['number'])); ?></td>
<?php if ($_SESSION['user']['admin']) { ?>
<td><input name="ids[]" type="checkbox" value="<?php $this->s($smsstop['id']); ?>"></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
@ -66,7 +57,6 @@
</div>
<?php } ?>
</div>
<?php } ?>
</form>
</div>
</div>
@ -78,17 +68,35 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('SmsStop', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{
e.preventDefault();
var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href');
jQuery(destination).find('input:checked').each(function ()
data: 'number_formatted',
},
{
url += '/' + jQuery(this).val();
});
window.location = url;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -41,19 +41,11 @@
<tr>
<th>Email</th>
<th>Admin</th>
<th>Status</th>
<th>Statut</th>
<th class="checkcolumn">&#10003;</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $user) { ?>
<tr>
<td><?php $this->s($user['email']); ?></td>
<td><?php $this->s($user['admin']); ?></td>
<td><?php $this->s($user['status']); ?></td>
<td><input type="checkbox" value="<?php $this->s($user['id']); ?>" name="ids[]"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
@ -80,17 +72,35 @@
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('User', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'email', render: jQuery.fn.dataTable.render.text()},
{data: 'admin', render: jQuery.fn.dataTable.render.text()},
{data: 'status', render: jQuery.fn.dataTable.render.text()},
{
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;
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php

View File

@ -33,9 +33,6 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$webhooks) { ?>
<p>Aucun webhook n'a été créé pour le moment.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-webhooks">
<thead>
@ -46,28 +43,18 @@
</tr>
</thead>
<tbody>
<?php foreach ($webhooks as $webhook) { ?>
<tr>
<td><?php $this->s($webhook['url']); ?></td>
<td><?php $this->s($webhook['type'] == 'send_sms' ? 'Envoi de SMS' : 'Reception de SMS'); ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($webhook['id']); ?>"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<div>
<div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Webhook', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un webhook</a>
</div>
<?php if ($webhooks) { ?>
<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('Webhook', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Webhook', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
</form>
</div>
@ -77,5 +64,50 @@
</div>
</div>
</div>
<script>
jQuery(document).ready(function ()
{
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Webhook', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'url', render: jQuery.fn.dataTable.render.text()},
{
data: 'type',
render: function (data, type, row, meta) {
switch (data) {
case 'send_sms':
return 'Envoi de SMS';
case 'receive_sms':
return 'Réception de SMS';
default:
return 'Inconnu';
}
},
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php
$this->render('incs/footer');