ria/app/Views/editasset.php
2025-03-04 11:37:42 +05:30

442 lines
22 KiB
PHP
Executable File

<?php
$AssetCode = '';
$AssetName = '';
$Description = '';
$Department = '';
$Location = '';
$User = '';
$SupplierName = '';
$DateOfPurchase = '';
$DateOfCommison = '';
$AssetValue = '';
$AssetStatus = '';
$IsActive = '';
$Remarks = '';
$DepartmentName = '';
$Department = '';
$SupplierCode = '';
$MaterialCode = '';
$PONO = '';
$POLineItem = '';
$Quantity = '';
$UOM = '';
$MaterialName = '';
$DeliveryDate = '';
$DDate = '';
if (!empty($assetList)) {
foreach ($assetList as $Asset) {
//print_r($Asset);die();
$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; //print_r($Asset->DateOfPurchase);
if ($DateOfPurchase != '' && $DateOfPurchase != '0000-00-00 00:00:00') {
$PODate = new DateTime($DateOfPurchase);
$DateOfPurchase = $PODate->format('d-m-Y');
} else {
$DateOfPurchase = '';
}
$DateOfCommison = $Asset->DateOfCommison;
if ($DateOfCommison != '' && $DateOfCommison != '0000-00-00 00:00:00') {
$DateOfCommission = new DateTime($Asset->DateOfCommison, new DateTimeZone('Asia/Kolkata'));
$DateOfCommison = $DateOfCommission->format('d-m-Y');
} else {
$DateOfCommison = '';
}
$AssetValue = $Asset->AssetValue;
$AssetStatus = $Asset->AssetStatus;
$MaterialCode = $Asset->MaterialCode;
$PONO = $Asset->PONO;
$POLineItem = $Asset->POLineItem;
$Quantity = $Asset->Quantity;
$MaterialName = $Asset->MaterialName;
$UOM = $Asset->UOM;
$DDt = $Asset->DeliveryDate;
if ($DDt != '' && $DDt != '0000-00-00 00:00:00') {
$DDate = new DateTime($DDt, new DateTimeZone('Asia/Kolkata'));
$DeliveryDate = $DDate->format('d-m-Y');
} else {
$DeliveryDate = '';
}
$Remarks = $Asset->Remarks;
$chk = $Asset->IsActive;
if ($chk == 1) {
$IsActive = 'checked';
} else {
$IsActive = '';
}
// if($DateOfPurchase != '')
// {
// $dtpurchase = new DateTime($DateOfPurchase);
// $DOPurchase = $dtpurchase ->format('d/m/Y');
// }
// if($DateOfCommission != '')
// {
// $dtCommission = new DateTime($DateOfCommission);
// $DOCommission = $dtCommission ->format('Y-m-d');
// }
}
}
?>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title text-center"><?= 'Edit Asset - ' . $AssetCode; ?> Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>assetListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" id="addAsset" action="<?php echo base_url() ?>editasset" method="post">
<div class="box-body">
<div class="form-row">
<div class="col-md-3">
<label class="col-form-label" for="AssetName">Asset Name<span class="badge">*</span></label>
<input type="text" class="form-control" 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 class="col-md-3">
<label class="col-form-label" for="Description">Asset Description<span class="badge">*</span></label>
<input type="text" class="form-control" id="Description" name="Description" value="<?php echo $Description; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="User">Asset User<span class="badge">*</span></label>
<input type="text" class="form-control" id="User" name="User" value="<?php echo $User; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Location">Asset Location<span class="badge">*</span></label>
<input type="text" class="form-control" id="Location" name="Location" value="<?php echo $Location; ?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="PONO">Purchase Order Number<span class="badge">*</span></label>
<select class="form-control select2" id="PONO" name="PONO">
<option value="<?php echo $PONO; ?>"><?php echo $PONO; ?></option>
<?php if (!empty($purchaseOrder)) {
foreach ($purchaseOrder as $order) { ?>
<option value="<?php echo $order->purchase_orderno; ?>"><?php echo $order->purchase_orderno; ?></option>
<?php }
} ?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Category">Asset Category<span class="badge">*</span></label>
<select class="form-control select2" id="Category" name="Category">
<option value="<?php echo $Category; ?>"><?php echo $CategoryName; ?></option>
<?php if (!empty($categories)) {
foreach ($categories as $cat) { ?>
<option value="<?php echo $cat->id; ?>"><?php echo $cat->name; ?></option>
<?php }
} ?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetType">Asset Type<span class="badge">*</span></label>
<select class="form-control select2" id="AssetType" name="AssetType">
<option value="<?php echo $AssetType; ?>"><?php echo $AssetType; ?></option>
<option value="Fixed">Fixed</option>
<option value="Consumable">Consumable</option>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetSubType">Asset Sub-Type<span class="badge">*</span></label>
<select class="form-control select2" id="AssetSubType" name="AssetSubType">
<option value="<?php echo $AssetSubType; ?>"><?php echo $AssetSubType; ?></option>
<option value="Individual">Individual</option>
<option value="Common">Common</option>
</select>
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="PDate">Purchase Date<span class="badge">*</span></label>
<input type="text" class="form-control" id="PDate" name="PDate" value="<?php echo $PDate; ?>" required>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Vendor">Vendor<span class="badge">*</span></label>
<select class="form-control select2" id="Vendor" name="Vendor">
<option value="<?php echo $Vendor; ?>"><?php echo $VendorName; ?></option>
<?php if (!empty($vendors)) {
foreach ($vendors as $vendor) { ?>
<option value="<?php echo $vendor->id; ?>"><?php echo $vendor->name; ?></option>
<?php }
} ?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Rate">Rate<span class="badge">*</span></label>
<input type="text" class="form-control" id="Rate" name="Rate" value="<?php echo $Rate; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Life">Life<span class="badge">*</span></label>
<input type="text" class="form-control" id="Life" name="Life" value="<?php echo $Life; ?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="AssetDept">Asset Department</label>
<input type="text" class="form-control" value="<?php echo $DepartmentName; ?>" id="AssetDept" readonly>
<input type="hidden" name="AssetDept" id="depcode" value="<?php echo $Department ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetOwner">Asset Owner</label>
<select class="form-control select2" id="AssetOwner" name="AssetOwner">
<option value="<?php echo $AssetOwner; ?>"><?php echo $AssetOwnerName; ?></option>
<?php if (!empty($owners)) {
foreach ($owners as $owner) { ?>
<option value="<?php echo $owner->id; ?>"><?php echo $owner->name; ?></option>
<?php }
} ?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="VendorWarranty">Vendor Warranty</label>
<input type="text" class="form-control" id="VendorWarranty" name="VendorWarranty" value="<?php echo $VendorWarranty; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="AMC">AMC Details</label>
<input type="text" class="form-control" id="AMC" name="AMC" value="<?php echo $AMC; ?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="AssetLocation">Current Asset Location</label>
<input type="text" class="form-control" id="AssetLocation" name="AssetLocation" value="<?php echo $AssetLocation; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Custodian">Custodian Name</label>
<input type="text" class="form-control" id="Custodian" name="Custodian" value="<?php echo $Custodian; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Condition">Condition</label>
<select class="form-control select2" id="Condition" name="Condition">
<option value="<?php echo $Condition; ?>"><?php echo $Condition; ?></option>
<option value="Good">Good</option>
<option value="Average">Average</option>
<option value="Poor">Poor</option>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Remarks">Remarks</label>
<textarea class="form-control" id="Remarks" name="Remarks"><?php echo $Remarks; ?></textarea>
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-12 text-right">
<a href="<?php echo base_url() ?>assetListing" class="btn btn-cancel" id="cancel" value="Cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</div>
</div><!-- /.box-body -->
</form>
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div><!-- /.content -->
</div><!-- /.content-page -->
<script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script>
<script>
$(function() {
$("#PONO").select2();
$("#SelectMaterialCode").select2();
$("#AssetStatus").select2();
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: 'dd-mm-yy',
changeMonth: true,
changeYear: true
});
$("#DateOfPurchase").datepicker({
minDate: new Date(year - SIAStartYear, 1, 1),
maxDate: 'now',
dateFormat: 'dd-mm-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;
}
$('#PONO').on('change', function() {
var PONO = $(this).val();
$('#SupplierName').val('');
$('#SupID').val('');
$('#MaterialCode').val('');
$('#UOM').val('');
$('#Quantity').val('');
$('#depcode').val('');
$('#AssetDept').val('');
$('#DateOfPurchase').val('');
$('#DeliveryDate').val('');
$('#PODescription').val('');
$('#Assetvalue').val('');
// alert(PONO);
if (PONO) {
//alert("INSIDE IF");
$('#loader').show();
$.ajax({
type: 'POST',
url: "<?php echo base_url() ?>assetdetails/getpodetails",
data: 'PONO=' + PONO,
dataType: 'json',
success: function(data) {
//alert(data);
$('#loader').hide();
var line = '';
$('#SelectMaterialCode').empty();
//alert('before');
$.each(data, function(i, item) {
//alert(item);
//line ='<option>select Material Code</option>';
//line +='<option value='+item.LineItemNo+'>'+item.LineItemNo+'-'+item.MaterialCode+'</option>';
//$('#DeliveryDate').val(item.DeliveryDate);
line += item;
$('#SelectMaterialCode').append(line);
});
}
});
}
});
$('#SelectMaterialCode').on('change', function() {
var line = $(this).val();
//line +='<option>select Material Code</option>'
if (line) {
$('#loader').show();
$.ajax({
type: 'POST',
url: "<?php echo base_url() ?>assetdetails/getline",
data: 'line=' + line,
success: function(data) {
//alert(data);
var id = $('#SelectMaterialCode').val();
$.each(JSON.parse(data), function(i, item) {
if (id == item.LineItemNo) {
$('#DateOfPurchase').val(item.PODate);
if (item.DeliveryDate != null) {
var date = new Date(item.DeliveryDate);
var date1 = (date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
if (item.DeliveryDate == '0000-00-00' || item.DeliveryDate == '30-11--0001') {
$('#DeliveryDate').val('');
} else {
//alert(item.DeliveryDate+ ',' + date1);
$("#DeliveryDate").val(date1);
}
//var correctDate = [DDate.getDate(),DDate.getMonth()+1,DDate.getFullYear()].join("/");
//alert(correctDate);
} else {
$('#DeliveryDate').val('');
}
$('#SupplierName').val(item.SupplierName);
$('#SupID').val(item.SupplierID);
$('#MaterialCode').val(item.MaterialCode);
$('#UOM').val(item.UOM);
$('#Quantity').val(item.Quantity);
$('#depcode').val(item.Departmentcode);
$('#AssetDept').val(item.DepartmentName);
$('#PODescription').val(item.MaterialName);
$('#Assetvalue').val(item.TotalValue);
//var date = new Date(item.DeliveryDate);
// var date1 = (date.getDate()+ '/' + (date.getMonth() + 1)+ '/' + date.getFullYear());
var date = new Date(item.PODate);
var date3 = (date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
$("#DateOfPurchase").val(date3);
}
$('#loader').hide();
//line ='<option>'+item.LineItemNo+'</option>';
// $('#POLineItem').append(line);
});
}
});
}
});
</script>