

<script src="<?= BASE_ASSET; ?>/js/jquery.hotkeys.js"></script>
<script type="text/javascript">
    function domo(){
     
       // Binding keys
       $('*').bind('keydown', 'Ctrl+s', function assets() {
          $('#btn_save').trigger('click');
           return false;
       });
    
       $('*').bind('keydown', 'Ctrl+x', function assets() {
          $('#btn_cancel').trigger('click');
           return false;
       });
    
      $('*').bind('keydown', 'Ctrl+d', function assets() {
          $('.btn_save_back').trigger('click');
           return false;
       });
        
    }
    
    jQuery(document).ready(domo);
</script>
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        Demandes        <small>Edit Demandes</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class=""><a  href="<?= site_url('administrator/demandes'); ?>">Demandes</a></li>
        <li class="active">Edit</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">
    <div class="row" >
        <div class="col-md-12">
            <div class="box box-warning">
                <div class="box-body ">
                    <!-- Widget: user widget style 1 -->
                    <div class="box box-widget widget-user-2">
                        <!-- Add the bg color to the header using any of the bg-* classes -->
                        <div class="widget-user-header ">
                            <div class="widget-user-image" style="text-align:left;">
                                <img class="img-circle" style="width:50px;" src="<?= BASE_ASSET; ?>/img/add2.png" alt="User Avatar">
                            </div>
                            <!-- /.widget-user-image -->
                            <h3 class="widget-user-username">Demandes</h3>
                            <h5 class="widget-user-desc">Edit Demandes</h5>
                            <hr>
                        </div>
                        <?= form_open(base_url('administrator/demandes/edit_save/'.$this->uri->segment(4)), [
                            'name'    => 'form_demandes', 
                            'class'   => 'form-horizontal form-step', 
                            'id'      => 'form_demandes', 
                            'method'  => 'POST'
                            ]); ?>

                        <?php
                        $user_groups = $this->model_group->get_user_group_ids();
                        ?>

                         
                        
                        
                        <div class="form-group ">
                            <label for="date" class="col-sm-2 control-label">Date 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-6">
                            <div class="input-group date col-sm-8">
                              <input type="text" class="form-control pull-right datetimepicker" name="date"  placeholder="Date" id="date" value="<?= set_value('date', $demandes->date); ?>">
                            </div>
                            <small class="info help-block">
                            </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="ref" class="col-sm-2 control-label">Ref 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="ref" name="ref" rows="10" cols="80"> <?= set_value('ref', $demandes->ref); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="date_limite" class="col-sm-2 control-label">Date Limite 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-6">
                            <div class="input-group date col-sm-8">
                              <input type="text" class="form-control pull-right datetimepicker" name="date_limite"  placeholder="Date Limite" id="date_limite" value="<?= set_value('date_limite', $demandes->date_limite); ?>">
                            </div>
                            <small class="info help-block">
                            </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="nom_prenom" class="col-sm-2 control-label">Nom Prenom 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="nom_prenom" name="nom_prenom" rows="10" cols="80"> <?= set_value('nom_prenom', $demandes->nom_prenom); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="tel" class="col-sm-2 control-label">Tel 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="tel" name="tel" rows="10" cols="80"> <?= set_value('tel', $demandes->tel); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="panne" class="col-sm-2 control-label">Panne 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="panne" name="panne" rows="10" cols="80"> <?= set_value('panne', $demandes->panne); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="op_id" class="col-sm-2 control-label">Op Id 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="op_id" id="op_id" placeholder="Op Id" value="<?= set_value('op_id', $demandes->op_id); ?>">
                                <small class="info help-block">
                                <b>Input Op Id</b> Max Length : 11.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="etat" class="col-sm-2 control-label">Etat 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="etat" id="etat" placeholder="Etat" value="<?= set_value('etat', $demandes->etat); ?>">
                                <small class="info help-block">
                                <b>Input Etat</b> Max Length : 11.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="res" class="col-sm-2 control-label">Res 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="res" id="res" placeholder="Res" value="<?= set_value('res', $demandes->res); ?>">
                                <small class="info help-block">
                                <b>Input Res</b> Max Length : 11.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="desc" class="col-sm-2 control-label">Desc 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="desc" name="desc" rows="10" cols="80"> <?= set_value('desc', $demandes->desc); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="dt_fin" class="col-sm-2 control-label">Dt Fin 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="dt_fin" name="dt_fin" rows="10" cols="80"> <?= set_value('dt_fin', $demandes->dt_fin); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="couleur" class="col-sm-2 control-label">Couleur 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="couleur" name="couleur" rows="10" cols="80"> <?= set_value('couleur', $demandes->couleur); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="prix" class="col-sm-2 control-label">Prix 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="prix" name="prix" rows="10" cols="80"> <?= set_value('prix', $demandes->prix); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="atelier" class="col-sm-2 control-label">Atelier 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="atelier" name="atelier" rows="10" cols="80"> <?= set_value('atelier', $demandes->atelier); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="remarque" class="col-sm-2 control-label">Remarque 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="remarque" name="remarque" rows="10" cols="80"> <?= set_value('remarque', $demandes->remarque); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="description" class="col-sm-2 control-label">Description 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <textarea id="description" name="description" rows="10" cols="80"> <?= set_value('description', $demandes->description); ?></textarea>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="retour" class="col-sm-2 control-label">Retour 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="retour" id="retour" placeholder="Retour" value="<?= set_value('retour', $demandes->retour); ?>">
                                <small class="info help-block">
                                <b>Input Retour</b> Max Length : 11.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="date_re" class="col-sm-2 control-label">Date Re 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-6">
                            <div class="input-group date col-sm-8">
                              <input type="text" class="form-control pull-right datetimepicker" name="date_re"  placeholder="Date Re" id="date_re" value="<?= set_value('date_re', $demandes->date_re); ?>">
                            </div>
                            <small class="info help-block">
                            </small>
                            </div>
                        </div>
                        
                        
                        
                                                 <div class="message"></div>
                                                <div class="row-fluid col-md-7 container-button-bottom">
                            <button class="btn btn-flat btn-primary btn_save btn_action" id="btn_save" data-stype='stay' title="<?= cclang('save_button'); ?> (Ctrl+s)">
                            <i class="fa fa-save" ></i> <?= cclang('save_button'); ?>
                            </button>
                            <a class="btn btn-flat btn-info btn_save btn_action btn_save_back" id="btn_save" data-stype='back' title="<?= cclang('save_and_go_the_list_button'); ?> (Ctrl+d)">
                            <i class="ion ion-ios-list-outline" ></i> <?= cclang('save_and_go_the_list_button'); ?>
                            </a>
                            <a class="btn btn-flat btn-default btn_action" id="btn_cancel" title="<?= cclang('cancel_button'); ?> (Ctrl+x)">
                            <i class="fa fa-undo" ></i> <?= cclang('cancel_button'); ?>
                            </a>
                            <span class="loading loading-hide">
                            <img src="<?= BASE_ASSET; ?>/img/loading-spin-primary.svg"> 
                            <i><?= cclang('loading_saving_data'); ?></i>
                            </span>
                        </div>
                                                 <?= form_close(); ?>
                    </div>
                </div>
                <!--/box body -->
            </div>
            <!--/box -->
        </div>
    </div>
</section>
<!-- /.content -->
<script src="<?= BASE_ASSET; ?>ckeditor/ckeditor.js"></script>
<!-- Page script -->
<script>
    $(document).ready(function(){
       
      
      CKEDITOR.replace('ref'); 
      var ref = CKEDITOR.instances.ref;
            CKEDITOR.replace('nom_prenom'); 
      var nom_prenom = CKEDITOR.instances.nom_prenom;
            CKEDITOR.replace('tel'); 
      var tel = CKEDITOR.instances.tel;
            CKEDITOR.replace('panne'); 
      var panne = CKEDITOR.instances.panne;
            CKEDITOR.replace('desc'); 
      var desc = CKEDITOR.instances.desc;
            CKEDITOR.replace('dt_fin'); 
      var dt_fin = CKEDITOR.instances.dt_fin;
            CKEDITOR.replace('couleur'); 
      var couleur = CKEDITOR.instances.couleur;
            CKEDITOR.replace('prix'); 
      var prix = CKEDITOR.instances.prix;
            CKEDITOR.replace('atelier'); 
      var atelier = CKEDITOR.instances.atelier;
            CKEDITOR.replace('remarque'); 
      var remarque = CKEDITOR.instances.remarque;
            CKEDITOR.replace('description'); 
      var description = CKEDITOR.instances.description;
                   
      $('#btn_cancel').click(function(){
        swal({
            title: "Are you sure?",
            text: "the data that you have created will be in the exhaust!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes!",
            cancelButtonText: "No!",
            closeOnConfirm: true,
            closeOnCancel: true
          },
          function(isConfirm){
            if (isConfirm) {
              window.location.href = BASE_URL + 'administrator/demandes';
            }
          });
    
        return false;
      }); /*end btn cancel*/
    
      $('.btn_save').click(function(){
        $('.message').fadeOut();
        $('#ref').val(ref.getData());
                $('#nom_prenom').val(nom_prenom.getData());
                $('#tel').val(tel.getData());
                $('#panne').val(panne.getData());
                $('#desc').val(desc.getData());
                $('#dt_fin').val(dt_fin.getData());
                $('#couleur').val(couleur.getData());
                $('#prix').val(prix.getData());
                $('#atelier').val(atelier.getData());
                $('#remarque').val(remarque.getData());
                $('#description').val(description.getData());
                    
        var form_demandes = $('#form_demandes');
        var data_post = form_demandes.serializeArray();
        var save_type = $(this).attr('data-stype');
        data_post.push({name: 'save_type', value: save_type});
    
        $('.loading').show();
    
        $.ajax({
          url: form_demandes.attr('action'),
          type: 'POST',
          dataType: 'json',
          data: data_post,
        })
        .done(function(res) {
          $('form').find('.form-group').removeClass('has-error');
          $('form').find('.error-input').remove();
          $('.steps li').removeClass('error');
          if(res.success) {
            var id = $('#demandes_image_galery').find('li').attr('qq-file-id');
            if (save_type == 'back') {
              window.location.href = res.redirect;
              return;
            }
    
            $('.message').printMessage({message : res.message});
            $('.message').fadeIn();
            $('.data_file_uuid').val('');
    
          } else {
            if (res.errors) {
               parseErrorField(res.errors);
            }
            $('.message').printMessage({message : res.message, type : 'warning'});
          }
    
        })
        .fail(function() {
          $('.message').printMessage({message : 'Error save data', type : 'warning'});
        })
        .always(function() {
          $('.loading').hide();
          $('html, body').animate({ scrollTop: $(document).height() }, 2000);
        });
    
        return false;
      }); /*end btn save*/
      
       
       
       

      async function chain(){
      }
       
      chain();


    
    
    }); /*end doc ready*/
</script>