2019-10-29 14:57:13 +01:00
< ? php
//Template dashboard
$this -> render ( 'incs/head' , [ 'title' => 'Scheduleds - Edit' ])
?>
< 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 " >
Modifier SMS programmés
</ h1 >
< ol class = " breadcrumb " >
< li >
2019-11-07 17:52:33 +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-11-07 17:52:33 +01:00
< i class = " fa fa-calendar " ></ 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-edit " ></ i > Modifier
</ li >
</ ol >
</ div >
</ div >
<!-- /. row -->
< div class = " row " >
< div class = " col-lg-12 " >
< div class = " panel panel-default " >
< div class = " panel-heading " >
< h3 class = " panel-title " >< i class = " fa fa-edit fa-fw " ></ i > Modification des SMS programmés </ h3 >
</ div >
< div class = " panel-body " >
2019-12-04 03:04:45 +01:00
< form action = " <?php echo \ descartes \R outer::url('Scheduled', 'update', ['csrf' => $_SESSION['csrf'] ]);?> " method = " POST " enctype = " multipart/form-data " >
2019-10-29 14:57:13 +01:00
< ? php foreach ( $scheduleds as $scheduled ) { ?>
< 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 " >
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 = " # " > l ' utilisation des templates .</ a >< br />
Vous pouvez obtenir une prévisualisation du résultat pour un contact en cliquant sur le boutton < b > " Prévisualiser " </ b >.
</ p >
< ? php } ?>
2019-11-10 16:53:47 +01:00
< textarea name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][text] " class = " form-control " required >< ? php $this -> s ( $scheduled [ 'text' ], true ); ?> </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 } ?>
2019-10-29 14:57:13 +01:00
</ div >
2019-12-04 03:04:45 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'mms' ] ? ? false ) { ?>
< div class = " form-group " >
< label > Ajouter un média </ label >
< p class = " italic small help description-scheduled-media " >
2021-03-22 01:29:06 +01: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 = " # " > 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 = " scheduleds_<?php $this->s ( $scheduled['id'] ); ?>_medias[] " value = " " type = " file " multiple />
</ div >
< ? php if ( $scheduled [ 'medias' ]) { ?>
< div class = " current-medias-container " >
< label > Médias déjà attachés au SMS </ label >
< ? php foreach ( $scheduled [ 'medias' ] as $key => $media ) { ?>
< p class = " current-media " >
< input type = " hidden " name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][media_ids][] " value = " <?php $this->s ( $media['id'] ); ?> " >
2021-03-26 23:32:29 +01:00
< label > Fichier < ? = $key + 1 ?> :</label><br/> <a href="<?php $this->s(HTTP_PWD_DATA_PUBLIC . '/' . $media['path']); ?>" class="btn btn-info btn-sm" target="_blank">Voir le média</a> <a href="#" class="btn btn-warning btn-delete-media btn-sm">Supprimer le média</a>
2021-03-22 01:29:06 +01:00
</ p >
< ? php } ?>
2019-12-04 03:04:45 +01:00
</ div >
< ? php } ?>
</ div >
< ? php } ?>
2019-10-29 14:57:13 +01:00
< div class = " form-group " >
< label > Date d ' envoi du SMS </ label >
2019-12-20 18:51:13 +01:00
< input name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][at] " class = " form-control form-datetime auto-width " type = " text " value = " <?php $this->s ( $scheduled['at'] ); ?> " readonly >
2019-10-29 14:57:13 +01:00
</ 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 " >
2019-11-10 16:53:47 +01:00
< input name = " " class = " form-control phone-international-input " type = " tel " value = " <?php $this->s ( $number ); ?> " scheduled - id = " <?php $this->s ( $scheduled['id'] ); ?> " >
2019-10-29 14:57:13 +01:00
< span class = " remove-scheduleds-number fa fa-times " ></ span >
</ div >
< ? php } ?>
< div class = " add-number-button fa fa-plus-circle " ></ div >
</ div >
</ div >
< div class = " form-group " >
< label > Contacts cibles </ label >
< input class = " add-contacts form-control " name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][contacts][] " value = " <?php $this->s (json_encode( $scheduled['contacts'] )); ?> " />
</ div >
< div class = " form-group " >
< label > Groupes cibles </ label >
2019-11-10 16:53:47 +01:00
< input class = " add-groupes form-control " name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][groups][] " value = " <?php $this->s (json_encode( $scheduled['groups'] )); ?> " />
2019-10-29 14:57:13 +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 >
< input class = " add-conditional-groups form-control " name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][conditional_groups][] " value = " <?php $this->s (json_encode( $scheduled['conditional_groups'] )); ?> " />
</ div >
< ? php } ?>
2019-11-11 04:05:26 +01:00
< ? php if ( $_SESSION [ 'user' ][ 'settings' ][ 'sms_flash' ]) { ?>
2019-10-29 14:57:13 +01:00
< div class = " form-group " >
< label > Envoyer comme un SMS Flash : </ label >
< div class = " form-group " >
< input name = " admin " type = " radio " value = " 1 " required < ? php echo ( $scheduled [ 'flash' ] ? 'checked' : '' ); ?> /> Oui
< input name = " admin " type = " radio " value = " 0 " required < ? php echo ( $scheduled [ 'flash' ] ? '' : 'checked' ); ?> /> Non
</ div >
</ div >
< ? php } ?>
2019-11-12 17:37:20 +01:00
< div class = " form-group " >
2019-11-20 02:45:00 +01:00
< label > Numéro à employer : </ label >
2020-03-04 01:40:47 +01:00
< select name = " scheduleds[<?php $this->s ( $scheduled['id'] ); ?>][id_phone] " class = " form-control " >
< option < ? php echo ( $scheduled [ 'id_phone' ] ? '' : 'selected="selected"' ); ?> value="">N'importe lequel</option>
2019-11-12 17:37:20 +01:00
< ? php foreach ( $phones as $phone ) { ?>
2020-03-31 01:19:21 +02:00
< option < ? php echo ( $scheduled [ 'id_phone' ] == $phone [ 'id' ] ? 'selected="selected"' : '' ); ?> value="<?php $this->s($phone['id']); ?>"><?php $this->s($phone['name']); ?></option>
2019-11-12 17:37:20 +01:00
< ? php } ?>
</ select >
</ div >
2019-10-29 14:57:13 +01:00
< hr />
2019-11-07 17:52:33 +01:00
< ? php } ?>
< a class = " btn btn-danger " href = " <?php echo \ descartes \R outer::url('Scheduled', 'list'); ?> " > Annuler </ a >
2019-10-29 14:57:13 +01:00
< input type = " submit " class = " btn btn-success " value = " Enregistrer le SMS " />
</ form >
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >
</ 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 ()
{
jQuery ( '.form-datetime' ) . datetimepicker (
{
format : 'yyyy-mm-dd hh:ii:ss' ,
autoclose : true ,
minuteStep : 1 ,
language : 'fr'
});
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' ,
2020-09-02 00:59:45 +02:00
displayField : 'name' ,
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-11-28 01:55:11 +01:00
valueField : 'id' ,
displayField : 'name' ,
2020-09-02 00:59:45 +02:00
maxSelection : null ,
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 '); ?>' ,
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 16:53:47 +01:00
jQuery ( 'body' ) . on ( 'click' , '.remove-scheduleds-number' , function ( e )
2019-10-29 14:57:13 +01:00
{
jQuery ( this ) . parents ( '.scheduleds-number-groupe' ) . remove ();
});
2019-11-10 16:53:47 +01:00
jQuery ( '.phone-international-input' ) . each ( function ()
{
var hidden_input_name = 'scheduleds[' + jQuery ( this ) . attr ( 'scheduled-id' ) + '][numbers][]' ;
window . intlTelInput ( this , {
hiddenInput : hidden_input_name ,
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 16:53:47 +01:00
nationalMode : true ,
utilsScript : '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
});
});
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 scheduledId = jQuery ( this ) . parents ( '.scheduleds-number-groupe-container' ) . attr ( 'scheduled-id' );
var newScheduledsNumberGroupe = '' +
'<div class="form-group scheduleds-number-groupe">' +
2019-11-10 16:53:47 +01:00
'<input name="" class="form-control phone-international-input" type="tel" scheduled-id="' + scheduledId + '" id="' + random_id + '">' +
2019-11-20 02:45:00 +01:00
' <span class="remove-scheduleds-number fa fa-times"></span>' +
2019-10-29 14:57:13 +01:00
'</div>' ;
jQuery ( this ) . before ( newScheduledsNumberGroupe );
2019-11-10 16:53:47 +01:00
var hidden_input_name = 'scheduleds[' + scheduledId + '][numbers][]' ;
var phone_input = jQuery ( '#' + random_id )[ 0 ];
window . intlTelInput ( phone_input , {
hiddenInput : hidden_input_name ,
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 16:53:47 +01:00
utilsScript : '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js'
2019-10-29 14:57:13 +01:00
});
2019-12-04 03:04:45 +01:00
});
jQuery ( 'body' ) . on ( 'click' , '.btn-delete-media' , function ( e )
{
e . preventDefault ();
2021-03-22 01:29:06 +01:00
jQuery ( this ) . parents ( '.current-media' ) . remove ();
2019-12-04 03:04:45 +01:00
});
2019-10-29 14:57:13 +01:00
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 ,
};
2019-10-29 14:57:13 +01:00
2019-11-20 02:45:00 +01:00
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'
});
});
2019-10-29 14:57:13 +01:00
});
</ script >
< ? php
$this -> render ( 'incs/footer' );