copy dari repo om Irfan

This commit is contained in:
2026-06-13 16:02:07 +10:00
commit db327c0305
5376 changed files with 2770667 additions and 0 deletions
+135
View File
@@ -0,0 +1,135 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class AbsensiModel extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_Absensi_byKARYAWAN_byTGL_forSync($id, $tgl) {
$this->db->select('*');
$this->db->from('absensi');
$this->db->where('KARYAWAN_ID=', $id);
$this->db->where('TGL_ABSENSI=', $tgl);
return $this->db->get()->result_array();
}
public function getData_SalesVisit_groupSALES_status0() {
$this->db->select('*');
$this->db->from('sales_visit');
$this->db->where('STATUS_SAV=0');
$this->db->group_by('SALES_ID');
return $this->db->get()->result_array();
}
public function getData_SalesVisit_bySALES_status0($id) {
$this->db->select('*');
$this->db->from('sales_visit');
$this->db->where('STATUS_SAV=0');
$this->db->where('SALES_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_DaftarSalesVisit_bySAV_orderDESC_limit1($id) {
$this->db->select('*');
$this->db->from('daftar_salesvisit a');
$this->db->join('sales_visit b','b.ID_SAV=a.SAV_ID');
$this->db->where('a.SAV_ID=', $id);
$this->db->order_by('a.ID_DSAV DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getDataAbsensi()
{
$this->db->select('*, b.NAMA_PANGGILAN_KARYAWAN');
$this->db->from('absensi a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.KARYAWAN_ID');
return $this->db->get()->result_array();
}
public function getCetak($bulan_awal, $tahun_awal, $bulan, $tahun)
{
$this->db->select('*, b.NAMA_PANGGILAN_KARYAWAN');
$this->db->from('absensi a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.KARYAWAN_ID');
//$this->db->where('a.TGL_ABSENSI LIKE "' . $tahun . '-' . $bulan . '%" ORDER BY a.KARYAWAN_ID ASC, a.TGL_ABSENSI ASC');
$this->db->where('a.TGL_ABSENSI >= "' . $tahun_awal . '-' . $bulan_awal . '-26"');
$this->db->where('a.TGL_ABSENSI <= "' . $tahun . '-' . $bulan . '-25" ORDER BY a.KARYAWAN_ID ASC, a.TGL_ABSENSI ASC');
// SELECT KARYAWAN_ID, COUNT(*)
// FROM absensi
// WHERE TELAT="YA"
// GROUP BY KARYAWAN_ID;
return $this->db->get()->result_array();
}
public function cekAbsensi($id, $tgl)
{
$this->db->select('*');
$this->db->from('absensi');
$this->db->where('KARYAWAN_ID=' . $id );
$this->db->where('TGL_ABSENSI = "' . $tgl . '" ORDER BY JAM_MASUK DESC LIMIT 1');
return $this->db->get()->result_array();
}
//belum bisa dipakai
public function total_telat($id)
{
//$telat='YA';
$this->db->select('*');
$this->db->from('absensi');
$this->db->where('KARYAWAN_ID ="' . $id . '" AND TELAT = "YA"');
//SELECT * FROM `absensi` WHERE KARYAWAN_ID = '1' AND TELAT = 'YA';
return $this->db->count_all_results();
}
public function getTelat()
{
$this->db->select('KARYAWAN_ID, COUNT(*)');
$this->db->from('absensi');
$this->db->where('TELAT="YA" GROUP BY KARYAWAN_ID');
return $this->db->get()->result_array();
//return $this->db->query("SELECT KARYAWAN_ID, COUNT(*) FROM absensi WHERE TELAT='YA' GROUP BY KARYAWAN_ID");
}
public function getDetailAbsensi($bulan_awal, $tahun_awal, $bulan_akhir, $tahun_akhir)
{
$this->db->select('*, b.NAMA_PANGGILAN_KARYAWAN, (SELECT COUNT(*) FROM absensi WHERE TELAT="YA" AND KARYAWAN_ID=b.ID_KARYAWAN AND TGL_ABSENSI BETWEEN "' . $tahun_awal . '-' . $bulan_awal . '-26" AND "' . $tahun_akhir . '-' . $bulan_akhir . '-25") AS TOTAL_TELAT ');
$this->db->from('absensi a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where('a.TGL_ABSENSI >= "' . $tahun_awal . '-' . $bulan_awal . '-26"');
$this->db->where('a.TGL_ABSENSI <= "' . $tahun_akhir . '-' . $bulan_akhir . '-25" ORDER BY a.KARYAWAN_ID ASC, a.TGL_ABSENSI ASC');
return $this->db->get()->result_array();
// select *, b.NAMA_PANGGILAN_KARYAWAN, (SELECT COUNT(*) AS TOTAL_TELAT
// FROM absensi
// WHERE TELAT="YA" AND KARYAWAN_ID="7")
// from absensi a
// join karyawan b on b.ID_KARYAWAN=a.KARYAWAN_ID
// where a.TGL_ABSENSI >= "2020-03-26" AND a.TGL_ABSENSI <= "2020-04-25" ORDER BY a.KARYAWAN_ID ASC, a.TGL_ABSENSI ASC
}
}
File diff suppressed because it is too large Load Diff
+123
View File
@@ -0,0 +1,123 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class KaryawanModel extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getDataKaryawan($id = null)
{
if ($id === null) {
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->join('cabang c', 'c.KODE_CABANG=b.CABANG_KODE');
$this->db->order_by('a.STATUS_KARYAWAN DESC');
$this->db->order_by('a.ID_KARYAWAN ASC ');
} else {
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->join('cabang c', 'c.KODE_CABANG=b.CABANG_KODE');
$this->db->where(['ID_KARYAWAN' => $id]);
$this->db->order_by('a.STATUS_KARYAWAN DESC');
$this->db->order_by('a.ID_KARYAWAN ASC ');
}
return $this->db->get()->result_array();
}
public function getDataKaryawan_Cabang_Kode($kode)
{
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->join('cabang c', 'c.KODE_CABANG=b.CABANG_KODE');
$this->db->where(['b.CABANG_KODE' => $kode]);
$this->db->order_by('a.STATUS_KARYAWAN DESC');
$this->db->order_by('a.ID_KARYAWAN ASC ');
return $this->db->get()->result_array();
}
public function getDataKaryawan1()
{
$this->db->select('*');
$this->db->from('karyawan ');
$this->db->where(['JABATAN_ID' => null]);
return $this->db->get()->result_array();
}
public function cekPass($id, $pass)
{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
$this->db->where(['PASSWORD' => $pass]);
return $this->db->get()->result_array();
}
public function getDataCabang()
{
$this->db->select('*');
$this->db->from('cabang');
return $this->db->get()->result_array();
}
public function getKodeCabangByIdKaryawan($id)
{
$this->db->select('b.CABANG_KODE');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->where(['ID_KARYAWAN' => $id]);
return $this->db->get()->result_array();
}
public function getDataKaryawanByKodeCabang($kode)
{
$this->db->select('a.ID_KARYAWAN, a.NAMA_KARYAWAN');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->join('cabang c', 'c.KODE_CABANG=a.CABANG_KODE');
$this->db->where(['c.KODE_CABANG' => $kode]);
$this->db->where(['a.STATUS_KARYAWAN' => 1]);
$this->db->order_by('a.ID_KARYAWAN ASC ');
return $this->db->get()->result_array();
}
public function getIdKaryawanTerakhir($cabang)
{
$this->db->select('ID_KARYAWAN');
$this->db->from('karyawan');
$this->db->like('ID_KARYAWAN', $cabang, 'after');
$this->db->order_by('IK DESC');
$this->db->limit(1);
return $this->db->get()->result_array();
}
public function getUsername($username)
{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['USERNAME' => $username]);
return $this->db->get()->result_array();
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelAgen extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getDataAgen($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('agen');
}else{
$this->db->select('*');
$this->db->from('agen');
$this->db->where(['ID_AGEN' => $id]);
}
return $this->db->get()->result_array();
}
public function getKodeAgen(){
$this->db->select('CONCAT(NAMA_AGEN,"|",TGL) as COBA');
$this->db->from('agen');
return $this->db->get()->result_array();
}
public function getDataTeknisi($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('operator');
$this->db->where('ID_OPERATOR >=3');
}else{
$this->db->select('*');
$this->db->from('operator');
$this->db->where('ID_OPERATOR >=3');
}
return $this->db->get()->result_array();
}
public function cekPass($id, $pass)
{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
$this->db->where(['PASSWORD' => $pass]);
return $this->db->get()->result_array();
}
}
?>
+684
View File
@@ -0,0 +1,684 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ModelBantuan extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
//Model addTempo
public function addTimeMinutes($time, $minutes)
{
$sum = strtotime(date("H:i:s", strtotime("$time")) . " +$minutes minutes");
$dateTo = date('H:i:s', $sum);
return $dateTo;
}
//Model getCount
public function getCount_CetakDokumen_Service()
{
$this->db->select('ID_CD');
$this->db->from('cetak_dokumen');
$this->db->where('SERVICE_ID is NOT NULL');
$this->db->where('LP_KARYAWAN is NULL');
return $this->db->count_all_results();
}
public function getCount_KlaimService_0_2()
{
$this->db->select('ID_KSV');
$this->db->from('klaim_service');
$this->db->where('STATUS_KSV=0 OR STATUS_KSV=2');
return $this->db->count_all_results();
}
public function getCount_OrderService_NonDATANG()
{
$this->db->select('ID_OS');
$this->db->from('order_service');
$this->db->where('DATANG_OS is NULL');
return $this->db->count_all_results();
}
public function getCount_Service_0()
{
$this->db->select('ID_SERVICE');
$this->db->from('service');
$this->db->where('STATUS_SERVICE=0');
return $this->db->count_all_results();
}
//Model getData
public function getData_Agen_byID($id = null)
{
if ($id == null) {
$this->db->select('*');
$this->db->from('agen');
} else {
$this->db->select('*');
$this->db->from('agen');
$this->db->where('ID_AGEN=', $id);
}
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forSERVICE_Null()
{
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('cetak_dokumen a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('sn_service c', 'c.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->join('brgsv f', 'f.ID_BRGSV=c.BRGSV_ID');
$this->db->where('a.STATUS_CD is NULL');
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forSERVICE_0_1()
{
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('cetak_dokumen a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('sn_service c', 'c.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->join('brgsv f', 'f.ID_BRGSV=c.BRGSV_ID');
$this->db->where('a.STATUS_CD=0 OR a.STATUS_CD=1');
$this->db->order_by('a.ID_CD DESC');
$this->db->limit('100');
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_byID($id)
{
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('cetak_dokumen a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('sn_service c', 'c.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->join('brgsv f', 'f.ID_BRGSV=c.BRGSV_ID');
$this->db->where('a.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_Karyawan_forLogin($username, $password)
{
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->where('a.USERNAME=', $username);
$this->db->where('a.PASSWORD=', $password);
return $this->db->get()->result_array();
}
public function getData_KlaimService_0_2($id = null)
{
if ($id == null) {
$this->db->select('*,DATE_FORMAT(a.TGL_KSV,"%d/%m/%Y") as TANGGAL');
$this->db->from('klaim_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('agen c', 'c.ID_AGEN=a.AGEN_ID');
$this->db->join('sn_service d', 'd.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan e', 'e.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota f', 'f.ID_KOTA=e.KOTA_ID', 'left');
$this->db->join('karyawan g', 'g.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=d.BRGSV_ID', 'left');
$this->db->where('a.STATUS_KSV=0 OR a.STATUS_KSV=2');
} else {
$this->db->select('*');
$this->db->from('klaim_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('agen c', 'c.ID_AGEN=a.AGEN_ID');
$this->db->join('sn_service d', 'd.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan e', 'e.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota f', 'f.ID_KOTA=e.KOTA_ID', 'left');
$this->db->join('karyawan g', 'g.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=d.BRGSV_ID', 'left');
$this->db->where('a.STATUS_KSV=0 OR a.STATUS_KSV=2');
$this->db->where('a.ID_KSV=', $id);
}
return $this->db->get()->result_array();
}
public function getData_KlaimService_1_3($id = null)
{
if ($id == null) {
$this->db->select('*,DATE_FORMAT(a.TGL_KSV,"%d/%m/%Y") as TANGGAL');
$this->db->from('klaim_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('agen c', 'c.ID_AGEN=a.AGEN_ID');
$this->db->join('sn_service d', 'd.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan e', 'e.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota f', 'f.ID_KOTA=e.KOTA_ID', 'left');
$this->db->join('karyawan g', 'g.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=d.BRGSV_ID', 'left');
$this->db->where('a.STATUS_KSV=1 OR a.STATUS_KSV=3');
} else {
$this->db->select('*');
$this->db->from('klaim_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('agen c', 'c.ID_AGEN=a.AGEN_ID');
$this->db->join('sn_service d', 'd.SERVICE_ID=b.ID_SERVICE');
$this->db->join('pelanggan e', 'e.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota f', 'f.ID_KOTA=e.KOTA_ID', 'left');
$this->db->join('karyawan g', 'g.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=d.BRGSV_ID', 'left');
$this->db->where('a.STATUS_KSV=1 OR a.STATUS_KSV=3');
$this->db->where('a.ID_KSV=', $id);
}
return $this->db->get()->result_array();
}
public function getData_LogService_byID($id)
{
$this->db->select('*');
$this->db->from('log_service a');
$this->db->join('sn_service b', 'b.ID_SNS=a.SNS_ID');
$this->db->join('service c', 'c.ID_SERVICE=b.SERVICE_ID');
$this->db->join('karyawan d', 'd.ID_KARYAWAN=a.TEKNISI_ID', 'left');
$this->db->where('a.ID_LSV=', $id);
return $this->db->get()->result_array();
}
public function getData_LogService_bySNS($id)
{
$this->db->select('*,DATE_FORMAT(a.TGL_LSV,"%d/%m/%Y") as TANGGAL');
$this->db->from('log_service a');
$this->db->join('sn_service b', 'b.ID_SNS=a.SNS_ID');
$this->db->join('service c', 'c.ID_SERVICE=b.SERVICE_ID');
$this->db->join('karyawan d', 'd.ID_KARYAWAN=a.TEKNISI_ID', 'left');
$this->db->where('a.SNS_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_OrderService_forInput()
{
$this->db->select('*, c.NAMA_KOTA AS NAMA_KOTA_SUPPLIER, e.NAMA_KOTA AS NAMA_KOTA_PELANGGAN,
CONCAT("Rp ",FORMAT(a.HARGA_OS,2)) as HARGA,DATE_FORMAT(a.REQUEST_OS,"%d/%m/%Y") as REQUEST');
$this->db->from('order_service a');
$this->db->join('supplier b', 'b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c', 'c.ID_KOTA=b.KOTA_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->where('a.DATANG_OS is NULL');
return $this->db->get()->result_array();
}
public function getData_OrderService_forRevisi()
{
$this->db->select('*,c.NAMA_KOTA AS NAMA_KOTA_SUPPLIER, e.NAMA_KOTA AS NAMA_KOTA_PELANGGAN,
CONCAT("Rp ",FORMAT(a.HARGA_OS,2)) as HARGA,DATE_FORMAT(a.REQUEST_OS,"%d/%m/%Y") as REQUEST,
DATE_FORMAT(a.DATANG_OS,"%d/%m/%Y") as DATANG');
$this->db->from('order_service a');
$this->db->join('supplier b', 'b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c', 'c.ID_KOTA=b.KOTA_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->where('a.DATANG_OS is NOT NULL');
return $this->db->get()->result_array();
}
public function getData_Pelanggan_byID($id = null)
{
if ($id == null) {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->order_by('a.TYPE_PELANGGAN ASC');
} else {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->where('a.ID_PELANGGAN=', $id);
}
return $this->db->get()->result_array();
}
public function getData_SalesOrder_forService()
{
$this->db->select('*,DATE_FORMAT(TGL_SO,"%d/%m/%Y") as TANGGAL');
$this->db->from('sales_order');
$this->db->where('STATUS_SO=1');
return $this->db->get()->result_array();
}
public function getData_Service_byID($id)
{
$this->db->select('*');
$this->db->from('service');
$this->db->where('ID_SERVICE=', $id);
return $this->db->get()->result_array();
}
public function getData_Service_forKlaimService()
{
$this->db->select('*');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID', 'left');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=a.GUDANG_ID_1', 'left');
$this->db->order_by('a.ID_SERVICE DESC');
$this->db->limit('100');
return $this->db->get()->result_array();
}
public function getData_SnService_byID($id)
{
$this->db->select('*');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->where('a.ID_SNS=', $id);
return $this->db->get()->result_array();
}
public function getData_SnService_bySERVICE_Not1($id = null)
{
if ($id == null) {
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID', 'left');
$this->db->join('daftar_service f', 'f.ID_DFS=a.DFS_ID', 'left');
$this->db->join('barang g', 'g.ID_BARANG=f.BARANG_ID', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=a.BRGSV_ID', 'left');
$this->db->group_by('a.ID_SNS');
$this->db->where('a.STATUS_SNS!="2" OR a.STATUS_SNS is NULL');
} else {
$this->db->select('*');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID', 'left');
$this->db->join('daftar_service f', 'f.ID_DFS=a.DFS_ID', 'left');
$this->db->join('barang g', 'g.ID_BARANG=f.BARANG_ID', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=a.BRGSV_ID', 'left');
$this->db->group_by('a.ID_SNS');
$this->db->where('a.STATUS_SNS!="2" OR a.STATUS_SNS is NULL');
$this->db->where('a.SERVICE_ID=', $id);
}
return $this->db->get()->result_array();
}
public function getData_SnService_bySERVICE_1($id = null)
{
if ($id == null) {
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID', 'left');
$this->db->join('daftar_service f', 'f.ID_DFS=a.DFS_ID', 'left');
$this->db->join('barang g', 'g.ID_BARANG=f.BARANG_ID', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=a.BRGSV_ID', 'left');
$this->db->group_by('a.ID_SNS');
$this->db->where('a.STATUS_SNS="2"');
} else {
$this->db->select('*');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=b.GUDANG_ID_1', 'left');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID', 'left');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID', 'left');
$this->db->join('daftar_service f', 'f.ID_DFS=a.DFS_ID', 'left');
$this->db->join('barang g', 'g.ID_BARANG=f.BARANG_ID', 'left');
$this->db->join('brgsv h', 'h.ID_BRGSV=a.BRGSV_ID', 'left');
$this->db->group_by('a.ID_SNS');
$this->db->where('a.STATUS_SNS="2"');
$this->db->where('a.SERVICE_ID=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Supplier_byID($id = null)
{
if ($id == null) {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->order_by('a.NAMA_SUPPLIER', 'ASC');
} else {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->where('a.ID_SUPPLIER=', $id);
}
return $this->db->get()->result_array();
}
public function getDataService($id = null)
{
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d %M %Y %H:%i")) AS WAKTU,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d/%m/%Y")) AS TERIMA');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->order_by('ID_SERVICE', 'ASC');
} else {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d %M %Y %H:%i")) AS WAKTU,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d/%m/%Y")) AS TERIMA');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->where(['ID_SERVICE' => $id]);
$this->db->order_by('ID_SERVICE', 'ASC');
}
return $this->db->get()->result_array();
}
public function getDataServiceNull($id = null)
{
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d %M %Y %H:%i")) AS WAKTU');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->order_by('ID_SERVICE', 'ASC');
$this->db->where('a.PROGRESS_ID is NULL', NULL, FALSE);
} else {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d %M %Y %H:%i")) AS WAKTU');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->where(['ID_SERVICE' => $id]);
$this->db->order_by('ID_SERVICE', 'ASC');
$this->db->where('a.PROGRESS_ID is NULL', NULL, FALSE);
}
return $this->db->get()->result_array();
}
public function getDataClaimNull($id = null)
{
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d %M %Y %H:%i")) AS WAKTU');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->join('progress e', 'e.ID_PROGRESS=a.PROGRESS_ID', 'left');
$this->db->join('garansi f', 'f.ID_GARANSI=e.GARANSI_ID', 'left');
$this->db->order_by('ID_SERVICE', 'ASC');
$this->db->where('e.GARANSI_ID is null');
$this->db->or_where('e.STATUS_PROGRESS="Claim Garansi"');
}
return $this->db->get()->result_array();
}
public function getDataUpClaimNull($id = null)
{
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TANGGAL_SERVICE,"%d %M %Y %H:%i")) AS WAKTU');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->join('progress e', 'e.ID_PROGRESS=a.PROGRESS_ID', 'left');
$this->db->join('claimdell f', 'f.ID_CLAIMDELL=a.CLAIMDELL_ID', 'left');
$this->db->order_by('ID_SERVICE', 'ASC');
$this->db->where('e.STATUS_PROGRESS="Claim Garansi"');
$this->db->where('f.NOSER_CLAIMDELL is null');
}
return $this->db->get()->result_array();
}
public function getDataServiceID($id = null)
{
if ($id === null) {
$this->db->select('a.ID_SERVICE');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->where('a.PROGRESS_ID is NULL', NULL, FALSE);
} else {
$this->db->select('a.ID_SERVICE');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->where('a.PROGRESS_ID is NULL', NULL, FALSE);
}
return $this->db->get()->result_array();
}
public function getDataServiceClaim($id = null)
{
if ($id === null) {
$this->db->select('*');
$this->db->from('service a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('operator d', 'd.ID_OPERATOR=a.OPERATOR_ID');
$this->db->join('progress e', 'e.ID_PROGRESS=a.PROGRESS_ID', 'left');
$this->db->join('garansi f', 'f.ID_GARANSI=e.GARANSI_ID', 'left');
}
return $this->db->get()->result_array();
}
public function getDataClaimdellID($id = null)
{
if ($id === null) {
$this->db->select_max('ID_CLAIMDELL');
$this->db->from('claimdell');
} else {
$this->db->select_max('ID_CLAIMDELL');
$this->db->from('claimdell');
}
return $this->db->get()->result_array();
}
public function getIDService($id = null)
{
if ($id === null) {
$this->db->select_max('ID_SERVICE');
$this->db->from('service');
} else {
$this->db->select_max('ID_SERVICE');
$this->db->from('service');
}
return $this->db->get()->result_array();
}
public function getIDProgress($id = null)
{
if ($id === null) {
$this->db->select_max('ID_PROGRESS');
$this->db->from('progress');
} else {
$this->db->select_max('ID_PROGRESS');
$this->db->from('progress');
}
return $this->db->get()->result_array();
}
public function getIDGaransi($id = null)
{
if ($id === null) {
$this->db->select_max('ID_GARANSI');
$this->db->from('garansi');
} else {
$this->db->select_max('ID_GARANSI');
$this->db->from('garansi');
}
return $this->db->get()->result_array();
}
public function getIDInternal($id = null)
{
if ($id === null) {
$this->db->select_max('ID_INTERNAL');
$this->db->from('internal');
} else {
$this->db->select_max('ID_INTERNAL');
$this->db->from('internal');
}
return $this->db->get()->result_array();
}
public function getIDOutlet($id = null)
{
if ($id === null) {
$this->db->select_max('ID_OUTLET');
$this->db->from('outlet');
} else {
$this->db->select_max('ID_OUTLET');
$this->db->from('outlet');
}
return $this->db->get()->result_array();
}
public function getGaransiID($id = null)
{
if ($id === null) {
$this->db->select('GARANSI_ID');
$this->db->from('progress');
} else {
$this->db->select('GARANSI_ID');
$this->db->from('progress');
$this->db->where(['ID_PROGRESS' => $id]);
}
return $this->db->get()->result_array();
}
public function getOutletID($id = null)
{
if ($id === null) {
$this->db->select('OUTLET_ID');
$this->db->from('service');
} else {
$this->db->select('c.ID_OUTLET');
$this->db->from('service a');
$this->db->join('progress b', 'b.ID_PROGRESS=a.PROGRESS_ID');
$this->db->join('outlet c', 'c.ID_OUTLET=a.OUTLET_ID');
$this->db->where(['b.ID_PROGRESS' => $id]);
}
return $this->db->get()->result_array();
}
public function getInternalID($id = null)
{
if ($id === null) {
$this->db->select('INTERNAL_ID');
$this->db->from('service');
} else {
$this->db->select('c.ID_INTERNAL');
$this->db->from('service a');
$this->db->join('progress b', 'b.ID_PROGRESS=a.PROGRESS_ID');
$this->db->join('internal c', 'c.ID_INTERNAL=a.INTERNAL_ID');
$this->db->where(['b.ID_PROGRESS' => $id]);
}
return $this->db->get()->result_array();
}
public function getCountService($id = null)
{
if ($id === null) {
$this->db->select('ID_SERVICE');
$this->db->from('service');
} else {
$this->db->select('ID_SERVICE');
$this->db->from('service');
}
return $this->db->count_all_results();
}
public function getDataProgressService($id = null)
{
if ($id === null) {
$this->db->select_max('ID_PROGRESS');
$this->db->from('progress');
} else {
$this->db->select_max('ID_PROGRESS');
$this->db->from('progress');
}
return $this->db->get()->result_array();
}
public function cekPass($id, $pass)
{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
$this->db->where(['PASSWORD' => $pass]);
return $this->db->get()->result_array();
}
public function getExcel_OrderService_All($start, $end)
{
$this->db->select('*, c.NAMA_KOTA AS NAMA_KOTA_SUPPLIER,CONCAT("Rp ",FORMAT(a.HARGA_OS,2)) as HARGA,
e.NAMA_KOTA AS NAMA_KOTA_PELANGGAN,DATE_FORMAT(a.REQUEST_OS, "%d/%m/%Y") AS REQUEST,DATE_FORMAT(a.DATANG_OS, "%d/%m/%Y") AS DATANG');
$this->db->from('order_service a');
$this->db->join('supplier b', 'b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c', 'c.ID_KOTA=b.KOTA_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->where('a.DATANG_OS is NULL');
$this->db->where('a.REQUEST_OS>=', $start);
$this->db->where('a.REQUEST_OS<=', $end);
return $this->db->get()->result_array();
}
public function getExcel_OrderService_bySupplier($start, $end, $m_supplier)
{
$this->db->select('*,c.NAMA_KOTA AS NAMA_KOTA_SUPPLIER,CONCAT("Rp ",FORMAT(a.HARGA_OS,2)) as HARGA,
e.NAMA_KOTA AS NAMA_KOTA_PELANGGAN,DATE_FORMAT(a.REQUEST_OS, "%d/%m/%Y") AS REQUEST,DATE_FORMAT(a.DATANG_OS, "%d/%m/%Y") AS DATANG');
$this->db->from('order_service a');
$this->db->join('supplier b', 'b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c', 'c.ID_KOTA=b.KOTA_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->where('a.DATANG_OS is NULL');
$this->db->where('a.REQUEST_OS>=', $start);
$this->db->where('a.REQUEST_OS<=', $end);
$this->db->where(['b.ID_SUPPLIER' => $m_supplier]);
return $this->db->get()->result_array();
}
}
+672
View File
@@ -0,0 +1,672 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ModelCetak extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_CetakDokumen_forSJPenjualan($level=null, $awal=null , $akhir=null) { // Cetak = [1]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('penjualan b', 'b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->join('sales_order c', 'c.ID_SO=b.SO_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=c.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
if ($level == 0) {
$this->db->where('c.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('c.CORP_ID>=4');
}
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=0');
$this->db->not_like('a.KODE_BUKTI', '.');
$this->db->order_by('a.TGL_CD DESC, a.ID_CD DESC');
return $this->db->get()->result_array();
}
public function getData_DaftarOrder_byCD($id) { // Cetak = [2, 5, 20, 24]
$this->db->select('*,FORMAT(a.HARGA_DO,2) as HARGA');
$this->db->from('daftar_order a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('penjualan c', 'c.SO_ID=b.ID_SO');
$this->db->join('cetak_dokumen d', 'd.PENJUALAN_ID=c.ID_PENJUALAN');
$this->db->join('barang e', 'e.ID_BARANG=a.BARANG_ID');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byCD($id) { // Cetak = [2, 5, 20, 24, 35]
$this->db->select('*,DATE_FORMAT(c.TGL_CETAK,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(b.TEMPO_PENJUALAN,"%d/%m/%Y") as TEMPO');
$this->db->from('sales_order a');
$this->db->join('penjualan b', 'b.SO_ID=a.ID_SO');
$this->db->join('cetak_dokumen c', 'c.PENJUALAN_ID=b.ID_PENJUALAN');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->join('karyawan f', 'f.ID_KARYAWAN=a.SALES_ID');
$this->db->where('c.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SnJual_byBARANG_forSJPenjualan($id1, $id2) { // Cetak = [2, 5, 24]
$this->db->select('a.NAMA_SNJ');
$this->db->from('sn_jual a');
$this->db->join('daftar_order b', 'b.ID_DO=a.DO_ID');
$this->db->join('barang c', 'c.ID_BARANG=b.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('b.ID_DO=', $id2);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_byID_forPenjualan($id) { // Cetak = [3, 4, 21, 22, 23, 33, 34, 36]
$this->db->select('*');
$this->db->from('cetak_dokumen a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->join('sales_order c','c.ID_SO=b.SO_ID');
$this->db->join('pelanggan d','d.ID_PELANGGAN=c.PELANGGAN_ID');
$this->db->where('a.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function addTempoDay($date, $day) { // Cetak = [4, 5, 22, 24]
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days");
$dateTo=date('Y-m-d', $sum);
return $dateTo;
}
public function getData_CetakDokumen_forSJMutasiBarang() { // Cetak = [6]
$this->db->select('*,DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL,c.NAMA_PANGGILAN_KARYAWAN as PEMBERI');
$this->db->from('cetak_dokumen a');
$this->db->join('mutasi_barang b', 'b.ID_MB=a.MB_ID');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=b.ADMIN_ID');
$this->db->where('a.SJ_INV=0');
$this->db->order_by('a.ID_CD DESC');
return $this->db->get()->result_array();
}
public function getData_DaftarMutasiBarang_byCD_forSJMutasiBarang($id) { // Cetak = [7, 8, 9]
$this->db->select('*');
$this->db->from('daftar_mutasibarang a');
$this->db->join('mutasi_barang b', 'b.ID_MB=a.MB_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('cetak_dokumen d', 'd.MB_ID=b.ID_MB');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_MutasiBarang_byCD($id) { // Cetak = [7, 8, 9]
$this->db->select('*,DATE_FORMAT(b.TGL_CETAK,"%d/%m/%Y") as TANGGAL');
$this->db->from('mutasi_barang a');
$this->db->join('cetak_dokumen b', 'b.MB_ID=a.ID_MB');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=a.ADMIN_ID');
$this->db->where('b.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SnMutasiBarang_byDMB($id) { // Cetak = [7, 8]
$this->db->select('*');
$this->db->from('sn_mutasibarang a');
$this->db->join('daftar_mutasibarang b','b.ID_DMB=a.DMB_ID');
$this->db->where(['a.DMB_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnMutasiBarang_byBARANG_forSJMutasiBarang($id1, $id2) { // Cetak = [9]
$this->db->select('a.NAMA_SNMB');
$this->db->from('sn_mutasibarang a');
$this->db->join('daftar_mutasibarang b', 'b.ID_DMB=a.DMB_ID');
$this->db->join('barang c', 'c.ID_BARANG=b.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('b.ID_DMB=', $id2);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forSJKonsinyasi($level=null, $awal=null , $akhir=null) { // Cetak = [10]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('konsinyasi b', 'b.ID_KONSINYASI=a.KONSINYASI_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->where('b.JENIS_KONSINYASI=', $level);
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=0');
$this->db->order_by('a.TGL_CD ASC, a.ID_CD ASC');
return $this->db->get()->result_array();
}
public function getData_DaftarKonsi_byCD_forSJKonsinyasi($id) { // Cetak = [11, 12]
$this->db->select('*');
$this->db->from('daftar_konsi a');
$this->db->join('konsinyasi b', 'b.ID_KONSINYASI=a.KONSINYASI_ID');
$this->db->join('cetak_dokumen c', 'c.KONSINYASI_ID=b.ID_KONSINYASI');
$this->db->join('barang d', 'd.ID_BARANG=a.BARANG_ID');
$this->db->where('c.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_Konsinyasi_byCD($id) { // Cetak = [11, 12]
$this->db->select('*,DATE_FORMAT(b.TGL_CETAK,"%d/%m/%Y") as TANGGAL');
$this->db->from('konsinyasi a');
$this->db->join('cetak_dokumen b', 'b.KONSINYASI_ID=a.ID_KONSINYASI');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->where('b.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SnKonsi_byBARANG_forSJKonsinyasi($id1, $id2) { // Cetak = [11, 12]
$this->db->select('a.NAMA_SNK');
$this->db->from('sn_konsi a');
$this->db->join('daftar_konsi b', 'b.ID_DFK=a.DFK_ID');
$this->db->join('barang c', 'c.ID_BARANG=b.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('b.ID_DFK=', $id2);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forSJPeminjaman() { // Cetak = [13]
$this->db->select('*,DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL');
$this->db->from('cetak_dokumen a');
$this->db->join('peminjaman b', 'b.ID_PEMINJAMAN=a.PEMINJAMAN_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->where('a.SJ_INV=0');
$this->db->order_by('a.ID_CD DESC');
return $this->db->get()->result_array();
}
public function getData_DaftarPinjam_byCD_forSJPeminjaman($id) { // Cetak = [14, 15]
$this->db->select('*');
$this->db->from('daftar_pinjam a');
$this->db->join('peminjaman b', 'b.ID_PEMINJAMAN=a.PEMINJAMAN_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->join('cetak_dokumen d', 'd.PEMINJAMAN_ID=b.ID_PEMINJAMAN');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_Peminjaman_byCD($id) { // Cetak = [14, 15, 16]
$this->db->select('*,DATE_FORMAT(b.TGL_CETAK,"%d/%m/%Y") as TANGGAL');
$this->db->from('peminjaman a');
$this->db->join('cetak_dokumen b', 'b.PEMINJAMAN_ID=a.ID_PEMINJAMAN');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->where('b.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SnPinjam_byDFP($id) { // Cetak = [14]
$this->db->select('*');
$this->db->from('sn_pinjam a');
$this->db->join('daftar_pinjam b','b.ID_DFP=a.DFP_ID');
$this->db->where(['a.DFP_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnPinjam_byBARANG_forSJPeminjaman($id1, $id2) { // Cetak = [15]
$this->db->select('a.NAMA_SNP');
$this->db->from('sn_pinjam a');
$this->db->join('daftar_pinjam b', 'b.ID_DFP=a.DFP_ID');
$this->db->join('barang c', 'c.ID_BARANG=b.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('b.ID_DFP=', $id2);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forSJTarikKonsi($level=null, $awal=null , $akhir=null) { // Cetak = [16]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('penarikan_konsi b', 'b.ID_PK=a.PK_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->where('b.JENIS_PK=', $level);
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=0');
$this->db->order_by('a.TGL_CD ASC, a.ID_CD ASC');
return $this->db->get()->result_array();
}
public function getData_DaftarPenarikanKonsi_byCD_forSJPenarikanKonsi($id) { // Cetak = [17, 18]
$this->db->select('*');
$this->db->from('daftar_penarikankonsi a');
$this->db->join('penarikan_konsi b', 'b.ID_PK=a.PK_ID');
$this->db->join('cetak_dokumen c', 'c.PK_ID=b.ID_PK');
$this->db->join('barang d', 'd.ID_BARANG=a.BARANG_ID');
$this->db->where('c.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_PenarikanKonsi_byCD($id) { // Cetak = [17, 18]
$this->db->select('*,DATE_FORMAT(b.TGL_CETAK,"%d/%m/%Y") as TANGGAL');
$this->db->from('penarikan_konsi a');
$this->db->join('cetak_dokumen b', 'b.PK_ID=a.ID_PK');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->where('b.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SnKonsi_byBARANG_forSJTarikKonsi($id1, $id2) { // Cetak = [17, 18]
$this->db->select('a.NAMA_SNK');
$this->db->from('sn_konsi a');
$this->db->join('daftar_konsi b', 'b.ID_DFK=a.DFK_ID');
$this->db->join('daftar_penarikankonsi c', 'c.PK_ID=a.PK_ID');
$this->db->where('b.BARANG_ID=c.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('c.ID_DPK=', $id2);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forNotaPenjualan($level=null, $awal=null , $akhir=null) { // Cetak = [19]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('penjualan b', 'b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->join('sales_order c', 'c.ID_SO=b.SO_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=c.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
if ($level == 0) {
$this->db->where('c.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('c.CORP_ID>=4');
}
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=1');
$this->db->not_like('a.KODE_BUKTI', '.');
$this->db->order_by('a.TGL_CD DESC, a.ID_CD DESC');
return $this->db->get()->result_array();
}
public function getData_DaftarOrder_bySO($id) { // Cetak = [20, 29]
$this->db->select('*,FORMAT(a.HARGA_DO,2) as HARGA');
$this->db->from('daftar_order a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->where('a.SO_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_PiutangDagang_byPENJUALAN($id) { // Cetak = [21, 23]
$this->db->select('*');
$this->db->from('piutang_dagang');
$this->db->where(['PENJUALAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarOrder_byPENJUALAN($id) { // Cetak = [21, 23]
$this->db->select('*');
$this->db->from('daftar_order a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('penjualan c', 'c.SO_ID=b.ID_SO');
$this->db->where('c.ID_PENJUALAN=', $id);
return $this->db->get()->result_array();
}
public function getSum_DaftarOrder_byCD_forNotaPenjualan($id) { // Cetak = [24]
$this->db->select('SUM(a.QTY_DO*a.HARGA_DO) as TOTAL');
$this->db->from('daftar_order a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('penjualan c', 'c.SO_ID=b.ID_SO');
$this->db->join('cetak_dokumen d', 'd.PENJUALAN_ID=c.ID_PENJUALAN');
$this->db->join('barang e', 'e.ID_BARANG=a.BARANG_ID');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forNotaReturBeli($level=null, $awal=null , $akhir=null) { // Cetak = [25]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('retur_pembelian b', 'b.ID_RB=a.RB_ID');
$this->db->join('pembelian c', 'c.ID_PEMBELIAN=b.PEMBELIAN_ID');
$this->db->join('supplier d', 'd.ID_SUPPLIER=c.SUPPLIER_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
if ($level == 0) {
$this->db->where('c.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('c.CORP_ID=5');
}
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=1');
$this->db->order_by('a.TGL_CD ASC, a.ID_CD ASC');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byCD($id) { // Cetak = [26, 27]
$this->db->select('*,FORMAT(a.HARGA_DRB,2) as HARGA');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b', 'b.ID_RB=a.RB_ID');
$this->db->join('pembelian c', 'c.ID_PEMBELIAN=b.PEMBELIAN_ID');
$this->db->join('cetak_dokumen d', 'd.RB_ID=b.ID_RB');
$this->db->join('barang e', 'e.ID_BARANG=a.BARANG_ID');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_ReturPembelian_byCD($id) { // Cetak = [26, 27]
$this->db->select('*,DATE_FORMAT(b.TGL_CETAK,"%d/%m/%Y") as TANGGAL');
$this->db->from('retur_pembelian a');
$this->db->join('cetak_dokumen b', 'b.RB_ID=a.ID_RB');
$this->db->join('pembelian c', 'c.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->join('supplier d', 'd.ID_SUPPLIER=c.SUPPLIER_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->join('karyawan f', 'f.ID_KARYAWAN=a.ADMIN_ID');
$this->db->where('b.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byRB($id) { // Cetak = [26]
$this->db->select('*,FORMAT(a.HARGA_DRB,2) as HARGA');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b', 'b.ID_RB=a.RB_ID');
$this->db->join('barang c', 'c.ID_BARANG=a.BARANG_ID');
$this->db->where('a.RB_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SnReturBeli_byBARANG_forNotaReturBeli($id1, $id2) { // Cetak = [27]
$this->db->select('a.NAMA_SNRB');
$this->db->from('sn_returbeli a');
$this->db->join('daftar_returbeli b', 'b.ID_DRB=a.DRB_ID');
$this->db->join('barang c', 'c.ID_BARANG=b.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('b.ID_DRB=', $id2);
return $this->db->get()->result_array();
}
public function getSum_DaftarReturBeli_byCD_forNotaReturBeli($id) { // Cetak = [27]
$this->db->select('SUM(a.QTY_DRB*a.HARGA_DRB) as TOTAL');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b', 'b.ID_RB=a.RB_ID');
$this->db->join('pembelian c', 'c.ID_PEMBELIAN=b.PEMBELIAN_ID');
$this->db->join('cetak_dokumen d', 'd.RB_ID=b.ID_RB');
$this->db->join('barang e', 'e.ID_BARANG=a.BARANG_ID');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forNotaProforma($level=null, $id_karyawan=null, $jabatan=null, $awal=null , $akhir=null) { // Cetak = [28]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->join('karyawan e', 'e.ID_KARYAWAN=b.SALES_ID');
$this->db->join('jabatan f', 'f.ID_JABATAN=e.JABATAN_ID');
if ($level == 0) {
$this->db->where('b.CORP_ID<=3');
} else if ($level == 1) {
$this->db->where('b.CORP_ID>=4');
}
if ($id_karyawan==1 OR $jabatan=="KEUANGAN" OR $jabatan=="ADMIN KEUANGAN" OR $jabatan=="ADMIN ITP") {
} else {
$this->db->where('b.SALES_ID=', $id_karyawan);
}
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=1');
$this->db->order_by('a.TGL_CD ASC, a.ID_CD ASC');
return $this->db->get()->result_array();
}
public function getData_DaftarOrder_byCD_forNotaProforma($id) { // Cetak = [29, 30]
$this->db->select('*,FORMAT(a.HARGA_DO,2) as HARGA');
$this->db->from('daftar_order a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('cetak_dokumen c', 'c.SO_ID=b.ID_SO');
$this->db->join('barang d', 'd.ID_BARANG=a.BARANG_ID');
$this->db->where('c.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byCD_forNotaProforma($id) { // Cetak = [29, 30]
$this->db->select('*,DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TANGGAL');
$this->db->from('cetak_dokumen a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->join('karyawan e', 'e.ID_KARYAWAN=b.SALES_ID');
$this->db->where('a.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getSum_DaftarOrder_byCD_forNotaProforma($id) { // Cetak = [30]
$this->db->select('SUM(a.QTY_DO*a.HARGA_DO) as TOTAL');
$this->db->from('daftar_order a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('cetak_dokumen c', 'c.SO_ID=b.ID_SO');
$this->db->join('barang d', 'd.ID_BARANG=a.BARANG_ID');
$this->db->where('c.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_CetakDokumen_forSJParsial($level=null, $awal=null , $akhir=null) { // Cetak = [31]
$this->db->select('*, DATE_FORMAT(a.TGL_CD,"%d/%m/%Y") as TANGGAL, DATE_FORMAT(a.TGL_CETAK,"%d/%m/%Y") as TGLCTK');
$this->db->from('cetak_dokumen a');
$this->db->join('penjualan b', 'b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->join('sales_order c', 'c.ID_SO=b.SO_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=c.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
if ($level == 0) {
$this->db->where('c.CORP_ID<=3');
} else if ($level == 1) {
$this->db->where('c.CORP_ID>=4');
}
$this->db->where('a.TGL_CD>=', $awal);
$this->db->where('a.TGL_CD<=', $akhir);
$this->db->where('a.SJ_INV=0');
$this->db->like('a.KODE_BUKTI', '.');
$this->db->order_by('a.TGL_CD ASC, a.ID_CD ASC');
return $this->db->get()->result_array();
}
public function getData_DaftarSjParsial_byCD_forSJParsial($id) { // Cetak = [32, 35]
$this->db->select('*');
$this->db->from('daftar_sjparsial a');
$this->db->join('sales_order b', 'b.ID_SO=a.SO_ID');
$this->db->join('penjualan c', 'c.SO_ID=b.ID_SO');
$this->db->join('cetak_dokumen d', 'd.ID_CD=a.CD_ID');
$this->db->join('barang e', 'e.ID_BARANG=a.BARANG_ID');
$this->db->where('d.ID_CD=', $id);
return $this->db->get()->result_array();
}
public function getData_SnSj_byBARANG_forSJParsial($id1, $id2) { // Cetak = [32, 35]
$this->db->select('a.NAMA_SNSJ');
$this->db->from('sn_sjparsial a');
$this->db->join('daftar_sjparsial b', 'b.ID_SJP=a.SJP_ID');
$this->db->join('barang c', 'c.ID_BARANG=b.BARANG_ID');
$this->db->where('b.BARANG_ID=', $id1);
$this->db->where('b.ID_SJP=', $id2);
return $this->db->get()->result_array();
}
public function getData_SlipManual_forSlipManual() { // Cetak = [AWW]
$this->db->select('*,a.CORP_ID as CID,a.SO_ID as SID,DATE_FORMAT(a.TGL_SM, "%d/%m/%Y") as TANGGAL');
$this->db->from('slip_manual a');
$this->db->join('corp b', 'b.ID_CORP=a.CORP_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('karyawan d', 'd.ID_KARYAWAN=a.ADMIN_ID');
$this->db->join('kota e', 'e.ID_KOTA=c.KOTA_ID');
$this->db->join('proyek f', 'f.ID_PROYEK=a.PROYEK_ID','left');
$this->db->join('sales_order g', 'g.ID_SO=a.SO_ID','left');
$this->db->order_by('a.ID_SM DESC');
$this->db->limit('100');
return $this->db->get()->result_array();
}
public function getData_DaftarSlipManual_SMNull($id = null) { // Cetak = [AWW]
if ($id == null) {
$id_karyawan = $this->session->userdata('id_karyawan');
$this->db->select('*,CONCAT("Rp ",FORMAT(HARGA_DSM,2)) as HARGA');
$this->db->from('daftar_slipmanual');
$this->db->where('SM_ID is NULL');
$this->db->where('KARYAWAN_ID=', $id_karyawan);
} else {
$this->db->select('*,CONCAT("Rp ",FORMAT(HARGA_DSM,2)) as HARGA');
$this->db->from('daftar_slipmanual');
$this->db->where('SM_ID is NULL');
$this->db->where('ID_DSM=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Proyek($id=null) { // Cetak = [AWW]
if ($id==null) {
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->order_by('a.PO_PROYEK ASC, a.ID_PROYEK DESC');
} else {
$this->db->select('*');
$this->db->from('proyek');
$this->db->where('ID_PROYEK=', $id);
}
return $this->db->get()->result_array();
}
public function getData_SalesOrder($id=null) { // Cetak = [AWW]
if ($id==null) {
$this->db->select('*');
$this->db->from('sales_order a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->where('a.STATUS_SO=1');
$this->db->order_by('a.ID_SO DESC');
} else {
$this->db->select('*');
$this->db->from('sales_order');
$this->db->where('ID_SO=', $id);
}
return $this->db->get()->result_array();
}
public function getKode_SJPenjualanDMT() { // Cetak = [AWW]
$this->db->select('MAX(KODE_SM) AS KODE');
$this->db->from('slip_manual');
$this->db->like('KODE_SM','SJ/DMT', 'after');
return $this->db->get()->result_array();
}
public function getKode_SJPenjualanPCM() { // Cetak = [AWW]
$this->db->select('MAX(KODE_SM) AS KODE');
$this->db->from('slip_manual');
$this->db->like('KODE_SM','SJ/PCM', 'after');
return $this->db->get()->result_array();
}
public function getKode_SJPenjualanTMP() { // Cetak = [AWW]
$this->db->select('MAX(KODE_SM) AS KODE');
$this->db->from('slip_manual');
$this->db->like('KODE_SM','SJ/TMP', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVPenjualanDMT() { // Cetak = [AWW]
$this->db->select('MAX(KODE_SM) AS KODE');
$this->db->from('slip_manual');
$this->db->like('KODE_SM','INV/DMT', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVPenjualanPCM() { // Cetak = [AWW]
$this->db->select('MAX(KODE_SM) AS KODE');
$this->db->from('slip_manual');
$this->db->like('KODE_SM','INV/PCM', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVPenjualanTMP() { // Cetak = [AWW]
$this->db->select('MAX(KODE_SM) AS KODE');
$this->db->from('slip_manual');
$this->db->like('KODE_SM','INV/TMP', 'after');
return $this->db->get()->result_array();
}
public function getID_SlipManual() { // Cetak = [AWW]
$this->db->select_max('ID_SM');
$this->db->from('slip_manual');
return $this->db->get()->result_array();
}
public function getData_DaftarSlipManual_byKARYAWAN($id) { // Cetak = [AWW]
$this->db->select('*');
$this->db->from('daftar_slipmanual');
$this->db->where('KARYAWAN_ID=', $id);
$this->db->where('SM_ID is NULL');
return $this->db->get()->result_array();
}
public function getData_SlipManual_byID_forSJManual($id) { // Cetak = [AWW]
$this->db->select('*,DATE_FORMAT(a.TGL_SM, "%d/%m/%Y") as TANGGAL');
$this->db->from('slip_manual a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c', 'c.ID_KOTA=b.KOTA_ID');
$this->db->where('a.ID_SM=', $id);
return $this->db->get()->result_array();
}
public function getData_DaftarSlipManual_byID_forSJManual($id) { // Cetak = [AWW]
$this->db->select('*');
$this->db->from('daftar_slipmanual a');
$this->db->join('slip_manual b', 'b.ID_SM=a.SM_ID');
$this->db->where('a.SM_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SlipManual_byID_forNotaManual($id) { // Cetak = [AWW]
$this->db->select('*,a.CORP_ID as CID,DATE_FORMAT(a.TGL_SM, "%d/%m/%Y") as TANGGAL,DATE_FORMAT(f.TEMPO_PENJUALAN, "%d/%m/%Y") as TEMPO');
$this->db->from('slip_manual a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c', 'c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d', 'd.ID_KARYAWAN=a.SALES_ID');
$this->db->join('sales_order e', 'e.ID_SO=a.SO_ID');
$this->db->join('penjualan f', 'f.SO_ID=e.ID_SO');
$this->db->where('a.ID_SM=', $id);
return $this->db->get()->result_array();
}
public function getData_DaftarSlipManual_byID_forNotaManual($id) { // Cetak = [AWW]
$this->db->select('*');
$this->db->from('daftar_slipmanual a');
$this->db->join('slip_manual b', 'b.ID_SM=a.SM_ID');
$this->db->join('sales_order c', 'c.ID_SO=b.SO_ID');
$this->db->join('penjualan d', 'd.SO_ID=c.ID_SO');
$this->db->where('a.SM_ID=', $id);
return $this->db->get()->result_array();
}
public function getSum_DaftarSlipManual_byID_forNotaManual($id) { // Cetak = [AWW]
$this->db->select('SUM(a.QTY_DSM*a.HARGA_DSM) as TOTAL');
$this->db->from('daftar_slipmanual a');
$this->db->join('slip_manual b', 'b.ID_SM=a.SM_ID');
$this->db->where('a.SM_ID=', $id);
return $this->db->get()->result_array();
}
}
+106
View File
@@ -0,0 +1,106 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelDaftarHarga extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getDataDaftarHarga($id = null){
if ($id === null) {
$this->db->select('*,CONCAT("Rp ",FORMAT(d.DEALER_HSRP,2)) as DEALER,CONCAT("Rp ",FORMAT(d.USER_HSRP,2)) as USER
,CONCAT("Rp ",FORMAT(c.NILAI_HAVG,2)) as AVG,DATE_FORMAT(d.TGL_HSRP, "%d/%m/%Y") as TANGGAL_HSRP,
DATE_FORMAT(c.TGL_HAVG, "%d/%m/%Y") as TANGGAL_HAVG');
$this->db->from('barang a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->join('harga_avg c','c.BARANG_ID=a.ID_BARANG');
$this->db->join('harga_srp d','d.BARANG_ID=a.ID_BARANG','left');
$this->db->order_by('b.NAMA_JENIS ASC,a.KODE_BARANG ASC, d.ID_HSRP DESC, c.ID_HAVG DESC');
$this->db->where('a.JENIS_ID!=6');
$this->db->where('b.TYPE_JENIS!=2');
$this->db->limit('100');
}else{
$this->db->select('*,CONCAT("Rp ",FORMAT(b.DEALER_HSRP,2)) as DEALER,CONCAT("Rp ",FORMAT(b.USER_HSRP,2)) as USER,CONCAT("Rp ",FORMAT(c.NILAI_HAVG,2)) as AVG');
$this->db->from('barang a');
$this->db->join('harga_srp b','b.BARANG_ID=a.ID_BARANG','left');
$this->db->join('harga_avg c','c.BARANG_ID=a.ID_BARANG','left');
$this->db->join('jenis d','d.ID_JENIS=a.JENIS_ID','left');
$this->db->order_by('a.KODE_BARANG ASC, b.ID_HSRP DESC, c.ID_HAVG DESC');
$this->db->where('a.JENIS_ID!=6');
$this->db->where('d.TYPE_JENIS!=2');
$this->db->where(['a.ID_BARANG' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_DaftarHarga_forAdmin($id = null){
if ($id === null) {
$this->db->select('*,CONCAT("Rp ",FORMAT(d.DEALER_HSRP,2)) as DEALER,CONCAT("Rp ",FORMAT(d.USER_HSRP,2)) as USER
,CONCAT("Rp ",FORMAT(c.NILAI_HAVG,2)) as AVG,DATE_FORMAT(d.TGL_HSRP, "%d/%m/%Y") as TANGGAL_HSRP,
DATE_FORMAT(c.TGL_HAVG, "%d/%m/%Y") as TANGGAL_HAVG');
$this->db->from('barang a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->join('harga_avg c','c.BARANG_ID=a.ID_BARANG');
$this->db->join('harga_srp d','d.BARANG_ID=a.ID_BARANG','left');
$this->db->order_by('b.NAMA_JENIS ASC,a.KODE_BARANG ASC, d.ID_HSRP DESC, c.ID_HAVG DESC');
$this->db->where('a.JENIS_ID!=6');
$this->db->where('b.TYPE_JENIS!=2');
$this->db->limit('100');
}else{
$this->db->select('*,CONCAT("Rp ",FORMAT(b.DEALER_HSRP,2)) as DEALER,CONCAT("Rp ",FORMAT(b.USER_HSRP,2)) as USER,CONCAT("Rp ",FORMAT(c.NILAI_HAVG,2)) as AVG');
$this->db->from('barang a');
$this->db->join('harga_srp b','b.BARANG_ID=a.ID_BARANG','left');
$this->db->join('harga_avg c','c.BARANG_ID=a.ID_BARANG','left');
$this->db->join('jenis d','d.ID_JENIS=a.JENIS_ID','left');
$this->db->order_by('a.KODE_BARANG ASC, b.ID_HSRP DESC, c.ID_HAVG DESC');
$this->db->where('a.JENIS_ID!=6');
$this->db->where('d.TYPE_JENIS!=2');
$this->db->where(['a.ID_BARANG' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_DaftarHarga_forView($id = null){
$this->db->select('a.*,b.NAMA_JENIS,c.*,d.*,CONCAT("Rp ",FORMAT(d.DEALER_HSRP,2)) as DEALER,
CONCAT("Rp ",FORMAT(d.USER_HSRP,2)) as USER,CONCAT("Rp ",FORMAT(c.NILAI_HAVG,2)) as AVG,
DATE_FORMAT(d.TGL_HSRP, "%d/%m/%Y") as TANGGAL_HSRP,DATE_FORMAT(c.TGL_HAVG, "%d/%m/%Y") as TANGGAL_HAVG');
$this->db->from('barang a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->join('harga_avg c','c.BARANG_ID=a.ID_BARANG');
$this->db->join('harga_srp d','d.BARANG_ID=a.ID_BARANG');
$this->db->order_by('b.NAMA_JENIS ASC,a.KODE_BARANG ASC, d.ID_HSRP DESC, c.ID_HAVG DESC');
$this->db->where('a.JENIS_ID!=6');
$this->db->where('b.TYPE_JENIS!=2');
return $this->db->get()->result_array();
}
public function getData_HargaSrp_byBARANG($id){
$this->db->select('*');
$this->db->from('harga_srp');
$this->db->where(['BARANG_ID' => $id]);
return $this->db->get()->result_array();
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+436
View File
@@ -0,0 +1,436 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelKlaim extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_Supplier($id=null) { //Klaim = [1, 5A, 9A]
if ($id == null) {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
} else {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->where(['ID_SUPPLIER' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Merk($id=null) { //Klaim = [1, 3]
if ($id == null) {
$this->db->select('*');
$this->db->from('merk');
$this->db->order_by('NAMA_MERK ASC');
} else {
$this->db->select('*');
$this->db->from('merk');
$this->db->where(['ID_MERK' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_DaftarBeli_status1($supplier_id = null, $merk_id = null, $tgl_awal = null, $tgl_akhir = null) { //Klaim = [1]
$this->db->select('*,DATE_FORMAT(e.TGL_INVBELI,"%d/%m/%Y") as TANGGAL');
$this->db->from('daftar_beli a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->join('merk d','d.ID_MERK=b.MERK_ID');
$this->db->join('pembelian e','e.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->where('e.STATUS_PEMBELIAN=1');
$this->db->where('b.JENIS_ID<=8 AND b.JENIS_ID!=7 AND b.JENIS_ID!=6');
$this->db->where('e.SUPPLIER_ID=',$supplier_id);
$this->db->where('e.TGL_INVBELI>=',$tgl_awal);
$this->db->where('e.TGL_INVBELI<=',$tgl_akhir);
if ($merk_id!=null) {
$this->db->where('b.MERK_ID=',$merk_id);
}
$this->db->group_by('a.ID_DB, a.BARANG_ID');
$this->db->order_by('e.TGL_INVBELI ASC, e.INV_PEMBELIAN ASC, b.KODE_BARANG ASC');
return $this->db->get()->result_array();
}
public function getData_SnBeli_byDB_status1($id) { //Klaim = [1, 2]
$this->db->select('*');
$this->db->from('sn_beli a');
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
$this->db->join('pembelian c','c.ID_PEMBELIAN=b.PEMBELIAN_ID');
$this->db->join('sn_stock d','d.NAMA_SNSTOCK=a.NAMA_SNB');
$this->db->where(['b.ID_DB' => $id]);
$this->db->where('c.STATUS_PEMBELIAN=1');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_bySNSTOCK($id) { //Klaim = [1, 2, 3, 4]
$this->db->select('*');
$this->db->from('sn_klaimprogram');
$this->db->where(['SNSTOCK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getID_SNKPRMax() { //Klaim = [2, 4]
$this->db->select_max('ID_SNKPR');
$this->db->from('sn_klaimprogram');
return $this->db->get()->result_array();
}
public function getData_DaftarBeli_byDB($id) { //Klaim = [2]
$this->db->select('*');
$this->db->from('daftar_beli a');
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->where(['a.ID_DB' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarKlaimProgram_byBARANG_bySUPPLIER_byNOTA($id_barang, $id_supplier, $nota) { //Klaim = [2, 8, 10]
$this->db->select('*');
$this->db->from('daftar_klaimprogram');
$this->db->where(['BARANG_ID' => $id_barang]);
$this->db->where(['SUPPLIER_ID' => $id_supplier]);
$this->db->where(['NOTA_DKPR' => $nota]);
return $this->db->get()->result_array();
}
public function getID_DKPRMax() { //Klaim = [2, 4, 8, 10]
$this->db->select_max('ID_DKPR');
$this->db->from('daftar_klaimprogram');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_jenis1($merk_id = null) { //Klaim = [3]
$this->db->select('*');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->join('merk d','d.ID_MERK=b.MERK_ID');
$this->db->where('b.JENIS_ID=8 AND a.JENIS_IO=1 AND b.MERK_ID=', $merk_id);
$this->db->or_where('b.JENIS_ID<=5 AND a.JENIS_IO=1 AND b.MERK_ID=', $merk_id);
$this->db->group_by('a.ID_IO');
$this->db->order_by('b.KODE_BARANG ASC');
return $this->db->get()->result_array();
}
public function getData_SnIo_byID_jenis1($id) { //Klaim = [3, 4]
$this->db->select('*');
$this->db->from('sn_io a');
$this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID');
$this->db->join('sn_stock c','c.NAMA_SNSTOCK=a.NAMA_SNIO');
$this->db->where(['b.ID_IO' => $id]);
$this->db->where('a.JENIS_SNIO=1');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_byID($id) { //Klaim = [4]
$this->db->select('*');
$this->db->from('transaksi_stock');
$this->db->where(['ID_IO' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarKlaimProgram_byBARANG_jenis0($id) { //Klaim = [4]
$this->db->select('*');
$this->db->from('daftar_klaimprogram');
$this->db->where(['BARANG_ID' => $id]);
$this->db->where('JENIS_DKPR=0');
return $this->db->get()->result_array();
}
public function getData_DaftarKlaimProgram_AmbilPembelian() { //Klaim = [5]
$this->db->select('*,DATE_FORMAT(a.TGL_DKPR,"%d/%m/%Y") as TANGGAL,FORMAT(a.HARGA_DKPR,2) as HARGA');
$this->db->from('daftar_klaimprogram a');
$this->db->join('produk b','b.ID_PRODUK=a.PRODUK_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
$this->db->join('barang e','e.ID_BARANG=a.BARANG_ID');
$this->db->where('a.JENIS_DKPR=1');
$this->db->where('a.KUNCI_DKPR is NULL');
$this->db->order_by('a.ID_DKPR DESC');
$this->db->limit('500');
return $this->db->get()->result_array();
}
public function getCount_SnKlaimProgram_byBARANG_byDKPR($id_barang, $dkpr_id) { //Klaim = [5, 9, 12]
$this->db->select('a.ID_SNKPR');
$this->db->from('sn_klaimprogram a');
$this->db->join('sn_stock b','b.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->where('b.BARANG_ID=', $id_barang);
$this->db->where('a.DKPR_ID=', $dkpr_id);
return $this->db->count_all_results();
}
public function getData_DaftarKlaimProgram_byID($id) { //Klaim = [6, 7, 8, 9A, 10, 11, 13, 25, 26, 27]
$this->db->select('*,DATE_FORMAT(a.TGL_DKPR,"%d/%m/%Y") as TANGGAL');
$this->db->from('daftar_klaimprogram a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID','left');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID','left');
$this->db->where('a.ID_DKPR=', $id);
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_byDKPR($id) { //Klaim = [5A, 7, 9A, 11, 13]
$this->db->select('*,FORMAT(b.HARGA_DKPR,2) as HARGA');
$this->db->from('sn_klaimprogram a');
$this->db->join('daftar_klaimprogram b','b.ID_DKPR=a.DKPR_ID');
$this->db->join('sn_stock c','c.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->join('pelanggan d','d.ID_PELANGGAN=a.PEL_ID','left');
$this->db->where('a.DKPR_ID=', $id);
$this->db->order_by('c.NAMA_SNSTOCK ASC');
return $this->db->get()->result_array();
}
public function getData_LinkKlaimProgram_bySNKPR($id) { //Klaim = [7, 11, 13, 17, 18]
$this->db->select('*,FORMAT(a.NILAI_LKPR,2) as NILAI');
$this->db->from('link_klaimprogram a');
$this->db->join('program b','b.ID_PROGRAM=a.PROGRAM_ID');
$this->db->join('potongan_klaimprogram c','c.ID_PKPR=a.PKPR_ID');
$this->db->where(['a.SNKPR_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarKlaimProgram_AmbilOpname() { //Klaim = [9]
$this->db->select('*,DATE_FORMAT(a.TGL_DKPR,"%d/%m/%Y") as TANGGAL,FORMAT(a.HARGA_DKPR,2) as HARGA');
$this->db->from('daftar_klaimprogram a');
$this->db->join('produk b','b.ID_PRODUK=a.PRODUK_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('supplier d','d.ID_SUPPLIER=a.SUPPLIER_ID','left');
$this->db->join('kota e','e.ID_KOTA=d.KOTA_ID','left');
$this->db->where('a.JENIS_DKPR=0');
$this->db->order_by('a.ID_DKPR DESC');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_byID($id) { //Klaim = [8, 10, 14, 15, 16, 17, 21, 23, 24, 27]
$this->db->select('*');
$this->db->from('sn_klaimprogram');
$this->db->where(['ID_SNKPR' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarKlaimProgram_AmbilSemua() { //Klaim = [12]
$this->db->select('*,DATE_FORMAT(a.TGL_DKPR,"%d/%m/%Y") as TANGGAL,FORMAT(a.HARGA_DKPR,2) as HARGA');
$this->db->from('daftar_klaimprogram a');
$this->db->join('produk b','b.ID_PRODUK=a.PRODUK_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
$this->db->join('barang e','e.ID_BARANG=a.BARANG_ID');
$this->db->where('a.KUNCI_DKPR is NULL');
$this->db->order_by('a.ID_DKPR DESC');
return $this->db->get()->result_array();
}
public function getData_DaftarKlaimProgram_kunciNotNull() { //Klaim = [12]
$this->db->select('*,DATE_FORMAT(a.TGL_DKPR,"%d/%m/%Y") as TANGGAL,FORMAT(a.HARGA_DKPR,2) as HARGA');
$this->db->from('daftar_klaimprogram a');
$this->db->join('produk b','b.ID_PRODUK=a.PRODUK_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
$this->db->join('barang e','e.ID_BARANG=a.BARANG_ID');
$this->db->order_by('a.ID_DKPR DESC');
$this->db->where('a.KUNCI_DKPR=1');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_forRedirect() { //Klaim = [12]
$this->db->select('*');
$this->db->from('sn_klaimprogram');
$this->db->order_by('NAMA_SNKPR ASC');
return $this->db->get()->result_array();
}
public function getCount_SnKlaimProgram_byBARANG_byDKPR_NotNull($id_barang, $dkpr_id) { //Klaim = [12]
$this->db->select('a.ID_SNKPR');
$this->db->from('sn_klaimprogram a');
$this->db->join('sn_stock b','b.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->where('b.BARANG_ID=', $id_barang);
$this->db->where('a.DKPR_ID=', $dkpr_id);
$this->db->where('a.STATUS_SNKPR IS NOT NULL');
return $this->db->count_all_results();
}
public function getData_Pelanggan_byID($id=null) { //Klaim = [13, 19]
if ($id==null) {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
} else {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->where(['a.ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Program($id=null) { //Klaim = [13]
if ($id == null) {
$this->db->select('*');
$this->db->from('program');
$this->db->order_by('KODE_PROGRAM');
} else {
$this->db->select('*');
$this->db->from('program');
$this->db->where(['ID_PROGRAM' => $id]);
$this->db->order_by('KODE_PROGRAM');
}
return $this->db->get()->result_array();
}
public function getData_HistoriSn_bySNKPR($id) { //Klaim = [13]
$this->db->select('*');
$this->db->from('histori_sn a');
$this->db->join('sn_stock b','b.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->join('sn_klaimprogram c','c.SNSTOCK_ID=a.SNSTOCK_ID');
$this->db->where('c.ID_SNKPR=', $id);
$this->db->where('b.STATUS_SNSTOCK=1');
$this->db->where('a.PELANGGAN_ID is NOT NULL');
//$this->db->order_by('a.ID_HSN DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getData_HistoriSn_byID($id) { //Klaim = [13]
$this->db->select('*,DATE_FORMAT(a.TGL_HSN,"%d/%m/%Y") as TANGGAL');
$this->db->from('histori_sn a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->where('a.ID_HSN=', $id);
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_byDKPR_NULL($id) { //Klaim = [13, 18]
$this->db->select('*,FORMAT(b.HARGA_DKPR,2) as HARGA');
$this->db->from('sn_klaimprogram a');
$this->db->join('daftar_klaimprogram b','b.ID_DKPR=a.DKPR_ID');
$this->db->join('sn_stock c','c.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->where('a.DKPR_ID=', $id);
$this->db->where('a.STATUS_SNKPR is NULL');
$this->db->order_by('c.NAMA_SNSTOCK ASC');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_byDKPR_status0($id) { //Klaim = [13, 18]
$this->db->select('*,FORMAT(b.HARGA_DKPR,2) as HARGA');
$this->db->from('sn_klaimprogram a');
$this->db->join('daftar_klaimprogram b','b.ID_DKPR=a.DKPR_ID');
$this->db->join('sn_stock c','c.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->where('a.DKPR_ID=', $id);
$this->db->where('a.STATUS_SNKPR=0');
$this->db->order_by('c.NAMA_SNSTOCK ASC');
return $this->db->get()->result_array();
}
public function getData_PotonganKlaimProgram_byDKPR_groupPKPR($id) { //Klaim = [13]
$this->db->select('*,FORMAT(a.NILAI_LKPR,2) as NILAI');
$this->db->from('link_klaimprogram a');
$this->db->join('sn_klaimprogram b','b.ID_SNKPR=a.SNKPR_ID');
$this->db->join('potongan_klaimprogram c','c.ID_PKPR=a.PKPR_ID');
$this->db->where('b.DKPR_ID=', $id);
$this->db->group_by('a.PKPR_ID');
$this->db->order_by('c.NAMA_PKPR ASC');
return $this->db->get()->result_array();
}
public function getData_PotonganKlaimProgram_byNAMA_byNILAI($id1, $id2) { //Klaim = [14]
$this->db->select('*');
$this->db->from('potongan_klaimprogram');
$this->db->where('NAMA_PKPR=', $id1);
$this->db->where('NILAI_PKPR=', $id2);
return $this->db->get()->result_array();
}
public function getID_PKPRMax() { //Klaim = [14]
$this->db->select_max('ID_PKPR');
$this->db->from('potongan_klaimprogram');
return $this->db->get()->result_array();
}
public function getData_LinkKlaimProgram_byID($id) { //Klaim = [16]
$this->db->select('*');
$this->db->from('link_klaimprogram a');
$this->db->join('program b','b.ID_PROGRAM=a.PROGRAM_ID');
$this->db->where(['a.ID_LKPR' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_status1() { //Klaim = [19]
$this->db->select('*,DATE_FORMAT(a.TGL_SALEOUT,"%d/%m/%Y") as TANGGAL,FORMAT(a.HARGA_SNKPR,2) as HARGA');
$this->db->from('sn_klaimprogram a');
$this->db->join('sn_stock b','b.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID');
$this->db->join('pelanggan d','d.ID_PELANGGAN=a.PEL_ID','left');
$this->db->join('kota e','e.ID_KOTA=d.KOTA_ID','left');
$this->db->where('a.STATUS_SNKPR=1');
$this->db->order_by('a.NOTA_SNKPR DESC');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_notaNotNull() { //Klaim = [19]
$this->db->select('*');
$this->db->from('sn_klaimprogram');
$this->db->where('NOTA_SNKPR is NOT NULL');
$this->db->order_by('NOTA_SNKPR DESC');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_kunciNotNull() { //Klaim = [19]
$this->db->select('*');
$this->db->from('sn_klaimprogram');
$this->db->order_by('NOTA_SNKPR ASC');
return $this->db->get()->result_array();
}
public function getKode_INVKlaim() { //Klaim = [20]
$this->db->select('MAX(NOTA_SNKPR) AS KODE');
$this->db->from('sn_klaimprogram');
$this->db->like('NOTA_SNKPR','INV/ITP-K', 'after');
return $this->db->get()->result_array();
}
public function getData_SnKlaimProgram_forCetakNota($id) { //Klaim = [22]
$this->db->select('*,DATE_FORMAT(a.TGL_SALEOUT,"%d/%m/%Y") as TANGGAL,FORMAT(a.HARGA_SNKPR,2) as HARGA');
$this->db->from('sn_klaimprogram a');
$this->db->join('sn_stock b','b.ID_SNSTOCK=a.SNSTOCK_ID');
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID');
$this->db->join('pelanggan d','d.ID_PELANGGAN=a.PEL_ID');
$this->db->join('kota e','e.ID_KOTA=d.KOTA_ID');
$this->db->where('a.ID_SNKPR=', $id);
$this->db->order_by('a.NOTA_SNKPR DESC');
return $this->db->get()->result_array();
}
public function getData_LinkKlaimProgram_byDKPR_byPKPR($id1, $id2) { //Klaim = [27]
$this->db->select('*');
$this->db->from('link_klaimprogram a');
$this->db->join('sn_klaimprogram b','b.ID_SNKPR=a.SNKPR_ID');
$this->db->where(['b.DKPR_ID' => $id1]);
$this->db->where(['a.PKPR_ID' => $id2]);
return $this->db->get()->result_array();
}
}
?>
+249
View File
@@ -0,0 +1,249 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelKonfigurasi extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_SetHakMaster_groupKARYAWAN() { // Konfigurasi = [1]
$this->db->select('*');
$this->db->from('set_hakmaster a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->order_by('b.NAMA_PANGGILAN_KARYAWAN ASC');
$this->db->group_by('a.KARYAWAN_ID');
return $this->db->get()->result_array();
}
public function getData_Karyawan_byID($id=null) { // Konfigurasi = [1]
if ($id==null) {
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where('STATUS_KARYAWAN=1');
$this->db->where('USERNAME!="insentive"');
$this->db->where('USERNAME!="louis"');
$this->db->where('USERNAME!="service"');
$this->db->where('USERNAME!="itp"');
$this->db->where('USERNAME!="none"');
$this->db->where('USERNAME!="sugeng"');
$this->db->where('USERNAME!="hwely"');
$this->db->where('USERNAME!="admin"');
$this->db->where('USERNAME!="irwan"');
$this->db->order_by('USERNAME ASC');
} else {
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_SetHakMaster_byKARYAWAN($id) { // Konfigurasi = [1, 2, 3]
$this->db->select('*');
$this->db->from('set_hakmaster a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where('a.KARYAWAN_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SetHariLibur() { // Konfigurasi = [4]
$this->db->select('*,DATE_FORMAT(TGL_SHL,"%d/%m/%Y") as TANGGAL');
$this->db->from('set_harilibur');
$this->db->order_by('ID_SHL DESC');
return $this->db->get()->result_array();
}
public function getData_SetHariLibur_byID($id) { // Konfigurasi = [6, 7]
$this->db->select('*,DATE_FORMAT(TGL_SHL,"%d/%m/%Y") as TANGGAL');
$this->db->from('set_harilibur');
$this->db->where('ID_SHL=', $id);
return $this->db->get()->result_array();
}
public function getData_Komisi($id = null) { // Konfigurasi = [8, 10]
if ($id === null) {
$this->db->select('*,FORMAT(BIAYA_SERVICE,2) as BIAYA');
$this->db->from('jenis');
$this->db->order_by('NAMA_JENIS ASC');
} else {
$this->db->select('*');
$this->db->from('jenis');
$this->db->where(['ID_JENIS' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Jenis_byID($id) { // Konfigurasi = [9, 11]
$this->db->select('*');
$this->db->from('jenis');
$this->db->where('ID_JENIS=', $id);
return $this->db->get()->result_array();
}
public function getData_Kuartal($id = null) { // Konfigurasi = [12, 13, 14, 16, 17]
if ($id === null) {
$this->db->select('*,DATE_FORMAT(AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR,DATE_FORMAT(KUNCI_KUARTAL,"%d/%m/%Y") as KUNCI');
$this->db->from('kuartal');
$this->db->order_by('STATUS_KUARTAL ASC, ID_KUARTAL DESC');
} else {
$this->db->select('*');
$this->db->from('kuartal');
$this->db->where(['ID_KUARTAL' => $id]);
$this->db->order_by('ID_KUARTAL ASC');
}
return $this->db->get()->result_array();
}
public function getData_RekapKuartal_byKUARTAL($id) { // Konfigurasi = [12, 15]
$this->db->select('*');
$this->db->from('rekap_kuartal a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->where(['a.KUARTAL_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SetTargetSales_byKUARTAL($id) { // Konfigurasi = [12, 15]
$this->db->select('*');
$this->db->from('set_targetsales a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->where(['a.KUARTAL_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_RumusKuartal($id = null) { // Konfigurasi = [18, 20, 22, 23, 24, 25]
if ($id === null) {
$this->db->select('*');
$this->db->from('rumus_kuartal');
$this->db->order_by('ID_RMQ DESC');
} else {
$this->db->select('*');
$this->db->from('rumus_kuartal');
$this->db->where(['ID_RMQ' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_DaftarRumusKuartal_byRMQ($id) { // Konfigurasi = [18, 21, 22, 23, 24]
$this->db->select('*,FORMAT(a.BAWAH_DRMQ,2) as BAWAH,FORMAT(a.ATAS_DRMQ,2) as ATAS,FORMAT((a.RATE_DRMQ*100),2) as RATE');
$this->db->from('daftar_rumuskuartal a');
$this->db->join('rumus_kuartal b','b.ID_RMQ=a.RMQ_ID');
$this->db->where(['a.RMQ_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarRumusKuartal_byID($id) { // Konfigurasi = [24]
$this->db->select('*,FORMAT(a.BAWAH_DRMQ,2) as BAWAH,FORMAT(a.ATAS_DRMQ,2) as ATAS,FORMAT((a.RATE_DRMQ*100),2) as RATE');
$this->db->from('daftar_rumuskuartal a');
$this->db->join('rumus_kuartal b','b.ID_RMQ=a.RMQ_ID');
$this->db->where(['a.ID_DRMQ' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarRumusKuartal_byRMQ_orderDESC_limit1($id) { // Konfigurasi = [25]
$this->db->select('*,FORMAT(a.BAWAH_DRMQ,2) as BAWAH,FORMAT(a.ATAS_DRMQ,2) as ATAS,FORMAT((a.RATE_DRMQ*100),2) as RATE');
$this->db->from('daftar_rumuskuartal a');
$this->db->join('rumus_kuartal b','b.ID_RMQ=a.RMQ_ID');
$this->db->where(['a.RMQ_ID' => $id]);
$this->db->order_by('a.ID_DRMQ DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getData_ListSalesTarget($id=null) { // Konfigurasi = [26, 27, 29, 31, 32]
if ($id==null) {
$this->db->select('*');
$this->db->from('list_sales_target a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID','left');
$this->db->order_by('a.ID_LST ASC');
} else {
$this->db->select('*');
$this->db->from('list_sales_target a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID','left');
$this->db->where(['a.ID_LST' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Kuartal_byTAHUN($id) { // Konfigurasi = [26, 27, 28]
$this->db->select('*,DATE_FORMAT(AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('kuartal');
$this->db->where(['TAHUN_KUARTAL' => $id]);
return $this->db->get()->result_array();
}
public function getData_SetTargetSales_byKUARTAL_byKARYAWAN($id1, $id2) { // Konfigurasi = [26, 27]
$this->db->select('*');
$this->db->from('set_targetsales a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->where(['a.KUARTAL_ID' => $id1]);
$this->db->where(['a.KARYAWAN_ID' => $id2]);
return $this->db->get()->result_array();
}
public function getData_SetTargetSales_byTAHUN($year) { // Konfigurasi = [26]
$this->db->select('*');
$this->db->from('set_targetsales a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->where(['b.TAHUN_KUARTAL' => $year]);
return $this->db->get()->result_array();
}
public function getData_ListSalesTarget_byKARYAWAN($id) { // Konfigurasi = [28, 29, 30]
$this->db->select('*');
$this->db->from('list_sales_target a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where(['a.KARYAWAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_ListSalesTarget_byTEAM($id) { // Konfigurasi = [28]
$this->db->select('*');
$this->db->from('list_sales_target a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where(['a.TEAM_LST' => $id]);
return $this->db->get()->result_array();
}
public function getData_SetTargetSales_byKARYAWAN($id) { // Konfigurasi = [29]
$this->db->select('*');
$this->db->from('set_targetsales a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where(['a.KARYAWAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_Karyawan_SALES() { // Konfigurasi = [29]
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID');
$this->db->like('b.NAMA_JABATAN','SALES');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','ITP');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Insentive');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','None');
$this->db->order_by('a.NAMA_PANGGILAN_KARYAWAN ASC');
return $this->db->get()->result_array();
}
}
?>
+838
View File
@@ -0,0 +1,838 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelKonfigurasi extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
//Model getAdd
public function addTempoMonth($date,$month) {
$sum = strtotime(date("m/d/Y", strtotime("$date")) . " +$month month");
$dateTo=date('m/d/Y',$sum);
return $dateTo;
}
//Model getData
public function getData_Bank_forSetdata($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('bank');
$this->db->order_by('KODE_BANK ASC');
}else{
$this->db->select('*');
$this->db->from('bank');
$this->db->where(['ID_bank' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Barang_forSetdata() {
$this->db->select('*');
$this->db->from('barang a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->where('b.TYPE_JENIS!=2');
$this->db->order_by('b.NAMA_JENIS ASC');
return $this->db->get()->result_array();
}
public function getData_DaftarKasbank_byPERKIRAAN_9_forSetdata() {
$this->db->select('*');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=9');
return $this->db->get()->result_array();
}
public function getData_DaftarKasbank_byPERKIRAAN_11_forSetdata() {
$this->db->select('*');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=11');
return $this->db->get()->result_array();
}
public function getData_DaftarKasbank_byPERKIRAAN_13_forSetdata() {
$this->db->select('*');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=13');
return $this->db->get()->result_array();
}
public function getData_DaftarKasbank_byPERKIRAAN_forSetdata($id) {
$this->db->select('*');
$this->db->from('daftar_kasbank');
$this->db->where(['PERKIRAAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarKasbank_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_DKB,2)) as DEBET,CONCAT("Rp ",FORMAT(a.KREDIT_DKB,2)) as KREDIT');
$this->db->from('daftar_kasbank a');
$this->db->join('perkiraan b','b.ID_PERKIRAAN=a.PERKIRAAN_ID');
$this->db->where('a.PERKIRAAN_ID=8');
$this->db->or_where('a.PERKIRAAN_ID=9');
$this->db->or_where('a.PERKIRAAN_ID=11');
$this->db->or_where('a.PERKIRAAN_ID=13');
$this->db->or_where('a.PERKIRAAN_ID=17');
$this->db->or_where('a.PERKIRAAN_ID=18');
$this->db->or_where('a.PERKIRAAN_ID=20');
return $this->db->get()->result_array();
}
public function getData_DaftarJurnalMemo_byDKB_forSetdata($id) {
$this->db->select('*');
$this->db->from('daftar_jurnalmemo');
$this->db->where(['DKB_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarJurnalMemo_byID($id) {
$this->db->select('*');
$this->db->from('daftar_jurnalmemo');
$this->db->where(['ID_DJM' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarJurnalMemo_byPERKIRAAN_forSetdata() {
$this->db->select('*');
$this->db->from('daftar_jurnalmemo');
return $this->db->get()->result_array();
}
public function getData_DaftarJurnalMemo_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_DJM,2)) as DEBET,CONCAT("Rp ",FORMAT(a.KREDIT_DJM,2)) as KREDIT');
$this->db->from('daftar_jurnalmemo a');
$this->db->join('perkiraan b','b.ID_PERKIRAAN=a.PERKIRAAN_ID');
return $this->db->get()->result_array();
}
public function getData_DpPembelian_byID($id) {
$this->db->select('*');
$this->db->from('dp_pembelian');
$this->db->where(['ID_DPB' => $id]);
return $this->db->get()->result_array();
}
public function getData_DpPembelian_bySUPPLIER_forSetdata($id) {
$this->db->select('*');
$this->db->from('dp_pembelian');
$this->db->where(['SUPPLIER_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DpPembelian_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_DPB,2)) as DEBET,DATE_FORMAT(a.TGL_DPB,"%d/%m/%Y") as TANGGAL');
$this->db->from('dp_pembelian a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
return $this->db->get()->result_array();
}
public function getData_DpPenjualan_byID($id) {
$this->db->select('*');
$this->db->from('dp_penjualan');
$this->db->where(['ID_DPJ' => $id]);
return $this->db->get()->result_array();
}
public function getData_DpPenjualan_byPELANGGAN_forSetdata($id) {
$this->db->select('*');
$this->db->from('dp_penjualan');
$this->db->where(['PELANGGAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DpPenjualan_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.KREDIT_DPJ,2)) as KREDIT,DATE_FORMAT(a.TGL_DPJ,"%d/%m/%Y") as TANGGAL');
$this->db->from('dp_penjualan a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
return $this->db->get()->result_array();
}
public function getData_HutangDagang_byID($id) {
$this->db->select('*');
$this->db->from('hutang_dagang');
$this->db->where(['ID_HDA' => $id]);
return $this->db->get()->result_array();
}
public function getData_HutangDagang_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.KREDIT_HDA,2)) as KREDIT,DATE_FORMAT(a.TGL_HDA,"%d/%m/%Y") as TANGGAL');
$this->db->from('hutang_dagang a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('pembelian d','d.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->order_by('a.ID_HDA DESC');
return $this->db->get()->result_array();
}
public function getData_Karyawan_forSetdata($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('karyawan');
$this->db->order_by('NAMA_PANGGILAN_KARYAWAN ASC');
}else{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Kas_forSetdata($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('kas');
}else{
$this->db->select('*');
$this->db->from('kas');
$this->db->where(['ID_KAS' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Neraca_AkumulasiLaba_forSetdata($id) {
$this->db->select('ID_NERACA');
$this->db->from('neraca');
$this->db->where('PERKIRAAN_ID=21');
$this->db->where(['SETDATA_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_Neraca_Lain_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.NILAI_NERACA,2)) as NERACA');
$this->db->from('neraca a');
$this->db->join('perkiraan b','b.ID_PERKIRAAN=a.PERKIRAAN_ID');
$this->db->where('a.PERKIRAAN_ID=21');
$this->db->or_where('a.PERKIRAAN_ID=22');
return $this->db->get()->result_array();
}
public function getData_Neraca_PersediaanAwal_forSetdata($id) {
$this->db->select('ID_NERACA');
$this->db->from('neraca');
$this->db->where('PERKIRAAN_ID=26');
$this->db->where(['SETDATA_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_Pelanggan_forSetdata($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID','left');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->order_by('a.TYPE_PELANGGAN ASC, a.NAMA_PELANGGAN ASC');
$this->db->group_by('a.ID_PELANGGAN');
}else{
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID','left');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->order_by('a.TYPE_PELANGGAN ASC');
$this->db->group_by('a.ID_PELANGGAN');
$this->db->where(['a.ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_PerkiraanKasbankLain_forSetdata($id=null) {
if ($id==null) {
$this->db->select('*');
$this->db->from('perkiraan');
$this->db->where('ID_PERKIRAAN=8');
$this->db->or_where('ID_PERKIRAAN=9');
$this->db->or_where('ID_PERKIRAAN=11');
$this->db->or_where('ID_PERKIRAAN=13');
$this->db->or_where('ID_PERKIRAAN=17');
$this->db->or_where('ID_PERKIRAAN=18');
$this->db->or_where('ID_PERKIRAAN=20');
} else {
$this->db->select('*');
$this->db->from('perkiraan');
$this->db->where(['ID_PERKIRAAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_PerkiraanJurnalMemoLain_forSetdata($id=null) {
if ($id==null) {
$this->db->select('*');
$this->db->from('perkiraan');
$this->db->where('ID_PERKIRAAN=10');
$this->db->or_where('ID_PERKIRAAN=12');
$this->db->or_where('ID_PERKIRAAN=14');
$this->db->or_where('ID_PERKIRAAN=16');
} else {
$this->db->select('*');
$this->db->from('perkiraan');
$this->db->where(['ID_PERKIRAAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Perkiraan_byID_forSetdata($id) {
$this->db->select('*');
$this->db->from('perkiraan');
$this->db->where(['ID_PERKIRAAN' => $id]);
return $this->db->get()->result_array();
}
public function getData_Pihakke3_forSetdata($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('pihakke3 a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
}else{
$this->db->select('*');
$this->db->from('pihakke3 a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->where(['a.ID_PIHAKKE3' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_PiutangDagang_byID($id) {
$this->db->select('*');
$this->db->from('piutang_dagang');
$this->db->where(['ID_PDA' => $id]);
return $this->db->get()->result_array();
}
public function getData_PiutangDagang_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_PDA,2)) as DEBET,DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y") as TANGGAL');
$this->db->from('piutang_dagang a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('penjualan d','d.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->order_by('a.ID_PDA DESC');
return $this->db->get()->result_array();
}
public function getData_PiutangKaryawan_byID($id) {
$this->db->select('*');
$this->db->from('piutang_karyawan');
$this->db->where(['ID_PKA' => $id]);
return $this->db->get()->result_array();
}
public function getData_PiutangKaryawan_byKARYAWAN_forSetdata($id) {
$this->db->select('*');
$this->db->from('piutang_karyawan');
$this->db->where(['KARYAWAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_PiutangKaryawan_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_PKA,2)) as DEBET,DATE_FORMAT(a.TGL_PKA,"%d/%m/%Y") as TANGGAL');
$this->db->from('piutang_karyawan a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->order_by('a.ID_PKA DESC');
return $this->db->get()->result_array();
}
public function getData_PiutangPihakke3_byID($id) {
$this->db->select('*');
$this->db->from('piutang_pihakke3');
$this->db->where(['ID_PPK' => $id]);
return $this->db->get()->result_array();
}
public function getData_PiutangPihakke3_byPIHAKKE3_forSetdata($id) {
$this->db->select('*');
$this->db->from('piutang_pihakke3');
$this->db->where(['PIHAKKE3_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_PiutangPihakke3_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_PPK,2)) as DEBET,DATE_FORMAT(a.TGL_PPK,"%d/%m/%Y") as TANGGAL');
$this->db->from('piutang_pihakke3 a');
$this->db->join('pihakke3 b','b.ID_PIHAKKE3=a.PIHAKKE3_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->order_by('a.ID_PPK DESC');
return $this->db->get()->result_array();
}
public function getData_SaldoBank_byBANK_forSetdata($id) {
$this->db->select('*');
$this->db->from('saldo_bank');
$this->db->where(['BANK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SaldoBank_byID($id) {
$this->db->select('*');
$this->db->from('saldo_bank');
$this->db->where(['ID_SB' => $id]);
return $this->db->get()->result_array();
}
public function getData_SaldoBank_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_SB,2)) as DEBET,DATE_FORMAT(a.TGL_INPUT,"%d/%m/%Y") as TANGGAL');
$this->db->from('saldo_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID');
$this->db->order_by('a.ID_SB DESC');
return $this->db->get()->result_array();
}
public function getData_SaldoKas_byID($id) {
$this->db->select('*');
$this->db->from('saldo_kas');
$this->db->where(['ID_SK' => $id]);
return $this->db->get()->result_array();
}
public function getData_SaldoKas_byKAS_forSetdata($id) {
$this->db->select('*');
$this->db->from('saldo_kas');
$this->db->where(['KAS_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SaldoKas_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.DEBET_SK,2)) as DEBET,DATE_FORMAT(a.TGL_INPUT,"%d/%m/%Y") as TANGGAL');
$this->db->from('saldo_kas a');
$this->db->join('kas b','b.ID_KAS=a.KAS_ID');
return $this->db->get()->result_array();
}
public function getData_SnIo_byID_forSetdata($id) {
$this->db->select('*');
$this->db->from('sn_io');
$this->db->where(['ID_SNIO' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnIo_byIO_forSetdata($id) {
$this->db->select('*');
$this->db->from('sn_io a');
$this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID');
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID');
$this->db->where(['a.IO_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnStock_byBARANG_Null_forSetdata($id) {
$this->db->select('*');
$this->db->from('sn_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->where(['a.BARANG_ID' => $id]);
$this->db->where('a.STATUS_SNSTOCK is NULL');
return $this->db->get()->result_array();
}
public function getData_SnStock_byBARANG_forSetdata($id) {
$this->db->select('ID_SNSTOCK');
$this->db->from('sn_stock');
$this->db->where(['BARANG_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnStock_byNAMA_AllStatus_forSetdata($id) {
$this->db->select('*');
$this->db->from('sn_stock');
$this->db->where(['NAMA_SNSTOCK' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnStock_SnIo_byNAMA_AllStatus_forSetdata($id) {
$this->db->select('*');
$this->db->from('sn_stock a');
$this->db->join('sn_io b','b.NAMA_SNIO=a.NAMA_SNSTOCK','left');
$this->db->where(['a.NAMA_SNSTOCK' => $id]);
return $this->db->get()->result_array();
}
public function getData_Supplier_forSetdata($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
}else{
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->where(['a.ID_SUPPLIER' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_byBARANG_forSetdata($id) {
$this->db->select('*');
$this->db->from('transaksi_stock');
$this->db->where(['BARANG_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_byID_forSetdata($id) {
$this->db->select('*');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID','left');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID','left');
$this->db->where(['a.ID_IO' => $id]);
$this->db->group_by('a.ID_IO');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_bySETDATA_forSetdata() {
$this->db->select('*');
$this->db->from('transaksi_stock');
$this->db->where('SETDATA_ID=1');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.HARGA_IO,2)) as HARGA');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->order_by('b.KODE_BARANG ASC');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_forSetdata_HPP() {
//$offset = 0;
$this->db->select('*,CONCAT("Rp ",FORMAT(a.HARGA_IO,2)) as HARGA');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where('a.STATUS_IO=0');
//$this->db->where('a.HARGA_IO is NULL');
$this->db->order_by('b.KODE_BARANG ASC');
//$this->db->limit('500',$offset);
//$this->db->limit('109');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_justID() {
$this->db->select('ID_IO');
$this->db->from('transaksi_stock');
$this->db->where('STATUS_IO is NULL');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_Null_forSetdata($id) {
$this->db->select('*');
$this->db->from('transaksi_stock');
$this->db->where(['ID_IO' => $id]);
$this->db->where('STATUS_IO is NULL');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_0_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.HARGA_IO,2)) as HARGA');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where('a.STATUS_IO=0');
$this->db->order_by('a.ID_IO DESC');
return $this->db->get()->result_array();
}
//Model getID
public function getID_BiayaPenyusutanInventarisMax() {
$this->db->select_max('ID_BPI');
$this->db->from('biaya_penyusutaninventaris');
return $this->db->get()->result_array();
}
public function getID_BiayaPenyusutanKendaraanMax() {
$this->db->select_max('ID_BPK');
$this->db->from('biaya_penyusutankendaraan');
return $this->db->get()->result_array();
}
public function getID_BiayaPenyusutanRukoMax() {
$this->db->select_max('ID_BPR');
$this->db->from('biaya_penyusutanruko');
return $this->db->get()->result_array();
}
public function getID_DaftarJurnalMemoMax() {
$this->db->select_max('ID_DJM');
$this->db->from('daftar_jurnalmemo');
return $this->db->get()->result_array();
}
public function getID_DaftarKasbankMax() {
$this->db->select_max('ID_DKB');
$this->db->from('daftar_kasbank');
return $this->db->get()->result_array();
}
public function getID_DPPajakMax() {
$this->db->select_max('ID_DPP');
$this->db->from('dp_pajak');
return $this->db->get()->result_array();
}
public function getID_DPPembelianMax() {
$this->db->select_max('ID_DPB');
$this->db->from('dp_pembelian');
return $this->db->get()->result_array();
}
public function getID_DPPenjualanMax() {
$this->db->select_max('ID_DPJ');
$this->db->from('dp_penjualan');
return $this->db->get()->result_array();
}
public function getID_PenjualanMax() {
$this->db->select_max('ID_PENJUALAN');
$this->db->from('penjualan');
return $this->db->get()->result_array();
}
public function getID_PembelianMax() {
$this->db->select_max('ID_PEMBELIAN');
$this->db->from('pembelian');
return $this->db->get()->result_array();
}
public function getID_PiutangKaryawanMax() {
$this->db->select_max('ID_PKA');
$this->db->from('piutang_karyawan');
return $this->db->get()->result_array();
}
public function getID_PiutangPihakke3Max() {
$this->db->select_max('ID_PPK');
$this->db->from('piutang_pihakke3');
return $this->db->get()->result_array();
}
public function getID_SaldoBankMax() {
$this->db->select_max('ID_SB');
$this->db->from('saldo_bank');
return $this->db->get()->result_array();
}
public function getID_SaldoKasMax() {
$this->db->select_max('ID_SK');
$this->db->from('saldo_kas');
return $this->db->get()->result_array();
}
public function getID_SetdataMax() {
$this->db->select_max('ID_SETDATA');
$this->db->from('setdata');
return $this->db->get()->result_array();
}
//Model getKode
public function getKode_Setdata() {
$this->db->select('MAX(KODE_SETDATA) AS KODE');
$this->db->from('setdata');
return $this->db->get()->result_array();
}
public function getKode_Penjualan() {
$this->db->select('MAX(KODE_PENJUALAN) AS KODE');
$this->db->from('penjualan');
return $this->db->get()->result_array();
}
public function getKode_Pembelian() {
$this->db->select('MAX(KODE_PEMBELIAN) AS KODE');
$this->db->from('pembelian');
return $this->db->get()->result_array();
}
//Model getNilai
public function getNilai_Neraca21_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(NILAI_NERACA,2)) as TOTAL');
$this->db->from('neraca');
$this->db->where('PERKIRAAN_ID=21');
$this->db->where('SETDATA_ID=1');
return $this->db->get()->result_array();
}
public function getNilai_Neraca22_forSetdata() {
$this->db->select('*,CONCAT("Rp ",FORMAT(NILAI_NERACA,2)) as TOTAL');
$this->db->from('neraca');
$this->db->where('PERKIRAAN_ID=22');
$this->db->where('SETDATA_ID=1');
return $this->db->get()->result_array();
}
//Model getQtyReal
public function getQtyReal_SnStock_byBARANG_Null_forSetdata($id) {
$this->db->select('a.ID_SNSTOCK');
$this->db->from('sn_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->where(['a.BARANG_ID' => $id]);
$this->db->where('a.STATUS_SNSTOCK is NULL');
return $this->db->count_all_results();
}
public function getQtyReal_TransaksiStock_forSetdata($id) {
$this->db->select('a.ID_SNIO');
$this->db->from('sn_io a');
$this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID');
$this->db->group_by('a.ID_SNIO');
$this->db->where(['a.IO_ID' => $id]);
return $this->db->count_all_results();
}
//Model getSum
public function getSum_DaftarKasbank_8_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DKB),2)) as TOTAL,SUM(DEBET_DKB) AS DEBET');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=8');
return $this->db->get()->result_array();
}
public function getSum_DpPembelian_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DPB),2)) as TOTAL,SUM(DEBET_DPB) AS DEBET');
$this->db->from('dp_pembelian');
return $this->db->get()->result_array();
}
public function getSum_DpPenjualan_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(KREDIT_DPJ),2)) as TOTAL,SUM(KREDIT_DPJ) AS KREDIT');
$this->db->from('dp_penjualan');
return $this->db->get()->result_array();
}
public function getSum_HutangAktiva_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(KREDIT_DKB),2)) as TOTAL,SUM(KREDIT_DKB) AS KREDIT');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=18');
return $this->db->get()->result_array();
}
public function getSum_HutangBank_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(KREDIT_DKB),2)) as TOTAL,SUM(KREDIT_DKB) AS KREDIT');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=17');
return $this->db->get()->result_array();
}
public function getSum_HutangDagang_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(KREDIT_HDA),2)) as TOTAL,SUM(KREDIT_HDA) AS KREDIT');
$this->db->from('hutang_dagang');
return $this->db->get()->result_array();
}
public function getSum_HutangPajak_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(KREDIT_DJM),2)) as TOTAL,SUM(KREDIT_DJM) AS KREDIT');
$this->db->from('daftar_jurnalmemo');
$this->db->where('PERKIRAAN_ID=16');
return $this->db->get()->result_array();
}
public function getSum_InventarisKantor_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DKB),2)) as TOTAL,SUM(DEBET_DKB) AS DEBET');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=9');
return $this->db->get()->result_array();
}
public function getSum_Kendaraan_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DKB),2)) as TOTAL,SUM(DEBET_DKB) AS DEBET');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=13');
return $this->db->get()->result_array();
}
public function getSum_Modal_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(KREDIT_DKB),2)) as TOTAL,SUM(KREDIT_DKB) AS KREDIT');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=20');
return $this->db->get()->result_array();
}
public function getSum_PenyusutanInventarisKantor_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DJM),2)) as TOTAL,SUM(DEBET_DJM) AS DEBET');
$this->db->from('daftar_jurnalmemo');
$this->db->where('PERKIRAAN_ID=67');
$this->db->where('BPI_ID is NOT NULL');
return $this->db->get()->result_array();
}
public function getSum_PenyusutanKendaraan_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DJM),2)) as TOTAL,SUM(DEBET_DJM) AS DEBET');
$this->db->from('daftar_jurnalmemo');
$this->db->where('PERKIRAAN_ID=67');
$this->db->where('BPK_ID is NOT NULL');
return $this->db->get()->result_array();
}
public function getSum_PenyusutanRuko_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DJM),2)) as TOTAL,SUM(DEBET_DJM) AS DEBET');
$this->db->from('daftar_jurnalmemo');
$this->db->where('PERKIRAAN_ID=67');
$this->db->where('BPR_ID is NOT NULL');
return $this->db->get()->result_array();
}
public function getSum_Persediaan_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(HARGA_IO*QTY_IO),2)) as TOTAL,SUM(HARGA_IO*QTY_IO) AS HARGA');
$this->db->from('transaksi_stock');
return $this->db->get()->result_array();
}
public function getSum_PiutangDagang_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_PDA),2)) as TOTAL,SUM(DEBET_PDA) AS DEBET');
$this->db->from('piutang_dagang');
return $this->db->get()->result_array();
}
public function getSum_PiutangKaryawan_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_PKA),2)) as TOTAL,SUM(DEBET_PKA) AS DEBET');
$this->db->from('piutang_karyawan');
return $this->db->get()->result_array();
}
public function getSum_PiutangPihakke3_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_PPK),2)) as TOTAL,SUM(DEBET_PPK) AS DEBET');
$this->db->from('piutang_pihakke3');
return $this->db->get()->result_array();
}
public function getSum_Ruko_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_DKB),2)) as TOTAL,SUM(DEBET_DKB) AS DEBET');
$this->db->from('daftar_kasbank');
$this->db->where('PERKIRAAN_ID=11');
return $this->db->get()->result_array();
}
public function getSum_SaldoBank_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_SB),2)) as TOTAL,SUM(DEBET_SB) AS DEBET');
$this->db->from('saldo_bank');
return $this->db->get()->result_array();
}
public function getSum_SaldoKas_forSetdata() {
$this->db->select('CONCAT("Rp ",FORMAT(SUM(DEBET_SK),2)) as TOTAL,SUM(DEBET_SK) AS DEBET');
$this->db->from('saldo_kas');
return $this->db->get()->result_array();
}
}
?>
+403
View File
@@ -0,0 +1,403 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelKontak extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
//Model getData
public function getData_Kontak($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('kontak a');
$this->db->join('posisi b','b.ID_POSISI=a.POSISI_ID');
$this->db->join('akun c','c.ID_AKUN=a.AKUN_ID');
$this->db->order_by('c.NAMA_AKUN ASC, a.NAMA_KONTAK ASC');
}else{
$this->db->select('*');
$this->db->from('kontak a');
$this->db->join('posisi b','b.ID_POSISI=a.POSISI_ID');
$this->db->join('akun c','c.ID_AKUN=a.AKUN_ID');
$this->db->order_by('c.NAMA_AKUN ASC, a.NAMA_KONTAK ASC');
$this->db->where(['a.AKUN_ID' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Kontak_byNAMA($id1, $id2=null){
if ($id2 == null) {
$this->db->select('*');
$this->db->from('kontak');
$this->db->where(['NAMA_KONTAK' => $id1]);
} else {
$this->db->select('*');
$this->db->from('kontak');
$this->db->where(['NAMA_KONTAK' => $id1]);
$this->db->where('ID_KONTAK!=', $id2);
}
return $this->db->get()->result_array();
}
public function getData_Pelanggan_byNAMA($id){
$this->db->select('*');
$this->db->from('pelanggan');
$this->db->where(['NAMA_PELANGGAN' => $id]);
return $this->db->get()->result_array();
}
public function getData_Pembelian_byID(){
$this->db->select('*');
$this->db->from('pembelian a');
$this->db->join('hutang_dagang b','b.PEMBELIAN_ID=a.ID_PEMBELIAN');
$this->db->where('a.STATUS_PEMBELIAN=1');
$this->db->group_by('a.ID_PEMBELIAN');
return $this->db->get()->result_array();
}
public function getData_Pelanggan_forAdmin($id = null){
if ($id == null) {
$this->db->select('a.*,b.NAMA_KOTA,c.NAMA_KELOMPOK');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->order_by('a.ID_PELANGGAN DESC');
$this->db->group_by('a.ID_PELANGGAN');
$this->db->where('a.ID_PELANGGAN is NULL');
} else {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID','left');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->order_by('a.TYPE_PELANGGAN ASC');
$this->db->group_by('a.ID_PELANGGAN');
$this->db->where(['a.ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Pelanggan_forView(){
$this->db->select('a.*,b.NAMA_KOTA,c.NAMA_KELOMPOK');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->order_by('a.ID_PELANGGAN DESC');
$this->db->group_by('a.ID_PELANGGAN');
return $this->db->get()->result_array();
}
public function getData_Pelanggan_Corporate(){
$this->db->select('a.*,b.NAMA_KOTA,c.NAMA_KELOMPOK');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->where('a.TYPE_PELANGGAN=0');
$this->db->order_by('a.NAMA_PELANGGAN ASC');
$this->db->group_by('a.ID_PELANGGAN');
return $this->db->get()->result_array();
}
public function getExcel_Pelanggan($type_cetak)
{
if ($type_cetak!="9") {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->join('kelompok c', 'c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->where('a.TYPE_PELANGGAN=', $type_cetak);
$this->db->order_by('a.NAMA_PELANGGAN ASC');
} else {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->join('kelompok c', 'c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->order_by('a.TYPE_PELANGGAN ASC, a.NAMA_PELANGGAN ASC');
}
return $this->db->get()->result_array();
}
public function getData_Pelanggan_byID($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID','left');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->join('sales_order d','d.PELANGGAN_ID=a.ID_PELANGGAN','left');
$this->db->join('penjualan e','e.SO_ID=d.ID_SO','left');
$this->db->order_by('a.TYPE_PELANGGAN ASC');
$this->db->group_by('a.ID_PELANGGAN');
}else{
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID','left');
$this->db->join('kelompok c','c.ID_KELOMPOK=a.KELOMPOK_ID','left');
$this->db->join('sales_order d','d.PELANGGAN_ID=a.ID_PELANGGAN','left');
$this->db->join('penjualan e','e.SO_ID=d.ID_SO','left');
$this->db->order_by('a.TYPE_PELANGGAN ASC');
$this->db->group_by('a.ID_PELANGGAN');
$this->db->where(['a.ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Sales($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID','left');
$this->db->where('a.JABATAN_ID=4');
}else{
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID','left');
$this->db->where('a.JABATAN_ID=4');
$this->db->where(['a.ID_KARYAWAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getDataDpPenjualan($id=null){
if ($id === null) {
$this->db->select('*,CONCAT("Rp ",FORMAT(b.SALDO_PELANGGAN,2)) as SALDO,CONCAT("Rp ",FORMAT(a.NOMINAL_DPJ,2)) as DP');
$this->db->from('dp_penjualan a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID','left');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
$this->db->group_by('a.ID_DPJ');
}else{
$this->db->select('*,CONCAT("Rp ",FORMAT(b.SALDO_PELANGGAN,2)) as SALDO,CONCAT("Rp ",FORMAT(a.NOMINAL_DPJ,2)) as DP');
$this->db->from('dp_penjualan a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID','left');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
$this->db->group_by('a.ID_DPJ');
$this->db->where(['a.PELANGGAN_ID' => $id]);
}
return $this->db->get()->result_array();
}
public function getDataPelangganDpj(){
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('dp_penjualan b','b.PELANGGAN_ID=a.ID_PELANGGAN','left');
$this->db->join('kota c','c.ID_KOTA=a.KOTA_ID','left');
$this->db->where('b.PELANGGAN_ID is NULL');
$this->db->order_by('a.TYPE_PELANGGAN','ASC');
return $this->db->get()->result_array();
}
public function getDataDpj($id){
$this->db->select('*');
$this->db->from('dp_penjualan');
$this->db->where(['ID_DPJ' => $id]);
return $this->db->get()->result_array();
}
public function getKodeDPJ() {
$this->db->select('MAX(KODE_DPJ) AS KODE');
$this->db->from('dp_penjualan');
return $this->db->get()->result_array();
}
public function hapusDPJ($id){
$this->db->where(['PELANGGAN_ID' => $id]);
$this->db->delete('dp_penjualan');
}
public function getIDPelangganMax(){
$this->db->select_max('ID_PELANGGAN');
$this->db->from('pelanggan');
return $this->db->get()->result_array();
}
public function getKelompokPelanggan(){
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID','left');
$this->db->join('kelompok c','c.ANGGOTA_ID=a.ID_PELANGGAN','left');
$this->db->group_by('a.ID_PELANGGAN');
$this->db->where('c.ANGGOTA_ID is NULL');
return $this->db->get()->result_array();
}
public function getDataPelangganNormal($id = null){
if ($id === null) {
$this->db->select('*');
$this->db->from('pelanggan');
$this->db->where('ID_PELANGGAN>=3');
}else{
$this->db->select('*');
$this->db->from('pelanggan');
$this->db->where('ID_PELANGGAN>=3');
}
return $this->db->get()->result_array();
}
public function getDataPelangganService($id = null){
if ($id === null) {
$this->db->select('*,b.ID_SERVICE');
$this->db->from('pelanggan a');
$this->db->join('service b','b.PELANGGAN_ID=a.ID_PELANGGAN');
}else{
$this->db->select('*,b.ID_SERVICE');
$this->db->from('pelanggan a');
$this->db->join('service b','b.PELANGGAN_ID=a.ID_PELANGGAN');
$this->db->where(['ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function cekPass($id, $pass)
{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
$this->db->where(['PASSWORD' => $pass]);
return $this->db->get()->result_array();
}
//Step Two, Input Piutang Dagang
public function getDataPiutangDagang($id = null){
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(d.HUTANG_PELANGGAN,2)) as HUTANG,CONCAT("Rp ",FORMAT(a.NOMINAL_PDA,2)) as PDA');
$this->db->from('piutang_dagang a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID','left');
$this->db->join('corp c','c.ID_CORP=b.CORP_ID','left');
$this->db->join('pelanggan d','d.ID_PELANGGAN=b.PELANGGAN_ID','left');
$this->db->join('kota e','e.ID_KOTA=d.KOTA_ID','left');
$this->db->join('karyawan f','f.ID_KARYAWAN=b.SALES_ID','left');
$this->db->group_by('a.ID_PDA');
}else{
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(d.HUTANG_PELANGGAN,2)) as HUTANG,CONCAT("Rp ",FORMAT(a.NOMINAL_PDA,2)) as PDA');
$this->db->from('piutang_dagang a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID','left');
$this->db->join('corp c','c.ID_CORP=b.CORP_ID','left');
$this->db->join('pelanggan d','d.ID_PELANGGAN=b.PELANGGAN_ID','left');
$this->db->join('kota e','e.ID_KOTA=d.KOTA_ID','left');
$this->db->join('karyawan f','f.ID_KARYAWAN=b.SALES_ID','left');
$this->db->group_by('a.ID_PDA');
$this->db->where(['d.ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getDataPenjualan($id) {
$this->db->select('PENJUALAN_ID,PELANGGAN_ID,CORP_ID,NOMINAL_PDA');
$this->db->from('piutang_dagang a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID','left');
$this->db->where(['a.ID_PDA' => $id]);
return $this->db->get()->result_array();
}
public function getDataCorp($id) {
$this->db->select('PIUTANG_CORP');
$this->db->from('corp');
$this->db->where(['ID_CORP' => $id]);
return $this->db->get()->result_array();
}
public function getKodePDA() {
$this->db->select('MAX(KODE_PDA) AS KODE');
$this->db->from('piutang_dagang');
return $this->db->get()->result_array();
}
public function getKodePenjualan() {
$this->db->select('MAX(KODE_PENJUALAN) AS KODE');
$this->db->from('penjualan');
return $this->db->get()->result_array();
}
public function getIDPenjualan() {
$this->db->select_max('ID_PENJUALAN');
$this->db->from('penjualan');
return $this->db->get()->result_array();
}
public function getData_Karyawan_MasterPelanggan($id) {
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID');
$this->db->where('a.USERNAME="iwan" OR a.USERNAME="helda" OR a.USERNAME="admin"');
$this->db->where(['a.ID_KARYAWAN' => $id]);
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byPELANGGAN($id) {
$this->db->select('*');
$this->db->from('sales_order');
$this->db->where(['PELANGGAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_HistoriSn_byPELANGGAN($id) {
$this->db->select('*');
$this->db->from('histori_sn');
$this->db->where(['PELANGGAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_PiutangDagang_byPELANGGAN($id) {
$this->db->select('*');
$this->db->from('piutang_dagang');
$this->db->where(['PELANGGAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DpPenjualan_byPELANGGAN($id) {
$this->db->select('*');
$this->db->from('dp_penjualan');
$this->db->where(['PELANGGAN_ID' => $id]);
return $this->db->get()->result_array();
}
}
?>
File diff suppressed because it is too large Load Diff
+14
View File
@@ -0,0 +1,14 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ModelLogin extends CI_Model
{
public function getLogin($username, $password)
{
return $this->db->query("SELECT * FROM karyawan WHERE username='$username' AND password='$password'");
}
public function getUser()
{
return $this->db->query("SELECT * FROM karyawan");
}
}
+188
View File
@@ -0,0 +1,188 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelNotifikasi extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getDataFlashNotif($id_karyawan)
{
$tgl = date('Y-m-d');
$this->db->select('*');
$this->db->from('log_notifikasi a');
$this->db->join('notifikasi b', 'b.ID_NOTIFIKASI=a.NOTIFIKASI_ID');
$this->db->where(['a.KARYAWAN_ID' => $id_karyawan]);
$this->db->where('b.TGL_NOTIFIKASI<=',$tgl);
$this->db->where(['a.STATUS' => 0]);
$this->db->order_by('b.ID_NOTIFIKASI', 'DESC');
return $this->db->get()->result_array();
}
public function getDataNotif($jenis, $jenis2, $id_karyawan)
{
$tgl = date('Y-m-d');
$this->db->select('a.ID_NOTIFIKASI, a.TGL_NOTIFIKASI, a.JENIS_NOTIFIKASI, a.KET_NOTIFIKASI, b.ID_LOG_NOTIFIKASI');
// $this->db->select('*');
$this->db->from('notifikasi a');
$this->db->join('log_notifikasi b', 'b.NOTIFIKASI_ID=a.ID_NOTIFIKASI');
$this->db->where(['a.TGL_NOTIFIKASI' => $tgl, 'b.KARYAWAN_ID' => $id_karyawan]);
$this->db->where(['b.STATUS!=' => 2]);
if ($jenis2 == 0) {
$this->db->where(['a.JENIS_NOTIFIKASI' => $jenis]);
} else {
$this->db->where(['a.JENIS_NOTIFIKASI!=' => 3]);
// $this->db->where(['a.JENIS_NOTIFIKASI' => $jenis2]);
}
$this->db->where(['a.JENIS_NOTIFIKASI!=' => 4]);
$this->db->order_by('a.ID_NOTIFIKASI', 'DESC');
// $this->db->limit(5);/
return $this->db->get()->result_array();
}
public function getDataNotif_AllNotif6($jenis, $id_karyawan)
{
$this->db->select('a.ID_NOTIFIKASI, a.TGL_NOTIFIKASI, a.JENIS_NOTIFIKASI, a.KET_NOTIFIKASI, b.ID_LOG_NOTIFIKASI');
$this->db->from('notifikasi a');
$this->db->join('log_notifikasi b', 'b.NOTIFIKASI_ID=a.ID_NOTIFIKASI');
$this->db->where(['b.KARYAWAN_ID' => $id_karyawan]);
$this->db->where(['b.STATUS!=' => 2]);
$this->db->where(['a.JENIS_NOTIFIKASI' => $jenis]);
$this->db->order_by('a.ID_NOTIFIKASI', 'DESC');
return $this->db->get()->result_array();
}
public function getDataNotif_AllNotif7($id_karyawan) {
$tgl_now = date('Y-m-d');
$tgl_weekbefore = $this->subTempoDay($tgl_now, 7);
$tgl_weekafter = $this->addTempoDay($tgl_now, 7);
$this->db->select('a.ID_NOTIFIKASI, a.TGL_NOTIFIKASI, a.JENIS_NOTIFIKASI, a.KET_NOTIFIKASI, b.ID_LOG_NOTIFIKASI, DATE_FORMAT(a.TGL_NOTIFIKASI,"%d/%m/%Y") as TANGGAL');
$this->db->from('notifikasi a');
$this->db->join('log_notifikasi b', 'b.NOTIFIKASI_ID=a.ID_NOTIFIKASI');
$this->db->where(['b.KARYAWAN_ID' => $id_karyawan]);
$this->db->where(['b.STATUS!=' => 2]);
$this->db->where('a.JENIS_NOTIFIKASI=7');
$this->db->where('a.TGL_NOTIFIKASI>=', $tgl_weekbefore);
$this->db->where('a.TGL_NOTIFIKASI<=', $tgl_weekafter);
$this->db->order_by('a.TGL_NOTIFIKASI', 'DESC');
return $this->db->get()->result_array();
}
public function addTempoDay($date, $day) {
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days");
$dateTo=date('Y-m-d',$sum);
return $dateTo;
}
public function subTempoDay($date, $day) {
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " -$day days");
$dateTo=date('Y-m-d',$sum);
return $dateTo;
}
public function getData_LogNotifikasi_byNOTIFIKASI($id)
{
$this->db->select('*');
$this->db->from('log_notifikasi a');
$this->db->join('notifikasi b', 'b.ID_NOTIFIKASI=a.NOTIFIKASI_ID');
$this->db->join('daftar_salesvisit c', 'c.ID_DSAV=b.DSAV_ID','left');
$this->db->join('sales_visit d', 'd.ID_SAV=c.SAV_ID','left');
$this->db->where(['a.ID_LOG_NOTIFIKASI' => $id]);
return $this->db->get()->result_array();
}
public function getData_LogNotifikasi_byKARYAWAN_status1($id)
{
$this->db->select('*');
$this->db->from('log_notifikasi a');
$this->db->join('notifikasi b', 'b.ID_NOTIFIKASI=a.NOTIFIKASI_ID');
$this->db->where(['a.KARYAWAN_ID' => $id]);
$this->db->where('a.STATUS=1');
return $this->db->get()->result_array();
}
public function getData_HistoriNotifikasi_byKARYAWAN_orderDESC_limit1($id)
{
$tgl = date('Y-m-d');
$this->db->select('*,DATE_FORMAT(TGL_HNF,"%d/%m/%Y") as TANGGAL');
$this->db->from('histori_notifikasi');
$this->db->where(['KARYAWAN_ID' => $id]);
$this->db->where(['TGL_HNF' => $tgl]);
$this->db->order_by('ID_HNF DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getData_SalesVisit_byID($id)
{
$this->db->select('*');
$this->db->from('sales_visit');
$this->db->where(['ID_SAV' => $id]);
return $this->db->get()->result_array();
}
public function getDataReminder($tgl, $id_karyawan)
{
$this->db->select('*');
$this->db->from('log_notifikasi a');
$this->db->join('notifikasi b', 'b.ID_NOTIFIKASI=a.NOTIFIKASI_ID');
$this->db->where('a.KARYAWAN_ID=', $id_karyawan);
$this->db->where('b.TGL_NOTIFIKASI=', $tgl);
$this->db->where('b.JENIS_NOTIFIKASI=4');
$this->db->order_by('a.ID_LOG_NOTIFIKASI', 'DESC');
return $this->db->get()->result_array();
}
public function getIdNotif($jenis, $reminder)
{
$this->db->select('ID_NOTIFIKASI');
$this->db->from('notifikasi');
$this->db->where(['JENIS_NOTIFIKASI' => $jenis, 'KET_NOTIFIKASI' => $reminder]);
$this->db->order_by('ID_NOTIFIKASI', 'DESC');
$this->db->limit(1);
return $this->db->get()->result_array();
}
public function updateLogNotif($id_log, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update('log_notifikasi', $data, array('ID_LOG_NOTIFIKASI' => $id_log));
} else {
$insert = $this->db->update_batch('log_notifikasi', $data, 'ID_LOG_NOTIFIKASI');
}
return $insert;
}
public function cekPass($id, $pass)
{
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where(['ID_KARYAWAN' => $id]);
$this->db->where(['PASSWORD' => $pass]);
return $this->db->get()->result_array();
}
}
+736
View File
@@ -0,0 +1,736 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelPembelian extends CI_Model {
public function create($table, $data, $batch = false) {
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false) {
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk) {
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_Pembelian_Null($id = null, $level = null){ //Pembelian = [1, 5, 11]
if ($id === null) {
$this->db->select('a.CORP_ID,a.ID_PEMBELIAN,a.KODE_PEMBELIAN,a.TGL_PEMBELIAN,a.SJ_PEMBELIAN,a.SUPPLIER_ID,a.TGL_SJBELI,
DATE_FORMAT(a.TGL_SJBELI,"%d/%m/%Y") as TANGGAL,b.NAMA_SUPPLIER,c.NAMA_KOTA');
$this->db->from('pembelian a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('corp d','d.ID_CORP=a.CORP_ID');
$this->db->where('a.STATUS_PEMBELIAN is NULL');
if ($level == 0) {
$this->db->where('a.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('a.CORP_ID=5');
}
}else{
$this->db->select('*');
$this->db->from('pembelian');
$this->db->where('STATUS_PEMBELIAN is NULL');
$this->db->where(['ID_PEMBELIAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_orderDESC_limit1($id) { //RekapGp = [6, 12]
$this->db->select('*');
$this->db->from('histori_kuantiti');
$this->db->where('BARANG_ID=', $id);
$this->db->order_by('ID_HQ DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_orderDESC_limit1_beforeID($id1, $id2) { //RekapGp = [6, 12]
$this->db->select('*');
$this->db->from('histori_kuantiti');
$this->db->where('BARANG_ID=', $id1);
$this->db->where('ID_HQ<', $id2);
$this->db->order_by('ID_HQ DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getData_ReturPenjualan_byKODE($id) {
$this->db->select('*');
$this->db->from('retur_penjualan a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->where('a.KODE_RJ=', $id);
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_byKODEBUKTI_beforeID($barang, $kodebukti, $idhq) { //Penjualan = [47, 54]
$this->db->select('*');
$this->db->from('histori_kuantiti');
$this->db->where('BARANG_ID=', $barang);
$this->db->where('KODE_BUKTI=', $kodebukti);
$this->db->where('ID_HQ<', $idhq);
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_afterID($id1, $id2) { //RekapGp = [6, 12]
$this->db->select('*');
$this->db->from('histori_kuantiti');
$this->db->where('BARANG_ID=', $id1);
$this->db->where('ID_HQ>', $id2);
return $this->db->get()->result_array();
}
public function getData_Corp_forPembelian($level){ //Pembelian = [1]
if ($level == 0) {
$this->db->select('*');
$this->db->from('corp');
$this->db->where('ID_CORP<=4');
} else if ($level == 1) {
$this->db->select('*');
$this->db->from('corp');
$this->db->where('ID_CORP=5');
}
return $this->db->get()->result_array();
}
public function getData_Supplier_byID($id=null) { //Pembelian = [1, 19, 23, 24]
if ($id==null) {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->order_by('a.NAMA_SUPPLIER ASC');
} else {
$this->db->select('*');
$this->db->from('supplier a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->where(['a.ID_SUPPLIER' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Karyawan_forLogin($username, $password) { //Pembelian = [2, 18, 25]
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->where('a.USERNAME=', $username);
$this->db->where('a.PASSWORD=', $password);
return $this->db->get()->result_array();
}
public function getKode_Pembelian() { //Pembelian = [3]
$this->db->select('MAX(KODE_PEMBELIAN) AS KODE');
$this->db->from('pembelian');
return $this->db->get()->result_array();
}
public function getData_Pembelian_byID($id=null) { //Pembelian = [4, 6, 7, 19, 23, 26, 37, 40, 43, 46, 49]
if ($id==null) {
$this->db->select('a.*,b.NAMA_CORP,c.NAMA_SUPPLIER,d.NAMA_KOTA');
$this->db->from('pembelian a');
$this->db->join('corp b','b.ID_CORP=a.CORP_ID','left');
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID','left');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID','left');
} else {
$this->db->select('*');
$this->db->from('pembelian a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->where(['a.ID_PEMBELIAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Pembelian_forSJ($id, $sj) { //Pembelian = [5, 41]
$this->db->select('*');
$this->db->from('pembelian');
$this->db->where('ID_PEMBELIAN!=', $id);
$this->db->where('SJ_PEMBELIAN=', $sj);
return $this->db->get()->result_array();
}
public function getData_DaftarBeli_byPEMBELIAN($id = null){ //Pembelian = [6, 7, 11, 19, 23, 27, 43, 44, 46, 47, 49]
if ($id === null) {
$this->db->select('*,FORMAT(a.HARGA_DB,2) as HARGA');
$this->db->from('daftar_beli a');
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
$this->db->join('kuantiti e','e.ID_KUANTITI=c.ID_BARANG');
}else{
$this->db->select('*,FORMAT(a.HARGA_DB,2) as HARGA');
$this->db->from('daftar_beli a');
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
$this->db->join('kuantiti e','e.ID_KUANTITI=c.ID_BARANG');
$this->db->where(['a.PEMBELIAN_ID' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_HutangDagang_byPEMBELIAN($id) { //Pembelian = [6, 33, 47, 50, 51]
$this->db->select('*');
$this->db->from('hutang_dagang');
$this->db->where(['PEMBELIAN_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_Barang_NonJasa($level){ //Pembelian = [7]
if ($level == 0) {
$this->db->select('a.ID_BARANG,c.PCM_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
} else if ($level == 1) {
$this->db->select('a.ID_BARANG,c.ITP_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
}
$this->db->from('barang a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->join('kuantiti c','c.ID_KUANTITI=a.ID_BARANG');
$this->db->where('b.TYPE_JENIS!=2');
if ($level == 0) {
$this->db->order_by('c.PCM_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
} else if ($level == 1) {
$this->db->order_by('c.ITP_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
}
return $this->db->get()->result_array();
}
public function getData_Barang_status1_NonJasa($level){ //Pembelian = [7]
if ($level == 0) {
$this->db->select('a.ID_BARANG,c.PCM_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
} else if ($level == 1) {
$this->db->select('a.ID_BARANG,c.ITP_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
}
$this->db->from('barang a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->join('kuantiti c','c.ID_KUANTITI=a.ID_BARANG');
$this->db->where('b.TYPE_JENIS!=2');
$this->db->where('a.STATUS_BARANG=1');
if ($level == 0) {
$this->db->order_by('c.PCM_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
} else if ($level == 1) {
$this->db->order_by('c.ITP_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
}
return $this->db->get()->result_array();
}
public function getQtyReal_SnBeli_byDB($id) { //Pembelian = [7, 9, 11, 12, 15, 16]
$this->db->select('a.ID_SNB');
$this->db->from('sn_beli a');
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
$this->db->group_by('a.ID_SNB');
$this->db->where(['a.DB_ID' => $id]);
return $this->db->count_all_results();
}
public function getData_DaftarBeli_byID_byBARANG($id1, $id2){ //Pembelian = [8]
$this->db->select('*');
$this->db->from('daftar_beli');
$this->db->where(['PEMBELIAN_ID' => $id1]);
$this->db->where(['BARANG_ID' => $id2]);
return $this->db->get()->result_array();
}
public function getData_DaftarBeli_byID($id) { //Pembelian = [10, 12, 15, 16, 20, 21, 50]
$this->db->select('*');
$this->db->from('daftar_beli a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->join('pembelian d','d.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->where(['a.ID_DB' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnBeli_byDB($id) { //Pembelian = [10, 13, 14, 23, 43, 47]
$this->db->select('*');
$this->db->from('sn_beli a');
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
$this->db->where(['a.DB_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnBeli_byBARANG($id) { //Pembelian = [12]
$this->db->select('*');
$this->db->from('sn_beli a');
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
$this->db->join('sn_stock c','c.NAMA_SNSTOCK=a.NAMA_SNB','left');
$this->db->where(['b.BARANG_ID' => $id]);
$this->db->where('c.STATUS_SNSTOCK is NULL');
$this->db->order_by('a.ID_SNB DESC');
return $this->db->get()->result_array();
}
public function getData_SnStock_SnBeli_byNAMA_AllStatus($id) { //Pembelian = [15]
$this->db->select('*');
$this->db->from('sn_stock a');
$this->db->join('sn_beli b','b.NAMA_SNB=a.NAMA_SNSTOCK','left');
$this->db->where(['a.NAMA_SNSTOCK' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnIo_byNAMA_AllStatus($id) { //Pembelian = [15]
$this->db->select('*');
$this->db->from('sn_io');
$this->db->where(['NAMA_SNIO' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnBeli_byID($id) { //Pembelian = [16, 27]
$this->db->select('*');
$this->db->from('sn_beli a');
$this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNB','left');
$this->db->where(['a.ID_SNB' => $id]);
return $this->db->get()->result_array();
}
public function getData_Pembelian_0($id = null, $level = null){ //Pembelian = [17, 23, 42, 44]
if ($id == null) {
$this->db->select('*,DATE_FORMAT(a.TGL_PEMBELIAN,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.TGL_SJBELI,"%d/%m/%Y") as TGLSJ');
$this->db->from('pembelian a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.KAR_GUDANG_PEMBELIAN');
$this->db->where('a.STATUS_PEMBELIAN=0');
if ($level == 0) {
$this->db->where('a.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('a.CORP_ID=5');
}
}else{
$this->db->select('*');
$this->db->from('pembelian');
$this->db->where('STATUS_PEMBELIAN=0');
$this->db->where(['ID_PEMBELIAN' => $id]);
}
return $this->db->get()->result_array();
}
public function addTempoDay($date,$day) { //Pembelian = [23, 41]
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days");
$dateTo=date('Y-m-d',$sum);
return $dateTo;
}
public function getID_SNSTOCKMax() { //Pembelian = [23]
$this->db->select_max('ID_SNSTOCK');
$this->db->from('sn_stock');
return $this->db->get()->result_array();
}
public function getData_Kuantiti_byID($id) { //Pembelian = [23, 27, 28, 31, 38, 47]
$this->db->select('*');
$this->db->from('kuantiti');
$this->db->where(['ID_KUANTITI' => $id]);
return $this->db->get()->result_array();
}
public function getData_Pembelian_1($id = null, $level = null, $tanggal_awal = null, $tanggal_akhir = null, $id_supplier = null){ //Pembelian = [24, 45]
if ($id == null) {
$this->db->select('*,DATE_FORMAT(a.TGL_INVBELI,"%d/%m/%Y") as TGLINV');
$this->db->from('pembelian a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->where('a.STATUS_PEMBELIAN=1');
$this->db->where('a.TGL_INVBELI>=', $tanggal_awal);
$this->db->where('a.TGL_INVBELI<=', $tanggal_akhir);
if ($id_supplier!=null) {
$this->db->where('a.SUPPLIER_ID=', $id_supplier);
}
if ($level == 0) {
$this->db->where('a.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('a.CORP_ID=5');
}
$this->db->order_by('a.KODE_PEMBELIAN ASC');
}else{
$this->db->select('*');
$this->db->from('pembelian');
$this->db->where('STATUS_PEMBELIAN=1');
$this->db->where(['ID_PEMBELIAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_ReturPembelian_byPEMBELIAN_byKARYAWAN_Null($id_pembelian, $id_karyawan){ //Pembelian = [24]
$this->db->select('*');
$this->db->from('retur_pembelian');
$this->db->where(['PEMBELIAN_ID' => $id_pembelian, 'ADMIN_ID' => $id_karyawan]);
$this->db->where('STATUS_RB is NULL');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byPEMBELIAN_byKARYAWAN_byLEVEL_KODENull($id_pembelian, $id_karyawan, $level) { //Pembelian = [26, 30]
$this->db->select('*');
$this->db->from('daftar_returbeli a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('retur_pembelian c','c.ID_RB=a.RB_ID');
$this->db->join('pembelian d','d.ID_PEMBELIAN=c.PEMBELIAN_ID');
$this->db->join('corp e','e.ID_CORP=d.CORP_ID');
$this->db->join('karyawan f','f.ID_KARYAWAN=c.ADMIN_ID');
$this->db->join('jabatan g','g.ID_JABATAN=f.JABATAN_ID');
$this->db->where(['c.PEMBELIAN_ID' => $id_pembelian]);
$this->db->where(['c.ADMIN_ID' => $id_karyawan]);
$this->db->where(['g.LEVEL_JABATAN' => $level]);
$this->db->where('c.KODE_RB is NULL');
return $this->db->get()->result_array();
}
public function getData_DaftarBeli_byPEMBELIAN_JENIS0($id, $level) { //Pembelian = [26]
if ($level == 0) {
$this->db->select('a.QTY_DB,c.*,d.NAMA_JENIS,e.PCM_KUANTITI as REAL');
} else if ($level == 1) {
$this->db->select('a.QTY_DB,c.*,d.NAMA_JENIS,e.ITP_KUANTITI as REAL');
}
$this->db->from('daftar_beli a');
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
$this->db->join('kuantiti e','e.ID_KUANTITI=c.ID_BARANG');
$this->db->where(['b.ID_PEMBELIAN' => $id]);
$this->db->where('d.TYPE_JENIS="0"');
return $this->db->get()->result_array();
}
public function getData_SnBeli_byPEMBELIAN($id) { //Pembelian = [26]
$this->db->select('*');
$this->db->from('sn_beli a');
$this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNB','left');
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID','left');
$this->db->join('daftar_beli d','d.ID_DB=a.DB_ID','left');
$this->db->where(['d.PEMBELIAN_ID' => $id]);
$this->db->order_by('a.NAMA_SNB ASC');
return $this->db->get()->result_array();
}
public function getData_SnReturBeli_byDRB_RBNull($id_drb) { //Pembelian = [26, 28]
$this->db->select('*');
$this->db->from('sn_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
$this->db->join('pembelian c','c.ID_PEMBELIAN=b.PEMBELIAN_ID');
$this->db->where(['a.DRB_ID' => $id_drb]);
$this->db->where('b.STATUS_RB is NULL');
$this->db->where('c.STATUS_PEMBELIAN=1');
return $this->db->get()->result_array();
}
public function getSum_DaftarReturBeli_byPEMBELIAN_byBARANG($id1,$id2) { //Pembelian = [27]
$this->db->select('*,SUM(a.QTY_DRB) as TOTAL_DRB');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID','left');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID','left');
$this->db->where(['b.PEMBELIAN_ID' => $id1]);
$this->db->where(['a.BARANG_ID' => $id2]);
return $this->db->get()->result_array();
}
public function getData_ReturPembelian_byPEMBELIAN_byADMIN_Null($id1, $id2) { //Pembelian = [27]
$this->db->select('*');
$this->db->from('retur_pembelian');
$this->db->where(['PEMBELIAN_ID' => $id1]);
$this->db->where(['ADMIN_ID' => $id2]);
$this->db->where('STATUS_RB is NULL');
return $this->db->get()->result_array();
}
public function getID_RBMax() { //Pembelian = [27]
$this->db->select_max('ID_RB');
$this->db->from('retur_pembelian');
return $this->db->get()->result_array();
}
public function getData_SnReturBeli_byRB_groupBARANG($id) { //Pembelian = [27]
$this->db->select('c.BARANG_ID,a.NAMA_SNRB');
$this->db->from('sn_returbeli a');
$this->db->join('sn_beli b','b.DB_ID=a.DB_ID','left');
$this->db->join('daftar_beli c','c.ID_DB=b.DB_ID','left');
$this->db->where(['a.RB_ID' => $id]);
$this->db->group_by('c.BARANG_ID');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byRB_byBARANG_byADMIN_Null($id_rb, $id_barang, $id_admin){ //Pembelian = [27]
$this->db->select('*');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->where(['a.RB_ID' => $id_rb]);
$this->db->where(['a.BARANG_ID' => $id_barang]);
$this->db->where(['b.ADMIN_ID' => $id_admin]);
$this->db->where('b.KODE_RB is NULL');
$this->db->where('b.STATUS_RB is NULL');
return $this->db->get()->result_array();
}
public function getData_SnStock_bySNB_2($id) { //Pembelian = [27]
$this->db->select('a.BARANG_ID');
$this->db->from('sn_stock a');
$this->db->join('sn_beli b','b.NAMA_SNB=a.NAMA_SNSTOCK');
$this->db->where(['b.ID_SNB' => $id]);
$this->db->where('a.STATUS_SNSTOCK=2');
$this->db->group_by('a.ID_SNSTOCK');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byRB_groupID($id){ //Pembelian = [27]
$this->db->select('*,CONCAT("Rp ",FORMAT(a.HARGA_DRB,2)) as HARGA,a.BARANG_ID as BID');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID','left');
$this->db->join('daftar_beli c','c.PEMBELIAN_ID=b.PEMBELIAN_ID','left');
$this->db->join('barang d','d.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis e','e.ID_JENIS=d.JENIS_ID');
$this->db->where(['a.RB_ID' => $id]);
$this->db->group_by('a.ID_DRB');
return $this->db->get()->result_array();
}
public function getData_SnReturBeli_byRB_groupID($id) { //Pembelian = [27, 31, 36]
$this->db->select('*');
$this->db->from('sn_returbeli a');
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
$this->db->where(['a.RB_ID' => $id]);
$this->db->group_by('a.ID_SNRB');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byID($id) { //Pembelian = [28, 34, 35]
$this->db->select('*');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->where(['a.ID_DRB' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnStock_byNAMA_2($id) { //Pembelian = [28, 31, 36, 38]
$this->db->select('ID_SNSTOCK');
$this->db->from('sn_stock');
$this->db->where(['NAMA_SNSTOCK' => $id]);
$this->db->where('STATUS_SNSTOCK=2');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byRB_Null($id){ //Pembelian = [28, 31]
$this->db->select('*');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
$this->db->where('b.STATUS_RB is NULL');
$this->db->where(['a.RB_ID' => $id]);
return $this->db->get()->result_array();
}
public function getKode_ReturPembelian() { //Pembelian = [29]
$this->db->select('MAX(KODE_RB) AS KODE');
$this->db->from('retur_pembelian');
return $this->db->get()->result_array();
}
public function getData_ReturPembelian_Null($id){ //Pembelian = [30, 31]
$this->db->select('*');
$this->db->from('retur_pembelian');
$this->db->where('STATUS_RB is NULL');
$this->db->where(['ID_RB' => $id]);
return $this->db->get()->result_array();
}
public function getData_ReturPembelian_0($id = null){ //Pembelian = [32,33, 36, 38]
if ($id === null) {
$this->db->select('a.ID_RB,a.KET_RB,a.KODE_RB,b.CORP_ID,b.INV_PEMBELIAN,c.NAMA_SUPPLIER,d.NAMA_KOTA,
DATE_FORMAT(a.TGL_RB,"%d/%m/%Y") as TANGGAL');
$this->db->from('retur_pembelian a');
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=b.SUPPLIER_ID');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
$this->db->group_by('a.ID_RB');
$this->db->where('a.STATUS_RB=0');
}else{
$this->db->select('*');
$this->db->from('retur_pembelian a');
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=b.SUPPLIER_ID');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
$this->db->join('daftar_returbeli e','e.RB_ID=a.ID_RB','left');
$this->db->join('barang f','f.ID_BARANG=e.BARANG_ID','left');
$this->db->join('jenis g','g.ID_JENIS=f.JENIS_ID','left');
$this->db->where('a.STATUS_RB=0');
$this->db->where(['a.ID_RB' => $id]);
$this->db->group_by('a.ID_RB');
}
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byRB_byBARANG_0($id){ //Pembelian = [33]
$this->db->select('*,FORMAT(a.HARGA_DRB,2) as HARGA,a.BARANG_ID as BID');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
$this->db->join('daftar_beli e','e.PEMBELIAN_ID=b.PEMBELIAN_ID','left');
$this->db->where('b.STATUS_RB=0');
$this->db->where('a.BARANG_ID=e.BARANG_ID');
$this->db->where(['a.RB_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_ReturPembelian_byID($id) { //Pembelian = [37]
$this->db->select('*');
$this->db->from('retur_pembelian');
$this->db->where(['ID_RB' => $id]);
return $this->db->get()->result_array();
}
public function getKode_INVReturBeliTMP() { //Pembelian = [37]
$this->db->select('MAX(INV_RB) AS KODE');
$this->db->from('retur_pembelian');
$this->db->like('INV_RB','RT/TMP', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVReturBeliDMT() { //Pembelian = [37]
$this->db->select('MAX(INV_RB) AS KODE');
$this->db->from('retur_pembelian');
$this->db->like('INV_RB','RT/DMT', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVReturBeliPCM() { //Pembelian = [37]
$this->db->select('MAX(INV_RB) AS KODE');
$this->db->from('retur_pembelian');
$this->db->like('INV_RB','RT/PCM', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVReturBeliSFTR() { //Pembelian = [37]
$this->db->select('MAX(INV_RB) AS KODE');
$this->db->from('retur_pembelian');
$this->db->like('INV_RB','RT/SFT', 'after');
return $this->db->get()->result_array();
}
public function getKode_INVReturBeliITP() { //Pembelian = [37]
$this->db->select('MAX(INV_RB) AS KODE');
$this->db->from('retur_pembelian');
$this->db->like('INV_RB','RT/ITP', 'after');
return $this->db->get()->result_array();
}
public function getData_DaftarReturBeli_byRB_0($id){ //Pembelian = [36, 38]
$this->db->select('*');
$this->db->from('daftar_returbeli a');
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
$this->db->where('b.STATUS_RB=0');
$this->db->where(['a.RB_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnReturBeli_byRB_byBARANG($id1,$id2) { //Pembelian = [38]
$this->db->select('a.NAMA_SNRB');
$this->db->from('sn_returbeli a');
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
$this->db->where(['a.RB_ID' => $id1]);
$this->db->where(['b.BARANG_ID' => $id2]);
$this->db->group_by('a.ID_SNRB');
return $this->db->get()->result_array();
}
public function subTempoMonth($date,$month) { //Pembelian = [39]
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " -$month months");
$dateTo=date('Y-m-d',$sum);
return $dateTo;
}
public function getData_Pembelian_forUbah($id=null, $level=null, $tanggal_awal=null, $tanggal_akhir=null) { //Pembelian = [39, 40, 48, 50, 51]
if ($id==NULL) {
$this->db->select('*,DATE_FORMAT(a.TGL_INVBELI,"%d/%m/%Y") as TGL_INV,DATE_FORMAT(a.TEMPO_INVBELI,"%d/%m/%Y") as TEMPO_INV,
,DATE_FORMAT(a.TT_PEMBELIAN,"%d/%m/%Y") as TT_INV');
$this->db->from('pembelian a');
$this->db->join('corp b','b.ID_CORP=a.CORP_ID');
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
$this->db->where('a.TGL_INVBELI>=', $tanggal_awal);
$this->db->where('a.TGL_INVBELI<=', $tanggal_akhir);
$this->db->where('a.STATUS_PEMBELIAN=1');
if ($level == 0) {
$this->db->where('a.CORP_ID<=4');
} else if ($level == 1) {
$this->db->where('a.CORP_ID=5');
}
$this->db->group_by('a.KODE_PEMBELIAN');
$this->db->order_by('a.KODE_PEMBELIAN ASC,a.TGL_INVBELI ASC');
} else {
$this->db->select('*,DATE_FORMAT(a.TGL_INVBELI,"%d/%m/%Y") as TGL_INV,DATE_FORMAT(a.TEMPO_INVBELI,"%d/%m/%Y") as TEMPO_INV,
,DATE_FORMAT(a.TT_PEMBELIAN,"%d/%m/%Y") as TT_INV');
$this->db->from('pembelian a');
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('hutang_dagang d','d.PEMBELIAN_ID=a.ID_PEMBELIAN');
$this->db->where('a.STATUS_PEMBELIAN=1');
$this->db->where(['a.ID_PEMBELIAN' => $id]);
$this->db->group_by('a.ID_PEMBELIAN');
}
return $this->db->get()->result_array();
}
public function getData_Pembelian_forINV($id, $inv) { //Pembelian = [41]
$this->db->select('*');
$this->db->from('pembelian');
$this->db->where('ID_PEMBELIAN!=', $id);
$this->db->where('INV_PEMBELIAN=', $inv);
return $this->db->get()->result_array();
}
public function getData_SnStock_byNAMA_AllStatus($id) { //Pembelian = [47]
$this->db->select('ID_SNSTOCK,STATUS_SNSTOCK');
$this->db->from('sn_stock');
$this->db->where(['NAMA_SNSTOCK' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnReturJual_byNAMA($nama) { //Pembelian = [47]
$this->db->select('*');
$this->db->from('sn_returjual');
$this->db->where(['NAMA_SNRJ' => $nama]);
return $this->db->get()->result_array();
}
public function getData_Pembelian_1_checkRevisi($id, $tgl) { //Pembelian = [47]
$this->db->select('*');
$this->db->from('pembelian');
$this->db->where(['ID_PEMBELIAN' => $id]);
$this->db->where('TGL_INVBELI>=', $tgl);
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_byKODE($id, $kode) { //Pembelian = [50]
$this->db->select('*');
$this->db->from('histori_kuantiti');
$this->db->where(['BARANG_ID' => $id]);
$this->db->where(['KODE_BUKTI' => $kode]);
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byKODE($kode) { //Pembelian = [50]
$this->db->select('*');
$this->db->from('histori_kuantiti');
$this->db->where(['KODE_BUKTI' => $kode]);
return $this->db->get()->result_array();
}
public function getSum_DaftarBeli_byPEMBELIAN($id) { //Pembelian = [50, 51]
$this->db->select('sum(HARGA_DB*QTY_DB) as TOTAL');
$this->db->from('daftar_beli');
$this->db->where(['PEMBELIAN_ID' => $id]);
return $this->db->get()->result_array();
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+711
View File
@@ -0,0 +1,711 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelRekapGp extends CI_Model {
public function create($table, $data, $batch = false)
{
if($batch === false){
$insert = $this->db->insert($table, $data);
}else{
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if($batch === false){
$insert = $this->db->update($table, $data, array($pk => $id));
}else{
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_SalesAll() { //RekapGp = [1]
$this->db->select('*, b.NAMA_JABATAN');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->where('a.ID_KARYAWAN!=1');
$this->db->where('b.NAMA_JABATAN!="GUDANG"');
$this->db->where('b.NAMA_JABATAN!="KEUANGAN"');
$this->db->where('b.NAMA_JABATAN!="UMUM"');
$this->db->where('b.NAMA_JABATAN!="SERVICE"');
$this->db->where('b.NAMA_JABATAN!="SUPPORT"');
$this->db->where('b.NAMA_JABATAN!="ADMIN GUDANG"');
$this->db->where('b.NAMA_JABATAN!="ADMIN KEUANGAN"');
$this->db->where('b.NAMA_JABATAN!="ADMIN UMUM"');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Hwely');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Gita');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Insentive');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','ITP');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Louis');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','None');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Service');
$this->db->not_like('a.NAMA_PANGGILAN_KARYAWAN','Sugeng');
$this->db->order_by('a.NAMA_PANGGILAN_KARYAWAN');
return $this->db->get()->result_array();
}
public function getData_Pelanggan_byID($id = null) { //RekapGp = [1]
if ($id == null) {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
} else {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
$this->db->where(['a.ID_PELANGGAN' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Proyek_forSales_Null_0($id) { //RekapGp = [1]
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_PROYEK is NULL AND a.SALES_ID=', $id);
$this->db->or_where('a.STATUS_PROYEK=0 AND a.SALES_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_Proyek_Null_0($id=null) { //RekapGp = [1]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_PROYEK is NULL');
$this->db->or_where('a.STATUS_PROYEK=0');
} else {
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_PROYEK is NULL');
$this->db->where(['a.ID_PROYEK' => $id]);
}
return $this->db->get()->result_array();
}
public function getKode_Proyek() { //RekapGp = [2]
$this->db->select('MAX(KODE_PROYEK) AS KODE');
$this->db->from('proyek');
$this->db->like('KODE_PROYEK','PRO','after');
return $this->db->get()->result_array();
}
public function getData_Proyek_byPO($po, $id=null) { //RekapGp = [3, 4]
$this->db->select('*');
$this->db->from('proyek');
$this->db->where('PO_PROYEK=', $po);
if ($id!=null) {
$this->db->where('ID_PROYEK!=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Proyek_byID($id) { //RekapGp = [4, 5, 6, 7, 9, 12, 14, 17, 18, 22, 23]
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->where(['a.ID_PROYEK' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarProyek_byPROYEK($id) { //RekapGp = [5, 6, 12, 16, 18, 22]
$this->db->select('*,FORMAT(a.HARGA_DPR,2) as HARGA');
$this->db->from('daftar_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
$this->db->where(['a.PROYEK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_byPROYEK($id) { //RekapGp = [5]
$this->db->select('*');
$this->db->from('transaksi_stock');
$this->db->where(['PROYEK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SoProyek_byPROYEK($id) { //RekapGp = [5, 6, 12, 16, 18 ,22]
$this->db->select('*,FORMAT(c.NILAI_SO,2) as NILAI,FORMAT(c.FEE_SO,2) as FEE,DATE_FORMAT(d.TGL_PENJUALAN,"%d/%m/%Y") as TANGGAL,a.SO_ID as SID');
$this->db->from('so_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('sales_order c','c.ID_SO=a.SO_ID');
$this->db->join('penjualan d','d.SO_ID=a.SO_ID');
$this->db->where('a.PROYEK_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_BiayaProyek_byPROYEK($id) { //RekapGp = [5, 6, 16, 18, 22]
$this->db->select('*,FORMAT(a.NILAI_BPRY,2) as NILAI');
$this->db->from('biaya_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where('a.PROYEK_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_HppProyek_byPROYEK($id) { //RekapGp = [6, 16, 18, 22]
$this->db->select('*,FORMAT(a.HARGA_HPR,2) as HARGA,DATE_FORMAT(a.TGL_HPR,"%d/%m/%Y") as TANGGAL');
$this->db->from('hpp_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('daftar_kasbank c','c.ID_DKB=a.DKB_ID');
$this->db->where(['a.PROYEK_ID' => $id]);
$this->db->order_by('a.ID_HPR DESC');
return $this->db->get()->result_array();
}
public function getSum_HppProyek_byPROYEK($id) { //RekapGp = [6, 16, 18, 22]
$this->db->select('SUM(a.HARGA_HPR) as TOTAL');
$this->db->from('hpp_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where(['a.PROYEK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byPELANGGAN_bySALES_status1_forProyek($id_pelanggan, $id_sales) { //RekapGp = [6, 18]
$this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL,FORMAT(a.NILAI_SO,2) as TOTAL');
$this->db->from('sales_order a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('so_proyek d','d.SO_ID=a.ID_SO','left');
$this->db->where('d.ID_SPR is NULL');
$this->db->where('a.STATUS_SO=1');
$this->db->where('a.GP_SO=1');
$this->db->where('a.PELANGGAN_ID=', $id_pelanggan);
$this->db->where('a.SALES_ID=', $id_sales);
$this->db->order_by('a.ID_SO DESC');
return $this->db->get()->result_array();
}
public function getSum_SoProyek_byPROYEK($id) { //RekapGp = [6, 13, 16, 18, 19, 22]
$this->db->select('SUM(c.HARGA_DO*c.QTY_DO) as NILAI');
$this->db->from('so_proyek a');
$this->db->join('sales_order b','b.ID_SO=a.SO_ID');
$this->db->join('daftar_order c','c.SO_ID=a.SO_ID');
$this->db->where(['a.PROYEK_ID' => $id]);
$this->db->group_by('a.PROYEK_ID');
return $this->db->get()->result_array();
}
public function getSum_SoProyek_byPROYEK_forFEE($id) { //RekapGp = [6, 13, 16, 18, 19, 22]
$this->db->select('SUM(b.FEE_SO) as FEE');
$this->db->from('so_proyek a');
$this->db->join('sales_order b','b.ID_SO=a.SO_ID');
$this->db->where(['a.PROYEK_ID' => $id]);
$this->db->group_by('a.PROYEK_ID');
return $this->db->get()->result_array();
}
public function getSum_BiayaProyek_byPROYEK($id) { //RekapGp = [6, 16, 18, 22]
$this->db->select('SUM(NILAI_BPRY) as TOTAL');
$this->db->from('biaya_proyek');
$this->db->where(['PROYEK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_MasukLebih0($id) { //RekapGp = [6, 12]
$this->db->select('*,DATE_FORMAT(a.TGL_HQ,"%d/%m/%Y") as TANGGAL');
$this->db->from('histori_kuantiti a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->order_by('a.ID_HQ ASC');
$this->db->where(['a.BARANG_ID' => $id]);
$this->db->where('a.MASUK_HQ>0');
return $this->db->get()->result_array();
}
public function getSum_HistoriKuantiti_byBARANG_byHQ($id_barang, $id_hq) { //RekapGp = [6, 12, 13, 16, 18, 19, 22]
$this->db->select('SUM(a.MASUK_HQ-a.KELUAR_HQ) as TOTAL, SUM(a.KELUAR_HQ) as KELUAR');
$this->db->from('histori_kuantiti a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.BARANG_ID' => $id_barang]);
$this->db->where('a.ID_HQ<=', $id_hq);
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_limitHQ($id_barang, $id_hq) { //RekapGp = [6, 12, 13, 16, 18, 19, 22]
$this->db->select('*,DATE_FORMAT(a.TGL_HQ,"%d/%m/%Y") as TANGGAL');
$this->db->from('histori_kuantiti a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.BARANG_ID' => $id_barang]);
$this->db->where('a.ID_HQ<', $id_hq);
$this->db->where('a.MASUK_HQ>0');
$this->db->order_by('a.ID_HQ DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getSum_HistoriKuantiti_byBARANG_byHQ1_byHQ2($id_barang, $id_hq1, $id_hq2) { //RekapGp = [6, 12, 13, 16, 18, 19, 22]
$this->db->select('SUM(a.KELUAR_HQ) as KELUAR');
$this->db->from('histori_kuantiti a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.BARANG_ID' => $id_barang]);
$this->db->where('a.ID_HQ<=', $id_hq1);
$this->db->where('a.ID_HQ>=', $id_hq2);
return $this->db->get()->result_array();
}
public function getSum_DaftarOrder_bySO($id) { //RekapGp = [6, 16, 18, 22]
$this->db->select('SUM(a.HARGA_DO*a.QTY_DO) as TOTAL');
$this->db->from('daftar_order a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.SO_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarOrder_bySO($id) { //RekapGp = [6, 18]
$this->db->select('*');
$this->db->from('daftar_order a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.SO_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_DaftarOrder_bySO_jenisNot2($id) { //RekapGp = [6, 13, 16, 18, 19, 22]
$this->db->select('*,DATE_FORMAT(d.TGL_PENJUALAN,"%d/%m/%Y") as TANGGAL');
$this->db->from('daftar_order a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->join('penjualan d','d.SO_ID=a.SO_ID');
$this->db->where(['a.SO_ID' => $id]);
$this->db->where('c.TYPE_JENIS!=2');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_bySO_jenis0($id) { //RekapGp = [6, 13, 16, 18, 19, 22]
$this->db->select('*,DATE_FORMAT(a.TGL_IO,"%d/%m/%Y") as TANGGAL');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.SO_ID' => $id]);
$this->db->where('a.JENIS_IO=0');
return $this->db->get()->result_array();
}
public function getData_TransaksiStock_bySO_jenis1($id) { //RekapGp = [6, 13, 16, 18, 19, 22]
$this->db->select('*,DATE_FORMAT(a.TGL_IO,"%d/%m/%Y") as TANGGAL');
$this->db->from('transaksi_stock a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->where(['a.SO_ID' => $id]);
$this->db->where('a.JENIS_IO=1');
return $this->db->get()->result_array();
}
public function getData_HistoriKuantiti_byBARANG_MasukLebih0_beforeTGL($id, $tgl) { //RekapGp = [6, 13, 16, 18, 19, 22]
$this->db->select('*,DATE_FORMAT(a.TGL_HQ,"%d/%m/%Y") as TANGGAL');
$this->db->from('histori_kuantiti a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
$this->db->order_by('a.ID_HQ ASC');
$this->db->where(['a.BARANG_ID' => $id]);
$this->db->where('a.MASUK_HQ>0');
$this->db->where('a.TGL_HQ<=', $tgl);
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byID($id=null) { //RekapGp = [7, 23]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL');
$this->db->from('sales_order a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_SO=1');
} else {
$this->db->select('*');
$this->db->from('sales_order');
$this->db->where(['ID_SO' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_SoProyek_bySO($id) { //RekapGp = [7, 22, 23]
$this->db->select('*,FORMAT(c.NILAI_SO,2) as NILAI,DATE_FORMAT(d.TGL_PENJUALAN,"%d/%m/%Y") as TANGGAL');
$this->db->from('so_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('sales_order c','c.ID_SO=a.SO_ID');
$this->db->join('penjualan d','d.SO_ID=a.SO_ID');
$this->db->where('a.SO_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SoProyek_byID($id) { //RekapGp = [8]
$this->db->select('*,FORMAT(c.NILAI_SO,2) as NILAI,DATE_FORMAT(d.TGL_PENJUALAN,"%d/%m/%Y") as TANGGAL');
$this->db->from('so_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('sales_order c','c.ID_SO=a.SO_ID');
$this->db->join('penjualan d','d.SO_ID=a.SO_ID');
$this->db->where('a.ID_SPR=', $id);
return $this->db->get()->result_array();
}
public function getData_BiayaProyek_byID($id) { //RekapGp = [10, 11]
$this->db->select('*,FORMAT(a.NILAI_BPRY,2) as NILAI');
$this->db->from('biaya_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where('a.ID_BPRY=', $id);
return $this->db->get()->result_array();
}
public function getCount_SnProyek_byDPR($id){ //RekapGp = [12]
$this->db->select('ID_SNPR');
$this->db->from('sn_proyek');
$this->db->where('DPR_ID=', $id);
return $this->db->count_all_results();
}
public function getID_TransaksiStockMax() { //RekapGp = [12]
$this->db->select_max('ID_IO');
$this->db->from('transaksi_stock');
return $this->db->get()->result_array();
}
public function getData_SnProyek_byDPR($id) { //RekapGp = [12]
$this->db->select('*');
$this->db->from('sn_proyek');
$this->db->where(['DPR_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_SnStock_byNAMA_19($id) { //RekapGp = [12]
$this->db->select('ID_SNSTOCK');
$this->db->from('sn_stock');
$this->db->where(['NAMA_SNSTOCK' => $id]);
$this->db->where('STATUS_SNSTOCK=19');
return $this->db->get()->result_array();
}
public function getData_Kuantiti_byID($id=null) { //RekapGp = [12]
if ($id==null) {
$this->db->select('*');
$this->db->from('kuantiti');
} else {
$this->db->select('*');
$this->db->from('kuantiti');
$this->db->where(['ID_KUANTITI' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Kuartal() { //RekapGp = [13]
$this->db->select('*,DATE_FORMAT(AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('kuartal');
$this->db->where('STATUS_KUARTAL is NULL');
return $this->db->get()->result_array();
}
public function getData_Proyek_status1_RQNotNull($id) { //RekapGp = [13]
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->join('rekap_kuartal e','e.ID_RQ=a.RQ_ID');
$this->db->join('kuartal f','f.ID_KUARTAL=e.KUARTAL_ID');
$this->db->where('a.STATUS_PROYEK=1 AND e.STATUS_RQ is NULL AND a.SALES_ID=', $id);
$this->db->or_where('a.STATUS_PROYEK=1 AND e.STATUS_RQ=0 AND a.SALES_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_Proyek_status1_RQNull($id) { //RekapGp = [13]
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_PROYEK=1');
$this->db->where('a.RQ_ID IS NULL');
$this->db->where(['a.SALES_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_RekapKuartal_bySALES_statusNull0($id=null) { //RekapGp = [13]
$this->db->select('*,DATE_FORMAT(b.AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(b.AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('rekap_kuartal a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->join('karyawan c','c.ID_KARYAWAN=a.SALES_ID');
if ($id!=null) {
$this->db->where('a.STATUS_RQ is NULL AND a.SALES_ID=', $id);
$this->db->or_where('a.STATUS_RQ=0 AND a.SALES_ID=', $id);
} else {
$this->db->where('a.STATUS_RQ is NULL');
$this->db->or_where('a.STATUS_RQ=0');
}
return $this->db->get()->result_array();
}
public function getData_Proyek_1_RqNotNull($id=null) { //RekapGp = [13]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->join('rekap_kuartal e','e.ID_RQ=a.RQ_ID');
$this->db->join('kuartal f','f.ID_KUARTAL=e.KUARTAL_ID');
$this->db->where('a.STATUS_PROYEK=1 AND e.STATUS_RQ is NULL');
$this->db->or_where('a.STATUS_PROYEK=1 AND e.STATUS_RQ=0');
} else {
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->join('rekap_kuartal e','e.ID_RQ=a.RQ_ID');
$this->db->join('kuartal f','f.ID_KUARTAL=e.KUARTAL_ID');
$this->db->where('a.STATUS_PROYEK=1 AND e.STATUS_RQ is NULL AND a.ID_PROYEK=', $id);
$this->db->or_where('a.STATUS_PROYEK=1 AND e.STATUS_RQ=0 AND a.ID_PROYEK=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Proyek_1_RqNull($id=null) { //RekapGp = [13]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_PROYEK=1');
$this->db->where('a.RQ_ID IS NULL');
} else {
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_PROYEK=1');
$this->db->where('a.RQ_ID IS NULL');
$this->db->where(['a.ID_PROYEK' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_Proyek_byRQ($id) { //RekapGp = [13, 15, 19]
$this->db->select('*,a.SALES_ID as SID');
$this->db->from('proyek a');
$this->db->join('rekap_kuartal b','b.ID_RQ=a.RQ_ID');
$this->db->join('pelanggan c','c.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->where('a.RQ_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SoProyek_byRQ($id) { //RekapGp = [13, 16, 19]
$this->db->select('*,a.SO_ID as SOID,b.SO_ID as POID,DATE_FORMAT(b.TGL_PROYEK,"%d/%m/%Y") as TANGGAL,FORMAT(d.NILAI_SO,2) as NILAI,FORMAT(d.FEE_SO,2) as FEE');
$this->db->from('so_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('penjualan c','c.SO_ID=a.SO_ID');
$this->db->join('sales_order d','d.ID_SO=a.SO_ID');
$this->db->join('pelanggan e','e.ID_PELANGGAN=d.PELANGGAN_ID');
$this->db->join('kota f','f.ID_KOTA=e.KOTA_ID');
$this->db->where('b.RQ_ID=', $id);
$this->db->order_by('e.NAMA_PELANGGAN ASC,b.KODE_PROYEK ASC,d.KODE_SO ASC');
return $this->db->get()->result_array();
}
public function getSum_SoProyek_byRQ($id) { //RekapGp = [13, 19]
$this->db->select('SUM(d.HARGA_DO*d.QTY_DO) as TOTAL');
$this->db->from('so_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('sales_order c','c.ID_SO=a.SO_ID');
$this->db->join('daftar_order d','d.SO_ID=a.SO_ID');
$this->db->where(['b.RQ_ID' => $id]);
$this->db->group_by('b.RQ_ID');
return $this->db->get()->result_array();
}
public function getSum_FeeSO_byRQ($id) { //RekapGp = [13, 19]
$this->db->select('SUM(c.FEE_SO) as TOTAL');
$this->db->from('so_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->join('sales_order c','c.ID_SO=a.SO_ID');
$this->db->where(['b.RQ_ID' => $id]);
$this->db->group_by('b.RQ_ID');
return $this->db->get()->result_array();
}
public function getSum_BiayaProyek_byRQ($id) { //RekapGp = [13, 19]
$this->db->select('SUM(a.NILAI_BPRY) as TOTAL');
$this->db->from('biaya_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where(['b.RQ_ID' => $id]);
return $this->db->get()->result_array();
}
public function getSum_HppProyek_byRQ($id) { //RekapGp = [13, 19]
$this->db->select('SUM(a.HARGA_HPR) as TOTAL');
$this->db->from('hpp_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where(['b.RQ_ID' => $id]);
return $this->db->get()->result_array();
}
public function getSum_DaftarProyek_byPROYEK($id) { //RekapGp = [13, 16, 19]
$this->db->select('SUM(a.HARGA_DPR*a.QTY_DPR) as TOTAL');
$this->db->from('daftar_proyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where(['a.PROYEK_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_Kuartal_byID($id) { //RekapGp = [14]
$this->db->select('*,DATE_FORMAT(AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('kuartal');
$this->db->where('ID_KUARTAL=', $id);
return $this->db->get()->result_array();
}
public function getData_RekapKuartal_bySALES_byKUARTAL_statusNull($id_sales, $id_kuartal) { //RekapGp = [14]
$this->db->select('*,DATE_FORMAT(b.AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(b.AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('rekap_kuartal a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->join('karyawan c','c.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_RQ is NULL');
$this->db->where('a.SALES_ID=', $id_sales);
$this->db->where('a.KUARTAL_ID=', $id_kuartal);
return $this->db->get()->result_array();
}
public function getID_RQMax() { //RekapGp = [14]
$this->db->select_max('ID_RQ');
$this->db->from('rekap_kuartal');
return $this->db->get()->result_array();
}
public function getData_RekapKuartal_byID($id) { //RekapGp = [15, 16, 17, 20, 21]
$this->db->select('*,DATE_FORMAT(b.AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(b.AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('rekap_kuartal a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->join('karyawan c','c.ID_KARYAWAN=a.SALES_ID');
$this->db->where(['a.ID_RQ' => $id]);
return $this->db->get()->result_array();
}
public function getData_Proyek_bySALES_statusNull($sales, $awal, $akhir) { //RekapGp = [15]
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.SALES_ID=', $sales);
$this->db->where('a.TGL_PROYEK>=', $awal);
$this->db->where('a.TGL_PROYEK<=', $akhir);
$this->db->where('a.STATUS_PROYEK is NULL');
return $this->db->get()->result_array();
}
public function getSum_SoProyek_bySO($id) { //RekapGp = [16]
$this->db->select('(SUM(c.HARGA_DO*c.QTY_DO)-b.FEE_SO) as TOTAL,SUM(c.HARGA_DO*c.QTY_DO) as NILAI,b.FEE_SO as FEE');
$this->db->from('so_proyek a');
$this->db->join('sales_order b','b.ID_SO=a.SO_ID');
$this->db->join('daftar_order c','c.SO_ID=a.SO_ID');
$this->db->where(['a.SO_ID' => $id]);
return $this->db->get()->result_array();
}
public function getSum_HppAwalProyek_byPROYEK_status1($id) { //RekapGp = [16]
$this->db->select('SUM(a.NILAI_HAP) as TOTAL');
$this->db->from('hpp_awalproyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where('a.PROYEK_ID=', $id);
$this->db->where('a.JENIS_HAP=1');
return $this->db->get()->result_array();
}
public function getSum_HppAwalProyek_byPROYEK_status2($id) { //RekapGp = [16]
$this->db->select('SUM(a.NILAI_HAP) as TOTAL');
$this->db->from('hpp_awalproyek a');
$this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID');
$this->db->where('a.PROYEK_ID=', $id);
$this->db->where('a.JENIS_HAP=2');
return $this->db->get()->result_array();
}
public function getData_RekapKuartal_bySALES_status0() { //RekapGp = [19]
$this->db->select('*,DATE_FORMAT(b.AWAL_KUARTAL,"%d/%m/%Y") as AWAL,DATE_FORMAT(b.AKHIR_KUARTAL,"%d/%m/%Y") as AKHIR');
$this->db->from('rekap_kuartal a');
$this->db->join('kuartal b','b.ID_KUARTAL=a.KUARTAL_ID');
$this->db->join('karyawan c','c.ID_KARYAWAN=a.SALES_ID');
$this->db->where('a.STATUS_RQ=0');
return $this->db->get()->result_array();
}
public function getData_Proyek_status1_Rq0($id) { //RekapGp = [19]
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->join('rekap_kuartal e','e.ID_RQ=a.RQ_ID');
$this->db->join('kuartal f','f.ID_KUARTAL=e.KUARTAL_ID');
$this->db->where('a.STATUS_PROYEK=1');
$this->db->where('e.STATUS_RQ=0');
$this->db->where(['a.SALES_ID' => $id]);
return $this->db->get()->result_array();
}
public function getData_Proyek_1_Rq0($id=null) { //RekapGp = [19]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->join('rekap_kuartal e','e.ID_RQ=a.RQ_ID');
$this->db->join('kuartal f','f.ID_KUARTAL=e.KUARTAL_ID');
$this->db->where('a.STATUS_PROYEK=1');
$this->db->where('e.STATUS_RQ=0');
} else {
$this->db->select('*');
$this->db->from('proyek a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID');
$this->db->join('rekap_kuartal e','e.ID_RQ=a.RQ_ID');
$this->db->join('kuartal f','f.ID_KUARTAL=e.KUARTAL_ID');
$this->db->where('a.STATUS_PROYEK=1');
$this->db->where('e.STATUS_RQ=0');
$this->db->where(['a.ID_PROYEK' => $id]);
}
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byPELANGGAN_bySALES_status1_SPR($id_pelanggan, $id_sales) { //RekapGp = [22]
$this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL,FORMAT(a.NILAI_SO,2) as TOTAL');
$this->db->from('sales_order a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
$this->db->join('so_proyek d','d.SO_ID=a.ID_SO','left');
$this->db->where('a.STATUS_SO=1');
$this->db->where('a.GP_SO=1');
$this->db->where('a.PELANGGAN_ID=', $id_pelanggan);
$this->db->where('a.SALES_ID=', $id_sales);
$this->db->order_by('a.ID_SO DESC');
return $this->db->get()->result_array();
}
public function getKode_Proyek_Pra() { //RekapGp = [24]
$this->db->select('MAX(KODE_PROYEK) AS KODE');
$this->db->from('proyek');
$this->db->like('KODE_PROYEK','PRA','after');
return $this->db->get()->result_array();
}
}
?>
+432
View File
@@ -0,0 +1,432 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ModelService extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_Service_byID_status0($id=null) { // Service [1]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('service a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.PEMBUAT_ID');
$this->db->where('a.STATUS_SERVICE=0');
} else {
$this->db->select('*,DATE_FORMAT(a.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('service a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.PEMBUAT_ID');
$this->db->where('a.STATUS_SERVICE=0');
$this->db->where('a.ID_SERVICE=', $id);
}
return $this->db->get()->result_array();
}
public function getData_DaftarService_bySERVICE($id) { // Service [1, 2, 3]
$this->db->select('*');
$this->db->from('daftar_service a');
$this->db->join('service b','b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
$this->db->where('a.SERVICE_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SnService_byDFS($id) { // Service [1, 3]
$this->db->select('*');
$this->db->from('sn_service a');
$this->db->join('daftar_service b','b.ID_DFS=a.DFS_ID');
$this->db->where('a.DFS_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_Service_byID($id) { // Service [2, 3]
$this->db->select('*');
$this->db->from('service');
$this->db->where('ID_SERVICE=', $id);
return $this->db->get()->result_array();
}
public function getData_Kuantiti_byID($id) { // Service [2, 3]
$this->db->select('*');
$this->db->from('kuantiti');
$this->db->where('ID_KUANTITI=', $id);
return $this->db->get()->result_array();
}
public function getData_SnStock_byNAMA_status17($id) { // Service [3]
$this->db->select('*');
$this->db->from('sn_stock');
$this->db->where('NAMA_SNSTOCK=', $id);
$this->db->where('STATUS_SNSTOCK=17');
return $this->db->get()->result_array();
}
public function getData_SnService_byKARYAWAN_statusNull($id) { // Service [4]
$this->db->select('*');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('unitservice c', 'c.ID_UNITSERVICE=a.UNITSERVICE_ID');
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota e', 'e.ID_KOTA=d.KOTA_ID');
$this->db->where('b.STATUS_SERVICE is NULL');
$this->db->where('b.PEMBUAT_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_Pelanggan_byID($id = null) { // Service [4]
if ($id == null) {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->order_by('a.TYPE_PELANGGAN ASC');
} else {
$this->db->select('*');
$this->db->from('pelanggan a');
$this->db->join('kota b', 'b.ID_KOTA=a.KOTA_ID');
$this->db->where('a.ID_PELANGGAN=', $id);
}
return $this->db->get()->result_array();
}
public function getData_UnitService_byID($id=null) { // Service [4, 8, 28]
if ($id==null) {
$this->db->select('*');
$this->db->from('unitservice a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->order_by('a.NAMA_UNITSERVICE ASC');
} else {
$this->db->select('*');
$this->db->from('unitservice a');
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
$this->db->where('a.ID_UNITSERVICE=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Kota_byID($id=null) { // Service [4]
if ($id==null) {
$this->db->select('*');
$this->db->from('kota');
$this->db->order_by('NAMA_KOTA ASC');
} else {
$this->db->select('*');
$this->db->from('kota');
$this->db->where('ID_KOTA=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Jenis_BIAYANot0() { // Service [4]
$this->db->select('*');
$this->db->from('jenis');
$this->db->where('BIAYA_SERVICE!="0.00"');
return $this->db->get()->result_array();
}
public function getKode_Service() { // Service [5]
$this->db->select('MAX(KODE_SERVICE) AS KODE');
$this->db->from('service');
$this->db->like('KODE_SERVICE','SRV', 'after');
return $this->db->get()->result_array();
}
public function getData_Pelanggan_byNAMA_byKOTA($nama, $kota) { // Service [6]
$this->db->select('*');
$this->db->from('pelanggan');
$this->db->where('NAMA_PELANGGAN=', $nama);
$this->db->where('KOTA_ID=', $kota);
return $this->db->get()->result_array();
}
public function getData_UnitService_byNAMA_byJENIS($nama, $jenis) { // Service [6]
$this->db->select('*');
$this->db->from('unitservice');
$this->db->where('NAMA_UNITSERVICE=', $nama);
$this->db->where('JENIS_ID=', $jenis);
return $this->db->get()->result_array();
}
public function getID_PelangganMax() { // Service [6]
$this->db->select_max('ID_PELANGGAN');
$this->db->from('pelanggan');
return $this->db->get()->result_array();
}
public function getID_UnitServiceMax() { // Service [6]
$this->db->select_max('ID_UNITSERVICE');
$this->db->from('unitservice');
return $this->db->get()->result_array();
}
public function getID_ServiceMax() { // Service [6]
$this->db->select_max('ID_SERVICE');
$this->db->from('service');
return $this->db->get()->result_array();
}
public function getData_SnService_byID($id) { // Service [7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 28]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL,e.NAMA_PANGGILAN_KARYAWAN as PEMBUAT');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID','left');
$this->db->join('unitservice d', 'd.ID_UNITSERVICE=a.UNITSERVICE_ID','left');
$this->db->join('karyawan e', 'e.ID_KARYAWAN=b.PEMBUAT_ID','left');
$this->db->where('a.ID_SNS=', $id);
return $this->db->get()->result_array();
}
public function getData_SnService_statusNull() { // Service [11, 16, 35, 36]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID','left');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID','left');
$this->db->join('unitservice e', 'e.ID_UNITSERVICE=a.UNITSERVICE_ID','left');
$this->db->join('daftar_service g', 'g.ID_DFS=a.DFS_ID','left');
$this->db->join('barang h', 'h.ID_BARANG=g.BARANG_ID','left');
$this->db->where('a.STATUS_SNS is NULL');
$this->db->where('b.STATUS_SERVICE is NOT NULL');
return $this->db->get()->result_array();
}
public function getData_HistoriService_bySNS($id) { // Service [11, 12, 16, 21, 35, 36]
$this->db->select('*');
$this->db->from('histori_service a');
$this->db->join('sn_service b', 'b.ID_SNS=a.SNS_ID');
$this->db->join('karyawan c', 'c.ID_KARYAWAN=a.TEKNISI_ID');
$this->db->where('a.SNS_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SnService_statusNull_fromGudang() { // Service [16, 35, 36]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->where('a.STATUS_SNS is NULL');
$this->db->where('b.PELANGGAN_ID is NULL');
return $this->db->get()->result_array();
}
public function getData_SnService_statusNull_fromPelanggan() { // Service [16, 35, 36]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->where('a.STATUS_SNS is NULL');
$this->db->where('b.PELANGGAN_ID is NOT NULL');
return $this->db->get()->result_array();
}
public function getData_SnService_status1() { // Service [16, 35, 36]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->where('a.STATUS_SNS=1');
return $this->db->get()->result_array();
}
public function subTempoMonth($date,$month) { // Service = [16] = Terpakai Untuk Fungsi Internal
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " -$month month");
$dateTo=date('Y-m-d',$sum);
return $dateTo;
}
public function getData_SalesOrder_byADMINSERVICE_status1() { // Service [16, 35, 36]
$tgl = date('Y-m-d');
$tgl_before = $this->subTempoMonth($tgl, 3);
$this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL');
$this->db->from('sales_order a');
$this->db->join('pelanggan b', 'b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->join('sn_service c', 'c.SO_ID=a.ID_SO','left');
$this->db->where('a.SALES_ID=53');
$this->db->where('a.STATUS_SO=1');
$this->db->where('a.TGL_SO>=', $tgl_before);
$this->db->where('c.SO_ID is NULL');
$this->db->order_by('a.TGL_SO DESC');
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byID($id) { // Service [17, 18]
$this->db->select('*');
$this->db->from('sales_order');
$this->db->where('ID_SO=', $id);
return $this->db->get()->result_array();
}
public function getData_SnService_allStatus_allSource() { // Service [22, 29]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.TGL_SNS,"%d/%m/%Y") as TANGGALAMBIL,
f.NAMA_PANGGILAN_KARYAWAN as PENERIMA,j.NAMA_PANGGILAN_KARYAWAN as PENGAMBIL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID','left');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID','left');
$this->db->join('unitservice e', 'e.ID_UNITSERVICE=a.UNITSERVICE_ID','left');
$this->db->join('karyawan f', 'f.ID_KARYAWAN=b.PENERIMA_ID','left');
$this->db->join('daftar_service g', 'g.ID_DFS=a.DFS_ID','left');
$this->db->join('barang h', 'h.ID_BARANG=g.BARANG_ID','left');
$this->db->join('penarikan_service i', 'i.ID_PSV=a.PSV_ID','left');
$this->db->join('karyawan j', 'j.ID_KARYAWAN=i.PENGAMBIL_ID','left');
return $this->db->get()->result_array();
}
public function getData_SnService_status2_PSVNull() { // Service [23]
$this->db->select('*,DATE_FORMAT(a.TGL_SNS,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('daftar_service c', 'c.ID_DFS=a.DFS_ID');
$this->db->join('barang d', 'd.ID_BARANG=c.BARANG_ID');
$this->db->where('a.STATUS_SNS=2');
$this->db->where('a.PSV_ID is NULL');
return $this->db->get()->result_array();
}
public function getData_NonSnService_groupBARANG() { // Service [25]
$this->db->select('*,SUM(a.MASUK_NONSNS-a.KELUAR_NONSNS) as TOTAL');
$this->db->from('nonsn_service a');
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
$this->db->group_by('a.BARANG_ID');
$this->db->order_by('TOTAL DESC,b.KODE_BARANG ASC');
return $this->db->get()->result_array();
}
public function getData_NonSnService_byBARANG($id) { // Service [26]
$this->db->select('*,DATE_FORMAT(a.TGL_NONSNS,"%d/%m/%Y") as TANGGAL');
$this->db->from('nonsn_service a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.PENERIMA_ID');
$this->db->where('a.BARANG_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_Barang_byID($id) { // Service [26]
$this->db->select('*');
$this->db->from('barang');
$this->db->where('ID_BARANG=', $id);
return $this->db->get()->result_array();
}
public function getData_SnService_PELANGGANNull_allStatus() { // Service [27]
$this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL');
$this->db->from('sn_service a');
$this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID');
$this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID');
$this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID');
$this->db->join('unitservice e', 'e.ID_UNITSERVICE=a.UNITSERVICE_ID');
$this->db->join('karyawan f', 'f.ID_KARYAWAN=b.PEMBUAT_ID');
$this->db->where('b.PELANGGAN_ID is NOT NULL');
$this->db->order_by('b.KODE_SERVICE DESC');
return $this->db->get()->result_array();
}
public function getData_KlaimService_Null() { // Service [29]
$this->db->select('*,DATE_FORMAT(a.TGL_KSV,"%d/%m/%Y") as TANGGAL,h.NAMA_PANGGILAN_KARYAWAN as PENERIMA,n.NAMA_PANGGILAN_KARYAWAN as PEMBERI,d.PELANGGAN_ID as DPID,
g.NAMA_BARANG as NBG,o.NAMA_BARANG as NBO');
$this->db->from('klaim_service a');
$this->db->join('servicecenter b','b.ID_SERVICECENTER=a.SERVICECENTER_ID');
$this->db->join('sn_service c','c.ID_SNS=a.SNS_ID','left');
$this->db->join('service d','d.ID_SERVICE=c.SERVICE_ID','left');
$this->db->join('unitservice e','e.ID_UNITSERVICE=c.UNITSERVICE_ID','left');
$this->db->join('daftar_service f','f.ID_DFS=c.DFS_ID','left');
$this->db->join('barang g','g.ID_BARANG=f.BARANG_ID','left');
$this->db->join('karyawan h','h.ID_KARYAWAN=d.PENERIMA_ID','left');
$this->db->join('pelanggan i','i.ID_PELANGGAN=d.PELANGGAN_ID','left');
$this->db->join('kota j','j.ID_KOTA=i.KOTA_ID','left');
$this->db->join('sn_pinjam k','k.ID_SNP=a.SNP_ID','left');
$this->db->join('daftar_pinjam l','l.ID_DFP=k.DFP_ID','left');
$this->db->join('peminjaman m','m.ID_PEMINJAMAN=l.PEMINJAMAN_ID','left');
$this->db->join('karyawan n','n.ID_KARYAWAN=m.PEMBERI_ID','left');
$this->db->join('barang o','o.ID_BARANG=l.BARANG_ID','left');
$this->db->where('a.STATUS_KSV is NULL');
$this->db->order_by('a.TGL_KSV ASC');
return $this->db->get()->result_array();
}
public function getData_ServiceCenter_byID($id=null) { // Service [29]
if ($id==null) {
$this->db->select('*');
$this->db->from('servicecenter');
$this->db->order_by('NAMA_SERVICECENTER ASC');
} else {
$this->db->select('*');
$this->db->from('servicecenter');
$this->db->where('ID_SERVICECENTER=', $id);
}
return $this->db->get()->result_array();
}
public function getData_KlaimService_NotNull() { // Service [29]
$this->db->select('*,DATE_FORMAT(a.TGL_KSV,"%d/%m/%Y") as TANGGAL');
$this->db->from('klaim_service a');
$this->db->join('sn_service b','b.ID_SNS=a.SNS_ID');
$this->db->join('service c','c.ID_SERVICE=b.SERVICE_ID');
$this->db->join('unitservice d','d.ID_UNITSERVICE=b.UNITSERVICE_ID','left');
$this->db->join('daftar_service e','e.ID_DFS=b.DFS_ID','left');
$this->db->join('barang f','f.ID_BARANG=e.BARANG_ID','left');
$this->db->join('karyawan g','g.ID_KARYAWAN=c.PENERIMA_ID','left');
$this->db->where('a.STATUS_KSV is NOT NULL');
$this->db->order_by('a.TGL_KSV ASC');
return $this->db->get()->result_array();
}
public function getData_SnPinjam_allStatus_allSource() { // Service [29]
$this->db->select('*');
$this->db->from('sn_pinjam a');
$this->db->join('daftar_pinjam b', 'b.ID_DFP=a.DFP_ID');
$this->db->join('peminjaman c', 'c.ID_PEMINJAMAN=b.PEMINJAMAN_ID');
$this->db->join('barang d', 'd.ID_BARANG=b.BARANG_ID');
return $this->db->get()->result_array();
}
public function getData_KlaimService_byID($id) { // Service [31, 32, 33]
$this->db->select('*');
$this->db->from('klaim_service');
$this->db->where('ID_KSV=', $id);
return $this->db->get()->result_array();
}
public function getData_KlaimService_AllStatus() { // Service [34]
$this->db->select('*,DATE_FORMAT(a.TGL_KSV,"%d/%m/%Y") as TANGGAL,h.NAMA_PANGGILAN_KARYAWAN as PENERIMA,n.NAMA_PANGGILAN_KARYAWAN as PEMBERI,d.PELANGGAN_ID as DPID,
g.NAMA_BARANG as NBG,o.NAMA_BARANG as NBO');
$this->db->from('klaim_service a');
$this->db->join('servicecenter b','b.ID_SERVICECENTER=a.SERVICECENTER_ID');
$this->db->join('sn_service c','c.ID_SNS=a.SNS_ID','left');
$this->db->join('service d','d.ID_SERVICE=c.SERVICE_ID','left');
$this->db->join('unitservice e','e.ID_UNITSERVICE=c.UNITSERVICE_ID','left');
$this->db->join('daftar_service f','f.ID_DFS=c.DFS_ID','left');
$this->db->join('barang g','g.ID_BARANG=f.BARANG_ID','left');
$this->db->join('karyawan h','h.ID_KARYAWAN=d.PENERIMA_ID','left');
$this->db->join('pelanggan i','i.ID_PELANGGAN=d.PELANGGAN_ID','left');
$this->db->join('kota j','j.ID_KOTA=i.KOTA_ID','left');
$this->db->join('sn_pinjam k','k.ID_SNP=a.SNP_ID','left');
$this->db->join('daftar_pinjam l','l.ID_DFP=k.DFP_ID','left');
$this->db->join('peminjaman m','m.ID_PEMINJAMAN=l.PEMINJAMAN_ID','left');
$this->db->join('karyawan n','n.ID_KARYAWAN=m.PEMBERI_ID','left');
$this->db->join('barang o','o.ID_BARANG=l.BARANG_ID','left');
$this->db->order_by('a.TGL_KSV ASC');
return $this->db->get()->result_array();
}
}
File diff suppressed because it is too large Load Diff
+241
View File
@@ -0,0 +1,241 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ModelVisit extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getData_SalesVisit_bySALES_status0($id=null) { // Visit [1]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_SAV,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.REMINDER_SAV,"%d/%m/%Y") as REMINDER');
$this->db->from('sales_visit a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.SALES_ID');
$this->db->join('akun c', 'c.ID_AKUN=a.AKUN_ID','left');
$this->db->join('kontak d', 'd.ID_KONTAK=a.KONTAK_ID','left');
$this->db->join('posisi e', 'e.ID_POSISI=d.POSISI_ID','left');
$this->db->where('a.STATUS_SAV=0');
} else {
$this->db->select('*,DATE_FORMAT(a.TGL_SAV,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.REMINDER_SAV,"%d/%m/%Y") as REMINDER');
$this->db->from('sales_visit a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.SALES_ID');
$this->db->join('akun c', 'c.ID_AKUN=a.AKUN_ID','left');
$this->db->join('kontak d', 'd.ID_KONTAK=a.KONTAK_ID','left');
$this->db->join('posisi e', 'e.ID_POSISI=d.POSISI_ID','left');
$this->db->where('a.STATUS_SAV=0');
if ($id==1 OR $id==2 OR $id==50) {
} else {
$this->db->where('a.SALES_ID=', $id);
}
}
return $this->db->get()->result_array();
}
public function getData_DaftarSalesVisit_bySAV_orderDESC_limit1($id) { // Visit [1, 4, 7, 8, 9, 10, 11, 12]
$this->db->select('*');
$this->db->from('daftar_salesvisit a');
$this->db->join('sales_visit b','b.ID_SAV=a.SAV_ID');
$this->db->where('a.SAV_ID=', $id);
$this->db->order_by('a.ID_DSAV DESC');
$this->db->limit('1');
return $this->db->get()->result_array();
}
public function getData_SalesVisit_byID($id) { // Visit [3, 4, 5, 6, 7, 9, 10]
$this->db->select('*,DATE_FORMAT(TGL_SAV,"%d/%m/%Y") as TANGGAL');
$this->db->from('sales_visit');
$this->db->where('ID_SAV=', $id);
return $this->db->get()->result_array();
}
public function getData_DaftarSalesVisit_bySAV_orderASC($id) { // Visit [3, 4]
$this->db->select('*,DATE_FORMAT(a.TGL_DSAV,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.TIMER_DSAV,"%d/%m/%Y") as TIMER');
$this->db->from('daftar_salesvisit a');
$this->db->join('sales_visit b','b.ID_SAV=a.SAV_ID');
$this->db->join('karyawan c','c.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where('a.SAV_ID=', $id);
$this->db->order_by('a.ID_DSAV ASC');
return $this->db->get()->result_array();
}
public function getData_Akun($id=null) { // Visit [4]
if ($id==null) {
$this->db->select('*');
$this->db->from('akun');
} else {
$this->db->select('*');
$this->db->from('akun');
$this->db->where('ID_AKUN=', $id);
}
return $this->db->get()->result_array();
}
public function getData_Kontak($id=null) { // Visit [4, 5]
if ($id==null) {
$this->db->select('*');
$this->db->from('kontak a');
$this->db->join('akun b','b.ID_AKUN=a.AKUN_ID');
} else {
$this->db->select('*');
$this->db->from('kontak a');
$this->db->join('akun b','b.ID_AKUN=a.AKUN_ID');
$this->db->where('a.ID_KONTAK=', $id);
}
return $this->db->get()->result_array();
}
public function getData_SalesOrder_bySALES_status0_status1($id) { // Visit [4]
$this->db->select('*');
$this->db->from('sales_order a');
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID');
$this->db->where('a.STATUS_SO=0 AND a.SALES_ID=', $id);
$this->db->or_where('a.STATUS_SO=1 AND a.SALES_ID=', $id);
$this->db->order_by('a.ID_SO DESC');
return $this->db->get()->result_array();
}
public function getData_PiutangDagang_bySO($id) { // Visit [4]
$this->db->select('*,FORMAT(a.DEBET_PDA,2) as DEBET,FORMAT(a.KREDIT_PDA,2) as KREDIT,DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y") as TANGGAL');
$this->db->from('piutang_dagang a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->where('b.SO_ID=', $id);
return $this->db->get()->result_array();
}
public function getSum_PiutangDagang_bySO_transaksi0($id) { // Visit [4]
$this->db->select('SUM(a.DEBET_PDA) as TOTAL');
$this->db->from('piutang_dagang a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->where('b.SO_ID=', $id);
$this->db->where('a.TRANSAKSI_PDA=0');
return $this->db->get()->result_array();
}
public function getSum_PiutangDagang_bySO_transaksi1($id) { // Visit [4]
$this->db->select('SUM(a.KREDIT_PDA) as TOTAL');
$this->db->from('piutang_dagang a');
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID');
$this->db->where('b.SO_ID=', $id);
$this->db->where('a.TRANSAKSI_PDA=1');
return $this->db->get()->result_array();
}
public function getID_DaftarSalesVisitMax() { // Visit [6]
$this->db->select_max('ID_DSAV');
$this->db->from('daftar_salesvisit');
return $this->db->get()->result_array();
}
public function getID_NotifikasiMax() { // Visit [6]
$this->db->select_max('ID_NOTIFIKASI');
$this->db->from('notifikasi');
return $this->db->get()->result_array();
}
public function getData_DaftarSalesVisit_byID($id) { // Visit [7, 8]
$this->db->select('*,DATE_FORMAT(TGL_DSAV,"%d/%m/%Y") as TANGGAL');
$this->db->from('daftar_salesvisit');
$this->db->where('ID_DSAV=', $id);
return $this->db->get()->result_array();
}
public function getData_Notifikasi_byDSAV($id) { // Visit [7, 8]
$this->db->select('*');
$this->db->from('notifikasi');
$this->db->where('DSAV_ID=', $id);
return $this->db->get()->result_array();
}
public function getData_SalesOrder_byID_status0_status1($id) { // Visit [9]
$this->db->select('*');
$this->db->from('sales_order');
$this->db->where('STATUS_SO=0 AND ID_SO=', $id);
$this->db->or_where('STATUS_SO=1 AND ID_SO=', $id);
return $this->db->get()->result_array();
}
public function getData_Karyawan_SalesOnly_NonFree() { // Visit [11]
$this->db->select('*');
$this->db->from('karyawan a');
$this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID');
$this->db->like('b.NAMA_JABATAN','SALES');
$this->db->not_like('a.USERNAME','none');
$this->db->not_like('a.USERNAME','insentive');
$this->db->not_like('a.USERNAME','service');
$this->db->not_like('a.USERNAME','itp');
$this->db->not_like('a.USERNAME','louis');
$this->db->order_by('a.NAMA_PANGGILAN_KARYAWAN ASC');
return $this->db->get()->result_array();
}
public function getData_SalesVisit_bySALES_status1_status2($id=null) { // Visit [11]
if ($id==null) {
$this->db->select('*,DATE_FORMAT(a.TGL_SAV,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.REMINDER_SAV,"%d/%m/%Y") as REMINDER');
$this->db->from('sales_visit a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.SALES_ID');
$this->db->join('akun c', 'c.ID_AKUN=a.AKUN_ID');
$this->db->join('kontak d', 'd.ID_KONTAK=a.KONTAK_ID');
$this->db->join('posisi e', 'e.ID_POSISI=d.POSISI_ID');
$this->db->where('a.STATUS_SAV=1');
$this->db->or_where('a.STATUS_SAV=2');
} else {
$this->db->select('*,DATE_FORMAT(a.TGL_SAV,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.REMINDER_SAV,"%d/%m/%Y") as REMINDER');
$this->db->from('sales_visit a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.SALES_ID');
$this->db->join('akun c', 'c.ID_AKUN=a.AKUN_ID');
$this->db->join('kontak d', 'd.ID_KONTAK=a.KONTAK_ID');
$this->db->join('posisi e', 'e.ID_POSISI=d.POSISI_ID');
$this->db->where('a.STATUS_SAV=1 AND a.SALES_ID=', $id);
$this->db->or_where('a.STATUS_SAV=2 AND a.SALES_ID=', $id);
}
return $this->db->get()->result_array();
}
public function getData_SalesVisit_bySALES_byAKHIR($id, $status) { // Visit [12]
$this->db->select('*,DATE_FORMAT(a.TGL_SAV,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.SELESAI_SAV,"%d/%m/%Y") as SELESAI');
$this->db->from('sales_visit a');
$this->db->join('karyawan b','b.ID_KARYAWAN=a.SALES_ID');
$this->db->join('akun c','c.ID_AKUN=a.AKUN_ID');
$this->db->join('kontak d','d.ID_KONTAK=a.KONTAK_ID','left');
$this->db->join('posisi e','e.ID_POSISI=d.POSISI_ID','left');
$this->db->join('sales_order f','f.ID_SO=a.SO_ID','left');
if ($id==0) {
} else {
$this->db->where('a.SALES_ID=', $id);
}
$this->db->where('a.STATUS_AKHIR=', $status);
return $this->db->get()->result_array();
}
public function getData_Karyawan_byID($id) { // Visit [12]
$this->db->select('*');
$this->db->from('karyawan');
$this->db->where('ID_KARYAWAN=', $id);
return $this->db->get()->result_array();
}
}
+106
View File
@@ -0,0 +1,106 @@
<?php
use LDAP\Result;
defined('BASEPATH') or exit('No direct script access allowed');
class ShiftModel extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function delete($table, $data, $pk)
{
$this->db->where_in($pk, $data);
return $this->db->delete($table);
}
public function getDataShift()
{
$this->db->select('*');
$this->db->from('shift a');
$this->db->join('cabang b', 'b.KODE_CABANG=a.CABANG_KODE');
$this->db->order_by('a.TANGGAL_SHIFT DESC');
return $this->db->get()->result_array();
}
public function getDataShiftByKodeCabang($kode)
{
$this->db->select('*');
$this->db->from('shift a');
$this->db->where(['a.CABANG_KODE' => $kode]);
$this->db->order_by('a.TANGGAL_SHIFT DESC');
return $this->db->get()->result_array();
}
public function getDataDetailByIdShift($id)
{
$this->db->select('a.ID_DETAIL_SHIFT, b.ID_KARYAWAN, b.NAMA_KARYAWAN');
$this->db->from('detail_shift a');
$this->db->join('karyawan b', 'b.ID_KARYAWAN=a.KARYAWAN_ID');
$this->db->where(['a.SHIFT_ID' => $id]);
return $this->db->get()->result_array();
}
public function getDataKaryawanByKodeCabang($id_cabang)
{
$this->db->select('a.ID_KARYAWAN, a.NAMA_KARYAWAN');
$this->db->from('karyawan a');
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
$this->db->where(['b.CABANG_KODE' => $id_cabang]);
$this->db->where(['a.STATUS_KARYAWAN' => 1]);
return $this->db->get()->result_array();
}
public function cekDetailByIdKarShift($idKar, $idShift)
{
$this->db->select('*');
$this->db->from('detail_shift');
$this->db->where(['KARYAWAN_ID' => $idKar, 'SHIFT_ID' => $idShift]);
return $this->db->get()->result_array();
}
public function getIdShiftTerakhir($cabang)
{
$this->db->select('ID_SHIFT');
$this->db->from('shift');
$this->db->like('ID_SHIFT', $cabang, 'after');
$this->db->order_by('IS DESC');
$this->db->limit(1);
return $this->db->get()->result_array();
}
public function getIdDetailShiftTerakhir($cabang)
{
$this->db->select('ID_DETAIL_SHIFT');
$this->db->from('detail_shift');
$this->db->like('ID_DETAIL_SHIFT', $cabang, 'after');
$this->db->order_by('IDS DESC');
$this->db->limit(1);
return $this->db->get()->result_array();
}
public function getDataShiftById($id)
{
$this->db->select('*');
$this->db->from('shift');
$this->db->where(['ID_SHIFT' => $id]);
return $this->db->get()->result_array();
}
public function getDataDetailShiftById($id)
{
$this->db->select('*');
$this->db->from('detail_shift');
$this->db->where(['ID_DETAIL_SHIFT' => $id]);
return $this->db->get()->result_array();
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class SinkronModel extends CI_Model
{
public function create($table, $data, $batch = false)
{
if ($batch === false) {
$insert = $this->db->insert($table, $data);
} else {
$insert = $this->db->insert_batch($table, $data);
}
return $insert;
}
public function update($table, $data, $pk, $id = null, $batch = false)
{
if ($batch === false) {
$insert = $this->db->update($table, $data, array($pk => $id));
} else {
$insert = $this->db->update_batch($table, $data, $pk);
}
return $insert;
}
public function getIpServer()
{
$this->db->select('*');
$this->db->from('ip_server');
$this->db->order_by('id_ip ASC');
$this->db->limit(1);
return $this->db->get()->result_array();
}
public function cekTabel($tabel)
{
$this->db->select('*');
$this->db->from($tabel);
$this->db->where(['SYNC' => 0]);
return $this->db->get()->result_array();
}
public function getDataJabatan($id)
{
$this->db->select('*');
$this->db->from('jabatan');
$this->db->where(['ID_JABATAN' => $id]);
return $this->db->get()->result_array();
}
public function getDataCabangByKode($id)
{
$this->db->select('*');
$this->db->from('cabang');
$this->db->where(['KODE_CABANG' => $id]);
return $this->db->get()->result_array();
}
}
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>