Trong Reports_model :

public function getShipping($date, $warehouse_id = NULL, $year = NULL, $month = NULL)
    {
        $sdate = $date.' 00:00:00';
        $edate = $date.' 23:59:59';
        $this->db->select('SUM( COALESCE( shipping, 0 ) ) AS shipping', FALSE);
        if ($date) {
            $this->db->where('date >=', $sdate)->where('date <=', $edate);
        } elseif ($month) {
            $this->load->helper('date');
            $last_day = days_in_month($month, $year);
            $this->db->where('date >=', $year.'-'.$month.'-01 00:00:00');
            $this->db->where('date <=', $year.'-'.$month.'-'.$last_day.' 23:59:59');
        }

        if ($warehouse_id) {
            $this->db->where('warehouse_id', $warehouse_id);
        }

        $q = $this->db->get('sales');
        if ($q->num_rows() > 0) {
      
            return $q->row();
        }
        return false;
    }

Trong controller : Reports.php trong function profit

$this->data['shipping'] = $this->reports_model->getShipping($date, $warehouse_id);

Trong views

<tr>
                    <td style="border-bottom: 1px solid #DDD;"><h4><?= lang('shipping'); ?>:</h4></td>
                    <td style="text-align:right;border-bottom: 1px solid #DDD;"><h4>
                               <span><?php $shipping = $shipping ? $shipping->shipping : 0; echo $this->sma->formatMoney($shipping); ?></span>
                        
                        </h4></td>
                </tr>

Và trừ đi phí ship ở đây

<td style="text-align:right;"><h4>
                            <span><strong><?= $this->sma->formatMoney($costing->sales - $costing->cost - $discount - $expense - $shipping); ?></strong></span>
                            <!-- <span><strong><?= $this->sma->formatMoney($costing->sales - $costing->cost - $discount - $expense).' ('.$this->sma->formatMoney($costing->net_sales - $costing->net_cost - $discount - $expense).')'; ?></strong></span> -->
                        </h4></td>

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *