table name changes : ps
This commit is contained in:
parent
d1fe31630c
commit
2b1526b886
@ -20,10 +20,10 @@ class Complaint extends BaseController
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
$ComplaintModel = new ComplaintModel();
|
||||
$complaint = $ComplaintModel->findAll();
|
||||
$cubiccentimeter = $ComplaintModel->getCubicCentimeterName();
|
||||
$cubiccapacity = $ComplaintModel->getCubicCapacityName();
|
||||
|
||||
$data['complaint']=$complaint;
|
||||
$data['cubiccentimeter']=$cubiccentimeter;
|
||||
$data['cubiccapacity']=$cubiccapacity;
|
||||
return view('complaint_list',$data);
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ class Complaint extends BaseController
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
try {
|
||||
$name = $this->request->getPost('name');
|
||||
$cubic_centimeter_id = $this->request->getPost('cubic_centimeter_id');
|
||||
// echo $cubic_centimeter_id; die;
|
||||
$cubic_capacity_id = $this->request->getPost('cubic_capacity_id');
|
||||
// echo $cubic_capacity_id; die;
|
||||
$ComplaintModel = new ComplaintModel();
|
||||
$conditions = ['name' => $name, 'isactive' => 1];
|
||||
|
||||
if ($cubic_centimeter_id) {
|
||||
$conditions['cubic_centimeter_id'] = $cubic_centimeter_id;
|
||||
if ($cubic_capacity_id) {
|
||||
$conditions['cubic_capacity_id'] = $cubic_capacity_id;
|
||||
}
|
||||
|
||||
if ($complaint_id > 0) {
|
||||
@ -59,7 +59,7 @@ class Complaint extends BaseController
|
||||
"cgst" => $this->request->getPost('tax')/2,
|
||||
"sgst" => $this->request->getPost('tax')/2,
|
||||
"tax" => $this->request->getPost('tax'),
|
||||
"cubic_centimeter_id" => $this->request->getPost('cubic_centimeter_id') ? $this->request->getPost('cubic_centimeter_id') : 0,
|
||||
"cubic_capacity_id" => $this->request->getPost('cubic_capacity_id') ? $this->request->getPost('cubic_capacity_id') : 0,
|
||||
];
|
||||
|
||||
if (!$complaint_id) {
|
||||
|
||||
@ -5,13 +5,13 @@ class ComplaintModel extends Model
|
||||
{
|
||||
protected $table = 'complaints';
|
||||
protected $primaryKey = 'complaint_id';
|
||||
protected $allowedFields = ['complaint_id','business_id','name','labour_charge','cgst','sgst','tax','labour_cost_with_tax','isactive','cubic_centimeter_id'];
|
||||
protected $allowedFields = ['complaint_id','business_id','name','labour_charge','cgst','sgst','tax','labour_cost_with_tax','isactive','cubic_capacity_id'];
|
||||
|
||||
public function getCubicCentimeterName()
|
||||
public function getCubiccapacityName()
|
||||
{
|
||||
return $this->db->table('cubic_centimeter')
|
||||
->select('cubic_centimeter.*')
|
||||
->where('cubic_centimeter.isactive', 1)
|
||||
return $this->db->table('cubic_capacity')
|
||||
->select('cubic_capacity.*')
|
||||
->where('cubic_capacity.isactive', 1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
@ -33,16 +33,16 @@
|
||||
if($value['isactive'] == 0){
|
||||
$color ='red';
|
||||
}
|
||||
$cubiccentimeter_name = ''; // Default to empty if no match
|
||||
// Loop through $cubiccentimeter to find a match
|
||||
foreach ($cubiccentimeter as $cc) {
|
||||
if ($cc['id'] == $value['cubic_centimeter_id']) {
|
||||
$cubiccentimeter_name = ' ( '.$cc['value'].' )'; // Get the name of the matching cubiccentimeter
|
||||
$cubiccapacity_name = ''; // Default to empty if no match
|
||||
// Loop through $cubiccapacity to find a match
|
||||
foreach ($cubiccapacity as $cc) {
|
||||
if ($cc['id'] == $value['cubic_capacity_id']) {
|
||||
$cubiccapacity_name = ' ( '.$cc['value'].' )'; // Get the name of the matching cubiccapacity
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr class="complaint_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" > <td><?= $value['name'].$cubiccentimeter_name;; ?></td>
|
||||
<tr class="complaint_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" > <td><?= $value['name'].$cubiccapacity_name;; ?></td>
|
||||
<td><?= $value['labour_cost_with_tax'] ?></td>
|
||||
<td><?= $value['tax']; ?></td>
|
||||
<td><?= $value['labour_charge']; ?></td>
|
||||
@ -91,10 +91,10 @@
|
||||
<input class="form-control" type="text" id="name" required="" placeholder="Complaint">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="cubic_centimeter">Cubic Centimeter</label>
|
||||
<select class="form-control" id="cubic_centimeter" name="cubic_centimeter" required data-toggle="select2">
|
||||
<option value="0">Select Cubic Centimeter</option>
|
||||
<?php foreach ($cubiccentimeter as $item): ?>
|
||||
<label for="cubic_capacity">Cubic capacity</label>
|
||||
<select class="form-control" id="cubic_capacity" name="cubic_capacity" required data-toggle="select2">
|
||||
<option value="0">Select Cubic capacity</option>
|
||||
<?php foreach ($cubiccapacity as $item): ?>
|
||||
<option value="<?= $item['id'] ?>"><?= $item['value'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@ -142,19 +142,19 @@
|
||||
}
|
||||
|
||||
function submitComplaint(params) {
|
||||
// console.log(':)',$('#cubic_centimeter_id').val());return false;
|
||||
// console.log(':)',$('#cubic_capacity_id').val());return false;
|
||||
if (!$('#name').val() || !$('#labour_charge').val()) {
|
||||
return false;
|
||||
}
|
||||
console.log($('#cubic_centimeter_id').val());
|
||||
console.log($('#cubic_capacity_id').val());
|
||||
var tax = parseFloat($("#tax").val());
|
||||
var labour_cost_with_tax = parseFloat($("#labour_cost_with_tax").val());
|
||||
if(labour_cost_with_tax == '' || tax == ''){
|
||||
toastr.warning('Please select Tax', 'Warning');
|
||||
return;
|
||||
}
|
||||
// if($(!'#cubic_centimeter').val()){
|
||||
// toastr.warning('Please select Cubic Centimeter', 'Warning');
|
||||
// if($(!'#cubic_capacity').val()){
|
||||
// toastr.warning('Please select Cubic capacity', 'Warning');
|
||||
// return;
|
||||
// }
|
||||
|
||||
@ -163,7 +163,7 @@
|
||||
labour_charge: $('#labour_charge').val(),
|
||||
tax: tax,
|
||||
labour_cost_with_tax: labour_cost_with_tax,
|
||||
cubic_centimeter_id: $('#cubic_centimeter').val(),
|
||||
cubic_capacity_id: $('#cubic_capacity').val(),
|
||||
};
|
||||
var complaint_id = $('#complaint_id').val();
|
||||
if (!complaint_id) {
|
||||
@ -216,7 +216,7 @@
|
||||
$('#name').val(response.complaint[0].name);
|
||||
$('#labour_charge').val(response.complaint[0].labour_charge);
|
||||
$('#labour_cost_with_tax').val(response.complaint[0].labour_cost_with_tax);
|
||||
var cc_id = response.complaint[0].cubic_centimeter_id;
|
||||
var cc_id = response.complaint[0].cubic_capacity_id;
|
||||
|
||||
var tax = parseFloat(response.complaint[0].cgst) + parseFloat(response.complaint[0].sgst);
|
||||
var selectElement = document.getElementById('tax');
|
||||
@ -227,7 +227,7 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
var selectElementForCC = document.getElementById('cubic_centimeter');
|
||||
var selectElementForCC = document.getElementById('cubic_capacity');
|
||||
var ccOptions = selectElementForCC.options;
|
||||
for (var j = 0; j < ccOptions.length; j++) {
|
||||
if (ccOptions[j].value === cc_id) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user