CHANGE_add_new_module_os:ss

This commit is contained in:
sriramv 2024-05-17 17:05:12 +05:30
parent e060440efd
commit fd9d319773
16 changed files with 1092 additions and 154 deletions

View File

@ -88,6 +88,7 @@ $routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
$routes->get("download_jobcard/(:any)", "Jobcard::download_jobcard/$1");
$routes->get("download_os", "Jobcard::download_os");
$routes->post("getServices", "Jobcard::getServices");
//End Job Card //
@ -202,3 +203,9 @@ $routes->get('dashboard', 'Users::dashboard');
$routes->get('edit_complaint/(:any)', 'Complaint::edit_complaint/$1');
$routes->get("delete_complaint/(:any)", "Complaint::delete_complaint/$1");
// Complaint End's//
// Out sourcing
$routes->get('outsourcing_index', 'Outsourcing::outsourcing_index');
$routes->post('create_os', 'Outsourcing::create_os');
$routes->get('edit_os/(:any)', 'Outsourcing::edit_OS/$1');
// Complaint End's

View File

@ -6,12 +6,14 @@ use App\Models\BranchModel;
use App\Models\JobcardModel;
use App\Models\JobcardComplaintModel;
use App\Models\JobcardCustomComplaintModel;
use App\Models\JobcardOSModel;
use App\Models\JobcardServiceModel;
use App\Models\JobcardProductModel;
use App\Models\ProductModel;
use App\Models\ServiceModel;
use App\Models\ClientModel;
use App\Models\ComplaintModel;
use App\Models\OutsourceModel;
use App\Models\BikemodelsModel;
use App\Models\BikemakeModel;
use App\Models\VehicleModel;
@ -97,8 +99,9 @@ class Jobcard extends BaseController
$servicedata = $this->JobcardModel->get_jobcard_service($job_card_id);
$complaintdata = $this->JobcardModel->get_jobcard_complaint($job_card_id);
$osdata = $this->JobcardModel->get_jobcard_os($job_card_id);
$customcomplaintdata = $this->JobcardModel->get_jobcard_custom_complaint($job_card_id);
$labourcost = array_merge($servicedata, $complaintdata,$customcomplaintdata);
$labourcost = array_merge($servicedata, $complaintdata,$customcomplaintdata,$osdata);
/** CALCULATE LABOURCOST WITH TAX */
$totalAmount = 0;
$totalTax = 0;
@ -111,9 +114,9 @@ class Jobcard extends BaseController
// Calculate total
$total = $totalAmount + $totalTax;
$discount = ($data['job_card'][0]['is_rework'] == 1) ? 0 : $data['job_card'][0]['discount'] ;
$amt_with_tax = $totalAmount + ($totalAmount * $totalTax / 100);
$totalAmount = ($amt_with_tax - $data['job_card'][0]['discount']) / (1 + ($totalTax/100));
$totalAmount = ($amt_with_tax - $discount) / (1 + ($totalTax/100));
// Create single output array
$labour_data[0] = [
"product_name" => "Labour Cost",
@ -211,6 +214,61 @@ class Jobcard extends BaseController
}
public function download_os()
{
$JobcardProductModel = new JobcardProductModel();
$outsource = $this->JobcardModel->download_os($this->session->get('logged_user_branch_id'));
foreach ($outsource as &$value) {
$products = [];
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
$product = $JobcardProductModel->select('job_card_product.job_card_product_id,job_card_product.product_id,job_card_product.qty,products.product_name as pname')
->join('products', 'products.product_id = job_card_product.product_id')
->whereIn('job_card_product.job_card_product_id', $product_ids)->find();
foreach ($product as $pr_value) {
array_push($products,$pr_value);
}
$value['products'] = $products;
}
$data['outsource'] = $outsource;
// Create an mPDF object
$mpdf = new Mpdf([
'mode' => '',
'format' => 'A5',
'default_font_size' => 0,
'default_font' => '',
// 'margin_right' => 1,
'margin_top' => 6,
'margin_bottom' => 6,
'margin_header' => 6,
'margin_footer' =>-30,
'orientation' => 'P',
]);
$mpdf->autoLangToFont = true;
$mpdf->autoScriptToLang = true;
// Set PDF properties
$mpdf->SetTitle('Invoice');
// $mpdf->SetAuthor($data[0]->branch_name);
$mpdf->SetCreator('');
// Generate the PDF content (HTML) with data
$html = view('outsourcing_template', $data);
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);
// Output the PDF to the browser for download
$mpdf->Output('OS_' . date('Y-m-d H-i-s') . '.pdf', 'D');
}
public function new_jobcard($job_card_id,$rework = null)
{
@ -233,11 +291,15 @@ class Jobcard extends BaseController
$ComplaintModel = new ComplaintModel();
$complaint=$ComplaintModel->where('isactive',1)->findAll();
$OutsourceModel = new OutsourceModel();
$os_data=$OutsourceModel->where('is_active',1)->findAll();
$data['complaint']= $complaint;
$data['product_1']=$product;
$data['product']="";
$data['service_1']=$service;
$data['service']="";
$data['service']="";
$data['os_data']=$os_data;
$data['client']=$client;
$data['vehicle']=$vehicle;
$data['logged_user_role'] = $this->session->get('logged_user_role');
@ -251,7 +313,9 @@ class Jobcard extends BaseController
$JobcardServiceModel = new JobcardServiceModel();
$JobcardComplaintModel = new JobcardComplaintModel();
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
$JobcardOSModel = new JobcardOSModel();
$ComplaintModel = new ComplaintModel();
$OutsourceModel = new OutsourceModel();
/*** SERVICE DATA ***/
$servicedata = $JobcardModel->service_data($job_card_id, $this->session->get('logged_user_branch_id'));
@ -288,9 +352,22 @@ class Jobcard extends BaseController
}
$data['editccomplaintdata'] = $ccomplaintdata;
/*** OUTSOURCING DATA ***/
$os_data = $JobcardModel->os_data($job_card_id, $this->session->get('logged_user_branch_id'));
// Using '&' to reference the original array element
foreach ($os_data as &$value) {
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock')
->join('products', 'products.product_id = job_card_product.product_id')
->whereIn('job_card_product_id', $product_ids)->findAll();
$value['product'] = $product;
}
$data['editosdata'] = $os_data;
$complaint=$ComplaintModel->where('isactive',1)->findAll();
$data['complaint']= $complaint;
$data['os_data'] = $OutsourceModel->where('is_active',1)->findAll();
$data['page_name']="Edit Job Card";
$ClientModel = new ClientModel();
@ -391,6 +468,7 @@ class Jobcard extends BaseController
$JobcardServiceModel = new JobcardServiceModel();
$JobcardComplaintModel = new JobcardComplaintModel();
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
$JobcardOSModel = new JobcardOSModel();
$this->delete_items($this->request->getPost('delete_items'));
$rework = $this->request->getPost('rework');
@ -410,10 +488,10 @@ class Jobcard extends BaseController
'note'=> $this->request->getPost('note'),
'status'=> $this->request->getPost('status'),
'assigned_to'=> json_encode($this->request->getPost('assigned_to')),
'subtotal'=> (isset($rework) ? 0 : $this->request->getPost('sub_total') ),
'tax'=> (isset($rework) ? 0 : $this->request->getPost('invoicetax') ),
'discount'=> ($this->request->getPost('discount')) == '' ? 0 : $this->request->getPost('discount'),
'total'=> (isset($rework) ? 0 : $this->request->getPost('grand_total') ),
'subtotal'=> $this->request->getPost('sub_total'), // (isset($rework) ? 0 : $this->request->getPost('sub_total') ),
'tax'=> $this->request->getPost('invoicetax'), //(isset($rework) ? 0 : $this->request->getPost('invoicetax') ),
'discount'=> $this->request->getPost('discount'), //($this->request->getPost('discount')) == '' ? 0 : $this->request->getPost('discount'),
'total'=> $this->request->getPost('grand_total'), //(isset($rework) ? 0 : $this->request->getPost('grand_total') ),
'isactive' => 1
];
$status = $this->request->getPost('status');
@ -453,8 +531,8 @@ class Jobcard extends BaseController
$service['service_id'] = $item->service_id;
$service['qty'] = $item->quality;
$service['tax'] = $item->tax;
$service['labour_cost'] = (isset($rework) ? 0 : $item->labour_cost );
$service['amount'] = (isset($rework) ? 0 : $item->amount );
$service['labour_cost'] = $item->labour_cost; //(isset($rework) ? 0 : $item->labour_cost );
$service['amount'] = $item->amount; //(isset($rework) ? 0 : $item->amount );
if(empty($item->id)) {
$JobcardServiceModel->insert($service);
@ -480,7 +558,7 @@ class Jobcard extends BaseController
// Insert into the service table
$service['job_card_id'] = $job_card_id;
$service['complaint_id'] = $item->complaint_id;
$service['labour_cost'] = $item->labour_cost;
$service['labour_cost'] = $item->amount;
$service['qty'] = $item->quality;
$service['tax'] = $item->tax;
$service['amount'] = $item->amount;
@ -529,6 +607,34 @@ class Jobcard extends BaseController
if(isset($item->product)) { $this->product_data_insertion($job_card_id, $cc_complaint_id, $JobcardCustomComplaintModel, $item, $JobcardProductModel, $status, $rework); }
}
/********** INSERT OUTSOURCE DATA ************/
$os_data = $data[0]->os;
foreach ($os_data as $item) {
// Insert into the service table
$service['job_card_id'] = $job_card_id;
$service['os_id'] = $item->os_id;
$service['labour_cost'] = $item->amount;
$service['qty'] = $item->quality;
$service['tax'] = $item->tax;
$service['amount'] = $item->amount;
if(empty($item->id)) {
$JobcardOSModel->insert($service);
$os_id = $JobcardOSModel->getInsertID();
}
else {
if($status == 'Cancelled')
{
$service = [];
$service['isactive'] = 0;
}
$JobcardOSModel->update($item->id, $service);
$os_id = $item->id;
}
if(isset($item->product)) { $this->product_data_insertion($job_card_id, $os_id, $JobcardOSModel, $item, $JobcardProductModel, $status, $rework); }
}
return redirect()->to('job_card_index');
}
@ -564,7 +670,7 @@ class Jobcard extends BaseController
$product['product_id'] = $pt->p_id;
$product['qty'] = $pt->qty;
$product['tax'] = $pt->tax;
$product['amount'] = (isset($rework) ? 0 : $pt->amount / $pt->qty );
$product['amount'] = $pt->amount / $pt->qty; //(isset($rework) ? 0 : $pt->amount / $pt->qty );
if(empty($pt->id)) {
$JobcardProductModel->insert($product);
$job_card_product_id = $JobcardProductModel->getInsertID();
@ -597,6 +703,7 @@ class Jobcard extends BaseController
$JobcardServiceModel = new JobcardServiceModel();
$JobcardComplaintModel = new JobcardComplaintModel();
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
$JobcardOSModel = new JobcardOSModel();
$data = json_decode($delArr);
$product_data = $data[0]->product;
@ -641,6 +748,17 @@ class Jobcard extends BaseController
$JobcardCustomComplaintModel->where($conditions)->delete();
}
}
$os_data = $data[0]->os;
if(!empty($os_data)) {
foreach ($os_data as $item) {
$conditions = [ 'job_card_os_id' => $item ];
$os_deleted_data = $JobcardOSModel->where($conditions)->findAll();
if(isset($os_deleted_data[0]['product_id']))
$this->product_delete($os_deleted_data[0]['product_id']);
$JobcardOSModel->where($conditions)->delete();
}
}
}
/** DELETE JOB CARD-PRODUCT */

View File

@ -0,0 +1,78 @@
<?php
namespace App\Controllers;
use App\Models\OutsourceModel;
use CodeIgniter\API\ResponseTrait;
class Outsourcing extends BaseController
{
public $session;
use ResponseTrait;
public function __construct()
{
$this->session = session();
}
public function outsourcing_index()
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$OutsourceModel = new OutsourceModel();
$os_data = $OutsourceModel->where('is_active', 1)->findAll();
$data['out_source'] = $os_data;
return view('outsourcing_list', $data);
}
public function create_os()
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
try {
$data = [
"name" => $this->request->getPost('name'),
"labour_cost" => $this->request->getPost('labour_cost'),
"cost_with_tax" => $this->request->getPost('cost_with_tax'),
"tax" => $this->request->getPost('tax'),
];
if ($this->request->getPost('id') == '') {
$OutsourceModel = new OutsourceModel();
$data['business_id'] = $this->session->get('logged_user_business_id');
$inserted = $OutsourceModel->insert($data);
if ($inserted) {
$result = $data;
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
$result = "No Match's";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
}
} else {
$OutsourceModel = new OutsourceModel();
$updated = $OutsourceModel->update($this->request->getPost('id'),$data);
if ($updated) {
$result = $data;
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
$result = "No Match's";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
}
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);
}
}
public function edit_OS($id)
{
$OutsourceModel = new OutsourceModel();
$os_data = $OutsourceModel->where('id',$id)->findAll();
$data['page_name']= 'Edit Out Source';
$data['os_data']= $os_data;
return json_encode($data);
}
}
?>

View File

@ -48,6 +48,16 @@ class JobcardModel extends Model
return $this->findAll();
}
public function os_data($job_card_id, $logged_user_branch_id)
{
$this->select('job_card.job_card_id, job_card_os.*');
$this->join('job_card_os', 'job_card_os.job_card_id = job_card.job_card_id');
$this->where('job_card_os.is_active', 1);
$this->where('job_card.job_card_id',$job_card_id);
$this->where('job_card.branch_id',$logged_user_branch_id);
return $this->findAll();
}
public function ccomplaint_data($job_card_id, $logged_user_branch_id)
{
$this->select('job_card.job_card_id, job_card_custom_complaint.* , job_card_custom_complaint.complaint_name as name');
@ -99,6 +109,16 @@ class JobcardModel extends Model
return $this->findAll();
}
public function get_jobcard_os($job_id)
{
$this->select('job_card.*, job_card_os.*, out_source.name as product_name, job_card_os.labour_cost as labour_amount');
$this->join('job_card_os', 'job_card_os.job_card_id = job_card.job_card_id');
$this->join('out_source', 'out_source.id = job_card_os.os_id');
$this->where('job_card.isactive', 1);
$this->where('job_card.job_card_id', $job_id);
return $this->findAll();
}
public function get_jobcard_custom_complaint($job_id)
{
$this->select('job_card.*, job_card_custom_complaint.*, job_card_custom_complaint.complaint_name as product_name, job_card_custom_complaint.labour_cost as labour_amount');
@ -120,6 +140,32 @@ class JobcardModel extends Model
return $this->findAll();
}
// $this->session->get('logged_user_branch_id')
public function download_os($logged_user_branch_id)
{
$this->select(
'job_card.job_card_id,job_card.created_at,job_card.branch_id,job_card.isactive,job_card.vehicle_id,
job_card_os.job_card_id,job_card_os.os_id,job_card_os.product_id,
out_source.name,
vehicle.reg_no, vehicle.make, vehicle.colour,vehicle.model,
make.make as bike_name, model.model_name as bike_modal_name'
);
// $this->from('job_card');
$this->join('job_card_os', 'job_card_os.job_card_id = job_card.job_card_id');
$this->join('out_source', 'out_source.id = job_card_os.os_id', 'left');
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
$this->join('make', 'make.make_id = vehicle.make', 'left');
$this->join('model', 'model.model_id = vehicle.model', 'left');
$this->where('job_card.isactive', 1);
$this->where('job_card.branch_id',$logged_user_branch_id);
$current_date = date('Y-m-d');
$this->where('DATE(job_card.created_at)', $current_date);
// $this->groupBy('job_card.job_card_id');
$this->orderBy('job_card.job_card_id','DESC');
return $this->findAll();
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class OutsourceModel extends Model
{
protected $table = 'out_source';
protected $primaryKey = 'id';
protected $allowedFields = ['id','business_id','name','labour_cost','tax','cost_with_tax','is_active'];
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class JobcardOSModel extends Model
{
protected $table = 'job_card_os';
protected $primaryKey = 'job_card_os_id';
protected $allowedFields = ['job_card_os_id','job_card_id','os_id', 'labour_cost','product_id', 'qty', 'tax', 'amount','isactive'];
}

View File

@ -250,35 +250,35 @@ p {
<td style="border: 0.5px solid black;"><?php
if(isset($item['custom_amount']))
{
echo round($item['custom_amount']) * $item['custom_tax'];
$sub_tot += round($item['custom_amount']) * $item['qty'];
echo ($item['custom_amount']) * $item['qty'];
$sub_tot += ($item['custom_amount']) * $item['qty'];
}
else
{
echo round($item['amount']) * $item['qty'];
$sub_tot += round($item['amount']) * $item['qty'];
echo ($item['amount']) * $item['qty'];
$sub_tot += ($item['amount']) * $item['qty'];
} ?></td>
<td style="border: 0.5px solid black;"><?= $item['qty'] ?></td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_amount']) ? '-' : $item['per'] ?></td>
<td style="border: 0.5px solid black;"><?= round($item['tax']) ?>%</td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? round($item['custom_tax'] / 2) : round($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? round($item['custom_tax'] / 2) : round($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;"><?= ($item['tax']) ?>%</td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? ($item['custom_tax'] / 2) : ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_tax']) ? ($item['custom_tax'] / 2) : ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;">
<?php if(isset($item['custom_tax'])) {
echo round(( ($item['custom_amount'] * $item['qty']) * $item['tax'] / 100));
$tax+= round(( ($item['custom_amount']* $item['qty'] ) * $item['tax'] / 100));
$tax+= (( ($item['custom_amount']* $item['qty'] ) * $item['tax'] / 100));
} else {
echo round( ($item['amount']* $item['qty']) * $item['tax'] / 100);
echo ( ($item['amount']* $item['qty']) * $item['tax'] / 100);
$tax+= ( ($item['amount']* $item['qty']) * $item['tax'] / 100);
} ?></td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_total']) ? round($item['custom_amount'] + ($item['custom_amount'] * $item['tax'] / 100)) * $item['qty'] : round($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) * $item['qty'] ?></td>
<td style="border: 0.5px solid black;"><?php echo isset($item['custom_total']) ? round( ($item['custom_amount'] + ($item['custom_amount'] * $item['tax'] / 100)) * $item['qty'] ) : ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) * $item['qty'] ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="6" style="border-top: 0.5px solid black;border-left: 0.5px solid black;"></td>
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Subtotal</td>
<td style="border: 0.5px solid black;"><?= $sub_tot ?></td>
<td style="border: 0.5px solid black;"><?= round($sub_tot) ?></td>
</tr>
<tr>
<td colspan="6" style="border-left: 0.5px solid black;"></td>
@ -293,18 +293,18 @@ p {
<tr>
<td colspan="6" style="border-left: 0.5px solid black;"></td>
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Estimate</td>
<td style="border: 0.5px solid black;"><?= $sub_tot + round($tax) ?></td>
<td style="border: 0.5px solid black;"><?php echo ($job_card[0]['is_rework'] == 1) ? 0 : round($sub_tot + $tax) ?></td>
</tr>
<tr>
<td colspan="6" style="border-left: 0.5px solid black;"></td>
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Discount</td>
<td style="border: 0.5px solid black;"><?= $job_card[0]['discount'] ?></td>
<td style="border: 0.5px solid black;"><?php echo ($job_card[0]['is_rework'] == 1) ? round($sub_tot + $tax) : $job_card[0]['discount'] ?></td>
</tr>
<tr>
<td colspan="10" style="border: 0.5px solid black;">Amount Chargeable (in words):
<?php
$formatter = new NumberFormatter("en", NumberFormatter::SPELLOUT);
$words = $formatter->format($sub_tot + round($tax));
$words = $formatter->format(round($sub_tot + $tax));
echo ucfirst($words);
?>
</td>

View File

@ -1,13 +1,17 @@
<?php include('layout/header.php'); ?>
<style>
.disabled {
pointer-events: none;
opacity: 0.5;
cursor: not-allowed;
}
</style>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $page_name?></h4>
<?php if(isset($jobs['job_card_id'])) { ?>
<a style="margin-left: 120px;position: absolute;" href="<?= base_url() ."download_jobcard/" . $jobs['job_card_id']; ?>" class="download-button" title="Download Jobcard"><i class="ri-download-2-fill" style="font-size: 20px;"></i></a>
<?php } ?>
<div class="page-title-right">
<a href="<?= base_url() . "sales_order_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<a href="<?= base_url() . "job_card_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<ol class="breadcrumb m-0">
</li>
@ -33,7 +37,7 @@
<label for="inputEmail4" class="col-form-label">Vehicle<span class="text-danger">*</span></label>
<?= isset($sales['vehicle_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addVehicleModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addVehicleModal" title="Add Client"></i>' ?>
<select class="form-control vehicle-select SelExample" name="vehicle_id" id="vehicle_name" <?= isset($sales['vehicle_id']) ? 'readonly' : 'required="true"' ?>>
<select class="form-control vehicle-select SelExample job_card_basic_details" name="vehicle_id" id="vehicle_name" <?= isset($sales['vehicle_id']) ? 'readonly' : 'required="true"' ?>>
<?= isset($sales['vehicle_id']) ? '' : '<option value="">Select a vehicle</option>' ?>
<?php foreach ($vehicle as $value) : ?>
@ -64,7 +68,7 @@
<div class="form-row">
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Address<span class="text-danger"></span></label>
<input type="text" class="form-control" name="billing_address" placeholder="Address"value="<?= isset($jobs['billing_address']) ? $jobs['billing_address'] : '' ?>" >
<input type="text" class="form-control job_card_basic_details" name="billing_address" placeholder="Address"value="<?= isset($jobs['billing_address']) ? $jobs['billing_address'] : '' ?>" >
</div>
<?php if(!isset($rework)) { ?>
@ -75,37 +79,31 @@
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">City<span class="text-danger"></span></label>
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($jobs['billing_city']) ? $jobs['billing_city'] : 'Chennai' ?>" >
<input type="text" class="form-control job_card_basic_details" name="city" placeholder="City"value="<?= isset($jobs['billing_city']) ? $jobs['billing_city'] : 'Chennai' ?>" >
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">State<span class="text-danger"></span></label>
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($jobs['billing_state']) ? $jobs['billing_state'] : 'Tamil Nadu' ?>" >
<input type="text" class="form-control job_card_basic_details" name="state" placeholder="State"value="<?= isset($jobs['billing_state']) ? $jobs['billing_state'] : 'Tamil Nadu' ?>" >
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">PIN Code<span class="text-danger"></span></label>
<input type="text" class="form-control" name="postalcode" placeholder="PIN Code"value="<?= isset($jobs['billing_postal_code']) ? $jobs['billing_postal_code'] : '' ?>" maxlength="6" minlength="6" >
<input type="text" class="form-control job_card_basic_details" name="postalcode" placeholder="PIN Code"value="<?= isset($jobs['billing_postal_code']) ? $jobs['billing_postal_code'] : '' ?>" maxlength="6" minlength="6" >
</div>
</div>
<br>
<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>
<input type="text" class="form-control" name="fuel_qty" placeholder="Fuel Qty"value="<?= isset($jobs['fuel_qty']) ? $jobs['fuel_qty'] : '' ?>" >
<input type="text" class="form-control job_card_basic_details" name="fuel_qty" placeholder="Fuel Qty"value="<?= isset($jobs['fuel_qty']) ? $jobs['fuel_qty'] : '' ?>" >
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Meter Reading<span class="text-danger"></span></label>
<input type="text" class="form-control" name="meter" placeholder="Meter Reading"value="<?= isset($jobs['meter']) ? $jobs['meter'] : '' ?>" >
<input type="text" class="form-control job_card_basic_details" name="meter" placeholder="Meter Reading"value="<?= isset($jobs['meter']) ? $jobs['meter'] : '' ?>" >
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Delivery Date<span class="text-danger"></span></label>
<input type="date" class="form-control" name="delivery_date" placeholder="Delivery Date" value="<?= isset($jobs['delivery_date']) ? $jobs['delivery_date'] : '' ?>">
<input type="date" class="form-control job_card_basic_details" name="delivery_date" placeholder="Delivery Date" value="<?= isset($jobs['delivery_date']) ? $jobs['delivery_date'] : '' ?>">
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Note<span class="text-danger"></span></label>
<input type="text" class="form-control" name="note" placeholder="Note"value="<?= isset($jobs['note']) ? $jobs['note'] : '' ?>" >
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Status<span class="text-danger">*</span>(<?php echo isset($jobs['status']) ? $jobs['status'] : '' ?>)</label>
<select class="form-control status-select" name="status" required data-toggle="select2">
@ -126,11 +124,10 @@
<?php endif; ?>
</select>
</div>
<?php if(isset($workers) && $jobs['status'] == 'Created') { ?>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Assign To</label>
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" required multiple>
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" multiple>
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Make</option>' ?>
<?php foreach ($workers as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
@ -142,6 +139,13 @@
</select>
</div>
<?php } ?>
<div class="form-group col-md-6">
<label for="inputPassword4" class="col-form-label">Note<span class="text-danger"></span></label>
<input type="text" class="form-control job_card_basic_details" name="note" placeholder="Note"value="<?= isset($jobs['note']) ? $jobs['note'] : '' ?>" >
</div>
</div>
<div class="form-row">
</div>
<div class="form-row" id="itemTableContainer">
<div class="form-group col-md-12">
@ -173,13 +177,16 @@
<div class="form-group text-right m-b-0">
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
<a class="btn" id="addService">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Service</h4>
<h4><i class="fa fa-plus" aria-hidden="true"></i>Service</h4>
</a>
<a class="btn" id="addcomplaint">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Complaint</h4>
<h4><i class="fa fa-plus" aria-hidden="true"></i>Complaint</h4>
</a>
<a class="btn" id="addCustomComplaint">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Custom Complaint</h4>
<h4><i class="fa fa-plus" aria-hidden="true"></i>Custom Complaint</h4>
</a>
<a class="btn" id="addOutsource">
<h4><i class="fa fa-plus" aria-hidden="true"></i>Outsource</h4>
</a>
</div>
<?php } ?>
@ -336,11 +343,12 @@
<script>
/** ACTION */
var logged_user = <?php echo isset($logged_user_role) ? json_encode($logged_user_role) : '' ?>;
/***** APPEND DATA ONLY EDIT ******/
/***** APPEND DATA ONLY EDIT ( ONLY EDIT ACTION ) ******/
$(document).ready(async function() {
/** SERVICE */
var edit_service_data = <?php echo isset($editservicedata) ? json_encode($editservicedata) : 0 ?>;
if(edit_service_data.length > 0) {
var rework = <?php echo !isset($rework) ? 1 : 0 ?>;
if(edit_service_data.length > 0 && rework) {
for (const value of edit_service_data) {
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
// console.log(servicearray);
@ -384,7 +392,7 @@ $(document).ready(async function() {
/** COMPLAINT */
var edit_complaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editcomplaintdata) : 0 ?>;
if(edit_complaint_data.length > 0) {
if(edit_complaint_data.length > 0 && rework) {
for (const value of edit_complaint_data) {
complaint = <?php echo json_encode($complaint) ?>;
// console.log(productarray);
@ -432,6 +440,56 @@ $(document).ready(async function() {
}
}
/** OUTSOURCING */
var edit_os_data = <?php echo isset($editosdata) ? json_encode($editosdata) : 0 ?>;
if(edit_os_data.length > 0 && rework) {
for (const value of edit_os_data) {
os_data = <?php echo json_encode($os_data) ?>;
// console.log(productarray);
var newRow = '<tr class="os_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost" value="'+value.labour_cost+'"></td><td><select class="form-control book-select SelExample os" id="os_detail" name="os_details[]" required data-toggle="select2" style="width: 249px !important;">';
for (var i = 0; i < os_data.length; i++)
{
var os = os_data[i];
if(value.os_id == os.id)
newRow += '<option value="' + os.id + '" ' + (value.os_id == os.id ? "selected" : "") + '>' + os.name + '</option>';
}
newRow += '</select></td>' +
'<td><input hidden type="text" class="form-control rate-d-only" value="'+value.amount+'" readonly /></td>' +
'<td hidden><input hidden type="text" class="form-control item-rate1" value="'+value.amount+'" name="unit-price[]" readonly /></td>' +
'<td><input hidden type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>';
<?php if(isset($logged_user_role) && ( $logged_user_role == "Store Manager" ) ) { ?>
newRow += '<td><input hidden type="number" class="form-control"/></td>';
<?php } ?>
newRow += '<td><input hidden type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" readonly /></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" value="'+value.amount+'" name="amount[]"/></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="os_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>';
<?php if(!isset($rework)) { ?>
newRow += '<td hidden><input name="id" value="'+value.job_card_os_id+'"></td></tr>';
<?php } else { ?>
newRow += '<td hidden><input name="id" value=""></td></tr>';
<?php } ?>
$('#productItemTable tbody').append(newRow);
// initializeSelect2();
/** APPEND CHILD PRODUCT */
await edit_product_data(value.product);
editlabourcost(value,'os_lb')
}
}
/** CUSTOM COMPLAINT */
var edit_ccomplaint_data = <?php echo isset($editccomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>;
if(edit_ccomplaint_data.length > 0) {
@ -471,19 +529,21 @@ $(document).ready(async function() {
}
function editlabourcost(data,cls) {
console.log(data.labour_cost,'data.labour_cost');
<?php if(isset($rework)) { ?> data.labour_cost = 0; <?php } ?>
total_wih_tax = parseInt(data.labour_cost) + (parseInt(data.labour_cost) * (data.tax / 100));
total_tax_amt = total_wih_tax - parseInt(data.labour_cost);
total_wih_tax = Number(data.labour_cost) + (Number(data.labour_cost) * (data.tax / 100));
total_tax_amt = Number(data.labour_cost) * (data.tax / 100);
var newRow = '<tr class="'+cls+'"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fas fa-user-alt" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" readonly value="Labour Cost"></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+data.labour_cost+'" readonly /></td>' +
'<td hidden><input hidden type="text" class="form-control item-rate" name="unit-price[]" value="'+data.labour_cost +'" /></td>' +
'<td><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="1" readonly /></td>';
<?php if(isset($logged_user_role) && ( $logged_user_role == "Store Manager" ) ) { ?>
newRow += '<td><input type="text" readonly value="NIL" type="number" class="form-control"/></td>';
<?php } ?>
<?php } ?>
newRow += '<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+data.tax+'" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+Math.round(total_tax_amt)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Math.round(total_wih_tax) + '" /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt.toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + total_wih_tax.toFixed(2) + '" /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
@ -497,9 +557,9 @@ $(document).ready(async function() {
for (const product of products) {
<?php if(isset($rework)) { ?> product.amount = 0; <?php } ?>
total_wih_tax =( parseInt(product.amount) + (parseInt(product.amount) * (product.tax / 100)) )* product.qty;
console.log(product.pname,product.qty_stock,'qty_stock');
total_tax_amt = total_wih_tax - ( parseInt(product.amount) * product.qty);
total_wih_tax =( Number(product.amount) + (Number(product.amount) * (product.tax / 100)) )* product.qty;
total_tax_amt = Number(product.amount) * (product.tax / 100);
var action;
if(logged_user == 'Store Manager')
{
@ -515,15 +575,15 @@ $(document).ready(async function() {
newRow += '<option value="' + product.product_id + '" selected>' + product.pname + '</option>';
newRow += '</select></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+Math.round(product.amount)+'" readonly /></td>' +
'<td hidden><input hidden type="text" class="form-control item-rate" name="unit-price[]" value="' + Math.round(product.amount * product.qty) + '" readonly /></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+product.amount+'" readonly /></td>' +
'<td hidden><input hidden type="text" class="form-control item-rate" name="unit-price[]" value="' + product.amount * product.qty + '" readonly /></td>' +
'<td><input type="number" class="form-control item-quantity" min="0" max="'+Number(product.qty_stock)+'" value="' + product.qty + '" name="quantity[]"/></td>';
<?php if(isset($logged_user_role) && ( $logged_user_role == "Store Manager" ) ) { ?>
newRow += '<td><input type="number" class="form-control issued-qty" min="'+product.issued_qty+'" max="'+product.qty+'" value="'+product.issued_qty+'" name="issued-qty" /></td>';
<?php } ?>
newRow += '<td> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + Math.round(product.tax) + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+Math.round(total_tax_amt)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax) + '" readonly/></center></td>' +
newRow += '<td> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + product.tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt.toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount[]" value="' + total_wih_tax.toFixed(2) + '" readonly/></center></td>' +
'<td>'+
action+
'<input value="product" name="item_type" hidden>'+
@ -542,6 +602,17 @@ $(document).ready(async function() {
}
});
/********************************************************************** */
$(document).ready(function() {
if(logged_user == 'Store Manager') {
$('.job_card_basic_details').attr('disabled', 'true');
$('.fa-trash').addClass('disabled');
$('#addVehicleModalButton').addClass('disabled');
$('.item-quantity').attr('readonly', 'true');
$('.item-amount').attr('readonly', 'true');
$('#dt_amount').attr('readonly', 'true');
}
});
$(window).on('load', function() {
// This code will execute after the page has been reloaded
@ -560,7 +631,7 @@ $(window).on('load', function() {
$('input[name="client_id"]').val(selectedClient.client_name);
$('input[name="billing_address"]').val(selectedClient.address);
$('input[name="billing_address"]').val(selectedClient.address);
// $('input[name="billing_address"]').val(selectedClient.address);
$('input[name="city"]').val(selectedClient.city);
$('input[name="state"]').val(selectedClient.state);
$('input[name="country"]').val(selectedClient.country);
@ -665,12 +736,11 @@ $(window).on('load', function() {
$('form').submit(function() {
return validateProductAdded();
});
$(document).on('keyup change', '.item-amount', function() {
amount = $(this).val();
tax = $(this).closest('tr').find('.item-tax').val();
actual_amount = Number(amount) / (1 + (Number(tax)/100));
actual_amount = Math.round(actual_amount)
className = $(this).closest('tr').attr('class');
if(className == 'service_lb') {
previousRow = $(this).closest('tr').prevAll(".service_class").first();
@ -686,7 +756,7 @@ $(window).on('load', function() {
tax_amount = amount - actual_amount;
tax_rate = $(this).closest('tr').find('.total-tax-amount');
tax_rate.val(Math.round(tax_amount));
tax_rate.val(tax_amount);
display_rate = $(this).closest('tr').find('.rate-d-only');
display_rate.val(actual_amount);
@ -705,7 +775,7 @@ $(window).on('load', function() {
tax_amount = amount - actual_amount;
tax_rate = $(this).closest('tr').find('.total-tax-amount');
tax_rate.val(Math.round(tax_amount));
tax_rate.val(tax_amount);
display_rate = $(this).closest('tr').find('.rate-d-only');
display_rate.val(actual_amount);
@ -713,20 +783,20 @@ $(window).on('load', function() {
else if(className == 'custom_complaint_lb') {
previousRow = $(this).closest('tr').prevAll(".custom_complaint_class").first();
labour_rate = previousRow.find('.labour_cost');
labour_rate.val(actual_amount);
labour_rate.val(actual_amount.toFixed(2));
item_rate = previousRow.find('.item-rate1');
item_rate.val(actual_amount);
item_rate.val(actual_amount.toFixed(2));
item_rate = $(this).closest('tr').find('.item-rate');
item_rate.val(actual_amount);
item_rate.val(actual_amount.toFixed(2));
tax_amount = amount - actual_amount;
tax_amount = Number(actual_amount) * (tax / 100);
tax_rate = $(this).closest('tr').find('.total-tax-amount');
tax_rate.val(Math.round(tax_amount));
tax_rate.val(tax_amount.toFixed(2));
display_rate = $(this).closest('tr').find('.rate-d-only');
display_rate.val(actual_amount);
display_rate.val(actual_amount.toFixed(2));
}
// Calculate amount and update amount input field
updateCalculations();
@ -749,16 +819,11 @@ $(window).on('load', function() {
}
var tableData;
// var initial = 0;
// Update item amounts on change of discount
$('#applyDiscountBtn').on('click', function() {
if($('#dt_amount').val() != '' && $('#dt_amount').val() > 0 && $('#grandtotal').val() > 0) {
// if(initial == 0) {
tableData = $('#productItemTable tbody').html();
console.log(tableData);
// initial++;
// }
tableData = $('#productItemTable tbody').html();
var discount = parseFloat($('#dt_amount').val());
@ -787,7 +852,7 @@ $(window).on('load', function() {
amount = $(this).val();
tax = $(this).closest('tr').find('.item-tax').val();
actual_amount = Number(amount) / (1 + (Number(tax)/100));
actual_amount = Math.round(actual_amount)
actual_amount = actual_amount;
className = $(this).closest('tr').attr('class');
if(className == 'service_lb') {
previousRow = $(this).closest('tr').prevAll(".service_class").first();
@ -802,8 +867,9 @@ $(window).on('load', function() {
item_rate.val(actual_amount);
tax_amount = amount - actual_amount;
console.log(tax_amount,'tax_amount');
tax_rate = $(this).closest('tr').find('.total-tax-amount');
tax_rate.val(Math.round(tax_amount));
tax_rate.val(tax_amount);
display_rate = $(this).closest('tr').find('.rate-d-only');
display_rate.val(actual_amount);
@ -822,7 +888,7 @@ $(window).on('load', function() {
tax_amount = amount - actual_amount;
tax_rate = $(this).closest('tr').find('.total-tax-amount');
tax_rate.val(Math.round(tax_amount));
tax_rate.val(tax_amount);
display_rate = $(this).closest('tr').find('.rate-d-only');
display_rate.val(actual_amount);
@ -840,7 +906,7 @@ $(window).on('load', function() {
tax_amount = amount - actual_amount;
tax_rate = $(this).closest('tr').find('.total-tax-amount');
tax_rate.val(Math.round(tax_amount));
tax_rate.val(tax_amount);
display_rate = $(this).closest('tr').find('.rate-d-only');
display_rate.val(actual_amount);
@ -855,7 +921,7 @@ $(window).on('load', function() {
var mapTable;
function data_contruction_for_save() {
var dataMapArray = [{ 'service': [], 'complaint': [], 'custom_complaint': [] }];
var dataMapArray = [{ 'service': [], 'complaint': [], 'custom_complaint': [], 'os': [] }];
// Select all <tr> elements within the tbody of the table with id productItemTable
var tableRows = document.querySelectorAll("#productItemTable tbody tr");
@ -902,6 +968,9 @@ $(window).on('load', function() {
else if(mapTable == "custom-comp") {
addProductToLastObjectByKey(dataMapArray, "custom_complaint", [{ 'id': id, 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
}
else if(mapTable == "os") {
addProductToLastObjectByKey(dataMapArray, "os", [{ 'id': id, 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
}
}
else if(className.includes("service"))
{
@ -918,6 +987,11 @@ $(window).on('load', function() {
mapTable = "custom-comp";
dataMapArray[0].custom_complaint.push({ 'id': id, 'labour_cost': labour_cost, 'complaint_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
}
else if(className.includes("os"))
{
mapTable = "os";
dataMapArray[0].os.push({ 'id': id, 'labour_cost': labour_cost, 'os_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
}
}
});
console.log(dataMapArray,'dataMapArray');
@ -994,7 +1068,7 @@ $(window).on('load', function() {
});
// Event listener for product selection
$(document).on('change', 'select[name="service_details[]"]', async function() {
$(document).on('change', 'select[name="service_details[]"]', async function() {
onchange_remove_subproduct($(this).closest('tr'));
@ -1009,12 +1083,12 @@ $(window).on('load', function() {
return item.service_id == productId;
});
// Access unit price from product and set it as rate
var unitPrice = parseInt(service_data.price); // Convert to float if necessary
var unitPrice = Number(service_data.labour_cost); // Convert to float if necessary
console.log(service_data);
$(this).closest('tr').find('.rate-d-only').val(unitPrice);
$(this).closest('tr').find('.item-rate1').val(unitPrice);
$(this).closest('tr').find('.item-tax').val(Number(service_data.tax));
$(this).closest('tr').find('.labour_cost').val(parseInt(service_data.labour_cost));
$(this).closest('tr').find('.labour_cost').val(unitPrice);
await labourcost(service_data.labour_cost,service_data.tax,$(this).closest('tr'),'service_lb');
service_child_products(service_data,$(this).closest('tr'))
}
@ -1028,7 +1102,7 @@ $(window).on('load', function() {
{
var $closestTR = tr;
while ($closestTR.next().length > 0 && $closestTR.attr('class') != "product") {
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class')) {
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class' || $closestTR.next().hasClass('os_class') )) {
break;
}
// Remove the next row
@ -1052,7 +1126,7 @@ $(window).on('load', function() {
});
// Access unit price from product and set it as rate
var unitPrice = parseInt(complaint_data.labour_charge); // Convert to float if necessary
var unitPrice = Number(complaint_data.labour_charge); // Convert to float if necessary
$(this).closest('tr').find('.rate-d-only').val(unitPrice);
$(this).closest('tr').find('.item-rate1').val(unitPrice);
$(this).closest('tr').find('.item-tax').val(Number(complaint_data.tax));
@ -1064,6 +1138,36 @@ $(window).on('load', function() {
updateCalculations();
});
// Event listener for product selection
$(document).on('change', 'select[name="os_details[]"]', async function() {
onchange_remove_subproduct($(this).closest('tr'));
// Get class name of the select element
var className = $(this).attr('class');
var productId = $(this).val();
var quantity = $(this).closest('tr').find('.item-quantity').val(1);
if(className.includes("os")) {
var os = <?php echo json_encode($os_data) ?>;
// Find product details from JSON
var os_data = os.find(function(item) {
return item.id == productId;
});
// Access unit price from product and set it as rate
var unitPrice = Number(os_data.labour_cost); // Convert to float if necessary
$(this).closest('tr').find('.rate-d-only').val(unitPrice);
$(this).closest('tr').find('.item-rate1').val(unitPrice);
$(this).closest('tr').find('.item-tax').val(Number(os_data.tax));
$(this).closest('tr').find('.labour_cost').val(Number(os_data.labour_cost));
await labourcost(os_data.labour_cost,os_data.tax,$(this).closest('tr'),'os_lb');
}
calculateAmount($(this).closest('tr'),'os','parent');
updateCalculations();
});
// Function to calculate amount based on rate and quantity
function calculateAmount(row,type,action) {
console.log(type);
@ -1082,14 +1186,14 @@ $(window).on('load', function() {
// Calculate total tax by adding CGST and SGST
var tax = cgst + sgst;
$(row).find('.item-tax').val(tax.toFixed(2));
$(row).find('.item-tax').val(tax.toFixed(0));
finrate = Number(product.unit_price) * quantity;
$(row).find('.item-rate').val(finrate);
rate = Number(product.unit_price);
var amount = (parseInt(rate) + (parseInt(rate) * tax / 100)) * quantity;
var amount = (rate + (rate * tax / 100)) * quantity;
total_tax_amt = amount - finrate;
$(row).find('.total-tax-amount').val(total_tax_amt);
$(row).find('.item-amount').val(amount);
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
$(row).find('.item-amount').val(amount.toFixed(2));
}
else if(type.includes("service")) {
if(action == 'parent') var $previousRow = row;
@ -1097,53 +1201,72 @@ $(window).on('load', function() {
var tax = $previousRow.find('.item-tax').val();
$(row).find('.item-tax').val(parseInt(tax).toFixed(2));
var $targetField = $previousRow.find('.item-rate1');
finrate = parseInt($targetField.val()) * quantity;
finrate = Number($targetField.val()) * quantity;
rate = $targetField.val();
$(row).find('.item-rate').val(finrate);
var amount = (parseInt(rate) + (parseInt(rate) * tax / 100)) *quantity;
var amount = (Number(rate) + (Number(rate) * tax / 100)) *quantity;
total_tax_amt = amount - finrate;
$(row).find('.total-tax-amount').val(total_tax_amt);
$(row).find('.item-amount').val(amount);
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
$(row).find('.item-amount').val(amount.toFixed(2));
}
else if(type.includes("complaint")) {
if(action == 'parent') var $previousRow = row;
else var $previousRow = row.prevAll(".complaint_class").first();
var tax = $previousRow.find('.item-tax').val();
$(row).find('.item-tax').val(parseInt(tax).toFixed(2));
$(row).find('.item-tax').val(Number(tax).toFixed(2));
var $targetField = $previousRow.find('.item-rate1');
finrate = parseInt($targetField.val()) * quantity;
finrate = Number($targetField.val()) * quantity;
$(row).find('.item-rate').val(finrate);
rate = $targetField.val();
var amount = (parseInt(rate) + (parseInt(rate) * tax / 100)) *quantity;
var amount = (Number(rate) + (Number(rate) * tax / 100)) *quantity;
total_tax_amt = amount - finrate;
$(row).find('.total-tax-amount').val(total_tax_amt);
$(row).find('.item-amount').val(amount);
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
$(row).find('.item-amount').val(amount.toFixed(2));
}
else if(type.includes("os")) {
if(action == 'parent') var $previousRow = row;
else var $previousRow = row.prevAll(".os_class").first();
var tax = $previousRow.find('.item-tax').val();
$(row).find('.item-tax').val(Number(tax).toFixed(2));
var $targetField = $previousRow.find('.item-rate1');
finrate = Number($targetField.val()) * quantity;
$(row).find('.item-rate').val(finrate);
rate = $targetField.val();
var amount = (Number(rate) + (Number(rate) * tax / 100)) *quantity;
total_tax_amt = amount - finrate;
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
$(row).find('.item-amount').val(amount.toFixed(2));
}
}
const labourcost = async (cost,tax,tr,cls) => {
total_wih_tax = parseInt(cost) + (parseInt(cost) * (tax / 100));
total_tax_amt = total_wih_tax - parseInt(cost);
console.log(cost,tax,tr,cls);
console.log('cost,tax,tr,cls');
total_wih_tax = Number(cost) + (Number(cost) * (tax / 100));
total_tax_amt = Number(cost) * (tax / 100);
var newRow = '<tr class="'+cls+'"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fas fa-user-alt" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" readonly value="Labour Cost"></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+cost+'" readonly /></td>' +
'<td hidden><input type="text" class="form-control item-rate" name="unit-price[]" value="'+cost+'" /></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+Number(cost)+'" readonly /></td>' +
'<td hidden><input type="text" class="form-control item-rate" name="unit-price[]" value="'+Number(cost)+'" /></td>' +
'<td><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="'+1+'" /></td>' +
'<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+tax+'" /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + total_wih_tax + '"/></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+Number(total_tax_amt).toFixed(2)+'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Number(total_wih_tax).toFixed(2) + '"/></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
$(newRow).insertAfter(tr);
// initializeSelect2();
$(newRow).insertAfter(tr);
// initializeSelect2();
}
const service_child_products = async (data,tr) => {
@ -1156,19 +1279,19 @@ $(window).on('load', function() {
var cgst = parseFloat(product.cgst);
var sgst = parseFloat(product.sgst);
// Calculate total tax by adding CGST and SGST
// Calculate total tax by adding CGST and SGST
var tax = cgst + sgst;
total_wih_tax = parseInt(product.unit_price) + (parseInt(product.unit_price) * (tax / 100));
total_tax_amt = total_wih_tax - parseInt(product.unit_price);
total_wih_tax = ( Number(product.unit_price) ) + ( Number(product.unit_price) * (tax / 100) );
total_tax_amt = Number(product.unit_price) * (tax / 100);
var newRow = '<tr class="product"><td hidden><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-wrench" style="font-size: 13px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">';
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>';
newRow += '</select></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+ Math.round(product.unit_price) +'" readonly /></td>' +
'<td><input type="text" class="form-control rate-d-only" value="'+ Number(product.unit_price).toFixed(2) +'" readonly /></td>' +
'<td hidden><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.unit_price + '" readonly /></td>' +
'<td><input type="number" class="form-control item-quantity" min="0" max="'+Number(product.qty_stock)+'" value="1" name="quantity[]"/></td>' +
'<td> <input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+ Math.round(total_tax_amt) +'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount1[]" value="' + Math.round(total_wih_tax) + '" readonly/></td>' +
'<td><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
'<td><input type="text" class="form-control total-tax-amount" value="'+ total_tax_amt.toFixed(2) +'" readonly /></td>' +
'<td><input type="text" class="form-control item-amount" name="amount1[]" value="' + total_wih_tax.toFixed(2) + '" readonly/></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="product" name="item_type" hidden></td>' +
'<td hidden><input type="hidden" name="id" value=""></td>' +
'</tr>';
@ -1254,7 +1377,10 @@ $(window).on('load', function() {
$('.lab_amt').each(function() {
maxValue += parseFloat($(this).val()) || 0;
});
$('#dt_amount').attr('max', maxValue);
<?php if(!isset($rework)) { ?>
$('#dt_amount').attr('max', maxValue);
<?php } ?>
if($('#discount_amt').val())
{
@ -1264,12 +1390,20 @@ $(window).on('load', function() {
$('#subtotal').val(sb_tot.toFixed(2));
$('#invoicetax').val(calculateTax().toFixed(2));
$('#grandtotal').val(tot.toFixed(2));
<?php if(isset($rework)) { ?>
$('#dt_amount').attr('readonly', true);
$('#dt_amount').val(tot.toFixed(2));
<?php } ?>
}
else
{
$('#subtotal').val(calculateSubtotal().toFixed(2));
$('#invoicetax').val(calculateTax().toFixed(2));
$('#grandtotal').val(calculateTotal().toFixed(2));
<?php if(isset($rework)) { ?>
$('#dt_amount').attr('readonly', true);
$('#dt_amount').val(calculateTotal().toFixed(2));
<?php } ?>
}
}
@ -1335,7 +1469,7 @@ $(window).on('load', function() {
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
}
console.log(servicearray);
var newRow = '<tr class="service_class"><td hidden> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Service</option>';
var newRow = '<tr class="service_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Service</option>';
for (var i = 0; i < servicearray.length; i++)
{
@ -1510,10 +1644,64 @@ $(window).on('load', function() {
labourCostInput.val(dummyValue);
});
$('#addOutsource').click(function() {
selected_os = [];
$('tr.os_class').each(function() {
var rowProductid = $(this).find('.complaint').val();
selected_os.push(rowProductid);
});
os = <?php echo json_encode($os_data) ?>;
var newRow = '<tr class="os_class"><td hidden> <input type="text" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample os" id="os_detail" name="os_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Outsource</option>';
for (var i = 0; i < os.length; i++)
{
var os_data = os[i];
if(!selected_os.includes(os_data.id))
{
newRow += '<option value="' + os_data.id + '">' + os_data.name + '</option>';
}
}
newRow += '</select></td>' +
'<td><input hidden type="text" class="form-control rate-d-only" readonly /></td>' +
'<td hidden><input type="text" class="form-control item-rate1" name="unit-price[]" readonly /></td>' +
'<td><input hidden type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td><input hidden type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td><input hidden type="text" class="form-control total-tax-amount" readonly /></td>' +
'<td><input hidden type="text" class="form-control item-amount1" name="amount[]"/></td>' +
'<td><div style="display: inline-block;">'+
'<center><i class="fa fa-trash remove-item"></i></center>'+
'</div>'+
'<div style="display: inline-block; margin-left: 10px;">'+
'<input value="product" name="item_type" hidden>'+
'<a class="complaint_detail" id="addProduct" title="Add Product">'+
'<i class="fa fa-plus" aria-hidden="true"></i>'+
'</a>'+
'</div>'+
'</td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#productItemTable tbody').append(newRow);
// initializeSelect2();
});
/** To achieve this functionality where entering a value in one input field automatically populates another input field
* ONLY APPLICABLE IN COMPLAINT ONLY
*/
$(document).ready(function() {
/** TAX FIELD */
$(document).on('input change', '.item-quantity-os_lb', async function() {
var enteredValue = $(this).val();
var $previousRow = $(this).closest("tr").prevAll(".os_class").first();
var $targetField = $previousRow.find('.item-quantity');
$targetField.val(enteredValue);
});
});
/**
* REMOVE ITEMS FROM THE TABLE
* **/
delete_items_id = [{ 'service': [], 'complaint': [], 'custom_complaint': [], 'product' : [] }];
delete_items_id = [{ 'service': [], 'complaint': [], 'custom_complaint': [], 'os': [], 'product' : [] }];
$(document).on('click', '.remove-item', function() {
var $closestTR = $(this).closest('tr');
@ -1535,6 +1723,12 @@ $(window).on('load', function() {
delete_items_id[0].custom_complaint.push(id);
console.log(delete_items_id);
}
else if($closestTR.attr('class') == "os_class")
{
id = $closestTR.find('input[name="id"]').val();
delete_items_id[0].os.push(id);
console.log(delete_items_id);
}
else if($closestTR.attr('class') == "product")
{
id = $closestTR.find('input[name="id"]').val();
@ -1543,7 +1737,7 @@ $(window).on('load', function() {
}
while ($closestTR.next().length > 0 && $closestTR.attr('class') != "product") {
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class')) {
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class') || $closestTR.next().hasClass('os_class')) {
break;
}
// Remove the next row

View File

@ -19,8 +19,11 @@
<h4 class="page-title">Job Card List</h4>
<?php if($admins) { ?>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class=""> <a href="<?= base_url() . "new_jobcard/0"; ?>" class="btn btn-primary waves-effect"> New Job Card</a></li>
<ol class="breadcrumb m-0">
<li class="">
<a href="<?= base_url() . "download_os"; ?>" class="btn btn-secondary waves-effect">Out Source</a>
<a href="<?= base_url() . "new_jobcard/0"; ?>" class="btn btn-primary waves-effect">New Job Card</a>
</li>
</ol>
</div>
<?php } ?>
@ -62,14 +65,22 @@
<td><?= $value['total']; ?></td>
<td><?= ($value['is_rework'] == 1) ? 'Rework/'.$value['status'] :$value['status']; ?></td>
<td>
<?php if($admins) { ?>
<a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="edit-button" title="Download"><i class="ri-file-download-line" style="font-size: 20px;"></i></a>&nbsp;
<?php } ?>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="<?= "new_jobcard/" . $value['job_card_id']; ?>" class="dropdown-item edit-button"><i class="ri-pencil-line mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="<?= "new_jobcard/" . $value['job_card_id']; ?>" class="edit-button" title="Edit"><i class="ri-pencil-line" style="font-size: 20px;"></i></a>&nbsp;
<?php if($value['is_rework'] == 0 && $admins) { ?>
<a href="<?= "new_jobcard/" . $value['job_card_id'] . "/re-work" ?>" class="edit-button" title="Re-work"><i class="ri-registered-fill" style="font-size: 20px;"></i></a>
<?php } ?>
<?php if($admins) { ?>
<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="<?= 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) { ?>
<a href="<?= "new_jobcard/" . $value['job_card_id'] . "/re-work" ?>" class="dropdown-item edit-button"><i class="ri-registered-fill mr-2 text-muted font-18 vertical-middle"></i>Rework</a>
<?php } ?>
</div>
</div>
</td>
<?php endif?>
<?php endforeach; ?>

View File

@ -256,14 +256,17 @@
<li>
<a href="<?php echo base_url('product_index') ?>">Products</a>
</li>
<li>
<a href="<?php echo base_url('service_index') ?>">Services</a>
</li>
</ul>
</div>
</li>
<?php } ?>
<?php if(session()->get('logged_user_role') == 'Floor Manager' ) { ?>
<li>
<a href="<?php echo base_url('service_index') ?>">
<i class="ri-e-bike-fill"></i>
<span>Services</span>
</a>
</li>
<li>
<a href="<?php echo base_url('index') ?>">
<i class="ri-message-2-line"></i>
@ -322,6 +325,13 @@
<span>Complaints Master</span>
</a>
</li>
<li>
<a href="<?php echo base_url('outsourcing_index') ?>">
<i class="ri-logout-circle-line"></i>
<span>Outsourcing Master</span>
</a>
</li>
<?php } ?>
</ul>

View File

@ -0,0 +1,232 @@
<?php include('layout/header.php'); ?>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Outsourcing List</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class=""> <a href="#" data-toggle="modal" data-target="#os-add-modal" class="btn btn-primary waves-effect" onclick="clearDetials(this)"> Add Outsourcing</a></li>
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<table id="datatable-buttons-2" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;">
<thead>
<tr>
<th>Out Sourcing</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th>
<th hidden>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($out_source as $value) : ?>
<tr>
<td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['cost_with_tax']; ?></td>
<td><?= $value['labour_cost']; ?></td>
<td hidden>
<?php if($value['is_active'] == 1): ?>
<span style="color:green">Active</span>
<?php else: ?>
<span style="color:red">Inactive</span>
<?php endif; ?>
</td>
<td>
<a data-toggle="modal" data-target="#os-add-modal" data-value="<?php echo $value['id']; ?>" onclick="editOS(this)" class="delete-button"><i class="ri-pencil-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= "delete_complaint/" . $value['id']; ?>" class="delete-button"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div> <!-- end card -->
</div> <!-- end col -->
</div>
<!-- /.modal -->
<div id="os-add-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4 id="form_add_edit">Add Outsourcing</h4>
</div>
<form id="model_form_data" class="px-3">
<div class="form-group">
<label for="name">Name </label>
<input class="form-control" type="text" id="id" hidden>
<input class="form-control" type="text" id="name" required="" placeholder="Name">
</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()">
<option value="0">Select Tax</option>
<option value="18">18%</option>
<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" 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>
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitComplaint(this)">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php include('layout/footer.php'); ?>
<script>
function ReverseCalculation() {
var tax = parseFloat($("#tax").val());
if(tax == ''){
toastr.warning('Please select Tax', 'Warning');
}else{
var labour_cost_with_tax = parseFloat($("#cost_with_tax").val());
var labour_cost = labour_cost_with_tax / parseFloat((tax / 100) + 1);
$("#labour_cost").val(labour_cost.toFixed(2));
}
}
function submitComplaint(params) {
if (!$('#name').val() || !$('#labour_cost').val()) {
return false;
}
var formData = {
id: $('#id').val(),
name: $('#name').val(),
labour_cost: $('#labour_cost').val(),
tax: $('#tax').val(),
cost_with_tax: $('#cost_with_tax').val(),
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_os"?>',
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
// Reload the page after successful submission
// window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function editOS(params) {
var id = $(params).data('value');
$.ajax({
type: 'GET',
url: '<?php echo base_url()."edit_os/"?>' + id,
dataType: 'json',
success: function(response) {
console.log(response.os_data[0].id);
$('#form_add_edit').html(response.page_name)
$('#id').val(response.os_data[0].id);
$('#name').val(response.os_data[0].name);
$('#labour_cost').val(response.os_data[0].labour_cost);
$('#cost_with_tax').val(response.os_data[0].cost_with_tax);
var tax = parseFloat(response.os_data[0].tax);
var selectElement = document.getElementById('tax');
var options = selectElement.options;
for (var i = 0; i < options.length; i++) {
if (parseInt(options[i].value) === tax) {
options[i].selected = true;
break;
}
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function clearDetials(params) {
$('#form_add_edit').text('Add Complaint');
}
</script>
<script>
$(document).ready(function() {
$('#datatable-buttons-2').DataTable({
"order": [[2, 'desc']], // Set initial sorting to descending on the first column
"dom": 'Bfrtip', // Show export buttons
"buttons": [ {
extend: 'pdfHtml5',
title: 'Complaint', // Set your custom PDF title here
text: 'PDF',
customize: function(doc) {
// You can further customize the PDF here if needed
// doc.content[1].table.body.forEach(function(row) {
// row.splice(0, 1); // Remove the first column (ID column)
// });
}
},
{
extend: 'print',
title: 'Complaint', // Set your custom print title here
text: 'Print',
customize: function(win) {
// You can further customize the print output here if needed
// $(win.document.body).find('table').find('th:first-child, td:first-child').remove();
}
},
{
extend: 'copy',
text: 'Copy', // Set the title for the Copy button
titleAttr: 'Copy', // Set the tooltip for the Copy button
exportOptions: {
// columns: ':not(:first-child)' // Exclude the first column (ID column)
}
},
{
extend: 'csv',
text: 'CSV', // Set the title for the CSV button
title: 'Complaint', // Set your custom print title here
exportOptions: {
// columns: ':not(:first-child)' // Exclude the first column (ID column)
}
}], // Enable export options
"language": {
"search": "Search: " // Customize search label
},
"ordering": false
});
});
</script>

View File

@ -0,0 +1,215 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
/* Add your CSS styles here to format the invoice for mPDF */
body {
font-family: 'Times New Roman', Times, sans-serif;
font-size: 12px; /* Change this value to your desired font size */
}
/* Style for the main table with border */
table.main-table {
width: 100%;
border-collapse: collapse;
border: -0.5px solid black; /* Add a border around the entire invoice */
}
table.main-table th,
table.main-table td {
border: none; /* Remove borders from all cells inside the main table */
}
/* Style for the table containing business details */
table.business-details-table {
width: 100%;
border-collapse: collapse;
}
table.business-details-table td {
padding: 8px;
text-align: left;
}
/* Style for the business logo and title */
.business-logo-container {
text-align: center;
}
img.business-logo {
max-width: 200px; /* Adjust the size of the logo */
}
/* Style for the business name */
.business-name {
font-size: 16px;
font-weight: bold;
margin-top: 10px;
}
/* Style for the table containing invoice info */
table.invoice-info-table {
width: 100%;
border-collapse: collapse;
}
table.invoice-info-table th,
table.invoice-info-table td {
border: 1px solid;
text-align: left;
}
/* Style for the addresses table */
table.addresses-table {
width: 100%;
}
table.addresses-table th {
text-align: left;
padding-left: 8px;
}
/* Style for the billing and shipping addresses */
.billing-address {
width: 50%;
padding-left: 8px;
}
/* Style for the invoice-related table */
table.invoice-related-table {
width: 100%;
border-collapse: collapse;
}
table.invoice-related-table th,
table.invoice-related-table td {
border: none; /* Remove borders from all cells in the invoice items table */
padding: 8px;
text-align: left; /* Center-align text in cells */
max-width: 2px;
}
table.invoice-related-table th {
background-color: #DAC2AD;
font-weight: bold;
}
/* --------------------------------- */
table.invoice-related-table1 {
/* width: 100%; */
border-collapse: collapse;
}
table.invoice-related-table1 th,
table.invoice-related-table1 td {
border: none;
padding: 8px;
text-align: left;
max-width: 2px;
}
table.invoice-related-table1 th {
background-color: #DAC2AD;
font-weight: bold;
}
/* Style for the business stamp and terms */
.business-stamp, .terms {
text-align: center;
margin-top: 20px;
}
.subtotal-table {
width: 100%;
margin-top: 20px;
}
.subtotal-table table {
width: 100%;
border-collapse: collapse;
border: 1px solid black; /* Add a border around the subtotal table */
}
.subtotal-table th,
.subtotal-table td {
border: none; /* Remove borders from cells inside the subtotal table */
padding: 8px;
text-align: right;
}
.subtotal-table th {
background-color: #f2f2f2;
font-weight: bold;
}
.subtotal-table td:last-child {
font-weight: bold; /* Make the last column (total values) bold */
}
td.invoice-number {
font-size: 18px; /* Increase font size to your desired value */
/* Highlight background color */
font-weight: bold; /* Make the text bold */
}
p {
margin-top: 0;
margin-bottom: 0rem;
}
</style>
</head>
<body>
<table><tr>
<td style="padding:20px;"><b>DATE: </b><?= date('d-m-Y') ?></td>
<td style="padding:20px;"><h3><b>OUT SOURCE</b></h3></td>
</tr></table>
<br>
<table class="list" style="width:100%; table-layout: fixed;">
<tr>
<td style="width: 100%; vertical-align: top;">
<table class="invoice-related-table1" style="width:100%;">
<tbody>
<!-- <tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="2"><center>TYPE OF SERVICES</center></th>
</tr> -->
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">Bike Detail</th>
<th style="border: 0.5px solid black;">Out Source List</th>
<th style="border: 0.5px solid black;">Product</th>
</tr>
<?php foreach ($outsource as $key => $item) : ?>
<tr>
<td style="border: 0.5px solid black;">
<?= $item['reg_no'] ?><br>
<?= $item['bike_name'] ?> - <?= $item['bike_modal_name'] ?><br>
<?= $item['colour'] ?> color<br>
</td>
<td style="border: 0.5px solid black;">
<?= $item['name'] ?><br>
</td>
<td style="border: 0.5px solid black;">
<?php foreach ($item['products'] as $key => $item) : ?>
(<?= $item['pname'] ?> x <?= $item['qty'] ?>)<br>
<?php endforeach; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</td>
</tr>
</table>
<br>
<br>
</body>
</html>

View File

@ -52,7 +52,7 @@
<th>Order Number</th>
<th>Vendor Name</th>
<th>Order Date</th>
<th>Contact Person Details</th>
<th>Contact Details</th>
<!-- <th>Contact Person Mobile</th> -->
<th>Items</th>
<th>Qty</th>
@ -89,13 +89,19 @@
<!-- Call the model method -->
<td>
<a href="<?= "new_purchase/" . $value['purchase_order_id']; ?>" class="edit-button" title="Edit"><i class="ri-pencil-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= "delete_purchase/" . $value['purchase_order_id']; ?>" class="delete-button" title="Delete"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php if($value['status'] != "PO Issued") { ?>
<a href="<?= "reorder_purchase/" . $value['purchase_order_id']; ?>" title="Pending Reorder"><i class="fa fa-retweet" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php } ?>
<a href="<?= "download_purchase_invoice/" . $value['purchase_order_id']; ?>" class="edit-button" title="Download"><i class="ri-download-2-fill" style="font-size: 20px;"></i></a>
</td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="<?= "new_purchase/" . $value['purchase_order_id']; ?>" class="edit-button dropdown-item"><i class="ri-pencil-line"></i>Edit</a>
<a href="<?= "delete_purchase/" . $value['purchase_order_id']; ?>" class="delete-button dropdown-item"><i class="ri-delete-bin-line"></i>Delete</a>
<?php if($value['status'] != "PO Issued") { ?>
<a href="<?= "reorder_purchase/" . $value['purchase_order_id']; ?>" class="dropdown-item"><i class="fa fa-retweet"></i>Pending Reorder</a>
<?php } ?>
<a href="<?= "download_purchase_invoice/" . $value['purchase_order_id']; ?>" class="edit-button dropdown-item"><i class="ri-download-2-fill"></i>Download</a>
</div>
</div>
</td>
<?php endif?>
<?php endforeach; ?>

View File

@ -93,9 +93,14 @@
</td>
<td>
<a href="<?= "new_sale/" . $value['sales_order_id']; ?>" class="edit-button" title="Edit"><i class="ri-pencil-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= "delete_sale/" . $value['sales_order_id']; ?>" class="delete-button" title="Delete"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= "download_invoice/" . $value['sales_order_id']; ?>" class="edit-button" title="Download"><i class="ri-download-2-fill" style="font-size: 20px;"></i></a>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="<?= "new_sale/" . $value['sales_order_id']; ?>" class="dropdown-item edit-button"><i class="ri-pencil-line mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="<?= "delete_sale/" . $value['sales_order_id']; ?>" class="dropdown-item delete-button"><i class="ri-delete-bin-line mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<a href="<?= "download_invoice/" . $value['sales_order_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download</a>
</div>
</div>
</td>

View File

@ -24,8 +24,7 @@
<tr>
<th>Service Name</th>
<th>Price</th>
<th>Cgst</th>
<th>Sgst</th>
<th>Tax</th>
<th>Description</th>
<th>Action</th>
</tr>
@ -36,8 +35,7 @@
<tr>
<td><?= $value['service_name']; ?></td>
<td><?= $value['price']; ?></td>
<td><?= $value['cgst']; ?></td>
<td><?= $value['sgst']; ?></td>
<td><?= $value['cgst'] + $value['sgst']; ?></td>
<td><?= $value['description']; ?></td>
<td>
<a href="<?= "new_service/" . $value['service_id']; ?>" class="edit-button">

View File

@ -51,8 +51,8 @@
<td><?= $value['mobile_no']; ?></td>
<td><?= $roleModel->getRoleNameById($value['role']); ?></td> <!-- Call the model method -->
<td>
<a href="<?= "new_user/" . $value['user_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
<a href="<?= "delete_user/" . $value['user_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
<a href="<?= "new_user/" . $value['user_id']; ?>" class="edit-button" style="font-size: 20px;"><i class="ri-pencil-line"></i></a>
<a href="<?= "delete_user/" . $value['user_id']; ?>" class="delete-button" style="font-size: 20px;"><i class="ri-delete-bin-line"></i></a>
</td>
<?php endif?>