CHANGE_service_module:ss

This commit is contained in:
sriramv 2024-04-24 13:38:42 +05:30
parent ba62d7de7d
commit e43589603e
7 changed files with 133 additions and 29 deletions

Binary file not shown.

View File

@ -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;
}

View File

@ -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;
// echo json_encode($service);die;
$data['service']=$service;
$product=$ProductModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$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'),

View File

@ -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()

View File

@ -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}'>

View File

@ -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>

View File

@ -22,34 +22,82 @@
<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" 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" 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["product_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>
<label for="inputEmail4" class="col-form-label">Labour Cost<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="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" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
@ -208,6 +256,24 @@ $(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>
<style>
.select2-container .select2-selection--multiple .select2-selection__choice{
padding: 5px 7px 5px 0 !important;