stock module latest today vadivel J 06-02-2025

This commit is contained in:
vadivelJ96 2025-02-06 12:17:43 +05:30
parent 67ba0ffce8
commit 93cdd3aa32
2 changed files with 71 additions and 26 deletions

View File

@ -624,6 +624,47 @@ class StockController extends BaseController
// Bag Stock details starts
//custom filterMaterialCode given by user
//two types of custom filter
//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 ..!!
//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..
//----------------1st part finished----//
//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 ..!!
//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()
{
@ -634,15 +675,16 @@ class StockController extends BaseController
$formattedDate = $date->format('Y-m');
$month = $formattedDate;
$month = $formattedDate;
//filterMaterialCode
$filterMaterialCode = $this->request->getPost('filterMaterialCode');
$filterMaterialCode = $this->request->getPost('filterMaterialCode');
} else {
$month = date('Y-m');
$filterMaterialCode = ['601529'];
}
$data = [];
@ -672,7 +714,13 @@ class StockController extends BaseController
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$data['bagStockDetails'] = $this->bagStockDetails_model->getBagStockForGivenMonth($startDate , $endDate ,$filterMaterialCode);
$data['bagStockDetails'] = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->groupBy(['materialCode', 'date'])
->orderBy('date', 'asc')
->orderBy('materialCode', 'asc')
->findAll();
// Initialize an empty array to hold the grouped data
$data['groupedBagStockDetails'] = [];
@ -717,15 +765,20 @@ class StockController extends BaseController
// if not get all the material codes from the raw material details table
if (!empty($data['groupedBagStockDetails'])) {
$result = $groupedByDate[$date];
$bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($filterMaterialCode);
$distinctMaterialCodes = [];
foreach ($result as $index => $eachResult) {
$distinctMaterialCodes[] = $result[$index]['materialCode'];
}
$bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($distinctMaterialCodes);
} else {
$bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode($filterMaterialCode);
$bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode();
}
// getting customer for creating table headers
// checking already existing stock if yes then get customer from the existing stock

View File

@ -164,35 +164,27 @@ class Rawmaterialdetails_model extends Model
return array_column($materialResults, 'MaterialCode');
}
function getAllBagMaterialCode($filterMaterialCode)
function getAllBagMaterialCode()
{
//when no data present for current month we are showing only active materials with filter option
$builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName')
->where('Category', 'Packing Material')
->where('IsActive', 1);
if (!empty($filterMaterialCode)) {
$builder->whereIn('MaterialCode', $filterMaterialCode);
}
$builder->orderBy('MaterialCode', 'asc');
->where('IsActive', 1)
->orderBy('MaterialCode', 'asc');
$query = $builder->get();
return $query->getResultArray();
}
function getSelectedBagMaterialCode($filterMaterialCode)
function getSelectedBagMaterialCode($distinctMaterialCodes)
{
//when data present with whether material is active or not we have to show them with filter option
$builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName')
->where('Category', 'Packing Material');
if (!empty($filterMaterialCode)) {
$builder->whereIn('MaterialCode', $filterMaterialCode);
}
$builder->orderBy('MaterialCode', 'asc');
->where('Category', 'Packing Material')
->whereIn('MaterialCode', $distinctMaterialCodes)
->orderBy('MaterialCode', 'asc');
$query = $builder->get();
return $query->getResultArray();
}