<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>Siddharth Industries - Add Asset Details</center>
        
      </h1>
    </section>
    
    <section class="content">
    <div style="text-align:right;">
    <a href="<?php 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="addAsset" action="<?php echo base_url() ?>addNewasset" 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"   required style="text-transform:uppercase;" id="AssetName" name="AssetName"  value="<?php echo isset($_POST['AssetName']) ? $_POST['AssetName'] : '' ?>">
										</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"  required name="Description" value="<?php echo isset($_POST['Description']) ? $_POST['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="-1"  >Select Department</option>
                                            <?php
                                            if(!empty($DepartmentList))
                                            {
                                                foreach ($DepartmentList as $DEP)
                                                {
													$DepartmentId = $DEP->DEPCode;
                                                  													
													if ($_POST['Department'] == $DepartmentId) 
													{

												echo "<option value=\"".$DepartmentId."\" selected=\"selected\">".$DepartmentId.' -  '. $DEP->DepartmentName."</option>"; 
													}
													else 
													{
													echo "<option value=\"".$DepartmentId."\">".$DepartmentId.' -  '. $DEP->DepartmentName ."</option>";       
													}						
													
                                                    
                                                }
                                            }
                                            ?>
                                        </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"  required id="Location" name="Location" value= "<?php echo isset($_POST['Location']) ? $_POST['Location'] : '' ?>">
                                    </div>
                                    </div>
                                    
                                </div>
								<div class="col-md-3">                                
                                    <div class="form-group">
                                        <div class="form-group">
                                        <span for="AssetOwner">Asset User</span>
                                        <input type="text" class="form-control required" required id="User" name="User" value= "<?php echo isset($_POST['User']) ? $_POST['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="-1">Select Supplier Name</option>
                                            <?php
                                            if(!empty($SupplierList))
                                            {
                                                foreach ($SupplierList as $SID)
                                                {
                                                   												
													$SupplierId = $SID->SupplierID;
                                                  													
													if ($_POST['SupplierName'] == $SupplierId) 
													{

												echo "<option value=\"".$SupplierId."\" selected=\"selected\">".$SupplierId.' -  '. $SID->SupplierName."</option>"; 
													}
													else 
													{
													echo "<option value=\"".$SupplierId."\">".$SupplierId.' -  '. $SID->SupplierName ."</option>";       
													}
                                                }
                                            }
                                            ?>
                                        </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 isset($_POST['DateOfPurchase']) ? $_POST['DateOfPurchase'] : '' ?>">
                                    </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 isset($_POST['DateOfCommission']) ? $_POST['DateOfCommission'] : '' ?>">

										</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" required onkeypress="return isNumberKey(event)" title="Please Enter currency value" maxlength="255" value= "<?php echo isset($_POST['Assetvalue']) ? $_POST['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="-1" >Select Asset Status</option>
                                            <?php
                                            if(!empty($AssetStatus))
                                            {
                                                foreach ($AssetStatus as $SID)
                                                {
													$AssetValue = $SID->ConfigValue;
                                                  													
													if ($_POST['AssetStatus'] == $AssetValue) 
													{

												echo "<option value=\"".$AssetValue."\" selected=\"selected\">".$AssetValue."</option>"; 
													}
													else 
													{
													echo "<option value=\"".$AssetValue."\">".$AssetValue."</option>";       
													}
                                                }
                                            }
											   
                                            ?>
                                        </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 isset($_POST['Remarks']) ? $_POST['Remarks'] : '' ?>">
                                    </div>
                                
								</div>
								<div class="col-md-3">
								<input type="checkbox" id="isactive" name="isactive"  <?php echo (isset($_POST['isactive']) ? 'checked' : '') ?>> 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>
            <div class="col-md-4">
                <?php
                    $this->load->helper('form');
                    $error = $this->session->flashdata('error');
                    if($error)
                    {
                ?>
                <div class="alert alert-danger alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <?php echo $this->session->flashdata('error'); ?>                    
                </div>
                <?php } ?>
                <?php  
                    $success = $this->session->flashdata('success');
                    if($success)
                    {
                ?>
                <div class="alert alert-success alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <?php echo $this->session->flashdata('success'); ?>
                </div>
                <?php } ?>
                
                <div class="row">
                    <div class="col-md-12">
                        <?php echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?>
                    </div>
                </div>
            </div>
        </div>    
    </section>
    
</div>
<script src="<?php echo base_url(); ?>assets/js/addUser.js" type="text/javascript"></script>
 