added mini feature of delete previous PO file in purchase module -vadivel J
This commit is contained in:
parent
029fe3d87e
commit
fdc9b5587a
@ -239,6 +239,7 @@ $routes->get('EditPO', 'Purchaseorder::EditPurchaseOrder');
|
||||
$routes->get('purchaseorder/CreatePOPrint', 'Purchaseorder::CreatePOPrint');
|
||||
$routes->post('purchaseorder/ReleasePO', 'Purchaseorder::ReleasePO');
|
||||
$routes->post('purchaseorder/EditRevenuePurchaseOrder', 'Purchaseorder::EditRevenuePurchaseOrder');
|
||||
$routes->post('purchaseorder/deletePurchaseOrderFile' , 'Purchaseorder::deletePurchaseOrderFile');
|
||||
|
||||
$routes->post('VerifyWithSupplierForPendingPO', 'Purchaseorder::VerifyWithSupplierForPendingPO');
|
||||
|
||||
|
||||
@ -2976,7 +2976,7 @@ class Purchaseorder extends BaseController
|
||||
}
|
||||
}else{
|
||||
log_message('error', 'File Upload not Done' . $requestfilename);
|
||||
return json_encode($this->requestr);
|
||||
|
||||
}
|
||||
$POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList);
|
||||
|
||||
@ -3415,9 +3415,48 @@ class Purchaseorder extends BaseController
|
||||
|
||||
|
||||
|
||||
/* delete purchase order file */
|
||||
|
||||
function deletePurchaseOrderFile(){
|
||||
|
||||
$PONO=$this->request->getPost('PONO');
|
||||
|
||||
$filename=$this->request->getPost('POFile');
|
||||
|
||||
$result= $this->purchaseorder_model->deletePurchaseOrderFile($PONO);
|
||||
|
||||
$result2=$this->purchaseorder_model->findPurchaseOrderFile($filename);
|
||||
|
||||
|
||||
|
||||
if ($result && empty($result2)) {
|
||||
|
||||
$path = ROOTPATH . 'public/uploads/POfiles/' . $filename;
|
||||
|
||||
if (file_exists($path)) {
|
||||
|
||||
if (unlink($path)) {
|
||||
|
||||
return $this->response->setJSON(['success' => 'File removed successfully !!!']);
|
||||
} else {
|
||||
|
||||
return $this->response->setJSON(['error' => 'Failed to delete the file from the server.']);
|
||||
}
|
||||
} else {
|
||||
|
||||
return $this->response->setJSON(['error' => 'File not found on the server.']);
|
||||
}
|
||||
|
||||
} else if($result){
|
||||
|
||||
return $this->response->setJSON(['success' => 'File removed successfully !!']);
|
||||
}
|
||||
else {
|
||||
|
||||
return $this->response->setJSON(['error' => 'File deletion from database failed or file still exists in database.']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*This function is used to convert amount(digit) into words*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1458,9 +1458,11 @@ if (!empty($getlogpodtl)) {
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12 px-4" align="left">
|
||||
<div class="form-group col-md-12 px-4" id="deletePreviousPurchaseOrderFileDiv" align="left">
|
||||
<?php if ($PrePOFile) { ?>
|
||||
<label><a title="previously uploaded PO File" href="<?php echo base_url() . 'public/uploads/POfiles/' . $PrePOFile ?>"><span>previously uploaded - </span><small><?= $PrePOFile; ?></small></a></label>
|
||||
|
||||
<button class="btn btn-danger btn-sm " id="deletePreviousPurchaseOrderFile">Delete </button>
|
||||
<?php } ?>
|
||||
<input type="hidden" id="PrePOFile" name="PrePOFile" value="<?php echo $PrePOFile; ?>" />
|
||||
<br>
|
||||
|
||||
@ -1494,19 +1494,22 @@ if (!empty($getlogpodtl)) {
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<label> Select Purchase Order File </label>
|
||||
<div class="form-row" align="left">
|
||||
<div class="form-group col-md-12">
|
||||
<label> Select Purchase Order File </label>
|
||||
|
||||
<input type="file" name="POFile" id="POFile">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" align="left">
|
||||
<br>
|
||||
<div class="form-row" id="deletePreviousPurchaseOrderFileDiv" align="left">
|
||||
<div class="form-group col-md-12">
|
||||
<?php if ($PrePOFile) { ?>
|
||||
<label><a title="previously uploaded PO File" href="<?php echo base_url() . 'public/uploads/POfiles/' . $PrePOFile ?>"><span>previously uploaded - </span><small><?= $PrePOFile; ?></small></a></label>
|
||||
<?php } ?>
|
||||
<label for="deletePreviousPurchaseOrderFile"><a title="previously uploaded PO File" href="<?php echo base_url() . 'public/uploads/POfiles/' . $PrePOFile ?>"><span>previously uploaded - </span><small><?= $PrePOFile; ?></small></a></label>
|
||||
|
||||
<button class="btn btn-danger btn-sm " id="deletePreviousPurchaseOrderFile">Delete </button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -5815,9 +5818,18 @@ if (!empty($getlogpodtl)) {
|
||||
formData.append('txtPONO', $('#txtPONO').val());
|
||||
formData.append('capitalType', $('#capitalType').val());
|
||||
const fileInput = document.getElementById('POFile');
|
||||
if (fileInput.files.length > 0) {
|
||||
const prePOFileInput= document.getElementById('PrePOFile');
|
||||
|
||||
console.log(fileInput.vlaue);
|
||||
console.log(prePOFileInput.value);
|
||||
|
||||
if (fileInput && fileInput.vlaue &&fileInput.files.length > 0) {
|
||||
formData.append('POFile', fileInput.files[0]);
|
||||
} else {
|
||||
} else if(prePOFileInput && prePOFileInput.files && prePOFileInput.files.length > 0) {
|
||||
formData.append('PrePOFile', prePOFileInput.files[0]);
|
||||
|
||||
}else{
|
||||
formData.append('POFile', " ");
|
||||
console.error('No file selected.');
|
||||
}
|
||||
$('input, select, textarea').each(function() {
|
||||
@ -8478,4 +8490,5 @@ if (!empty($getlogpodtl)) {
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
@ -2635,12 +2635,14 @@ if (!empty($getlogpodtl)) {
|
||||
|
||||
<?php if ($PrePOFile) { ?>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12" align="left"><br />
|
||||
<div class="form-group col-md-12" id="deletePreviousPurchaseOrderFileDiv" align="left"><br />
|
||||
|
||||
<label><a title="previously uploaded PO File"
|
||||
href="<?php echo base_url() . 'public/uploads/POfiles/' . $PrePOFile ?>">
|
||||
<span>previously uploaded purchase order file- </span>
|
||||
<small><?= $PrePOFile; ?></small></a></label>
|
||||
|
||||
<button class="btn btn-danger btn-sm " id="deletePreviousPurchaseOrderFile">Delete </button>
|
||||
|
||||
<input type="hidden" id="PrePOFile" name="PrePOFile" value="<?php echo $PrePOFile; ?>" /><br>
|
||||
</div>
|
||||
|
||||
@ -1163,22 +1163,26 @@ if (!empty($getlogpodtl)) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row px-4">
|
||||
|
||||
<div class="form-group col-md-3" align="left">
|
||||
|
||||
<label>Select Purchase Order File</label>
|
||||
<input type="file" class="" name="POFile" id="POFile">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-row px-4">
|
||||
<label>Select Purchase Order File</label>
|
||||
<div class="form-group col-md-12" align="left">
|
||||
|
||||
<input type="file" class="" name="POFile" id="POFile">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row px-4">
|
||||
<div class="form-group col-md-3" align="left">
|
||||
<div class="form-group col-md-12" id="deletePreviousPurchaseOrderFileDiv" align="left">
|
||||
<div>
|
||||
<?php if ($PrePOFile) { ?>
|
||||
<label><a title="previously uploaded PO File" href="<?php echo base_url() . 'public/uploads/POfiles/' . $PrePOFile ?>"><span>Previously Uploaded Purchase Order File- </span><small><?= $PrePOFile; ?></small></a></label>
|
||||
|
||||
<button class="btn btn-danger btn-sm " id="deletePreviousPurchaseOrderFile">Delete </button>
|
||||
<?php } ?>
|
||||
<input type="hidden" id="PrePOFile" name="PrePOFile" value="<?php echo $PrePOFile; ?>" />
|
||||
|
||||
|
||||
@ -151,6 +151,51 @@
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$('document').ready(function(){
|
||||
$('#deletePreviousPurchaseOrderFile').click(function(){
|
||||
|
||||
var PONO = $('#txtPONO').val();
|
||||
|
||||
let confirmTrue=confirm(`Do you confirm to delete the Purchase order file for the PONO ${PONO} ?`);
|
||||
|
||||
|
||||
if(confirmTrue){
|
||||
|
||||
var filename = $('#PrePOFile').val();
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo base_url('/purchaseorder/deletePurchaseOrderFile') ?>",
|
||||
type: 'POST',
|
||||
data: {
|
||||
PONO :PONO,
|
||||
POFile:filename
|
||||
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
|
||||
|
||||
$('#deletePreviousPurchaseOrderFileDiv').hide();
|
||||
|
||||
|
||||
if (response)
|
||||
alert(response.success);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}else{
|
||||
return ;
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user