<?php

/* 
 * Author       : Jai K
 * Purpose      : The Edir page for Expense Type
 * Created On   : 2017-01-25 16:05    
 */

?>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><a href="<?php echo base_url() . $controller; ?>" class="list-btn"><i class="fa fa-list" title="Go to Listing"></i></a><?php echo $title; ?> - Edit</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <form action="<?php echo $form_action;?>" method="post" enctype="multipart/form-data" onsubmit="return validate(this);">    
                    <input type="hidden" name="token" value="<?php echo $token; ?>" />    
                    <div class="box box-danger">
                        <div class="box-body">
                            <?php if( !empty( $success ) || !empty( $error ) ) : ?>
                                <div class="alert alert-<?php echo !empty( $success ) ? 'success' : 'danger'; ?> alert-dismissable">
                                    <i class="fa fa-thumbs-o-<?php echo !empty( $success ) ? 'up' : 'down'; ?>"></i>
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                    <h4><?php echo !empty( $success ) ? $success : $error; ?></h4>
                                </div>
                            <?php endif; ?>
                            
                            <ul class="error_container"></ul>
                            <div class="col-xs-12">
                                <div class="col-md-6">
                                    <div class="form-group float-clear">
                                        <label>Ref. No</label>
                                        <input type="text" class="form-control readonly" name="exp_rec_no" placeholder="Auto Generated" readonly value="<?php echo $edit_data->exp_rec_no; ?>" />
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Type<span class="required">*</span></label>
                                        <select name="exp_type" class="form-control select2 req">
                                            <option value="">-- Select Expense Type --</option>
                                            <?php foreach($expense_types as $key => $types) {?>
                                                <option value="<?php echo $types->id;?>" <?php echo ($types->id == $edit_data->exp_type_id) ? 'selected' : '';?>><?php echo $types->type_name;?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group float-clear" id="exp-type-add" style="display: none;">
                                        <label>&nbsp;</label>
                                        <input type="text" class="form-control" name="exp_type_add" placeholder="New Type" />
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Subject<span class="required">*</span></label>
                                        <select name="exp_sub" class="form-control select2 req" data-slug="<?php echo $edit_data->exp_sub_slug; ?>">
                                            <option value="">-- Select Expense Subject --</option>
                                            <option value="add" style="color: #f33;">-- Add New --</option>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group float-clear" id="exp-sub-add" style="display: none;">
                                        <label>&nbsp;</label>
                                        <input type="text" class="form-control" name="exp_sub_add" placeholder="New Subject" />
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Name<span class="required">*</span></label>
                                        <input type="text" class="form-control req" name="exp_name" placeholder="Expense Name" value="<?php echo $edit_data->exp_name; ?>" />
                                    </div>
                                    
                                    <div class="form-group float-clear deposit_mode" style="display:<?php echo ($edit_data->mode == 1 || $edit_data->mode == 2) ?  'block':  'none';?>">
                                        <label>Mode<span class="required">*</span></label>
                                        <select name="mode" class="form-control select2">
                                            <option value="">-- Select Mode --</option>
                                                <option value="1" <?php echo ($edit_data->mode == 1) ? 'selected' : '' ?>>Cash</option>
                                                <option value="2" <?php echo ($edit_data->mode == 2) ? 'selected' : '' ?>>Cheque</option>
                                        </select>
                                    </div>
                                    
                                    <div class="cheque_details" style="display:<?php echo ($edit_data->mode == 2) ?  'block':  'none';?>">
                                        <div class="form-group float-clear">
                                            <label>Cheque No<span class="required">*</span></label>
                                            <input type="text" class="form-control num-pad" name="cheque_no" value="<?php echo $edit_data->cheque_no;?>" />
                                        </div>
                                    </div>
                                </div>
                                
                                <div class="col-md-6">
                                    <div class="form-group float-clear">
                                        <label>Date<span class="required">*</span></label>
                                        <div class="input-group">
                                            <input type="text" class="form-control date-picker req" name="exp_date" placeholder="dd/mm/yyyy" value="<?php echo date("d-m-Y", strtotime($edit_data->exp_date)); ?>" />
                                            <div class="input-group-addon"><i class="fa fa-calendar"></i></div>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Amount</label>
                                        <input type="text" class="form-control amount num-pad" name="exp_amount" placeholder="0.00" value="<?php echo $edit_data->exp_amount; ?>" />
                                    </div>
                                    
                                    <div class="form-group float-clear">
                                        <label>Description</label>
                                        <textarea class="form-control" name="exp_desc"><?php echo $edit_data->exp_desc; ?></textarea>
                                    </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 $edit_data->status == '1' ? 'checked' : ''; ?> /> &nbsp;&nbsp;Active</label> 
                                            <label for="status" style="width: 32%;"><input type="radio" name="status" value="0"  <?php echo $edit_data->status == '0' ? 'checked' : ''; ?>/> &nbsp;&nbsp;Inactive</label> 
                                        </div>
                                    </div>
                                    
                                    <div class="cheque_details" style="display:<?php echo ($edit_data->mode == 2) ?  'block':  'none';?>;">
                                        <div class="form-group float-clear">
                                            <label>Bank Name<span class="required">*</span></label>
                                            <input type="text" class="form-control" name="cheque_bank" value="<?php echo $edit_data->bank_name;?>" />
                                        </div>
                                        
                                        <div class="form-group float-clear">
                                            <label>Cheque Date<span class="required">*</span></label>
                                            <div class="input-group">
                                                <input type="text" class="form-control date-picker" name="cheque_date" placeholder="dd/mm/yyyy" value="<?php echo ($edit_data->cheque_date != '1970-01-01 00:00:00') ? (date("d-m-Y",strtotime($edit_data->cheque_date))) : ''; ?>" />
                                                <div class="input-group-addon"><i class="fa fa-calendar"></i></div>
                                            </div>
                                        </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>
<script type="text/javascript" src="<?php echo BASE_URL;  ?>assets/js/expenses.js"></script>
