Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic
This commit is contained in:
commit
f1f546dfbd
BIN
PO00000008-2024-04-24-04-43-17.pdf
Normal file
BIN
PO00000008-2024-04-24-04-43-17.pdf
Normal file
Binary file not shown.
@ -302,7 +302,7 @@ class Purchase extends BaseController
|
||||
$VendorModel = new VendorModel();
|
||||
$vendor = $VendorModel->where('vendor_id',$this->request->getPost('vendor_id'))->findAll();
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ServiceModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\VendorModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\VendorModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
use App\Models\ProductModel;
|
||||
|
||||
class Service extends BaseController
|
||||
{
|
||||
@ -68,7 +68,7 @@ class Service extends BaseController
|
||||
public function new_service($service_id)
|
||||
{
|
||||
|
||||
|
||||
$ProductModel = new ProductModel();
|
||||
if ($service_id === '0') {
|
||||
|
||||
$data['services'] = [];
|
||||
@ -78,6 +78,12 @@ class Service extends BaseController
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$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";
|
||||
} else if ($service_id !== '0') {
|
||||
|
||||
@ -89,13 +95,18 @@ class Service extends BaseController
|
||||
|
||||
$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 = [];
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
|
||||
foreach ($services['makes_id'] as $make_id) {
|
||||
$models[] = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
||||
if( $services['makes_id'] != null) {
|
||||
foreach ($services['makes_id'] as $make_id) {
|
||||
$models[] = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
$data['models'] = $models;
|
||||
|
||||
// Load make data
|
||||
@ -105,7 +116,12 @@ class Service extends BaseController
|
||||
$tax=$ServiceModel->getTax();
|
||||
$data['tax']=$tax;
|
||||
|
||||
$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;
|
||||
@ -119,6 +135,8 @@ class Service extends BaseController
|
||||
{
|
||||
|
||||
$ServiceModel = new ServiceModel();
|
||||
|
||||
// echo json_encode($this->request->getPost());die;
|
||||
|
||||
$tax= $this->request->getPost('tax')/2;
|
||||
|
||||
@ -130,9 +148,13 @@ class Service extends BaseController
|
||||
$make_json = json_encode($make_ids);
|
||||
$data = [
|
||||
'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,
|
||||
'igst' => $tax,
|
||||
'tax' => $this->request->getPost('tax'),
|
||||
'labour_cost' => $this->request->getPost('labour_cost'),
|
||||
'price' => $this->request->getPost('price'),
|
||||
'makes_id' => $make_json,
|
||||
'models_id' => $model_json,
|
||||
'description' => $this->request->getPost('description'),
|
||||
|
||||
@ -5,7 +5,7 @@ class ServiceModel extends Model
|
||||
{
|
||||
protected $table = 'services';
|
||||
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()
|
||||
|
||||
@ -26,6 +26,11 @@
|
||||
|
||||
<!-- icons -->
|
||||
<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>
|
||||
/* Override toastr font color */
|
||||
.toast-warning {
|
||||
@ -44,6 +49,13 @@
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
toastr.options = {
|
||||
"timeOut": 5000,
|
||||
"closeButton": true,
|
||||
};
|
||||
</script>
|
||||
</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}'>
|
||||
|
||||
@ -159,5 +159,9 @@
|
||||
</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>
|
||||
@ -22,35 +22,83 @@
|
||||
<h4 class="header-title">Service Details :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
<!-- Options for make -->
|
||||
<?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>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
<?php foreach ($models as $make_models): ?>
|
||||
<?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>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
<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-group col-md-4">
|
||||
<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>
|
||||
<!-- Options for make -->
|
||||
<!-- <option value="0">Custom</option> -->
|
||||
<?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>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
<!-- <option value="0">Custom</option> -->
|
||||
<?php foreach ($models as $make_models): ?>
|
||||
<?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>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="model" class="col-form-label">Product<span class="text-danger">*</span></label>
|
||||
<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>
|
||||
<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>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Price<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="price" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" required>
|
||||
<label for="inputEmail4" class="col-form-label">Labour Cost<span class="text-danger">*</span></label>
|
||||
<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 class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Tax</label>
|
||||
@ -208,6 +256,122 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
</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>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user