diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 18b17b25..7d0fdad4 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -446,4 +446,12 @@ $routes->post('updateIncomingSilicaSandDetails', 'StockController::updateIncomin
//Bag stock details
$routes->match(['GET','POST'],'bagStockDetails', 'StockController::loadView_bagStockDetails');
-$routes->post('updateBagStockDetails', 'StockController::updateBagStockDetails');
\ No newline at end of file
+$routes->post('updateBagStockDetails', 'StockController::updateBagStockDetails');
+
+//Dust And Rough Stock Details
+$routes->match(['GET','POST'],'dustAndRoughStockDetails', 'StockController::loadView_dustAndRoughStockDetails');
+$routes->post('updateDustAndRoughStockDetails', 'StockController::updateDustAndRoughStockDetails');
+
+//Resin stock details
+$routes->match(['GET','POST'],'resinStockDetails', 'StockController::loadView_resinStockDetails');
+$routes->post('updateResinStockDetails', 'StockController::updateResinStockDetails');
\ No newline at end of file
diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php
index d68212d4..fd66d3eb 100644
--- a/app/Controllers/StockController.php
+++ b/app/Controllers/StockController.php
@@ -13,6 +13,8 @@ use App\Models\IncomingSilicaSandDetailsModel;
use App\Models\Inwardgateregister_model;
use App\Models\Rawmaterialdetails_model;
use App\Models\BagStockDetailsModel;
+use App\Models\DustAndRoughModel;
+use App\Models\ResinStockModel;
use CodeIgniter\HTTP\ResponseInterface;
use DateTime;
@@ -31,6 +33,8 @@ class StockController extends BaseController
protected $rawmaterialdetails_model;
protected $bagStockDetails_model;
protected $Rawmaterialdetails_model;
+ protected $dustAndRoughStockDetails_model;
+ protected $resinStockDetails_model;
/**
* This is default constructor of the class
@@ -39,16 +43,30 @@ class StockController extends BaseController
{
$this->db = \Config\Database::connect();
parent::__construct();
- $this->powerConsumptionDetails_model = new PowerConsumptionDetails();
- $this->coatingMachineDetails_model = new CoatingMachineDetailsModel();
- $this->drierMachineDetails_model = new DrierMachineDetailsModel();
- $this->factoryMachine_model = new FactoryMachineModel();
- $this->factoryVehicleDieselDetails_model = new FactoryVehicleDieselDetailsModel();
+
+ $this->powerConsumptionDetails_model = new PowerConsumptionDetails();
+
+ $this->coatingMachineDetails_model = new CoatingMachineDetailsModel();
+
+ $this->drierMachineDetails_model = new DrierMachineDetailsModel();
+
+ $this->factoryMachine_model = new FactoryMachineModel();
+
+ $this->factoryVehicleDieselDetails_model = new FactoryVehicleDieselDetailsModel();
+
$this->factoryVehicleDieselStockSummary_model = new FactoryVehicleDieselStockSummaryModel();
- $this->rawmaterialdetails_model = new Rawmaterialdetails_model();
- $this->incomingSilicaSandDetails_model = new IncomingSilicaSandDetailsModel();
- $this->inwardGateRegister_model = new Inwardgateregister_model();
- $this->bagStockDetails_model = new BagStockDetailsModel();
+
+ $this->rawmaterialdetails_model = new Rawmaterialdetails_model();
+
+ $this->incomingSilicaSandDetails_model = new IncomingSilicaSandDetailsModel();
+
+ $this->inwardGateRegister_model = new Inwardgateregister_model();
+
+ $this->bagStockDetails_model = new BagStockDetailsModel();
+
+ $this->dustAndRoughStockDetails_model = new DustAndRoughModel();
+
+ $this->resinStockDetails_model = new ResinStockModel() ;
$this->session = session();
@@ -284,6 +302,22 @@ class StockController extends BaseController
$this->global['pageTitle']='Bag Stock Details';
+
+ $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();
+
+
+
+
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$data['bagStockDetails'] = $this->bagStockDetails_model
@@ -325,16 +359,16 @@ class StockController extends BaseController
foreach($bagMaterials as $key => $bagMaterial){
$materialCode = $bagMaterial['MaterialCode'];
$bagMaterials[$key]['customers'] = $this->bagStockDetails_model
- ->select('customer')
+ ->select('customer')
->where('date >=', $startDate)
->where('date <=', $endDate)
- ->where('materialCode', $materialCode)
- ->first()['customer'] ?? '';
- }
-
- $bagMaterialcount = count($bagMaterials);
-
- $data['bagMaterialcount'] = $bagMaterialcount;
+ ->where('materialCode', $materialCode)
+ ->first()['customer'] ?? '';
+ }
+
+ $bagMaterialcount = count($bagMaterials);
+
+ $data['bagMaterialcount'] = $bagMaterialcount;
$data['bagMaterials'] = $bagMaterials;
$date = DateTime::createFromFormat('Y-m', $month);
@@ -392,8 +426,252 @@ class StockController extends BaseController
echo "Data Saved Successfully";
}
+
+
+ //Dust And Rough Stock Details
+
+ public function loadView_dustAndRoughStockDetails(){
+
+ if ($this->request->getMethod() === 'POST'){
+ $month = $this->request->getPost('month');
+
+ $date = DateTime::createFromFormat('M-Y', $month);
+
+ $formattedDate = $date->format('Y-m');
+
+ $month=$formattedDate;
+ }
+ else{
+ $month = date('Y-m');
+ }
+
+ $data=[];
+
+ $data['month']=$month;
+
+ $this->global['pageTitle']='Dust And Rough Stock Details';
+
+ $startDate = "$month-01";
+ $endDate = date("Y-m-t", strtotime($startDate));
+ $data['dustAndRoughStockDetails'] = $this->dustAndRoughStockDetails_model
+ ->where('date >=', $startDate)
+ ->where('date <=', $endDate)
+ ->orderBy('date','asc')
+ ->findAll();
+
+ $date = DateTime::createFromFormat('Y-m', $month);
+
+ $formattedDate = $date->format('M-Y');
+
+ $data['month']=$formattedDate;
+
+ return $this->loadViews("dustAndRoughStockDetails", $this->global, $data, NULL);
+
+ }
+
+ public function updateDustAndRoughStockDetails(){
+
+ $postData = $this->request->getPost();
+
+ $updateDustAndRoughStockDetailsData = json_decode($postData['updateDustAndRoughStockDetails'], true);
+
+ $updates = [];
+
+ $inserts = [];
+
+ foreach($updateDustAndRoughStockDetailsData as $data){
+
+ $date = $data['date'];
+
+ $dbData= [
+ 'date' => $data['date'],
+ 'finalRough' => $data['finalRough'],
+ 'dust' => $data['dust'],
+ 'total' => $data['total']
+
+ ];
+
+ $resultExists=$this->dustAndRoughStockDetails_model
+ ->where('date',$date)
+ ->first();
+
+
+ if (empty($resultExists)) {
+ $inserts[] = $dbData;
+
+ } else {
+ $updates[] = $dbData;
+ }
+ }
+
+ if (!empty($inserts)) {
+ $this->dustAndRoughStockDetails_model->insertBatch($inserts);
+ }
+
+ if (!empty($updates)) {
+
+ $updateResult = $this->dustAndRoughStockDetails_model->updateBatch($updates, 'date');
+
+ if ($updateResult === FALSE) {
+ echo "Error during update";
+ } else {
+ echo "Data Updated Successfully";
+ return;
+ }
+ }
+
+ echo "Data Saved Successfully";
+
+ }
+ //Resin Stock Details
+
+ public function loadView_resinStockDetails(){
+
+ if ($this->request->getMethod() === 'POST'){
+
+ $month = $this->request->getPost('month');
+
+ $date = DateTime::createFromFormat('M-Y', $month);
+
+ $formattedDate = $date->format('Y-m');
+
+ $month=$formattedDate;
+ }
+ else{
+ $month = date('Y-m');
+ }
+
+ $data=[];
+
+ $data['month']=$month;
+
+ $this->global['pageTitle']='Resin Stock Details';
+
+
+ $previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m');
+ $previousMonthStartDate = "$previousMonth-01";
+ $previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate));
+ $data['previousMonthResinStockDetails'] = $this->resinStockDetails_model
+ ->select(['materialCode', 'date' ,'balanceStock'])
+ ->distinct()
+ ->where('date =', $previousMonthEndDate)
+ ->groupBy(['materialCode','date'])
+ ->orderBy('date','desc')
+ ->orderBy('materialCode','asc')
+ ->findAll();
+
+
+
+
+ $startDate = "$month-01";
+ $endDate = date("Y-m-t", strtotime($startDate));
+ $data['resinStockDetails'] = $this->resinStockDetails_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['groupedResinStockDetails'] = [];
+
+ // Temporary array to store grouped data by date
+ $groupedByDate = [];
+
+ // Group by 'date'
+ foreach ($data['resinStockDetails'] as $detail) {
+ $date = $detail['date'];
+
+ // Initialize the array for this date if it doesn't exist
+ if (!isset($groupedByDate[$date])) {
+ $groupedByDate[$date] = [];
+ }
+
+ // Append the detail to the sub-array for this date
+ $groupedByDate[$date][] = $detail;
+ }
+
+ // Reset the structure to have indexed arrays without the date keys
+ $data['groupedResinStockDetails'] = array_values($groupedByDate);
+
+
+
+ $resinMaterials= $this->rawmaterialdetails_model->getAllResinMaterialCode();
+
+ foreach($resinMaterials as $key => $resinMaterial){
+ $materialCode = $resinMaterial['MaterialCode'];
+ $resinMaterials[$key]['customers'] = $this->bagStockDetails_model
+ ->select('customer')
+ ->where('date >=', $startDate)
+ ->where('date <=', $endDate)
+ ->where('materialCode', $materialCode)
+ ->first()['customer'] ?? '';
+ }
+
+ $resinMaterialCount = count($resinMaterials);
+
+ $data['resinMaterialCount'] = $resinMaterialCount;
+ $data['resinMaterials'] = $resinMaterials;
+
+ $date = DateTime::createFromFormat('Y-m', $month);
+
+ $formattedDate = $date->format('M-Y');
+
+ $data['month']=$formattedDate;
+
+ return $this->loadViews("resinStockDetails", $this->global, $data, NULL);
+
+ }
+
+ public function updateResinStockDetails(){
+
+
+ $postData = $this->request->getPost();
+
+ $updateResinStockDetailsData = json_decode($postData['updateResinStockDetails'], true);
+
+ foreach($updateResinStockDetailsData 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->resinStockDetails_model
+ ->where('date',$date)
+ ->where('materialCode',$materialCode)
+ ->first();
+
+
+ if(!empty($resultExists)){
+
+ $updated = $this->resinStockDetails_model
+ ->where('date',$date)
+ ->where('materialCode',$materialCode)
+ ->set($dbData)
+ ->update();
+
+ }else{
+ $inserted = $this->resinStockDetails_model->insert($dbData);
+ }
+
+ }
+
+ echo "Data Saved Successfully";
+
+ }
diff --git a/app/Models/DustAndRoughModel.php b/app/Models/DustAndRoughModel.php
new file mode 100644
index 00000000..a59b1757
--- /dev/null
+++ b/app/Models/DustAndRoughModel.php
@@ -0,0 +1,46 @@
+db->table('t_materialmaster')
+ ->select('MaterialCode , MaterialName')
+ ->where('IsActive', 1)
+ ->where('Category', 'plastic_chemicals')
+ ->orderBy('MaterialCode', 'asc');
+ $query = $builder->get();
+ $materialResults = $query->getResultArray();
+
+ return $materialResults;
+
+ }
+
function getMaterialstock($MaterialCode, $currentdate)
diff --git a/app/Models/ResinStockModel.php b/app/Models/ResinStockModel.php
new file mode 100644
index 00000000..22b6efca
--- /dev/null
+++ b/app/Models/ResinStockModel.php
@@ -0,0 +1,48 @@
+
material |
-
-
-
+
@@ -230,11 +228,12 @@
|
- | Customer |
-
+ Customer |
-
+ |
= $bagMaterial['customers']?>
|
@@ -268,11 +267,7 @@
//dd($groupedBagStockDetails);
foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){
?>
-
-
-
-
-
+
$bagStock){ ?>
= $bagStock['materialCode']?>
- | = $bagStock['customer']?> |
+
+ = $bagStock['customer']?>
+ |
- |
+
-
+
+
- modify('first day of this month')->format('Y-m-d');
- $endDate = $date->modify('last day of this month')->format('Y-m-d');
+ $startDate = $date->modify('first day of this month')->format('Y-m-d');
+ $endDate = $date->modify('last day of this month')->format('Y-m-d');
- $datesInMonth = [];
+ $datesInMonth = [];
- $period = new DatePeriod(
- new DateTime($startDate),
- new DateInterval('P1D'),
- (new DateTime($endDate))->modify('+1 day')
- );
+ $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 ($period as $day) {
+ $datesInMonth[] = $day->format('Y-m-d');
+ }
- ?>
+ ?>
- $dateInMonth){ ?>
-
- $bagMaterial){ ?>
-
+ $dateInMonth){ ?>
+
+ $bagMaterial){ ?>
+
-
- format('d-m-Y');
- ?>
- |
- = $startDate ?>
+
+ format('d-m-Y');
+ ?>
+ |
+ = $startDate ?>
+ |
+
+
+
+ = $dateInMonth?>
|
-
-
-
- = $dateInMonth?>
- |
-
- = $bagMaterial['MaterialCode']?>
- |
+
+ = $bagMaterial['MaterialCode']?>
+ |
-
- = $bagMaterial['customers']?>
- |
+
+ = $bagMaterial['customers']?>
+ |
-
-
- oninput="openingStockChange(this)"
- contenteditable="true"
+ |
+
+ oninput="openingStockChange(this)"
+ contenteditable="true"
-
- >0 |
+
+ >= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?>
- 0 |
+ 0 |
- 0 |
+ 0 |
- 0 |
+ = $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?> |
+
+
-
-
@@ -490,13 +493,15 @@
const table = $('#bagStockDetailsTableId');
const rows = [];
-
+ //this table to json is customized for bagstock not for all
+
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const date = rowCells.eq(0).text().trim();
-
+ /** we get eight entries against a material so we loop from 1 to 7 and so on
+ in a single row **/
for (let i = 1; i < rowCells.length; i += 7) {
const rowData = {
date: rowCells.eq(i).text().trim(),
@@ -620,6 +625,15 @@
}
})
}
+
+ function customerChange(thElement){
+ let materialCode = thElement.getAttribute('data-materialCode');
+ let newCustomerValue = thElement.innerText;
+ let matchingCustomerData = document.querySelectorAll(`td.customer[data-materialCode="${materialCode}"]`);
+ matchingCustomerData.forEach((element,index)=>{
+ element.innerText=newCustomerValue;
+ })
+ }
diff --git a/app/Views/dustAndRoughStockDetails.php b/app/Views/dustAndRoughStockDetails.php
new file mode 100644
index 00000000..139f5370
--- /dev/null
+++ b/app/Views/dustAndRoughStockDetails.php
@@ -0,0 +1,466 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ - Stocks
+ -
+
Dust And Rough Stock Details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Date |
+ Final Rough |
+ Dust |
+ Total |
+
+
+
+
+ | +16 Mesh |
+ 10 Ton Dryer |
+
+
+
+
+
+
+ $dustAndRoughStockDetail){
+ ?>
+
+ |
+
+ |
+
+ = $dustAndRoughStockDetail['finalRough'] ?> |
+
+ = $dustAndRoughStockDetail['dust'] ?> |
+
+ = $dustAndRoughStockDetail['total'] ?> |
+
+
+ modify('first day of this month')->format('Y-m-d');
+ $endDate = $date->modify('last day of this month')->format('Y-m-d');
+
+ $datesInMonth = [];
+
+
+ $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){
+ ?>
+
+ |
+
+ |
+
+ = 0 ?> |
+
+ = 0 ?> |
+
+ = 0 ?> |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/Views/includes/new_header.php b/app/Views/includes/new_header.php
index 4a489a1f..d7651d78 100755
--- a/app/Views/includes/new_header.php
+++ b/app/Views/includes/new_header.php
@@ -778,6 +778,11 @@
Power Consumption
Bag Stock Details
+
+ Dust And Rough Stock Details
+
+ Resin Stock Details
+
diff --git a/app/Views/powerConsumptionDetails.php b/app/Views/powerConsumptionDetails.php
index ea528e59..357b07a5 100644
--- a/app/Views/powerConsumptionDetails.php
+++ b/app/Views/powerConsumptionDetails.php
@@ -235,7 +235,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
- Stocks
-
-
Diesel - Factory Vehicle Details
+ Power Consumption Details
diff --git a/app/Views/resinStockDetails.php b/app/Views/resinStockDetails.php
new file mode 100644
index 00000000..6a9787dd
--- /dev/null
+++ b/app/Views/resinStockDetails.php
@@ -0,0 +1,640 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ - Stocks
+ -
+
Bag Stock Details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | material |
+
+
+
+
+ = $bagMaterial['MaterialName']?>
+
+ |
+
+
+
+
+ | Customer |
+
+
+
+ = $bagMaterial['customers']?>
+ |
+
+
+
+
+
+
+
+ | Date |
+
+
+
+ Date |
+ material |
+ customer |
+ Opening Stock |
+ Receipt |
+ Used |
+ Balance Stock |
+
+
+
+
+
+
+
+
+ $bagStockDetails){
+ ?>
+
+ $bagStock){ ?>
+
+ format('d-m-Y');
+ ?>
+ |
+ = $startDate ?>
+ |
+
+
+
+ = $bagStock['date']?>
+ |
+ = $bagStock['materialCode']?>
+ |
+
+
+ = $bagStock['customer']?>
+ |
+
+
+ oninput="openingStockChange(this)"
+ contenteditable="true"
+
+
+ >= $bagStock['opening']?>
+ |
+
+
+ = $bagStock['receipt']?>
+ |
+
+ = $bagStock['used']?>
+ |
+
+
+ = $bagStock['balanceStock']?>
+ |
+
+
+
+
+
+
+
+
+
+ modify('first day of this month')->format('Y-m-d');
+ $endDate = $date->modify('last day of this month')->format('Y-m-d');
+
+ $datesInMonth = [];
+
+
+ $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');
+ }
+
+ ?>
+
+ $dateInMonth){ ?>
+
+ $bagMaterial){ ?>
+
+
+
+ format('d-m-Y');
+ ?>
+ |
+ = $startDate ?>
+ |
+
+
+
+ = $dateInMonth?>
+ |
+
+
+ = $bagMaterial['MaterialCode']?>
+ |
+
+
+ = $bagMaterial['customers']?>
+ |
+
+
+
+ oninput="openingStockChange(this)"
+ contenteditable="true"
+
+
+ >= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?> |
+
+ 0 |
+
+ 0 |
+
+ = $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?> |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+