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

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

    public function tb_scan_out($tgl)
    {
        return $this->db->query("SELECT C.barang,COUNT(A.no_lot) AS qty_out
        FROM tb_scan_out A
        LEFT JOIN (SELECT kode_fg,sku FROM tb_fg_gudang) B ON B.kode_fg = A.no_lot 
        LEFT JOIN (SELECT sku,barang FROM tb_fg) C ON C.sku = B.sku
        WHERE DATE(A.scan_time) = '$tgl' AND A.gudang_asal = 5
        GROUP BY C.barang;")->result_array();
    }

    public function tb_scan_in($tgl)
    {
        return $this->db->query("SELECT C.barang,COUNT(A.no_lot) AS qty_out
        FROM tb_scan_mutasi A
        LEFT JOIN (SELECT kode_fg,sku FROM tb_fg_gudang) B ON B.kode_fg = A.no_lot 
        LEFT JOIN (SELECT sku,barang FROM tb_fg) C ON C.sku = B.sku
        WHERE DATE(A.scan_time) = '$tgl' AND A.gudang_asal = 5
        GROUP BY C.barang;")->result_array();
    }
}
