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

This commit is contained in:
Gowtham M 2025-01-04 08:38:11 +05:30
commit 692b6ff9b8
30 changed files with 504 additions and 124 deletions

View File

@ -98,6 +98,7 @@ $routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1");
$routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
$routes->get("preview_jobcard_invoice/(:any)", "Jobcard::preview_jobcard_invoice/$1");
$routes->get("preview_jobcard/(:any)", "Jobcard::preview_jobcard/$1");
$routes->get("download_jobcard_files/(:any)", "Jobcard::download_jobcard_files/$1");
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
// $routes->post("save_vehicle", "Jobcard::save_vehicle");

View File

@ -79,7 +79,7 @@ class Client extends BaseController
if (!empty($client_id)) {
$data['updated_by'] = (int)$this->session->get('logged_user');
$update= $ClientModel->update($client_id, $data);
if($update){
@ -91,6 +91,7 @@ class Client extends BaseController
$error = "Mobile number already exists";
return json_encode(false);
}else{
$data['created_by'] = (int)$this->session->get('logged_user');
$ClientModel->insert($data);
return json_encode(true);
}

View File

@ -29,6 +29,19 @@ class Complaint extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
try {
$name = $this->request->getPost('name');
$ComplaintModel = new ComplaintModel();
if ($complaint_id>0) {
$complaint = $ComplaintModel->where(['name' => $name, 'isactive' => 1])
->where('complaint_id !=', $complaint_id)
->findAll();
} else {
$complaint = $ComplaintModel->where(['name' => $name, 'isactive' => 1])->findAll();
}
if (!empty($complaint)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
"name" => $this->request->getPost('name'),

View File

@ -25,6 +25,7 @@ use Mpdf\Mpdf;
use DateTime;
use CodeIgniter\API\ResponseTrait;
use App\Helpers\InvNoHelper;
use App\Helpers\ClientDetailsUpdate;
class Jobcard extends BaseController
{
@ -112,6 +113,7 @@ class Jobcard extends BaseController
/** CALCULATE LABOURCOST WITH TAX */
$totalAmount = 0;
$totalTax = 0;
$hsn_sac = 0;
// Calculate total amount and total tax
foreach ($labourcost as $product) {
@ -150,6 +152,8 @@ class Jobcard extends BaseController
//asign values to same array
$data['job_card_products'][$key]['tax_amount'] = $tax;
$data['job_card_products'][$key]['total_amount'] = $total;
$data['job_card_products'][$key]['taxable_value'] = $amount;
$data['job_card_products'][$key]['hsn_sac'] = $hsn_sac;
//calculate sum
$data['sum_of_tax'] += $tax;
@ -228,6 +232,19 @@ class Jobcard extends BaseController
}
}
public function download_jobcard_files($job_card_id)
{
try {
$data = $this->JobcardFileModel->where(['job_card_id'=>$job_card_id,'isactive'=>1])->findAll();
return $this->respond(['status' => 'success','code' => 200,'data' => $data],200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);
}
}
public function download_jobcard($job_card_id)
{
$data = $this->getJobCardData($job_card_id);
@ -640,8 +657,7 @@ class Jobcard extends BaseController
public function add_jobs()
{
if($this->session->get('logged_user_role') == "Store Manager") {
if($this->session->get('logged_user_role') == "Store Manager") {
$data['status'] = $this->request->getPost('status');
$job_card_id = $this->request->getPost('job_card_id');
$this->JobcardModel->update($job_card_id, $data); // issued status update
@ -682,7 +698,11 @@ class Jobcard extends BaseController
'total'=> $this->request->getPost('grand_total'),
'isactive' => 1
];
$update_client_address = $this->request->getPost('update_client_address');
if(isset($update_client_address) && $update_client_address == 'on')
{
ClientDetailsUpdate::updateClientAddress($this->request->getPost('vehicle_id'),$job_card_data);
}
$status = $this->request->getPost('status');
// Insert or update sales order
$job_card_id = $this->request->getPost('job_card_id');

View File

@ -39,6 +39,20 @@ class Manufacturer extends BaseController
$manufacturer_name = $this->request->getPost('manufacturername');
$quality = $this->request->getPost('quality');
$ManufacturerModel = new ManufacturerModel();
if ($manufacturer_id>0) {
$manufacturer = $ManufacturerModel->where(['manufacturer_name' => $manufacturer_name, 'isactive' => 1])
->where('manufacturer_id !=', $manufacturer_id)
->findAll();
} else {
$manufacturer = $ManufacturerModel->where(['manufacturer_name' => $manufacturer_name, 'isactive' => 1])->findAll();
}
if (!empty($manufacturer)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
'manufacturer_name' => $manufacturer_name,
'quality' => $quality,

View File

@ -64,8 +64,21 @@ class Model extends BaseController
try {
$make_id = $this->request->getPost('make_id');
$model_name = $this->request->getPost('modelname');
$BikemodelsModel = new BikemodelsModel();
if ($make_id>0) {
$make = $BikemodelsModel->where(['make' => $model_name, 'isactive' => 1])
->where('make_id !=', $make_id)
->findAll();
} else {
$make = $BikemodelsModel->where(['make' => $model_name, 'isactive' => 1])->findAll();
}
if (!empty($make)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
'make_id' => $make_id,
'model_name' => $model_name

View File

@ -28,16 +28,30 @@ class Outsourcing extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
try {
$name = $this->request->getPost('name');
$id = $this->request->getPost('id');
$OutsourceModel = new OutsourceModel();
if ($id == '') {
$complaint = $OutsourceModel->where(['name' => $name, 'is_active' => 1])
->where('id !=', $id)
->findAll();
} else {
$complaint = $OutsourceModel->where(['name' => $name, 'is_active' => 1])->findAll();
}
if (!empty($complaint)) {
$result = "Name Already Exist";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200);
}
$data = [
"name" => $this->request->getPost('name'),
"name" => $name,
"labour_cost" => $this->request->getPost('labour_cost'),
"cost_with_tax" => $this->request->getPost('cost_with_tax'),
"tax" => $this->request->getPost('tax'),
"description" => $this->request->getPost('description'),
];
if ($this->request->getPost('id') == '') {
if ($id == '') {
$OutsourceModel = new OutsourceModel();
$data['business_id'] = $this->session->get('logged_user_business_id');
$inserted = $OutsourceModel->insert($data);

View File

@ -102,8 +102,10 @@ class Vehicle extends BaseController
$vehicle_id = $this->request->getPost('vehicle_id');
if (!empty($vehicle_id)) {
$data['updated_by'] = (int)$this->session->get('logged_user');
$VehicleModel->update($vehicle_id, $data);
} else {
$data['created_by'] = (int)$this->session->get('logged_user');
$VehicleModel->insert($data);
}
return redirect()->to('vehicle_index');

View File

@ -71,10 +71,25 @@ class Vendor extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$VendorModel = new VendorModel();
$vendor_name = $this->request->getPost('vendor_name');
$vendor_id = $this->request->getPost('vendor_id');
if ($vendor_id>0) {
$vendor = $VendorModel->where(['vendor_name' => $vendor_name, 'isactive' => 1])
->where('vendor_id !=', $vendor_id)
->findAll();
} else {
$vendor = $VendorModel->where(['vendor_name' => $vendor_name, 'isactive' => 1])->findAll();
}
if (!empty($vendor)) {
session()->setFlashdata('warning', 'Vendor Name Already Exist.');
$this->logger->info("Vendor: Name Already Exist ID = ".$vendor_id);
return redirect()->to('vendor_index');
}
$data = [
'vendor_name' => $this->request->getPost('vendor_name'),
'vendor_name' => $vendor_name,
'gstnumber' => $this->request->getPost('gstnumber'),
'vendor_email' => $this->request->getPost('email'),
'address' => $this->request->getPost('address'),

View File

@ -5,7 +5,7 @@ class ClientModel extends Model
{
protected $table = 'client';
protected $primaryKey = 'client_id';
protected $allowedFields = ['client_id','client_type','gstnumber','client_name','email','mobile_no','address','city','state','postal_code','country','description','isactive','branch_id'];
protected $allowedFields = ['client_id','client_type','gstnumber','client_name','email','mobile_no','address','city','state','postal_code','country','description','isactive','branch_id','updated_by','created_by'];
}

View File

@ -83,7 +83,7 @@ class JobcardModel extends Model
public function get_jobcard_products_details($job_id)
{
$this->select('job_card_product.*, products.product_name, products.per');
$this->select('job_card_product.*, products.product_name, products.per,products.hsn_sac');
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id');
$this->join('products', 'products.product_id = job_card_product.product_id');
$this->where('job_card_product.is_active', 1);

View File

@ -46,7 +46,7 @@ class SalesOrderModel extends Model
$result = $this->db->table('sales_order_product')
->where('sales_order_product.sales_order_id', $sales_order_id)
->join('products', 'products.product_id = sales_order_product.product_id')
->select('sales_order_product.*, products.product_name, products.per, products.ml')
->select('sales_order_product.*, products.product_name, products.per, products.ml,products.hsn_sac')
->get()
->getResult();

View File

@ -7,7 +7,7 @@ class VehicleModel extends Model
protected $table = 'vehicle';
protected $primaryKey = 'vehicle_id';
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','gstnumber','email','postal_code','mobile_no','specific','isactive'];
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','gstnumber','email','postal_code','mobile_no','specific','isactive','updated_by','created_by'];
public function getCustomerandVehicle($branch_id)
{

View File

@ -20,7 +20,7 @@
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Client Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="client_name" placeholder="Name" value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>" required>
<input type="text" class="form-control" name="client_name" id="client_name" placeholder="Name" value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputAddress" class="col-form-label">Mobile<span class="text-danger">*</span></label>
@ -70,7 +70,7 @@
</div>
</div>
<button type="submit" id="client_form_submit" class="btn btn-primary">Submit</button>
<button type="submit" id="client_form_submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -92,6 +92,22 @@
// action="<?= base_url() . "add_client"; ?>"
var formData = $('#client_form').serialize();
const submitButton = $('#client_form_submit');
var mobile = $('#mobile').val();
var clientname = $('#client_name').val();
if (!clientname) {
toastr.warning("Client Name cannot be empty!");
$('#client_name').focus();
submitButton.prop('disabled', false).text('Submit');
return;
}
if (!mobile) {
toastr.warning("mobile Number cannot be empty!");
$('#mobile').focus();
submitButton.prop('disabled', false).text('Submit');
return;
}
submitButton.prop('disabled', true).text('Processing...');
$.ajax({
type: 'POST',
@ -102,12 +118,12 @@
console.log(response);
if(response == 'update'){
toastr.success('Client Updated Succssfully');
window.location.href = '<?= base_url() . "client_index"; ?>';
// submitButton.prop('disabled', false).text('Submit');
}else if(response){
toastr.success('Client Added Succssfully');
window.location.href = '<?= base_url() . "client_index"; ?>';
// submitButton.prop('disabled', false).text('Submit');
}else{
toastr.warning('Mobile number already exists');
$('#mobile_error').html('Mobile number already exists');
@ -115,8 +131,8 @@
$('#mobile').focus();
setTimeout(() => {
$('#mobile').css('border', '1px solid #ced4da');
}, 2000);
submitButton.prop('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {

View File

@ -19,9 +19,9 @@
<table id="datatable-complaint" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;">
<thead>
<tr>
<th> Complaint</th>
<th>Complaint</th>
<th>Unit Price (Including Tax)</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th>
<th hidden>Status</th>
<th>Actions</th>
@ -34,8 +34,8 @@
$color ='red';
}?>
<tr class="complaint_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" > <td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_cost_with_tax']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_charge']; ?></td>
<td hidden>
<?php if($value['isactive'] == 1): ?>
@ -80,8 +80,11 @@
<label for="name">Complaint </label>
<input class="form-control" type="text" id="complaint_id" hidden>
<input class="form-control" type="text" id="name" required="" placeholder="Complaint">
</div>
<div class="form-group">
<label for="labour_cost_with_tax">Unit Price (Including Tax)</label>
<input class="form-control" type="number" id="labour_cost_with_tax" name="labour_cost_with_tax" placeholder="Total Price" step="0.01" min="0" onkeyup="ReverseCalculation()" required>
</div>
<div class="form-group">
<label for="labour_charge">Tax </label>
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2" onchange="ReverseCalculation()">
@ -90,10 +93,6 @@
<option value="28" >28%</option>
</select>
</div>
<div class="form-group">
<label for="labour_cost_with_tax">Labour Charge + Tax</label>
<input class="form-control" type="text" id="labour_cost_with_tax" placeholder="Labour Charge + Tax" onkeyup="ReverseCalculation()" required>
</div>
<div class="form-group">
<label for="labour_charge">Labour Charge </label>
<input class="form-control" type="text" id="labour_charge" placeholder="Labour Charge" required readonly>
@ -138,8 +137,7 @@
if (!complaint_id) {
complaint_id = 0;
}
$(params).attr('disabled', true);
$(params).attr('disabled', true).text('Processing...');
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_complaint/"?>' + complaint_id,
@ -147,12 +145,29 @@
dataType: 'json',
success: function(response) {
console.log(response);
// Reload the page after successful submission
window.location.reload();
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
toastr.success(response.data, 'Success');
window.location.reload();
} else {
toastr.warning(response.data || "Unexpected error occurred!", 'Warning');
$(params).attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.warning(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
});
}

View File

@ -175,7 +175,7 @@
</div>
</div>
<?php if ($return_order['status'] !== 'Returned') : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>
</div>

16
app/Views/invoice_pdf_template.php Normal file → Executable file
View File

@ -88,11 +88,13 @@
<thead>
<tr style="height: 36px; border: 1px solid lightgrey;background: lightgray; font-size: x-small;">
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>No</strong></td>
<td style="width: 5%; height: 36px; text-align: center; font-size: small;"><strong>No</strong></td>
<td style="width: 20%; height: 36px; text-align: left; font-size: small;"><strong>Description</strong></td>
<td style="width: 5%; height: 36px; text-align: center; font-size: small;"><strong>HSN/SAC</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Rate(&#8377;)</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Qty</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Per</strong></td>
<td style="width: 5%; height: 36px; text-align: center; font-size: small;"><strong>Qty</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Taxable Value</strong></td>
<td style="width: 5%; height: 36px; text-align: center; font-size: small;"><strong>Per</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>GST(%)</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: 12px;"><strong>Total Tax(&#8377;)</strong></td>
<td style="width: 10%; height: 36px; text-align: right; font-size: small;"><strong>Total(&#8377;)</strong></td>
@ -114,9 +116,11 @@
<tr >
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"> <?= $key+1; ?> </td>
<td style="width: 10%; padding:10px; font-size: small;"> <?= $value->product_name; ?> </td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?php echo $value->net_price; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->qty; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->per; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->hsn_sac; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->net_price; ?></td>
<td style="width: 5%; padding:10px; text-align: center; font-size: small;"><?= $value->qty; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= ($value->net_price * $value->qty); ?></td>
<td style="width: 5%; padding:10px; text-align: center; font-size: small;"><?= $value->per; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->tax; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;">&nbsp;<?php echo number_format($tax, 2, '.', ''); ?></td>
<td style="width: 10%; padding:10px; text-align: right; font-size: small;"><?php echo number_format($value->amount, 2, '.', ''); ?></td>

View File

@ -89,10 +89,12 @@
<tr style="height: 36px; border: 1px solid lightgrey;background: lightgray; font-size: x-small;">
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>No</strong></td>
<td style="width: 20%; height: 36px; text-align: left; font-size: small;"><strong>Description</strong></td>
<td style="width: 10%; height: 36px; text-align: left; font-size: small;"><strong>Description</strong></td>
<td style="width: 10%; height: 36px; text-align: left; font-size: small;"><strong>HSN/SAC</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Rate(&#8377;)</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Qty</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Per</strong></td>
<td style="width: 5%; height: 36px; text-align: center; font-size: small;"><strong>Qty</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>Taxable Value</strong></td>
<td style="width: 5%; height: 36px; text-align: center; font-size: small;"><strong>Per</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: small;"><strong>GST(%)</strong></td>
<td style="width: 10%; height: 36px; text-align: center; font-size: 12px;"><strong>Total Tax(&#8377;)</strong></td>
<td style="width: 10%; height: 36px; text-align: right; font-size: small;"><strong>Total(&#8377;)</strong></td>
@ -105,12 +107,14 @@
<?php foreach ($job_card_products as $key => $value) { ?>
<tr >
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"> <?= $key+1; ?> </td>
<td style="width: 10%; height: 5px; font-size: small;"> <?= $value['product_name']; ?> </td>
<td style="width: 5%; height: 5px;text-align: center; font-size: small;"> <?= $key+1; ?> </td>
<td style="width: 20%; height: 5px; font-size: small;"> <?= $value['product_name']; ?> </td>
<td style="width: 5%; height: 5px;text-align: center; font-size: small;"> <?= $value['hsn_sac']; ?> </td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?php echo $value['amount']; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value['qty']; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value['per']; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value['tax']; ?></td>
<td style="width: 5%; height: 5px;text-align: center; font-size: small;"><?= $value['qty']; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value['taxable_value'] ; ?></td>
<td style="width: 5%; height: 5px;text-align: center; font-size: small;"><?= $value['per']; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= number_format($value['tax'], 2, '.', ''); ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;">&nbsp;<?php echo number_format($value['tax_amount'], 2, '.', ''); ?></td>
<td style="width: 10%; height: 5px;text-align: right; font-size: small;"><?php echo number_format($value['total_amount'], 2, '.', ''); ?></td>
</tr>

View File

@ -6,6 +6,19 @@
opacity: 0.5;
cursor: not-allowed;
}
hr{
margin-top:0 !important;
}
.file-append-row{
margin-bottom:-18px !important;
}
.file-append-row,.file-exist-row{
/* margin-bottom:-18px !important; */
margin-top:-35px !important;
}
</style>
<style>
@ -131,6 +144,14 @@
</div>
</div>
<br>
<div class="form-row">
<div class="form-group col-md-12" style="display: flex;align-items: center; gap: 8px;">
<input class="form-check-input" type="checkbox" name="update_client_address" style=" margin: 0;">
<label class="form-check-label" for="flexCheckDefault" style=" margin: 0;padding-left: 20px;">
Update client address
</label>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Fuel Qty<span class="text-danger"></span></label>
@ -219,19 +240,27 @@
</div>
<?php endif; ?>
</div>
<div class="files">
<div class="form-row">
<div class="form-group col-md-12" style="text-align: right;">
<button type="button" class="btn btn-primary waves-effect btn-sm a1"
onclick="appendFilesFileds()" id="filebtn">
Add File
</button>
<div style="display: flex; justify-content: space-between; align-items: center;">
<h4>File Details</h4>
<div>
<button type="button" class="btn" onclick="toggleFiles(this)">
<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i></h4>
</button>
</div>
</div>
<div id="existingContainer"></div>
<div id="filesContainer"></div>
</div>
<hr>
<div class="files" style="display: none;">
<div class="form-row">
<div class="form-group col-md-12" style="text-align: right;">
<button type="button" class="btn btn-primary waves-effect btn-sm a1" onclick="appendFilesFileds()" id="filebtn">
Add File
</button>
</div>
</div>
<br>
<div id="existingContainer"></div>
<div id="filesContainer"></div>
</div>
<div class="form-row" id="itemTableContainer">
<div class="form-group col-md-12">
<h4>Item Details</h4>
@ -311,10 +340,10 @@
</div>
<?php if (!isset($jobs['status']) || $jobs['status'] !== 'Paid') : ?>
<button type="submit" id="submit-btn" class="btn btn-primary">Submit</button>
<button type="submit" id="submit-btn" class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
<?php if (isset($rework) && $rework = 'Paid') : ?>
<button type="submit" id="submit-btn" class="btn btn-primary">Submit</button>
<button type="submit" id="submit-btn" class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>
</div>
@ -1208,11 +1237,12 @@ $(document).ready(function() {
data_contruction_for_save();
$("#delete_items").val(JSON.stringify(delete_items_id));
$('#form-submit').submit();
$('#submit-btn').prop('disabled', true);
$('#submit-btn').prop('disabled', true).text('Processing...');
}else{
$('#submit-btn').prop('disabled', false).text('Submit');
}
});
});
// Event listener for product selection
$(document).on('change', 'select[name="item_details[]"]', function() {
var productId = $(this).val();
@ -2307,7 +2337,7 @@ $(document).ready(function() {
var fileId = data != null && data != '' ? data.file_id : '';
var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
var newRowHtml = `<div class="form-row pad mb-2">
var newRowHtml = `<div class="file-exist-row form-row pad mb-2">
<div class="form-group col-md-4">
<label class="col-form-label">File name</label>
<input type="text" maxlength="255" class="form-control" value="${fileName}" readonly>
@ -2325,12 +2355,12 @@ $(document).ready(function() {
`;
$('#existingContainer').append(newRowHtml);
$('#existingContainer').append(newRowHtml);existingContainer
}
function appendFilesFileds(data) {
var newRowHtml = `
<div class="form-row pad">
<div class="file-append-row form-row pad mb-2">
<div class="form-group col-md-4">
<label class="col-form-label">File name</label>
<input type="text" id="manual_file_name" name="manual_file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.manual_file_name : ''}">
@ -2392,6 +2422,27 @@ $(document).ready(function() {
}
</script>
<script>
// $(document).ready(function() {
// const button = $('.toggle-btn')[0]; // Select the button element
// toggleFiles(button); // Call toggleFiles on document ready
// });
function toggleFiles(button) {
const filesContainer = document.querySelector('.files');
// Check if the container is already maximized or minimized
if (filesContainer.style.display === "none") {
filesContainer.style.display = "block"; // Show and maximize the container
button.innerHTML = '<h4><i class="fa fa-minus" aria-hidden="true" style="margin-right: 5px;"></i></h4>';
} else {
filesContainer.style.display = "none"; // Minimize the container
button.innerHTML = '<h4><i class="fa fa-plus" aria-hidden="true" style="margin-right: 5px;"></i></h4>';
}
}
</script>

View File

@ -91,6 +91,7 @@
<!-- <a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Invoice</a> -->
<?php } ?>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" class="dropdown-item preview-jobcard" href="#" title="Preview Jobcard"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Jobcard</a>
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" data-order_number="<?= $value['order_number']; ?>" class="dropdown-item download-files"><i class="ri-eye-fill mr-2 text-muted font-18 vertical-middle"></i>Preview Files</a>
<!-- <a href="<?= base_url() ."download_jobcard/" . $value['job_card_id']; ?>" class="dropdown-item download-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Jobcard</a> -->
<?php if($value['status'] == 'Paid' && $admins && $value['is_rework'] == 0) { ?>
@ -150,6 +151,20 @@
</div>
</div>
</div>
<div class="modal fade" id="FilesModal" tabindex="-1" role="dialog" aria-labelledby="FilesModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="width: 794px; height: 1123px;">
<div class="modal-header">
<h5 class="modal-title" id="FilesModalLabel"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" style="font-family: Times New Roman, Times, sans-serif !important; font-size: 12px !important;">
</div>
</div>
</div>
</div>
<?php include('layout/footer.php'); ?>
@ -288,6 +303,89 @@
});
});
$(document).on('click', '.download-files', function() {
var jobCardId = $(this).data('job-card-id');
var orderNumber = $(this).data('order_number');
$('#FilesModal .modal-body').empty();
$.ajax({
type: 'GET',
url: 'download_jobcard_files/'+jobCardId,
dataType: 'json',
success: function(response) {
if (response.status == "success") {
$('#FilesModal').modal('show');
$('#FilesModalLabel').text('Jobcard Files Modal ( '+orderNumber+' )');
// var filePath = response.data != null && response.data != '' ? response.data.file_name : '';
// console.log(filePath);
// var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
// var fileName = response.data != null && response.data != '' ? response.data.manual_file_name : '';
const base_url = '<?php echo base_url(); ?>';
if(response.data && response.data.length > 0){
var newRowHtml = `<div class="container-fluid">
<div class="row">`;
(response.data).forEach(function(row) {
var filePath = row != null && row != '' ?row.file_name : '';
var downloadUrl = `${base_url}public/uploads/jobcardfiles/${filePath}`;
var fileName = row != null && row != '' ? row.manual_file_name : '';
var fileType = filePath.split('.').pop().toLowerCase();
var imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
newRowHtml += `<div class="col-md-6 col-xl-3">
<div class="card product-box">
<div class="product-img">
<div class="p-3">`;
if (imageExtensions.includes(fileType)) {
newRowHtml +=`<img src="`+downloadUrl+`" alt="Image Not Found" class="img-fluid" />`;
} else {
newRowHtml +=`<div text-align="center" >This is NOT an image file.`+`its a `+fileType+` type file</div>`;
}
newRowHtml +=`</div>
</div>
<div class="product-info border-top p-3">
<div style="display: flex; justify-content: space-between; align-items: center;">
<h5 class="font-16 mt-0 mb-1">
<a href="#" class="text-dark">`+fileName+`</a>
</h5>
<a href="${downloadUrl}" download>
<i class="fa fa-download" aria-hidden="true" style="font-size: 25px;"></i>
</a>
</div>
</div>
</div>
</div>`;});
newRowHtml += `</div>
</div>`;
$('#FilesModal .modal-body').append(newRowHtml);
}else{
$('#FilesModal .modal-body').append(`
<div style="text-align: center; padding: 10px; color: red;">
Data not found
</div>
`);
}
}else{
$('#FilesModal').modal('hide');
$('#FilesModalLabel').text('');
$('#FilesModal .modal-body').append(`
<div style="text-align: center; padding: 10px; color: red;">
Data not found
</div>
`);
alert("Data Not Founded");
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
$('#FilesModal').modal('hide');
$('#FilesModalLabel').text('');
$('#FilesModal .modal-body').append(`
<div style="text-align: center; padding: 10px; color: red;">
Data not found
</div>
`);
}
});
});
$(document).on('click', '#printInvoiceButton', function() {
var jobCardId = $(this).data('id');

View File

@ -151,6 +151,7 @@
modelname: $('#modelname').val()
};
var model_id =0;
$(params).attr('disabled','true').text('Processing...');
$.ajax({
type: 'POST',
url: 'create_model/'+model_id,
@ -158,6 +159,13 @@
dataType: 'json',
success: function(response) {
console.log(response);
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{
@ -165,10 +173,22 @@
$('#modelname').val('');
toastr.success(response.data, 'Success');
}
} else {
alert(response.data || "Unexpected error occurred!");
toastr.success(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.success(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
});
}
@ -190,25 +210,43 @@
if (!edit_make_id) {
edit_make_id =0;
}
$(params).attr('disabled','true').text('Processing...');
$.ajax({
type: 'POST',
url: 'create_make/'+edit_make_id,
data: formData,
dataType: 'json',
success: function(response) {
if (response.status == "failed") {
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
}else{
$('#bike_make_login-modal').modal('hide');
$('#bike_make_name').val('');
toastr.success(response.data, 'Success');
window.location.reload();
$(params).attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{
$('#bike_model_login-modal').modal('hide');
$('#modelname').val('');
toastr.success(response.data, 'Success');
window.location.reload();
}
} else {
alert(response.data || "Unexpected error occurred!");
toastr.success(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
// console.error(xhr.responseText);
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.success(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
}
});
}

View File

@ -123,7 +123,7 @@
if (!$('#manufacturer_name').val() || !$('#quality').val()) {
return false;
}
$('#manufacturer_submit').attr('disabled','true');
$('#manufacturer_submit').attr('disabled','true').text('Processing...');
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_manufacturer/"?>'+edit_manufacturer_id,
@ -131,13 +131,30 @@
dataType: 'json',
success: function(response) {
console.log(response);
$('#manufacturer_modal').modal('hide');
$('#bike_make_name').val('');
window.location.reload();
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$('#manufacturer_submit').attr('disabled', false).text('Submit');
return;
}
if (response.code === 200) {
$('#manufacturer_modal').modal('hide');
$('#bike_make_name').val('');
toastr.success(response.data, 'Success');
window.location.reload();
} else {
toastr.warning(response.data || "Unexpected error occurred!", 'Warning');
$('#manufacturer_submit').attr('disabled', false).text('Submit');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.warning(errorMessage, 'Warning');
$('#manufacturer_submit').attr('disabled', false).text('Submit');
}
});
}

View File

@ -20,8 +20,8 @@
<thead>
<tr>
<th>Out Sourcing</th>
<th>Unit Price (Including Tax)</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th>
<th>Description</th>
<th hidden>Status</th>
@ -36,8 +36,8 @@
}?>
<tr class="outsource_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
<td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['cost_with_tax']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_cost']; ?></td>
<td><?= $value['description']; ?></td>
<td hidden>
@ -85,6 +85,10 @@
<input class="form-control" type="text" id="name" required="" placeholder="Name">
</div>
<div class="form-group">
<label for="cost_with_tax">Unit Price (Including Tax)</label>
<input class="form-control" type="number" id="cost_with_tax" name="cost_with_tax" placeholder="Total Price" step="0.01" min="0" onkeyup="ReverseCalculation()" required >
</div>
<div class="form-group">
<label for="labour_charge">Tax </label>
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2" onchange="ReverseCalculation()">
@ -93,10 +97,6 @@
<option value="28" >28%</option>
</select>
</div>
<div class="form-group">
<label for="cost_with_tax">Labour Charge + Tax</label>
<input class="form-control" type="text" id="cost_with_tax" name="cost_with_tax" placeholder="Labour Charge + Tax" onkeyup="ReverseCalculation()" required="">
</div>
<div class="form-group">
<label for="labour_cost">Labour Cost </label>
<input class="form-control" type="text" id="labour_cost" placeholder="Labour Charge" required readonly>
@ -134,6 +134,7 @@
function submitComplaint(params, event) {
$(params).attr('disabled', true).text('Processing...');
if (!$('#name').val() || !$('#labour_cost').val() ) {
return false;
}
@ -159,11 +160,32 @@
// $('#outsource_submit_button').removeAttr('disabled');
console.log(response);
// Reload the page after successful submission
window.location.reload();
if (response.code === 404) {
toastr.warning(response.data, 'Warning');
$(params).attr('disabled', false).text('Submit');
$('#outsource_form')[0].reset();
return;
}
if (response.code === 200 || response.status === 'success') {
toastr.success(response.data, 'Success');
window.location.reload();
} else {
toastr.warning(response.data || "Unexpected error occurred!", 'Warning');
$(params).attr('disabled', false).text('Submit');
$('#outsource_form')[0].reset();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
let errorMessage = "An error occurred while processing your request.";
if (xhr.responseJSON && xhr.responseJSON.data) {
errorMessage = xhr.responseJSON.data;
}
toastr.warning(errorMessage, 'Warning');
$(params).attr('disabled', false).text('Submit');
$('#outsource_form')[0].reset();
}
});
}

View File

@ -32,7 +32,7 @@
<div class="card">
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_purchase"; ?>" method="post">
<form action="<?= base_url() . "add_purchase"; ?>" method="post" id="purchaseForm">
<input type="hidden" id="purchase_order_id" name="purchase_order_id" value="<?= isset($purchase['purchase_order_id']) ? $purchase['purchase_order_id'] : '' ?>"readonly>
<h4 class="header-title">Purchase Details :</h4><br>
<div class="form-row">
@ -226,7 +226,7 @@
</div>
</div> -->
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Received' || isset($reorder)) : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>
</div>
@ -641,6 +641,12 @@ $('#editaddbutton').click(function(event) {
// 'background-color': '#ebebe0',
// });
});
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#purchaseForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});

View File

@ -156,7 +156,7 @@
</textarea>
</div>
</div>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>

View File

@ -199,7 +199,7 @@
</div>
</div>
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Released') : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<button type="submit" id="editaddbutton"class="btn btn-primary" style="float:right;">Submit</button>
<?php endif; ?>
</form>

View File

@ -18,7 +18,7 @@
<div class="card">
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_service"; ?>" method="post">
<form action="<?= base_url() . "add_service"; ?>" method="post" id="serviceForm">
<h4 class="header-title">Service Details :</h4>
<div class="form-row">
<div class="form-group col-md-3">
@ -88,25 +88,10 @@
<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>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax</label>
<select class="form-control status-select" name="tax" data-toggle="select2" required>
<?php
<?php
$cgst = isset($services['cgst']) ? $services['cgst'] : 0; // CGST value (half of the tax amount)
$sgst = isset($services['sgst']) ? $services['sgst'] : 0; // SGST value (half of the tax amount)
$tax = $cgst + $sgst; // Total tax (sum of CGST and SGST)
?>
<option value="" <?= ($tax == 0) ? 'selected' : '' ?>>Select Tax</option>
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Labour Cost + Tax<span class="text-danger">*</span></label>
<?php
if(isset($services['labour_cost'])){
$labour_cost = ($services['labour_cost'] / 100) * $tax;
$labour_cost = round($labour_cost + $services['labour_cost']);
@ -114,7 +99,18 @@
$labour_cost = '';
}
?>
<input type="text" class="form-control" name="labour_cost_With_Tax" id="LabourCostWithTax" placeholder="Labour Cost + Tax" value="<?= $labour_cost; ?>" required="">
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Unit Price (Including Tax)<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="labour_cost_With_Tax" id="LabourCostWithTax" placeholder="Total Price" step="0.01" min="0" value="<?= $labour_cost; ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax<span class="text-danger">*</span></label>
<select class="form-control status-select" name="tax" data-toggle="select2" required>
<option value="" <?= ($tax == 0) ? 'selected' : '' ?>>Select Tax</option>
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select>
</div>
@ -141,7 +137,7 @@
<textarea class="form-control" name="description" placeholder="Description" ><?= isset($services['description']) ? $services['description'] : '' ?></textarea>
</div>
</div>
<button id="service_form_submit" type="submit" class="btn btn-primary">Submit</button>
<button id="service_form_submit" type="submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -470,6 +466,12 @@ document.getElementById('category').addEventListener('change', function() {
// }
})
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#serviceForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});
</script>

View File

@ -18,8 +18,7 @@
<div class="card">
<div class="card-body">
<form id="vehicle_add_form_id" action="<?= base_url() . "add_vehicle"; ?>" method="post" id="vehicleForm">
<form id="vehicle_add_form_id" action="<?= base_url() . "add_vehicle"; ?>" method="post">
<h4 class="header-title">Vehicle Details :</h4>
<div class="form-row">
<div class="form-group col-md-4">
@ -468,10 +467,13 @@ $('#saveModelBtn').click(function() {
var register_number = $('#regno').val();
var vehicle_id = $('#vehicle_id').val();
const submitButton = $('#form_submit_button');
submitButton.prop('disabled', true).text('Processing...');
if (!register_number) {
toastr.warning("Registration Number cannot be empty!");
$('#regno').focus(); // Set focus to the registration number input field
submitButton.prop('disabled', false).text('Submit');
return;
}
@ -483,9 +485,9 @@ $('#saveModelBtn').click(function() {
data: { register_number: register_number },
success: function (response) {
if (response) {
$('#regno').val('');
$('#regno').focus(); // Set focus to the registration number input field
$('#regno').val('').focus();
toastr.warning("Register Number Already Added!");
submitButton.prop('disabled', false).text('Submit');
} else {
// If the registration number is not a duplicate, submit the form
$('#vehicle_add_form_id')[0].submit();
@ -494,22 +496,19 @@ $('#saveModelBtn').click(function() {
error: function (xhr, status, error) {
console.error(error); // Log any errors to the console
toastr.error("An error occurred while checking the registration number.");
submitButton.prop('disabled', false).text('Submit');
}
});
} else {
$('#vehicle_add_form_id')[0].submit();
}
});
$('#vehicle_add_form_id').on('submit', function () {
const submitButton = $('#form_submit_button');
submitButton.prop('disabled', true).text('Processing...');
});
});
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#vehicleForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});
</script>

View File

@ -167,7 +167,7 @@
</div>
</div>
<button type="submit" id="vendor_add_submit" class="btn btn-primary">Submit</button>
<button type="submit" id="vendor_add_submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -240,14 +240,14 @@ $(document).ready(function() {
});
$('#vendor_add_submit').click(function (event) {
var form = document.getElementById('vendor_form');
var form = document.getElementById('vendor_form');
if (form.checkValidity()) {
$(this).attr('disabled', true);
$(this).attr('disabled', true).text('Processing...');
$('#vendor_form').submit();
}else{
$(this).attr('disabled', false).text('Submit');
}
})
});
});
</script>
<style>

View File

@ -74,6 +74,21 @@
</div>
</div> <!-- end card -->
</div> <!-- end col -->
<?php if (session()->getFlashdata('warning')): ?>
<script>
$(document).ready(function() {
toastr.warning("<?= session()->getFlashdata('warning'); ?>", "Warning");
});
</script>
<?php endif; ?>
<?php if (session()->getFlashdata('success')): ?>
<script>
$(document).ready(function() {
toastr.success("<?= session()->getFlashdata('success'); ?>", "Success");
});
</script>
<?php endif; ?>
<?php include('layout/footer.php'); ?> </div>
<script>