first commit
This commit is contained in:
109
application/models/M_tabel_ss.php
Executable file
109
application/models/M_tabel_ss.php
Executable file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
class M_tabel_ss extends CI_Model {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
private function _get_datatables_query($column_search,$column_order,$order,$table,$table_join,$where,$as)
|
||||
{
|
||||
|
||||
|
||||
|
||||
$column_search = $column_search;
|
||||
$column_order = $column_order;
|
||||
$order = $order;
|
||||
$this->db->select($as);
|
||||
$this->db->from($table);
|
||||
|
||||
if ($where != null) {
|
||||
$this->db->where($where);
|
||||
}
|
||||
|
||||
if ($table_join != null) {
|
||||
// $this->db->where($where);
|
||||
foreach ($table_join as $key => $value) {
|
||||
$this->db->join($value['table'],$value['join']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$i = 0;
|
||||
|
||||
|
||||
// foreach ($this->column_search as $item) // looping awal
|
||||
foreach ($column_search as $item) // looping awal
|
||||
{
|
||||
if($_POST['search']['value']) // jika datatable mengirimkan pencarian dengan metode POST
|
||||
{
|
||||
|
||||
if($i===0) // looping awal
|
||||
{
|
||||
$this->db->group_start();
|
||||
$this->db->like($item, $_POST['search']['value']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->or_like($item, $_POST['search']['value']);
|
||||
}
|
||||
|
||||
// if(count($this->column_search) - 1 == $i)
|
||||
if(count($column_search) - 1 == $i)
|
||||
$this->db->group_end();
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if(isset($_POST['order']))
|
||||
{
|
||||
$this->db->order_by($column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
|
||||
// $this->db->order_by($this->column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
|
||||
}
|
||||
else if(isset($this->order))
|
||||
{
|
||||
$order = $this->order;
|
||||
$this->db->order_by(key($order), $order[key($order)]);
|
||||
}
|
||||
}
|
||||
|
||||
function get_datatables($column_search,$column_order,$order,$table,$table_join,$where,$as)
|
||||
{
|
||||
$this->_get_datatables_query($column_search,$column_order,$order,$table,$table_join,$where,$as);
|
||||
if($_POST['length'] != -1)
|
||||
$this->db->limit($_POST['length'], $_POST['start']);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function count_filtered($column_search,$column_order,$order,$table,$table_join,$where,$as)
|
||||
{
|
||||
$this->_get_datatables_query($column_search,$column_order,$order,$table,$table_join,$where,$as);
|
||||
$query = $this->db->get();
|
||||
return $query->num_rows();
|
||||
}
|
||||
|
||||
public function count_all($table,$table_join,$where,$as)
|
||||
{
|
||||
|
||||
$this->db->select($as);
|
||||
$this->db->from($table);
|
||||
|
||||
if ($where != null) {
|
||||
$this->db->where($where);
|
||||
}
|
||||
|
||||
if ($table_join != null) {
|
||||
// $this->db->where($where);
|
||||
foreach ($table_join as $key => $value) {
|
||||
$this->db->join($value['table'],$value['join']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
}
|
||||
308
application/models/Model.php
Executable file
308
application/models/Model.php
Executable file
@ -0,0 +1,308 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Model extends CI_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
function index(){
|
||||
|
||||
}
|
||||
|
||||
function tampil_data_keseluruhan($namatabel) //gunakan ini untuk menampilkan tabel yg lebih spesifik 'where'
|
||||
{
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function tampil_data_where($namatabel,$array) //gunakan ini untuk menampilkan tabel yg lebih spesifik 'where'
|
||||
{
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
$this->db->where($array);
|
||||
// $this->db->limit(1);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function tampil_data_where1($namatabel,$array,$bintang) //gunakan ini untuk menampilkan tabel yg lebih spesifik 'where'
|
||||
{
|
||||
$this->db->select($bintang);
|
||||
$this->db->from($namatabel);
|
||||
$this->db->where($array);
|
||||
// $this->db->limit(1);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function tampil_data_keseluruhan_order_by($namatabel,$order_by,$order) //gunakan ini untuk menampilkan tabel yg lebih spesifik 'where'
|
||||
{
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
// $this->db->where($array);
|
||||
$this->db->order_by($order_by, $order);
|
||||
// $this->db->limit(1);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function tampil_data_where_order_by($namatabel,$array,$order_by,$order) //gunakan ini untuk menampilkan tabel yg lebih spesifik 'where'
|
||||
{
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
$this->db->where($array);
|
||||
$this->db->order_by($order_by, $order);
|
||||
// $this->db->limit(1);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function tampil_data_last($namatabel,$kolom)
|
||||
{
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
$this->db->limit(1);
|
||||
$this->db->order_by($kolom,"DESC");
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function custom_query($query)
|
||||
{
|
||||
$query1 = $this->db->query($query);
|
||||
return $query1;
|
||||
|
||||
}
|
||||
|
||||
function insert($namatabel,$array)
|
||||
{
|
||||
return $this->db->insert($namatabel,$array);
|
||||
}
|
||||
|
||||
function update($table,$array,$array_condition)
|
||||
{
|
||||
$this->db->where($array);
|
||||
$this->db->update($table, $array_condition);
|
||||
}
|
||||
|
||||
function delete($table,$array_condition)
|
||||
{
|
||||
// $this->db->where($array);
|
||||
$this->db->delete($table, $array_condition);
|
||||
// $this->db->delete(table_name, where_clause)
|
||||
}
|
||||
|
||||
|
||||
|
||||
function like($namatabel,$field,$like,$kategori)
|
||||
{
|
||||
if ($kategori == '') {
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
$this->db->like($field, $like, 'both');
|
||||
// $this->db->limit(1);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}else{
|
||||
$this->db->select("*");
|
||||
$this->db->from($namatabel);
|
||||
$this->db->where(array('kategori'=>$kategori));
|
||||
$this->db->like($field, $like, 'both');
|
||||
// $this->db->limit(1);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
function data_user($nik,$pencarian)
|
||||
{
|
||||
$data = $this->tampil_data_where('tb_staff_kelurahan',array('nik' => $nik));
|
||||
foreach ($data->result() as $key => $value) ;
|
||||
if ($pencarian == "data_diri") {
|
||||
return $value;
|
||||
}else if ($pencarian == "kelurahan") {
|
||||
$kelurahan = $this->tampil_data_where('tb_kelurahan',array('no' => $value->kelurahan));
|
||||
foreach ($kelurahan->result() as $key1 => $value1) ;
|
||||
return $value1->kelurahan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function serialize($data){
|
||||
$keys = array_column($data,'name');
|
||||
$values = array_column($data,'value');
|
||||
$data = array_combine($keys, $values);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function cek_penamaan_foto($imageFileType)
|
||||
{
|
||||
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" ) {
|
||||
|
||||
return 0;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function upload_foto($value,$key,$cek_no,$kategori) {
|
||||
|
||||
$data = $value;
|
||||
$data = substr($data, 0, -2);
|
||||
// $data = 'data:image/'.$data;
|
||||
// print_r($data);
|
||||
// define('UPLOAD_DIR', 'images/');
|
||||
$image_parts = explode(";base64,", $data);
|
||||
$image_type_aux = explode("image/", $image_parts[0]);
|
||||
$image_type = $image_type_aux[1];
|
||||
$image_base64 = base64_decode($image_parts[1]);
|
||||
// if ($e == 1) {
|
||||
// $edit = '_edit';
|
||||
// $file = 'images/'.$cek_no. '/foto'.$edit.$key.'.png';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $edit = '';
|
||||
if ($kategori == 'berita') {
|
||||
$file = 'assets/admin_assets/images/berita/'.$cek_no. '/foto'.$key.'.png';
|
||||
}
|
||||
if ($kategori == 'iklan') {
|
||||
$file = 'assets/admin_assets/images/iklan/'.$cek_no. '/foto'.$key.'.png';
|
||||
}
|
||||
file_put_contents($file, $image_base64);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function bulan($bulan)
|
||||
{
|
||||
|
||||
switch ($bulan) {
|
||||
case '01':
|
||||
$bulannya = 'Januari';
|
||||
break;
|
||||
|
||||
case '02':
|
||||
$bulannya = 'Februari';
|
||||
break;
|
||||
|
||||
case '03':
|
||||
$bulannya = 'Maret';
|
||||
break;
|
||||
|
||||
case '04':
|
||||
$bulannya = 'April';
|
||||
break;
|
||||
|
||||
case '05':
|
||||
$bulannya = 'Mei';
|
||||
break;
|
||||
|
||||
case '06':
|
||||
$bulannya = 'Juni';
|
||||
break;
|
||||
|
||||
case '07':
|
||||
$bulannya = 'Juli';
|
||||
break;
|
||||
|
||||
case '08':
|
||||
$bulannya = 'Agustus';
|
||||
break;
|
||||
|
||||
case '09':
|
||||
$bulannya = 'September';
|
||||
break;
|
||||
|
||||
case '10':
|
||||
$bulannya = 'Oktober';
|
||||
break;
|
||||
|
||||
case '11':
|
||||
$bulannya = 'November';
|
||||
break;
|
||||
|
||||
case '12':
|
||||
$bulannya = 'Desember';
|
||||
break;
|
||||
|
||||
default:
|
||||
$bulannya = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $bulannya;
|
||||
}
|
||||
|
||||
function hari($hari)
|
||||
{
|
||||
// $ini = ''
|
||||
switch ($hari) {
|
||||
case 'Sunday':
|
||||
$ini = 'Ahad';
|
||||
break;
|
||||
case 'Monday':
|
||||
$ini = 'Senin';
|
||||
break;
|
||||
case 'Tuesday':
|
||||
$ini = 'Selasa';
|
||||
break;
|
||||
case 'Wednesday':
|
||||
$ini = 'Rabu';
|
||||
break;
|
||||
case 'Thursday':
|
||||
$ini = 'Kamis';
|
||||
break;
|
||||
case 'Friday':
|
||||
$ini = 'Jumat';
|
||||
break;
|
||||
case 'Saturday':
|
||||
$ini = 'Sabtu';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $ini;
|
||||
}
|
||||
|
||||
// function qrcode_buku($kode){
|
||||
// include "phpqrcode/qrlib.php";
|
||||
// $kode = $kode;
|
||||
|
||||
// // $PNG_TEMP_DIR = 'images/'.$kategori;
|
||||
|
||||
// $PNG_WEB_DIR = 'images/buku/';
|
||||
|
||||
// if (!file_exists($PNG_WEB_DIR))
|
||||
// mkdir($PNG_WEB_DIR);
|
||||
|
||||
// $errorCorrectionLevel = 'H';
|
||||
|
||||
// $matrixPointSize = 10;
|
||||
|
||||
// $filename =$PNG_WEB_DIR.md5($kode).'.png';
|
||||
// QRcode::png($kode, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
|
||||
|
||||
// if (file_exists($PNG_WEB_DIR.md5($kode).'.png') > 0) {
|
||||
// return "ada";
|
||||
// }else{
|
||||
// return "tiada";
|
||||
// }
|
||||
// }
|
||||
|
||||
function cek_last_ai($tables){
|
||||
return $this->db->query("SELECT `AUTO_INCREMENT` as no
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = '".$this->db->database."'
|
||||
AND TABLE_NAME = '".$tables."'")->result()[0]->no;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
application/models/index.html
Executable file
11
application/models/index.html
Executable file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user