<?php
$this->load->view('includes/header');
$values_posted_back = (is_array($this->input->post())) ? TRUE : FALSE;
?>
<div class="page-title">
  <h2><span>Edit <?php echo $heading_title; ?></span></h2>
  <div class="buttons">
    <?php echo anchor("sitepanel/category/", '<span>Cancel</span>', 'class="btn btn-danger pull-right" '); ?>
    <a href="javascript:void(0);" class="btn btn-success addbtn pull-right"><span>Update</span></a>
  </div>
</div>

<div class="page-content-wrap">
  <div class="row">
    <div class="col-md-12">
      <div class="panel panel-default">
        <div class="panel-body">  
          <?php echo form_open_multipart(current_url_query_string(), array('id' => 'catfrm', 'name' => 'catfrm', 'class' => "form-horizontal")); ?>
          <div id="tab_pinfo">
            <div class="row">
              <div class="col-md-10 col-md-offset-1">
                <?php
                //echo $catresult['category_id'];
                $default_params = array(
                    'heading_element' => array(
                        'field_heading' => $heading_title . " Name",
                        'field_name' => "category_name",
                        'field_value' => $catresult['category_name'],
                        'field_placeholder' => "Your Catgeory Name",
                        'exparams' => 'size="40"',
                        'cat_id' => $catresult['category_id']
                    ),
                    'url_element' => array(
                        'field_heading' => "Page URL",
                        'field_name' => "friendly_url",
                        'field_value' => $catresult['friendly_url'],
                        'field_placeholder' => "Your Page URL",
                        'exparams' => 'size="40"',
                    )
                );
                seo_edit_form_element($default_params);
                ?>
                <div class="form-group">
                  <label class="col-md-3 control-label">Category Type</label>
                  <div class="col-md-9">
                    <input type="radio" class="" <?php echo ($catresult['catType'] == '0') ? 'checked' : ''; ?> name="catType"  value="0" /> Product &nbsp;&nbsp;
                    <input type="radio" class="" <?php echo ($catresult['catType'] == '1') ? 'checked' : ''; ?> name="catType"  value="1" />Service
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-md-3 col-xs-12 control-label">Description</label>
                  <div class="col-md-6 col-xs-12">                                            
                    <textarea name="category_description" rows="5" cols="50" id="cat_desc" ><?php echo set_value('category_description', $catresult['category_description']); ?></textarea> <?php echo display_ckeditor($ckeditor); ?>
                    <?php echo form_error('category_description'); ?>
                  </div>
                </div>

                <div class="form-group">
                  <label class="col-md-3 control-label">File</label>
                  <div class="col-md-3">
                    <input type="file" class="fileinput btn-primary" name="category_image" />
                  </div>

                  <?php
                  if ($catresult['category_image'] != '' && file_exists(UPLOAD_DIR . "/category/" . $catresult['category_image'])) {
                    ?>
                    <div class="col-md-3">
                      <a href="#" data-toggle="modal" data-target=".pop-up-1">
                        <img src="<?php echo base_url() . 'uploaded-files/category/' . $catresult['category_image']; ?>" width="150" class="img-responsive img-rounded center-block" alt="">
                      </a>
                    </div>
                    <?php
                    if ($this->deletePrvg === TRUE) {
                      ?>
                      <div class="col-md-3">
                        <input type="checkbox"  name="cat_img_delete" value="Y">
                        Delete
                      </div>
                      <?php
                    }
                  }
                  ?>
                  <div class="col-md-9 col-md-offset-3 pull-left">
                    [ <?php echo $this->config->item('category.best.image.view'); ?> ]
                  </div>
                </div>

                <div class="form-group">
                  <label class="col-md-3 control-label">Category Icon</label>
                  <div class="col-md-3">
                    <input type="file" class="fileinput btn-primary" name="category_icon" />
                  </div>

                  <?php
                  if ($catresult['category_icon'] != '' && file_exists(UPLOAD_DIR . "/category/" . $catresult['category_icon'])) {
                    ?>
                    <div class="col-md-6">
                      <a href="#" data-toggle="modal" data-target=".pop-up-1">
                        <img src="<?php echo base_url() . 'uploaded-files/category/' . $catresult['category_icon']; ?>" width="52" class="img-responsive img-rounded center-block" alt="">
                      </a>
                    </div>
                    <?php
                  }
                  ?>
                  <div class="col-md-9 col-md-offset-3 pull-left">
                    [ ( File should be .jpg, .png, .gif format and file size should not be more then 100 KB) ( Best image size 52X52 or in Similar Ratio ) ]
                  </div>
                </div>


                <div class="form-group" style="background:#eee">
                  <label class="col-md-6 control-label"><strong>SEO Parameters</strong></label>
                </div>
                <div class="form-group">
                  <label class="col-md-3 control-label">Meta Title</label>
                  <div class="col-md-6"> <input type="text" class="form-control" name="meta_title" value="<?php echo set_value('meta_title', $metaDets['meta_title']); ?>"  title="Meta Title"/><?php echo form_error('meta_title') ?>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-md-3 control-label">Meta Description</label>
                  <div class="col-md-6"> <textarea class="form-control" name="meta_description"><?php echo set_value('meta_description', $metaDets['meta_description']); ?></textarea><?php echo form_error('meta_description') ?>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-md-3 control-label">Meta Keyword</label>
                  <div class="col-md-6"> <input type="text" class="form-control" name="meta_keyword" value="<?php echo set_value('meta_keyword', $metaDets['meta_keyword']); ?>"  title="Meta Keyword"/><?php echo form_error('meta_keyword') ?>
                  </div>
                </div>

                <div class="form-group">
                  <div class="col-md-6 col-md-offset-3">
                    <input type="submit" name="sub" class="btn btn-success pull-right" value="Update" class="button2" />
                    <input type="hidden" name="action" value="editcategory" />
                    <input type="hidden" name="category_id" id="pg_recid" value="<?php echo $catresult['category_id']; ?>">
                  </div>
                </div>                      
              </div>
            </div>
          </div>
          <?php echo form_close(); ?>                              
        </div>                              
      </div>                    
    </div>                                
  </div>
</div>
<!-- END PAGE CONTENT WRAPPER -->
<div class="modal fade pop-up-1" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel-1" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h4 class="modal-title" id="myLargeModalLabel-1">Image</h4>
      </div>
      <div class="modal-body">
        <img src="<?php echo base_url() . 'uploaded-files/category/' . $catresult['category_image']; ?>" class="img-responsive img-rounded center-block" alt="">
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal mixer image -->
<script type="text/javascript">
  $(document).ready(function () {
    $('#catfrm').submit(function (e) {
      e.preventDefault();
      var frmObj = this;
      $('#brand_id option:eq(0),#frame_material_id option:eq(0),#frame_type_id option:eq(0)').attr('selected', false);
      frmObj.submit();
    });
    $('.addbtn').click(function () {
      $('#catfrm').submit();
    });
  });
</script>
<?php $this->load->view('includes/footer'); ?>