all basic functionnalities working fine

This commit is contained in:
osaajani 2019-11-10 17:32:59 +01:00
parent 1dfebd1df7
commit bb6f755ef2
21 changed files with 53 additions and 54 deletions

View File

@ -28,7 +28,7 @@ function verifReceived()
jQuery('.popup-alert').fadeOut('slow'); jQuery('.popup-alert').fadeOut('slow');
jQuery.getJSON(HTTP_PWD + "/received/popup", function( data ) { jQuery.getJSON(HTTP_PWD + "/received/popup", function( data ) {
$.each(data, function(key, val) { $.each(data, function(key, val) {
showMessage('SMS reçu du ' + val.send_by.replace(/</g, "&lt;").replace(/>/g, "&gt;") + ' : ' + val.content.replace(/</g, "&lt;").replace(/>/g, "&gt;"), 1); showMessage('SMS reçu du ' + val.origin.replace(/</g, "&lt;").replace(/>/g, "&gt;") + ' : ' + val.text.replace(/</g, "&lt;").replace(/>/g, "&gt;"), 1);
playReceptionSound(); playReceptionSound();
}); });
}); });

View File

@ -91,10 +91,10 @@ class Console extends \descartes\InternalController
$numbers = []; $numbers = [];
//On récupère les numéros pour le Sms et on les ajoute //On récupère les numéros pour le Sms et on les ajoute
$target_numbers = $this->internal_scheduled->get_numbers($id_scheduled); $destination_numbers = $this->internal_scheduled->get_numbers($id_scheduled);
foreach ($target_numbers as $target_number) foreach ($destination_numbers as $destination_number)
{ {
$numbers[] = $target_number['number']; $numbers[] = $destination_number['number'];
} }
//On récupère les contacts, et on ajoute les numéros //On récupère les contacts, et on ajoute les numéros
@ -143,7 +143,7 @@ class Console extends \descartes\InternalController
$now = $now->format('Y-m-d H:i:s'); $now = $now->format('Y-m-d H:i:s');
//On peut maintenant ajouter le Sms //On peut maintenant ajouter le Sms
if (!$id_sended = $this->model_sended->insert(['at' => $now, 'target' => $number, 'content' => $scheduled['content'], 'before_delivered' => ceil(mb_strlen($scheduled['content']) / 160)])) if (!$id_sended = $this->model_sended->insert(['at' => $now, 'destination' => $number, 'content' => $scheduled['content'], 'before_delivered' => ceil(mb_strlen($scheduled['content']) / 160)]))
{ {
echo 'Impossible d\'inserer le sms pour le numero '.$number."\n"; echo 'Impossible d\'inserer le sms pour le numero '.$number."\n";
} }
@ -249,7 +249,7 @@ class Console extends \descartes\InternalController
$interval = new \DateInterval('PT12H'); $interval = new \DateInterval('PT12H');
$sinceDate = $now->sub($interval)->format('Y-m-d H:i:s'); $sinceDate = $now->sub($interval)->format('Y-m-d H:i:s');
if (!$sendeds = $this->model_sended->_select('sendeds', ['target' => $number, 'delivered' => false, 'failed' => false, '>at' => $sinceDate], 'at', false, 1)) if (!$sendeds = $this->model_sended->_select('sendeds', ['destination' => $number, 'delivered' => false, 'failed' => false, '>at' => $sinceDate], 'at', false, 1))
{ {
continue; continue;
} }

View File

@ -66,14 +66,14 @@ namespace controllers\internals;
/** /**
* Cette fonction retourne une liste des receivedes sous forme d'un tableau. * Cette fonction retourne une liste des receivedes sous forme d'un tableau.
* *
* @param string $target : Le numéro auquel est envoyé le message * @param string $destination : Le numéro auquel est envoyé le message
* *
* @return array : La liste des sendeds * @return array : La liste des sendeds
*/ */
public function get_by_target($target) public function get_by_destination($destination)
{ {
//Recupération des sendeds //Recupération des sendeds
return $this->model_sended->get_by_target($target); return $this->model_sended->get_by_destination($destination);
} }
/** /**

View File

@ -88,7 +88,7 @@ namespace controllers\publics;
$now = new \DateTime(); $now = new \DateTime();
$now = $now->format('Y-m-d H:i:s'); $now = $now->format('Y-m-d H:i:s');
$sendeds = $this->internal_sended->get_by_target($number); $sendeds = $this->internal_sended->get_by_destination($number);
$receiveds = $this->internal_received->get_by_origin($number); $receiveds = $this->internal_received->get_by_origin($number);
$scheduleds = $this->internal_scheduled->get_before_date_for_number($now, $number); $scheduleds = $this->internal_scheduled->get_before_date_for_number($now, $number);
@ -98,7 +98,7 @@ namespace controllers\publics;
{ {
$messages[] = [ $messages[] = [
'date' => htmlspecialchars($sended['at']), 'date' => htmlspecialchars($sended['at']),
'text' => htmlspecialchars($sended['content']), 'text' => htmlspecialchars($sended['text']),
'type' => 'sended', 'type' => 'sended',
'status' => ($sended['delivered'] ? 'delivered' : ($sended['failed'] ? 'failed' : '')), 'status' => ($sended['delivered'] ? 'delivered' : ($sended['failed'] ? 'failed' : '')),
]; ];
@ -108,9 +108,9 @@ namespace controllers\publics;
{ {
$messages[] = [ $messages[] = [
'date' => htmlspecialchars($received['at']), 'date' => htmlspecialchars($received['at']),
'text' => htmlspecialchars($received['content']), 'text' => htmlspecialchars($received['text']),
'type' => 'received', 'type' => 'received',
'md5' => md5($received['at'].$received['content']), 'md5' => md5($received['at'].$received['text']),
]; ];
} }
@ -118,7 +118,7 @@ namespace controllers\publics;
{ {
$messages[] = [ $messages[] = [
'date' => htmlspecialchars($scheduled['at']), 'date' => htmlspecialchars($scheduled['at']),
'text' => htmlspecialchars($scheduled['content']), 'text' => htmlspecialchars($scheduled['text']),
'type' => 'inprogress', 'type' => 'inprogress',
]; ];
} }
@ -141,7 +141,7 @@ namespace controllers\publics;
* Cette fonction permet d'envoyer facilement un sms à un numéro donné. * Cette fonction permet d'envoyer facilement un sms à un numéro donné.
* *
* @param string $csrf : Le jeton csrf * @param string $csrf : Le jeton csrf
* @param string $_POST['content'] : Le contenu du Sms * @param string $_POST['text'] : Le contenu du Sms
* @param string $_POST['numbers'] : Un tableau avec le numero des gens auxquel envoyer le sms * @param string $_POST['numbers'] : Un tableau avec le numero des gens auxquel envoyer le sms
* *
* @return string : json string Le statut de l'envoi * @return string : json string Le statut de l'envoi
@ -163,9 +163,8 @@ namespace controllers\publics;
$now = new \DateTime(); $now = new \DateTime();
$now = $now->format('Y-m-d H:i:s'); $now = $now->format('Y-m-d H:i:s');
$scheduled = []; $at = $now;
$scheduled['at'] = $now; $text = $_POST['text'] ?? '';
$scheduled['content'] = $_POST['content'] ?? '';
$numbers = $_POST['numbers'] ?? false; $numbers = $_POST['numbers'] ?? false;
if (!$numbers) if (!$numbers)
@ -177,7 +176,7 @@ namespace controllers\publics;
return false; return false;
} }
if (!$this->internal_scheduled->create($scheduled, $numbers)) if (!$this->internal_scheduled->create($at, $text, false, false, $numbers))
{ {
$return['success'] = false; $return['success'] = false;
$return['message'] = 'Impossible de créer le Sms'; $return['message'] = 'Impossible de créer le Sms';

View File

@ -109,7 +109,7 @@ namespace models;
FROM scheduled_group FROM scheduled_group
WHERE id_group IN ( WHERE id_group IN (
SELECT id_group SELECT id_group
FROM `group`_contact FROM `group_contact`
WHERE id_contact IN ( WHERE id_contact IN (
SELECT id SELECT id
FROM contact FROM contact

View File

@ -78,13 +78,13 @@ namespace models;
/** /**
* Cette fonction retourne une liste des sended sous forme d'un tableau. * Cette fonction retourne une liste des sended sous forme d'un tableau.
* *
* @param string $target : Le numéro auquel est envoyé le message * @param string $destination : Le numéro auquel est envoyé le message
* *
* @return array : La liste des sended * @return array : La liste des sended
*/ */
public function get_by_target($target) public function get_by_destination($destination)
{ {
return $this->_select('sended', ['target' => $target]); return $this->_select('sended', ['destination' => $destination]);
} }
/** /**

View File

@ -128,9 +128,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -89,9 +89,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -87,9 +87,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -153,7 +153,7 @@
<tbody> <tbody>
<?php foreach ($sendeds as $sended) { ?> <?php foreach ($sendeds as $sended) { ?>
<tr> <tr>
<td><?php $this->s($sended['target']); ?></td> <td><?php $this->s($sended['destination']); ?></td>
<td><?php $this->s($sended['at']); ?></td> <td><?php $this->s($sended['at']); ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
@ -190,7 +190,7 @@
<tr> <tr>
<td><?php $this->s($received['origin']); ?></td> <td><?php $this->s($received['origin']); ?></td>
<td><?php $this->s($received['at']); ?></td> <td><?php $this->s($received['at']); ?></td>
<td><?php echo ($received['is_command']) ? 'Oui' : 'Non'; ?></td> <td><?php echo ($received['command']) ? 'Oui' : 'Non'; ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
</tbody> </tbody>

View File

@ -47,7 +47,7 @@
</thead> </thead>
<tbody> <tbody>
<?php foreach ($discussions as $discussion) { ?> <?php foreach ($discussions as $discussion) { ?>
<tr class="goto" url="<?php $this->s(\Router::url('Discussion', 'show', ['number' => $discussion['number']])); ?>"> <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($discussion['at']); ?></td>
<td><?php $this->s(isset($discussion['contact']) ? $discussion['contact'] . ' (' . $discussion['number'] . ')' : $discussion['number']); ?></td> <td><?php $this->s(isset($discussion['contact']) ? $discussion['contact'] . ' (' . $discussion['number'] . ')' : $discussion['number']); ?></td>
</tr> </tr>

View File

@ -36,8 +36,8 @@
</div> </div>
<div class="col-lg-12 message-input-container"> <div class="col-lg-12 message-input-container">
<div class="discussion-message message-input"> <div class="discussion-message message-input">
<form class="send-message-discussion" action="<?php $this->s(\Router::url('Discussion', 'send', ['csrf' => $_SESSION['csrf']])); ?>" method="POST"> <form class="send-message-discussion" action="<?php $this->s(\descartes\Router::url('Discussion', 'send', ['csrf' => $_SESSION['csrf']])); ?>" method="POST">
<textarea name="content" placeholder="Envoyer un message..."></textarea> <textarea name="text" placeholder="Envoyer un message..."></textarea>
<input type="hidden" name="numbers[]" value="<?php $this->s($number); ?>" /> <input type="hidden" name="numbers[]" value="<?php $this->s($number); ?>" />
<button class="btn" ><span class="fa fa-fw fa-send-o"></span> Envoyer</button> <button class="btn" ><span class="fa fa-fw fa-send-o"></span> Envoyer</button>
</form> </form>
@ -58,7 +58,7 @@
function getmessages () function getmessages ()
{ {
ajaxTransactionId = Date.now(); ajaxTransactionId = Date.now();
jQuery.getJSON(HTTP_PWD + "/discussions/getmessages/<?php echo htmlspecialchars(urlencode($number)); ?>/" + ajaxTransactionId , function( data ) { jQuery.getJSON(HTTP_PWD + "/discussion/getmessage/<?php echo htmlspecialchars(urlencode($number)); ?>/" + ajaxTransactionId , function( data ) {
if (data.transaction_id != ajaxTransactionId) if (data.transaction_id != ajaxTransactionId)
{ {

View File

@ -98,9 +98,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -87,9 +87,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -97,9 +97,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -87,9 +87,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -110,9 +110,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -178,9 +178,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -93,9 +93,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -81,9 +81,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });

View File

@ -62,7 +62,7 @@
</div> </div>
<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>
<div class="btn-groupe action-dropdown" target="#table-webhooks"> <div class="btn-groupe action-dropdown" destination="#table-webhooks">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Action pour la sélection <span class="caret"></span></button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Action pour la sélection <span class="caret"></span></button>
<ul class="dropdown-menu pull-right" role="menu"> <ul class="dropdown-menu pull-right" role="menu">
<li><a href="<?php echo \descartes\Router::url('webhooks', 'edit', [$_SESSION['csrf']]); ?>"><span class="fa fa-edit"></span> Modifier</a></li> <li><a href="<?php echo \descartes\Router::url('webhooks', 'edit', [$_SESSION['csrf']]); ?>"><span class="fa fa-edit"></span> Modifier</a></li>
@ -84,9 +84,9 @@
jQuery('.action-dropdown a').on('click', function (e) jQuery('.action-dropdown a').on('click', function (e)
{ {
e.preventDefault(); e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target'); var destination = jQuery(this).parents('.action-dropdown').attr('destination');
var url = jQuery(this).attr('href'); var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function () jQuery(destination).find('input:checked').each(function ()
{ {
url += '/' + jQuery(this).val(); url += '/' + jQuery(this).val();
}); });