diff --git a/PO00000003-2024-04-23-12-04-15.pdf b/PO00000003-2024-04-23-12-04-15.pdf
deleted file mode 100644
index b1ed2f8..0000000
Binary files a/PO00000003-2024-04-23-12-04-15.pdf and /dev/null differ
diff --git a/PO00000004-2024-04-23-12-04-45.pdf b/PO00000004-2024-04-23-12-04-45.pdf
deleted file mode 100644
index 5b4a3b2..0000000
Binary files a/PO00000004-2024-04-23-12-04-45.pdf and /dev/null differ
diff --git a/PO00000005-2024-04-23-12-06-31.pdf b/PO00000005-2024-04-23-12-06-31.pdf
deleted file mode 100644
index cd201df..0000000
Binary files a/PO00000005-2024-04-23-12-06-31.pdf and /dev/null differ
diff --git a/PO00000008-2024-04-24-04-43-17.pdf b/PO00000008-2024-04-24-04-43-17.pdf
deleted file mode 100644
index be2df23..0000000
Binary files a/PO00000008-2024-04-24-04-43-17.pdf and /dev/null differ
diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php
index 8e6fe52..9d50386 100644
--- a/app/Controllers/Jobcard.php
+++ b/app/Controllers/Jobcard.php
@@ -212,7 +212,7 @@ class Jobcard extends BaseController
}
- public function new_jobcard($job_card_id)
+ public function new_jobcard($job_card_id,$rework = null)
{
if ($job_card_id === '0') {
$data['page_name']="Create Job Card";
@@ -353,6 +353,7 @@ class Jobcard extends BaseController
$vehicle=$VehicleModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$data['vehicle']=$vehicle;
$data['logged_user_role'] = $this->session->get('logged_user_role');
+ if($rework == 're-work') { $data['rework']= true; }
if($this->session->get('logged_user_role') == "Floor Manager")
{
@@ -372,14 +373,16 @@ class Jobcard extends BaseController
public function add_jobs()
{
+ // echo $this->request->getPost('issued_items');die;
// echo $this->request->getPost('products');die;
// echo $this->request->getPost('delete_items');die;
// echo $this->request->getPost('issued_items');die;
+ // echo json_encode($this->request->getPost());die;
$JobcardModel = new JobcardModel();
if($this->session->get('logged_user_role') == "Store Manager") {
$data['status'] = $this->request->getPost('status');
$job_card_id = $this->request->getPost('job_card_id');
- $JobcardModel->update($job_card_id, $data);
+ $JobcardModel->update($job_card_id, $data); // issued status update
$issued_product_id = $this->request->getPost('issued_items');
$this->update_store_status($issued_product_id, $data['status']);
return redirect()->to('job_card_index');
@@ -390,11 +393,11 @@ class Jobcard extends BaseController
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
$this->delete_items($this->request->getPost('delete_items'));
-
+ $rework = $this->request->getPost('rework');
// Job card INSERT
$job_card_data = [
'client_name' => $this->request->getPost('client_id'),
- 'mobile_no' => $this->request->getPost('mobile_no'),
+ 'client_mobile_no' => $this->request->getPost('mobile_no'),
'vehicle_id'=>$this->request->getPost('vehicle_id'),
'branch_id'=> $this->session->get('logged_user_branch_id'),
'billing_address' => $this->request->getPost('billing_address'),
@@ -407,11 +410,10 @@ class Jobcard extends BaseController
'note'=> $this->request->getPost('note'),
'status'=> $this->request->getPost('status'),
'assigned_to'=> json_encode($this->request->getPost('assigned_to')),
- // 'store_item_issued'=> $this->request->getPost('store_item_issued'),
- 'subtotal'=> $this->request->getPost('sub_total'),
- 'tax'=> $this->request->getPost('invoicetax'),
+ 'subtotal'=> (isset($rework) ? 0 : $this->request->getPost('sub_total') ),
+ 'tax'=> (isset($rework) ? 0 : $this->request->getPost('invoicetax') ),
'discount'=> ($this->request->getPost('discount')) == '' ? 0 : $this->request->getPost('discount'),
- 'total'=> $this->request->getPost('grand_total'),
+ 'total'=> (isset($rework) ? 0 : $this->request->getPost('grand_total') ),
'isactive' => 1
];
$status = $this->request->getPost('status');
@@ -430,10 +432,15 @@ class Jobcard extends BaseController
$JobcardModel->insert($job_card_data);
$job_card_id = $JobcardModel->getInsertID(); // Get the last inserted ID
- $orderNumber = 'JC-' . date('md') . '-' . str_pad($job_card_id, 5, '0', STR_PAD_LEFT);
+ if(isset($rework)) {
+ $job_card = $JobcardModel->find($rework);
+ $JobcardModel->update($job_card_id, ['order_number' => $job_card['order_number'], 'is_rework' => 1 ]);
+ } else {
+ $orderNumber = 'JC-' . date('md') . '-' . str_pad($job_card_id, 5, '0', STR_PAD_LEFT);
+ $JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
+ }
// print_r($orderNumber);die;
// Update sales order with generated order number
- $JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
}
/********** INSERT SERVICE DATA ************/
@@ -444,11 +451,11 @@ class Jobcard extends BaseController
// Insert into the service table
$service['job_card_id'] = $job_card_id;
$service['service_id'] = $item->service_id;
- $service['labour_cost'] = $item->labour_cost;
$service['qty'] = $item->quality;
$service['tax'] = $item->tax;
- $service['amount'] = $item->amount;
- // echo empty($item->id);die;
+ $service['labour_cost'] = (isset($rework) ? 0 : $item->labour_cost );
+ $service['amount'] = (isset($rework) ? 0 : $item->amount );
+
if(empty($item->id)) {
$JobcardServiceModel->insert($service);
$service_id = $JobcardServiceModel->getInsertID();
@@ -463,7 +470,7 @@ class Jobcard extends BaseController
$service_id = $item->id;
}
- if(isset($item->product)) { $this->product_data_insertion($job_card_id, $service_id, $JobcardServiceModel, $item, $JobcardProductModel, $status); }
+ if(isset($item->product)) { $this->product_data_insertion($job_card_id, $service_id, $JobcardServiceModel, $item, $JobcardProductModel, $status, $rework); }
}
/********** INSERT COMPLAINT DATA ************/
@@ -491,7 +498,7 @@ class Jobcard extends BaseController
$complaint_id = $item->id;
}
- if(isset($item->product)) { $this->product_data_insertion($job_card_id, $complaint_id, $JobcardComplaintModel, $item, $JobcardProductModel, $status); }
+ if(isset($item->product)) { $this->product_data_insertion($job_card_id, $complaint_id, $JobcardComplaintModel, $item, $JobcardProductModel, $status, $rework); }
}
/********** INSERT CUSTOM COMPLAINT DATA ************/
@@ -519,7 +526,7 @@ class Jobcard extends BaseController
$cc_complaint_id = $item->id;
}
- if(isset($item->product)) { $this->product_data_insertion($job_card_id, $cc_complaint_id, $JobcardCustomComplaintModel, $item, $JobcardProductModel, $status); }
+ if(isset($item->product)) { $this->product_data_insertion($job_card_id, $cc_complaint_id, $JobcardCustomComplaintModel, $item, $JobcardProductModel, $status, $rework); }
}
return redirect()->to('job_card_index');
@@ -530,21 +537,25 @@ class Jobcard extends BaseController
if($status == 'Issued') {
$JobcardProductModel = new JobcardProductModel();
$productModel = new ProductModel();
- $data['status'] = 1;
$product_data = json_decode($issued_product_id);
foreach ($product_data as $key => $value) {
$jc_product = $JobcardProductModel->where('job_card_product_id', $value->id)->findAll();
if($jc_product[0]['status'] == 0)
{
+ $data['issued_qty'] = $value->qty;
+ if($value->qty == $jc_product[0]['qty']) { $data['status'] = 1; }
$res = $JobcardProductModel->update($value->id, $data);
- if($res && $status == 'Issued')
- $this->updateProductQuantity($productModel, $jc_product[0]['product_id'], $value->qty);
+ if($res)
+ {
+ $deduct_qty = $value->qty - $jc_product[0]['issued_qty'];
+ $this->updateProductQuantity($productModel, $jc_product[0]['product_id'], $deduct_qty);
+ }
}
}
}
}
- public function product_data_insertion($job_card_id, $parent_id, $ParentModel, $item, $JobcardProductModel, $status)
+ public function product_data_insertion($job_card_id, $parent_id, $ParentModel, $item, $JobcardProductModel, $status, $rework)
{
// Insert into the product table
$id = [];
@@ -553,7 +564,7 @@ class Jobcard extends BaseController
$product['product_id'] = $pt->p_id;
$product['qty'] = $pt->qty;
$product['tax'] = $pt->tax;
- $product['amount'] = $pt->amount / $pt->qty;
+ $product['amount'] = (isset($rework) ? 0 : $pt->amount / $pt->qty );
if(empty($pt->id)) {
$JobcardProductModel->insert($product);
$job_card_product_id = $JobcardProductModel->getInsertID();
@@ -562,8 +573,13 @@ class Jobcard extends BaseController
if($status == 'Cancelled')
{
$product = [];
+ $product['job_card_id'] = $job_card_id;
+ $product['product_id'] = $pt->p_id;
$product['is_active'] = 0;
}
+ $old_data = $JobcardProductModel->find($pt->id);
+ if($pt->qty != $old_data['issued_qty'] && $pt->qty > $old_data['issued_qty']) { $product['status'] = 0; }
+ // echo $pt->id;die;
$JobcardProductModel->update($pt->id, $product);
$job_card_product_id = $pt->id;
}
@@ -646,10 +662,11 @@ class Jobcard extends BaseController
foreach ($id_array as $key => $product_id) {
$product = $JobcardProductModel->find($product_id);
- $qty = isset($product['qty']) ? $product['qty'] : 0;
+ $qty = isset($product['issued_qty']) ? $product['issued_qty'] : 0;
if ($status == 'Issued') {
// $this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
- }elseif ($status == 'Cancelled' && $product['status'] == 1){
+ }elseif ($status == 'Cancelled'){
+
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
$data['status'] = 0;
// echo $product['job_card_product_id'];die;
@@ -671,6 +688,7 @@ class Jobcard extends BaseController
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
}
+
private function updateProductQuantity($ProductModel, $product_id, $sold_qty)
{
// Fetch current product quantity
diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php
index 8dcf66a..17f421c 100644
--- a/app/Controllers/Users.php
+++ b/app/Controllers/Users.php
@@ -6,16 +6,46 @@ use App\Models\UsersModel;
use App\Models\RoleModel;
use App\Models\BusinessModel;
use App\Models\BranchModel;
-
+use App\Models\JobcardProductModel;
+use App\Models\JobcardModel;
+use App\Models\BikemodelsModel;
+use App\Models\BikemakeModel;
class Users extends BaseController
{
+ public $session;
+ public function __construct()
+ {
+
+ $this->session = session();
+
+ }
+
public function dashboard()
{
- return view('dashboard');
+ $UsersModel = new UsersModel();
+ $dashboard_data = $UsersModel->dashboard_live_data($this->session->get('logged_user_branch_id'));
+ foreach ($dashboard_data as &$value) {
+ $assigned_ids = !empty(json_decode($value['assigned_to'], true)) ? json_decode($value['assigned_to'], true) : [0];
+ $user = $UsersModel->select('users.name as username, roles.roles as userrole')->join('roles', 'roles.role_id = users.role', 'left')->whereIn('users.user_id', $assigned_ids)->findAll();
+
+ $value['username'] = '';
+ foreach ($user as $val) {
+ if (isset($val['username'])) {
+ $value['username'] .= $val['username'] . '- ' . $val['userrole'] .'
';
+ }
+ }
+
+ }
+
+ $JobcardModel = new JobcardModel();
+ $current_date = date('Y-m-d');
+ $data['delivery_data'] = $JobcardModel->where('DATE(delivery_date)', $current_date)->where('isactive',1)->findAll();
+ $data['dashboard_data'] = $dashboard_data;
+ return view('dashboard',$data);
}
diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php
index 2c024b4..55c9992 100644
--- a/app/Models/JobcardModel.php
+++ b/app/Models/JobcardModel.php
@@ -9,7 +9,7 @@ class JobcardModel extends Model
'order_number','client_mobile_no','client_name',
'billing_address','billing_city','billing_state','billing_country',
'billing_postal_code','fuel_qty', 'meter', 'delivery_date', 'note',
- 'status','assigned_to', 'store_item_issued','subtotal','tax', 'discount','total','isactive'];
+ 'status','assigned_to', 'is_rework','subtotal','tax', 'discount','total','isactive'];
diff --git a/app/Models/JobcardProductModel.php b/app/Models/JobcardProductModel.php
index a13c8ae..4a79c3c 100644
--- a/app/Models/JobcardProductModel.php
+++ b/app/Models/JobcardProductModel.php
@@ -5,5 +5,5 @@ class JobcardProductModel extends Model
{
protected $table = 'job_card_product';
protected $primaryKey = 'job_card_product_id';
- protected $allowedFields = ['job_card_product_id','job_card_id' , 'product_id', 'qty', 'tax', 'amount', 'status', 'isactive'];
+ protected $allowedFields = ['job_card_product_id','job_card_id' , 'product_id', 'qty', 'tax', 'amount', 'status', 'issued_qty', 'is_active'];
}
\ No newline at end of file
diff --git a/app/Models/UsersModel.php b/app/Models/UsersModel.php
index 0251f70..31fa957 100644
--- a/app/Models/UsersModel.php
+++ b/app/Models/UsersModel.php
@@ -11,4 +11,36 @@ class UsersModel extends Model
public function getUserById($user_id) {
return $this->db->table('users')->where('user_id', $user_id)->get()->getRowArray();
}
+
+ public function dashboard_live_data($logged_user_branch_id)
+ {
+ $this->select('job_card.*, vehicle.reg_no, vehicle.make, vehicle.colour, vehicle.model, make.make as bike_name, model.model_name as bike_modal_name');
+ $this->from('job_card');
+ $this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
+ $this->join('make', 'make.make_id = vehicle.make', 'left');
+ $this->join('model', 'model.model_id = vehicle.model', 'left');
+ $this->where('job_card.isactive', 1);
+ $this->where('job_card.branch_id',$logged_user_branch_id);
+ $current_date = date('Y-m-d');
+ $this->where('DATE(job_card.created_at)', $current_date);
+ $this->groupBy('job_card.job_card_id');
+ $this->orderBy('job_card.job_card_id','DESC');
+ return $this->findAll();
+ }
+
+ public function today_delivery($logged_user_branch_id)
+ {
+ $this->select('job_card.*, vehicle.reg_no, vehicle.make, vehicle.colour, vehicle.model, make.make as bike_name, model.model_name as bike_modal_name');
+ $this->from('job_card');
+ $this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
+ $this->join('make', 'make.make_id = vehicle.make', 'left');
+ $this->join('model', 'model.model_id = vehicle.model', 'left');
+ $this->where('job_card.isactive', 1);
+ $this->where('job_card.branch_id',$logged_user_branch_id);
+ $current_date = date('Y-m-d');
+ $this->where('DATE(job_card.created_at)', $current_date);
+ $this->groupBy('job_card.job_card_id');
+ $this->orderBy('job_card.job_card_id','DESC');
+ return $this->findAll();
+ }
}
\ No newline at end of file
diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php
index 0106059..a567901 100644
--- a/app/Views/dashboard.php
+++ b/app/Views/dashboard.php
@@ -1,14 +1,90 @@
+ Current List of Job Cards +
+ +| Bike Details | +Job Card No | +Created Time | +Client | +Workers | +
|---|---|---|---|---|
| = $value['reg_no'] ?>, = $value['bike_name'] ?> = $value['bike_modal_name'] ?>, = $value['colour'] ?> color |
+ = $value['order_number'] ?> | +format('h:iA'); + echo $formattedTime; + ?> + (TODAY) | += $value['client_name'] ?> = $value['client_mobile_no'] ?> |
+ + |