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 } }