ajoute une fonction d'envoi de SMS à tout le répertoire

This commit is contained in:
Romain Guerrero 2016-03-24 14:03:15 +01:00
parent a03787bc53
commit 5007156562
2 changed files with 26 additions and 3 deletions

View file

@ -146,6 +146,7 @@
$numbers = (isset($_POST['numbers'])) ? $_POST['numbers'] : array(); $numbers = (isset($_POST['numbers'])) ? $_POST['numbers'] : array();
$contacts = (isset($_POST['contacts'])) ? $_POST['contacts'] : array(); $contacts = (isset($_POST['contacts'])) ? $_POST['contacts'] : array();
$groups = (isset($_POST['groups'])) ? $_POST['groups'] : array(); $groups = (isset($_POST['groups'])) ? $_POST['groups'] : array();
$allContacts = (isset($_POST['all-contacts'])) ? $_POST['all-contacts'] : false;
//Si pas de contenu dans le SMS //Si pas de contenu dans le SMS
if (!$content) if (!$content)
@ -159,7 +160,7 @@
} }
//Si pas numéros, contacts, ou groupes cibles //Si pas numéros, contacts, ou groupes cibles
if (!$numbers && !$contacts && !$groups) if (!$numbers && !$contacts && !$groups && !$allContacts)
{ {
if (!$api) if (!$api)
{ {
@ -215,6 +216,13 @@
} }
} }
if ($allContacts) {
$contacts = $db->getFromTableWhere('contacts');
foreach ($contacts as $key => $contact) {
$contacts[$key] = $contact['id'];
}
}
foreach ($contacts as $id_contact) foreach ($contacts as $id_contact)
{ {
if (!$db->insertIntoTable('scheduleds_contacts', ['id_scheduled' => $id_scheduled, 'id_contact' => $id_contact])) if (!$db->insertIntoTable('scheduleds_contacts', ['id_scheduled' => $id_scheduled, 'id_contact' => $id_contact]))

View file

@ -57,6 +57,11 @@
<div class="add-number-button fa fa-plus-circle"></div> <div class="add-number-button fa fa-plus-circle"></div>
</div> </div>
</div> </div>
<div class="checkbox">
<label>
<input type="checkbox" id="all-contacts" name="all-contacts" value=1> <strong>Envoyer à tout le répertoire</strong>
</label>
</div>
<div class="form-group"> <div class="form-group">
<label>Contacts cibles</label> <label>Contacts cibles</label>
<input class="add-contacts form-control" name="contacts[]"/> <input class="add-contacts form-control" name="contacts[]"/>
@ -100,7 +105,7 @@
// Affiche plus d'infos que le nom du contact si on est en mode infos contacts // Affiche plus d'infos que le nom du contact si on est en mode infos contacts
jQuery('.add-contacts').each(function() jQuery('.add-contacts').each(function()
{ {
jQuery(this).magicSuggest({ magicContacts = jQuery(this).magicSuggest({
data: '<?php echo $this->generateUrl('contacts', 'jsonGetContacts'); ?>', data: '<?php echo $this->generateUrl('contacts', 'jsonGetContacts'); ?>',
valueField: '<?php echo RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS ? 'contacts.' : ''; ?>id', valueField: '<?php echo RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS ? 'contacts.' : ''; ?>id',
displayField: '<?php echo RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS ? 'contacts.' : ''; ?>name', displayField: '<?php echo RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS ? 'contacts.' : ''; ?>name',
@ -121,7 +126,7 @@
jQuery('.add-groups').each(function() jQuery('.add-groups').each(function()
{ {
jQuery(this).magicSuggest({ magicGroups = jQuery(this).magicSuggest({
data: '<?php echo $this->generateUrl('groups', 'jsonGetGroups'); ?>', data: '<?php echo $this->generateUrl('groups', 'jsonGetGroups'); ?>',
valueField: 'id', valueField: 'id',
displayField: 'name', displayField: 'name',
@ -181,6 +186,16 @@
this.submit(); this.submit();
}); });
$("#all-contacts").on('change', function() {
if ($(this).is(':checked')) {
magicContacts.disable();
magicGroups.disable();
} else {
magicContacts.enable();
magicGroups.enable();
}
})
}); });
</script> </script>
<?php <?php