ok

Mini Shell

Direktori : /home2/selectio/www/mm-tailor-billing/app/models/
Upload File :
Current File : //home2/selectio/www/mm-tailor-billing/app/models/Customers_model.php

<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Customers_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getCustomerDetails($customerid)
    {
        $this->db->order_by('id', 'asc');
        $q = $this->db->get_where('customers', ['id' => $customerid]);
        if ($q->num_rows() > 0) {
            foreach (($q->result()) as $row) {
                $data[] = $row;
            }
            return $data;
        }
    }
    
    public function addCustomer($data = [])
    {
        if ($this->db->insert('customers', $data)) {
            return $this->db->insert_id();
        }
        return false;
    }

    public function deleteCustomer($id)
    {
        if ($this->db->delete('customers', ['id' => $id])) {
            return true;
        }
        return false;
    }

    public function getCustomerByID($id)
    {
        $q = $this->db->get_where('customers', ['id' => $id], 1);
        if ($q->num_rows() > 0) {
            return $q->row();
        }
        return false;
    }

    public function updateCustomer($id, $data = [])
    {
        if ($this->db->update('customers', $data, ['id' => $id])) {
            return true;
        }
        return false;
    }
    
    public function getSalesByCustomerID($customer_id)
    {
         $this->db->select('id,hold_ref,(SELECT FORMAT((SUM(tec_sale_items.quantity)),0) from tec_sale_items LEFT JOIN tec_products ON tec_sale_items.product_id=tec_products.id where tec_sale_items.sale_id=tec_sales.id and tec_products.pant_shirt_category=1) as pant_count,(SELECT FORMAT((SUM(tec_sale_items.quantity)),0) from tec_sale_items LEFT JOIN tec_products ON tec_sale_items.product_id=tec_products.id where tec_sale_items.sale_id=tec_sales.id and tec_products.pant_shirt_category=2) as shirt_count,date,unit_process_status,grand_total,paid,sale_date', false);
      
         $q = $this->db->get_where('sales', ['customer_id' => $customer_id]);
         if ($q->num_rows() > 0) {
             foreach (($q->result()) as $row) {
                 $data[] = $row;
             }
             return $data;
         }
         return false;
    }
    
}

Zerion Mini Shell 1.0