CHANGE_PRODUCT_ADD_NEW_ML : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-03 11:41:53 +05:30
parent cd3840cf0f
commit d0591ed77d
13 changed files with 563 additions and 699 deletions

View File

@ -53,6 +53,8 @@ class Jobcard extends BaseController
public function download_jobcard_invoice($job_card_id)
{
$data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id);
$bus_id = $this->session->get('logged_user_business_id');
$data['job_card'] = $this->JobcardModel->where('job_card_id',$job_card_id)->findAll();
@ -61,7 +63,6 @@ class Jobcard extends BaseController
// echo json_encode($data['job_card_products']);die;
// Create an mPDF object
$mpdf = new Mpdf([
'mode' => '',
@ -79,7 +80,8 @@ class Jobcard extends BaseController
$mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->autoScriptToLang = true;
// Set PDF properties
$mpdf->SetTitle('Invoice');
// $mpdf->SetAuthor($data[0]->branch_name);
@ -87,13 +89,14 @@ class Jobcard extends BaseController
// Generate the PDF content (HTML) with data
$html = view('invoice_pdf_template', $data);
echo $html;die;
$html = view('invoice_pdf_template_jobcard', $data);
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);
// Output the PDF to the browser for download
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
}

View File

@ -138,6 +138,13 @@ class Products extends BaseController
$tax= $this->request->getPost('tax')/2;
// print_r($this->request->getPost());die;
if ($this->request->getPost('per') != 'ml') {
$ml = 0;
}else{
$ml = $this->request->getPost('ml');
}
$data = [
'product_name' => $this->request->getPost('productname'),
'product_category' => $this->request->getPost('productcategory'),
@ -166,7 +173,8 @@ class Products extends BaseController
'branch_id' => $this->session->get('logged_user_branch_id'),
'total_amount' => $this->session->get('total_amount'),
'per' => $this->session->get('per')
'per' => $this->request->getPost('per'),
'ml' => $ml
];
$product_id = $this->request->getPost('product_id');

View File

@ -299,27 +299,20 @@ public function delete_sales_product()
$BikemodelsModel = new BikemodelsModel();
$BikemakeModel = new BikemakeModel();
$data = $model->getSalesPdf($sales_order_id);
$bus_id = $this->session->get('logged_user_business_id');
$company_address = $BusinessModel->where('business_id', $bus_id)->where('isactive', 1)->findAll();
$branch = $BranchModel->where('branch_id', $data[0]->branch_id)->first();
$business = $BusinessModel->where('business_id', $branch['business_id'])->first();
$vehicle = $VehicleModel->where('vehicle_id',$data[0]->vehicle_id)->first();
$bike_model = $BikemodelsModel->where('model_id',$vehicle['model'])->first();
$bike_make = $BikemakeModel->where('make_id', $vehicle['make'])->first();
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
$mpdf = new Mpdf([
'mode' => '',
'format' => 'A5',
'default_font_size' => 0,
'default_font' => '',
'default_font' => '',
// 'margin_right' => 1,
'margin_top' => 6,
'margin_bottom' => 6,
@ -328,16 +321,12 @@ public function delete_sales_product()
'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)
if ($data[0]->status === 'Draft') {
// Set the watermark text and options
@ -357,7 +346,7 @@ public function delete_sales_product()
// return view('invoice_pdf_template', ['sales' => $data,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
// Generate the PDF content (HTML) with data
$html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
$html = view('invoice_pdf_template', ['sales' => $data,'company_address'=>$company_address,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);

View File

@ -9,7 +9,7 @@ class ProductModel extends Model
'quality','product_name','branch_id','prefered_vendor','product_category','mfr_part_no','purchase_order_level',
'unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level',
'handler','qty_in_demand','product_image','description','specification','hsn_sac','isactive','total_amount',
'per'];
'per','ml'];
public function getTax()

View File

@ -123,13 +123,19 @@
if ($purchasechild['isactive'] == 1) : ?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;" readonly>
<option value="">Select a Product</option>
<?php foreach ($product as $value) : ?>
<?php if ($value['per'] == 'ml') {
$value_ml = ' ('.$value['ml'].$value['per'].')';
} else {
$value_ml = '';
}
?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"]; ?>
<?= $value["product_name"].$value_ml; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>

View File

@ -4,176 +4,40 @@
<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%;
}
table.invoice-info-table th,
table.invoice-info-table td {
text-align: right;
}
/* 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;
padding: 8px;
text-align: left;
}
table.invoice-related-table 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;
}
.invoice-info-table {
border-collapse: collapse;
}
.invoice-info-table td {
border: 1px solid black;
width: 100px;
}
.invoice-info-table tr:first-child td {
border-top: none;
}
.invoice-info-table tr:last-child td {
border-bottom: none;
}
.invoice-info-table tr td:first-child {
border-left: none;
}
.invoice-info-table tr td:last-child {
border-right: none;
}
.term_condition {
border-collapse: collapse;
width: 100%;
}
.term_condition td {
border: 0.5px solid black;
padding: 8px;
text-align: center;
}
body {font-family: 'Times New Roman', Times, sans-serif;font-size: 12px;}
table.main-table {width: 100%;border-collapse: collapse;border: -0.5px solid black;}
table.main-table th,table.main-table td {border: none;}
table.business-details-table {width: 100%;border-collapse: collapse;}
table.business-details-table td {padding: 8px;text-align: left;}
.business-logo-container {text-align: center;}
img.business-logo {max-width: 200px;}
.business-name {font-size: 16px;font-weight: bold;margin-top: 10px;}
table.invoice-info-table {width: 100%;}
table.invoice-info-table th,table.invoice-info-table td {text-align: right;}
table.addresses-table {width: 100%;}
table.addresses-table th {text-align: left;padding-left: 8px;}
.billing-address {width: 50%;padding-left: 8px;}
table.invoice-related-table {width: 100%;border-collapse: collapse;}
table.invoice-related-table th,table.invoice-related-table td {border: none;padding: 8px;text-align: left;}
table.invoice-related-table th {background-color: #DAC2AD;font-weight: bold;}
table.invoice-related-table thead tr th{border: 0.5px solid black;"}
table.invoice-related-table thead tr{border: 0.5px solid black;"}
.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;}
.subtotal-table th,.subtotal-table td {border: none;padding: 8px;text-align: right;}
.subtotal-table th {background-color: #f2f2f2;font-weight: bold;}
.subtotal-table td:last-child {font-weight: bold; }
td.invoice-number {font-size: 18px;font-weight: bold; /* Make the text bold */}
p {margin-top: 0;margin-bottom: 0rem;}
.invoice-info-table {border-collapse: collapse;}
.invoice-info-table td {border: 1px solid black;width: 100px;}
.invoice-info-table tr:first-child td {border-top: none;}
.invoice-info-table tr:last-child td {border-bottom: none;}
.invoice-info-table tr td:first-child {border-left: none;}
.invoice-info-table tr td:last-child {border-right: none;}
.term_condition {border-collapse: collapse;width: 100%;}
.term_condition td {border: 0.5px solid black;padding: 8px;text-align: center;}
</style>
</head>
<body>
@ -181,9 +45,8 @@
<table class="main-table">
<tr>
<td>
<table class="business-details-table">
<?php foreach ($company_address as $value) : ?>
<table class="business-details-table"><?php foreach ($company_address as $value) : ?>
<tr>
<td style="max-width: 50px;">
<p><b>THE MECHANIC</b><br>
<?= $value['address'] ?>,<br>
@ -198,69 +61,56 @@
<?= '<b>State Name: </b>'.$job_card[0]['billing_state'] ?><br>
<?= '<b>Place of Supply: </b>'.$value['state'] ?></p>
</td>
</tr>
<?php endforeach; ?>
</tr><?php endforeach; ?>
<tr>
<td><span>GSTIN: <?php echo $business['gstno']?> </span><br>
<span>State Name: <?php echo $business['state']?> , Code: <?php echo $business['code']?> </span><br>
<span>Contact : <?php echo $business['mobile']?></span><br>
<span>Email : <?php echo $business['email']?></span><br><br>
<span style="font-size: 15px;font-weight: bold;">Buyer (Bill To) </span>
<td>
<span>GSTIN: <?php echo $business['gstno']?> </span><br>
<span>State Name: <?php echo $business['state']?> , Code: <?php echo $business['code']?> </span><br>
<span>Contact : <?php echo $business['mobile']?></span><br>
<span>Email : <?php echo $business['email']?></span><br><br>
<span style="font-size: 15px;font-weight: bold;">Buyer (Bill To) </span>
</td>
</tr>
</table>
</td>
<td>
<table class="invoice-info-table" >
<tbody >
<tr>
<td>Invoice No.</td>
<td>1</td>
<td>Invoice No.</td><td>1</td>
</tr>
<tr>
<td>Dated</td>
<td>2</td>
<td>Dated</td><td>2</td>
</tr>
<tr>
<td>Bike Name</td>
<td><?php echo $bike_make['make'], $bike_model['model_name']; ?></td>
<td>Bike Name</td><td><?php echo $bike_make['make'], $bike_model['model_name']; ?></td>
</tr>
<tr>
<td>Colour</td>
<td><?php echo $vehicle['colour']?></td>
<td>Colour</td><td><?php echo $vehicle['colour']?></td>
</tr>
<tr>
<td>Bike Number</td>
<td><?php echo $vehicle['reg_no']?></td>
<td>Bike Number</td><td><?php echo $vehicle['reg_no']?></td>
</tr>
<tr>
<td>Contact Number</td>
<td><?php echo $vehicle['mobile_no']?></td>
<td>Contact Number</td><td><?php echo $vehicle['mobile_no']?></td>
</tr>
<tr>
<td>Job Card No. </td>
<td>5</td>
<td>Job Card No. </td><td>5</td>
</tr>
<tr>
<td>Dated</td>
<td>5</td>
<td>Dated</td><td>5</td>
</tr>
<tr>
<td>Delivery Date</td>
<td>5</td>
<td>Delivery Date</td><td>5</td>
</tr>
<tr>
<td>Mode Of Payment</td>
<td>5</td>
<td>Mode Of Payment</td><td>5</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<table class="addresses-table">
<tr >
<td class="billing-address">
@ -276,107 +126,78 @@
<?php endforeach; ?>
</td>
<!-- <td class="shipping-address">
</td> -->
</tr>
</table>
<br> <br>
<table class="invoice-related-table">
<thead>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">S no</th>
<th style="border: 0.5px solid black;">Description Of Goods</th>
<th style="border: 0.5px solid black;">Taxable Value</th>
<th style="border: 0.5px solid black;">Quantity</th>
<th style="border: 0.5px solid black;">Per</th>
<th style="border: 0.5px solid black;">GST</th>
<th style="border: 0.5px solid black;">CGST Amount</th>
<th style="border: 0.5px solid black;">SGST Amount</th>
<th style="border: 0.5px solid black;">Total Tax</th>
<th style="border: 0.5px solid black;">Total</th>
</tr>
</thead>
<tbody>
<?php $serialNumber = 1; ?>
<?php foreach ($items as $item) : ?>
</table><br><br>
<table class="invoice-related-table">
<thead>
<tr >
<th >S no</th>
<th >Description Of Goods</th>
<th >Taxable Value</th>
<th >Quantity</th>
<th >Per</th>
<th >GST</th>
<th >CGST Amount</th>
<th >SGST Amount</th>
<th >Total Tax</th>
<th >Total</th>
</tr>
</thead>
<tbody>
<?php $serialNumber = 1; ?>
<?php foreach ($items as $item) : ?>
<tr>
<?php $taxPercentage = $item->tax / 100;
$taxAmount = $item->amount * $taxPercentage;
$amountWithoutTax = $item->amount - $taxAmount;
$value_tax = number_format($taxAmount, 2, '.', ',');?>
<td style="border: 1px solid black;">
<?= $serialNumber++; ?>
</td>
<td style="border-right: 0.5px solid black;"><?= $item->product_name ?></td>
<td style="border-right: 0.5px solid black;"> <?php echo number_format($amountWithoutTax, 2, '.', ','); ?></td>
<td style="border-right: 0.5px solid black;"><?= $item->qty ?></td>
<td style="border-right: 0.5px solid black;"></td>
<td style="border-right: 0.5px solid black;"><?= $item->tax ?>%</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border: 0.5px solid black;"><?php echo $value_tax;?></td>
<td style="border-right: 0.5px solid black;"><?= $item->amount ?></td>
</tr>
<?php endforeach; ?>
<tr>
<?php $taxPercentage = $item->tax / 100;
$taxAmount = $item->amount * $taxPercentage;
$amountWithoutTax = $item->amount - $taxAmount;
$value_tax = number_format($taxAmount, 2, '.', ',');?>
<td style="border: 1px solid black;">
<?= $serialNumber++; ?>
</td>
<td style="border-right: 0.5px solid black;"><?= $item->product_name ?></td>
<td style="border-right: 0.5px solid black;"> <?php echo number_format($amountWithoutTax, 2, '.', ','); ?></td>
<td style="border-right: 0.5px solid black;"><?= $item->qty ?></td>
<td style="border-right: 0.5px solid black;"></td>
<td style="border-right: 0.5px solid black;"><?= $item->tax ?>%</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border: 0.5px solid black;"><?php echo $value_tax;?></td>
<td style="border-right: 0.5px solid black;"><?= $item->amount ?></td>
<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;">Total Taxable Value</td>
<td style="border: 0.5px solid black;"></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;">Total Taxable Value</td>
<td style="border: 0.5px solid black;"></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;">CGST</td>
<td style="border: 0.5px solid black;"></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;">SGST</td>
<td style="border: 0.5px solid black;"></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;">Total</td>
<td style="border: 0.5px solid black;"></td>
</tr>
<tr>
<td colspan="10" style="border: 0.5px solid black;">Amount Chargeable (in words)</td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td colspan="7" style="border: 0.5px solid black;"><p>Declaration: <br> We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.<br><br>**This is computer generated bill and doesnt require signature</p></td>
<td colspan="3" style="border: 0.5px solid black;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
<tr>
<td colspan="6" style="border-left: 0.5px solid black;"></td>
<td colspan="3" style="text-align:center;border: 0.5px solid black;">CGST</td>
<td style="border: 0.5px solid black;"></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;">SGST</td>
<td style="border: 0.5px solid black;"></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;">Total</td>
<td style="border: 0.5px solid black;"></td>
</tr>
<tr>
<td colspan="10" style="border: 0.5px solid black;">Amount Chargeable (in words)</td>
</tr>
</tbody>
</table>
<div class="business-stamp">
</div>
<div class="terms">
<!-- <p style=text-align:left><?= $value->terms_condition;?></p> -->
</div>
<!-- ... (your existing HTML template) -->
<!-- Add this to the end of your HTML template -->
<!-- <img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png" /> -->
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td colspan="7" style="border: 0.5px solid black;"><p>Declaration: <br> We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.<br><br>**This is computer generated bill and doesnt require signature</p></td>
<td colspan="3" style="border: 0.5px solid black;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -54,10 +54,13 @@
/* 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: right;
}
@ -87,11 +90,11 @@ 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: center; /* Center-align text in cells */
text-align: left; /* Center-align text in cells */
}
table.invoice-related-table th {
background-color: #f2f2f2;
background-color: #DAC2AD;
font-weight: bold;
}
@ -138,12 +141,15 @@ p {
</style>
</head>
<body>
<h3 style="text-align:center;text-decoration: underline;">Tax Invoice</h3>
<table class="main-table">
<tr>
<td>
<table class="business-details-table">
<?php foreach ($company_address as $value) : ?>
<tr>
<td style="max-width: 50px;">
<p><b>THE MECHANIC</b><br>
<?= $value['address'] ?>,<br>
@ -164,7 +170,9 @@ p {
</table>
</td>
<td>
<table class="invoice-info-table" style="max-width: 250px;border: 1px solid black;">
<div>
<table class="invoice-info-table" style="max-width: 250px;border: 1px solid black; ">
<tbody>
<tr>
<td>Invoice No.</td>
<td>1657</td>
@ -201,7 +209,9 @@ p {
<td>Mode of Payment</td>
<td>Online</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</table>
@ -229,15 +239,15 @@ p {
<td style="border: 1px solid black;">
<?= $serialNumber++; ?>
</td>
<td style="border-right: 0.5px solid black;"><?= $item['product_name'] ?></td>
<td style="border-right: 0.5px solid black;"><?= $item['amount'] ?></td>
<td style="border-right: 0.5px solid black;"><?= $item['qty'] ?></td>
<td style="border-right: 0.5px solid black;">nos</td>
<td style="border-right: 0.5px solid black;"><?= $item['tax'] ?>%</td>
<td style="border-right: 0.5px solid black;"><?= ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border-right: 0.5px solid black;"><?= ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;"><?= $item['product_name'] ?></td>
<td style="border: 0.5px solid black;"><?= $item['amount'] ?></td>
<td style="border: 0.5px solid black;"><?= $item['qty'] ?></td>
<td style="border: 0.5px solid black;">nos</td>
<td style="border: 0.5px solid black;"><?= $item['tax'] ?>%</td>
<td style="border: 0.5px solid black;"><?= ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;"><?= ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
<td style="border: 0.5px solid black;"><?= ($item['amount'] * $item['tax'] / 100) ?></td>
<td style="border-right: 0.5px solid black;"><?= ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) ?></td>
<td style="border: 0.5px solid black;"><?= ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) ?></td>
</tr>
<?php endforeach; ?>
<tr>
@ -263,6 +273,12 @@ p {
<tr>
<td colspan="10" style="border: 0.5px solid black;">Amount Chargeable (in words)</td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td colspan="7" style="border: 0.5px solid black;"><p>Declaration: <br> We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.<br><br>**This is computer generated bill and doesnt require signature</p></td>
<td colspan="3" style="border: 0.5px solid black;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
</tr>
</tbody>
</table>

View File

@ -29,7 +29,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" <?= isset($sales['vehicle_id']) ? 'readonly' : 'required' ?>>
<select class="form-control vehicle-select SelExample" name="vehicle_id" id="vehicle_name" <?= isset($sales['vehicle_id']) ? 'readonly' : 'required' ?>>
<?= isset($sales['vehicle_id']) ? '' : '<option value="">Select a vehicle</option>' ?>
<?php foreach ($vehicle as $value) : ?>
@ -916,14 +916,11 @@ $(document).ready(async function() {
// Event listener for "Add More Item" button
$(document).on('click', '#addProduct', function() {
console.log(productarray.length);
if(productarray.length == 0) {
productarray = <?php echo json_encode($product) ?>;
console.log(productarray);
}
var newRow = '<tr class="product"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;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;"><option value="">Select a Product</option>';
for (var i = 0; i < productarray.length; i++)
{
var product = productarray[i];
@ -939,44 +936,43 @@ $(document).ready(async function() {
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
// $('#productItemTable tbody').append(newRow);
$(newRow).insertAfter($(this).closest('tr'));
// $('#productItemTable tbody').append(newRow);
$(newRow).insertAfter($(this).closest('tr'));
initializeSelect2();
});
$('#addService').click(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 style="width:10%;"> <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>';
for (var i = 0; i < servicearray.length; i++)
{
var service = servicearray[i];
newRow += '<option value="' + service.service_id + '">' + service.service_name + '</option>';
if ($('#vehicle_name').val()) {
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
// console.log(servicearray);
var newRow = '<tr class="service_class"><td hidden style="width:10%;"> <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>';
for (var i = 0; i < servicearray.length; i++)
{
var service = servicearray[i];
newRow += '<option value="' + service.service_id + '">' + service.service_name + '</option>';
}
newRow += '</select></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td><center><i class="fa fa-trash remove-item" id="remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#productItemTable tbody').append(newRow);
initializeSelect2();
}else{
toastr.warning("First Select Vehicle!");
}
newRow += '</select></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" name="quantity[]" readonly/></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td><center><i class="fa fa-trash remove-item" id="remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#productItemTable tbody').append(newRow);
initializeSelect2();
});
$('#addcomplaint').click(function() {
complaint = <?php echo json_encode($complaint) ?>;
// console.log(productarray);
var newRow = '<tr class="complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
for (var i = 0; i < complaint.length; i++)
@ -1002,17 +998,12 @@ $(document).ready(async function() {
'</td>' +
'<td hidden><input type="hidden" name="id"></td>' +
'</tr>';
$('#productItemTable tbody').append(newRow);
$('#productItemTable tbody').append(newRow);
initializeSelect2();
});
$('#addCustomComplaint').click(function() {
complaint = <?php echo json_encode($complaint) ?>;
// console.log(productarray);
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5"></textarea></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" /></td>' +
@ -1043,25 +1034,25 @@ $(document).ready(async function() {
$('#productItemTable tbody').append(newRow);
initializeSelect2();
// Function to increment class name
function incrementClassName(className) {
var classNumber = parseInt(className.match(/\d+/)[0]);
return className.replace(/\d+/, classNumber + 1);
}
// Function to increment class name And this Class name for for remove the parent Custom Comlaint is remove the child to remove
function incrementClassName(className) {
var classNumber = parseInt(className.match(/\d+/)[0]);
return className.replace(/\d+/, classNumber + 1);
}
// Initial class name
var initialClassName = 'custom_complaint_class';
var currentClassName;
// Initial class name
var initialClassName = 'custom_complaint_class';
var currentClassName;
// Loop to check for existence of subsequent classes
for (var i = 2000; i <= 2100; i++) {
currentClassName = initialClassName + '_' + i;
if ($('.' + currentClassName).length === 0) {
// If the class doesn't exist, increment the last found class
$('.' + initialClassName).removeClass(initialClassName).addClass(currentClassName);
break;
}
}
// Loop to check for existence of subsequent classes
for (var i = 2000; i <= 2100; i++) {
currentClassName = initialClassName + '_' + i;
if ($('.' + currentClassName).length === 0) {
// If the class doesn't exist, increment the last found class
$('.' + initialClassName).removeClass(initialClassName).addClass(currentClassName);
break;
}
}
});
$(document).on('input', '.item_dummy', function() {

View File

@ -7,11 +7,7 @@
<div class="page-title-right">
<a href="<?= base_url() . "product_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<ol class="breadcrumb m-0">
</li>
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
<li class="breadcrumb-item active">Datatables</li> -->
</ol>
</ol>
</div>
</div>
</div>
@ -22,53 +18,49 @@
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_product"; ?>" method="post">
<h4 class="header-title">Product Details :</h4><br>
<h4 class="header-title">Product Details :</h4><br>
<div class="form-row">
<div class="form-group col-md-4">
<div class="form-group col-md-4">
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i>' ?>
<select class="form-control SelExample" id="make" name="make[]" required multiple>
<option value="">Select a Make</option>
<!-- Options for make -->
<?php foreach ($make as $value): ?>
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && in_array($value['make_id'], $products['make_id']) ? 'selected' : '' ?>>
<?= $value['make'] ?>
</option>
<?php endforeach; ?>
</select>
<?php foreach ($make as $value): ?>
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && in_array($value['make_id'], $products['make_id']) ? 'selected' : '' ?>>
<?= $value['make'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i>'; ?>
<select class="form-control SelExample" id="model" name="model[]" required multiple>
<!-- Options for model will be populated dynamically via AJAX -->
<?php if(isset($models) && !empty($models)): ?>
<?php foreach ($models as $make_models): ?>
<?php foreach ($make_models as $model): ?>
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], $products['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i>'; ?>
<select class="form-control SelExample" id="model" name="model[]" required multiple>
<!-- Options for model will be populated dynamically via AJAX -->
<?php if(isset($models) && !empty($models)): ?>
<?php foreach ($models as $make_models): ?>
<?php foreach ($make_models as $model): ?>
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], $products['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<?php endif; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="manufacturer" name="manufacturer" required>
<option value="">Select a Manufacturer</option>
<?php foreach ($manufacturers as $value): ?>
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($products['manufacturer_id']) && $products['manufacturer_id'] == $value['manufacturer_id'] ? 'selected' : '' ?>>
<?= $value['manufacturer_name'] ?>
</option>
<?php endforeach; ?>
</select>
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="manufacturer" name="manufacturer" required>
<option value="">Select a Manufacturer</option>
<?php foreach ($manufacturers as $value): ?>
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($products['manufacturer_id']) && $products['manufacturer_id'] == $value['manufacturer_id'] ? 'selected' : '' ?>>
<?= $value['manufacturer_name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="quality" class="col-form-label">Quality<span class="text-danger">*</span></label>
@ -76,7 +68,6 @@
<!-- Options for quality will be populated dynamically via JavaScript -->
</select>
</div>
<div class="form-group col-md-4">
<label for="inputAddress" class="col-form-label">Manfacturer Part Number</label>
<input type="text" class="form-control" name="mfr_part_no" placeholder="Manfacturer Part Number" value="<?= isset($products['mfr_part_no']) ? $products['mfr_part_no'] : '' ?>" >
@ -89,24 +80,22 @@
<?php foreach ($vendors as $vendor): ?>
<option value="<?= $vendor['vendor_id'] ?>" <?= isset($products['vendor']) && in_array($vendor['vendor_id'], json_decode($products['vendor'], true)) ? 'selected' : '' ?>>
<?= $vendor['vendor_name'] ?>
</option>
<?php endforeach; ?>
<?= $vendor['vendor_name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="preferred_vendor" class="col-form-label">Preferred Vendor<span class="text-danger">*</span></label>
<select class="form-control" id="preferred_vendor" name="prefered_vendor" required>
<!-- Loop through vendors and set selected attribute if ID matches preferredVendorId -->
<?php foreach ($vendorsProduct as $vendor): ?>
<option value="<?= $vendor['id'] ?>" <?= (isset($preferredVendorId) && $vendor['id'] == $preferredVendorId) ? 'selected' : '' ?>>
<?= $vendor['name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
<label for="preferred_vendor" class="col-form-label">Preferred Vendor<span class="text-danger">*</span></label>
<select class="form-control" id="preferred_vendor" name="prefered_vendor" required>
<!-- Loop through vendors and set selected attribute if ID matches preferredVendorId -->
<?php foreach ($vendorsProduct as $vendor): ?>
<option value="<?= $vendor['id'] ?>" <?= (isset($preferredVendorId) && $vendor['id'] == $preferredVendorId) ? 'selected' : '' ?>>
<?= $vendor['name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-3">
<label for="inputEmail4" class="col-form-label">HSN/SAC<span class="text-danger"></span></label>
<input type="text" class="form-control" name="hsn_sac" placeholder="HSN/SAC" value="<?= isset($products['hsn_sac']) ? $products['hsn_sac'] : '' ?>" >
@ -114,72 +103,67 @@
<div class="form-group col-md-3">
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger"></span></label>
<select class="form-control status-select SelExample" name="productcategory" required data-toggle="select2">
<option value="" >Select Category</option>
<option value="Bearings" <?= (isset($products['product_category']) && $products['product_category'] == 'Bearings') ? 'selected' : '' ?>>Bearings</option>
<option value="Paste" <?= (isset($products['product_category']) && $products['product_category'] == 'Paste') ? 'selected' : '' ?>>Paste</option>
<option value="Clutch Plates" <?= (isset($products['product_category']) && $products['product_category'] == 'Clutch Plates') ? 'selected' : '' ?>>Clutch Plates</option>
<option value="Head Beeding" <?= (isset($products['product_category']) && $products['product_category'] == 'Head Beeding') ? 'selected' : '' ?>>Head Beeding</option>
<option value="Oil Seal" <?= (isset($products['product_category']) && $products['product_category'] == 'Oil Seal') ? 'selected' : '' ?>>Oil Seal</option>
<option value="Switches" <?= (isset($products['product_category']) && $products['product_category'] == 'Switches') ? 'selected' : '' ?>>Switches</option>
<option value="Speedometer" <?= (isset($products['product_category']) && $products['product_category'] == 'Speedometer') ? 'selected' : '' ?>>Speedometer</option>
<option value="Oil" <?= (isset($products['product_category']) && $products['product_category'] == 'Oil') ? 'selected' : '' ?>>Oil</option>
<option value="Cone set" <?= (isset($products['product_category']) && $products['product_category'] == 'Cone set') ? 'selected' : '' ?>>Cone set</option>
<option value="Brake" <?= (isset($products['product_category']) && $products['product_category'] == 'Brake') ? 'selected' : '' ?>>Brake</option>
<option value="Oil Filter" <?= (isset($products['product_category']) && $products['product_category'] == 'Oil Filter') ? 'selected' : '' ?>>Oil Filter</option>
<option value="Battery" <?= (isset($products['product_category']) && $products['product_category'] == 'Battery') ? 'selected' : '' ?>>Battery</option>
<option value="Lubricants" <?= (isset($products['product_category']) && $products['product_category'] == 'Lubricants') ? 'selected' : '' ?>>Lubricants</option>
<option value="Mirror" <?= (isset($products['product_category']) && $products['product_category'] == 'Mirror') ? 'selected' : '' ?>>Mirror</option>
<option value="Spark Plug" <?= (isset($products['product_category']) && $products['product_category'] == 'Spark Plug') ? 'selected' : '' ?>>Spark Plug</option>
<option value="Belt" <?= (isset($products['product_category']) && $products['product_category'] == 'Belt') ? 'selected' : '' ?>>Belt</option>
<option value="Indicators" <?= (isset($products['product_category']) && $products['product_category'] == 'Indicators') ? 'selected' : '' ?>>Indicators</option>
<option value="Wiring" <?= (isset($products['product_category']) && $products['product_category'] == 'Wiring') ? 'selected' : '' ?>>Wiring</option>
<option value="Light" <?= (isset($products['product_category']) && $products['product_category'] == 'Light') ? 'selected' : '' ?>>Light</option>
<option value="Flasher" <?= (isset($products['product_category']) && $products['product_category'] == 'Flasher') ? 'selected' : '' ?>>Flasher</option>
<option value="Buzzer" <?= (isset($products['product_category']) && $products['product_category'] == 'Buzzer') ? 'selected' : '' ?>>Buzzer</option>
<option value="Bush" <?= (isset($products['product_category']) && $products['product_category'] == 'Bush') ? 'selected' : '' ?>>Bush</option>
<option value="Wheel rubber" <?= (isset($products['product_category']) && $products['product_category'] == 'Wheel rubber') ? 'selected' : '' ?>>Wheel rubber</option>
<option value="Stand" <?= (isset($products['product_category']) && $products['product_category'] == 'Stand') ? 'selected' : '' ?>>Stand</option>
<option value="Kicker" <?= (isset($products['product_category']) && $products['product_category'] == 'Kicker') ? 'selected' : '' ?>>Kicker</option>
<option value="Gear" <?= (isset($products['product_category']) && $products['product_category'] == 'Gear') ? 'selected' : '' ?>>Gear</option>
<option value="Disc Pad" <?= (isset($products['product_category']) && $products['product_category'] == 'Disc Pad') ? 'selected' : '' ?>>Disc Pad</option>
<option value="Foot Rest" <?= (isset($products['product_category']) && $products['product_category'] == 'Foot Rest') ? 'selected' : '' ?>>Foot Rest</option>
<option value="Petrol Tap" <?= (isset($products['product_category']) && $products['product_category'] == 'Petrol Tap') ? 'selected' : '' ?>>Petrol Tap</option>
<option value="Bolts ,Nuts & screws" <?= (isset($products['product_category']) && $products['product_category'] == 'Bolts ,Nuts & screws') ? 'selected' : '' ?>>Bolts ,Nuts & screws</option>
<option value="Tyres & Tubes" <?= (isset($products['product_category']) && $products['product_category'] == 'Tyres & Tubes') ? 'selected' : '' ?>>Tyres & Tubes</option>
<option value="Gasket" <?= (isset($products['product_category']) && $products['product_category'] == 'Gasket') ? 'selected' : '' ?>>Gasket</option>
<option value="Clutch Switch" <?= (isset($products['product_category']) && $products['product_category'] == 'Clutch Switch') ? 'selected' : '' ?>>Clutch Switch</option>
<option value="Fuse" <?= (isset($products['product_category']) && $products['product_category'] == 'Fuse') ? 'selected' : '' ?>>Fuse</option>
<option value="Gaskets" <?= (isset($products['product_category']) && $products['product_category'] == 'Gaskets') ? 'selected' : '' ?>>Gaskets</option>
<option value="Yoke" <?= (isset($products['product_category']) && $products['product_category'] == 'Yoke') ? 'selected' : '' ?>>Yoke</option>
<option value="Air Filter" <?= (isset($products['product_category']) && $products['product_category'] == 'Air Filter') ? 'selected' : '' ?>>Air Filter</option>
<option value="Glass" <?= (isset($products['product_category']) && $products['product_category'] == 'Glass') ? 'selected' : '' ?>>Glass</option>
<option value="Chain Adjuster" <?= (isset($products['product_category']) && $products['product_category'] == 'Chain Adjuster') ? 'selected' : '' ?>>Chain Adjuster</option>
<option value="Spokes" <?= (isset($products['product_category']) && $products['product_category'] == 'Spokes') ? 'selected' : '' ?>>Spokes</option>
<option value="V bush" <?= (isset($products['product_category']) && $products['product_category'] == 'V bush') ? 'selected' : '' ?>>V bush</option>
<option value="Stay Bush" <?= (isset($products['product_category']) && $products['product_category'] == 'Stay Bush') ? 'selected' : '' ?>>Stay Bush</option>
<option value="Roller Bush" <?= (isset($products['product_category']) && $products['product_category'] == 'Roller Bush') ? 'selected' : '' ?>>Roller Bush</option>
<option value="Brake Shoe" <?= (isset($products['product_category']) && $products['product_category'] == 'Brake Shoe') ? 'selected' : '' ?>>Brake Shoe</option>
<option value="Mud Flap" <?= (isset($products['product_category']) && $products['product_category'] == 'Mud Flap') ? 'selected' : '' ?>>Mud Flap</option>
<option value="Grip" <?= (isset($products['product_category']) && $products['product_category'] == 'Grip') ? 'selected' : '' ?>>Grip</option>
<option value="Rubber" <?= (isset($products['product_category']) && $products['product_category'] == 'Rubber') ? 'selected' : '' ?>>Rubber</option>
<option value="Cables" <?= (isset($products['product_category']) && $products['product_category'] == 'Cables') ? 'selected' : '' ?>>Cables</option>
<option value="" >Select Category</option>
<option value="Bearings" <?= (isset($products['product_category']) && $products['product_category'] == 'Bearings') ? 'selected' : '' ?>>Bearings</option>
<option value="Paste" <?= (isset($products['product_category']) && $products['product_category'] == 'Paste') ? 'selected' : '' ?>>Paste</option>
<option value="Clutch Plates" <?= (isset($products['product_category']) && $products['product_category'] == 'Clutch Plates') ? 'selected' : '' ?>>Clutch Plates</option>
<option value="Head Beeding" <?= (isset($products['product_category']) && $products['product_category'] == 'Head Beeding') ? 'selected' : '' ?>>Head Beeding</option>
<option value="Oil Seal" <?= (isset($products['product_category']) && $products['product_category'] == 'Oil Seal') ? 'selected' : '' ?>>Oil Seal</option>
<option value="Switches" <?= (isset($products['product_category']) && $products['product_category'] == 'Switches') ? 'selected' : '' ?>>Switches</option>
<option value="Speedometer" <?= (isset($products['product_category']) && $products['product_category'] == 'Speedometer') ? 'selected' : '' ?>>Speedometer</option>
<option value="Oil" <?= (isset($products['product_category']) && $products['product_category'] == 'Oil') ? 'selected' : '' ?>>Oil</option>
<option value="Cone set" <?= (isset($products['product_category']) && $products['product_category'] == 'Cone set') ? 'selected' : '' ?>>Cone set</option>
<option value="Brake" <?= (isset($products['product_category']) && $products['product_category'] == 'Brake') ? 'selected' : '' ?>>Brake</option>
<option value="Oil Filter" <?= (isset($products['product_category']) && $products['product_category'] == 'Oil Filter') ? 'selected' : '' ?>>Oil Filter</option>
<option value="Battery" <?= (isset($products['product_category']) && $products['product_category'] == 'Battery') ? 'selected' : '' ?>>Battery</option>
<option value="Lubricants" <?= (isset($products['product_category']) && $products['product_category'] == 'Lubricants') ? 'selected' : '' ?>>Lubricants</option>
<option value="Mirror" <?= (isset($products['product_category']) && $products['product_category'] == 'Mirror') ? 'selected' : '' ?>>Mirror</option>
<option value="Spark Plug" <?= (isset($products['product_category']) && $products['product_category'] == 'Spark Plug') ? 'selected' : '' ?>>Spark Plug</option>
<option value="Belt" <?= (isset($products['product_category']) && $products['product_category'] == 'Belt') ? 'selected' : '' ?>>Belt</option>
<option value="Indicators" <?= (isset($products['product_category']) && $products['product_category'] == 'Indicators') ? 'selected' : '' ?>>Indicators</option>
<option value="Wiring" <?= (isset($products['product_category']) && $products['product_category'] == 'Wiring') ? 'selected' : '' ?>>Wiring</option>
<option value="Light" <?= (isset($products['product_category']) && $products['product_category'] == 'Light') ? 'selected' : '' ?>>Light</option>
<option value="Flasher" <?= (isset($products['product_category']) && $products['product_category'] == 'Flasher') ? 'selected' : '' ?>>Flasher</option>
<option value="Buzzer" <?= (isset($products['product_category']) && $products['product_category'] == 'Buzzer') ? 'selected' : '' ?>>Buzzer</option>
<option value="Bush" <?= (isset($products['product_category']) && $products['product_category'] == 'Bush') ? 'selected' : '' ?>>Bush</option>
<option value="Wheel rubber" <?= (isset($products['product_category']) && $products['product_category'] == 'Wheel rubber') ? 'selected' : '' ?>>Wheel rubber</option>
<option value="Stand" <?= (isset($products['product_category']) && $products['product_category'] == 'Stand') ? 'selected' : '' ?>>Stand</option>
<option value="Kicker" <?= (isset($products['product_category']) && $products['product_category'] == 'Kicker') ? 'selected' : '' ?>>Kicker</option>
<option value="Gear" <?= (isset($products['product_category']) && $products['product_category'] == 'Gear') ? 'selected' : '' ?>>Gear</option>
<option value="Disc Pad" <?= (isset($products['product_category']) && $products['product_category'] == 'Disc Pad') ? 'selected' : '' ?>>Disc Pad</option>
<option value="Foot Rest" <?= (isset($products['product_category']) && $products['product_category'] == 'Foot Rest') ? 'selected' : '' ?>>Foot Rest</option>
<option value="Petrol Tap" <?= (isset($products['product_category']) && $products['product_category'] == 'Petrol Tap') ? 'selected' : '' ?>>Petrol Tap</option>
<option value="Bolts ,Nuts & screws" <?= (isset($products['product_category']) && $products['product_category'] == 'Bolts ,Nuts & screws') ? 'selected' : '' ?>>Bolts ,Nuts & screws</option>
<option value="Tyres & Tubes" <?= (isset($products['product_category']) && $products['product_category'] == 'Tyres & Tubes') ? 'selected' : '' ?>>Tyres & Tubes</option>
<option value="Gasket" <?= (isset($products['product_category']) && $products['product_category'] == 'Gasket') ? 'selected' : '' ?>>Gasket</option>
<option value="Clutch Switch" <?= (isset($products['product_category']) && $products['product_category'] == 'Clutch Switch') ? 'selected' : '' ?>>Clutch Switch</option>
<option value="Fuse" <?= (isset($products['product_category']) && $products['product_category'] == 'Fuse') ? 'selected' : '' ?>>Fuse</option>
<option value="Gaskets" <?= (isset($products['product_category']) && $products['product_category'] == 'Gaskets') ? 'selected' : '' ?>>Gaskets</option>
<option value="Yoke" <?= (isset($products['product_category']) && $products['product_category'] == 'Yoke') ? 'selected' : '' ?>>Yoke</option>
<option value="Air Filter" <?= (isset($products['product_category']) && $products['product_category'] == 'Air Filter') ? 'selected' : '' ?>>Air Filter</option>
<option value="Glass" <?= (isset($products['product_category']) && $products['product_category'] == 'Glass') ? 'selected' : '' ?>>Glass</option>
<option value="Chain Adjuster" <?= (isset($products['product_category']) && $products['product_category'] == 'Chain Adjuster') ? 'selected' : '' ?>>Chain Adjuster</option>
<option value="Spokes" <?= (isset($products['product_category']) && $products['product_category'] == 'Spokes') ? 'selected' : '' ?>>Spokes</option>
<option value="V bush" <?= (isset($products['product_category']) && $products['product_category'] == 'V bush') ? 'selected' : '' ?>>V bush</option>
<option value="Stay Bush" <?= (isset($products['product_category']) && $products['product_category'] == 'Stay Bush') ? 'selected' : '' ?>>Stay Bush</option>
<option value="Roller Bush" <?= (isset($products['product_category']) && $products['product_category'] == 'Roller Bush') ? 'selected' : '' ?>>Roller Bush</option>
<option value="Brake Shoe" <?= (isset($products['product_category']) && $products['product_category'] == 'Brake Shoe') ? 'selected' : '' ?>>Brake Shoe</option>
<option value="Mud Flap" <?= (isset($products['product_category']) && $products['product_category'] == 'Mud Flap') ? 'selected' : '' ?>>Mud Flap</option>
<option value="Grip" <?= (isset($products['product_category']) && $products['product_category'] == 'Grip') ? 'selected' : '' ?>>Grip</option>
<option value="Rubber" <?= (isset($products['product_category']) && $products['product_category'] == 'Rubber') ? 'selected' : '' ?>>Rubber</option>
<option value="Cables" <?= (isset($products['product_category']) && $products['product_category'] == 'Cables') ? 'selected' : '' ?>>Cables</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="inputEmail4" class="col-form-label">Specification<span class="text-danger"></span></label>
<input type="text" class="form-control" name="specification" placeholder="Specification" value="<?= isset($products['specification']) ? $products['specification'] : '' ?>" >
</div>
<div class="form-group col-md-3">
<label for="inputEmail4" class="col-form-label">Rack Number<span class="text-danger"></span></label>
<input type="text" class="form-control" name="rack_number" placeholder="Rack Number" value="<?= isset($products['rack_number']) ? $products['rack_number'] : '' ?>" >
</div>
</div>
</div>
<input type="hidden" id="product_id" name="product_id" value="<?= isset($products['product_id']) ? $products['product_id'] : '' ?>"><br>
<h4 class="header-title">Pricing Information :</h4><br>
<div class="form-row">
@ -208,49 +192,54 @@
<label for="inputPassword4" class="col-form-label">Unit Price + Tax</label>
<input type="number" class="form-control" name="total_amount" placeholder="Total Price"value="<?= isset($products['total_amount']) ? $products['total_amount'] : '' ?>" required readonly>
</div>
</div><br>
<h4 class="header-title">Stock Information :</h4><br>
<div class="form-row">
<div class="form-group col-md-3">
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Unit of Measurement<span class="text-danger">*</span></label>
<select class="form-control status-select" name="per" required data-toggle="select2">
<select class="form-control status-select" id="per" name="per" required data-toggle="select2">
<option value="" <?= (isset($products['per']) && $products['per'] == '') ? 'selected' : '' ?>>Select</option>
<option value="Nos" <?= (isset($products['per']) && $products['per'] == 'Nos') ?'selected' : '' ?>>nos</option>
<option value="ml" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'selected' : '' ?>>ml</option>
<option value="litre" <?= (isset($products['per']) && $products['per'] == 'litre') ? 'selected' : '' ?>>litre</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
<input type="number" class="form-control" id="qty_in_stock" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
<input type="number" class="form-control" id="purchase_order_level" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
<input type="number" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
</div>
<div class="form-group col-md-3" id="ml_div" <?= (isset($products['per']) && $products['per'] == 'ml') ? '' : 'hidden' ?> >
<label for="inputPassword4" class="col-form-label">ML<span class="text-danger">*</span></label>
<select name="ml" id="ml" class="form-control" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'required' : '' ?>>
<option value <?= (isset($products['ml']) && $products['ml'] == 0) ? 'selected' : '' ?>>Slect ML</option>
<option value="50" <?= (isset($products['ml']) && $products['ml'] == 50) ? 'selected' : '' ?>>50</option>
<option value="100" <?= (isset($products['ml']) && $products['ml'] == 100) ? 'selected' : '' ?>>100</option>
<option value="250" <?= (isset($products['ml']) && $products['ml'] == 250) ? 'selected' : '' ?>>250</option>
<option value="500" <?= (isset($products['ml']) && $products['ml'] == 500) ? 'selected' : '' ?>>500</option>
<option value="750" <?= (isset($products['ml']) && $products['ml'] == 750) ? 'selected' : '' ?>>750</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
<input type="number" class="form-control" id="qty_in_stock" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
<input type="number" class="form-control" id="purchase_order_level" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
<input type="number" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
</div>
<div class="form-group col-md-4" hidden>
<label for="inputPassword4" class="col-form-label">Qty in Demand</label>
<input type="number" class="form-control" name="qty_in_demand" placeholder="Qty in Demand" value="<?= isset($products['qty_in_demand']) ? $products['qty_in_demand'] : '' ?>" >
</div>
</div>
</div><br>
<h4 class="header-title">Description Details :</h4><br>
<div class="form-row">
<div class="form-group col-md-12">
<div class="form-group col-md-12">
<label for="inputPassword4" class="col-form-label">Description</label>
<textarea class="form-control" name="description" placeholder="Description"value="<?= isset($products['description']) ? $products['description'] : '' ?>" required>
</textarea>
</div>
</div>
</textarea>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
@ -583,63 +572,73 @@ $('#saveMakeBtn').click(function() {
</script>
<!-- Save Modal Funxtion -->
<script>
// Populate make dropdown in the add model modal
function populateMakeDropdown() {
$.ajax({
url: '<?php echo base_url('get_makes') ?>', // URL to your CodeIgniter controller method to fetch makes
type: 'GET',
dataType: 'json',
success: function(response) {
$('#makeSelect').empty();
$('#makeSelect').append('<option value="">Select Make</option>');
response.forEach(function(make) {
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
});
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
}
// Call the function to populate make dropdown initially
$(document).ready(function() {
// populateMakeDropdown();
});
// Save model function
$('#saveModelBtn').click(function() {
var makeId = $('#makeSelect').val();
var model = $('#modelInput').val();
console.log(model);
if (makeId != '' && model != '') {
// Populate make dropdown in the add model modal
function populateMakeDropdown() {
$.ajax({
url: '<?php echo base_url().'save_model'?>',
method: 'POST',
data: {
make_id: makeId,
modelvalue: model
},
url: '<?php echo base_url('get_makes') ?>', // URL to your CodeIgniter controller method to fetch makes
type: 'GET',
dataType: 'json',
success: function(response) {
if (response.success) {
$('#addModelModal').modal('hide');
toastr.success("Model saved successfully");
$('#model').append('<option value="' + response.model_id + '">' + response.model_value + '</option>');
} else {
toastr.error("Failed to save model");
}
$('#makeSelect').empty();
$('#makeSelect').append('<option value="">Select Make</option>');
response.forEach(function(make) {
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
});
},
error: function(xhr, status, error) {
console.error('Error occurred while saving model:', error);
toastr.error("Failed to save model. Please try again");
console.error(xhr.responseText);
}
});
} else {
toastr.warning("Please fill in both make and model fields");
}
});
// Call the function to populate make dropdown initially
$(document).ready(function() {
// populateMakeDropdown();
});
// Save model function
$('#saveModelBtn').click(function() {
var makeId = $('#makeSelect').val();
var model = $('#modelInput').val();
if (makeId != '' && model != '') {
$.ajax({
url: '<?php echo base_url().'save_model'?>',
method: 'POST',
data: {
make_id: makeId,
modelvalue: model
},
success: function(response) {
if (response.success) {
$('#addModelModal').modal('hide');
toastr.success("Model saved successfully");
$('#model').append('<option value="' + response.model_id + '">' + response.model_value + '</option>');
} else {
toastr.error("Failed to save model");
}
},
error: function(xhr, status, error) {
console.error('Error occurred while saving model:', error);
toastr.error("Failed to save model. Please try again");
}
});
} else {
toastr.warning("Please fill in both make and model fields");
}
});
$('#per').change(function () {
if ($(this).val() == 'ml') {
$('#ml_div').removeAttr('hidden');
$('#ml').attr('required','required');
}else{
$('#ml_div').attr('hidden', 'hidden');
$('#ml').removeAttr('required');
}
})
</script>
<style>
.select2-container--default .select2-results__option--highlighted[aria-selected]{

View File

@ -135,71 +135,75 @@
<h4>Item Details</h4>
<br />
<table class="table table-bordered" id="itemTable">
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<?php if (!empty($purchase["status"]) && !isset($reorder)): ?>
<th>Received</th>
<th>Amount</th>
<?php endif; ?>
<th hidden></th>
<th></th>
</tr>
</thead>
<tbody>
<!-- Dynamically add rows for item details -->
<?php if (isset($purchase_product) && !empty($purchase_product)) : ?>
<?php foreach ($purchase_product as $purchasechild) :
if ($purchasechild['isactive'] == 1) : ?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<?php foreach ($product as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"]; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? ( (!isset($reorder) || $purchasechild['is_selected'] == 0) ? $purchasechild['received_qty'] : $purchasechild['qty'] - $purchasechild['received_qty'] ) : $purchasechild['qty'] ?>">
</td>
<?php if(!isset($reorder)) { ?>
<td style="width:2%;">
<input type="hidden" name="selected_items[]" value="<?= (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes -->
<input type="checkbox" class="form-control-check-input" <?php echo (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="amount[]" value="<?= isset($purchasechild['amount']) ? $purchasechild['amount'] : '' ?>">
</td>
<?php } ?>
<td hidden><input type="hidden" value="<?= isset($purchasechild['purchase_order_child_id']) ? $purchasechild['purchase_order_child_id'] : '' ?>"name="purchase_order_child_id[]"></td>
<td style="width:5%;">
<center><i class="fa fa-trash remove-item"></i></center>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<!-- You can add more rows as needed using JavaScript -->
</tbody>
</table>
<?php if (empty($purchase["status"]) || isset($reorder)): ?>
<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="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a>
</div>
<?php endif; ?>
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<?php if (!empty($purchase["status"]) && !isset($reorder)): ?>
<th>Received</th>
<th>Amount</th>
<?php endif; ?>
<th hidden></th>
<th></th>
</tr>
</thead>
<tbody>
<!-- Dynamically add rows for item details -->
<?php if (isset($purchase_product) && !empty($purchase_product)) : ?>
<?php foreach ($purchase_product as $purchasechild) :
if ($purchasechild['isactive'] == 1) : ?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<?php foreach ($product as $value) : ?>
<?php if ($value['per'] == 'ml') {
$value_ml = ' ('.$value['ml'].$value['per'].')';
} else {
$value_ml = '';
}
?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"].$value_ml; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? ( (!isset($reorder) || $purchasechild['is_selected'] == 0) ? $purchasechild['received_qty'] : $purchasechild['qty'] - $purchasechild['received_qty'] ) : $purchasechild['qty'] ?>">
</td>
<?php if(!isset($reorder)) { ?>
<td style="width:2%;">
<input type="hidden" name="selected_items[]" value="<?= (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes -->
<input type="checkbox" class="form-control-check-input" <?php echo (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="amount[]" value="<?= isset($purchasechild['amount']) ? $purchasechild['amount'] : '' ?>">
</td>
<?php } ?>
<td hidden><input type="hidden" value="<?= isset($purchasechild['purchase_order_child_id']) ? $purchasechild['purchase_order_child_id'] : '' ?>"name="purchase_order_child_id[]"></td>
<td style="width:5%;">
<center><i class="fa fa-trash remove-item"></i></center>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<!-- You can add more rows as needed using JavaScript -->
</tbody>
</table>
<?php if (empty($purchase["status"]) || isset($reorder)): ?>
<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="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a>
</div>
<?php endif; ?>
</div>
</div>
@ -412,13 +416,17 @@ $(document).ready(function() {
// Event listener for "Add More Item" button
$('#addItem').click(function() {
console.log(productarray);
// console.log(productarray);
var newRow = '<tr>' + '<td><select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
for (var i = 0; i < productarray.length; i++)
{
var product = productarray[i];
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>';
var value_ml ='';
if (product.per == 'ml') {
value_ml = "("+product.ml+product.per+")";
}
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml + '</option>';
}
newRow += '</select></td>' +

View File

@ -113,12 +113,18 @@
<tbody>
<?php if (isset($products) && !empty($products)) :
foreach ($products as $product) { ?>
<?php if ($product['per'] == 'ml') {
$value_ml = ' ('.$product['ml'].$product['per'].')';
} else {
$value_ml = '';
}
?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>>
<?= $product["product_name"]; ?>
<?= $product["product_name"].$value_ml; ?>
</option>
</select>
</td>

View File

@ -119,62 +119,68 @@
<br />
<table class="table table-bordered" id="itemTable">
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<?php if (!empty($purchase["status"])): ?>
<th>Select Return product</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<!-- Dynamically add rows for item details -->
<?php if (isset($purchase_product) && !empty($purchase_product)) : ?>
<?php foreach ($purchase_product as $key=> $purchasechild) :
if ($purchasechild['isactive'] == 1) : ?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<?php foreach ($product as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"]; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="1" max="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>" value="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>">
</td>
<td style="width:7%;">
<input type="checkbox" class="form-control-check-input" name="return_selected_items[]" value="<?= $key; ?>">
</td>
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<?php if (!empty($purchase["status"])): ?>
<th>Select Return product</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<!-- Dynamically add rows for item details -->
<?php if (isset($purchase_product) && !empty($purchase_product)) : ?>
<?php foreach ($purchase_product as $key=> $purchasechild) :
if ($purchasechild['isactive'] == 1) : ?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<?php foreach ($product as $value) : ?>
<?php if ($value['per'] == 'ml') {
$value_ml = ' ('.$value['ml'].$value['per'].')';
} else {
$value_ml = '';
}
?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"].$value_ml; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="1" max="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>" value="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>">
</td>
<td style="width:7%;">
<input type="checkbox" class="form-control-check-input" name="return_selected_items[]" value="<?= $key; ?>">
</td>
<td hidden><input type="hidden" value="<?= isset($purchasechild['purchase_order_child_id']) ? $purchasechild['purchase_order_child_id'] : '' ?>"name="purchase_order_child_id[]"></td>
<td style="width:5%;">
<center><i class="fa fa-trash remove-item"></i></center>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<!-- You can add more rows as needed using JavaScript -->
</tbody>
</table>
<?php if (empty($purchase["status"])): ?>
<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="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a>
</div>
<?php endif; ?>
<td hidden><input type="hidden" value="<?= isset($purchasechild['purchase_order_child_id']) ? $purchasechild['purchase_order_child_id'] : '' ?>"name="purchase_order_child_id[]"></td>
<td style="width:5%;">
<center><i class="fa fa-trash remove-item"></i></center>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<!-- You can add more rows as needed using JavaScript -->
</tbody>
</table>
<?php if (empty($purchase["status"])): ?>
<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="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a>
</div>
<?php endif; ?>
</div>

View File

@ -159,10 +159,16 @@
required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<?php foreach ($product as $value) : ?>
<?php if ($value['per'] == 'ml') {
$value_ml = ' ('.$value['ml'].$value['per'].')';
} else {
$value_ml = '';
}
?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>"
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"]; ?>
<?= $value["product_name"].$value_ml; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
@ -617,13 +623,18 @@ $(document).ready(function() {
// Event listener for "Add More Item" button
$('#addItem').click(function() {
console.log(productarray);
// console.log(productarray);
var newRow = '<tr>' +
'<td><select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
for (var i = 0; i < productarray.length; i++) {
var product = productarray[i];
newRow += '<option value="' + product.product_id + '" >' + product.product_name +
// console.log("product",product);
var value_ml ='';
if (product.per == 'ml') {
value_ml = "("+product.ml+product.per+")";
}
newRow += '<option value="' + product.product_id + '" >' + product.product_name + value_ml +
'</option>';
}