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 // 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() public function loadView_bagStockDetails()
{ {
@ -636,13 +677,14 @@ class StockController extends BaseController
$month = $formattedDate; $month = $formattedDate;
//filterMaterialCode
$filterMaterialCode = $this->request->getPost('filterMaterialCode');
$filterMaterialCode = $this->request->getPost('filterMaterialCode'); $filterMaterialCode = $this->request->getPost('filterMaterialCode');
} else { } else {
$month = date('Y-m'); $month = date('Y-m');
$filterMaterialCode = ['601529'];
} }
$data = []; $data = [];
@ -672,7 +714,13 @@ class StockController extends BaseController
$startDate = "$month-01"; $startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate)); $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 // Initialize an empty array to hold the grouped data
$data['groupedBagStockDetails'] = []; $data['groupedBagStockDetails'] = [];
@ -717,14 +765,19 @@ class StockController extends BaseController
// if not get all the material codes from the raw material details table // if not get all the material codes from the raw material details table
if (!empty($data['groupedBagStockDetails'])) { if (!empty($data['groupedBagStockDetails'])) {
$result = $groupedByDate[$date];
$bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($filterMaterialCode); $distinctMaterialCodes = [];
} else {
$bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode($filterMaterialCode); foreach ($result as $index => $eachResult) {
$distinctMaterialCodes[] = $result[$index]['materialCode'];
} }
$bagMaterials = $this->rawmaterialdetails_model->getSelectedBagMaterialCode($distinctMaterialCodes);
} else {
$bagMaterials = $this->rawmaterialdetails_model->getAllBagMaterialCode();
}
// getting customer for creating table headers // getting customer for creating table headers

View File

@ -164,35 +164,27 @@ class Rawmaterialdetails_model extends Model
return array_column($materialResults, 'MaterialCode'); 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') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName') ->select('MaterialCode, MaterialName')
->where('Category', 'Packing Material') ->where('Category', 'Packing Material')
->where('IsActive', 1); ->where('IsActive', 1)
->orderBy('MaterialCode', 'asc');
if (!empty($filterMaterialCode)) {
$builder->whereIn('MaterialCode', $filterMaterialCode);
}
$builder->orderBy('MaterialCode', 'asc');
$query = $builder->get(); $query = $builder->get();
return $query->getResultArray(); 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') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName') ->select('MaterialCode, MaterialName')
->where('Category', 'Packing Material'); ->where('Category', 'Packing Material')
->whereIn('MaterialCode', $distinctMaterialCodes)
if (!empty($filterMaterialCode)) { ->orderBy('MaterialCode', 'asc');
$builder->whereIn('MaterialCode', $filterMaterialCode);
}
$builder->orderBy('MaterialCode', 'asc');
$query = $builder->get(); $query = $builder->get();
return $query->getResultArray(); return $query->getResultArray();
} }