Ajout de la suppression sur les logs du système (sms reçus, envoyés, events, sms stop)

This commit is contained in:
Pierre-Lin Bonnemaison 2015-10-13 19:24:20 +02:00
parent a7293d7530
commit 3369c34152
13 changed files with 381 additions and 50 deletions

View File

@ -46,4 +46,40 @@
'nbResults' => count($events), 'nbResults' => count($events),
)); ));
} }
/**
* Cette fonction supprimer une liste de sms reçus
* @param $csrf : Le jeton CSRF
* @param int... $ids : Les id des sms à supprimer
* @return boolean;
*/
public function delete($csrf)
{
//On vérifie que le jeton csrf est bon
if (!internalTools::verifyCSRF($csrf))
{
$_SESSION['errormessage'] = 'Jeton CSRF invalide !';
header('Location: ' . $this->generateUrl('events'));
return false;
}
//On récupère les ids comme étant tous les arguments de la fonction et on supprime le premier (csrf)
$ids = func_get_args();
unset($ids[0]);
//Create de l'object de base de données
global $db;
//Si on est pas admin
if (!$_SESSION['admin'])
{
$_SESSION['errormessage'] = 'Vous devez être administrateur pour effectuer cette action.';
header('Location: ' . $this->generateUrl('events'));
return false;
}
$db->deleteEventsIn($ids);
header('Location: ' . $this->generateUrl('events'));
return true;
}
} }

View File

@ -91,4 +91,40 @@
$_SESSION['popup_nb_receiveds'] = $nbReceiveds; $_SESSION['popup_nb_receiveds'] = $nbReceiveds;
return true; return true;
} }
/**
* Cette fonction supprimer une liste de sms reçus
* @param $csrf : Le jeton CSRF
* @param int... $ids : Les id des sms à supprimer
* @return boolean;
*/
public function delete($csrf)
{
//On vérifie que le jeton csrf est bon
if (!internalTools::verifyCSRF($csrf))
{
$_SESSION['errormessage'] = 'Jeton CSRF invalide !';
header('Location: ' . $this->generateUrl('receiveds'));
return false;
}
//On récupère les ids comme étant tous les arguments de la fonction et on supprime le premier (csrf)
$ids = func_get_args();
unset($ids[0]);
//Create de l'object de base de données
global $db;
//Si on est pas admin
if (!$_SESSION['admin'])
{
$_SESSION['errormessage'] = 'Vous devez être administrateur pour effectuer cette action.';
header('Location: ' . $this->generateUrl('receiveds'));
return false;
}
$db->deleteReceivedsIn($ids);
header('Location: ' . $this->generateUrl('receiveds'));
return true;
}
} }

View File

@ -48,4 +48,40 @@
'nbResults' => count($sendeds), 'nbResults' => count($sendeds),
)); ));
} }
/**
* Cette fonction supprimer une liste de sms reçus
* @param $csrf : Le jeton CSRF
* @param int... $ids : Les id des sms à supprimer
* @return boolean;
*/
public function delete($csrf)
{
//On vérifie que le jeton csrf est bon
if (!internalTools::verifyCSRF($csrf))
{
$_SESSION['errormessage'] = 'Jeton CSRF invalide !';
header('Location: ' . $this->generateUrl('sendeds'));
return false;
}
//On récupère les ids comme étant tous les arguments de la fonction et on supprime le premier (csrf)
$ids = func_get_args();
unset($ids[0]);
//Create de l'object de base de données
global $db;
//Si on est pas admin
if (!$_SESSION['admin'])
{
$_SESSION['errormessage'] = 'Vous devez être administrateur pour effectuer cette action.';
header('Location: ' . $this->generateUrl('sendeds'));
return false;
}
$db->deleteSendedsIn($ids);
header('Location: ' . $this->generateUrl('sendeds'));
return true;
}
} }

View File

@ -46,4 +46,40 @@
'nbResults' => count($smsStops), 'nbResults' => count($smsStops),
)); ));
} }
/**
* Cette fonction supprimer une liste de sms stop
* @param $csrf : Le jeton CSRF
* @param int... $ids : Les id des sms à supprimer
* @return boolean;
*/
public function delete($csrf)
{
//On vérifie que le jeton csrf est bon
if (!internalTools::verifyCSRF($csrf))
{
$_SESSION['errormessage'] = 'Jeton CSRF invalide !';
header('Location: ' . $this->generateUrl('smsstop'));
return false;
}
//On récupère les ids comme étant tous les arguments de la fonction et on supprime le premier (csrf)
$ids = func_get_args();
unset($ids[0]);
//Create de l'object de base de données
global $db;
//Si on est pas admin
if (!$_SESSION['admin'])
{
$_SESSION['errormessage'] = 'Vous devez être administrateur pour effectuer cette action.';
header('Location: ' . $this->generateUrl('smsstop'));
return false;
}
$db->deleteSmsStopsIn($ids);
header('Location: ' . $this->generateUrl('smsstop'));
return true;
}
} }

View File

@ -45,6 +45,25 @@
return $this->runQuery($query, $params); return $this->runQuery($query, $params);
} }
/**
* Supprime tous les sendeds dont l'id fait partie du tableau fourni
* @param $sendeds_ids : Tableau des id des sendeds à supprimer
* @return int : Nombre de lignes supprimées
*/
public function deleteSendedsIn($sendeds_ids)
{
$query = "
DELETE FROM sendeds
WHERE id ";
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
$generted_in = $this->generateInFromArray($sendeds_ids);
$query .= $generted_in['QUERY'];
$params = $generted_in['PARAMS'];
return $this->runQuery($query, $params, self::ROWCOUNT);
}
/*********************************/ /*********************************/
/* PARTIE DES REQUETES RECEIVEDS */ /* PARTIE DES REQUETES RECEIVEDS */
/*********************************/ /*********************************/
@ -159,6 +178,25 @@
return $this->runQuery($query, $params); return $this->runQuery($query, $params);
} }
/**
* Supprime tous les receivedss dont l'id fait partie du tableau fourni
* @param $receiveds_ids : Tableau des id des receiveds à supprimer
* @return int : Nombre de lignes supprimées
*/
public function deleteReceivedsIn($receiveds_ids)
{
$query = "
DELETE FROM receiveds
WHERE id ";
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
$generted_in = $this->generateInFromArray($receiveds_ids);
$query .= $generted_in['QUERY'];
$params = $generted_in['PARAMS'];
return $this->runQuery($query, $params, self::ROWCOUNT);
}
/***********************************/ /***********************************/
/* PARTIE DES REQUETES DISCUSSIONS */ /* PARTIE DES REQUETES DISCUSSIONS */
/***********************************/ /***********************************/
@ -779,4 +817,51 @@
return $this->runQuery($query, $params, self::ROWCOUNT); return $this->runQuery($query, $params, self::ROWCOUNT);
} }
/******************************/
/* PARTIE DES REQUETES EVENTS */
/******************************/
/**
* Supprime tous les events dont l'id fait partie du tableau fourni
* @param $events_ids : Tableau des id des events à supprimer
* @return int : Nombre de lignes supprimées
*/
public function deleteEventsIn($events_ids)
{
$query = "
DELETE FROM events
WHERE id ";
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
$generted_in = $this->generateInFromArray($events_ids);
$query .= $generted_in['QUERY'];
$params = $generted_in['PARAMS'];
return $this->runQuery($query, $params, self::ROWCOUNT);
}
/********************************/
/* PARTIE DES REQUETES SMS STOP */
/********************************/
/**
* Supprime tous les sms_stops dont l'id fait partie du tableau fourni
* @param $sms_stops_ids : Tableau des id des sms_stops à supprimer
* @return int : Nombre de lignes supprimées
*/
public function deleteSmsStopsIn($sms_stops_ids)
{
$query = "
DELETE FROM sms_stop
WHERE id ";
//On génère la clause IN et les paramètres adaptés depuis le tableau des id
$generted_in = $this->generateInFromArray($sms_stops_ids);
$query .= $generted_in['QUERY'];
$params = $generted_in['PARAMS'];
return $this->runQuery($query, $params, self::ROWCOUNT);
}
} }

View File

@ -63,19 +63,18 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div> <div>
<div class="col-xs-6 no-padding"> <div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo $this->generateUrl('commands', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter une commande</a> <a class="btn btn-success" href="<?php echo $this->generateUrl('commands', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter une commande</a>
</div> </div>
<div class="text-right col-xs-6 no-padding"> <div class="text-right col-xs-6 no-padding">
<strong>Action groupée :</strong> <strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-commands"> <div class="btn-group action-dropdown" target="#table-commands">
<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 $this->generateUrl('commands', 'edit', [$_SESSION['csrf']]); ?>"><span class="fa fa-edit"></span> Modifier</a></li> <li><a href="<?php echo $this->generateUrl('commands', 'edit', [$_SESSION['csrf']]); ?>"><span class="fa fa-edit"></span> Modifier</a></li>
<li><a href="<?php echo $this->generateUrl('commands', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li> <li><a href="<?php echo $this->generateUrl('commands', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul> </ul>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -61,19 +61,18 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div> <div>
<div class="col-xs-6 no-padding"> <div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo $this->generateUrl('contacts', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un contact</a> <a class="btn btn-success" href="<?php echo $this->generateUrl('contacts', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un contact</a>
</div> </div>
<div class="text-right col-xs-6 no-padding"> <div class="text-right col-xs-6 no-padding">
<strong>Action groupée :</strong> <strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-contacts"> <div class="btn-group action-dropdown" target="#table-contacts">
<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 $this->generateUrl('contacts', 'edit', [$_SESSION['csrf']]); ?>"><span class="fa fa-edit"></span> Modifier</a></li> <li><a href="<?php echo $this->generateUrl('contacts', 'edit', [$_SESSION['csrf']]); ?>"><span class="fa fa-edit"></span> Modifier</a></li>
<li><a href="<?php echo $this->generateUrl('contacts', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li> <li><a href="<?php echo $this->generateUrl('contacts', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul> </ul>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -42,6 +42,7 @@
<th>Type</th> <th>Type</th>
<th>Date</th> <th>Date</th>
<th>Texte</th> <th>Texte</th>
<th>Sélectionner</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -54,6 +55,7 @@
<td><span class="fa fa-fw <?php echo internalTools::eventTypeToIcon($event['type']); ?>"></span></td> <td><span class="fa fa-fw <?php echo internalTools::eventTypeToIcon($event['type']); ?>"></span></td>
<td><?php secho($event['at']); ?></td> <td><?php secho($event['at']); ?></td>
<td><?php secho($event['text']); ?></td> <td><?php secho($event['text']); ?></td>
<td><input type="checkbox" value="<?php secho($event['id']); ?>"></td>
</tr> </tr>
<?php <?php
} }
@ -62,6 +64,15 @@
</table> </table>
</div> </div>
<nav> <nav>
<div class="text-right col-xs-12 no-padding">
<strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-events">
<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">
<li><a href="<?php echo $this->generateUrl('events', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul>
</div>
</div>
<ul class="pager"> <ul class="pager">
<?php <?php
if ($page) if ($page)
@ -83,7 +94,6 @@
?> ?>
</ul> </ul>
</nav> </nav>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -91,5 +101,21 @@
</div> </div>
</div> </div>
</div> </div>
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
{
e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target');
var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function ()
{
url += '/' + jQuery(this).val();
});
window.location = url;
});
});
</script>
<?php <?php
$incs->footer(); $incs->footer();

View File

@ -61,19 +61,18 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div> <div>
<div class="col-xs-6 no-padding"> <div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo $this->generateUrl('groups', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un groupe</a> <a class="btn btn-success" href="<?php echo $this->generateUrl('groups', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter un groupe</a>
</div> </div>
<div class="text-right col-xs-6 no-padding"> <div class="text-right col-xs-6 no-padding">
<strong>Action groupée :</strong> <strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-groups"> <div class="btn-group action-dropdown" target="#table-groups">
<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 $this->generateUrl('groups', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</a></li> <li><a href="<?php echo $this->generateUrl('groups', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</a></li>
<li><a href="<?php echo $this->generateUrl('groups', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li> <li><a href="<?php echo $this->generateUrl('groups', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul> </ul>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -53,7 +53,7 @@
</li> </li>
<li> <li>
<a href="javascript:;" data-toggle="collapse" data-target="#logs"><i class="fa fa-fw fa-file-text"></i> Logs <i class="fa fa-fw fa-caret-down"></i></a> <a href="javascript:;" data-toggle="collapse" data-target="#logs"><i class="fa fa-fw fa-file-text"></i> Logs <i class="fa fa-fw fa-caret-down"></i></a>
<ul id="logs" class="collapse <?php echo in_array($page, array('sendeds', 'receiveds', 'events')) ? 'in' : ''; ?>"> <ul id="logs" class="collapse <?php echo in_array($page, array('sendeds', 'receiveds', 'events', 'smsstop')) ? 'in' : ''; ?>">
<li <?php echo $page == 'sendeds' ? 'class="active"' : ''; ?>> <li <?php echo $page == 'sendeds' ? 'class="active"' : ''; ?>>
<a href="<?php echo $this->generateUrl('sendeds'); ?>"><i class="fa fa-fw fa-send"></i> SMS envoyés</a> <a href="<?php echo $this->generateUrl('sendeds'); ?>"><i class="fa fa-fw fa-send"></i> SMS envoyés</a>
</li> </li>

View File

@ -43,6 +43,7 @@
<th>Message</th> <th>Message</th>
<th>Date</th> <th>Date</th>
<th>Commande</th> <th>Commande</th>
<th>Sélectionner</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -56,6 +57,7 @@
<td><?php secho($received['content']); ?></td> <td><?php secho($received['content']); ?></td>
<td><?php secho($received['at']); ?></td> <td><?php secho($received['at']); ?></td>
<td><?php echo $received['is_command'] ? 'Oui' : 'Non'; ?></td> <td><?php echo $received['is_command'] ? 'Oui' : 'Non'; ?></td>
<td><input type="checkbox" value="<?php secho($received['id']); ?>"></td>
</tr> </tr>
<?php <?php
} }
@ -64,6 +66,15 @@
</table> </table>
</div> </div>
<nav> <nav>
<div class="text-right col-xs-12 no-padding">
<strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-receiveds">
<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">
<li><a href="<?php echo $this->generateUrl('receiveds', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul>
</div>
</div>
<ul class="pager"> <ul class="pager">
<?php <?php
if ($page) if ($page)
@ -93,5 +104,21 @@
</div> </div>
</div> </div>
</div> </div>
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
{
e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target');
var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function ()
{
url += '/' + jQuery(this).val();
});
window.location = url;
});
});
</script>
<?php <?php
$incs->footer(); $incs->footer();

View File

@ -43,19 +43,21 @@
<th>Message</th> <th>Message</th>
<th>Date</th> <th>Date</th>
<th>Statut</th> <th>Statut</th>
<th>Sélectionner</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach ($sendeds as $send) foreach ($sendeds as $sended)
{ {
?> ?>
<tr> <tr>
<td><?php secho($send['id']); ?></td> <td><?php secho($sended['id']); ?></td>
<td><?php secho($send['target']); ?></td> <td><?php secho($sended['target']); ?></td>
<td><?php secho($send['content']); ?></td> <td><?php secho($sended['content']); ?></td>
<td><?php secho($send['at']); ?></td> <td><?php secho($sended['at']); ?></td>
<td><?php secho($send['delivered'] ? 'Délivré' : ($send['failed'] ? 'Échoué' : 'Inconnu')); ?></td> <td><?php secho($sended['delivered'] ? 'Délivré' : ($sended['failed'] ? 'Échoué' : 'Inconnu')); ?></td>
<td><input type="checkbox" value="<?php secho($sended['id']); ?>"></td>
</tr> </tr>
<?php <?php
} }
@ -64,6 +66,15 @@
</table> </table>
</div> </div>
<nav> <nav>
<div class="text-right col-xs-12 no-padding">
<strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-sendeds">
<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">
<li><a href="<?php echo $this->generateUrl('sendeds', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul>
</div>
</div>
<ul class="pager"> <ul class="pager">
<?php <?php
if ($page) if ($page)
@ -85,7 +96,6 @@
?> ?>
</ul> </ul>
</nav> </nav>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -93,5 +103,21 @@
</div> </div>
</div> </div>
</div> </div>
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
{
e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target');
var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function ()
{
url += '/' + jQuery(this).val();
});
window.location = url;
});
});
</script>
<?php <?php
$incs->footer(); $incs->footer();

View File

@ -35,11 +35,12 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="table-events"> <div class="table-events">
<table class="table table-bordered table-hover table-striped" id="table-sms-stop"> <table class="table table-bordered table-hover table-striped" id="table-smsstop">
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<th>Numéro</th> <th>Numéro</th>
<th>Sélectionner</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -50,6 +51,7 @@
<tr> <tr>
<td><?php secho($smsStop['id']); ?></td> <td><?php secho($smsStop['id']); ?></td>
<td><?php secho($smsStop['number']); ?></td> <td><?php secho($smsStop['number']); ?></td>
<td><input type="checkbox" value="<?php secho($smsStop['id']); ?>"></td>
</tr> </tr>
<?php <?php
} }
@ -58,6 +60,15 @@
</table> </table>
</div> </div>
<nav> <nav>
<div class="text-right col-xs-12 no-padding">
<strong>Action groupée :</strong>
<div class="btn-group action-dropdown" target="#table-smsstop">
<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">
<li><a href="<?php echo $this->generateUrl('smsstop', 'delete', [$_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</a></li>
</ul>
</div>
</div>
<ul class="pager"> <ul class="pager">
<?php <?php
if ($page) if ($page)
@ -79,7 +90,6 @@
?> ?>
</ul> </ul>
</nav> </nav>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -87,5 +97,21 @@
</div> </div>
</div> </div>
</div> </div>
<script>
jQuery(document).ready(function ()
{
jQuery('.action-dropdown a').on('click', function (e)
{
e.preventDefault();
var target = jQuery(this).parents('.action-dropdown').attr('target');
var url = jQuery(this).attr('href');
jQuery(target).find('input:checked').each(function ()
{
url += '/' + jQuery(this).val();
});
window.location = url;
});
});
</script>
<?php <?php
$incs->footer(); $incs->footer();