Ajout des accusés de reception
This commit is contained in:
parent
ee02e2609b
commit
3a7cd8ebda
|
@ -85,6 +85,7 @@
|
|||
'date' => htmlspecialchars($sended['at']),
|
||||
'text' => htmlspecialchars($sended['content']),
|
||||
'type' => 'sended',
|
||||
'delivered' => ($sended['delivered'] ? true : false),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -239,12 +239,33 @@
|
|||
//On gère les SMS STOP
|
||||
if (trim($text) == 'STOP')
|
||||
{
|
||||
echo 'STOP SMS detected ' . $number;
|
||||
echo 'STOP SMS detected ' . $number . "\n";
|
||||
$this->wlog('STOP SMS detected ' . $number);
|
||||
$db->insertIntoTable('sms_stop', ['number' => $number]);
|
||||
continue;
|
||||
}
|
||||
|
||||
//On gère les accusés de reception
|
||||
if (trim($text) == 'Delivered')
|
||||
{
|
||||
echo 'Delivered SMS for ' . $number . "\n";
|
||||
$this->wlog('Delivered SMS for ' . $number);
|
||||
|
||||
//On récupère les SMS par encore validé, uniquement sur les dernières 24h
|
||||
$now = new DateTime();
|
||||
$interval = new DateInterval('P1D');
|
||||
$sinceDate = $now->sub($interval)->format('Y-m-d H:i:s');
|
||||
|
||||
if (!$sendeds = $db->getFromTableWhere('sendeds', ['target' => $number, 'delivered' => false, '>at' => $sinceDate], 'at', false, 1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$db->updateTableWhere('sendeds', ['delivered' => true], ['id' => $sendeds[0]['id']]);
|
||||
echo "Sended SMS id " . $sendeds[0]['id'] . " to delivered status\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$number)
|
||||
{
|
||||
$this->wlog('Invalid phone number in file "' . $dir);
|
||||
|
|
|
@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS sendeds
|
|||
at DATETIME NOT NULL,
|
||||
target VARCHAR(12) NOT NULL,
|
||||
content VARCHAR(1000) NOT NULL,
|
||||
delivered BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
'<div class="clearfix message-container">' +
|
||||
'<div class="discussion-message message-sended">' +
|
||||
'<div class="discussion-message-text">' + message.text + '</div>' +
|
||||
'<div class="discussion-message-date">' + message.date + '</div>' +
|
||||
'<div class="discussion-message-date">' + message.date + (message.delivered ? ' <span class="fa fa-check-circle fa-fw text-success"></span>' : '' ) + '</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
break;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
<th>Numéro</th>
|
||||
<th>Message</th>
|
||||
<th>Date</th>
|
||||
<th>Delivré</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -54,6 +55,7 @@
|
|||
<td><?php secho($send['target']); ?></td>
|
||||
<td><?php secho($send['content']); ?></td>
|
||||
<td><?php secho($send['at']); ?></td>
|
||||
<td><?php secho($send['delivered'] ? 'Oui' : 'Non'); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue