Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic into main

This commit is contained in:
VE10-Sanjeev 2024-09-30 13:58:28 +00:00
commit 7d1e8d9db1
12 changed files with 356 additions and 111 deletions

View File

@ -481,7 +481,8 @@ class Jobcard extends BaseController
public function new_jobcard($job_card_id,$rework = null)
{
if ($job_card_id === '0') {
$data['page_name']="Create Job Card";
$data['page_name']="Create Job Card";
$data['jobs'] = [];
$data['jobcardfiles'] = [];
$ClientModel = new ClientModel();
@ -684,13 +685,14 @@ class Jobcard extends BaseController
$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")
{
$RoleModel = new RoleModel();
$data['workers'] = $RoleModel->get_workers($this->session->get('logged_user_branch_id'));
}
}
$RoleModel = new RoleModel();
$data['workers'] = $RoleModel->get_workers($this->session->get('logged_user_branch_id'));
$data['job_card_id'] = $job_card_id;
$bikeMakeModel = new BikeMakeModel();
$data['makeData'] =$bikeMakeModel->findAll();
@ -703,13 +705,8 @@ 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;
// echo "<pre>";
// print_r($this->request->getPost());die;
// dd($this->request->getPost());
$JobcardModel = new JobcardModel();
if($this->session->get('logged_user_role') == "Store Manager") {
$data['status'] = $this->request->getPost('status');
@ -749,14 +746,14 @@ class Jobcard extends BaseController
'note'=> $this->request->getPost('note'),
'status'=> $this->request->getPost('status'),
'assigned_to'=> json_encode($this->request->getPost('assigned_to')),
'subtotal'=> $this->request->getPost('sub_total'), // (isset($rework) ? 0 : $this->request->getPost('sub_total') ),
'tax'=> $this->request->getPost('invoicetax'), //(isset($rework) ? 0 : $this->request->getPost('invoicetax') ),
'discount'=> $this->request->getPost('discount'), //($this->request->getPost('discount')) == '' ? 0 : $this->request->getPost('discount'),
'total'=> $this->request->getPost('grand_total'), //(isset($rework) ? 0 : $this->request->getPost('grand_total') ),
'trial_mechanic'=> $this->request->getPost('trial_mechanic'),
'subtotal'=> $this->request->getPost('sub_total'),
'tax'=> $this->request->getPost('invoicetax'),
'discount'=> $this->request->getPost('discount'),
'total'=> $this->request->getPost('grand_total'),
'isactive' => 1
];
// echo "<pre>";
// print_r($job_card_data);die;
$status = $this->request->getPost('status');
// Insert or update sales order
$job_card_id = $this->request->getPost('job_card_id');
@ -784,17 +781,13 @@ class Jobcard extends BaseController
$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
}
/********** INSERT SERVICE DATA ************/
$data = json_decode($_POST['products']);
$service_data = $data[0]->service;
// echo "<pre>";
// print_r($service_data);die;
foreach ($service_data as $item) {
// Insert into the service table
$service['job_card_id'] = $job_card_id;
@ -1148,10 +1141,10 @@ class Jobcard extends BaseController
$product = $JobcardProductModel->find($product_id);
$qty = isset($product['issued_qty']) ? $product['issued_qty'] : 0;
if ($status == 'Issued') {
// $this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
// $this->subractProductQuantity($ProductModel, $product['product_id'], $qty);
}elseif ($status == 'Cancelled'){
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
$this->subractProductQuantity($ProductModel, $product['product_id'], $qty);
$data['status'] = 0;
// echo $product['job_card_product_id'];die;
// $JobcardProductModel->where('job_card_product_id',$product['job_card_product_id'])->update($data);
@ -1164,26 +1157,41 @@ class Jobcard extends BaseController
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
// Calculate updated quantity
$new_qty = $current_qty + $sold_qty;
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
if($product['per'] == 'barrel')
{
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
}
else if($product['per'] == 'box')
{
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
}
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
$ProductModel->update($product_id, $data );
}
private function updateProductQuantity($ProductModel, $product_id, $sold_qty)
private function subractProductQuantity($ProductModel, $product_id, $sold_qty)
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
// Calculate updated quantity
$new_qty = $current_qty - $sold_qty;
$data['qty_stock'] = $product['qty_stock'] - $sold_qty;
if($product['per'] == 'barrel')
{
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
}
else if($product['per'] == 'box')
{
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
}
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
$ProductModel->update($product_id, $data );
}
public function delete_sales_product()

View File

@ -151,12 +151,15 @@ class Products extends BaseController
$ProductModel = new ProductModel();
$tax= $this->request->getPost('tax')/2;
// print_r($this->request->getPost());die;
if ($this->request->getPost('per') != 'ml') {
$ml = 0;
}else{
$ml = 0; $box = 0; $qty_per_box = 0; $barrel = 0; $ltr_per_barrel = 0;
if ($this->request->getPost('per') == 'ml') {
$ml = $this->request->getPost('ml');
}else if ($this->request->getPost('per') == 'box'){
$box = $this->request->getPost('box');
$qty_per_box = $this->request->getPost('qty_per_box');
}else if ($this->request->getPost('per') == 'barrel'){
$barrel = $this->request->getPost('barrel');
$ltr_per_barrel = $this->request->getPost('ltr_per_barrel');
}
$data = [
@ -170,7 +173,6 @@ class Products extends BaseController
'cgst' => $tax,
'purchase_cost' => $this->request->getPost('purchase_cost'),
'qty_stock'=> $this->request->getPost('qty_in_stock'),
'qty_in_demand'=> $this->request->getPost('qty_in_demand'),
'description' => $this->request->getPost('description'),
'vendor' =>json_encode( $this->request->getPost('vendor')),
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
@ -188,7 +190,11 @@ class Products extends BaseController
'total_amount' => $this->request->getPost('total_amount'),
'per' => $this->request->getPost('per'),
'ml' => $ml
'ml' => $ml,
'box' => $box,
'qty_per_box' => $qty_per_box,
'barrel' => $barrel,
'ltr_per_barrel' => $ltr_per_barrel
];
$product_id = $this->request->getPost('product_id');

View File

@ -326,19 +326,25 @@ class Purchase extends BaseController
}
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
// Calculate updated quantity
$new_qty = $current_qty + $sold_qty;
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
}
if($product['per'] == 'barrel')
{
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
}
else if($product['per'] == 'box')
{
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
}
// Update quantity in Product table
$ProductModel->update($product_id, $data );
}
public function delete_purchase($purchase_order_id)
{

View File

@ -242,18 +242,24 @@ class ReturnOrder extends BaseController
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
{
// Fetch current product quantity
$product = $ProductModel->find($product_id);
// Calculate updated quantity
$new_qty = $current_qty + $sold_qty;
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
}
if($product['per'] == 'barrel')
{
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
}
else if($product['per'] == 'box')
{
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
}
// Update quantity in Product table
$ProductModel->update($product_id, $data );
}
public function delete_purchase($purchase_order_id)
{

View File

@ -145,6 +145,8 @@ class Sales extends BaseController
$SalesOrderModel = new SalesOrderModel();
$ProductModel = new ProductModel();
$SalesOrderProductModel = new SalesOrderProductModel(); // Assuming you have a model for sales_order_product
// Prepare data for sales order
$data = [
@ -169,7 +171,6 @@ class Sales extends BaseController
// Insert or update sales order
$sales_order_id = $this->request->getPost('sales_order_id');
if (!empty($sales_order_id)) {
// print_r("hello");die;
if ($this->request->getPost('status') === "Paid") {
$data['mode_of_payment'] = $this->request->getPost('mode_of_payment');
}
@ -177,12 +178,13 @@ class Sales extends BaseController
} else {
$SalesOrderModel->insert($data);
$sales_order_id = $SalesOrderModel->getInsertID(); // Get the last inserted ID
// Update sales order with generated order number
$orderNumber = 'SO-' . date('md') . '-' . str_pad($sales_order_id, 5, '0', STR_PAD_LEFT);
$SalesOrderModel->update($sales_order_id, ['order_number' => $orderNumber]);
}
$orderNumber = 'SO-' . date('md') . '-' . str_pad($sales_order_id, 5, '0', STR_PAD_LEFT);
// Update sales order with generated order number
$SalesOrderModel->update($sales_order_id, ['order_number' => $orderNumber]);
// Prepare data for sales order product
$product_ids = $this->request->getPost('item_details');
@ -200,12 +202,8 @@ class Sales extends BaseController
foreach ($product_ids as $key => $product_id) {
$qty = isset($quantities[$key]) ? $quantities[$key] : 0;
if ($status == 'Created') {
// echo "hello";die;
$this->updateProductQuantity($ProductModel, $product_id, $qty);
$this->subractProductQuantity($ProductModel, $product_id, $qty);
}elseif ($status == 'Cancelled'){
// echo "cancel";die;
// echo"hello";die;
$this->addBackProductQuantity($ProductModel, $product_id, $qty);
}
@ -247,29 +245,43 @@ class Sales extends BaseController
private function addBackProductQuantity($ProductModel, $product_id, $sold_qty)
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
// Calculate updated quantity
$new_qty = $current_qty + $sold_qty;
$data['qty_stock'] = $product['qty_stock'] + $sold_qty;
if($product['per'] == 'barrel')
{
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
}
else if($product['per'] == 'box')
{
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
}
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
$ProductModel->update($product_id, $data );
}
private function updateProductQuantity($ProductModel, $product_id, $sold_qty)
private function subractProductQuantity($ProductModel, $product_id, $sold_qty)
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
// Fetch current product quantity
$product = $ProductModel->find($product_id);
$current_qty = $product['qty_stock'];
// Calculate updated quantity
$new_qty = $current_qty - $sold_qty;
$data['qty_stock'] = $product['qty_stock'] - $sold_qty;
if($product['per'] == 'barrel')
{
$data['barrel'] = $data['qty_stock'] / $product['ltr_per_barrel'];
}
else if($product['per'] == 'box')
{
$data['box'] = $data['qty_stock'] / $product['qty_per_box'];
}
// Update quantity in Product table
$ProductModel->update($product_id, ['qty_stock' => $new_qty]);
$ProductModel->update($product_id, $data );
}
public function delete_sales_product()

View File

@ -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', 'is_rework','subtotal','tax', 'discount','total','isactive','mode_of_payment'];
'status','assigned_to', 'is_rework','subtotal','tax', 'discount','total','isactive','mode_of_payment','trial_mechanic'];

View File

@ -9,7 +9,7 @@ class ProductModel extends Model
'quality','product_name','branch_id','prefered_vendor','product_category','mfr_part_no','purchase_order_level',
'unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level',
'handler','qty_in_demand','product_image','description','specification','hsn_sac','isactive','total_amount',
'per','ml'];
'per','ml','box','qty_per_box','barrel','ltr_per_barrel'];
public function getTax()

View File

@ -21,7 +21,7 @@ class RoleModel extends Model
$this->join('users', 'users.role = roles.role_id');
$this->where('roles.isactive', 1);
$this->where('users.isactive', 1);
$this->whereIn('roles.roles', ['Mechanic','Helper']);
$this->whereIn('roles.roles', ['Senior Mechanic','Mechanic','Helper']);
$this ->where('users.branch_id',$logged_user_branch_id);
return $this->findAll();
}

View File

@ -22,17 +22,28 @@
top:4px;
}
.select2-container .select2-selection--multiple{
height: 36px;
border:1px solid #ced4da;
}
.select2-container--default .select2-selection--multiple .select2-selection__rendered{
line-height: 36px;
}
.select2-container--default .select2-selection--multiple .select2-selection__arrow{
top:4px;
}
</style>
<style>
.select2-container .select2-selection--multiple .select2-selection__choice{
padding: 5px 7px 5px 0 !important;
color: #000000;
}
.select2-container--default .select2-results__option--highlighted[aria-selected]{
color:#ffffff;
background-color: #526dee;
}
.select2-container--default .select2-results__option{
border-bottom: 1px solid #dddddd;
}
.select2-container--default .select2-results__option[aria-selected=true]{
color: #000000;
background-color: #3efba4;
font-weight: 500;
border-bottom: 1px solid #747474;
}
</style>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
@ -153,20 +164,36 @@
<?php endif; ?>
</select>
</div>
<?php if(isset($workers) && $jobs['status'] == 'Created') { ?>
<?php if(isset($workers)) { ?>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Assign To</label>
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" multiple>
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Make</option>' ?>
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" data-toggle="select2" multiple>
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Mechanic</option>' ?>
<?php foreach ($workers as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["user_id"] ?>" <?= isset($jobs['assigned_to']) && is_array(json_decode($jobs['assigned_to'])) && in_array($value["user_id"], json_decode($jobs['assigned_to'])) ? 'selected' : ''; ?>>
<?= $value["name"]; ?>
<?= $value["name"]." - ".$value['roles']; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Trial Mechanic</label>
<select class="form-control SelExample" name="trial_mechanic" id="trial_mechanic" data-toggle="select2" >
<?= isset($jobs['trial_mechanic']) ? '' : '<option value="">Select a Mechanic</option>' ?>
<?php foreach ($workers as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["user_id"] ?>" <?= isset($jobs['trial_mechanic']) && $value["user_id"] = $jobs['trial_mechanic'] ? 'selected' : ''; ?>>
<?= $value["name"]." - ".$value['roles']; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<?php } ?>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Note<span class="text-danger"></span></label>
@ -2080,14 +2107,14 @@ $closestTR.remove();
<script>
$(document).ready(function(){
// Initialize select2
$(".SelExample").select2();
// Initialize select2
$(".SelExample").select2();
});
function initializeSelect2() {
$('.SelExample').select2({
width: '249px' // Adjust width as needed
});
}
$('.SelExample').select2({
width: '249px' // Adjust width as needed
});
}
</script>
<script>
$(document).ready(function() {

View File

@ -1,5 +1,56 @@
<!-- <div class="loader" style="display:none;">
<div class="loader-inner" >
<div class="gear">
<div class="center"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
<div class="gear gear-two">
<div class="center"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
<div class="gear gear-three">
<div class="center"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
</div>
</div> -->
<div id="loader" style="display:none;">
<div class="gear">
<div class="center"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
<!-- <div class="gear gear-two">
<div class="center"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
<div class="gear gear-three">
<div class="center"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div> -->
</div>
<!-- Footer Start -->

View File

@ -71,6 +71,135 @@
}
.gear {
position: absolute;
width: 80px;
height: 80px;
margin: auto;
background: #198;
border-radius: 50%;
animation-name: spin;
animation-duration:6s;
animation-iteration-count: infinite;
animation-timing-function: linear;
top: 50%;
left: 0;
right: 0;
}
.gear .center {
position: absolute;
top: 20px;
left: 20px;
z-index: 10;
width: 40px;
height: 40px;
background: #fff;
border-radius: 50%;
}
.bar {
position: absolute;
top: -10px;
left: 28px;
z-index: 1;
width: 22px;
height: 100px;
background: #198;
}
.bar:nth-child(2) {
transform: rotate(45deg);
}
.bar:nth-child(3) {
transform: rotate(90deg);
}
.bar:nth-child(4) {
transform: rotate(135deg);
}
.gear-two {
left: -90px;
top: 68px;
width: 55px;
height: 55px;
background: #f58bb6;
animation-name: spin-reverse;
}
.gear-two .bar {
background: #f58bb6;
width: 14px;
height: 70px;
left: 20px;
top: -8px;
}
.gear-two .center {
width: 28px;
height: 28px;
left: 13px;
top: 13px;
}
.gear-three {
left: 90px;
top: 68px;
width: 55px;
height: 55px;
background: #576e81;
animation-name: spin-reverse;
}
.gear-three .bar {
background: #576e81;
width: 14px;
height: 70px;
left: 20px;
top: -8px;
}
.gear-three .center {
width: 28px;
height: 28px;
left: 13px;
top: 13px;
}
@-webkit-keyframes spin {
50% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes spin {
50% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-webkit-keyframes spin-reverse {
50% {
-webkit-transform: rotate(-360deg);
transform: rotate(-360deg);
}
}
@keyframes spin-reverse {
50% {
-webkit-transform: rotate(-360deg);
transform: rotate(-360deg);
}
}
#loader {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgb(0 0 0 / 5%);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999; /* Ensure it appears on top of other content */
}
</style>
<script>
toastr.options = {

View File

@ -434,7 +434,7 @@ $(document).ready(function() {
$('#makeSelectMessage').hide();
// AJAX request to get models based on the selected make ID
// $('.loader-section').show();
$('#loader').show();
$.ajax({
url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
type: 'POST',
@ -464,7 +464,7 @@ $(document).ready(function() {
// Handle case when no models are found
$('#model').empty().append('<option value="">No models found</option>');
}
// $('.loader-section').hide();
$('#loader').hide();
},
error: function(xhr, status, error) {
// Handle error