<script src="<?php echo base_url();?>ckeditor/ckeditor.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css">
      <section class="content-header">
      <h1>

        Events

      </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/event');?>">Events</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('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                    <input type="text" class="form-control" id="title" name="name_<?php echo $lang['id']; ?>" value="<?php if($title['title']!=''){ echo $title['title']; } else { echo $eventDetail['title']; } ?>" 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">Sub Ttile [<?php echo $lang['name']; ?>]</label>

                  <div class="col-sm-10">
                  <?php $title = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                    <input type="text" class="form-control" id="sub_title" name="sub_title<?php echo $lang['id']; ?>" value="<?php if($title['sub_title']!=''){ echo $title['sub_title']; } else { echo $eventDetail['sub_title']; } ?>" placeholder="Please enter sub title">

                  </div>

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

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

                  <div class="col-sm-10">
				  <?php $text = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                  <input type="text" class="form-control" id="teasertext" name="teasertext_<?php echo $lang['id']; ?>" value="<?php if($text['teasertext']!=''){ echo $text['teasertext']; } else { echo $eventDetail['teasertext']; } ?>" placeholder="Please enter teaser text">

                  </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('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                    <textarea name="content_<?php echo $lang['id']; ?>" class="form-control"><?php if($content['description']!=''){ echo $content['description']; } else { echo $eventDetail['description']; } ?></textarea>
                  <script>
                           CKEDITOR.replace( 'content_<?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">Banner Image</label>

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

                  </div>

                </div>
                <div class="form-group">

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

                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="event_video" name="event_video" value="<?php echo $eventDetail['event_video']; ?>">

                  </div>

                </div>
                <div class="form-group">

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

                  <div class="col-sm-10">
                  <ul class="partyList">
                  <?php if(!empty($imageDetails)){ 
                      foreach ($imageDetails as $images) { ?>
                      <li>
                        <img src="<?php echo  base_url();?>assets/userfiles/<?php echo $images['path'].'/'.$images['filename'].'.'.$images['extension'] ; ?>" width="100">
                        <a onclick="return confirm('Are you sure');" href="<?php echo  base_url();?>admin/event/deleteParty/<?php echo $images['id']; ?>/<?php echo str_replace('/','-',uri_string()); ?>"><span class="fa fa-ban"></span></a>
                      </li>
                  <?php  }
                  }  ?>
                  </ul>
                    <input type="file" class="form-control" id="party_image" name="party_image[]" multiple>

                  </div>

                </div>
                <div class="form-group">

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

                  <div class="col-sm-10">

                    <input type="text" class="form-control" id="video_url" name="video_url" value="<?php echo $eventDetail['video_url']; ?>">

                  </div>

                </div>
                <div class="form-group" style="display: none;">
                  <label class="col-sm-2 control-label">Stripe Account</label>
                  <div class="col-sm-10">
                  <?php if(count($stripe_accounts)>0){
                        foreach ($stripe_accounts as $key => $accounts) { ?>
                        <label style="margin:0 5px; vertical-align:middle;">
                          <input type="radio" class="" id="stripe_account" name="stripe_account_id" value="<?php echo $accounts['id']; ?>" <?php if($accounts['id']==$eventDetail['stripe_account_id']){ echo 'checked'; } ?>>
                        <?php echo $accounts['name']; ?>
                        </label>
                  <?php }
                      }
                    ?>
                  </div>
                </div>
                <div class="form-group">

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

                  <div class="col-sm-10">
                    <select class="form-control" name="location_id[]" multiple="">
                    <?php if(!empty($locations))
                          foreach ($locations as $loc) {
                           echo '<option value="'.$loc['id'].'" '.((in_array($loc['id'],$locationDetails))?'selected':'').'>'.$loc['name'].'</option>';
                          }
                      ?>
                      </select>
                  </div>

                </div>
                <div class="form-group">

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

                  <div class="col-sm-10">
                    <textarea class="form-control" name="address"><?php if($eventDetail['address']!=''){ echo $eventDetail['address']; } ?></textarea>
                    <script>
                           CKEDITOR.replace( 'address',{
                                    filebrowserBrowseUrl : '/castle/fileman/index.html',
                                    filebrowserImageBrowseUrl : '/castle/fileman/index.html?type=image',
                                    removeDialogTabs: 'link:upload;image:upload'
                            });
                        </script> 
                  </div>

                </div>


                <div class="form-group">

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

                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="airport_distance" name="airport_distance" value="<?php echo $eventDetail['airport_distance']; ?>">
                  </div>

                </div>


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

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

                  <div class="col-sm-10">
				   <?php $details = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                    <textarea class="form-control" name="party_details_<?php echo $lang['id']; ?>"><?php if($details['party_details']!=''){ echo $details['party_details']; } elseif($eventDetail['party_details']!=''){ echo $eventDetail['party_details']; } ?></textarea>
                    <script>
                           CKEDITOR.replace( 'party_details_<?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">Services</label>

                  <div class="col-sm-10">
                    <ul class="serviceList">
                    <?php if(!empty($services))
                          $i=0;
                          foreach ($services as $serv) { ?>
                            <li>
                              <input type="checkbox" id="<?php echo $i; ?>" name="services[]" value="<?php echo $serv; ?>" <?php echo ((in_array($serv,$evtServices))?'checked':''); ?>>
                              <label for="<?php echo $i; ?>"><?php echo $serv; ?></label>
                            </li>
                    <?php $i++; }
                      ?>
                    </ul> 
                  </div>

                </div>
                <?php if(!empty($pastParties)){ ?>
                <div class="form-group">

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

                  <div class="col-sm-10">
                    <select class="form-control past" name="past_parties[]" multiple="" style="height: 200px; margin-bottom: 15px;">
                    <?php if(!empty($pastParties))
                          foreach ($pastParties as $past) {
                            $pastParties = explode(',',$eventDetail['past_parties']);
                           echo '<option value="'.$past['id'].'" '.((in_array($past['id'],$pastParties))?'selected':'').'>'.$past['title'].'('.$past['files_have'].'F)'.' '.'('.$past['video_have'].'V)'.'</option>';
                          }
                      ?>
                      </select>
                      
                  </div>

                </div>

                <?php } ?>

                <div class="form-group">
                  <label class="col-sm-2 control-label">Show/Off Rating and Extra info section</label>

                  <div class="col-sm-10">
                    <label class="switch">
                      <input type="checkbox" name="rating_on_off" value="1" <?php if($eventDetail['rating_on_off']==1){ echo 'checked'; } ?>>
                      <span class="slider round"></span>
                    </label>
                  </div>
                </div>
                
                <div class="form-group">
                  <label class="col-sm-2 control-label">Party Rating</label>

                  <div class="col-sm-10">
                    <input class="rating" name="rating" value="<?php if($eventDetail['rating']!=''){ echo $eventDetail['rating']; } ?>">
                  </div>
                </div>
                <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">Party Info Text [<?php echo $lang['name']; ?>]</label>
                      <?php $extrainfo = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" name="extra_text_<?php echo $lang['id']; ?>" value="<?php if($extrainfo['extra_text']!=''){ echo $extrainfo['extra_text']; } elseif($eventDetail['extra_text']!=''){ echo $eventDetail['extra_text']; } ?>">
                      </div>
                    </div>
                <?php } } ?>
                <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">Party Extra Info [<?php echo $lang['name']; ?>]</label>
                      <?php $extrainfo = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                      <div class="col-sm-10">
                        <input type="text"  class="form-control" name="extra_info_<?php echo $lang['id']; ?>" value="<?php if($extrainfo['extra_info']!=''){ echo $extrainfo['extra_info']; } elseif($eventDetail['extra_info']!=''){ echo $eventDetail['extra_info']; } ?>">
                      </div>
                    </div>
                <?php } } ?>
                <div class="form-group">
                  <div class="row">
                   <div class="col-sm-6">
                      <label class="col-sm-4 control-label">From Date</label>

                      <div class="col-sm-8">
                          <input type="text" name="fromDate" id="fromDate" value="<?php echo date('d-m-Y',$eventDetail['time_from']); ?>">

                      </div>
                   </div>
                   <div class="col-sm-6">
                      <label class="col-sm-4 control-label">To Date</label>

                      <div class="col-sm-8">
                          <input type="text" name="toDate" id="toDate" value="<?php echo date('d-m-Y',$eventDetail['time_to']); ?>">
                      </div>
                   </div>
                  </div>
                </div>

                
                 
                


                <div class="form-group">
                  <div class="row">
                   <div class="col-sm-6">
                      <label class="col-sm-4 control-label">Basic Package Price</label>

                      <div class="col-sm-8">
                          <input type="text" name="basic_drinking" id="basic_drinking" value="<?php echo $eventDetail['basic_drinking']; ?>">
                      </div>
                   </div>
                   <div class="col-sm-6">
                      <label class="col-sm-4 control-label">Premium Package Price</label>

                      <div class="col-sm-8">
                          <input type="text" name="premium_drinking" id="premium_drinking" value="<?php echo $eventDetail['premium_drinking']; ?>">
                      </div>
                   </div>
                  </div>
                </div>



                <div class="form-group">
                  <div class="row">
                   <div class="col-sm-6">
                      <label class="col-sm-4 control-label">Early bird discount (%)</label>

                      <div class="col-sm-8">
                          <select class="form-control" name="discount" id="discount">
                            <option value="0">--Select--</option>
                            <?php for ($i=1; $i <= 50 ; $i++) { ?>
                              <option value="<?php echo $i; ?>" <?php if($eventDetail['discount']==$i){ echo 'selected';} ?>><?php echo $i; ?></option>
                            <?php }?>
                          </select>
                      </div>
                   </div>
                   <div class="col-sm-6">
                      <label class="col-sm-4 control-label">Early bird discount end date</label>

                      <div class="col-sm-8">
                          <input type="text" name="discount_end_date" id="discount_end_date" value="<?php if($eventDetail['discount_end_date']!='1970-01-01' && $eventDetail['discount_end_date']!=''){ echo $eventDetail['discount_end_date'];} else { echo ''; } ?>">
                      </div>
                   </div>
                   
                  </div>
                </div>

                <h4>Checkin Additional Step Details: </h4>
                   <?php if(!empty($languages)){ 
                      foreach ($languages as $lang) { ?>
                        <div class="form-group">
                          <label class="col-sm-2 control-label">Additional Checkin Step Title [<?php echo $lang['name']; ?>]</label>
                          <?php $addcheckintitle = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                          <div class="col-sm-10">
                            <input type="text"  class="form-control" name="add_checkin_title_<?php echo $lang['id']; ?>" value="<?php if($addcheckintitle['add_checkin_title']!=''){ echo $addcheckintitle['add_checkin_title']; } elseif($eventDetail['add_checkin_title']!=''){ echo $eventDetail['add_checkin_title']; } ?>">
                          </div>
                        </div>
                  <?php } } ?>
                  <?php if(!empty($languages)){ 
                      foreach ($languages as $lang) { ?>
                        <div class="form-group">
                          <label class="col-sm-2 control-label">Additional Checkin Step Info [<?php echo $lang['name']; ?>]</label>
                          <?php $addcheckininfo = getValue('evt_language_values',array('lang_id'=>$lang['id'],'event_id'=>$eventDetail['id'])); ?>
                          <div class="col-sm-10">
                            <input type="text"  class="form-control" name="add_checkin_info_<?php echo $lang['id']; ?>" value="<?php if($addcheckininfo['add_checkin_info']!=''){ echo $addcheckininfo['add_checkin_info']; } elseif($eventDetail['add_checkin_info']!=''){ echo $eventDetail['add_checkin_info']; } ?>">
                          </div>
                        </div>
                  <?php } } ?>
                   <div class="form-group">
                      <label class="col-sm-2 control-label">Additional Checkin Step Price</label>
                      <div class="col-sm-4">
                          <input type="text" name="add_checkin_price" id="add_checkin_price" value="<?php echo $eventDetail['add_checkin_price']; ?>">
                      </div>
                   </div>
                   <div class="form-group">
                      <label class="col-sm-2 control-label">Additional Checkin Step Picture</label>
                      <div class="col-sm-10">
                        <?php if($eventDetail['add_checkin_picture']){ ?>
                        <img src="<?php echo base_url(); ?>assets/userfiles/<?php echo $eventDetail['add_checkin_picture'];?>" width="100">
                      <?php } ?>
                          <input type="file" class="form-control" id="add_checkin_picture" name="add_checkin_picture" >

                      </div>
                   </div>
                   <div class="form-group">
                      <label class="col-sm-2 control-label">Show Additional Checkin Step</label>
                      <div class="col-sm-10">
                          <input type="checkbox" class="" id="show_addion_step" name="show_addion_step" value="1" <?php if($eventDetail['show_addion_step']==1){ echo 'checked'; }?>>
                      </div>
                   </div>
                   <div class="form-group">
                      <label class="col-sm-2 control-label">Additional Checkin Is Mandatory</label>
                      <div class="col-sm-10">
                          <input type="checkbox" class="" id="additonal_step_is_mandatory" name="additonal_step_is_mandatory" value="1" <?php if($eventDetail['additonal_step_is_mandatory']==1){ echo 'checked'; }?>>
                      </div>
                   </div>
                  <div class="form-group">
                      <label class="col-sm-2 control-label">Event Unique ID</label>
                      <div class="col-sm-3">
                          <input type="text" class="" id="event_unique_id" name="event_unique_id" value="<?php if($eventDetail['event_unique_id']){ echo $eventDetail['event_unique_id']; }?>" >
                      </div>
                  </div>
              </div>
              
              <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="Edit" 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%;

    }
    /* The switch - the box around the slider */
.switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 17px;
}

/* Hide default HTML checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 13px;
  width: 13px;
  left: 2px;
  bottom: 3px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

    </style>

   <script type='text/javascript'>
      $("#add_frm").validate({
        rules: {
          <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
          name_<?php echo $lang['id']; ?>: {
            required: true,
          },
          <?php } } ?>
          <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
          content_<?php echo $lang['id']; ?>: {
            required: true,
          },
          <?php } } ?>
          'location_id[]':{
            required:true
          },
          'services[]':{
            required:true
          },
          fromDate:{
            required:true
          },
          toDate:{
            required:true
          },
          basic_drinking:{
            required:true,
            number:true,
          },
          premium_drinking:{
            required:true,
            number:true,
          },
        }
      });
      $(function(){
        $("#fromDate").datetimepicker();
        $("#toDate").datetimepicker({
          minDate: $("#fromDate").val(),
        });

        $("#discount_end_date").datetimepicker({
          timepicker:false,
           formatDate:'Y/m/d',
           minYear:'2019'
        });
        
        $('.past').multiselect();
      });
    </script>

   <script type="text/javascript">
    function return_back()
    {
      var back_url='<?php echo base_url()?>admin/event';
      window.location=back_url;
    }
   </script>
   <script src="<?php echo base_url()?>assets/js/simple-rating.js"></script>
   <link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/css/simple-rating.css">

    <script type="text/javascript">
      $(document).ready(function(){
        $('.rating').rating();
        var rating = '<?php if($eventDetail['rating']!=''){ echo $eventDetail['rating']; } ?>';
        if(rating > 0){
          $("[data-rating = "+rating+"]").click();
        }
      });
    </script>
   <style type="text/css">
   .multiselect-container {background: #131217;height: 200px; overflow-y: scroll; overflow-x: hidden;}
   .multiselect-container input[type="checkbox"] { margin-left: -20px !important; margin-right: 0 !important;}
   .box-footer .btn.btn-default, .btn.btn-default:hover {
    color: #ffffff;
    background-color: #ff6600 !important;
    border-color: #ff9630 !important;
    border-radius: 0 !important;
    text-transform: uppercase !important;
}
.dropdown-menu > li > a {
    color: #b3975b;
}
button.multiselect {
    background: #22222c;
    border-color: #b3975b;
    color: #b3975b;
    margin-left: -7px !important;
}
   </style>