<?php $this->load->view('includes/header'); ?>
<div class="page-title">
  <h2><span><?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>Add</span></a>    
  </div>
</div>
<!-- PAGE CONTENT WRAPPER -->
<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("sitepanel/category/add/" . $parent_id, 'class="form-horizontal" id="catForm"'); ?>  
          <div id="tab_pinfo">
            <div class="row">
              <div class="col-md-10 col-md-offset-1">
                <?php
                $default_params = array(
                    'heading_element' => array(
                        'field_heading' => "Name",
                        'field_name' => "category_name",
                        'field_placeholder' => "Your Catgeory Name",
                        'exparams' => 'size="40"'
                    ),
                    'url_element' => array(
                        'field_heading' => "Page URL",
                        'field_name' => "friendly_url",
                        'field_placeholder' => "Your Page URL",
                        'exparams' => 'size="40"',
                        'pre_seo_url' => '',
                        'pre_url_tag' => FALSE
                    )
                );
                if (is_array($parentData)) {
                  $pre_seo_url = base_url() . $parentData['friendly_url'] . "/";
                  $default_params['url_element']['pre_seo_url'] = $pre_seo_url;
                  $default_params['url_element']['pre_url_tag'] = TRUE;
                  $default_params['url_element']['exparams'] = 'size="30"';
                }
                seo_add_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="" checked name="catType"  value="0" /> Product &nbsp;&nbsp;
                    <input type="radio" class="" 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'); ?></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-9">
                    <input type="file" class="fileinput btn-primary" name="category_image"  title="Browse file"/>
                    <br />
                    <br />
                    [ <?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-9">
                    <input type="file" class="fileinput btn-primary" name="category_icon"  title="Browse file"/>
                    <br />
                    <br />
                    [ ( 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'); ?>"  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_keyword'); ?></textarea><?php echo form_error('meta_keyword') ?>
                  </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'); ?>"  title="Meta Keyword"/><?php echo form_error('meta_keyword') ?>
                  </div>
                </div>

                <div class="form-group">
                  <label class="col-md-3 control-label"></label>
                  <div class="col-md-9">
                    <input type="submit" name="sub" class="btn btn-success pull-right" value="Add" class="button2" />
                    <input type="hidden" name="action" value="addcategory" />
                    <?php
                    if (is_array($parentData)) {
                      ?>
                      <input type="hidden" name="parent_id" value="<?php echo $parentData['category_id']; ?>" />
                      <?php
                    }
                    ?>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <?php echo form_close(); ?>                                
        </div>
      </div>
    </div>
  </div>                    
</div>
<!-- END PAGE CONTENT WRAPPER --> 
<?php $this->load->view('includes/footer'); ?>
<script type="text/javascript">
  $('.addbtn').click(function(){
    $('#catForm').submit();
  });
</script>