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

This commit is contained in:
bitbucket 2024-04-06 10:36:36 +05:30
commit 2178d60dca
7 changed files with 42 additions and 34 deletions

View File

@ -59,6 +59,7 @@ class Products extends BaseController
$ProductModel = new ProductModel();
$tax= $this->request->getPost('tax')/2;
$data = [
'product_name' => $this->request->getPost('productname'),
@ -67,12 +68,13 @@ class Products extends BaseController
'serial_no' => $this->request->getPost('serial_no'),
'unit_price' => $this->request->getPost('unit_price'),
'commision_rate' => $this->request->getPost('commision_rate'),
'sgst' => $this->request->getPost('sgst_value'),
'cgst' => $this->request->getPost('cgst_value'),
'sgst' => $tax,
'cgst' => $tax,
'purchase_cost' => $this->request->getPost('purchase_cost'),
'qty'=> $this->request->getPost('qty_in_stock'),
'qty_stock'=> $this->request->getPost('qty_in_stock'),
'qty_in_demand'=> $this->request->getPost('qty_in_demand'),
'description' => $this->request->getPost('description'),
'vendor' => $this->request->getPost('vendor'),
'isactive' => 1 ,
'branch_id' => $this->session->get('logged_user_branch_id')
];

View File

@ -123,7 +123,7 @@ $data['product']=$product;
$status = $this->request->getPost('status');
foreach ($product_ids as $key => $product_id) {
$qty = isset($quantities[$key]) ? $quantities[$key] : 0;
if ($status == 'InvoiceGenerated') {
if ($status == 'Paid') {
// echo"hello";die;
// Calculate updated quantity and update Product table
$this->updateProductQuantity($ProductModel, $product_id, $qty);
@ -232,8 +232,8 @@ public function delete_sales_product()
'format' => 'A5',
'default_font_size' => 0,
'default_font' => '',
'margin_left' => 2,
'margin_right' => 2,
// 'margin_right' => 1,
'margin_top' => 6,
'margin_bottom' => 6,
'margin_header' => 6,
@ -249,9 +249,7 @@ public function delete_sales_product()
$mpdf->SetAuthor($data[0]->branch_name);
$mpdf->SetCreator('');
$htmlFooter='<div >
<img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png"style=margin-top:70px;/> </div>';
$mpdf->setHTMLFooter($htmlFooter);
// Generate the PDF content (HTML)
if ($data[0]->status === 'Draft') {
@ -273,7 +271,7 @@ public function delete_sales_product()
// Generate the PDF content (HTML) with data
$html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items]);
// echo $html;die;
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);

View File

@ -5,7 +5,7 @@ class ProductModel extends Model
{
protected $table = 'products';
protected $primaryKey = 'product_id';
protected $allowedFields = ['product_id','product_name','branch_id','search_tag','product_category','mfr_part_no','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
protected $allowedFields = ['product_id','product_name','branch_id','search_tag','product_category','mfr_part_no','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
public function getTax()

View File

@ -143,7 +143,7 @@ p {
<?php foreach ($sales as $value) : ?>
<tr>
<td class="business-logo-container"style="font-size: 25px;
<td class="business-logo-container"style="font-size: 20px;
font-weight: bold;">
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"> -->
THE MECHANIC
@ -154,7 +154,7 @@ p {
<p><?= $value->company_address ?>,<br>
<?= $value->company_city ?>,
<?= $value->company_state ?>
<?= $value->company_postal_code ? " - ".$value->company_postal_code:"" ?>.</p>
<?= $value->company_postal_code ?>.</p>
<p><?= $value->company_mobile_no ?></p>
</td>
@ -180,11 +180,11 @@ p {
</table>
<table class="addresses-table">
<tr>
<tr >
<th class="billing-address">Billing Address</th>
</tr>
<tr>
<tr >
<td class="billing-address">
<?php foreach ($sales as $value) : ?>
<?= $value->client_name ?><br>
@ -208,9 +208,9 @@ p {
<tr>
<th>S.no</th>
<th>Item Name</th>
<th>Qty</th>
<th>Rate</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
@ -224,8 +224,9 @@ p {
</td>
<td><?= $item->product_name ?></td>
<td><?= $item->qty ?></td>
<td><?= number_format($item->net_price, 2, '.', ',') ?></td>
<td><?= $item->qty ?></td>
<td><?= number_format($item->amount, 2, '.', ',') ?></td>

View File

@ -41,7 +41,7 @@
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Vendor</label>
<input type="text" class="form-control" name="vendor" placeholder="Vendor"value="<?= isset($products['vendor_id']) ? $products['vendor_id'] : '' ?>" required>
<input type="text" class="form-control" name="vendor" placeholder="Vendor"value="<?= isset($products['vendor']) ? $products['vendor'] : '' ?>" required>
</div>
</div>
<input type="hidden" id="product_id" name="product_id" value="<?= isset($products['product_id']) ? $products['product_id'] : '' ?>"><br>
@ -49,26 +49,30 @@
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Unit Price</label>
<input type="number" class="form-control" name="unit_price" placeholder="City"value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required>
<input type="number" class="form-control" name="unit_price" placeholder="Price"value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required>
</div>
<div class="form-group col-md-4" hidden>
<label for="inputPassword4" class="col-form-label">Commision Rate</label>
<input type="number" class="form-control" name="commision_rate" placeholder="Commision Rate"value="<?= isset($products['commision_rate']) ? $products['commision_rate'] : '' ?>" required>
<input type="number" class="form-control" name="commision_rate" placeholder="Commision Rate"value="<?= isset($products['commision_rate']) ? $products['commision_rate'] : '' ?>" >
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Purchase Cost</label>
<input type="number" class="form-control" name="purchase_cost" placeholder="Purchase Cost"value="<?= isset($products['purchase_cost']) ? $products['purchase_cost'] : '' ?>" required>
</div>
<div class="form-group col-md-2">
<label for="inputPassword4" class="col-form-label">Sgst</label>
<input type="number" class="form-control d-none" name="sgst_value" id="sgstValue" placeholder="SGST" value="<?= isset($products['sgst']) ? $products['sgst'] : '9' ?>">
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax</label>
<?php
$sgst = isset($products['sgst']) ? $products['sgst'] : 9; // SGST value (half of the tax amount)
$cgst = isset($products['cgst']) ? $products['cgst'] : 9; // CGST value (half of the tax amount)
$tax = $sgst + $cgst; // Total tax (sum of SGST and CGST)
?>
<input type="number" class="form-control d-none" name="tax" id="sgstValue" placeholder="Tax" value="<?= $tax ?>">
</div>
<div class="form-group col-md-2">
<label for="inputPassword4" class="col-form-label">Cgst</label>
<input type="number" class="form-control d-none" name="cgst_value" id="cgstValue" placeholder="CGST" value="<?= isset($products['cgst']) ? $products['cgst'] : '9' ?>">
</div>
</div><br>
<h4 class="header-title">Stock Information :</h4><br>
<div class="form-row">
@ -78,7 +82,7 @@
</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'] : '' ?>" required>
<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>

View File

@ -70,9 +70,9 @@
<td><?= $value['total']; ?></td>
<td>
<a href="<?= "new_sale/" . $value['sales_order_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
<?php if ($value['status'] == 'InvoiceGenerated') : ?>
<a href="<?= "download_invoice/" . $value['sales_order_id']; ?>" class="edit-button"><i class="ri-file-download-line"></i></a>
<?php endif; ?>
<a href="<?= "delete_sale/" . $value['sales_order_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
</td>

View File

@ -41,7 +41,7 @@
<select class="form-control status-select" name="status" required data-toggle="select2">
<!-- <option value="">Select a Status</option> -->
<option value="Created" <?= isset($sales['status']) && $sales['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
<option value="InvoiceGenerated" <?= isset($sales['status']) && $sales['status'] === 'InvoiceGenerated' ? 'selected' : '' ?>>Generate Invoice</option>
<option value="Paid" <?= isset($sales['status']) && $sales['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
</select>
</div>
@ -198,7 +198,10 @@
</textarea>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<?php if (!isset($sales['status']) || $sales['status'] !== 'Paid') : ?>
<button type="submit" class="btn btn-primary">Submit</button>
<?php endif; ?>
</form>
</div>
</div>