2019-10-29 14:57:13 +01:00
< ? php
//Template dashboard
$this -> render ( 'incs/head' , [ 'title' => 'Scheduleds - Add' ])
?>
< div id = " wrapper " >
< ? php
$this -> render ( 'incs/nav' , [ 'page' => 'scheduleds' ])
?>
< div id = " page-wrapper " >
< div class = " container-fluid " >
<!-- Page Heading -->
< div class = " row " >
< div class = " col-lg-12 " >
< h1 class = " page-header " >
Nouveau SMS programmé
</ h1 >
< ol class = " breadcrumb " >
< li >
2019-11-10 00:27:42 +01:00
< i class = " fa fa-dashboard " ></ i > < a href = " <?php echo \ descartes \R outer::url('Dashboard', 'show'); ?> " > Dashboard </ a >
2019-10-29 14:57:13 +01:00
</ li >
< li >
2019-12-20 18:51:13 +01:00
< i class = " fa fa-send " ></ i > < a href = " <?php echo \ descartes \R outer::url('Scheduled', 'list'); ?> " > Scheduleds </ a >
2019-10-29 14:57:13 +01:00
</ li >
< li class = " active " >
< i class = " fa fa-plus " ></ i > Nouveau
</ li >
</ ol >
</ div >
</ div >
<!-- /. row -->
< div class = " row " >
< div class = " col-lg-12 " >
2020-03-27 05:09:04 +01:00
< ? php if ( ! count ( $phones )) { ?>
< div class = " alert alert-danger " > Pour pouvoir envoyez un SMS vous devez d 'abord <a href="<?= \descartes\Router::url(' Phone ', ' add ' ); ?> ">créer au moins un téléphone.</a></div>
< ? php } ?>
2019-10-29 14:57:13 +01:00
< div class = " panel panel-default " >
< div class = " panel-heading " >
2019-12-20 18:51:13 +01:00
< h3 class = " panel-title " >< i class = " fa fa-send fa-fw " ></ i > Création d ' un nouveau SMS </ h3 >
2019-10-29 14:57:13 +01:00
</ div >
< div class = " panel-body " >
2019-12-04 03:04:45 +01:00
< form action = " <?php echo \ descartes \R outer::url('Scheduled', 'create', ['csrf' => $_SESSION['csrf'] ]);?> " method = " POST " enctype = " multipart/form-data " >
2019-10-29 14:57:13 +01:00
< div class = " form-group " >
2019-11-20 02:45:00 +01:00
< label > Texte du SMS </ label >
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'templating' ]) { ?>
< p class = " italic small help description-scheduled-text " >
2021-06-15 01:49:47 +02:00
Vous pouvez utilisez des fonctionnalités de templating pour indiquer des valeures génériques qui seront remplacées par les données du contact au moment de l 'envoie. Pour plus d' information , consultez la documentation sur < a href = " https://documentation.raspisms.fr/users/templating/overview.html " target = " _blank " > l ' utilisation des templates .</ a >< br />
Vous pouvez obtenir une prévisualisation du résultat pour un contact , ainsi qu ' une estimation du nombre de crédits qui seront utilisés par SMS , en cliquant sur le boutton < b > " Prévisualiser " </ b >.
2019-11-20 02:45:00 +01:00
</ p >
< ? php } ?>
2022-09-26 17:17:41 +02:00
< textarea name = " text " class = " form-control " required maxlength = " <?= \ models \ Scheduled::SMS_LENGTH_LIMIT; ?> " >< ? php $this -> s ( $_SESSION [ 'previous_http_post' ][ 'text' ] ? ? '' ) ?> </textarea>
2019-11-20 02:45:00 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'templating' ]) { ?>
< div class = " scheduled-preview-container " >
< label > Prévisualiser pour : </ label >
< select name = " " class = " form-control " >
< ? php foreach ( $contacts as $contact ) { ?>
< option value = " <?php $this->s ( $contact['id'] ); ?> " >< ? php $this -> s ( $contact [ 'name' ]); ?> </option>
< ? php } ?>
</ select >
< a class = " btn btn-info preview-button " href = " # " > Prévisualiser </ a >
</ div >
< ? php } ?>
</ div >
2019-12-04 03:04:45 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'mms' ] ? ? false ) { ?>
2021-03-22 01:29:06 +01:00
< div class = " form-group scheduled-media-group " >
< label > Ajouter un média au SMS </ label >
2019-12-04 03:04:45 +01:00
< p class = " italic small help description-scheduled-media " >
2021-06-15 01:49:47 +02:00
L 'ajout d' un média nécessite un téléphone supportant l 'envoi de MMS. Pour plus d' information , consultez la documentation sur < a href = " https://documentation.raspisms.fr/users/mms/overview.html " target = " _blank " > l ' utilisation des MMS .</ a >
2019-12-04 03:04:45 +01:00
</ p >
2021-03-22 01:29:06 +01:00
< div class = " form-group " >
< input class = " " name = " medias[] " value = " " type = " file " multiple />
</ div >
2019-12-04 03:04:45 +01:00
</ div >
< ? php } ?>
2019-11-20 02:45:00 +01:00
< div class = " form-group " >
< label > Date d ' envoi du SMS </ label >
2020-08-17 21:05:01 +02:00
< input name = " at " class = " form-control form-datetime auto-width " type = " text " readonly value = " <?php $this->s ( $_SESSION['previous_http_post'] ['at'] ?? $now ) ?> " >
2019-11-20 02:45:00 +01:00
</ div >
< div class = " form-group " >
< label > Numéros cibles </ label >
2022-03-15 02:24:28 +01:00
< div class = " form-group scheduleds-number-groupe-container container-fluid " >
< div class = " row scheduleds-number-groupe " >
< ? php $random_id = uniqid (); ?>
< div class = " col-xs-4 " >
< label > Numéro cible : </ label >< br />
< input name = " " data - uid = " <?= $random_id ?> " class = " form-control phone-international-input " type = " tel " >
</ div >
< div class = " scheduleds-number-data-container col-xs-8 " >
< label > Données associées : </ label >
< div class = " form-group " data - uid = " <?= $random_id ?> " >
< input name = " " class = " form-control scheduled-number-data-name " type = " text " placeholder = " Nom de la donnée " pattern = " [a-zA-Z0-9_]* " >
:
< input name = " " class = " form-control scheduled-number-data-value " type = " text " placeholder = " Valeur de la donnée " >
</ div >
</ div >
2019-11-20 02:45:00 +01:00
</ div >
2022-03-15 02:24:28 +01:00
< div class = " text-center " >< div class = " add-number-button fa fa-plus-circle " ></ div ></ div >
2019-11-20 02:45:00 +01:00
</ div >
</ div >
< div class = " form-group " >
< label > Contacts cibles </ label >
2020-08-17 21:05:01 +02:00
< input class = " add-contacts form-control " name = " contacts[] " value = " <?php $this->s (json_encode( $_SESSION['previous_http_post'] ['contacts'] ?? $prefilled_contacts )) ?> " />
2019-11-20 02:45:00 +01:00
</ div >
< div class = " form-group " >
< label > Groupes cibles </ label >
2020-08-17 21:05:01 +02:00
< input class = " add-groupes form-control " name = " groups[] " value = " <?php $this->s (json_encode( $_SESSION['previous_http_post'] ['groups'] ?? $prefilled_groups )) ?> " />
2019-11-20 02:45:00 +01:00
</ div >
2019-11-28 01:55:11 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'conditional_group' ] ? ? false ) { ?>
< div class = " form-group " >
< label > Groupes conditionnels cibles </ label >
2020-08-17 21:05:01 +02:00
< input class = " add-conditional-groups form-control " name = " conditional_groups[] " value = " <?php $this->s (json_encode( $_SESSION['previous_http_post'] ['conditional_groups'] ?? $prefilled_conditional_groups )) ?> " />
2019-11-28 01:55:11 +01:00
</ div >
< ? php } ?>
2022-03-15 02:24:28 +01:00
< div class = " form-group scheduled-media-group " >
< label > Ajouter un fichier CSV de destinataires </ label >
< p class = " italic small help description-scheduled-csv " >
Le SMS sera envoyé à tous les numéros inclus dans le fichier CSV . Assurez - vous que le fichier CSV respecte le format indiqué dans la documentation sur < a href = " https://documentation.raspisms.fr/users/sms/csv.html " target = " _blank " > l ' envoi de SMS à un fichier CSV .</ a >
</ p >
< div class = " form-group " >
< input class = " " name = " csv " value = " " type = " file " multiple />
</ div >
</ div >
2019-11-20 02:45:00 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'sms_flash' ]) { ?>
2019-11-12 17:37:20 +01:00
< div class = " form-group " >
2019-11-20 02:45:00 +01:00
< label > Envoyer comme un SMS Flash : </ label >
< div class = " form-group " >
2020-08-17 21:05:01 +02:00
< input name = " flash " type = " radio " value = " 1 " required < ? = ( isset ( $_SESSION [ 'previous_http_post' ][ 'flash' ]) && ( bool ) $_SESSION [ 'previous_http_post' ][ 'flash' ]) ? 'checked' : '' ; ?> /> Oui
< input name = " flash " type = " radio " value = " 0 " required < ? = ( ! isset ( $_SESSION [ 'previous_http_post' ][ 'flash' ]) || ( isset ( $_SESSION [ 'previous_http_post' ][ 'flash' ]) && ! ( bool ) $_SESSION [ 'previous_http_post' ][ 'flash' ])) ? 'checked' : '' ; ?> /> Non
2019-11-20 02:45:00 +01:00
</ div >
2019-11-12 17:37:20 +01:00
</ div >
2019-11-20 02:45:00 +01:00
< ? php } ?>
2023-02-24 16:29:10 +01:00
< div class = " form-group " >
< label > Tag à associé à la campagne </ label >
< p class = " italic small help " >
Vous pouvez renseigner une chaine de caractère qui sera associée à tous les SMS envoyés . Utile pour associer un identifiant interne à vos systèmes . Laissez vide si vous ne voulez pas associé de chaine .
</ p >
< div class = " form-group " >
< input name = " tag " class = " form-control " type = " text " placeholder = " Ex: region-001 " maxlength = " 255 " >
</ div >
</ div >
2023-02-20 03:17:53 +01:00
< ? php if ( count ( $phones ) || count ( $phone_groups )) { ?>
2020-03-27 05:09:04 +01:00
< div class = " form-group " >
< label > Numéro à employer : </ label >
< select name = " id_phone " class = " form-control " >
< option value = " " > N ' importe lequel </ option >
2023-02-20 03:17:53 +01:00
< optgroup label = " Téléphones " >
< ? php foreach ( $phones as $phone ) { ?>
< option value = " phone_<?php $this->s ( $phone['id'] ); ?> " < ? = ( $_SESSION [ 'previous_http_post' ][ 'id_phone' ] ? ? '' ) == ( 'phone_' . $phone [ 'id' ]) ? 'selected' : '' ?> ><?php $this->s($phone['name']); ?></option>
< ? php } ?>
</ optgroup >
< optgroup label = " Groupes de téléphones " >
< ? php foreach ( $phone_groups as $phone_group ) { ?>
< option value = " phonegroup_<?php $this->s ( $phone_group['id'] ); ?> " < ? = ( $_SESSION [ 'previous_http_post' ][ 'id_phone' ] ? ? '' ) == ( 'phonegroup_' . $phone_group [ 'id' ]) ? 'selected' : '' ?> ><?php $this->s($phone_group['name']); ?></option>
< ? php } ?>
</ optgroup >
2020-03-27 05:09:04 +01:00
</ select >
</ div >
< ? php } ?>
2019-11-20 02:45:00 +01:00
< a class = " btn btn-danger " href = " <?php echo \ descartes \R outer::url('Scheduled', 'list'); ?> " > Annuler </ a >
< input type = " submit " class = " btn btn-success " value = " Enregistrer le SMS " />
</ form >
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >
2019-10-29 14:57:13 +01:00
</ div >
2019-11-20 02:45:00 +01:00
< div class = " modal fade " tabindex = " -1 " id = " scheduled-preview-text-modal " >
< div class = " modal-dialog modal-lg " >
< div class = " modal-content " >
< div class = " modal-header " >
< button type = " button " class = " close " data - dismiss = " modal " aria - label = " Close " >< span aria - hidden = " true " >& times ; </ span ></ button >
< h4 class = " modal-title " > Prévisualisation du message </ h4 >
</ div >
< div class = " modal-body " >
< pre ></ pre >
2021-06-15 01:49:47 +02:00
< p class = " credit-estimation-container bold " >
Ce message devrait coûter < span class = " credit-estimation-value " ></ span > crédits par destinataire .
</ p >
2019-11-20 02:45:00 +01:00
</ div >
< div class = " modal-footer " >
< button type = " button " class = " btn btn-default " data - dismiss = " modal " > Close </ button >
</ div >
</ div >
</ div >
</ div >
2019-10-29 14:57:13 +01:00
< script >
jQuery ( document ) . ready ( function ()
2019-11-10 15:47:28 +01:00
{
var number_inputs = [];
2022-03-15 02:24:28 +01:00
toto = number_inputs ;
2019-11-10 15:47:28 +01:00
2019-10-29 14:57:13 +01:00
jQuery ( '.add-contacts' ) . each ( function ()
{
jQuery ( this ) . magicSuggest ({
2019-11-07 17:52:33 +01:00
data : '<?php echo \descartes\Router::url(' Contact ', ' json_list '); ?>' ,
2019-10-29 14:57:13 +01:00
valueField : 'id' ,
displayField : 'name' ,
2020-09-02 00:59:45 +02:00
maxSelection : null ,
2019-10-29 14:57:13 +01:00
});
});
jQuery ( '.add-groupes' ) . each ( function ()
{
jQuery ( this ) . magicSuggest ({
2019-11-09 03:35:12 +01:00
data : '<?php echo \descartes\Router::url(' Group ', ' json_list '); ?>' ,
2019-10-29 14:57:13 +01:00
valueField : 'id' ,
displayField : 'name' ,
2020-09-02 00:59:45 +02:00
maxSelection : null ,
2019-10-29 14:57:13 +01:00
});
});
2019-11-10 15:47:28 +01:00
2019-11-28 01:55:11 +01:00
jQuery ( '.add-conditional-groups' ) . each ( function ()
{
jQuery ( this ) . magicSuggest ({
data : '<?php echo \descartes\Router::url(' ConditionalGroup ', ' json_list '); ?>' ,
valueField : 'id' ,
displayField : 'name' ,
2020-09-02 00:59:45 +02:00
maxSelection : null ,
2019-11-28 01:55:11 +01:00
});
});
2019-11-10 15:47:28 +01:00
jQuery ( 'body' ) . on ( 'click' , '.remove-scheduleds-number' , function ( e )
{
jQuery ( this ) . parents ( '.scheduleds-number-groupe' ) . remove ();
2019-10-29 14:57:13 +01:00
});
2019-11-10 15:47:28 +01:00
jQuery ( '.form-datetime' ) . datetimepicker (
2019-10-29 14:57:13 +01:00
{
2019-11-10 15:47:28 +01:00
format : 'yyyy-mm-dd hh:ii:ss' ,
autoclose : true ,
minuteStep : 1 ,
language : 'fr'
2019-10-29 14:57:13 +01:00
});
2019-11-10 15:47:28 +01:00
//intlTelInput
2019-10-29 14:57:13 +01:00
jQuery ( 'body' ) . on ( 'click' , '.add-number-button' , function ( e )
2019-11-10 16:53:47 +01:00
{
var random_id = Math . random () . toString ( 36 ) . substring ( 2 , 15 ) + Math . random () . toString ( 36 ) . substring ( 2 , 15 );
2019-10-29 14:57:13 +01:00
var newScheduledsNumberGroupe = '' +
2022-03-15 02:24:28 +01:00
'<div class="row scheduleds-number-groupe">' +
'<div class="col-xs-4">' +
'<label>Numéro cible : </label><br/>' +
'<input id="' + random_id + '" name="" class="form-control phone-international-input" type="tel" >' +
'</div>' +
'<div class="scheduleds-number-data-container col-xs-8">' +
'<label>Données associées : </label>' +
'<div class="form-group" data-uid="' + random_id + '">' +
'<input name="" class="form-control scheduled-number-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">' +
' : ' +
'<input name="" class="form-control scheduled-number-data-value" type="text" placeholder="Valeur de la donnée">' +
'</div>' +
'</div>' +
'<a href="#" class="scheduleds-number-groupe-remove"><span class="fa fa-times"></span></a>' +
'</div>' ;
2019-10-29 14:57:13 +01:00
2022-03-15 02:24:28 +01:00
jQuery ( this ) . parent ( 'div' ) . before ( newScheduledsNumberGroupe );
2019-11-10 16:53:47 +01:00
var number_input = jQuery ( '#' + random_id )[ 0 ];
2019-11-10 15:47:28 +01:00
var iti_number_input = window . intlTelInput ( number_input , {
2022-03-15 02:24:28 +01:00
hiddenInput : 'numbers[' + random_id + '][number]' ,
2019-11-11 04:05:26 +01:00
defaultCountry : '<?php $this->s($_SESSION[' user '][' settings '][' default_phone_country ']); ?>' ,
preferredCountries : < ? php $this -> s ( json_encode ( explode ( ',' , $_SESSION [ 'user' ][ 'settings' ][ 'preferred_phone_country' ])), false , false ); ?> ,
2019-12-04 03:04:45 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'authorized_phone_country' ] ? ? false ) { ?>
onlyCountries : < ? php $this -> s ( json_encode ( explode ( ',' , $_SESSION [ 'user' ][ 'settings' ][ 'authorized_phone_country' ])), false , false ); ?> ,
< ? php } ?>
2019-10-29 14:57:13 +01:00
nationalMode : true ,
2019-11-10 15:47:28 +01:00
utilsScript : '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
});
2019-10-29 14:57:13 +01:00
2019-11-10 15:47:28 +01:00
number_inputs . push ({
'number_input' : number_input ,
'iti_number_input' : iti_number_input ,
});
});
2019-10-29 14:57:13 +01:00
2022-03-15 02:24:28 +01:00
jQuery ( 'body' ) . on ( 'click' , '.scheduleds-number-groupe-remove' , function ( e )
{
e . preventDefault ();
jQuery ( this ) . parent ( '.scheduleds-number-groupe' ) . remove ();
return false ;
});
2019-11-10 15:47:28 +01:00
var number_input = jQuery ( '.phone-international-input' )[ 0 ];
var iti_number_input = window . intlTelInput ( number_input , {
2022-03-15 02:24:28 +01:00
hiddenInput : 'numbers[' + jQuery ( number_input ) . attr ( 'data-uid' ) + '][number]' ,
2019-11-11 04:05:26 +01:00
defaultCountry : '<?php $this->s($_SESSION[' user '][' settings '][' default_phone_country ']); ?>' ,
preferredCountries : < ? php $this -> s ( json_encode ( explode ( ',' , $_SESSION [ 'user' ][ 'settings' ][ 'preferred_phone_country' ])), false , false ); ?> ,
2019-12-04 03:04:45 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'authorized_phone_country' ] ? ? false ) { ?>
onlyCountries : < ? php $this -> s ( json_encode ( explode ( ',' , $_SESSION [ 'user' ][ 'settings' ][ 'authorized_phone_country' ])), false , false ); ?> ,
< ? php } ?>
2019-11-10 15:47:28 +01:00
nationalMode : true ,
utilsScript : '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
2019-10-29 14:57:13 +01:00
});
2019-11-10 15:47:28 +01:00
number_inputs . push ({
'number_input' : number_input ,
'iti_number_input' : iti_number_input ,
});
2019-11-20 02:45:00 +01:00
jQuery ( 'body' ) . on ( 'click' , '.preview-button' , function ( e )
{
e . preventDefault ();
var id_contact = jQuery ( this ) . parents ( '.scheduled-preview-container' ) . find ( 'select' ) . val ();
var template = jQuery ( this ) . parents ( '.form-group' ) . find ( 'textarea' ) . val ();
2021-01-17 03:16:57 +01:00
var data = {
2019-11-20 02:45:00 +01:00
'id_contact' : id_contact ,
'template' : template ,
};
jQuery . ajax ({
type : " POST " ,
url : HTTP_PWD + '/template/preview' ,
2021-01-17 03:16:57 +01:00
data : data ,
success : function ( data ) {
jQuery ( '#scheduled-preview-text-modal' ) . find ( '.modal-body pre' ) . text ( data . result );
2021-06-15 01:49:47 +02:00
if ( data . estimation_credit !== 'undefined' ) {
jQuery ( '#scheduled-preview-text-modal' ) . find ( '.modal-body .credit-estimation-value' ) . text ( data . estimation_credit );
} else {
jQuery ( '#scheduled-preview-text-modal' ) . find ( '.modal-body .credit-estimation-value' ) . text ( '0' );
}
2019-11-20 02:45:00 +01:00
jQuery ( '#scheduled-preview-text-modal' ) . modal ({ 'keyboard' : true });
},
dataType : 'json'
});
});
2022-03-15 02:24:28 +01:00
jQuery ( '.scheduleds-number-groupe-container' ) . on ( 'input' , '.scheduled-number-data-value, .scheduled-number-data-name' , function ( e )
{
var scheduled_number = jQuery ( this ) . parents ( '.scheduleds-number-groupe' );
var focus_group = jQuery ( this ) . parent ( '.form-group' );
var focus_input = this ;
var input_name = focus_group . find ( '.scheduled-number-data-name' );
var input_value = focus_group . find ( '.scheduled-number-data-value' );
var uid = focus_group . attr ( 'data-uid' )
scheduled_number . find ( '.form-group' ) . each ( function ( e )
{
var current_input_name = jQuery ( this ) . find ( '.scheduled-number-data-name' );
var current_input_value = jQuery ( this ) . find ( '.scheduled-number-data-value' );
if ( current_input_value . is ( focus_input ) || current_input_name . is ( focus_input ))
{
return true ;
}
if ( jQuery ( current_input_name ) . val () === '' && jQuery ( current_input_value ) . val () === '' )
{
jQuery ( this ) . remove ();
}
return true ;
});
if ( input_name . val () === '' || input_value . val () === '' )
{
return true ;
}
var template = '' +
'<div class="form-group" data-uid="' + uid + '">' +
'<input name="" class="form-control scheduled-number-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">' +
' : ' +
'<input name="" class="form-control scheduled-number-data-value" type="text" placeholder="Valeur de la donnée">' +
' <a href="#" class="scheduled-number-data-remove"><span class="fa fa-times"></span></a>' +
'</div>' ;
scheduled_number . find ( '.scheduleds-number-data-container' ) . append ( template );
});
jQuery ( '.scheduleds-number-groupe-container' ) . on ( 'click' , '.scheduled-number-data-remove' , function ( e )
{
e . preventDefault ();
if ( jQuery ( '.scheduleds-number-data-container .form-group' ) . length > 1 )
{
jQuery ( this ) . parent ( '.form-group' ) . remove ();
}
return false ;
});
jQuery ( 'form' ) . on ( 'submit' , function ( e )
{
jQuery ( '.scheduleds-number-data-container .form-group' ) . each ( function ()
{
var name = jQuery ( this ) . find ( '.scheduled-number-data-name' ) . val ();
name = name . replace ( / \W / g , '' );
var uid = jQuery ( this ) . attr ( 'data-uid' );
name = 'numbers[' + uid + '][data][' + name + ']' ;
jQuery ( this ) . find ( '.scheduled-number-data-value' ) . attr ( 'name' , name );
});
return true ;
});
2019-10-29 14:57:13 +01:00
});
</ script >
< ? php
$this -> render ( 'incs/footer' );