<script src="<?php echo base_url();?>ckeditor/ckeditor.js"></script>
      <section class="content-header">
      <h1>

        Checkin Steps

      </h1>

      <ol class="breadcrumb">

        <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>

        <li><a href="<?php echo base_url('admin/checkin');?>">Checkin Steps</a></li>

        <li class="active"> Edit</li>

      </ol>

    </section>

    

    <section class="content">

      <div class="row">

      <?php echo $this->utility->showMsg();?>

        <div class="col-md-12">

        <div class="loader" style="display:none;"><img src='<?php echo base_url();?>assets/images/loading.gif' alt='loading' /></div>

          <!-- Horizontal Form -->

          <div class="box box-info">

            <div class="box-header with-border">

              <h3 class="box-title">Edit </h3>

            </div>

            <!-- /.box-header -->

            <!-- form start -->

            <form id="add_frm" name="add_frm" class="form-horizontal" method="post" action="" enctype="multipart/form-data">
            
              <div class="box-body">

              <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
                   
                <div class="form-group">

                  <label class="col-sm-2 control-label">Ttile [<?php echo $lang['name']; ?>]</label>

                  <div class="col-sm-10">
                    <?php $title = getValue('checkin_steps_details',array('lang_id'=>$lang['id'],'checkin_step_id'=>$checkin_stepsDetails['id'])); ?>
                    
                    <input type="text" class="form-control" id="title" name="details_name_<?php echo $lang['id']; ?>" value="<?php if(!empty($title)){ echo $title['details_name']; }?>" placeholder="Please enter title">

                  </div>

                </div>
              <?php } } ?>  
              <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>  
                <div class="form-group">

                  <label class="col-sm-2 control-label">Content [<?php echo $lang['name']; ?>]</label>

                  <div class="col-sm-10">
                  <?php $content = getValue('checkin_steps_details',array('lang_id'=>$lang['id'],'checkin_step_id'=>$checkin_stepsDetails['id'])); ?>
                    <textarea name="details_desc_<?php echo $lang['id']; ?>" class="form-control"><?php if(!empty($content)){ echo $content['details_desc']; }?></textarea>
                  <script>
                           CKEDITOR.replace( 'details_desc_<?php echo $lang['id']; ?>',{
                                    filebrowserBrowseUrl : '/castle/fileman/index.html',
                                    filebrowserImageBrowseUrl : '/castle/fileman/index.html?type=image',
                                    removeDialogTabs: 'link:upload;image:upload'
                            });
                        </script> 
                </div>
              </div>
              <?php } } ?> 
              <div class="form-group">

                  <label class="col-sm-2 control-label">Image</label>

                  <div class="col-sm-10">
                  <img src="<?php echo base_url(); ?>assets/userfiles/<?php echo $checkin_stepsDetails['path'].'/'.$checkin_stepsDetails['filename'].'.'.$checkin_stepsDetails['extension'];?>" width="100">
                    <input type="file" class="form-control" id="image" name="image" >

                  </div>

                </div>

                <?php if($checkin_stepsDetails['code']=='additional_step'){ ?>

                  <?php if($checkin_events){ 
                    foreach ($checkin_events as $checkin_evt_key => $checkin_evt_val) { ?>
                      <div class="">
                          <div class="form-group">
                              <div class="col-sm-1">
                                <input type="checkbox" name="status[]" value="1" <?php if($checkin_evt_val['status']==1){ echo 'checked';} ?>>
                              </div>
                              <div class="col-sm-3">
                                <input type="text" class="form-control" id="price" name="price[]" value="<?php echo $checkin_evt_val['price']; ?>" placeholder="please enter price">
                              </div>
                          
                              <div class="col-sm-4">
                                <select name="event[]" class="form-control">
                                  <option value="">--Choose Event--</option>
                                <?php if($events){ 
                                    foreach ($events as $key => $value) { ?>
                                      <option value="<?php echo $value['id']; ?>" <?php if($checkin_evt_val['event_id']==$value['id']){ echo 'selected';} ?>><?php echo $value['title']; ?></option>       
                                <?php }
                                  } 
                                ?>
                                </select>
                              </div>
                          
                          <?php if($checkin_evt_key==0){ ?>
                          <div class="col-sm-4">
                              <a href="javascript:void()" class="btn btn-warning add_more" >+</a>
                          </div>
                        <?php } else { ?>
                          <div class="col-sm-4">
                              <a href="javascript:void()" class="btn btn-warning remove_more" >-</a>
                          </div>
                        <?php } ?>
                        </div>
                  <?php }
                    } else {
                  ?>
                      <div class="">
                        <div class="form-group">
                            <div class="col-sm-1">
                                <input type="checkbox" name="status[]" value="1" checked>
                              </div>

                            <div class="col-sm-3">
                              <input type="text" class="form-control" id="price" name="price[]"  placeholder="please enter price">
                            </div>

                            <div class="col-sm-4">
                              <select name="event[]" class="form-control">
                                <option value="">--Choose Event--</option>
                              <?php if($events){ 
                                  foreach ($events as $key => $value) { ?>
                                    <option value="<?php echo $value['id']; ?>"><?php echo $value['title']; ?></option>       
                              <?php }
                                }
                              ?>
                              </select>
                            </div>
                            <div class="col-sm-4">
                              <a href="javascript:void()" class="btn btn-warning add_more" >+</a>
                            </div>
                        </div>
                      </div>
                      
                    <?php } ?>
                    <span class="additional_step_add"></span>
                <?php } ?>
              <div class="box-footer">

                <button type="button" onclick="return_back()"class="btn btn-warning  margin-left  " >Cancel</button>

                <input type="submit" class="btn btn-black " value="Update" id="add">

              </div>

              <input type="hidden" name="frmSecurity" value="<?php echo $this->utility->getSecurity();?>"/>

            </form>

          </div>
        </div>
      </div>
    </section>

    <style type="text/css">

    .loader{

      position: fixed;

      left: 0;

      top: 0;

      right: 0;

      bottom: 0;

      width: 100%;

      height: 100%;

      background-color: rgba(0, 0, 0, 0.60);

      z-index: 9999;

      text-align: center;

    }

    .loader img{

      z-index: 99999;

      margin-top: 10%;

    }

    </style>

   <script type='text/javascript'>
      $("#add_frm").validate({
        rules: {
          details_name_2:{
            required: true
          },
          details_desc_2:{
            required: true
          }
        }
      });
      $(function(){
        $("#fromDate").datetimepicker();
        $("#toDate").datetimepicker();
      });
    </script>

   <script type="text/javascript">
    function return_back()
    {
      var back_url='<?php echo base_url()."admin/checkin"; ?>';
      window.location=back_url;
    }

    <?php if($checkin_stepsDetails['code']=='additional_step'){ ?>
    var select = '<?php if($events){ 
                            foreach ($events as $key => $value) { ?>
                              <option value="<?php echo $value['id']; ?>"><?php echo $value['title']; ?></option>\
                        <?php }
                          }
                        ?>';
    $('body').on('click','.add_more',function(){
      $('.additional_step_add').append('<div class="">\
                  <div class="form-group">\
                      <div class="col-sm-1">\
                        <input type="checkbox" name="status[]" value="1" checked>\
                      </div>\
                      <div class="col-sm-3">\
                        <input type="text" class="form-control" id="price" name="price[]"  placeholder="please enter price">\
                      </div>\
                      <div class="col-sm-4">\
                        <select name="event[]" class="form-control">\
                        <option value="">--Choose Event--</option>\
                        '+select+'\
                        </select>\
                      </div>\
                      <div class="col-sm-4">\
                          <a href="javascript:void()" class="btn btn-warning remove_more" >-</a>\
                      </div>\
                </div>');
    })
    $('body').on('click','.remove_more',function(){
      $(this).parent().parent().remove();
    })
    <?php } ?>
   </script>