<script src="https://cdn.ckeditor.com/4.7.1/standard/ckeditor.js"></script>
<section class="content-header">
  <h1>Page Meta</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/page_meta');?>">Page Meta</a></li>
    <li class="active">Add</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_frm" name="add_frm" class="form-horizontal" method="post" action="" enctype="multipart/form-data" onsubmit="return formValidate();">
        
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Page Name</label>
              <div class="col-sm-6">
              
              <label class="form-control"><?php if($advertDetails){ echo $advertDetails['page_name']; }?></label>
              </div>
            </div>
          </div>
          <input type="hidden" class="form-control" name="name_page" value="<?php if($advertDetails){ echo $advertDetails['page_name']; }?>">
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Page Title [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('page_meta',array('lang_id'=>$lang['id'],'page_name'=>$advertDetails['page_name']));?>
              <input type="text" class="form-control required" required id="page_title" name="page_title_<?php echo $lang['id']; ?>" value="<?php if(!empty($title['page_title'])){ echo $title['page_title']; } else { echo $advertDetails['page_title']; }?>" placeholder="Please enter page 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">Meta Title [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('page_meta',array('lang_id'=>$lang['id'],'page_name'=>$advertDetails['page_name']));?>
              <input type="text" class="form-control required" required id="meta_title" name="meta_title_<?php echo $lang['id']; ?>" value="<?php if(!empty($title['meta_title'])){ echo $title['meta_title']; } else { echo $advertDetails['meta_title']; }?>" placeholder="Please enter meta 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">Meta Keywords [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('page_meta',array('lang_id'=>$lang['id'],'page_name'=>$advertDetails['page_name']));?>
              <input type="text" class="form-control required" required id="meta_keywords" name="meta_keywords_<?php echo $lang['id']; ?>" value="<?php if(!empty($title['meta_keywords'])){ echo $title['meta_keywords']; } else { echo $advertDetails['meta_keywords']; }?>" placeholder="Please enter meta keywords">
              </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 Decription [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('page_meta',array('lang_id'=>$lang['id'],'page_name'=>$advertDetails['page_name']));?>
              <textarea name="meta_desc_<?php echo $lang['id']; ?>" class="form-control"><?php if(!empty($title['meta_desc'])){ echo $title['meta_desc']; } else { echo $advertDetails['meta_desc']; }?></textarea>
                  <script>
                           CKEDITOR.replace( 'meta_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-footer">
            <button type="button" onclick="return_back()"class="btn btn-default  margin-left  " >Cancel</button>
            <input type="submit" class="btn btn-info " value="Update" id="add">
          </div>
        </form>
      </div>
    </div>
  </div>
</section>
 <script type='text/javascript'>
  $("#add_frm").validate({
        rules: {
          'meta_title': {
            required: true,
          },
          'meta_keywords': {
            required: true,
          },
          'meta_desc': {
            required: true,
          }
        }
      });
      
</script>
 <script type="text/javascript">
  function return_back(){
    var back_url='<?php echo base_url()?>admin/page_meta';
    window.location=back_url;
  }
 </script>