<script type="text/javascript" src="<?php echo base_url();?>assets/js/item.js"></script>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color">Item Edit</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <?php $general = get_general_setting();?>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <form action="<?php echo $form_action;?>" method="post" name="item_form" enctype="multipart/form-data" method="post" onsubmit="return autoValidate();">        
                    <input type="hidden" name="hidden_item_id" value="<?php echo $item->id;?>" />    
                    <div class="box box-danger">
                        <div class="box-body">
                            <ul class="error_container"></ul>
                            <div class="col-xs-12">
                                <div class="col-md-6">
                                    <?php if($general->is_category == 1) {?>
                                        <div class="form-group float-clear">
                                            <label>Category Name<span class="required">*</span></label>
                                            <select name="category_id" class="form-control select2">
                                                <option value="">Select Category Name</option>
                                                    <?php foreach($category as $key=>$value) {?>
                                                        <option value="<?php echo $value->id;?>" <?php echo ($value->id == $item->category_id) ? 'selected' : '';?>><?php echo $value->category_name;?></option>
                                                    <?php } ?>
                                            </select>
                                        </div>
                                    <?php } ?>
                                    <div class="form-group float-clear">
                                        <label>Name<span class="required">*</span></label>
                                        <input type="text" class="form-control"  name="item_name" placeholder="Name" value="<?php echo $item->name;?>" />
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Name (T)</label>
                                        <div class="input-group">
                                            <input type="text" class="form-control multi tamil-name input-tamil"  name="tamil_item_name" placeholder="jkpH;bgah;" value="<?php echo $item->tamil_name;?>" onclick="set_tamil_keypad(this);" />
                                            <div class="input-group-addon"><i class="fa fa-keyboard-o"></i></div>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Price<span class="required">*</span></label>
                                        <div class="input-group">
                                            <div class="input-group-addon">$</div>
                                            <input type="text" class="form-control float_value" name="price" value="<?php echo $item->price;?>" />
                                        </div>
                                    </div>
                                    
                                    <!--<div class="form-group float-clear">
                                        <label>Priority</label>
                                        <select name="proirity" class="form-control select2">
                                            <option value="">Select</option>
                                            <option value="1">1</option>
                                            <option value="2">2</option>
                                        </select>
                                    </div>-->
                                    
                                    <div class="form-group float-clear">
                                        <label>Receipt</label>
                                        <select name="receipt" class="form-control select2">
                                            <option value="1" <?php echo ($item->receipt == 1) ? 'selected' : '';?>>With Name</option>
                                            <option value="0" <?php echo ($item->receipt == 0) ? 'selected' : '';?>>Without Name</option>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Inventory</label>
                                        <input type="checkbox" class="form-control" name="is_inventory" value="1" <?php echo ($item->is_inventory == 1) ? 'checked' : '';?> />
                                    </div>
                                    
                                    <div class="form-group float-clear" id="inv-cat-wrap" <?php echo $item->is_inventory == 1 ? '' : 'style="display: none;"'; ?> >
                                        <label>Inventory Category Name<span class="required">*</span></label>
                                        <select name="inv_cat" class="form-control select2 <?php echo $item->is_inventory == 1 ? 'req' : ''; ?>" >
                                            <option value="">Select Inv. Category Name</option>
                                            <?php foreach( $inv_cats as $k => $inv_cat ) : ?>
                                                <option value="<?php echo $inv_cat['id']; ?>"><?php echo $inv_cat['name']; ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                        <input type="hidden" name="inv_item" value="<?php echo $item->is_inventory == 1 ? $item->inv_item_id : ''; ?>" />
                                    </div>
                                    
                                    <div class="form-group form_group_div" style="display:<?php echo ($general->is_category == 1) ? 'none' : 'block';?>">
                                        <label>Color (Top)</label>
                                        <div class="input-group colorpicker" style="padding-left: 12px;">
                                            <input type="text" class="form-control my-colorpicker1" name="color_top" value="<?php echo ($general->is_category == 0) ? $item->item_top_color : 'rgba('.rand(0,180).','.rand(0,180).','.rand(0,180).',1)'; ?>" style="width: 258px;" />
                                            <div class="input-group-addon"><i></i></div>
                                        </div><!-- /.input group -->
                                    </div>
                                    
                                    <div class="form-group form_group_div" style="display:<?php echo ($general->is_category == 1) ? 'none' : 'block';?>">
                                        <label>Color (Bottom)</label>
                                        <div class="input-group colorpicker" style="padding-left: 12px;">
                                            <input type="text" class="form-control my-colorpicker1" name="color_bottom" value="<?php echo ($general->is_category == 0) ? $item->item_bottom_color : 'rgba('.rand(0,180).','.rand(0,180).','.rand(0,180).',1)'; ?>" style="width: 258px;" />
                                            <div class="input-group-addon"><i></i></div>
                                        </div><!-- /.input group -->
                                    </div>
                                    
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="form-group float-clear">
                                        <label>Footer Receipt</label>
                                        <input type="checkbox" class="form-control" name="is_enable" value="1"  <?php echo ($item->is_enable_footer == 1) ? 'checked' : '';?> />
                                    </div>
                                    <div class="form-group float-clear">
                                        <label>God Name</label>
                                        <select name="god_name" class="form-control select2">
                                            <option value="1" <?php echo ($item->god_name == 1) ? 'selected' : '';?>>With God Name</option>
                                            <option value="0" <?php echo ($item->god_name == 0) ? 'selected' : '';?>>Without God Name</option>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Order Sequence</label>
                                        <input type="text" class="form-control integer_value" name="seq_no" maxlength="50" value="<?php echo $item->order_sequence;?>" />
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Prefix</label>
                                        <input type="text" class="form-control" name="prefix" value="<?php echo $item->prefix;?>" />
                                    </div>
                                    
                                    <div class="form-group">
                                        <label>Upload Image</label>
                                       <input type="file" class="form-control img_file" value="<?php echo $item->image;?>" data-value="<?php echo $item->image;?>" name="image" data-allowed_exetnsions="<?php echo implode('|', image_extensions());?>" />
                                        <!-- Eg: data-allowed_size 2 MB -->
                                        <div class="img_preview">
                                            <?php
                                            if ((!empty($item->image)) && (file_exists(FCPATH . DIR_ITEM_IMAGE . $item->image))) {
                                                $image_url = base_url() . DIR_ITEM_IMAGE . $item->image;
                                                $alt = 'No image not found!';   
                                            }
                                            else {
                                                $image_url = base_url() . NO_IMG;
                                                $alt = 'No image not found!';
                                            }
                                            ?>
                                            <img class="toggle" src="<?php echo $image_url;?>" alt="<?php echo $alt;?>" style="padding-left: 15%;" /><br />
                                            
                                            <?php if ((!empty($item->image)) && (file_exists(FCPATH . DIR_ITEM_IMAGE . $item->image))) { ?>
                                            <span><input type="checkbox" id="img_hide" name="img_delete" value="1"/>Delete</span>
                                             <?php } ?>
                                        </div>
                                        <span class="allowed_type">File should be <b><i><?php echo strtoupper(implode(', ', image_extensions()));?></i></b> file format</span>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="leftcol">Status</label>
                                        <div>
                                            <label for="status" style="width: 32%;"><input type="radio" name="status" value="1" <?php echo $item->status == "1" ? 'checked' : ''; ?>/> &nbsp;&nbsp;Active</label> 
                                            <label for="status" style="width: 32%;"><input type="radio" name="status" value="0" <?php echo $item->status == "0" ? 'checked' : ''; ?> /> &nbsp;&nbsp;Inactive</label> 
                                        </div>
                                    </div>
                                    
                                </div>
                            </div>
                        </div>
                        
                        <div class="box-footer form-actions float-clear">
                            <input class="btn reset" type="reset" value="Reset" />
                            <input type="submit" name="submit" value="Update" class="btn btn-success btn-primary" />
                        </div>
                    </div><!-- /.box -->
                </form>
            </div><!-- /.col-xs-12 -->
        </div><!-- /.row -->
    </section><!-- /.content -->
</aside>
<style>
    .colorpicker:before {
        display: none;
    }
</style>