first commit

This commit is contained in:
alazhar
2020-01-02 23:12:35 +07:00
commit 1b7f223f9d
362 changed files with 110045 additions and 0 deletions

View File

@ -0,0 +1,67 @@
<?php
class Barang extends CI_Model{
//print_r($this->db->last_query());
function tambahbarang($data)
{
return $this->db->insert('barang',$data);
}
function barang_all()
{
$query = $this->db->get('barang');
//return $query->row();
return $query->result_array();
}
function barang_all2($limit,$offset)
{
$query = $this->db->get('barang',$limit,$offset);
//return $query->row();
return $query->result_array();
}
function barang_cust($where)
{
$this->db->where($where);
$query = $this->db->get('barang');
return $query->row();
}
function updatebarang($id,$data)
{
$this->db->where('id',$id);
return $this->db->update('barang',$data);
}
function deletebarang($id)
{
$this->db->where('id', $id);
return $this->db->delete('barang');
}
function caribarang($key)
{
$array = array('nama' => $key, 'kdbarang' => $key, 'tags' => $key);
$this->db->or_like($array);
$query = $this->db->get('barang');
return $query->result_array();
}
function barang_sold($id,$qty)
{
$this->db->set('stok', 'stok - ' . (int) $qty, FALSE);
$this->db->where('id', $id);
return $this->db->update('barang');
}
function baranglaris()
{
}
function barangbaru()
{
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
class Kategori extends CI_Model{
//print_r($this->db->last_query());
function tambahkategori($data)
{
return $this->db->insert('kategori',$data);
}
function kategori_all()
{
$query = $this->db->get('kategori');
//return $query->result();
return $query->result_array();
}
function loadkategori()
{
$this->db->select('nama,id');
$this->db->where('order !=','0');
$query = $this->db->get('kategori');
return $query->result();
}
function updatekategori($id,$data)
{
$this->db->where('id',$id);
return $this->db->update('barang',$data);
}
function deletekategori($id)
{
$this->db->where('id', $id);
return $this->db->delete('barang');
}
}
?>

View File

@ -0,0 +1,65 @@
<?php
class Transaction extends CI_Model{
function get_all(){
$query = $this->db->get('transaksi');
return $query->row();
//return $query->result_array();
}
function get_order()
{
$q = "SELECT s.transaksi as id,p.nama,p.kota_kab,p.provinsi,sum(s.qty) as jumlah,";
$q .= "t.total_harga,DATE_FORMAT(t.tanggal_order,'%d %b %Y') as tgl,t.status ";
$q .= "FROM sales s ";
$q .= "LEFT JOIN profil p ON s.pembeli = p.id ";
$q .= "LEFT JOIN transaksi t ON s.transaksi = t.id ";
$q .= "WHERE t.type = 'ONLINE' ";
$q .= "GROUP BY s.transaksi;";
$query = $this->db->query($q);
return $query->result_array();
}
function get_single_order($id)
{
$query = $this->db->get_where('sales', array('transaksi' => $id),1);
$idp = $query->result_array();
$query = $this->db->get_where('profil', array('id' => $idp[0]['pembeli']));
$result['profil'] = $query->result_array();
$query = $this->db->get_where('transaksi', array('id' => $id));
$result['transaksi'] = $query->result_array();
$q = "SELECT b.nama,s.qty,b.harga FROM sales s ";
$q .= "LEFT JOIN barang b ON s.barang=b.id ";
$q .= "WHERE s.transaksi=".$id.";";
$query = $this->db->query($q);
$result['barang'] = $query->result_array();
return $result;
}
function pending_order()
{
$this->db->select('count(*) as ttl');
$query = $this->db->get_where('transaksi', array('status' => 'pending','type' => 'online'));
return $query->row();
}
function update_order($id,$status)
{
$this->db->set('status', $status);
$this->db->where('id', $id);
$this->db->update('transaksi');
}
function tambah_trans($data)
{
if($this->db->insert('transaksi',$data)){
return $this->db->insert_id();
}else return 0;
}
function tambah_sales($data)
{
return $this->db->insert('sales',$data);
}
}
?>

View File

@ -0,0 +1,19 @@
<?php
class UserModel extends CI_Model{
function tambah($data)
{
return $this->db->insert('user',$data);
}
function tambah_profil($data)
{
if($this->db->insert('profil',$data)){
return $this->db->insert_id();
}else return 0;
}
function login($data)
{
$query = $this->db->get_where('users', array('username' => $data['username'],'pass'=>$data['password']), 1);
return $query->row();
}
}

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>