Modify Packaging Php

0

Hello, I want to modify the packaging.php

Name, quantity, category and unit price. I have structured something like this according to the logic that I see from the SMA, but it still doesn't work, can you please help me:

<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th><?= lang('name'); ?></th>
<th><?= lang('quantity'); ?></th>
<th><?= lang('category'); ?></th> <!-- th add category -->
<th><?= lang('unit-price'); ?></th> <!-- th add price -->
</tr>
</thead>
<tbody>

        <?php foreach ($packaging as $item) {
            echo '<tr>';
            echo '<td>' . $item['name'] . '</td>';
            echo '<td>' . $this->sma->formatQuantity($item['quantity']) . ' '. $item['unit'] . '</td>';
            echo '<td>' . $item['category'] . '</td>'; // add category
            echo '<td>' . $this->sma->formatDecimal($product->tax_method ? $product->price + $ctax['amount'] : $product->price) . '</td>'; // Add unit price
            echo '</tr>';
        } ?>
Question Resolved For: Stock Manager Advance with All Modules 0 Votes 3 Answers 661 Views
Asked by maxventasweb 1 year ago

0

Answered by Enyinnaya Gift

Hi [[@maxventasweb](/u/maxventasweb)](/u/maxventasweb) . Replace the entire code in Packaging.php in the code below.

<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                <i class="fa fa-2x">&times;</i>
            </button>
            <button type="button" class="btn btn-xs btn-default no-print pull-right" style="margin-right:15px;" onclick="window.print();">
                <i class="fa fa-print"></i> <?= lang('print'); ?>
            </button>
            <h4 class="modal-title" id="myModalLabel"><?= lang('packaging'); ?></h4>
        </div>
        <div class="modal-body">
            <div class="well well-sm">
                <?= lang('biller') . ': ' . $sale->biller; ?><br>
                <?= lang('reference') . ': ' . $sale->reference_no; ?><br>
                <?= lang('warehouse') . ': ' . $warehouse->name . ' (' . $warehouse->code . ')'; ?>
            </div>
            <div class="table-responsive">
                <table class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <th><?= lang('name'); ?></th>
                            <th><?= lang('quantity'); ?></th>
                            <th><?= lang('category'); ?></th>
                            <th><?= lang('unit_price'); ?></th>
                        </tr>
                    </thead>
                    <tbody>

                    <?php foreach ($packaging as $item) {
                        echo '<tr>';
                        echo '<td>' . $item['name'] . '</td>';
                        echo '<td>' . $this->sma->formatQuantity($item['quantity']) . ' ' . $item['unit'] . '</td>';
                        echo '<td>' . $item['category'] . '</td>';
                        echo '<td>' . $item['unit_price'] . '</td>';
                        echo '</tr>';
                    } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

Then in the controller script Sales.php , directory path app\controllers\admin\Sales.php, replace the Packaging() function in line 1637 to 1659 with the code below.

public function packaging($id)
    {
        $sale                   = $this->sales_model->getInvoiceByID($id);
        $this->data['returned'] = false;
        if ($sale->sale_status == 'returned' || $sale->return_id) {
            $this->data['returned'] = true;
        }
        $this->data['warehouse'] = $this->site->getWarehouseByID($sale->warehouse_id);
        $items                   = $this->sales_model->getAllInvoiceItems($sale->id);
        foreach ($items as $item) {
            $packaging[] = [
                'name'     => $item->product_code . ' - ' . $item->product_name,
                'quantity' => $item->quantity,
                'unit'     => $item->product_unit_code,
                'rack'     => $this->sales_model->getItemRack($item->product_id, $sale->warehouse_id),
                'category' => $item->cat_name.' ('.$item->cat_code.')',
                'unit_price' => $item->unit_price,
            ];
        }
        $this->data['packaging'] = $packaging;
        $this->data['sale']      = $sale;

        $this->load->view($this->theme . 'sales/packaging', $this->data);
    }

Finally in the model script Sales_model.php , directory path app\models\admin\Sales_model.php, replace the getAllInvoiceItems() function in line 245 to 268 with the code below.

public function getAllInvoiceItems($sale_id, $return_id = null)
    {
        $this->db->select('sale_items.*, tax_rates.code as tax_code, tax_rates.name as tax_name, tax_rates.rate as tax_rate, products.image, products.details as details, product_variants.name as variant, products.hsn_code as hsn_code, products.second_name as second_name, products.unit as base_unit_id, units.code as base_unit_code, categories.code as cat_code, categories.name as cat_name')
            ->join('products', 'products.id=sale_items.product_id', 'left')
            ->join('product_variants', 'product_variants.id=sale_items.option_id', 'left')
            ->join('tax_rates', 'tax_rates.id=sale_items.tax_rate_id', 'left')
            ->join('units', 'units.id=products.unit', 'left')
            ->join('categories', 'products.category_id=categories.id', 'left')
            ->group_by('sale_items.id')
            ->order_by('id', 'asc');
        if ($sale_id && !$return_id) {
            $this->db->where('sale_id', $sale_id);
        } elseif ($return_id) {
            $this->db->where('sale_id', $return_id);
        }
        $q = $this->db->get('sale_items');
        if ($q->num_rows() > 0) {
            foreach (($q->result()) as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
    }

My name is @Enyinnaya Gift . I am an Independent software developer with in-depth knowledge of SMA system. I have done a lot of customization for many happy clients across the globe.

You can check out highlights and a demo of my latest customization by Clicking HERE - Highlights

You can also reach me via any of the following mediums for a real-time discussion on your customization request:

-Skype ID: enyinnayag
-Wechat ID: genyinnaya
-Email: [email protected]
-WhatsApp: +2348068355192

0

Answered by maxventasweb 1 year ago

You are amazing, it worked perfectly, thank you very much, I will not hesitate to hire you in future developments 😃

0

Answered by Mian Saleem 1 year ago

Thank you @Enyinnaya Gift for help 😃

We use Cookies

We use cookies to ensure that we give you the best experience on our website. By continuing to browse the site you are agreeing to our use of cookies.