copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
class ModelPromo 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 getDataPromo($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,a.NAMA_PROMO,a.TGL_PROMO,CONCAT(FORMAT(a.POTONGAN,0)) as POTONGANHARGA,b.NO_INVOICE');
|
||||
$this->db->from('promo a');
|
||||
$this->db->join('invoice b','b.ID_INVOICE=a.ID_INVOICE');
|
||||
}else{
|
||||
$this->db->select('*,a.NAMA_PROMO,a.TGL_PROMO,CONCAT(FORMAT(a.POTONGAN,0)) as POTONGANHARGA,b.NO_INVOICE');
|
||||
$this->db->from('promo a');
|
||||
$this->db->join('invoice b','b.ID_INVOICE=a.ID_INVOICE');
|
||||
$this->db->where(['ID_PROMO' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user