<?php

$AssetCode = '';
$AssetName = '';
$Description = '';
$Department = '';
$Location = '';
$User = '';
$SupplierName = '';
$DOPurchase = '';
$DOCommission = '';
$AssetValue = '';
$AssetStatus = '';
$IsActive ='';
$Remarks = '';
$DepartmentName ='';
$SupplierCode = '';
if(!empty($assetList))
{
    foreach ($assetList as $Asset)
    {
        $AssetCode = $Asset->AssetCode;
        $AssetName = $Asset->AssetName;
        $Description = $Asset->Description;
		$Department = $Asset->DEPCode ;
		$DepartmentName = $Asset->DepartmentName;
        $Location = $Asset->Location;
        $User = $Asset->UserName;
        $SupplierName = $Asset->SupplierName;
		$SupplierCode = $Asset->SupplierCode;
        $DateOfPurchase = $Asset->DateOfPurchase;
        $DateOfCommission = $Asset->DateOfCommison;
        $AssetValue = $Asset->AssetValue;
        $AssetStatus = $Asset->AssetStatus;
		
        $Remarks = $Asset->Remarks;
		 $chk =  $Asset->IsActive;
		 
		 if($chk == 1)
		 {
			 $IsActive = 'checked';
		 }
		 else
		 {
			 $IsActive = '';
		 }
		 
		 if($DateOfPurchase != '')
		{
			$dtpurchase = new DateTime($DateOfPurchase);
			$DOPurchase =  $dtpurchase ->format('Y-m-d');
		}
		 if($DateOfCommission != '')
		{
			$dtCommission = new DateTime($DateOfCommission);
			$DOCommission =  $dtCommission ->format('Y-m-d');
		}
    }
}


?>
<script> 

$(function() {
	var d = new Date();

	var month = d.getMonth();
	var day = d.getDate();
	var year = d.getFullYear()  ;
	var SIAStartYear = year - 2015;
	var mindt = year-70;
	var maxdt =  year-15;
	
  
	  $("#DateOfCommission").datepicker({
	minDate : new Date(year-SIAStartYear,1,1),
	maxDate :'now',
	dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,



});
 $("#DateOfPurchase").datepicker({
	minDate : new Date(year-SIAStartYear,1,1),
	maxDate :'now',
	dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true


});
	 
	 
});

 function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       }
</script>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <center>Edit Asset Details</center>
        
      </h1>
    </section>
    
    <section class="content">
    <div style="text-align:right;">
    <a href="<?php echo base_url() ?>assetListing" class="btn btn-info" value="Back"/>Back</a>
	</div>
	<br/>
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
              <!-- general form elements -->
                <div class="box box-primary">
                     
                    <!-- form start -->
                    
                    <form role="form" id="addUser" action="<?php echo base_url() ?>editasset" method="post">

                        <div class="box-body">
                            <div class="row">                        							
								<div class="col-md-3">                                
                                    <div class="form-group">
                                        <div class="form-group">
                                        <span for="Asset_Name">Asset Name</span>
										
                                        <input type="text" class="form-control required" id="AssetName" name="AssetName" value="<?php echo $AssetName;?>" style="text-transform:uppercase;">
										 <input type="hidden" name="AssetCode" id="AssetCode"  class="form-control" readonly  value="<?php echo $AssetCode;?>">   
										</div>
                                    </div>
                                    
                                </div>
                                
                            
                            
							<div class="col-md-3">                                
                                    <div class="form-group">
                                        <div class="form-group">
                                        <span for="Description">Description</span>
                                        <input type="text" class="form-control required" id="Description" name="Description"
										value="<?php echo $Description; ?>">
                                    </div>
                                    </div>
                                    
                                </div>
								<div class="col-md-3">                                
                                    <div class="form-group">
                                        <div class="form-group">
                                        <span for="Department">Department</span>
                                        <select class="form-control required" id="Department" name="Department">
                                            <option value="<?php echo $Department; ?>"><?php echo $Department.' - '.$DepartmentName; ?></option>
                                            <?php
                                            if(!empty($DepartmentList))
                                            {
                                                foreach ($DepartmentList as $SID)
                                                {
                                                    ?>
                                                    <option value="<?php echo $SID->DEPCode ?>"><?php echo $SID->DEPCode.' - '. $SID->DepartmentName;?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                    </div>
                                    
                                </div>
								<div class="col-md-3">                                
                                    <div class="form-group">
                                        <div class="form-group">
                                        <span for="Location">Location</span>
                                        <input type="text" class="form-control required" id="Location" name="Location"
										value="<?php echo $Location;?>">
                                    </div>
                                    </div>
                                    
                                </div>
								<div class="col-md-3">                                
                                    <div class="form-group">
                                        <div class="form-group">
                                        <span for="AssetOwner">Asset User Name</span>
                                        <input type="text" class="form-control required" id="User" name="User" value="<?php echo $User;?>">
                                    </div>
                                    </div>
                                    
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <span for="SupplierName">Supplier Name</span>
                                        <select class="form-control required" id="SupplierName" name="SupplierName">
                                            <option value="<?php echo $SupplierCode;?>"><?php echo $SupplierCode.' - '.$SupplierName;?></option>
                                            <?php 
                                            if(!empty($SupplierList))
                                            {
                                                foreach ($SupplierList as $SID)
                                                {
                                                    ?>
                                                    <option value="<?php echo $SID->SupplierID; ?>"><?php echo $SID->SupplierID.' - '.$SID->SupplierName ;?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
								<div class="col-md-3">
                                   
                                        <div class="form-group">
                                        <span for="DateOfPurchase">Date Of Purchase</span>
                                        <input  id="DateOfPurchase" required name="DateOfPurchase"  onkeypress="return false;"  maxlength="10"  class="form-control" value="<?php echo $DOPurchase; ?>">
                                    </div>
                                    </div>
                                
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <span for="DateOfCommission">Date Of Commission</span>
										<input  id="DateOfCommission" required name="DateOfCommission"  onkeypress="return false;"  maxlength="10"  class="form-control" value="<?php echo $DOCommission;?>">

										</div>
                                </div>
								 
								
								<div class="col-md-3">
                                    <div class="form-group">
                                        <span for="Assetvalue">Asset Value</span>
                                        <input type="text" class="form-control required" id="Assetvalue" name="Assetvalue" onkeypress="return isNumberKey(event)" maxlength="255"  value="<?php echo $AssetValue;?>">
                                        
                                    </div>
                                
								</div>
								 
								   <div class="col-md-3">
                                    <div class="form-group">
                                        <span for="AssetStatus">Asset Status</span>
                                        <select class="form-control required" id="AssetStatus" name="AssetStatus">
                                            <option   value="<?php echo $AssetStatus; ?>"><?php echo $AssetStatus; ?></option>
                                            <?php
                                            if(!empty($AssetStatusList))
                                            {
                                                foreach ($AssetStatusList as $SID)
                                                {
                                                    ?>
                                                    <option value="<?php echo $SID->ConfigValue; ?>"> <?php echo $SID->ConfigValue ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
								
								<div class="col-md-6">
                                    <div class="form-group">
                                        <span for="Remarks">Remarks</span>
                                         
                                        <input type="text" class="form-control required" id="Remarks" name="Remarks" maxlength="500" value="<?php echo $Remarks; ?>">
                                    </div>
                                
								</div>
								<div class="col-md-3">
								<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive ?> > IsActive
								</div>
						</div><!-- /.box-body -->
    
                        <div class="box-footer" style="text-align:right">
                            <input type="submit" class="btn btn-info" value="Submit" />
                            <input type="reset" class="btn btn-info" value="Reset" />
                        </div>
                    </form>
                </div>
            </div>
      

