changes in master module 11-03-2025

This commit is contained in:
vadivelJ96 2025-03-11 09:57:39 +05:30
parent 725c96a123
commit 7569114c1f
10 changed files with 763 additions and 728 deletions

View File

@ -66,6 +66,7 @@ $routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRaw
$routes->get('exportmaterial', 'Rawmaterialdetails::exportmaterial');
$routes->post('deleteMaterial', 'Rawmaterialdetails::deleteMaterial');
$routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial');
$routes->post('materialCodesConfigCategory', 'Rawmaterialdetails::materialCodesConfigCategory');
// Cost Center Routes
$routes->match(['GET','POST'],'costListing', 'CostCenter::index');
@ -145,12 +146,13 @@ $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/editconfig', 'Configurationctrl::editconfig');
$routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig');
$routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck');
$routes->get('configurationctrl/deleteConfig', 'Configurationctrl::deleteConfig');
$routes->get('configurationctrl/reActivateConfig', 'Configurationctrl::reActivateConfig');
$routes->post('configurationctrl/saveConfigValue', 'Configurationctrl::saveConfigValue');
// Department Master Routes
$routes->match(["GET","POST"],'departmentListing', 'Department::index');

View File

@ -84,13 +84,32 @@ class Configurationctrl extends BaseController
function editconfig($ConfigID = '')
{
$ConfigID = $this->request->getVar('ConfigID');
$isActiveFilter = 1 ; // default flag for active data
$showArchive = 0 ; // default flag for inactive data
if ($this->request->getMethod() === 'POST') {
$ConfigID = $this->request->getPost('ConfigID');
$showArchive = $this->request->getPost('showArchive');
//reversing condition that when user wants deleted data (archived)to be shown , then we are making active filter 0
if($showArchive){
$isActiveFilter = 0;
}
}
if ($this->request->getMethod() === 'GET') {
$ConfigID = $this->request->getVar('ConfigID');
}
$data['showArchive'] = $showArchive;
$data['master'] = $this->configmodel->GetConfigCenterMaster($ConfigID);
$data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID);
$data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID,$isActiveFilter);
$data['ConfigID'] = $ConfigID;
$this->global['pageTitle'] = 'Edit Config';
// echo "<pre>";
// print_r($data);die;
$this->loadViews("editconfig", $this->global, $data, NULL);
}
@ -175,7 +194,7 @@ class Configurationctrl extends BaseController
$data = $this->request->getPost();
$configId = $data['configId'];
$configValue = $data['ConfigValue'];
$configValue = str_replace(" ","",$data['configValue']);
$result = $this->configmodel->configValueCheck($configId, $configValue);
@ -187,9 +206,13 @@ class Configurationctrl extends BaseController
$key = $this->request->getVar('key');
$value = $this->request->getVar('value');
$ConfigID = $this->request->getVar('ConfigID');
$where = ['isActive'=> $value];
$result = $this->configmodel->activeInactiveConfigValue($key, $where);
return redirect()->back();
return redirect()->to(base_url('configurationctrl/editconfig?ConfigID=' . $ConfigID));
}
public function getPONOcreatedBasedOnConfig(){
$data = $this->request->getPost();
@ -223,6 +246,24 @@ class Configurationctrl extends BaseController
return redirect()->back();
}
public function saveConfigValue(){
$data = $this->request->getPost();
$configId = $data['ConfigID'];
$configValue = $data['ConfigValue'];
$key = $data['key']??'';
$result = $this->configmodel->saveConfigValue($key,$configId, $configValue);
if($result){
return $this->response->setJSON(['status'=>true]);
}else{
return $this->response->setJSON(['status'=>true]);
}
}
}

View File

@ -66,14 +66,14 @@ class Rawmaterialdetails extends BaseController
function rawmaterialListing()
{
$isActiveFilter = 1 ; // default showing active data
$showArchive = 0 ; //
$isActiveFilter = 1 ; // default flag for active data
$showArchive = 0 ; // default flag for inactive data
if ($this->request->getMethod() === 'POST') {
$showArchive = $this->request->getPost('showArchive');
//reversing condition that when user wants deleted data to be shown we are making active filter
if($showArchive){
//reversing condition that when user wants deleted data (archived)to be shown , then we are making active filter 0
if($showArchive){
$isActiveFilter = 0;
}
}
@ -144,7 +144,7 @@ class Rawmaterialdetails extends BaseController
function addRawMaterial()
{
$this->rawmaterialdetails_model = new rawmaterialdetails_model();;
$this->rawmaterialdetails_model = new rawmaterialdetails_model();
$data['material'] = $this->rawmaterialdetails_model->getmaterialType();
$data['materialcategory'] = $this->rawmaterialdetails_model->getmaterialCategory();
// $data['materialCategoryList']= $this->materialCategories_model->where('is_active',1)->findAll();
@ -303,6 +303,7 @@ class Rawmaterialdetails extends BaseController
$data['cfUOM'] = $this->rawmaterialdetails_model->getConversionfactorUOM();
$data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode();
$data['avg_price'] = $this->rawmaterialdetails_model->getMaterialAvg($RawMaterialID);
//print_r($data['avg_price']);die();
$this->global['pageTitle'] = 'Edit Material Master';
$this->loadViews("editRawmaterial", $this->global, $data, NULL);
@ -492,5 +493,31 @@ class Rawmaterialdetails extends BaseController
}
function materialCodesConfigCategory (){
$configKey = $this->request->getPost('configKey');
//need to get the config key from the post data
$result = $this->rawmaterialdetails_model->materialCodesConfigCategory($configKey);
return $this->response->setJSON($result);
}
}

View File

@ -2329,317 +2329,288 @@ class StockController extends BaseController
// Bag Stock details starts
public function loadView_bagStockDetails()
{
//custom filterMaterialCode given by user
if ($this->request->getMethod() === 'POST') {
$month = $this->request->getPost('month');
//two types of custom filter
$date = DateTime::createFromFormat('M-Y', $month);
//1) fliter for no data present in db - active and is active is not a concern ..!!(for current month)
// + adding new material in packing material category is not a concern ..!!
// - deleting existing material in packing material category is not a concern ..!!
$formattedDate = $date->format('Y-m');
//fetch all active material in bag stock then ,
// i) if no custom filter option given , all active material code going to be present in filterMaterialCode .
// ii)if custom filter option given , what are all the materials active is going to be filtered among given filterMaterialCode..
$month = $formattedDate;
$session = session ();
$session->set('stock_month',$month);
//----------------1st part finished----//
} else {
$session = session();
//2) filter for data present in db -- active and is active is a concern ..!!
// + adding new material category in packing material is a concern ..!!
// - deleting existing material category in packing material is a concern ..!!
$month = $session->get('stock_month');
//for second case if already material present in db but deleted in material master means
// i) we need to show the deleted one too for that month .
// ii)check If they add another material in packing material for current month,
// we need to put dummy entry(empty string) and show that as well.
//wild scenario if user wants to add an new material and its entry in previous month
//i) Hard code database entry after consultation can be entertained..!!
//-------------- 2nd part finished -----//
// Action
public function loadView_bagStockDetails()
{
if ($this->request->getMethod() === 'POST') {
$month = $this->request->getPost('month');
$date = DateTime::createFromFormat('M-Y', $month);
$formattedDate = $date->format('Y-m');
$month = $formattedDate;
$session = session ();
$session->set('stock_month',$month);
} else {
$session = session();
$month = $session->get('stock_month');
if (empty($month)) {
$month = date('Y-m'); // Default to the current month
}
}
$data = [];
$data['month'] = $month;
$this->global['pageTitle'] = 'Bag Stock Details';
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$customisedMaterialCodes = $this->request->getPost('customisedMaterialCodes') ?? [];
$existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel
->select('materialCode')
->where('date',"$month-01")
->where('stock_category','packing_material')
->findAll();
//check user applies for filter currently
if(!empty($customisedMaterialCodes)){
//user applied filter,
//check already filter existing , if exists remove that ,
if(!empty($existingCustomMaterialCodes)){
//hard delete done..!!
$existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel
->where('date',"$month-01")
->where('stock_category','packing_material')
->delete();
}
//if no filter already exists or removed current one , just add current filter for that month ....!!
$inserts = [];
foreach($customisedMaterialCodes as $index => $customisedMaterialCode){
$inserts [] = [
'date' => "$month-01",
'stock_category' => "packing_material",
'materialCode' => $customisedMaterialCode
];
//checking filtered material code present in table , if not create dummy one for whole month
$findMaterialCode = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode',$customisedMaterialCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMaterialCode)){
//create dummy entry for that
$this->createDummyEntryForBag($customisedMaterialCode,$startDate,$endDate);
}
if (empty($month)) {
$month = date('Y-m'); // Default to the current month
}
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMaterialInStockModel->insertBatch($inserts);
$data = [];
//get the currently applied filter
$existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel
$data['month'] = $month;
$this->global['pageTitle'] = 'Bag Stock Details';
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
///////////////////////////filter part starts//////////////////////////
$customisedMaterialCodes = $this->request->getPost('customisedMaterialCodes') ?? [];
$existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel
->select('materialCode')
->where('date',"$month-01")
->where('stock_category','packing_material')
->get()->getResultArray();
->findAll();
//check user applies for filter currently
if(!empty($customisedMaterialCodes)){
//user applied filter,
//check already filter existing , if exists remove that ,
if(!empty($existingCustomMaterialCodes)){
//hard delete done..!!
$existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel
->where('date',"$month-01")
->where('stock_category','packing_material')
->delete();
}
//if no filter already exists or removed current one , just add current filter for that month ....!!
$inserts = [];
foreach($customisedMaterialCodes as $index => $customisedMaterialCode){
$inserts [] = [
'date' => "$month-01",
'stock_category' => "packing_material",
'materialCode' => $customisedMaterialCode
];
//checking filtered material code present in table , if not create dummy one for whole month
$findMaterialCode = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode',$customisedMaterialCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMaterialCode)){
//create dummy entry for that
$this->createDummyEntryForBag($customisedMaterialCode,$startDate,$endDate);
}
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMaterialInStockModel->insertBatch($inserts);
//get the currently applied filter
$existingCustomMaterialCodes = $this->monthWiseMaterialInStockModel
->select('materialCode')
->where('date',"$month-01")
->where('stock_category','packing_material')
->get()->getResultArray();
}
}
}
//possible if no filter applied at all...!!!
if(empty($existingCustomMaterialCodes)){
//no filter applied at all just present all active material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getAllBagMaterialCode();
}else{
//if filter present,get that material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getSelectedBagMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode'));
}
$materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode');
$bagMaterials = $existingCustomMaterialCodes ;
$data['activeBagMaterials'] = $this->rawmaterialdetails_model->getAllBagMaterialCode();
// Get the previous month's last date bag stock details for next month updation
$previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m');
$previousMonthStartDate = "$previousMonth-01";
$previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate));
$data['previousMonthBagStockDetails'] = $this->bagStockDetails_model
->select(['materialCode', 'date', 'balanceStock'])
->distinct()
->where('date =', $previousMonthEndDate)
->groupBy(['materialCode', 'date'])
->orderBy('date', 'desc')
->orderBy('materialCode', 'asc')
->findAll();
// checking in database if the data is available for the month
$data['bagStockDetails'] = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->whereIn('materialCode',$materialCodeList)
->groupBy(['materialCode', 'date'])
->orderBy('date', 'asc')
->orderBy('materialCode', 'asc')
->findAll();
// Initialize an empty array to hold the grouped data
$data['groupedBagStockDetails'] = [];
// Temporary array to store grouped data by date
$groupedByDate = [];
// Group by 'date'
foreach ($data['bagStockDetails'] as $detail) {
$date = $detail['date'];
// Initialize the array for this date if it doesn't exist
if (!isset($groupedByDate[$date])) {
$groupedByDate[$date] = [];
//possible if no filter applied at all...!!!
if(empty($existingCustomMaterialCodes)){
//no filter applied at all just present all active material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getAllBagMaterialCode();
}else{
//if filter present,get that material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getSelectedBagMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode'));
}
/*******************************************************************************************************************
creating an sub array (inner array) for date wise and append the detail into an array as sub-array
$materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode');
$groupedByDate[] outer array
$bagMaterials = $existingCustomMaterialCodes ;
$groupedByDate[$date]
will look like [[bag1],[bag2],[bag3],[bag4],[bag5]] inner array
the above process is done for single row (date wise) and the same process is repeated for all the rows
*******************************************************************************************************************/
$data['activeBagMaterials'] = $this->rawmaterialdetails_model->getAllBagMaterialCode();
// Append the detail to the sub-array for this date
$groupedByDate[$date][] = $detail;
}
///////////////////////////filter part ends//////////////////////////
// Reset the structure to have indexed arrays without the date keys
$data['groupedBagStockDetails'] = array_values($groupedByDate);
// getting customer for creating table headers
// checking already existing stock if yes then get customer from the existing stock
// if not set customer as '' empty string
foreach ($bagMaterials as $key => $bagMaterial) {
$materialCode = $bagMaterial['MaterialCode'];
$bagMaterials[$key]['customers'] = $this->bagStockDetails_model
->select('customer')
// Get the previous month's last date bag stock details for next month updation
$previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m');
$previousMonthStartDate = "$previousMonth-01";
$previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate));
$data['previousMonthBagStockDetails'] = $this->bagStockDetails_model
->select(['materialCode', 'date', 'balanceStock'])
->distinct()
->where('date =', $previousMonthEndDate)
->groupBy(['materialCode', 'date'])
->orderBy('date', 'desc')
->orderBy('materialCode', 'asc')
->findAll();
// checking in database if the data is available for the month
$data['bagStockDetails'] = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode', $materialCode)
->first()['customer'] ?? '';
}
->whereIn('materialCode',$materialCodeList)
->groupBy(['materialCode', 'date'])
->orderBy('date', 'asc')
->orderBy('materialCode', 'asc')
->findAll();
$bagMaterialcount = count($bagMaterials);
// Initialize an empty array to hold the grouped data
$data['groupedBagStockDetails'] = [];
$data['bagMaterialcount'] = $bagMaterialcount;
$data['bagMaterials'] = $bagMaterials;
// Temporary array to store grouped data by date
$groupedByDate = [];
$date = DateTime::createFromFormat('Y-m', $month);
// Group by 'date'
foreach ($data['bagStockDetails'] as $detail) {
$date = $detail['date'];
$formattedDate = $date->format('M-Y');
$data['month'] = $formattedDate;
return $this->loadViews("stock/bagStockDetails", $this->global, $data, NULL);
}
public function updateBagStockDetails()
{
$postData = $this->request->getPost();
$updateBagStockDetailsData = json_decode($postData['updateBagStockDetails'], true);
$inserts = [];
$updates = [];
foreach ($updateBagStockDetailsData as $data) {
$date = $data['date'];
$materialCode = $data['materialCode'];
// Initialize the array for this date if it doesn't exist
if (!isset($groupedByDate[$date])) {
$groupedByDate[$date] = [];
}
$dbData = [
'date' => $data['date'],
'materialCode' => $data['materialCode'],
'customer' => $data['customer'],
'opening' => $data['opening'],
'receipt' => $data['receipt'],
'used' => $data['used'],
'balanceStock' => $data['balanceStock'],
];
/*******************************************************************************************************************
creating an sub array (inner array) for date wise and append the detail into an array as sub-array
$resultExists = $this->bagStockDetails_model
->where('date', $date)
->where('materialCode', $materialCode)
->first();
$groupedByDate[] outer array
$groupedByDate[$date]
will look like [[bag1],[bag2],[bag3],[bag4],[bag5]] inner array
the above process is done for single row (date wise) and the same process is repeated for all the rows
*******************************************************************************************************************/
if (empty($resultExists)) {
$inserts[] = $dbData;
} else {
$dbData['id'] = $resultExists['id'];
$updates[] = $dbData;
// Append the detail to the sub-array for this date
$groupedByDate[$date][] = $detail;
}
}
if (!empty($inserts)) {
$inserted = $this->bagStockDetails_model->insertBatch($inserts);
}
if (!empty($updates)) {
$updateResult = $this->bagStockDetails_model->updateBatch($updates, 'id');
if ($updateResult === FALSE) {
echo "Error during update";
} else {
echo "Data Updated Successfully";
return;
// Reset the structure to have indexed arrays without the date keys
$data['groupedBagStockDetails'] = array_values($groupedByDate);
// getting customer for creating table headers
// checking already existing stock if yes then get customer from the existing stock
// if not set customer as '' empty string
foreach ($bagMaterials as $key => $bagMaterial) {
$materialCode = $bagMaterial['MaterialCode'];
$bagMaterials[$key]['customers'] = $this->bagStockDetails_model
->select('customer')
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode', $materialCode)
->first()['customer'] ?? '';
}
$bagMaterialcount = count($bagMaterials);
$data['bagMaterialcount'] = $bagMaterialcount;
$data['bagMaterials'] = $bagMaterials;
$date = DateTime::createFromFormat('Y-m', $month);
$formattedDate = $date->format('M-Y');
$data['month'] = $formattedDate;
return $this->loadViews("stock/bagStockDetails", $this->global, $data, NULL);
}
echo "Data Saved Successfully";
}
public function updateBagStockDetails()
{
$postData = $this->request->getPost();
$updateBagStockDetailsData = json_decode($postData['updateBagStockDetails'], true);
$inserts = [];
$updates = [];
foreach ($updateBagStockDetailsData as $data) {
$date = $data['date'];
$materialCode = $data['materialCode'];
$dbData = [
'date' => $data['date'],
'materialCode' => $data['materialCode'],
'customer' => $data['customer'],
'opening' => $data['opening'],
'receipt' => $data['receipt'],
'used' => $data['used'],
'balanceStock' => $data['balanceStock'],
];
$resultExists = $this->bagStockDetails_model
->where('date', $date)
->where('materialCode', $materialCode)
->first();
if (empty($resultExists)) {
$inserts[] = $dbData;
} else {
$dbData['id'] = $resultExists['id'];
$updates[] = $dbData;
}
}
if (!empty($inserts)) {
$inserted = $this->bagStockDetails_model->insertBatch($inserts);
}
if (!empty($updates)) {
$updateResult = $this->bagStockDetails_model->updateBatch($updates, 'id');
if ($updateResult === FALSE) {
echo "Error during update";
} else {
echo "Data Updated Successfully";
return;
}
}
echo "Data Saved Successfully";
}
@ -2796,7 +2767,7 @@ class StockController extends BaseController
$inserts = [];
$inserts = $this->generateDummyData($startDate, $endDate);
$inserts = $this->createDummyDataForTrp($startDate, $endDate);
$freshEntry = true ;
@ -3013,70 +2984,6 @@ class StockController extends BaseController
public function generateDummyData($startDate, $endDate)
{
$datesInMonth = [];
$inserts = [];
$trpAbstract = [] ;
$period = new DatePeriod(
new DateTime($startDate),
new DateInterval('P1D'),
(new DateTime($endDate))->modify('+1 day')
);
foreach ($period as $day) {
$datesInMonth[] = $day->format('Y-m-d');
}
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
$inserts[] = [
'Date' => $dateInMonth,
'openingTime' => " ",
'closingTime' => " ",
'totalHours' => " ",
'coldStart' => " ",
'breakdownHours' => " ",
'burnerFiringHours' => " ",
'sandFeedingHours' => " ",
'workingPersonEngineers' => " ",
'workingPersonSupervisiors' => " ",
'workingPersonOperators' => " ",
'rollerDrivers' => " ",
'natureOfMaintenance' => '',
'location' => '',
'description' => '',
'gasReceiptBg' => " ",
'gasReceiptPg' => " ",
'physicalGasConsumption' => " ",
'trpPlusDrierGasConsumption' => " ",
'trpPhysicalGasPerTon' => " ",
'panelGasConsumption' => " ",
'panelGasPerTon' => " ",
'edRunningHours' => " ",
'edProduction' => " ",
'edUsage' => " ",
'trpProduction' => " ",
'trpProductionPerHour' => " ",
'waterReceipt' => " ",
'waterConsumption' => " ",
'ebReading' =>" ",
'ebReadingPerUnitTon' =>" ",
'msSeperation' => " ",
'edWaste' => " ",
'coolerBags' =>" ",
'edPlus20Waste' => " ",
'cycloneWaste' => " "
];
}
return $inserts;
}
public function updateAbstractDetails() {
$updateAbstractDetails = json_decode($this->request->getPost('updateAbstractDetails'), true);
@ -3299,6 +3206,67 @@ class StockController extends BaseController
}
public function createDummyDataForTrp($startDate, $endDate)
{
$datesInMonth = [];
$inserts = [];
$trpAbstract = [] ;
$period = new DatePeriod(
new DateTime($startDate),
new DateInterval('P1D'),
(new DateTime($endDate))->modify('+1 day')
);
foreach ($period as $day) {
$datesInMonth[] = $day->format('Y-m-d');
}
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
$inserts[] = [
'Date' => $dateInMonth,
'openingTime' => " ",
'closingTime' => " ",
'totalHours' => " ",
'coldStart' => " ",
'breakdownHours' => " ",
'burnerFiringHours' => " ",
'sandFeedingHours' => " ",
'workingPersonEngineers' => " ",
'workingPersonSupervisiors' => " ",
'workingPersonOperators' => " ",
'rollerDrivers' => " ",
'natureOfMaintenance' => '',
'location' => '',
'description' => '',
'gasReceiptBg' => " ",
'gasReceiptPg' => " ",
'physicalGasConsumption' => " ",
'trpPlusDrierGasConsumption' => " ",
'trpPhysicalGasPerTon' => " ",
'panelGasConsumption' => " ",
'panelGasPerTon' => " ",
'edRunningHours' => " ",
'edProduction' => " ",
'edUsage' => " ",
'trpProduction' => " ",
'trpProductionPerHour' => " ",
'waterReceipt' => " ",
'waterConsumption' => " ",
'ebReading' =>" ",
'ebReadingPerUnitTon' =>" ",
'msSeperation' => " ",
'edWaste' => " ",
'coolerBags' =>" ",
'edPlus20Waste' => " ",
'cycloneWaste' => " "
];
}
return $inserts;
}

View File

@ -85,7 +85,6 @@ class Config_model extends Model
$builder = $this->db->table('t_configmaster')
->select('*')
//->join('t_configdetails con','con.Config_ID = COM.Config_ID','left')
->where('Config_ID', $ConfigID);
$query = $builder->get();
@ -93,13 +92,14 @@ class Config_model extends Model
return $query->getResult();
}
function GetConfigCenterDetails($ConfigID = '')
function GetConfigCenterDetails($ConfigID = '',$isActiveFilter)
{
//echo $ConfigID ;die();
$builder = $this->db->table('t_configmaster COM')
->select('*')
->join('t_configdetails con', 'con.Config_ID = COM.Config_ID', 'left')
->where('COM.Config_ID', $ConfigID);
->where('COM.Config_ID', $ConfigID)
->where('con.isActive', $isActiveFilter);
$query = $builder->get();
return $query->getResult();
@ -193,13 +193,11 @@ class Config_model extends Model
public function configValueCheck($configId , $configValue){
$builder = $this->db->table('t_configdetails')
->where('Config_ID',$configId)
->where('configValue ', $configValue);
$query = $builder->get();
->where('Config_ID',$configId);
$builder = $builder->where('REPLACE(configValue , " ", "") ',$configValue);
$query = $builder->get();
// dd( $this->db->getLastQuery());
return $query->getResultArray();
return $query->getResultArray();
}
public function activeInactiveConfigValue($key, $value){
@ -289,4 +287,32 @@ return $result;
// 'PO_RELEASED','ST026'
}
public function saveConfigValue($key,$configId, $configValue){
if(!empty($key)){
$builder = $this->db->table('t_configdetails')
->where('Config_ID', $configId)
->where('key',$key)
->update([
'ConfigValue'=> $configValue
]);
$res = $this->db->affectedRows();
return $res;
}else{
$builder = $this->db->table('t_configdetails');
$builder->insert(
[
'ConfigValue'=>$configValue,
'Config_ID'=>$configId,
'isActive'=> 1]);
$res = $this->db->affectedRows();
return $res;
}
}
}

View File

@ -426,4 +426,24 @@ where (CurrentStock+OpeningStock)<reorder";
return $query->getResultArray();
}
function materialCodesConfigCategory($configKey){
$builder = $this->db->table('t_materialmaster MM')
->select('MM.MaterialCode,MM.MaterialName,MM.MaterialType,MM.Category,MM.IsActive,MM.UOM')
->where('MM.Category' , $configKey);
$query = $builder->get();
if ($query->getNumRows() > 0) {
//return $this->db->getLastQuery();
return $query->getResultArray();
} else {
return [];
}
}
}

View File

@ -123,11 +123,7 @@
<div style="margin-left:auto">
<div class="form-check" style="margin-right: 25px;">
<input class="form-check-input" type="checkbox" id="showArchiveId" name="showArchive" value="1"
onchange="showArchiveList()" style="width: 18px; height: 18px;">
<label class="form-check-label" for="showArchiveId" style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</div>
</div>
@ -172,34 +168,11 @@
<td><?= $record->isActive == 1 ? 'Active' : 'InActive'; ?></td>
<td>
<?php if ($record->isActive == 0) { ?>
<a onclick="confirmReActivateConfig(event)"
href="<?php echo base_url() . 'configurationctrl/reActivateConfig?ConfigID=' . $record->Config_ID; ?>"
data-toggle="tooltip"
title="<?php echo $record->Config_ID ?> - Click here to Re activate Config Details"><i
class="fas fa-key"></i>
</a>
<?php } else { ?>
<a href="<?php echo base_url() . 'configurationctrl/editconfig?ConfigID=' . $record->Config_ID; ?>"
data-toggle="tooltip"
title="<?php echo $record->Config_ID ?> - Click here to Edit Config Details">
<i class="fas fa-edit"></i>
</a>
&nbsp;&nbsp;
<!-- <a onclick="confirmDeleteConfig(event)"
href="<?php echo base_url() . 'configurationctrl/deleteConfig?ConfigID=' . $record->Config_ID; ?>"
data-toggle="tooltip"
title="<?php echo $record->Config_ID ?> - Click here to Delete Config Details">
<i class="fas fa-trash" data-toggle="tooltip" title="Click here to Delete the Config Value"></i>
</a> -->
<?php } ?>
<a href="<?php echo base_url() . 'configurationctrl/editconfig?ConfigID=' . $record->Config_ID; ?>"
data-toggle="tooltip"
title="<?php echo $record->Config_ID ?> - Click here to Edit Config Details">
<i class="fas fa-edit"></i>
</a>
</td>
</tr>
@ -317,42 +290,3 @@
</script>
<script>
function showArchiveList() {
let isChecked = $("#showArchiveId").prop('checked');
// Show or hide the rows based on checkbox status
$(".deactivatedRow").each(function () {
if (isChecked) {
$(this).show();
} else {
$(this).hide();
}
});
}
$(document).ready(function () {
let table = $('#config_list_table').DataTable();
showArchiveList();
table.on('draw', function () {
showArchiveList();
});
});
function confirmDeleteConfig(event) {
let result = confirm("Do You want to delete this configuration ?");
if (result) { return; } else { event.preventDefault(); }
}
function confirmReActivateConfig(event) {
let result = confirm("Do You want to Re activate deleted configuration ?");
if (result) { return; } else { event.preventDefault(); }
}
</script>

View File

@ -1,5 +1,5 @@
<script>
//window.onload=al();
function al() {
alert($('#ConfigId').val());
}
@ -64,7 +64,7 @@ if (!empty($master)) {
<div class="col-12">
<div class="card">
<div class="card-body">
<?php
<?php
$attributes = array('class' => 'form-horizontal', 'id' => 'editConfig');
echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?>
@ -95,6 +95,7 @@ if (!empty($master)) {
echo form_input($data);
?>
</div>
</div>
<div class="form-row" style="margin-top:10px">
@ -105,17 +106,22 @@ if (!empty($master)) {
</div>
</div>
<?php echo form_close(); ?>
<br>
<div>
<div align="right">
<div class="form-check" style="margin-right: 25px;">
<input class="form-check-input" type="checkbox" id="showChildArchiveId"
name="showChildArchive" value="1" onchange="showChildArchiveList()"
style="width: 18px; height: 18px;">
<label class="form-check-label" for="showChildArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
<form id="archiveFormId" action="<?php echo base_url("/configurationctrl/editconfig")?>" method="post">
<input class="form-check-input" type="checkbox" id="showArchiveId"
name="showArchive" value="1" <?php echo $showArchive ? "checked" : " " ?>
style="width: 18px; height: 18px;">
<input type="hidden" name="ConfigID" value="<?=$ConfigId?>" >
<label class="form-check-label" for="showArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</form>
</div>
</div>
@ -147,15 +153,21 @@ if (!empty($master)) {
id="configVal<?php echo $index ?>"
value="<?php echo $con->ConfigValue ?>">
<tr class="<?php if ($con->isActive == 0) {
echo "deactivatedRow";
} ?>" style="<?php if ($con->isActive == 0) {
echo "display:none";
} ?>">
<tr>
<td><?php echo $index; ?></td>
<td>
<?php echo $index; ?></td>
<?php if($con->Config_ID === 'C023'){ ?>
<td><a class="config-category" data-value="<?php echo $con->ConfigValue;?>" data-key="<?php echo $con->Key; ?>"><?php echo $con->ConfigValue ?></a></td>
<td>
<a
class="config-category"
data-value="<?php echo $con->ConfigValue;?>"
data-key="<?php echo $con->Key; ?>"
style="cursor: pointer;">
<?php echo $con->ConfigValue ?>
</a>
</td>
<?php }else{ ?>
<td><?php echo $con->ConfigValue; ?></td>
<?php } ?>
@ -163,26 +175,42 @@ if (!empty($master)) {
<?php if ($con->isActive == 0) { ?>
<a onclick="confirmReActivateConfig(event)" href="<?php echo base_url() . 'activeInactiveConfigValue
?key=' . $con->Key . '
&value=1'; ?>"
?key=' . $con->Key .
'&value=1'.
'&ConfigID=' . $con->Config_ID
; ?>"
data-toggle="tooltip" title="<?php echo $con->Config_ID ?> - Click here to Re
activate Config Details"><i class="fas fa-key"></i>
</a>
<?php } else { ?>
<a data-target='#Edit' data-id="<?php echo $index; ?>"
data-userid="<?php echo $index; ?>" data-toggle="modal"
href="#Edit"><i class="fas fa-edit" data-toggle="tooltip"
<!-- edit section -->
<a
class="editConfigurationBtn"
data-id="<?php echo $index; ?>"
data-key="<?php echo $con->Key; ?>"
data-code="<?php echo $con->Config_ID; ?>"
data-userid="<?php echo $index; ?>"
data-configvalue="<?php echo $con->ConfigValue; ?>"
href="#EditConfiguration"><i class="fas fa-edit" data-toggle="tooltip"
title="Click here to Edit Config Value"></i>
</a>
&nbsp;&nbsp; &nbsp;&nbsp;
<!-- delete section -->
<a onclick="confirmDeleteConfig(event)"
data-key="<?php echo $con->Key; ?>"
data-code="<?php echo $con->Config_ID; ?>"
href="<?php echo base_url() . 'activeInactiveConfigValue?key=' . $con->Key . '&value=0'; ?>"
href="<?php echo base_url() . 'activeInactiveConfigValue
?key=' . $con->Key .
'&value=0' .
'&ConfigID=' . $con->Config_ID
;
?>"
data-toggle="tooltip"
title="<?php echo $con->ConfigValue ?> - Click here to Delete Config Details">
<i class="fas fa-trash" data-toggle="tooltip" title="Click here to Delete the Config Value"></i>
@ -191,10 +219,13 @@ if (!empty($master)) {
</td>
</tr>
<?php }
} ?>
<input type="hidden" name="txtRowCount" id="txtRowCount"
value="<?php echo $index ?>" />
<?php
}
}
?>
</tbody>
</table>
</div>
@ -211,6 +242,13 @@ if (!empty($master)) {
</div>
</div>
<!-- modal_sec_starts -->
<!-- Modal For Add Configuration -->
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
@ -243,14 +281,14 @@ if (!empty($master)) {
<div class="modal-footer">
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px"
data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickAdd" id="tempClickAdd"> Add </a>
<button type="button" class="btn btn-success font " id="tempClickAdd"> Add </button>
</div>
</div>
</div>
</div>
<!-- Modal For Edit Configuration -->
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
<!-- Modal For Edit Configuration -->
<div class="modal fade" id="EditConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
@ -264,9 +302,9 @@ if (!empty($master)) {
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="row" >
<div class="col-md-3 col-md-offset-2">
S.NO :
Key :
</div>
<div class="col-md-5">
<?php
@ -307,17 +345,22 @@ if (!empty($master)) {
</form>
</div>
<!-- Modal Footer -->
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px"
data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickUpdate" id="tempClickUpdate"><i
class="fas fa-edit"></i>&nbsp;&nbsp;Update</a>
<button
type="button"
class=" btn btn-success font " id="tempClickUpdate"><i
class="fas fa-edit"></i>&nbsp;&nbsp;Update
</button>
</div>
</div>
</div>
</div>
<!-- Long Content Scroll Modal -->
<!-- Material listing Modal -->
<div class="modal fade" id="scrollable-modal" tabindex="-1" role="dialog" aria-labelledby="scrollableModalTitle" aria-hidden="true" style="max-width: 100%;">
<div class="modal-dialog modal-dialog-scrollable" role="document" style="max-width: 50%;">
<div class="modal-content">
@ -336,212 +379,203 @@ if (!empty($master)) {
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
</div>
<script type="text/html" id="tempList">
<tr id="<%=index%>">
<?php
$data = array('name' => '"configVal[<%=index%>][index]"', 'value' => set_value('<%=index%>'), 'id' => '"configVal[<%=index%>][index]"', 'class' => 'form-control', 'type' => 'hidden');
echo form_input($data);
?>
<td align="left"><%=index%></td>
<td align="left"><%=ConfigValue%></td>
<td>
<a data-target='#Edit' data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#Edit"><i class="fas fa-edit" data-toggle="tooltip" title="Click here to view/Edit the <%=ConfigValue%> Budget details"></i>&nbsp;&nbsp;&nbsp;</a>
</td>
</tr>
<!-- script_sec_starts -->
<script>
//prevent duplicate entries made in the config by checking it during on change event of the config value in add or edit
$('#AddConfigValue,#configValue').on('change', function() {
let configValue = $(this).val().trim(); //
$('#loader').show();
$.ajax({
type: 'POST',
url: "<?php echo base_url('configurationctrl/configValueCheck'); ?>",
data: {
configId: $('#ConfigId').val().trim(),
configValue: configValue
},
success: function(data) {
console.log(data);
if (data.length > 0) {
if (data[0]?.isActive == 1) {
alert("This Configuration Value is already present. Kindly change it.");
$('#AddConfigValue').val('');
$('#configValue').val('');
event.preventDefault();
}
if (data[0]?.isActive == 0) {
alert("This Configuration Value is already present in deleted section. Kindly reactivate it if needed.");
$('#AddConfigValue').val('');
$('#configValue').val('');
event.preventDefault();
}
}
},
error: function(xhr, status, error) {
console.log("Error occurred: ", error);
},
complete: function() {
$('#loader').hide();
console.log('AJAX call completed in change.');
}
});
});
</script>
<script>
$(document).ready(function() {
var index = $('#txtRowCount').val();
var userid = '';
$("#Edit").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
$('#key').val($('#configtable tr:eq(' + userid + ') td:eq(0)').text());
$('#Config_ID').val($('#ConfigId').val());
$('#configValue').val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
$('#ConfigVal' + userid).val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
// add config modals add button
$('#tempClickAdd').click( function() {
});
$('.tempClickAdd').click(function() {
var cid = $('#ConfigId').val()
if ($("#AddConfigValue").val() != '-1' && $("#AddConfigValue").val() != null && $("#AddConfigValue").val() != '') {
$('#AddConfigValue').show();
var ConfigValue = $("#AddConfigValue").val();
$('#AddConfigValue').val('');
if ($("#AddConfigValue").val() != '-1' && $("#AddConfigValue").val() != null && $("#AddConfigValue").val().trim() != '') {
index = parseInt(index) + 1;
var temp = index;
var template = jQuery("#tempList").html();
var html = `
<tr id="${temp}">
<td>${temp}</td>
<td>${ConfigValue}</td>
<td>
<a class="editConfig" data-target='#Edit' data-id="${temp}" data-index="${index}" data-userid="${temp}" data-toggle="modal" href="#Edit">
<i class="fas fa-edit"></i>
</a>
</td>
</tr>`;
$('#tempAppend').append(html);
var theForm = $(".editConfig");
addHidden(theForm, "DbKey" + temp, 0);
addHidden(theForm, "configVal" + temp, ConfigValue);
$('#txtRowCount').val(temp);
//CountRows();
$('#AddConfiguration').modal('hide');
} else {
alert('Please enter all the values');
}
});
function addHidden(theForm, key, value) {
// Create a hidden input element, and append it to the form:
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;
'name-as-seen-at-the-server';
input.value = value;
theForm.append(input);
}
$('.tempClickUpdate').click(function() {
if ($("#configValue").val() != '') {
var temp = index;
var ConfigValue = $("#configValue").val();
//alert(userid);
$('#configtable tr:eq(' + userid + ') td:eq(1)').text(ConfigValue);
//alert($('#hConfigValue'+userid).val());
//$('#hConfigValue'+userid).val(ConfigValue);
$('#Config_ID' + userid).val($('#ConfigId').val());
$('#configValue' + userid).val(ConfigValue);
$("#configVal" + userid).val(ConfigValue);
$('#Edit').modal('hide');
} else {
alert('Please enter all the values');
}
});
function ConfirmDelete() {
var x = confirm("Are you sure you want to delete?");
if (x)
return true;
else
return false;
}
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 &&
(charCode < 48 || charCode > 57))
return false;
return true;
}
//var baseurl = "<?php print base_url(); ?>";
$(".editConfig").submit(function(e) {
if (validate()) {
$('#loader').show();
$.ajax({
data: $('.editConfig').serialize(),
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configedit",
success: function(data) {
//alert(data);
$('#loader').hide();
if (data) {
$('#content').loader('hide');
//alert(data);
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
window.location = baseurl + 'CostCenter/CostListing';
$('#loader').show();
$.ajax({
url: "<?php echo base_url('configurationctrl/saveConfigValue'); ?>",
data: {
ConfigID: $('#ConfigId').val(),
ConfigValue: $("#AddConfigValue").val()
},
method: 'POST',
success: function(response) {
if (response.status) {
alert('Config Value added successfully');
location.reload();
} else {
alert('Failed to add Config Value');
}
},
error: function(xhr, status, error) {
console.log("Error occurred: ", error);
},
complete: function() {
console.log('AJAX call completed in tempClickAdd.');
$('#loader').hide();
}
});
} else {
alert('Please enter all the values');
}
});
//$('#content').loader('hide');
}
});
function validate() {
if ($("option:selected", $("#ApprovedBy")).val() == '-1') {
alert('Please Select Approver Names');
return false;
$(document).on('click', '.editConfigurationBtn', function() {
var id = $(this).data('id');
var key = $(this).data('key');
var code = $(this).data('code');
var configValue = $(this).data('configvalue');
$('#key').val(key);
$('#Config_ID').val(code);
$('#configValue').val(configValue);
$('#EditConfiguration').modal('show');
});
// edit config modals update button
$('#tempClickUpdate').click(function() {
if ($("#configValue").val() != '-1' && $("#configValue").val() != null && $("#configValue").val().trim() != '') {
$('#loader').show();
$.ajax({
url: "<?php echo base_url('configurationctrl/saveConfigValue'); ?>",
data: {
key : $('#key').val(),
ConfigID: $('#Config_ID').val(),
ConfigValue: $("#configValue").val()
},
method: 'POST',
success: function(response) {
if (response.status) {
alert('Config Value updated successfully');
location.reload();
} else {
alert('Failed to update Config Value');
}
},
error: function(xhr, status, error) {
console.log("Error occurred: ", error);
},
complete: function() {
console.log('AJAX call completed.');
$('#loader').hide();
}
});
} else {
return true;
alert('Please enter all the values');
}
}
});
//this click function is used for showing material codes in modal window , MC created using a particular configuration value
$(".config-category").click(function () {
const key_id = $(this).data("key");
const value = $(this).data("value");
$('#loader').show();
$('#scrollableModalTitle').text(`List of PO created using ${value} `);
$('#scrollableModalTitle').text(`List of Materials created using ${value} `);
// AJAX API call
$.ajax({
url: "<?php echo base_url('getPONOcreatedBasedOnConfig'); ?>",
data: { key_id: key_id },
method: 'POST',
dataType: 'json',
url: "<?php echo base_url('materialCodesConfigCategory'); ?>",
data: { configKey: key_id },
method: 'POST',
success: function (response) {
if (response.length > 0) {
if (response.length > 0) {
let tableHtml = `
<table class="table table-bordered">
<thead style="background-color: #539754; color: white; font-size: 12px;">
<tr>
<th style="text-align: center;" >PO Number</th>
<th>PO Date</th>
<th style="text-align: center;" >Material Code</th>
<th style="text-align: center;" >Material Name</th>
<th style="text-align: center;" >PO Type</th>
<th style="text-align: center;" >PO Status</th>
<th style="text-align: center;" >Material Type</th>
<th style="text-align: center;" >Material Status</th>
</tr>
</thead>
@ -551,14 +585,18 @@ if (!empty($master)) {
response.forEach(item => {
tableHtml += `
<tr>
<td class="pono-cell" data-pono="${item.PONO}" data-potype="${item.POType}" data-capitalrange="${item.CapitalRange}" style="cursor: pointer; color: #4d3a6d;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
<u>${item.PONO}</u>
<tr>
<td class="mc-cell"
data-materialCode="${item.MaterialCode}"
data-materialType="${item.MaterialType}"
data-uom="${item.UOM}"
style="cursor: pointer; color: #4d3a6d;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
<u>${item.MaterialCode}</u>
</td>
<td style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">${item.PODate}</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">${item.MaterialName}</td>
<td style="text-align:left;">${item.POType}</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">${item.StatusName}</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">${item.MaterialType}</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">${item.IsActive?"Active":"InActive"}</td>
</tr>
`;
@ -576,14 +614,22 @@ if (!empty($master)) {
$('#scrollable-modal').modal('show');
// Attach click event to PONO cells after the table is rendered
$('.pono-cell').click(function () {
const pono = $(this).data('pono');
const ReqType = $(this).data('potype');
const CapitalRange = $(this).data('capitalrange');
const url = '<?php echo base_url(); ?>EditPO?PONO=' + pono +'&ReqType='+ReqType+'&CapitalRange='+CapitalRange;
$('.mc-cell').click(function () {
const materialCode = $(this).attr('data-materialCode');
const materialType = $(this).attr('data-materialType');
const UOM =$(this).attr('data-uom');
let today = new Date();
let day = String(today.getDate()).padStart(2, '0'); // Ensure two-digit format
let month = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-based
let year = today.getFullYear();
let currentDate = `${day}-${month}-${year}`;
const url = '<?php echo base_url(); ?>viewRawmaterial?RID='+materialCode+'&MType='+materialType+'&UOM='+UOM+'&date1='+currentDate;
window.open(url, '_blank');
// window.location.href = url;
});
} else {
@ -591,12 +637,16 @@ if (!empty($master)) {
$('#scrollable-modal').modal('show');
}
$('#loader').hide();
},
error: function (xhr, status, error) {
// Handle any errors
console.error("API Error:", error);
alert("Failed to load material data.");
},
complete: function() {
$('#loader').hide();
console.log('ajax call completed..!!');
}
});
});
@ -605,8 +655,12 @@ if (!empty($master)) {
</script>
<script>
//final update button for master config add / update action made in the editConfig page
$('#updateConfigBtnId').click(function() {
alert("final config update..!!");
return;
if($('#ConfigName').val().trim() == ''){
@ -661,77 +715,10 @@ if (!empty($master)) {
});
</script>
<script>
$('#AddConfigValue, #configValue').change(function() {
let configValue = $(this).val().trim();
console.log(configValue,configValue.length);
let configTable = customTableToJson();
let configValueExisting = configTable.filter(element => element['Configuration Value'] == configValue);
if (configValueExisting && configValueExisting.length > 0) {
alert('configuration value is already present , Kindly check in Table and archive too..!!');
$(this).val('');
return false;
}
})
</script>
<script>
function customTableToJson() {
let rows = [];
let headers = [];
// Get table headers
$(`#configtable thead tr th`).each(function() {
headers.push($(this).text().trim());
});
// Get table rows including hidden ones
$(`#configtable tbody tr`).each(function() {
let row = {};
$(this).find('td').each(function(index) {
// Use the headers as keys for JSON
let header = headers[index];
row[header] = $(this).text().trim();
});
if (Object.keys(row).length > 0) {
rows.push(row);
}
});
return rows;
}
</script>
<script>
function showChildArchiveList() {
let isChecked = $("#showChildArchiveId").prop('checked');
// Show or hide the rows based on checkbox status
$(".deactivatedRow").each(function() {
if (isChecked) {
$(this).show();
} else {
$(this).hide();
}
});
}
$(document).ready(function() {
let table = $('#configtable');
showChildArchiveList();
table.on('draw', function() {
showChildArchiveList();
});
});
//confirm delete configuration
function confirmDeleteConfig(event) {
event.preventDefault(); // Prevent default link action
@ -739,28 +726,28 @@ if (!empty($master)) {
let code_value = $(event.currentTarget).data('code');
let deleteUrl = event.currentTarget.href; // Store the href URL
if (code_value == 'C023') {
if (code_value == 'C023') {
$.ajax({
type: 'POST',
url: "<?php echo base_url('getPONOcreatedBasedOnConfig'); ?>",
data: { key_id: key_id },
dataType: 'json',
url: "<?php echo base_url('materialCodesConfigCategory'); ?>",
data: { configKey: key_id },
success: function(data) {
let content = "Do you want to delete this configuration?";
if (data.length > 0) {
content += "\n\nCreated PONO's are - ";
content += "\n\nCreated Material Codes are - ";
data.forEach(function(item) {
content += "\n- " + item.PONO;
content += "\n- " + item.MaterialCode;
});
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?");
let result = confirm(content);
if (result) {
window.location.assign(deleteUrl); // Use assign() instead of href
}
@ -781,6 +768,7 @@ if (!empty($master)) {
}
}
//reactivate deleted configuration
function confirmReActivateConfig(event) {
let result = confirm("Do You want to Re activate deleted configuration ?");
if (result) {
@ -791,11 +779,31 @@ if (!empty($master)) {
}
</script>
<!-- Preventing default Enter key behavior to avoid submitting form in add or edit config values-->
<script>
$(document).on('keydown', function(event) {
if (event.key === 'Enter') {
event.preventDefault(); // Prevent default Enter key behavior
}
});
</script>
<!-- submitting form when show archive checkbox changes -->
<script>
$(document).on("change", "#showArchiveId", function () {
console.log("Checkbox changed, submitting form...");
$("#archiveFormId").submit();
});
</script>
<!-- data table added for the config value table -->
<script>
document.addEventListener("DOMContentLoaded", function () {
new DataTable("#configtable", {
paging: true, // Enable Pagination
ordering: true, // Enable Sorting
searching: true // Enable Search
});
});
</script>

View File

@ -34,6 +34,11 @@
.icon-button:hover {
color: #0056b3;
}
.category-search{
width: 20px !important;
}
</style>
@ -80,8 +85,9 @@
placeholder="Select To Date" autocomplete="off">
<!-- New Category Field -->
<label for="category">Category:</label>
<select class="form-control" style="width: auto !important;" autocomplete="off" id="category" name="category">
<div class="form-group">
<label for="category">Category:</label>
<select class="form-control category-search" autocomplete="off" id="category" name="category">
<option value="">Select Category </option>
<?php
if (!empty($materialCategoryList)) {
@ -89,7 +95,9 @@
?>
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option>
<?php } } ?>
</select>
</select>
</div>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true"
class="icon-button" title="Search"></i></button>
@ -579,4 +587,11 @@ $(document).ready(function () {
console.log("Checkbox changed, submitting form...");
$("#archiveFormId").submit();
});
</script>
<script>
$(document).ready(function(){
$('#category').select2();
});
</script>

View File

@ -361,7 +361,7 @@
<!-- modal2 - Edit Igr modal -->
<div id="Igrshow" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-dialog modal " style="width:1250px;">
<div class="modal-content">
<div class="modal-header">
@ -512,15 +512,9 @@
</tr>
</thead>
<tbody id="tbleIGRAppend">
<!-- <tr>
<td>1</td>
<td>RM002</td>
<td>Raw sand</td>
<td>Kgs</td>
<td>10000</td>
<td>10000</td>
<td>Received</td>
</tr> -->
</tbody>
</table>