From a28862ba31f8811cb7c9a98f21802a8cfbcb56bb Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 13 Feb 2025 11:51:12 +0000 Subject: [PATCH 1/5] bug fixes 2 : ps --- app/Config/Routes.php | 2 +- app/Controllers/Configurationctrl.php | 8 ++ app/Controllers/Rawmaterialdetails.php | 34 ------ app/Models/Config_model.php | 12 +++ app/Models/Purchaseorder_model.php | 2 +- app/Models/Rawmaterialdetails_model.php | 29 ++---- app/Models/Requistion_model.php | 7 +- app/Views/addRawMaterial.php | 81 ++++----------- app/Views/configlisting.php | 65 ++++++++++-- app/Views/editRawmaterial.php | 77 ++++---------- app/Views/editRevenuepurchaseorder.php | 132 +++++++++++++++++++++++- app/Views/editconfig.php | 62 ++++++++--- app/Views/editrequisitionform.php | 19 +++- app/Views/purchaseorder.php | 116 +++++++++++++++++++++ app/Views/rawmaterialListing.php | 2 +- app/Views/requisitionform.php | 38 +++++-- 16 files changed, 469 insertions(+), 217 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3e22539f..b08ca39c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -63,7 +63,6 @@ $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'rawmaterialListing/(:num)', 'R $routes->post('materialExist', 'Rawmaterialdetails::checkmaterial'); $routes->get('viewRawmaterial', 'Rawmaterialdetails::viewRawmaterial'); $routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial'); -$routes->post('rawmaterialdetails/addMaterialCategories', 'Rawmaterialdetails::addMaterialCategories'); $routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial'); $routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial'); $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial'); @@ -144,6 +143,7 @@ $routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configVa $routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue'); $routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue'); $routes->get('activeInactiveConfigValue', 'Configurationctrl::activeInactiveConfigValue'); +$routes->post('getPONOcreatedBasedOnConfig', 'Configurationctrl::getPONOcreatedBasedOnConfig'); $routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig'); $routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig'); $routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck'); diff --git a/app/Controllers/Configurationctrl.php b/app/Controllers/Configurationctrl.php index 83b09a79..1ff5b1fe 100755 --- a/app/Controllers/Configurationctrl.php +++ b/app/Controllers/Configurationctrl.php @@ -190,6 +190,14 @@ class Configurationctrl extends BaseController $result = $this->configmodel->activeInactiveConfigValue($key, $where); return redirect()->back(); } + public function getPONOcreatedBasedOnConfig(){ + $data = $this->request->getPost(); + $key_id = $data['key_id']; + $result = $this->configmodel->getPONOcreatedBasedOnConfig($key_id); + return $this->response->setJSON($result); + // return $result; + + } public function deleteConfigValue(){ diff --git a/app/Controllers/Rawmaterialdetails.php b/app/Controllers/Rawmaterialdetails.php index 31f51c2f..e05b1b11 100755 --- a/app/Controllers/Rawmaterialdetails.php +++ b/app/Controllers/Rawmaterialdetails.php @@ -352,40 +352,6 @@ class Rawmaterialdetails extends BaseController } - function addMaterialCategories(){ - - $configCode = 'C023'; - $configVal = $this->request->getpost('category_name'); - $configArr = array('Config_ID' => $configCode, 'ConfigValue' => $configVal); - $existingCategory = $this->rawmaterialdetails_model->checkMaterialCategory($configVal); - - if ($existingCategory) { - // Data already exists, handle this case (e.g., return an error or ignore the insert) - return $this->response->setJSON([ - 'status' => '409', - 'message' => 'Category Already Exists..!!', - ]); - } - - $insertResult=$this->rawmaterialdetails_model->insertvalueintoconfig($configArr); - - if ($insertResult) { - // Send a success response as JSON - return $this->response->setJSON([ - 'status' => '201', - 'message' => 'Category added successfully', - ]); - } else { - // Send an error response as JSON - return $this->response->setJSON([ - 'status' => '400', - 'message' => 'Failed to add category', - ]); - } - - } - - function insertvalueintoconfig() { diff --git a/app/Models/Config_model.php b/app/Models/Config_model.php index f854f137..ef2109e9 100755 --- a/app/Models/Config_model.php +++ b/app/Models/Config_model.php @@ -228,4 +228,16 @@ class Config_model extends Model return $res; } + public function getPONOcreatedBasedOnConfig($key_id){ + $builder = $this->db->table('t_purchaseorder_lineitem PL') + ->select('PL.PONO, MM.MaterialName, CD.ConfigValue as CategoryName') + ->join('t_materialmaster MM', 'MM.MaterialCode = PL.MaterialCode', 'left') + ->join('t_configdetails CD', 'CD.Key = MM.Category', 'left') + ->where('CD.Key', $key_id); + + $query = $builder->get(); + $result = $query->getResultArray(); + return $result; + } + } \ No newline at end of file diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index 42f7d670..99fd3837 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -1142,7 +1142,7 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, { $subQuery = 'SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Per,ServiceMaterialDescription,ReceivedQuantity,Rate,Req.Status,(Quantity *Rate) as BasicValue , (( AfterSGST + AfterCGST + - AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName + AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName,LineItem.LineitemDescription FROM t_purchaseorder_lineitem LineItem join t_materialmaster Mat on Mat.MaterialCode = LineItem.MaterialCode left join t_revenue_tax Tax on Tax.LineItemNo = LineItem.LineItemNo diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index 1eaa36bb..f530ada6 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -18,9 +18,10 @@ class Rawmaterialdetails_model extends Model { $builder = $this->db->table('t_materialmaster') - ->select('t_materialmaster.* , emp.FirstName as createdby_user') + ->select('t_materialmaster.* , emp.FirstName as createdby_user,cd.ConfigValue as CategoryName') ->join('tbl_users as user', 'user.UserId = t_materialmaster.createdby', 'left') ->join('t_employee_details as emp', 'emp.EmpID = user.EmpID', 'left') + ->join('t_configdetails as cd', 'cd.Key = t_materialmaster.Category', 'left') ->orderBy('CreatedDate','desc'); $query = $builder->get(); $result = $query->getResult(); @@ -76,7 +77,7 @@ class Rawmaterialdetails_model extends Model { $Config_ID = 'C023'; $builder = $this->db->table('t_configdetails') - ->select('Config_ID,ConfigValue') + ->select('Key,Config_ID,ConfigValue') ->where('isActive', 1) ->where('Config_id', $Config_ID); if ($MaterialCategory != '') { @@ -329,15 +330,18 @@ class Rawmaterialdetails_model extends Model // on 28/jan/2025. both add and edit. category condition added. + // on 13/Feb/2025. Change based On Config Child Values. function checkMaterialExists($materialCode , $materialName ,$materialCategory) { - $builder = $this->db->table('t_materialmaster') - ->select('MaterialCode,MaterialName,MaterialType,Category,IsActive'); + + $builder = $this->db->table('t_materialmaster MM') + ->select('MM.MaterialCode,MM.MaterialName,MM.MaterialType,MM.Category,MM.IsActive,CD.ConfigValue as CategoryName') + ->join('t_configdetails as CD', ' CD.Key = MM.Category', 'left'); if(!empty($materialCode)){ - $builder = $builder->where('MaterialCode !=' , $materialCode); + $builder = $builder->where('MM.MaterialCode !=' , $materialCode); } - $builder->where('Category' , $materialCategory); - $builder->where('REPLACE(MaterialName, " ", "")' , $materialName); + $builder->where('MM.Category' , $materialCategory); + $builder->where('REPLACE(MM.MaterialName, " ", "")' , $materialName); $query = $builder->get(); if ($query->getNumRows() > 0) { @@ -347,17 +351,6 @@ class Rawmaterialdetails_model extends Model } } - function checkMaterialCategory($mc) - { - $builder = $this->db->table('t_configdetails') - ->select('ConfigValue') - ->where('Config_ID', 'C023') - ->like('ConfigValue', $mc); - $query = $builder->get()->getRow(); - return $query; - } - - function reOrderListing() { diff --git a/app/Models/Requistion_model.php b/app/Models/Requistion_model.php index d5f5230a..bfeed261 100755 --- a/app/Models/Requistion_model.php +++ b/app/Models/Requistion_model.php @@ -196,9 +196,10 @@ class Requistion_model extends Model */ function getRawMaterialList($MaterialCode) { - $builder = $this->db->table('t_materialmaster') - ->select('MaterialName,UOM,Category') - ->where('MaterialCode',$MaterialCode ); + $builder = $this->db->table('t_materialmaster MM') + ->select('MM.MaterialName,MM.UOM,MM.Category,CD.ConfigValue as CategoryName') + ->join('t_configdetails CD', 'CD.Key = MM.Category', 'left') + ->where('MM.MaterialCode',$MaterialCode ); $query = $builder->get(); return $query->getResultArray(); diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index 93ccd7d1..cedc94c8 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -70,17 +70,17 @@
- - + --> - + = 1) { $('#loader').hide(); - if(data[0]?.IsActive == 1){ - alert('Material name already existed ! '); - $('#MaterialName').val(''); - }else{ - alert('Material name already existing in the deleted section.!!'); - $('#MaterialName').val(''); - } - var related_name = ""; - $.each(data, function(i, obj) { + let message = ""; + if (data[0]?.IsActive == 1) { + message = "Material name already exists!\n\n"; + } else { + message = "Material name already exists in the deleted section!\n\n"; + } - related_name += obj.MaterialCode + " - " + obj.MaterialName + " - " + obj.MaterialType + " - " + obj.Category + "\n"; + let related_name = ""; + $.each(data, function(i, obj) { + related_name += obj.MaterialCode + " - " + obj.MaterialName + " - " + obj.MaterialType + " - " + obj.CategoryName + "\n"; + }); - }); + message += "'" + materialName + "' - related materials are:\n\n" + related_name; - alert("'" + materialName + "' - related materials are , " + " \n \n" + related_name); - $("#MaterialName").val(''); - $("#MaterialName").focus(); + alert(message); + + $("#MaterialName").val(''); + $("#MaterialName").focus(); } else { $('#loader').hide(); console.log("working") @@ -479,48 +480,6 @@ if ($total <= $reorder) { return false; } - $.ajax({ - url: "", - type: 'POST', - data: { - category_name: materialCategory - }, - success: function(response) { - - if(response.status== 201 ){ - - $("#addMaterialCaterogyModal").modal('hide'); - $("#materialCategoryInput").val(''); - $("#MaterialCategory").append(``) - } - else if(response.status=="409"){ - - $("#addMaterialCaterogyModal").modal('hide'); - $("#materialCategoryInput").val(''); - // $('#MaterialCategory').val(materialCategory); - - $('#MaterialCategory').trigger('change'); - - setTimeout(()=>{ alert(`${response.message}`) },1000) - } - else{ - $("#addMaterialCaterogyModal").modal('hide'); - $("#materialCategoryInput").val(''); - - setTimeout(()=>{ alert('Error Adding Category..!!'); },1000) - - } - - - }, - error: function(xhr, status, error) { - // Handle errors - alert('Error adding category'); - console.log(error); - } - }); - - } diff --git a/app/Views/editRevenuepurchaseorder.php b/app/Views/editRevenuepurchaseorder.php index 95f727b0..649c0f7c 100755 --- a/app/Views/editRevenuepurchaseorder.php +++ b/app/Views/editRevenuepurchaseorder.php @@ -1,5 +1,110 @@ + "NO", "value" => "0"), @@ -147,6 +243,7 @@ if (!empty($getlogpodtl)) { // var maxDate = new Date(minDate.getFullYear() + 1, minDate.getMonth(), minDate.getDate()); }); + Requisition No Item Code Item Description + Line Item Specs Quantity UOM Rate @@ -826,6 +923,20 @@ if (!empty($getlogpodtl)) { ReqNo ?> MaterialCode ?> MaterialName ?> + + + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; ?> + + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; } ?> + Quantity ?> UOM ?> Rate ?> @@ -1088,6 +1199,7 @@ if (!empty($getlogpodtl)) { + @@ -3157,7 +3269,7 @@ if (!empty($getlogpodtl)) { echo form_input($data); ?>
-
+
'txtAfterFreightlocview', 'value' => set_value('txtAfterFreightlocview'), 'id' => 'txtAfterFreightlocview', 'class' => 'form-control num', 'readonly' => 'true'); @@ -4663,13 +4775,24 @@ if (!empty($getlogpodtl)) { // ReceivedQuantity: 0, // PendingQuantity: quantity // })); + PONOStatus = var rowHtml = ` ${temp} ${Reqnumber} ${materialCode} - ${materialName} - ${quantity} + ${materialName}`; + if (PONOStatus === "PO_DRAFT" || PONOStatus === "PO_CREATED") { + rowHtml += `- + `; + }else{ rowHtml += `-`; } + rowHtml += `${quantity} ${uom} ${itemRate} ${basicval} @@ -5548,7 +5671,7 @@ if (!empty($getlogpodtl)) { $('#EditCustomDutyExpenses').val($('#CustomDutyExpenses' + userid).val()); //$('#txtEditInsurance').val($('#RMCIncludingCustomers'+userid).val()); - $('#EdittxtTotalOrderValue').val(cellval[9].innerHTML); + $('#EdittxtTotalOrderValue').val(cellval[10].innerHTML); @@ -5653,7 +5776,7 @@ if (!empty($getlogpodtl)) { $('#ViewAfterSgst').val($('#AfterSgst' + userid).val()); $('#ViewAfterIgst').val($('#AfterIgst' + userid).val()); $('#ViewOtherAllowances').val($('#OtherAmt' + userid).val()); - $('#ViewTotalAmountlocal').val(cellval[9].innerHTML); + $('#ViewTotalAmountlocal').val(cellval[10].innerHTML); $('#drpFreightviewloc').val($("#Ftype" + userid).val()); @@ -6428,12 +6551,12 @@ if (!empty($getlogpodtl)) { cellval[2].innerHTML = materialCode; cellval[3].innerHTML = materialName; - cellval[4].innerHTML = quantity; - cellval[5].innerHTML = uom; - cellval[6].innerHTML = parseFloat(itemRate).toFixed(2); - cellval[7].innerHTML = parseFloat(basicval).toFixed(2); - cellval[8].innerHTML = parseFloat(TotalTaxValue).toFixed(2); - cellval[9].innerHTML = parseFloat(Total).toFixed(2); + cellval[5].innerHTML = quantity; + cellval[6].innerHTML = uom; + cellval[7].innerHTML = parseFloat(itemRate).toFixed(2); + cellval[8].innerHTML = parseFloat(basicval).toFixed(2); + cellval[9].innerHTML = parseFloat(TotalTaxValue).toFixed(2); + cellval[10].innerHTML = parseFloat(Total).toFixed(2); diff --git a/app/Views/editRevenuepurchaseorder.php b/app/Views/editRevenuepurchaseorder.php index 649c0f7c..a8251fb0 100755 --- a/app/Views/editRevenuepurchaseorder.php +++ b/app/Views/editRevenuepurchaseorder.php @@ -72,26 +72,15 @@ const $btn = $(this); const $editContainer = $btn.closest('.edit-container'); const $input = $editContainer.find('.edit-input-field'); + const value = $input.val().trim(); const $link = $editContainer.siblings('.editable-field'); - const invoiceId = $link.data('lineitemdesc'); - $('#loader').show(); - // Save logic (API call) - $.ajax({ - url: 'updateInvRecQty', - method: 'POST', - data: { invoice_id: invoiceId, received_qty: value }, - success: function (response) { - // Show success and update the tag value - $link.text(value).show(); - $editContainer.hide(); - $('#loader').hide(); - }, - error: function (xhr) { - $('#loader').hide(); - alert('Failed to save the value.'); - } - }); + const LineItemNoteForAuditor = $link.data('notes'); + const id = $link.data('id'); + var theForm = $(".CreatePO"); + $("#LineItemNoteForAuditor" + id).val(value); // to update the hidden fields + $link.text(value).show(); // to update table cell + $editContainer.hide(); }); // Handle click on the close (cancel) button @@ -2346,6 +2335,7 @@ if (!empty($getlogpodtl)) { Requisition No Item Code Item Description + Line Item Specs Quantity UOM Rate @@ -2362,7 +2352,6 @@ if (!empty($getlogpodtl)) { - Lineitem Description Action @@ -2379,6 +2368,20 @@ if (!empty($getlogpodtl)) { ReqNo ?> MaterialCode ?> MaterialName ?> + + + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; ?> + + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; } ?> + Quantity ?> UOM ?> Rate ?> @@ -2519,19 +2522,10 @@ if (!empty($getlogpodtl)) { name="" id="" value="TotalValue; ?>" /> - - - - LineitemDescription) ? $record->LineitemDescription : "-"; ?> - - - + + // var template = jQuery("#RevenueList").html(); @@ -4508,23 +4505,25 @@ if (!empty($getlogpodtl)) { ${temp} ${Reqnumber} ${materialCode} - ${materialName} - ${quantity} - ${uom} - ${itemRate} - ${basicval} - ${TotalTaxValue} - ${TotalOrderValue} - - - - - - + ${materialName}`; + if (PONOStatus === "PO_DRAFT" || PONOStatus === "PO_CREATED") { + rowHtml += `- + `; + }else{ rowHtml += `-`; } + rowHtml += ` + ${quantity} + ${uom} + ${itemRate} + ${basicval} + ${TotalTaxValue} + ${TotalOrderValue} + @@ -4532,7 +4531,7 @@ if (!empty($getlogpodtl)) { - + `; $('#RevenueAppend').append(rowHtml); @@ -4574,6 +4573,7 @@ if (!empty($getlogpodtl)) { addHidden(theForm, "LineItemNo" + temp, ''); addHidden(theForm, "per" + temp, PER); addHidden(theForm, "service_description" + temp, service_description); + addHidden(theForm, "LineItemNoteForAuditor" + temp, '-'); $('#txtRowCount').val(temp); populateValueMainFormForRevenue(); clearRevenueModalFields(); diff --git a/app/Views/editconfig.php b/app/Views/editconfig.php index 6385e75f..20bf6e67 100755 --- a/app/Views/editconfig.php +++ b/app/Views/editconfig.php @@ -624,6 +624,7 @@ if (!empty($master)) { let key_id = $(event.currentTarget).data('key'); let code_value = $(event.currentTarget).data('code'); + let deleteUrl = event.currentTarget.href; // Store the href URL if (code_value == 'C023') { $.ajax({ @@ -641,13 +642,16 @@ if (!empty($master)) { data.forEach(function(item) { content += "\n- " + item.PONO; }); + let result = confirm(content); + if (result) { + window.location.assign(deleteUrl); // Use assign() instead of href + } + }else{ + let result = confirm("Do you want to delete this configuration?"); + if (result) { + window.location.assign(deleteUrl); // Use assign() instead of href + } } - - let result = confirm(content); - - if (result) { - window.location.href = event.currentTarget.href; // Proceed with deletion - } }, error: function(xhr, status, error) { console.log("Error occurred: ", error); diff --git a/app/Views/editimportpo.php b/app/Views/editimportpo.php index eebb9a8f..9a7732dd 100755 --- a/app/Views/editimportpo.php +++ b/app/Views/editimportpo.php @@ -1,3 +1,99 @@ + + Requisition No Material Code Description + Line Item Specs Quantity UOM Rate @@ -763,6 +860,20 @@ if (!empty($getlogpodtl)) { ReqNo ?> MaterialCode ?> MaterialName ?> + + + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; ?> + + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; } ?> + Quantity ?> UOM ?> Rate ?> @@ -879,6 +990,7 @@ if (!empty($getlogpodtl)) { + -