
<script src="<?= BASE_ASSET; ?>/js/jquery.hotkeys.js"></script>

<script type="text/javascript">
//This page is a result of an autogenerated content made by running test.html with firefox.
function domo(){
 
   // Binding keys
   $('*').bind('keydown', 'Ctrl+a', function assets() {
       window.location.href = BASE_URL + '/administrator/Demandes/add';
       return false;
   });

   $('*').bind('keydown', 'Ctrl+f', function assets() {
       $('#sbtn').trigger('click');
       return false;
   });

   $('*').bind('keydown', 'Ctrl+x', function assets() {
       $('#reset').trigger('click');
       return false;
   });

   $('*').bind('keydown', 'Ctrl+b', function assets() {

       $('#reset').trigger('click');
       return false;
   });
}

jQuery(document).ready(domo);
</script>
<!-- Content Header (Page header) -->
<section class="content-header">
   <h1>
      <?= cclang('demandes') ?><small><?= cclang('list_all'); ?></small>
   </h1>
   <ol class="breadcrumb">
      <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
      <li class="active"><?= cclang('demandes') ?></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="row pull-right">
                        <?php is_allowed('demandes_add', function(){?>
                        <a class="btn btn-flat btn-success btn_add_new" id="btn_add_new" title="<?= cclang('add_new_button', [cclang('demandes')]); ?>  (Ctrl+a)" href="<?=  site_url('administrator/demandes/add'); ?>"><i class="fa fa-plus-square-o" ></i> <?= cclang('add_new_button', [cclang('demandes')]); ?></a>
                        <?php }) ?>
                        <?php is_allowed('demandes_export', function(){?>
                        <a class="btn btn-flat btn-success" title="<?= cclang('export'); ?> <?= cclang('demandes') ?> " href="<?= site_url('administrator/demandes/export?q='.$this->input->get('q').'&f='.$this->input->get('f')); ?>"><i class="fa fa-file-excel-o" ></i> <?= cclang('export'); ?> XLS</a>
                        <?php }) ?>
                        <?php is_allowed('demandes_export', function(){?>
                        <a class="btn btn-flat btn-success" title="<?= cclang('export'); ?> pdf <?= cclang('demandes') ?> " href="<?= site_url('administrator/demandes/export_pdf?q='.$this->input->get('q').'&f='.$this->input->get('f')); ?>"><i class="fa fa-file-pdf-o" ></i> <?= cclang('export'); ?> PDF</a>
                        <?php }) ?>
                     </div>
                     <div class="widget-user-image" style="text-align:left;">
                        <img class="img-circle" style="width:50px;" src="<?= BASE_ASSET; ?>/img/list.png" alt="User Avatar">
                     </div>
                     <!-- /.widget-user-image -->
                     <h3 class="widget-user-username"><?= cclang('demandes') ?></h3>
                     <h5 class="widget-user-desc"><?= cclang('list_all', [cclang('demandes')]); ?>  <i class="label bg-yellow"><?= $demandes_counts; ?>  <?= cclang('items'); ?></i></h5>
                  </div>

                  <form name="form_demandes" id="form_demandes" action="<?= base_url('administrator/demandes/index'); ?>">
                  

                  <div class="table-responsive"> 
                  <table class="table table-bordered table-striped dataTable">
                     <thead>
                        <tr class="">
                                                     <th>
                            <input type="checkbox" class="flat-red toltip" id="check_all" name="check_all" title="check all">
                           </th>
                                                    <th data-field="date"data-sort="1" data-primary-key="0"> <?= cclang('date') ?></th>
                           <th data-field="ref"data-sort="1" data-primary-key="0"> <?= cclang('ref') ?></th>
                           <th data-field="date_limite"data-sort="1" data-primary-key="0"> <?= cclang('date_limite') ?></th>
                           <th data-field="nom_prenom"data-sort="1" data-primary-key="0"> <?= cclang('nom_prenom') ?></th>
                           <th data-field="tel"data-sort="1" data-primary-key="0"> <?= cclang('tel') ?></th>
                           <th data-field="panne"data-sort="1" data-primary-key="0"> <?= cclang('panne') ?></th>
                           <th data-field="op_id"data-sort="1" data-primary-key="0"> <?= cclang('op_id') ?></th>
                           <th data-field="etat"data-sort="1" data-primary-key="0"> <?= cclang('etat') ?></th>
                           <th data-field="res"data-sort="1" data-primary-key="0"> <?= cclang('res') ?></th>
                           <th data-field="desc"data-sort="1" data-primary-key="0"> <?= cclang('desc') ?></th>
                           <th data-field="dt_fin"data-sort="1" data-primary-key="0"> <?= cclang('dt_fin') ?></th>
                           <th data-field="couleur"data-sort="1" data-primary-key="0"> <?= cclang('couleur') ?></th>
                           <th data-field="prix"data-sort="1" data-primary-key="0"> <?= cclang('prix') ?></th>
                           <th data-field="atelier"data-sort="1" data-primary-key="0"> <?= cclang('atelier') ?></th>
                           <th data-field="remarque"data-sort="1" data-primary-key="0"> <?= cclang('remarque') ?></th>
                           <th data-field="description"data-sort="1" data-primary-key="0"> <?= cclang('description') ?></th>
                           <th data-field="retour"data-sort="1" data-primary-key="0"> <?= cclang('retour') ?></th>
                           <th data-field="date_re"data-sort="1" data-primary-key="0"> <?= cclang('date_re') ?></th>
                           <th><?= cclang('action') ?></th>                        </tr>
                     </thead>
                     <tbody id="tbody_demandes">
                     <?php foreach($demandess as $demandes): ?>
                        <tr>
                                                       <td width="5">
                              <input type="checkbox" class="flat-red check" name="id[]" value="<?= $demandes->id; ?>">
                           </td>
                                                       
                           <td><?= _ent($demandes->date); ?></td> 
                           <td><?= _ent($demandes->ref); ?></td> 
                           <td><?= _ent($demandes->date_limite); ?></td> 
                           <td><?= _ent($demandes->nom_prenom); ?></td> 
                           <td><?= _ent($demandes->tel); ?></td> 
                           <td><?= _ent($demandes->panne); ?></td> 
                           <td><?= _ent($demandes->op_id); ?></td> 
                           <td><?= _ent($demandes->etat); ?></td> 
                           <td><?= _ent($demandes->res); ?></td> 
                           <td><?= _ent($demandes->desc); ?></td> 
                           <td><?= _ent($demandes->dt_fin); ?></td> 
                           <td><?= _ent($demandes->couleur); ?></td> 
                           <td><?= _ent($demandes->prix); ?></td> 
                           <td><?= _ent($demandes->atelier); ?></td> 
                           <td><?= _ent($demandes->remarque); ?></td> 
                           <td><?= _ent($demandes->description); ?></td> 
                           <td><?= _ent($demandes->retour); ?></td> 
                           <td><?= _ent($demandes->date_re); ?></td> 
                           <td width="200">
                            
                                                              <?php is_allowed('demandes_view', function() use ($demandes){?>
                                 <a href="<?= site_url('administrator/demandes/single_pdf/' .$demandes->id); ?>" class="label-default"><i class="fa fa-file-pdf-o"></i> <?= cclang('PDF') ?>
                              <a href="<?= site_url('administrator/demandes/view/' . $demandes->id); ?>" class="label-default"><i class="fa fa-newspaper-o"></i> <?= cclang('view_button'); ?>
                              <?php }) ?>
                              <?php is_allowed('demandes_update', function() use ($demandes){?>
                              <a href="<?= site_url('administrator/demandes/edit/' . $demandes->id); ?>" class="label-default"><i class="fa fa-edit "></i> <?= cclang('update_button'); ?></a>
                              <?php }) ?>
                              <?php is_allowed('demandes_delete', function() use ($demandes){?>
                              <a href="javascript:void(0);" data-href="<?= site_url('administrator/demandes/delete/' . $demandes->id); ?>" class="label-default remove-data"><i class="fa fa-close"></i> <?= cclang('remove_button'); ?></a>
                               <?php }) ?>

                           </td>                        </tr>
                      <?php endforeach; ?>
                      <?php if ($demandes_counts == 0) :?>
                         <tr>
                           <td colspan="100">
                           Demandes data is not available
                           </td>
                         </tr>
                      <?php endif; ?>

                     </tbody>
                  </table>
                  </div>
               </div>
               <hr>
               <!-- /.widget-user -->
               <div class="row">
                  <div class="col-md-8">
                     <div class="col-sm-2 padd-left-0 " >
                        <select type="text" class="form-control chosen chosen-select" name="bulk" id="bulk" placeholder="Site Email" >
                           <option value="">Bulk</option>
                                                     <option value="delete">Delete</option>
                                                  </select>
                     </div>
                     <div class="col-sm-2 padd-left-0 ">
                        <button type="button" class="btn btn-flat" name="apply" id="apply" title="<?= cclang('apply_bulk_action'); ?>"><?= cclang('apply_button'); ?></button>
                     </div>
                     <div class="col-sm-3 padd-left-0  " >
                        <input type="text" class="form-control" name="q" id="filter" placeholder="<?= cclang('filter'); ?>" value="<?= $this->input->get('q'); ?>">
                     </div>
                     <div class="col-sm-3 padd-left-0 " >
                        <select type="text" class="form-control chosen chosen-select" name="f" id="field" >
                           <option value=""><?= cclang('all'); ?></option>
                            <option <?= $this->input->get('f') == 'date' ? 'selected' :''; ?> value="date">Date</option>
                           <option <?= $this->input->get('f') == 'ref' ? 'selected' :''; ?> value="ref">Ref</option>
                           <option <?= $this->input->get('f') == 'date_limite' ? 'selected' :''; ?> value="date_limite">Date Limite</option>
                           <option <?= $this->input->get('f') == 'nom_prenom' ? 'selected' :''; ?> value="nom_prenom">Nom Prenom</option>
                           <option <?= $this->input->get('f') == 'tel' ? 'selected' :''; ?> value="tel">Tel</option>
                           <option <?= $this->input->get('f') == 'panne' ? 'selected' :''; ?> value="panne">Panne</option>
                           <option <?= $this->input->get('f') == 'op_id' ? 'selected' :''; ?> value="op_id">Op Id</option>
                           <option <?= $this->input->get('f') == 'etat' ? 'selected' :''; ?> value="etat">Etat</option>
                           <option <?= $this->input->get('f') == 'res' ? 'selected' :''; ?> value="res">Res</option>
                           <option <?= $this->input->get('f') == 'desc' ? 'selected' :''; ?> value="desc">Desc</option>
                           <option <?= $this->input->get('f') == 'dt_fin' ? 'selected' :''; ?> value="dt_fin">Dt Fin</option>
                           <option <?= $this->input->get('f') == 'couleur' ? 'selected' :''; ?> value="couleur">Couleur</option>
                           <option <?= $this->input->get('f') == 'prix' ? 'selected' :''; ?> value="prix">Prix</option>
                           <option <?= $this->input->get('f') == 'atelier' ? 'selected' :''; ?> value="atelier">Atelier</option>
                           <option <?= $this->input->get('f') == 'remarque' ? 'selected' :''; ?> value="remarque">Remarque</option>
                           <option <?= $this->input->get('f') == 'description' ? 'selected' :''; ?> value="description">Description</option>
                           <option <?= $this->input->get('f') == 'retour' ? 'selected' :''; ?> value="retour">Retour</option>
                           <option <?= $this->input->get('f') == 'date_re' ? 'selected' :''; ?> value="date_re">Date Re</option>
                          </select>
                     </div>
                     <div class="col-sm-1 padd-left-0 ">
                        <button type="submit" class="btn btn-flat" name="sbtn" id="sbtn" value="Apply" title="<?= cclang('filter_search'); ?>">
                        Filter
                        </button>
                     </div>
                     <div class="col-sm-1 padd-left-0 ">
                        <a class="btn btn-default btn-flat" name="reset" id="reset" value="Apply" href="<?= base_url('administrator/demandes');?>" title="<?= cclang('reset_filter'); ?>">
                        <i class="fa fa-undo"></i>
                        </a>
                     </div>
                  </div>
                  </form>                  <div class="col-md-4">
                     <div class="dataTables_paginate paging_simple_numbers pull-right" id="example2_paginate" >
                        <?= $pagination; ?>
                     </div>
                  </div>
               </div>
            </div>
            <!--/box body -->
         </div>
         <!--/box -->
      </div>
   </div>
</section>
<!-- /.content -->

<!-- Page script -->
<script>
  $(document).ready(function(){
   
    $('.remove-data').click(function(){

      var url = $(this).attr('data-href');

      swal({
          title: "<?= cclang('are_you_sure'); ?>",
          text: "<?= cclang('data_to_be_deleted_can_not_be_restored'); ?>",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "<?= cclang('yes_delete_it'); ?>",
          cancelButtonText: "<?= cclang('no_cancel_plx'); ?>",
          closeOnConfirm: true,
          closeOnCancel: true
        },
        function(isConfirm){
          if (isConfirm) {
            document.location.href = url;            
          }
        });

      return false;
    });


    $('#apply').click(function(){

      var bulk = $('#bulk');
      var serialize_bulk = $('#form_demandes').serialize();

      if (bulk.val() == 'delete') {
         swal({
            title: "<?= cclang('are_you_sure'); ?>",
            text: "<?= cclang('data_to_be_deleted_can_not_be_restored'); ?>",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "<?= cclang('yes_delete_it'); ?>",
            cancelButtonText: "<?= cclang('no_cancel_plx'); ?>",
            closeOnConfirm: true,
            closeOnCancel: true
          },
          function(isConfirm){
            if (isConfirm) {
               document.location.href = BASE_URL + '/administrator/demandes/delete?' + serialize_bulk;      
            }
          });

        return false;

      } else if(bulk.val() == '')  {
          swal({
            title: "Upss",
            text: "<?= cclang('please_choose_bulk_action_first'); ?>",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Okay!",
            closeOnConfirm: true,
            closeOnCancel: true
          });

        return false;
      }

      return false;

    });/*end appliy click*/


    //check all
    var checkAll = $('#check_all');
    var checkboxes = $('input.check');

    checkAll.on('ifChecked ifUnchecked', function(event) {   
        if (event.type == 'ifChecked') {
            checkboxes.iCheck('check');
        } else {
            checkboxes.iCheck('uncheck');
        }
    });

    checkboxes.on('ifChanged', function(event){
        if(checkboxes.filter(':checked').length == checkboxes.length) {
            checkAll.prop('checked', 'checked');
        } else {
            checkAll.removeProp('checked');
        }
        checkAll.iCheck('update');
    });
    initSortable('demandes', $('table.dataTable'));
  }); /*end doc ready*/
</script>