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,23 +74,10 @@ function playReceptionSound ()
jQuery(document).ready(function() 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('.datatable').on('draw.dt', function (){
jQuery('body :checkbox').off('shiftcheckbox'); jQuery('body :checkbox').off('shiftcheckbox');
jQuery('body :checkbox').shiftcheckbox(); jQuery('body :checkbox').shiftcheckbox();
}); });
var verifReceivedInterval = setInterval(verifReceived, 10000); var verifReceivedInterval = setInterval(verifReceived, 10000);

View File

@ -42,8 +42,17 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$commands = $this->internal_command->list_for_user($_SESSION['user']['id']); $this->render('command/list');
$this->render('command/list', ['commands' => $commands]); }
/**
* 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,9 +48,19 @@ namespace controllers\publics;
{ {
$page = (int) $page; $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]); $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. * Cette fonction va supprimer une liste de groups.

View File

@ -40,9 +40,22 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$contacts = $this->internal_contact->list_for_user($_SESSION['user']['id']); return $this->render('contact/list');
}
/**
* 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']);
}
return $this->render('contact/list', ['contacts' => $contacts]); header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
} }
/** /**

View File

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

View File

@ -40,8 +40,22 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$events = $this->internal_event->list_for_user($_SESSION['user']['id']); $this->render('event/list');
$this->render('event/list', ['events' => $events, 'nb_results' => \count($events)]); }
/**
* 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]);
} }
/** /**
@ -60,6 +74,13 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Event', 'list')); 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'] ?? []; $ids = $_GET['ids'] ?? [];
foreach ($ids as $id) foreach ($ids as $id)

View File

@ -42,15 +42,18 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$groups = $this->internal_group->list_for_user($_SESSION['user']['id']); $this->render('group/list');
}
foreach ($groups as $key => $group)
{
$contacts = $this->internal_group->get_contacts($group['id']); /**
$groups[$key]['nb_contacts'] = \count($contacts); * Return groups as json
} */
public function list_json()
$this->render('group/list', ['groups' => $groups]); {
$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]); $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. * Cette fonction va supprimer une liste de phones.
* *

View File

@ -41,32 +41,22 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$receiveds = $this->internal_received->list_for_user($_SESSION['user']['id']); $this->render('received/list', ['is_unread' => false]);
}
foreach ($receiveds as $key => $received)
/**
* Return received as json
*/
public function list_json()
{
$entities = $this->internal_received->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{ {
if ('read' !== $received['status']) $entity['origin_formatted'] = \controllers\internals\Tool::phone_link($entity['origin']);
{
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $received['id']);
}
if (null !== $received['id_phone'])
{
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $received['id_phone']);
if ($phone)
{
$receiveds[$key]['phone_name'] = $phone['name'];
}
}
$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() 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()
{
$entities = $this->internal_received->list_unread_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{ {
$this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $received['id']); $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)
{
if (!$this->verify_csrf($csrf))
{
\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)
{ {
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $received['id_phone']); $this->internal_received->mark_as_unread_for_user($_SESSION['user']['id'], $id);
if ($phone)
{
$receiveds[$key]['phone_name'] = $phone['name'];
}
} }
elseif ($status === \models\Received::STATUS_READ)
$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $received['origin']);
if ($contact)
{ {
$receiveds[$key]['contact'] = $contact['name']; $this->internal_received->mark_as_read_for_user($_SESSION['user']['id'], $id);
} }
} }
$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() public function list()
{ {
$scheduleds = $this->internal_scheduled->list_for_user($_SESSION['user']['id']); $this->render('scheduled/list');
$this->render('scheduled/list', ['scheduleds' => $scheduleds]); }
/**
* 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,28 +42,24 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$sendeds = $this->internal_sended->list_for_user($_SESSION['user']['id']); $this->render('sended/list');
}
foreach ($sendeds as $key => $sended) /**
* Return sendeds as json
*/
public function list_json()
{
$entities = $this->internal_sended->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{ {
if (null !== $sended['id_phone']) $entity['destination_formatted'] = \controllers\internals\Tool::phone_link($entity['destination']);
{
$phone = $this->internal_phone->get_for_user($_SESSION['user']['id'], $sended['id_phone']);
if ($phone)
{
$sendeds[$key]['phone_name'] = $phone['name'];
}
}
$contact = $this->internal_contact->get_by_number_and_user($_SESSION['user']['id'], $sended['destination']);
if ($contact)
{
$sendeds[$key]['contact'] = $contact['name'];
}
} }
$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. * Cette fonction va supprimer une liste de sendeds.

View File

@ -39,8 +39,22 @@ namespace controllers\publics;
*/ */
public function list() public function list()
{ {
$smsstops = $this->internal_sms_stop->list_for_user($_SESSION['user']['id']); $this->render('smsstop/list');
$this->render('smsstop/list', ['smsstops' => $smsstops, 'nb_results' => \count($smsstops)]); }
/**
* 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() public function list()
{ {
$users = $this->internal_user->list(); $this->render('user/list');
$this->render('user/list', ['users' => $users]); }
/**
* 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() public function list()
{ {
$webhooks = $this->internal_webhook->list_for_user($_SESSION['user']['id']); $this->render('webhook/list');
$this->render('webhook/list', ['webhooks' => $webhooks]); }
/**
* 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 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. * Return a group by his name for a user.
* *

View File

@ -18,31 +18,93 @@ namespace models;
{ {
const STATUS_UNREAD = 'unread'; const STATUS_UNREAD = 'unread';
const STATUS_READ = 'read'; 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 $id_user : user id
* @param int $limit : Max results to return * @param ?int $limit : Number of entry to return or null
* @param int $offset : Number of results to ignore * @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)
{ {
$limit = (int) $limit; $query = '
$offset = (int) $offset; 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
';
$query = ' if ($limit !== null)
SELECT * FROM received {
WHERE status = \'unread\' $limit = (int) $limit;
AND id_user = :id_user
LIMIT ' . $limit . ' OFFSET ' . $offset;
$query .= ' LIMIT ' . $limit;
if ($offset !== null)
{
$offset = (int) $offset;
$query .= ' OFFSET ' . $offset;
}
}
$params = [ $params = [
'id_user' => $id_user, 'id_user' => $id_user,
]; ];
return $this->_run_query($query, $params); 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. * Count number of unread received sms for user.
@ -154,7 +216,7 @@ namespace models;
public function get_discussions_for_user(int $id_user) public function get_discussions_for_user(int $id_user)
{ {
$query = ' $query = '
SELECT at, number SELECT discussions.at, discussions.number, contact.name as contact_name
FROM ( FROM (
SELECT at, destination as number FROM sended SELECT at, destination as number FROM sended
WHERE id_user = :id_user WHERE id_user = :id_user
@ -163,6 +225,8 @@ namespace models;
WHERE id_user = :id_user WHERE id_user = :id_user
) )
) as discussions ) as discussions
LEFT JOIN contact
ON discussions.number = contact.number AND id_user = :id_user
GROUP BY number GROUP BY number
ORDER BY at DESC ORDER BY at DESC
'; ';

View File

@ -19,6 +19,48 @@ namespace models;
const STATUS_UNKNOWN = 'unknown'; const STATUS_UNKNOWN = 'unknown';
const STATUS_DELIVERED = 'delivered'; const STATUS_DELIVERED = 'delivered';
const STATUS_FAILED = 'failed'; 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. * Return x last sendeds message for a user, order by date.

View File

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

View File

@ -35,43 +35,29 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$commands) { ?> <div class="table-responsive">
<p>Aucune commande n'a été créée pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-commands">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-commands"> <th>Nom</th>
<thead> <th>Script</th>
<tr> <th>Admin obligatoire</th>
<th>Nom</th> <th class="checkcolumn">&#10003;</th>
<th>Script</th> </tr>
<th>Admin obligatoire</th> </thead>
<th class="checkcolumn">&#10003;</th> <tbody>
</tr> </tbody>
</thead> </table>
<tbody> </div>
<?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>
<div class="col-xs-6 no-padding"> <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> <a class="btn btn-success" href="<?php echo \descartes\Router::url('Command', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter une commande</a>
</div> </div>
<?php if ($commands) { ?> <div class="text-right col-xs-6 no-padding">
<div class="text-right col-xs-6 no-padding"> <strong>Action pour la séléction :</strong>
<strong>Action pour la séléction :</strong> <button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Command', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<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>
<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>
</div>
<?php } ?>
</div> </div>
</form> </form>
</div> </div>
@ -81,5 +67,44 @@
</div> </div>
</div> </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 <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -81,20 +81,37 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "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()},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -37,42 +37,29 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$contacts) { ?> <div class="table-responsive">
<p>Aucun contact n'est enregistré pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-contacts">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-contacts"> <th>Nom</th>
<thead> <th>Numéro</th>
<tr> <th class="checkcolumn">&#10003;</th>
<th>Nom</th> </tr>
<th>Numéro</th> </thead>
<th class="checkcolumn">&#10003;</th> <tbody>
</tr> </tbody>
</thead> </table>
<tbody> </div>
<?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>
<div class="col-xs-6 no-padding"> <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> <a class="btn btn-success" href="<?php echo \descartes\Router::url('Contact', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un contact</a>
</div> </div>
<?php if ($contacts) { ?> <div class="text-right col-xs-6 no-padding">
<div class="text-right col-xs-6 no-padding"> <strong>Action pour la séléction :</strong>
<strong>Action pour la séléction :</strong> <button class="btn btn-default" type="submit" formaction="<?php echo \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('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" 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>
<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>
</div>
<?php } ?>
</div> </div>
</form> </form>
</div> </div>
@ -124,18 +111,50 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function() jQuery(document).ready(function()
{
//Import/export contacts
jQuery('body').on('click', '#btn-import', function ()
{ {
jQuery('body').on('click', '#btn-import', function () jQuery('#import-modal').modal({'keyboard': true});
{
jQuery('#import-modal').modal({'keyboard': true});
});
jQuery('body').on('click', '#btn-export', function ()
{
jQuery('#export-modal').modal({'keyboard': true});
});
}); });
jQuery('body').on('click', '#btn-export', function ()
{
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> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -34,28 +34,24 @@
<h3 class="panel-title"><i class="fa fa-comments-o fa-fw"></i> Liste des discussions</h3> <h3 class="panel-title"><i class="fa fa-comments-o fa-fw"></i> Liste des discussions</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<?php if (!$discussions) { ?> <div class="table-responsive">
Aucune discussion n'est en cours actuellement. <table class="table table-bordered table-hover table-striped datatable" id="table-discussions">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-discussions"> <th>Date du dernier message</th>
<thead> <th>Numéro</th>
<tr> </tr>
<th>Date du dernier message</th> </thead>
<th>Numéro</th> <tbody>
</tr> <?php /*foreach ($discussions as $discussion) { ?>
</thead> <tr class="goto" url="<?php $this->s(\descartes\Router::url('Discussion', 'show', ['number' => $discussion['number']])); ?>">
<tbody> <td><?php $this->s($discussion['at']); ?></td>
<?php foreach ($discussions as $discussion) { ?> <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 class="goto" url="<?php $this->s(\descartes\Router::url('Discussion', 'show', ['number' => $discussion['number']])); ?>"> </tr>
<td><?php $this->s($discussion['at']); ?></td> <?php } */?>
<td><?php $this->s(isset($discussion['contact']) ? $discussion['contact'] . ' (' . \controllers\internals\Tool::phone_format($discussion['number']) . ')' : \controllers\internals\Tool::phone_format($discussion['number'])); ?></td> </tbody>
</tr> </table>
<?php } ?> </div>
</tbody>
</table>
</div>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>
@ -63,5 +59,44 @@
</div> </div>
</div> </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 <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -136,7 +136,10 @@
var messageInputContainer = jQuery('.message-input-container').outerHeight(); var messageInputContainer = jQuery('.message-input-container').outerHeight();
var footerHeight = jQuery('footer').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); jQuery('.discussion-container').outerHeight(containerHeight);
} }

View File

@ -35,42 +35,29 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$events) { ?> <div class="table-events">
<p>Aucun évènement n'a été enregistré pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-events">
<?php } else { ?> <thead>
<div class="table-events"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-events"> <th>Type</th>
<thead> <th>Date</th>
<tr> <th>Texte</th>
<th>Type</th> <?php if ($_SESSION['user']['admin']) { ?>
<th>Date</th>
<th>Texte</th>
<th class="checkcolumn">&#10003;</th> <th class="checkcolumn">&#10003;</th>
</tr> <?php } ?>
</thead> </tr>
<tbody> </thead>
<?php foreach ($events as $event) { ?> <tbody></tbody>
<tr> </table>
<td><span class="fa fa-fw <?php echo \controllers\internals\Tool::event_type_to_icon($event['type']); ?>"></span></td> </div>
<td><?php $this->s($event['at']); ?></td> <div>
<td><?php $this->s($event['text']); ?></td> <?php if ($_SESSION['user']['admin']) { ?>
<?php if ($_SESSION['user']['admin']) { ?> <div class="text-right col-xs-12 no-padding">
<td><input name="ids[]" type="checkbox" value="<?php $this->s($event['id']); ?>"></td> <strong>Action pour la séléction :</strong>
<?php } ?> <button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Event', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</tr> </div>
<?php } ?> <?php } ?>
</tbody> </div>
</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('Event', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
<?php } ?>
</form> </form>
</div> </div>
</div> </div>
@ -80,20 +67,46 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "ajax": {
'url': '<?php echo \descartes\Router::url('Event', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{
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']) { ?>
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
<?php } ?>
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -35,42 +35,36 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$groups) { ?> <div class="table-responsive">
<p>Aucun groupe n'a été formé pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-groupes">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-groupes"> <th>Nom</th>
<thead> <th>Nombre de contacts</th>
<th class="checkcolumn">&#10003;</th>
</tr>
</thead>
<tbody>
<?php foreach ($groups as $group) { ?>
<tr> <tr>
<th>Nom</th> <td><?php $this->s($group['name']); ?></td>
<th>Nombre de contacts</th> <td><?php $this->s($group['nb_contacts']); ?></td>
<th class="checkcolumn">&#10003;</th> <td><input type="checkbox" name="ids[]" value="<?php $this->s($group['id']); ?>"></td>
</tr> </tr>
</thead> <?php } ?>
<tbody> </tbody>
<?php foreach ($groups as $group) { ?> </table>
<tr> </div>
<td><?php $this->s($group['name']); ?></td>
<td><?php $this->s($group['nb_contacts']); ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($group['id']); ?>"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<div> <div>
<div class="col-xs-6 no-padding"> <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> <a class="btn btn-success" href="<?php echo \descartes\Router::url('Group', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un groupe</a>
</div> </div>
<?php if ($groups) { ?> <div class="text-right col-xs-6 no-padding">
<div class="text-right col-xs-6 no-padding"> <strong>Action pour la séléction :</strong>
<strong>Action pour la séléction :</strong> <button class="btn btn-default" type="submit" formaction="<?php echo \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('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" 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>
<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>
</div>
<?php } ?>
</div> </div>
</form> </form>
</div> </div>
@ -81,20 +75,37 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "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()},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -35,58 +35,28 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$phones) { ?> <div class="table-responsive">
<p>Aucun téléphone utilisable n'a été ajouté pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-phones">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-phones"> <th>ID</th>
<thead> <th>Nom</th>
<tr> <th>Adaptateur</th>
<th>ID</th> <th>Callbacks</th>
<th>Nom</th> <th class="checkcolumn">&#10003;</th>
<th>Adaptateur</th> </tr>
<th>Callbacks</th> </thead>
<th class="checkcolumn">&#10003;</th> <tbody>
</tr> </tbody>
</thead> </table>
<tbody> </div>
<?php foreach ($phones as $phone) { ?> <div>
<tr> <div class="col-xs-6 no-padding">
<td><?php $this->s($phone['id']); ?></td> <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>
<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> </div>
<?php } ?> <div class="text-right col-xs-6 no-padding">
<div> <strong>Action pour la séléction :</strong>
<div class="col-xs-6 no-padding"> <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>
<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>
</div> </div>
</form> </form>
@ -98,20 +68,62 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "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()},
{
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;
},
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -1,11 +1,17 @@
<?php <?php
//Template dashboard //Template dashboard
if ($is_unread)
$this->render('incs/head', ['title' => 'Receiveds - Show All']) {
$this->render('incs/head', ['title' => 'Receiveds - Unread']);
}
else
{
$this->render('incs/head', ['title' => 'Receiveds - Show All']);
}
?> ?>
<div id="wrapper"> <div id="wrapper">
<?php <?php
$this->render('incs/nav', ['page' => 'receiveds']) $this->render('incs/nav', ['page' => ($is_unread ? 'receiveds_unread' : 'receiveds')])
?> ?>
<div id="page-wrapper"> <div id="page-wrapper">
<div class="container-fluid"> <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> <i class="fa fa-dashboard"></i> <a href="<?php echo \descartes\Router::url('Dashboard', 'show'); ?>">Dashboard</a>
</li> </li>
<li class="active"> <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> </li>
</ol> </ol>
</div> </div>
@ -31,13 +37,10 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <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>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$receiveds) { ?>
<p>Aucun SMS n'a été reçu pour le moment.</p>
<?php } else { ?>
<div class="table-receiveds"> <div class="table-receiveds">
<table class="table table-bordered table-hover table-striped datatable" id="table-receiveds"> <table class="table table-bordered table-hover table-striped datatable" id="table-receiveds">
<thead> <thead>
@ -48,39 +51,21 @@
<th>Date</th> <th>Date</th>
<th>Status</th> <th>Status</th>
<th>Commande</th> <th>Commande</th>
<?php if ($_SESSION['user']['admin']) { ?><th class="checkcolumn">&#10003;</th><?php } ?> <th class="checkcolumn">&#10003;</th>
</tr> </tr>
</thead> </thead>
<tbody> <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> </tbody>
</table> </table>
</div> </div>
<div> <div>
<?php if ($_SESSION['user']['admin']) { ?> <div class="text-right col-xs-12 no-padding">
<div class="text-right col-xs-12 no-padding"> <strong>Action pour la séléction :</strong>
<strong>Action pour la séléction :</strong> <button class="btn btn-default" type="submit" formaction="<?php echo \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 btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Received', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</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>
</div> <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>
<?php } ?> </div>
</div> </div>
<?php } ?>
</form> </form>
</div> </div>
</div> </div>
@ -90,20 +75,71 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "ajax": {
'url': '<?php echo $is_unread ? \descartes\Router::url('Received', 'list_unread_json') : \descartes\Router::url('Received', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{
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()},
{
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> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

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,41 +35,29 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$scheduleds) { ?> <div class="table-scheduleds">
<p>Aucun SMS n'est actuellement programmé.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-scheduleds">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped" id="table-scheduleds"> <th>Date</th>
<thead> <th>Contenu</th>
<tr> <th class="checkcolumn">&#10003;</th>
<th>Date</th> </tr>
<th>Contenu</th> </thead>
<th class="checkcolumn">&#10003;</th> <tbody>
</tr> </tbody>
</thead> </table>
<tbody> </div>
<?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>
<div class="col-xs-6 no-padding"> <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> <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> </div>
<?php if ($scheduleds) { ?>
<div class="text-right col-xs-6 no-padding"> <div class="text-right col-xs-6 no-padding">
<strong>Action pour la séléction :</strong> <strong>Action pour la séléction :</strong>
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Scheduled', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button> <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> <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> </div>
<?php } ?> </div>
</div> </div>
</form> </form>
</div> </div>
@ -80,20 +68,37 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "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()},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -35,62 +35,27 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$sendeds) { ?> <div class="table-sendeds">
<p>Aucun SMS n'a été envoyé pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-sendeds">
<?php } else { ?> <thead>
<div class="table-sendeds"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-sendeds"> <th>De</th>
<thead> <th>À</th>
<tr> <th>Message</th>
<th>De</th> <th>Date</th>
<th>À</th> <th>Statut</th>
<th>Message</th> <th class="checkcolumn">&#10003;</th>
<th>Date</th> </tr>
<th>Statut</th> </thead>
<?php if ($_SESSION['user']['admin']) { ?> <tbody></tbody>
<th class="checkcolumn">&#10003;</th> </table>
<?php } ?> </div>
</tr> <div>
</thead> <div class="text-right col-xs-12 no-padding">
<tbody> <strong>Action pour la séléction :</strong>
<?php foreach ($sendeds as $sended) { ?> <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>
<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>
</table>
</div> </div>
<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> </div>
</form> </form>
</div> </div>
@ -100,21 +65,64 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "ajax": {
'url': '<?php echo \descartes\Router::url('Sended', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'phone_name', render: jQuery.fn.dataTable.render.text()},
{
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()},
{
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
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -35,38 +35,28 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$smsstops) { ?> <div class="table-events">
<p>Aucun SMS STOP n'a été reçu pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-smsstop">
<?php } else { ?> <thead>
<div class="table-events"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-smsstop"> <th>Numéro</th>
<thead> <?php if ($_SESSION['user']['admin']) { ?>
<tr>
<th>Numéro</th>
<th class="checkcolumn">&#10003;</th> <th class="checkcolumn">&#10003;</th>
</tr> <?php } ?>
</thead> </tr>
<tbody> </thead>
<?php foreach ($smsstops as $smsstop) { ?> <tbody>
<tr> </tbody>
<td><?php echo(\controllers\internals\Tool::phone_link($smsstop['number'])); ?></td> </table>
<?php if ($_SESSION['user']['admin']) { ?> </div>
<td><input name="ids[]" type="checkbox" value="<?php $this->s($smsstop['id']); ?>"></td> <div>
<?php } ?> <?php if ($_SESSION['user']['admin']) { ?>
</tr> <div class="text-right col-xs-12 no-padding">
<?php } ?> <strong>Action pour la séléction :</strong>
</tbody> <button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('SmsStop', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</table> </div>
</div> <?php } ?>
<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('SmsStop', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
</div>
<?php } ?>
</form> </form>
</div> </div>
</div> </div>
@ -76,20 +66,38 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "ajax": {
'url': '<?php echo \descartes\Router::url('SmsStop', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{
data: 'number_formatted',
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -41,19 +41,11 @@
<tr> <tr>
<th>Email</th> <th>Email</th>
<th>Admin</th> <th>Admin</th>
<th>Status</th> <th>Statut</th>
<th class="checkcolumn">&#10003;</th> <th class="checkcolumn">&#10003;</th>
</tr> </tr>
</thead> </thead>
<tbody> <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> </tbody>
</table> </table>
</div> </div>
@ -78,20 +70,38 @@
</div> </div>
</div> </div>
<script> <script>
jQuery(document).ready(function () jQuery(document).ready(function ()
{ {
jQuery('.action-dropdown a').on('click', function (e) jQuery('.datatable').DataTable({
{ "pageLength": 25,
e.preventDefault(); "bLengthChange": false,
var destination = jQuery(this).parents('.action-dropdown').attr('destination'); "language": {
var url = jQuery(this).attr('href'); "url": HTTP_PWD + "/assets/js/datatables/french.json",
jQuery(destination).find('input:checked').each(function () },
{ "columnDefs": [{
url += '/' + jQuery(this).val(); 'targets': 'checkcolumn',
}); 'orderable': false,
window.location = url; }],
});
}); "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()},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script> </script>
<?php <?php
$this->render('incs/footer'); $this->render('incs/footer');

View File

@ -33,41 +33,28 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form method="GET"> <form method="GET">
<?php if (!$webhooks) { ?> <div class="table-responsive">
<p>Aucun webhook n'a été créé pour le moment.</p> <table class="table table-bordered table-hover table-striped datatable" id="table-webhooks">
<?php } else { ?> <thead>
<div class="table-responsive"> <tr>
<table class="table table-bordered table-hover table-striped datatable" id="table-webhooks"> <th>Url</th>
<thead> <th>Type de webhook</th>
<tr> <th class="checkcolumn">&#10003;</th>
<th>Url</th> </tr>
<th>Type de webhook</th> </thead>
<th class="checkcolumn">&#10003;</th> <tbody>
</tr> </tbody>
</thead> </table>
<tbody> </div>
<?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>
<div class="col-xs-6 no-padding"> <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> <a class="btn btn-success" href="<?php echo \descartes\Router::url('Webhook', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un webhook</a>
</div> </div>
<?php if ($webhooks) { ?> <div class="text-right col-xs-6 no-padding">
<div class="text-right col-xs-6 no-padding"> <strong>Action pour la séléction :</strong>
<strong>Action pour la séléction :</strong> <button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Webhook', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<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>
<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>
</div>
<?php } ?>
</div> </div>
</form> </form>
</div> </div>
@ -77,5 +64,50 @@
</div> </div>
</div> </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 <?php
$this->render('incs/footer'); $this->render('incs/footer');