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

This commit is contained in:
aadhavan valli 2024-04-24 15:27:18 +05:30
commit f1f546dfbd
7 changed files with 232 additions and 30 deletions

Binary file not shown.

View File

@ -302,7 +302,7 @@ class Purchase extends BaseController
$VendorModel = new VendorModel(); $VendorModel = new VendorModel();
$vendor = $VendorModel->where('vendor_id',$this->request->getPost('vendor_id'))->findAll(); $vendor = $VendorModel->where('vendor_id',$this->request->getPost('vendor_id'))->findAll();
$mail_status = $this->download_purchase_invoice($purchase_order_id, $vendor[0]['vendor_email']); $mail_status = $this->download_purchase_invoice($purchase_order_id, $vendor[0]['vendor_email']);
echo $mail_status;die; // echo $mail_status;die;
$_SESSION['mail_status'] = $mail_status; $_SESSION['mail_status'] = $mail_status;
} }

View File

@ -6,7 +6,7 @@ use App\Models\ServiceModel;
use App\Models\BikemakeModel; use App\Models\BikemakeModel;
use App\Models\VendorModel; use App\Models\VendorModel;
use App\Models\BikemodelsModel; use App\Models\BikemodelsModel;
use App\Models\ProductModel;
class Service extends BaseController class Service extends BaseController
{ {
@ -68,7 +68,7 @@ class Service extends BaseController
public function new_service($service_id) public function new_service($service_id)
{ {
$ProductModel = new ProductModel();
if ($service_id === '0') { if ($service_id === '0') {
$data['services'] = []; $data['services'] = [];
@ -78,6 +78,12 @@ class Service extends BaseController
$BikemakeModel = new BikemakeModel(); $BikemakeModel = new BikemakeModel();
$data['make'] = $BikemakeModel->findAll(); $data['make'] = $BikemakeModel->findAll();
$data['models'] = []; $data['models'] = [];
$service=$ServiceModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
// echo $this->session->get('logged_user_branch_id');die;
$data['service']=$service;
$product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
// echo json_encode($service);die;
$data['product']=$product;
$data['page_name']="Add Service"; $data['page_name']="Add Service";
} else if ($service_id !== '0') { } else if ($service_id !== '0') {
@ -89,13 +95,18 @@ class Service extends BaseController
$data['page_name']="Edit Service"; $data['page_name']="Edit Service";
$product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$data['product']=$product;
$models = []; $models = [];
$BikemodelsModel = new BikemodelsModel(); $BikemodelsModel = new BikemodelsModel();
if( $services['makes_id'] != null) {
foreach ($services['makes_id'] as $make_id) { foreach ($services['makes_id'] as $make_id) {
$models[] = $BikemodelsModel->where('make_id', $make_id)->findAll(); $models[] = $BikemodelsModel->where('make_id', $make_id)->findAll();
} }
}
$data['models'] = $models; $data['models'] = $models;
// Load make data // Load make data
@ -107,6 +118,11 @@ class Service extends BaseController
$data['services']=$services; $data['services']=$services;
$service=$ServiceModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
// echo $this->session->get('logged_user_branch_id');die;
// echo json_encode($service);die;
$data['service']=$service;
} }
$data['service_id'] = $service_id; $data['service_id'] = $service_id;
// echo"<pre>"; // echo"<pre>";
@ -120,6 +136,8 @@ class Service extends BaseController
$ServiceModel = new ServiceModel(); $ServiceModel = new ServiceModel();
// echo json_encode($this->request->getPost());die;
$tax= $this->request->getPost('tax')/2; $tax= $this->request->getPost('tax')/2;
$make_ids = $this->request->getPost('make'); $make_ids = $this->request->getPost('make');
@ -130,9 +148,13 @@ class Service extends BaseController
$make_json = json_encode($make_ids); $make_json = json_encode($make_ids);
$data = [ $data = [
'service_name' => $this->request->getPost('servicename'), 'service_name' => $this->request->getPost('servicename'),
'price' => $this->request->getPost('price'), 'category' => $this->request->getPost('category'),
'product_id' => json_encode($this->request->getPost('product_id')),
'cgst' => $tax, 'cgst' => $tax,
'igst' => $tax, 'igst' => $tax,
'tax' => $this->request->getPost('tax'),
'labour_cost' => $this->request->getPost('labour_cost'),
'price' => $this->request->getPost('price'),
'makes_id' => $make_json, 'makes_id' => $make_json,
'models_id' => $model_json, 'models_id' => $model_json,
'description' => $this->request->getPost('description'), 'description' => $this->request->getPost('description'),

View File

@ -5,7 +5,7 @@ class ServiceModel extends Model
{ {
protected $table = 'services'; protected $table = 'services';
protected $primaryKey = 'service_id'; protected $primaryKey = 'service_id';
protected $allowedFields = ['service_id','branch_id','service_name','price','cgst','igst','description','makes_id','models_id','isactive']; protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','igst','price','tax','description','makes_id','models_id','product_id','sub_service_id','isactive'];
public function getTax() public function getTax()

View File

@ -26,6 +26,11 @@
<!-- icons --> <!-- icons -->
<link href="<?php echo base_url()?>public/assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <link href="<?php echo base_url()?>public/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<!-- toster alert -->
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.css" rel="stylesheet">
<style> <style>
/* Override toastr font color */ /* Override toastr font color */
.toast-warning { .toast-warning {
@ -44,6 +49,13 @@
} }
</style> </style>
<script>
toastr.options = {
"timeOut": 5000,
"closeButton": true,
};
</script>
</head> </head>
<body class="loading" data-layout-mode="detached" data-layout='{"mode": "light", "width": "fluid", "menuPosition": "fixed", "sidebar": { "color": "light", "size": "default", "showuser": true}, "topbar": {"color": "dark"}, "showRightSidebarOnPageLoad": true}'> <body class="loading" data-layout-mode="detached" data-layout='{"mode": "light", "width": "fluid", "menuPosition": "fixed", "sidebar": { "color": "light", "size": "default", "showuser": true}, "topbar": {"color": "dark"}, "showRightSidebarOnPageLoad": true}'>

View File

@ -159,5 +159,9 @@
</script> </script>
<script> <script>
<?php if(isset($_SESSION['mail_status']) && $_SESSION['mail_status'] == 200) { ?>
toastr.success("Mail Send Successfully", 'Success');
<?php } else if(isset($_SESSION['mail_status']) && $_SESSION['mail_status'] != 200) { ?>
toastr.error('Mail Send Attempt Unsuccessful', 'Error');
<?php } ?>
</script> </script>

View File

@ -20,11 +20,27 @@
<h4 class="header-title"></h4> <h4 class="header-title"></h4>
<form action="<?= base_url() . "add_service"; ?>" method="post"> <form action="<?= base_url() . "add_service"; ?>" method="post">
<h4 class="header-title">Service Details :</h4><br> <h4 class="header-title">Service Details :</h4><br>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Category<span class="text-danger">*</span></label>
<select class="form-control" id="category" name="category" required>
<option value="">Select</option>
<option value="0" <?= (isset($services['category']) && $services['category'] == 0) ? 'selected' : '' ?> >Custom</option>
<option value="1" <?= (isset($services['category']) && $services['category'] == 1) ? 'selected' : '' ?> >Manual</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Service Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="servicename" placeholder="Service Name" value="<?= isset($services['service_name']) ? $services['service_name'] : '' ?>" required>
</div>
</div>
<div id="customFields" <?php if(isset($services['category']) && $services['category'] == "0") { echo 'style="display: none;"'; } ?> >
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label> <label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="make" name="make[]" required multiple> <select class="form-control SelExample" id="make" name="make[]" required multiple>
<!-- Options for make --> <!-- Options for make -->
<!-- <option value="0">Custom</option> -->
<?php foreach ($make as $value): ?> <?php foreach ($make as $value): ?>
<option value="<?= $value['make_id'] ?>" <?= isset($services['makes_id']) && in_array($value['make_id'], $services['makes_id']) ? 'selected' : '' ?>><?= $value['make'] ?></option> <option value="<?= $value['make_id'] ?>" <?= isset($services['makes_id']) && in_array($value['make_id'], $services['makes_id']) ? 'selected' : '' ?>><?= $value['make'] ?></option>
<?php endforeach; ?> <?php endforeach; ?>
@ -33,6 +49,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label> <label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="model" name="model[]" required multiple> <select class="form-control SelExample" id="model" name="model[]" required multiple>
<!-- <option value="0">Custom</option> -->
<?php foreach ($models as $make_models): ?> <?php foreach ($models as $make_models): ?>
<?php foreach ($make_models as $model): ?> <?php foreach ($make_models as $model): ?>
<option value="<?= $model['model_id'] ?>" <?= isset($services['models_id']) && in_array($model['model_id'], $services['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option> <option value="<?= $model['model_id'] ?>" <?= isset($services['models_id']) && in_array($model['model_id'], $services['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
@ -40,17 +57,48 @@
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Service Name<span class="text-danger">*</span></label> <label for="model" class="col-form-label">Product<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="servicename" placeholder="Service Name" value="<?= isset($services['service_name']) ? $services['service_name'] : '' ?>" required> <select class="form-control SelExample" id="productSelect" name="product_id[]" required multiple>
<option value="">Select a Product</option>
<option value="0" <?= isset($services['product_id']) && in_array(0, json_decode($services['product_id'])) ? 'selected' : '' ?>>None</option>
<?php foreach ($product as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($services['product_id']) && in_array($value['product_id'], json_decode($services['product_id'])) ? 'selected' : '' ?>>
<?= $value["product_name"]; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="model" class="col-form-label">Service<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="serviceSelected" name="sub_service_id[]" required multiple>
<option value="">Select a Service</option>
<option value="0" <?= isset($services['sub_service_id']) && in_array(0, json_decode($services['sub_service_id'])) ? 'selected' : '' ?>>None</option>
<?php foreach ($service as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["service_id"] ?>" <?= isset($services['sub_service_id']) && in_array($value['sub_service_id'], json_decode($services['sub_service_id'])) ? 'selected' : '' ?>>
<?= $value["service_name"]; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div> </div>
</div> </div>
<input type="hidden" id="service_id" name="service_id" value="<?= isset($services['service_id']) ? $services['service_id'] : '' ?>"><br> <input type="hidden" id="service_id" name="service_id" value="<?= isset($services['service_id']) ? $services['service_id'] : '' ?>"><br>
<h4 class="header-title">Pricing Information :</h4><br> <h4 class="header-title">Pricing Information :</h4><br>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Price<span class="text-danger">*</span></label> <label for="inputEmail4" class="col-form-label">Labour Cost<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="price" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" required> <input type="text" class="form-control" name="labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['labour_cost']) ? $services['labour_cost'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="price" id="price" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" required>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax</label> <label for="inputPassword4" class="col-form-label">Tax</label>
@ -208,6 +256,122 @@ $(document).ready(function() {
</script> </script>
<script>
document.getElementById('category').addEventListener('change', function() {
var customFields = document.getElementById('customFields');
var makeSelect = document.getElementById('make');
var modelSelect = document.getElementById('model');
if (this.value == '1') {
customFields.style.display = 'block';
makeSelect.setAttribute('required', 'required');
modelSelect.setAttribute('required', 'required');
} else {
customFields.style.display = 'none';
makeSelect.removeAttribute('required');
modelSelect.removeAttribute('required');
}
});
</script>
<input id="productCost" value="0" hidden>
<script>
data = <?php echo json_encode($product) ?>;
$('#productSelect').change(function() {
console.log('jsfd');
if(this.value != 0) {
// Get the selected options
var selectedOptions = this.selectedOptions;
// Initialize sum
var sum = 0;
for (var i = 0; i < selectedOptions.length; i++) {
var productId = selectedOptions[i].value;
var price = getPriceForProductId(productId);
sum += parseInt(price);
}
$('#productCost').val(parseInt(sum));
console.log(sum);
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + labour_cost;
console.log("New value of #serviceCost:", add);
$('#price').val(add);
}
else if(this.value == '') {
$('#productCost').val(0);
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) + labour_cost;
console.log("New value of #serviceCost:", add);
$('#price').val(add);
}
});
// Function to fetch the price for a product
function getPriceForProductId(productId) {
for (var i = 0; i < data.length; i++) {
if (data[i].product_id === productId) {
// Return the purchase_cost if the product_id matches
return data[i].purchase_cost;
}
}
}
</script>
<input id="serviceCost" value="0" hidden>
<script>
servicedata = <?php echo json_encode($service) ?>;
$('#serviceSelected').change(function() {
console.log(this.value);
if(this.value != 0) {
// Get the selected options
var selectedOptions = this.selectedOptions;
// Initialize sum
var ssum = 0;
for (var i = 0; i < selectedOptions.length; i++) {
var serviceId = selectedOptions[i].value;
var sprice = getPriceForServiceId(serviceId);
ssum += parseInt(sprice);
}
$('#serviceCost').val(parseInt(ssum));
console.log(ssum);
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val()) + labour_cost;
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val());
console.log("New value of #serviceCost:", add);
$('#price').val(add);
}
else if(this.value == '') {
$('#serviceCost').val(0);
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val()) + labour_cost;
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val());
console.log("New value of #serviceCost:", add);
$('#price').val(add);
}
});
// Function to fetch the price for a product
function getPriceForServiceId(serviceId) {
console.log(serviceId);
for (var i = 0; i < servicedata.length; i++) {
if (servicedata[i].service_id === serviceId) {
// Return the purchase_cost if the product_id matches
return servicedata[i].price;
}
}
}
</script>
<script>
$('#labour_cost').on('keyup change', function() {
var newValue = ($(this).val() == '') ? 0 : $(this).val();
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(newValue);
$('#price').val(add);
});
</script>
<style> <style>
.select2-container .select2-selection--multiple .select2-selection__choice{ .select2-container .select2-selection--multiple .select2-selection__choice{
padding: 5px 7px 5px 0 !important; padding: 5px 7px 5px 0 !important;