

<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>
        عمليات عصر الزيتون        <small>Edit عمليات عصر الزيتون</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class=""><a  href="<?= site_url('administrator/agritun_masra_sortant'); ?>">عمليات عصر الزيتون</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">عمليات عصر الزيتون</h3>
                            <h5 class="widget-user-desc">Edit عمليات عصر الزيتون</h5>
                            <hr>
                        </div>
                        <?= form_open(base_url('administrator/agritun_masra_sortant/edit_save/'.$this->uri->segment(4)), [
                            'name'    => 'form_agritun_masra_sortant', 
                            'class'   => 'form-horizontal form-step', 
                            'id'      => 'form_agritun_masra_sortant', 
                            'method'  => 'POST'
                            ]); ?>

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

                         
                         
                        
                        
                        <div class="form-group ">
                            <label for="masra" class="col-sm-2 control-label">المعصرة 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <select  class="form-control chosen chosen-select-deselect" name="masra" id="masra" data-placeholder="Select المعصرة" >
                                    <option value=""></option>
                                    <?php foreach (db_get_all_data('agritun_masra') as $row): ?>
                                    <option <?=  $row->id ==  $agritun_masra_sortant->masra ? 'selected' : ''; ?> value="<?= $row->id ?>"><?= $row->name; ?></option>
                                    <?php endforeach; ?>  
                                </select>
                                <small class="info help-block">
                                <b>Input Masra</b> Max Length : 300.</small>
                            </div>
                        </div>


                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="qualite_zit" class="col-sm-2 control-label">نوع الزيتون 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <select  class="form-control chosen chosen-select" name="qualite_zit" id="qualite_zit" data-placeholder="Select نوع الزيتون" >
                                    <option value=""></option>
                                    <option <?= $agritun_masra_sortant->qualite_zit == "حي" ? 'selected' :''; ?> value="حي">حي</option>
                                    <option <?= $agritun_masra_sortant->qualite_zit == "نشيرة" ? 'selected' :''; ?> value="نشيرة">نشيرة</option>
                                    </select>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="qte_zitoun" class="col-sm-2 control-label">كمية الزيتون 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="qte_zitoun" id="qte_zitoun" placeholder="كمية الزيتون" value="<?= set_value('qte_zitoun', $agritun_masra_sortant->qte_zitoun); ?>">
                                <small class="info help-block">
                                <b>Input Qte Zitoun</b> Max Length : 300.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="prix_u" class="col-sm-2 control-label">سعر العصر 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="prix_u" id="prix_u" placeholder="سعر العصر" value="<?= set_value('prix_u', $agritun_masra_sortant->prix_u); ?>">
                                <small class="info help-block">
                                <b>Input Prix U</b> Max Length : 300.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="qte_zit" class="col-sm-2 control-label">كمية  الزيت 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="qte_zit" id="qte_zit" placeholder="كمية  الزيت" value="<?= set_value('qte_zit', $agritun_masra_sortant->qte_zit); ?>">
                                <small class="info help-block">
                                <b>Input Qte Zit</b> Max Length : 300.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="cout" class="col-sm-2 control-label">التكلفة 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="cout" id="cout" placeholder="التكلفة" value="<?= set_value('cout', $agritun_masra_sortant->cout); ?>">
                                <small class="info help-block">
                                <b>Input Cout</b> Max Length : 300.</small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="qualite" class="col-sm-2 control-label">جودة الزيت 
                            <i class="required">*</i>
                            </label>
                            <div class="col-sm-8">
                                <select  class="form-control chosen chosen-select" name="qualite" id="qualite" data-placeholder="Select جودة الزيت" >
                                    <option value=""></option>
                                    <option <?= $agritun_masra_sortant->qualite == "extra vierge" ? 'selected' :''; ?> value="extra vierge">بكر ممتاز</option>
                                    <option <?= $agritun_masra_sortant->qualite == "vierge" ? 'selected' :''; ?> value="vierge">بكر</option>
                                    <option <?= $agritun_masra_sortant->qualite == "lampante" ? 'selected' :''; ?> value="lampante">لامبونتي</option>
                                    </select>
                                <small class="info help-block">
                                </small>
                            </div>
                        </div>
                        
                        
                         
                        
                        
                        <div class="form-group ">
                            <label for="i_src" class="col-sm-2 control-label">الصورة 
                            </label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="i_src" id="i_src" placeholder="الصورة" value="<?= set_value('i_src', $agritun_masra_sortant->i_src); ?>">
                                <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 -->
<!-- Page script -->
<script>
    $(document).ready(function(){
       
      
             
      $('#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/agritun_masra_sortant';
            }
          });
    
        return false;
      }); /*end btn cancel*/
    
      $('.btn_save').click(function(){
        $('.message').fadeOut();
            
        var form_agritun_masra_sortant = $('#form_agritun_masra_sortant');
        var data_post = form_agritun_masra_sortant.serializeArray();
        var save_type = $(this).attr('data-stype');
        data_post.push({name: 'save_type', value: save_type});
    
        $('.loading').show();
    
        $.ajax({
          url: form_agritun_masra_sortant.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 = $('#agritun_masra_sortant_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>