<script src="https://cdn.ckeditor.com/4.7.1/standard/ckeditor.js"></script>
<section class="content-header">
  <h1>Shop Article</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/shop');?>">Shop</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>
      <div class="box box-info">
        <div class="box-header with-border">
          <h3 class="box-title">Edit </h3>
        </div>
        <form id="add_cat_add" name="add_cat_add" class="form-horizontal" method="post" action="" enctype="multipart/form-data" onsubmit="return formValidate();">
           <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Meta Title [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('shop_lang_values',array('lang_id'=>$lang['id'],'shop_id'=>$shopDetails['shop_id']));?>
              <input type="text" class="form-control required" required id="meta_title_<?php echo $lang['id']; ?>" name="meta_title_<?php echo $lang['id']; ?>" value="<?php if(!empty($title['meta_title'])){ echo $title['meta_title']; }?>" placeholder="Please enter meta title" style="width:680px;">
                <p style="color:#b3975b !important">Please enter details with comma seperators</p>
              </div>
            </div>
          </div>
          <?php } } ?> 
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Meta Description [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
             <?php $title = getValue('shop_lang_values',array('lang_id'=>$lang['id'],'shop_id'=>$shopDetails['shop_id']));?>
             <textarea name="meta_description_<?php echo $lang['id']; ?>" id="meta_description_<?php echo $lang['id']; ?>" class="form-control required" required style="width:680px;height:175px;"><?php if(!empty($title['meta_desc'])){ echo $title['meta_desc']; }?></textarea>
              </div>
            </div>
          </div>
          <?php } } ?>
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?> 
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Title [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('shop_lang_values',array('lang_id'=>$lang['id'],'shop_id'=>$shopDetails['shop_id']));?>
              <input type="text" name="title_<?php echo $lang['id']; ?>" id="title_<?php echo $lang['id']; ?>" class="form-control required" required style="width:680px;" value="<?php if(!empty($title['title'])){ echo $title['title']; }?>">
              </div>
            </div>
          </div>
          <?php } } ?>
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Description [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-8">
              <?php $title = getValue('shop_lang_values',array('lang_id'=>$lang['id'],'shop_id'=>$shopDetails['shop_id']));?>
             <textarea name="desc_<?php echo $lang['id']; ?>" id="desc_<?php echo $lang['id']; ?>" class="form-control required" required style="width:680px;height:175px;"><?php if(!empty($title['description'])){ echo $title['description']; }?></textarea>
              <script>
                           CKEDITOR.replace( '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>
          </div>
          <?php } } ?>

          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Link</label>
              <div class="col-sm-6">
              <input type="text" class="form-control required" required id="link" name="link" value="<?php if(!empty($shopDetails['link'])){ echo $shopDetails['link']; }?>" placeholder="Please enter link" style="width:680px;">
              </div>
            </div>
          </div>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Images</label>
              <div class="col-sm-10">
                <input type="file" class="form-control" id="logofile" name="userfile[]" value="" multiple>
                ( SELECT MULTIPLE BY PRESS CTRL+ SELECT)<br/><br/><br/>
                <?php if(count($shopImages)>0){
                        foreach ($shopImages as $key => $value) { ?>
                           <div class="col-md-6">
                            <img src="<?php echo base_url(); ?>assets/userfiles/img/shop/<?php echo $value['filename']; ?>" class="img-responsive">
                            <a href="<?php echo  base_url();?>admin/shop/imgDelete/<?php echo base64_encode($value['imgId']); ?>/<?php echo str_replace('/','-',uri_string()); ?>" class="" onclick="return confirm('Are you sure')">
                              <i class="fa fa-trash tooltipstered"></i>
                            </a>
                          </div>
                          
                <?php   } 
                      }
                 ?> 
              </div>
            </div>
          </div>
          <div class="box-footer">
            <button type="button" onclick="return_back()"class="btn btn-default  margin-left  " >Cancel</button>
            <input type="submit" class="btn btn-info " value="Edit" id="add">
          </div>
        </form>
      </div>
    </div>
  </div>
</section>
 <script type='text/javascript'>
  $("#add_cat_add").validate();
  
</script>
 <script type="text/javascript">
  function return_back(){
    var back_url='<?php echo base_url()?>admin/shop';
    window.location=back_url;
  }
 </script>