<?php
$this->load->view ( $left );
$this->load->view ( $header );
?>
<style type="text/css">
    .ibox-content {
        border-style : none;
    }

    .hr-line-dashed {
        margin: 5px 0;
    }
</style>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2><?php echo (@$catagory->id == '') ? 'New Color' : 'Edit Color';?></h2>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row text-center animated fadeInRightBig">
        <div class="col-lg-12">
            <form method="post" class="form-horizontal" id="category_data">
                <input type="hidden" name="id" id="id" class="form-control" value="<?=@$catagory->id?>">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Category</label>
                            <div class="col-sm-10">
                                <input type="text" name="name" id="name" class="form-control" placeholder="Category Name" value="<?=@$catagory->name?>" required="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Sort Order</label>
                            <div class="col-sm-10">
                                <input type="text" name="sort_order" id="sort_order" class="form-control" placeholder="Sort Order" value="<?=@$catagory->sort_order?>" required="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-lg-6 pull-right">
                                <div class="form-group">
                                    <div class="col-sm-12 col-sm-offset-2">
                                        <button class="btn btn-primary save_bank_details" type="button" data-status="1"><span class="m-l-xs">Save</span></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $this->load->view($footer); ?>
<script type="text/javascript">
    $(document).ready(function(){
        $('.save_bank_details').on('click',function(){
            if ($('#name').val() == '') {
                $('#name').parent().parent().addClass('has-error');
                return false;
            } else {
                $('#name').parent().parent().removeClass('has-error');
            }
            $.ajax({
                url: '<?php echo site_url('category/savecategory');?>',
                type: "POST",
                data:$('#category_data').serialize(),
                success: function(data){                  
                    window.location.href = '<?php echo site_url("category");?>';
                }
            });
        });
    });
</script>
