<?php $currency_symbol = $this->customlib->getSchoolCurrencyFormat(); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            <i class="fa fa-credit-card"></i> Asset</h1>
								<a href="<?php  echo base_url(); ?>book_depreciation/" class="col-md pull-right">Book Depreciation</a>
								<b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								<a href="<?php  echo base_url(); ?>asset/" class="col-md pull-right">Add Asset</a>
								<b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>												 
								 <a href="<?php  echo base_url(); ?>assettypes/" class="col-md pull-right">Asset Types</a> 
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>depreciationmethods/" class="col-md pull-right">Depreciation Methods</a>	
								 <a href="<?php  echo base_url(); ?>location/" class="col-md pull-right">Employee</a>	
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>department/" class="col-md pull-right">Department</a>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
		<?php
            if ($this->rbac->hasPrivilege('class', 'can_add')) {
                ?> 
            <div class="col-md-12">
                <!-- Horizontal Form -->
                <div class="box box-primary">
				    <div style="padding:10px;">
						<a href="<?php echo base_url(); ?>asset/viewasset" class="btn btn-primary btn-sm pull-right"><i class="fa fa-eye"></i> View Assets</a>
                    </div>
                    <div class="box-header with-border">
                        <h3 class="box-title">Edit Asset</h3>
                    </div><!-- /.box-header -->
				<?php  
				 foreach ($asset->result() as $dep_row)  
					 {   
					?>
                    <form id="form1" action="<?php echo site_url('asset/edit/' . $dep_row->id) ?>"  id="employeeform" name="employeeform" method="post" accept-charset="utf-8">
                         <div class="box-body">
                                <?php if ($this->session->flashdata('msg')) { ?>
                                    <?php echo $this->session->flashdata('msg') ?>
                                <?php } ?>
                                <?php
                                if (isset($error_message)) {
                                    echo "<div class='alert alert-danger'>" . $error_message . "</div>";
                                }    
                                ?>
                                <?php echo $this->customlib->getCSRF(); ?>     
						
                            <div class="tshadow mb25 bozero">    
                                <h4 class="pagetitleh2"> Edit Asset </h4>
                                <div class="around10">
									<div class="row">
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Asset Code</label> <small class="req"> *</small> 
                                                <input autofocus="" id="asset_code" name="asset_code" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->asset_code; ?>" />
                                                <span class="text-danger"><?php echo form_error('asset_code'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Descripiton</label> 
                                                <input id="description" name="description" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->description; ?>" />
                                                <span class="text-danger"><?php echo form_error('description'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Asset Type</label><small class="req"> *</small> 
                                                <select  id="asset_type" name="asset_type" class="form-control"  >
                                                    <option value="<?php echo $dep_row->asset_type; ?>"><?php echo $dep_row->asset_type; ?></option>
                                                    <?php
                                                    foreach ($asset_type->result() as $asset) {
                                                        ?>
                                                        <option> <?php echo $asset->asset_code; ?></option>
                                                        <?php
                                                    }
                                                    ?>
                                                </select>
                                                <span class="text-danger"><?php echo form_error('asset_type'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Master Asset</label><small class="req"> *</small> 
                                                <input id="master_asset" name="master_asset" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->master_asset; ?>" />
                                                <span class="text-danger"><?php echo form_error('master_asset'); ?></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Number of Units</label><small class="req"> *</small> 
                                                <input id="units_num" name="units_num" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->units_num; ?>" />
                                                <span class="text-danger"><?php echo form_error('units_num'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Serial Number</label>
                                                <input id="serial_num" name="serial_num" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->serial_num; ?>" />
                                                <span class="text-danger"><?php echo form_error('serial_num'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputFile"> Department</label><small class="req"> *</small> 
                                                <select class="form-control" name="department">
                                                    <option value="<?php echo $dep_row->department; ?>"><?php echo $dep_row->department; ?></option>
                                                    <?php
                                                    foreach ($department->result() as $value) {
                                                        ?>
                                                        <option><?php echo $value->department; ?></option>
                                                        <?php
                                                    }
                                                    ?>
                                                </select>
                                                <span class="text-danger"><?php echo form_error('department'); ?></span>
                                            </div>
                                        </div>                                       
										<div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputFile"> Employee</label><small class="req"> *</small> 
                                                <select class="form-control" name="employee">
                                                    <option value="<?php echo $dep_row->employee; ?>"><?php echo $dep_row->employee; ?></option>
                                                    <?php
                                                    foreach ($employee->result() as $value) {
                                                        ?>
                                                        <option><?php echo $value->location; ?></option>
                                                        <?php
                                                    }
                                                    ?>
                                                </select>
                                                <span class="text-danger"><?php echo form_error('employee'); ?></span>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="row">
                                        <div class="col-md-2">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Supplier</label>
                                                <input id="supplier" name="supplier" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->supplier; ?>" />
                                                <span class="text-danger"><?php echo form_error('supplier'); ?></span>
                                            </div>
                                        </div>                                       
										<div class="col-md-2">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Capex Order</label>
                                                <input id="capex_order" name="capex_order" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->capex_order; ?>" />
                                                <span class="text-danger"><?php echo form_error('capex_order'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-2">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1">Purchase Price</label>
                                                <input id="purchase_price" name="purchase_price" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->purchase_price; ?>" />
                                                <span class="text-danger"><?php echo form_error('purchase_price'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Insured Value</label>
                                                <input id="insured_value" name="insured_value" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->insured_value; ?>" />
                                                <span class="text-danger"><?php echo form_error('insured_value'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Scrap Value</label>
                                                <input id="scrap_value" name="scrap_value" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->scrap_value; ?>" />
                                                <span class="text-danger"><?php echo form_error('scrap_value'); ?></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                         <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Revaluation</label>
                                                <input id="revaluation" name="revaluation" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->revaluation; ?>"/>
                                                <span class="text-danger"><?php echo form_error('revaluation'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Purchase Date</label>
                                                <input id="purchase_date" name="purchase_date" placeholder="" type="date" class="form-control"  value="<?php echo $dep_row->purchase_date; ?>"/>
                                                <span class="text-danger"><?php echo form_error('purchase_date'); ?></span>
                                            </div>
                                        </div>                                         
										<div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Replacement Date</label>
                                                <input id="replacement_date" name="replacement_date" placeholder="" type="date" class="form-control"  value="<?php echo $dep_row->replacement_date; ?>"/>
                                                <span class="text-danger"><?php echo form_error('replacement_date'); ?></span>
                                            </div>
                                        </div> 										
										<div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Replacement Cost</label>
                                                <input id="replacement_cost" name="replacement_cost" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->replacement_cost; ?>" />
                                                <span class="text-danger"><?php echo form_error('replacement_cost'); ?></span>
                                            </div>
                                        </div>   
                                    </div>                                  
									<div class="row">
                                         <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Base Cost</label>
                                                <input id="base_cost" name="base_cost" placeholder="" type="text" class="form-control"  value="<?php echo $dep_row->base_cost; ?>" />
                                                <span class="text-danger"><?php echo form_error('base_cost'); ?></span>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="exampleInputEmail1"> Roll Over Relief</label>
                                                <input id="roll_over_relief" name="roll_over_relief" placeholder="" type="date" class="form-control"  value="<?php echo $dep_row->roll_over_relief; ?>"/>
                                                <span class="text-danger"><?php echo form_error('roll_over_relief'); ?></span>
                                            </div>
                                        </div>                                         										  
                                    </div>

                                </div>
                            </div>																									
                            </div><!-- /.box-body -->

                        <div class="box-footer">
                            <button type="button" id="btnreset" class="btn btn-default"><?php echo $this->lang->line('reset'); ?></button>
                            <button type="submit" class="btn btn-info pull-right">Update</button>
                        </div>
                    </form>
					<?php } ?>
                </div>

            </div><!--/.col (right) -->
            <!-- right column -->
			<?php } ?>
        </div>
        <div class="row">
            <!-- left column -->

            <!-- right column -->
            <div class="col-md-12">

            </div><!--/.col (right) -->
        </div>   <!-- /.row -->
    </section><!-- /.content -->
</div><!-- /.content-wrapper -->

<script type="text/javascript">
    $(document).ready(function () {


        $("#btnreset").click(function () {
            $("#form1")[0].reset();
        });

    });
</script>
<script>
    $(document).ready(function () {
        $('.detail_popover').popover({
            placement: 'right',
            trigger: 'hover',
            container: 'body',
            html: true,
            content: function () {
                return $(this).closest('td').find('.fee_detail_popover').html();
            }
        });
    });
</script>