2019-11-12 05:16:59 +01:00
< ? php
//Template dashboard
$this -> render ( 'incs/head' , [ 'title' => 'Phones - Show All' ])
?>
< div id = " wrapper " >
< ? php
$this -> render ( 'incs/nav' , [ 'page' => 'phones' ])
?>
< div id = " page-wrapper " >
< div class = " container-fluid " >
<!-- Page Heading -->
< div class = " row " >
< div class = " col-lg-12 " >
< h1 class = " page-header " >
Nouveau téléphone
</ h1 >
< ol class = " breadcrumb " >
< li >
< i class = " fa fa-dashboard " ></ i > < a href = " <?php echo \ descartes \R outer::url('Dashboard', 'show'); ?> " > Dashboard </ a >
</ li >
< li >
< i class = " fa fa-phone " ></ i > < a href = " <?php echo \ descartes \R outer::url('Phone', 'list'); ?> " > Téléphones </ a >
</ li >
< li class = " active " >
< i class = " fa fa-plus " ></ i > Nouveau
</ 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-phone fa-fw " ></ i > Ajout d ' un téléphone </ h3 >
</ div >
< div class = " panel-body " >
< form action = " <?php echo \ descartes \R outer::url('Phone', 'create', ['csrf' => $_SESSION['csrf'] ]);?> " method = " POST " >
< div class = " form-group " >
2020-03-31 01:19:21 +02:00
< label > Nom du téléphone </ label >
2019-11-20 02:45:00 +01:00
< p class = " italic small help " >
2020-03-31 01:19:21 +02:00
Le nom du téléphone qui enverra et recevra les messages .
2019-11-12 05:16:59 +01:00
</ p >
< div class = " form-group " >
2020-03-31 01:19:21 +02:00
< input required = " required " name = " name " class = " form-control " placeholder = " Nom du téléphone " >
2019-11-12 05:16:59 +01:00
</ div >
</ div >
< div class = " form-group " >
< label > Adaptateur logiciel du téléphone : </ label >
2020-03-04 01:40:47 +01:00
< p class = " italic small help " id = " description-adapter-general " >
2019-11-12 05:16:59 +01:00
L 'adaptateur logiciel utilisé par RaspiSMS pour communiquer avec le téléphone. Pour plus d' information , consultez < a href = " https://raspisms.raspberry-pi.fr/documentation " target = " _blank " > la documentation de RaspiSMS </ a > concernant les adaptateurs logiciels .
</ p >
< select name = " adapter " class = " form-control " id = " adapter-select " >
< ? php foreach ( $adapters as $adapter ) { ?>
< option
value = " <?= $adapter['meta_classname'] ?> "
title = " <?php $this->s ( $adapter['meta_description'] ); ?> "
data - description = " <?php $this->s ( $adapter['meta_description'] ); ?> "
2020-01-09 22:23:58 +01:00
data - datas - fields = " <?php $this->s (json_encode( $adapter['meta_datas_fields'] )); ?> "
2019-11-12 05:16:59 +01:00
>
< ? php $this -> s ( $adapter [ 'meta_name' ]); ?>
</ option >
< ? php } ?>
</ select >
</ div >
2020-03-04 01:40:47 +01:00
< div id = " adapter-datas-container " class = " form-group " >
< div id = " adapter-datas-description-container " >
< h4 > Description de l ' adaptateur </ h4 >
< div id = " adapter-datas-description " ></ div >
</ div >
< div id = " adapter-data-fields-container " >
< h4 > Réglages de l ' adaptateur </ h4 >
< div id = " adapter-datas-fields " ></ div >
</ div >
2020-01-09 22:23:58 +01:00
</ div >
2019-11-12 05:16:59 +01:00
< a class = " btn btn-danger " href = " <?php echo \ descartes \R outer::url('Phone', 'list'); ?> " > Annuler </ a >
2020-04-02 01:56:40 +02:00
< input type = " submit " class = " btn btn-success " value = " Enregistrer le téléphone " />
2019-11-12 05:16:59 +01:00
</ form >
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >
< script >
2020-01-09 22:23:58 +01:00
function change_adapter ()
2019-11-12 05:16:59 +01:00
{
var option = jQuery ( '#adapter-select' ) . find ( 'option:selected' );
2020-03-04 01:40:47 +01:00
jQuery ( '#adapter-datas-description' ) . html ( option . attr ( 'data-description' ));
2019-11-12 05:16:59 +01:00
jQuery ( '#description-adapter-datas' ) . text ( option . attr ( 'data-datas-help' ));
2020-01-09 22:23:58 +01:00
var datas_fields = option . attr ( 'data-datas-fields' );
datas_fields = JSON . parse ( datas_fields );
2020-04-02 01:55:55 +02:00
var numbers = [];
2020-01-09 22:23:58 +01:00
var html = '' ;
jQuery . each ( datas_fields , function ( index , field )
2019-11-12 05:16:59 +01:00
{
2020-04-02 01:55:55 +02:00
if ( ! field . number )
{
html += '<div class="form-group">' +
'<label>' + field . title + '</label>' +
'<p class="italic small help">' + field . description + '</p>' +
'<div class="form-group">' +
'<input name="adapter_datas[' + field . name + ']" class="form-control" ' + ( field . required ? 'required' : '' ) + ' ' + ( field . default_value ? 'value="' + field . default_value + '"' : '' ) + '>' +
'</div>' +
'</div>' ;
}
else
{
var random_id = Math . random () . toString ( 36 ) . substring ( 2 , 15 ) + Math . random () . toString ( 36 ) . substring ( 2 , 15 );
html += '' +
'<div class="form-group">' +
'<label>' + field . title + '</label>' +
'<p class="italic small help">' + field . description + '</p>' +
'<div class="form-group">' +
'<input name="" class="form-control phone-international-input" type="tel" id="' + random_id + '" ' + ( field . required ? 'required' : '' ) + ' ' + ( field . default_value ? 'value="' + field . default_value + '"' : '' ) + '>' +
'</div>' +
'</div>' ;
var number = {
'id' : random_id ,
'name' : field . name ,
};
numbers . push ( number );
}
2019-11-12 05:16:59 +01:00
});
2020-03-04 01:40:47 +01:00
if ( html == '' )
{
html = 'Pas de réglages.' ;
}
jQuery ( '#adapter-datas-fields' ) . html ( html );
2020-04-02 01:55:55 +02:00
for ( i = 0 ; i < numbers . length ; i ++ )
{
var iti_number_input = window . intlTelInput ( document . getElementById ( numbers [ i ] . id ), {
hiddenInput : 'adapter_datas[' + numbers [ i ] . name + ']' ,
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 ); ?> ,
nationalMode : true ,
utilsScript : '<?php echo HTTP_PWD_JS; ?>/intlTelInput/utils.js' ,
});
}
2020-01-09 22:23:58 +01:00
}
2019-11-12 05:16:59 +01:00
2020-01-09 22:23:58 +01:00
jQuery ( 'document' ) . ready ( function ( $ )
{
change_adapter ();
jQuery ( '#adapter-select' ) . on ( 'change' , function ( e )
{
change_adapter ();
2019-11-12 05:16:59 +01:00
});
});
</ script >
< ? php
$this -> render ( 'incs/footer' );