<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>

        Side 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/side_event');?>">Side 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="form-group">

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

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

                    <select class="form-control" name="event_id[]" multiple="" id="event_id">
                    <?php if(!empty($events))
                          foreach ($events as $event) {
                           echo '<option value="'.$event['id'].'" '.((in_array($event['id'], $eventDetail['events']))?'selected':'').'>'.$event['title'].'</option>';
                          }
                      ?>
                    </select>

                  </div>

                </div>
              <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('side_events_lang_values',array('lang_id'=>$lang['id'],'side_event_id'=>$eventDetail['id'])); ?>
                    <input type="text" class="form-control" id="title" name="title_<?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('side_events_lang_values',array('lang_id'=>$lang['id'],'side_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">Description [<?php echo $lang['name']; ?>]</label>

                  <div class="col-sm-10">
                  <?php $title = getValue('side_events_lang_values',array('lang_id'=>$lang['id'],'side_event_id'=>$eventDetail['id'])); ?>
                  <textarea name="description<?php echo $lang['id']; ?>" class="form-control"><?php if($title['description']!=''){ echo $title['description']; } else { echo $eventDetail['description']; } ?></textarea>
                  <script>
                           CKEDITOR.replace( 'description<?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();?>/<?php echo $eventDetail['image']; ?>" width="200">
                    <input type="file" class="form-control" id="image" name="image" >

                  </div>

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

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

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

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

                  </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%;

    }

    </style>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js"></script>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css" />
   <script type='text/javascript'>
      $('#event_id').multiselect();
      $("#add_frm").validate({
        rules: {
          <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
          title_<?php echo $lang['id']; ?>: {
            required: true,
          },
          <?php } } ?>
          <?php if(!empty($languages)){ 
                  foreach ($languages as $lang) { ?>
          subtitle<?php echo $lang['id']; ?>: {
            required: true,
          },
          <?php } } ?>
          location_id:{
            required:true
          },
        }
      });
    </script>

   <script type="text/javascript">
    function return_back()
    {
      var back_url='<?php echo base_url()?>admin/side_event';
      window.location=back_url;
    }
   </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>