move some fonts to dir with 's' because some external developper is an incompetent motherfucker, update all intl number, because they also are motherfuckers

This commit is contained in:
osaajani 2019-11-10 16:53:47 +01:00
parent 3934dba4f9
commit 29cd7edd5d
13 changed files with 72 additions and 118 deletions

View File

@ -1,2 +1,2 @@
RewriteEngine on
RewriteRule !\.(js|ico|ICO|gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|css|woff|ttf|wav|ogg|mp3)$ index.php
RewriteRule !\.(js|ico|ICO|gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|css|woff|woff2|ttf|wav|ogg|mp3)$ index.php

View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

View File

@ -98,8 +98,15 @@ namespace controllers\internals;
*
* @return mixed bool|int : false si echec, sinon l'id du nouveau scheduled inséré
*/
public function create($scheduled, $numbers = [], $contacts_ids = [], $groups_ids = [])
public function create($at, $text, $flash = false, $progress = false, $numbers = [], $contacts_ids = [], $groups_ids = [])
{
$scheduled = [
'at' => $at,
'text' => $text,
'flash' => $flash,
'progress' => $progress,
];
if (!$id_scheduled = $this->model_scheduled->insert($scheduled))
{
$date = date('Y-m-d H:i:s');
@ -134,7 +141,7 @@ namespace controllers\internals;
* @param array $contacts_ids : Les ids des contact auquels envoyer le scheduled
* @param array $groups_ids : Les ids des group auxquels envoyer le scheduled
* @param mixed $id
* @param mixed $content
* @param mixed $text
* @param mixed $at
* @param mixed $contact_ids
* @param mixed $flash
@ -142,11 +149,11 @@ namespace controllers\internals;
*
* @return int : le nombre de ligne modifiées
*/
public function update($id, $content, $at, $numbers = [], $contact_ids = [], $groups_ids = [], $flash = false, $progress = false)
public function update($id, $text, $at, $numbers = [], $contact_ids = [], $groups_ids = [], $flash = false, $progress = false)
{
$scheduled = [
'at' => $at,
'content' => $content,
'text' => $text,
'flash' => $flash,
'progress' => $progress,
];
@ -157,19 +164,19 @@ namespace controllers\internals;
$this->model_scheduled->delete_scheduled_contacts($id);
$this->model_scheduled->delete_scheduled_groups($id);
foreach ($scheduled['number'] as $number)
foreach ($numbers as $number)
{
$this->model_scheduled->insert_scheduled_number($scheduled['scheduled']['id'], $number);
$this->model_scheduled->insert_scheduled_number($id, $number);
}
foreach ($scheduled['contact_ids'] as $contact_id)
foreach ($contact_ids as $contact_id)
{
$this->model_scheduled->insert_scheduled_contact($scheduled['scheduled']['id'], $contact_id);
$this->model_scheduled->insert_scheduled_contact($id, $contact_id);
}
foreach ($scheduled['group_ids'] as $group_id)
foreach ($groups_ids as $group_id)
{
$this->model_scheduled->insert_scheduled_group($scheduled['scheduled']['id'], $group_id);
$this->model_scheduled->insert_scheduled_group($id, $group_id);
}
return (bool) $success;

View File

@ -142,27 +142,24 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\FlashMessage\FlashMessage::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
$date = $_POST['date'] ?? false;
$content = $_POST['content'] ?? false;
$at = $_POST['at'] ?? false;
$text = $_POST['text'] ?? false;
$numbers = $_POST['numbers'] ?? [];
$contacts = $_POST['contacts'] ?? [];
$groups = $_POST['groups'] ?? [];
if (!$content)
if (empty($text))
{
\FlashMessage\FlashMessage::push('danger', 'Vous ne pouvez pas créer un Sms sans message.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i'))
if (!\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i'))
{
\FlashMessage\FlashMessage::push('danger', 'Vous devez fournir une date valide.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
@ -173,36 +170,28 @@ namespace controllers\publics;
if (!$number)
{
unset($numbers[$key]);
continue;
}
$numbers[$key] = $number;
}
if (!$numbers && !$contacts && !$groups)
{
\FlashMessage\FlashMessage::push('danger', 'Vous devez renseigner au moins un destinataire pour le Sms.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
$scheduled = [
'at' => $date,
'content' => $content,
'flash' => false,
'progress' => false,
];
if (!$scheduled_id = $this->internal_scheduled->create($scheduled, $numbers, $contacts, $groups))
$scheduled_id = $this->internal_scheduled->create($at, $text, false, false, $numbers, $contacts, $groups);
if (!$scheduled_id)
{
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer le Sms.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
\FlashMessage\FlashMessage::push('success', 'Le Sms a bien été créé pour le '.$date.'.');
\FlashMessage\FlashMessage::push('success', 'Le Sms a bien été créé pour le ' . $at . '.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
@ -229,23 +218,21 @@ namespace controllers\publics;
foreach ($scheduleds as $id_scheduled => $scheduled)
{
$date = $scheduled['date'] ?? false;
$content = $scheduled['content'] ?? false;
$at = $scheduled['at'] ?? false;
$text = $scheduled['text'] ?? false;
$numbers = $scheduled['numbers'] ?? [];
$contacts = $scheduled['contacts'] ?? [];
$groups = $scheduled['groups'] ?? [];
if (!$content)
if (empty($text))
{
$all_update_ok = false;
continue;
}
if (!\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i'))
if (!\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i'))
{
$all_update_ok = false;
continue;
}
@ -256,7 +243,6 @@ namespace controllers\publics;
if (!$number)
{
unset($numbers[$key]);
continue;
}
@ -266,15 +252,13 @@ namespace controllers\publics;
if (!$numbers && !$contacts && !$groups)
{
$all_update_ok = false;
continue;
}
$success = $this->internal_scheduled->update($id_scheduled, $content, $date, $numbers, $contacts, $groups);
$success = $this->internal_scheduled->update($id_scheduled, $text, $at, $numbers, $contacts, $groups);
if (!$success)
{
$all_update_ok = false;
continue;
}
}
@ -282,12 +266,10 @@ namespace controllers\publics;
if (!$all_update_ok)
{
\FlashMessage\FlashMessage::push('danger', 'Certains SMS n\'ont pas pu êtres mis à jour.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
\FlashMessage\FlashMessage::push('success', 'Tous les SMS ont été mis à jour.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
}

View File

@ -48,8 +48,7 @@
<div class="form-group">
<label>Numéro de téléphone du contact</label>
<div class="form-group">
<input name="number" class="form-control" type="tel" id="phone-international-input">
<input name="number" type="hidden" id="phone-hidden-input" required>
<input name="" class="form-control" type="tel" id="phone-international-input">
</div>
</div>
<a class="btn btn-danger" href="<?php echo \descartes\Router::url('Contact', 'list'); ?>">Annuler</a>
@ -67,18 +66,12 @@
{
var number_input = jQuery('#phone-international-input')[0];
var iti_number_input = window.intlTelInput(number_input, {
hiddenInput: 'number',
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
utilsScript: '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
});
jQuery('form').on('submit', function(e)
{
e.preventDefault();
jQuery('#phone-hidden-input').val(iti_number_input.getNumber())
this.submit();
});
});
</script>
<?php

View File

@ -51,7 +51,6 @@
<label>Numéro de téléphone du contact</label>
<div class="form-group">
<input name="" class="form-control phone-international-input" type="tel" contact-id="<?php $this->s($contact['id']); ?>" value="<?php $this->s($contact['number']); ?>">
<input name="contacts[<?php $this->s($contact['id']); ?>][number]" type="hidden" id="phone-hidden-input-<?php $this->s($contact['id']); ?>" required>
</div>
</div>
<hr/>
@ -72,19 +71,14 @@
jQuery('.phone-international-input').each(function()
{
var number_input = this;
var hidden_input_name = 'contacts[' + jQuery(number_input).attr('contact-id') + '][number]';
var iti_number_input = window.intlTelInput(number_input, {
hiddenInput: hidden_input_name,
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
utilsScript: '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
});
jQuery('form').on('submit', function(e)
{
e.preventDefault();
jQuery('#phone-hidden-input-' + jQuery(number_input).attr('contact-id')).val(iti_number_input.getNumber())
this.submit();
});
});
});
</script>

View File

@ -40,11 +40,11 @@
<form action="<?php echo \descartes\Router::url('Scheduled', 'create', ['csrf' => $_SESSION['csrf']]);?>" method="POST">
<div class="form-group">
<label>Texte du SMS</label>
<textarea name="content" class="form-control" required></textarea>
<textarea name="text" class="form-control" required></textarea>
</div>
<div class="form-group">
<label>Date d'envoi du SMS</label>
<input name="date" class="form-control form-datetime" type="text" value="<?php $this->s($now); ?>" readonly>
<input name="at" class="form-control form-datetime" type="text" value="<?php $this->s($now); ?>" readonly>
</div>
<div class="form-group">
<label>Numéros cibles</label>
@ -52,7 +52,6 @@
<div class="form-group scheduleds-number-groupe">
<input name="" class="form-control phone-international-input" type="tel" >
<span class="remove-scheduleds-number fa fa-times"></span>
<input name="numbers[]" type="hidden" class="phone-hidden-input">
</div>
<div class="add-number-button fa fa-plus-circle"></div>
</div>
@ -123,16 +122,19 @@
//intlTelInput
jQuery('body').on('click', '.add-number-button', function(e)
{
{
var random_id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
var newScheduledsNumberGroupe = '' +
'<div class="form-group scheduleds-number-groupe">' +
'<input name="" class="form-control phone-international-input" type="tel" >' +
'<input name="" class="form-control phone-international-input" type="tel" id="' + random_id + '">' +
'<span class="remove-scheduleds-number fa fa-times"></span>' +
'<input name="numbers[]" type="hidden" class="phone-hidden-input">' +
'</div>';
var number_input = jQuery(this).before(newScheduledsNumberGroupe);
jQuery(this).before(newScheduledsNumberGroupe);
var number_input = jQuery('#' + random_id)[0];
var iti_number_input = window.intlTelInput(number_input, {
hiddenInput: 'numbers[]',
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
@ -147,6 +149,7 @@
var number_input = jQuery('.phone-international-input')[0];
var iti_number_input = window.intlTelInput(number_input, {
hiddenInput: 'numbers[]',
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
@ -157,19 +160,6 @@
'number_input': number_input,
'iti_number_input': iti_number_input,
});
jQuery('form').on('submit', function(e)
{
e.preventDefault();
for (i = 0; i < number_inputs.length; i++)
{
var container = jQuery(number_inputs[i].number_input).parents('.scheduleds-number-groupe');
container.find('.phone-hidden-input').val(number_inputs[i][iti_number_input].getNumber());
}
this.submit();
});
});
</script>
<?php

View File

@ -41,20 +41,19 @@
<?php foreach ($scheduleds as $scheduled) { ?>
<div class="form-group">
<label>Texte du SMS</label>
<textarea name="scheduleds[<?php $this->s($scheduled['id']); ?>][content]" class="form-control" required><?php $this->s($scheduled['content'], true); ?></textarea>
<textarea name="scheduleds[<?php $this->s($scheduled['id']); ?>][text]" class="form-control" required><?php $this->s($scheduled['text'], true); ?></textarea>
</div>
<div class="form-group">
<label>Date d'envoi du SMS</label>
<input name="scheduleds[<?php $this->s($scheduled['id']); ?>][date]" class="form-control form-datetime" type="text" value="<?php $this->s($scheduled['at']); ?>" readonly>
<input name="scheduleds[<?php $this->s($scheduled['id']); ?>][at]" class="form-control form-datetime" type="text" value="<?php $this->s($scheduled['at']); ?>" readonly>
</div>
<div class="form-group">
<label>Numéros cibles</label>
<div class="form-group scheduleds-number-groupe-container" scheduled-id="<?php $this->s($scheduled['id']); ?>" >
<?php foreach ($scheduled['numbers'] as $number) { ?>
<div class="form-group scheduleds-number-groupe">
<input name="" class="form-control phone-international-input" type="tel" value="<?php $this->s($number); ?>">
<input name="" class="form-control phone-international-input" type="tel" value="<?php $this->s($number); ?>" scheduled-id="<?php $this->s($scheduled['id']); ?>">
<span class="remove-scheduleds-number fa fa-times"></span>
<input name="scheduleds[<?php $this->s($scheduled['id']); ?>][numbers][]" type="hidden" class="phone-hidden-input">
</div>
<?php } ?>
<div class="add-number-button fa fa-plus-circle"></div>
@ -66,7 +65,7 @@
</div>
<div class="form-group">
<label>Groupes cibles</label>
<input class="add-groupes form-control" name="scheduleds[<?php $this->s($scheduled['id']); ?>][groupes][]" value="<?php $this->s(json_encode($scheduled['groupes'])); ?>" />
<input class="add-groupes form-control" name="scheduleds[<?php $this->s($scheduled['id']); ?>][groups][]" value="<?php $this->s(json_encode($scheduled['groups'])); ?>" />
</div>
<?php if (RASPISMS_SETTINGS_SMS_FLASH) { ?>
<div class="form-group">
@ -117,60 +116,49 @@
displayField: 'name',
});
});
jQuery('.phone-international-input').intlTelInput({
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
utilsScript: '<?php echo HTTP_PWD; ?>/js/intlTelInput/lib/libphonenumber/utils.js'
});
jQuery('body').on('click', '.remove-scheduleds-number', function(e)
jQuery('body').on('click', '.remove-scheduleds-number', function(e)
{
jQuery(this).parents('.scheduleds-number-groupe').remove();
});
jQuery('.phone-international-input').each(function ()
{
var hidden_input_name = 'scheduleds[' + jQuery(this).attr('scheduled-id') + '][numbers][]';
window.intlTelInput(this, {
hiddenInput: hidden_input_name,
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
utilsScript: '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
});
});
jQuery('body').on('click', '.add-number-button', function(e)
{
{
var random_id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
var scheduledId = jQuery(this).parents('.scheduleds-number-groupe-container').attr('scheduled-id');
var newScheduledsNumberGroupe = '' +
'<div class="form-group scheduleds-number-groupe">' +
'<input name="" class="form-control phone-international-input" type="tel" >' +
'<input name="" class="form-control phone-international-input" type="tel" scheduled-id="' + scheduledId + '" id="' + random_id + '">' +
'<span class="remove-scheduleds-number fa fa-times"></span>' +
'<input name="scheduleds[' + scheduledId + '][numbers][]" type="hidden" class="phone-hidden-input">' +
'</div>';
jQuery(this).before(newScheduledsNumberGroupe);
jQuery('.phone-international-input').intlTelInput({
var hidden_input_name = 'scheduleds[' + scheduledId + '][numbers][]';
var phone_input = jQuery('#' + random_id)[0];
window.intlTelInput(phone_input, {
hiddenInput: hidden_input_name,
defaultCountry: '<?php $this->s(RASPISMS_SETTINGS_DEFAULT_PHONE_COUNTRY); ?>',
preferredCountries: <?php $this->s(json_encode(explode(',', RASPISMS_SETTINGS_PREFERRED_PHONE_COUNTRY)), false, false); ?>,
nationalMode: true,
utilsScript: '<?php echo HTTP_PWD; ?>/js/intlTelInput/lib/libphonenumber/utils.js'
utilsScript: '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
});
});
jQuery('.form-datetime').datetimepicker(
{
format: 'yyyy-mm-dd hh:ii:ss',
autoclose: true,
minuteStep: 1,
language: 'fr'
});
jQuery('form').on('submit', function(e)
{
e.preventDefault();
jQuery('.phone-international-input').each(function(key, value)
{
var container = jQuery(this).parents('.scheduleds-number-groupe');
container.find('.phone-hidden-input').val(jQuery(this).intlTelInput("getNumber"));
});
this.submit();
});
});
</script>
<?php

View File

@ -53,7 +53,7 @@
<tr>
<td><?php $this->s($scheduled['id']); ?></td>
<td><?php $this->s($scheduled['at']); ?></td>
<td><?php $this->s($scheduled['content']); ?></td>
<td><?php $this->s($scheduled['text']); ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($scheduled['id']); ?>"></td>
</tr>
<?php } ?>