403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /wamp/www/sipapbd_2021_sekolah/update/application/modules/lokasi/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /wamp/www/sipapbd_2021_sekolah/update/application/modules/lokasi/models/lokasi_model.php
<?php
class Lokasi_model extends Base_Model {
	
	var $data;
	var $fieldmap_lokasi;
	var $fieldmap_daftar;
	var $fieldmap_filter;
	
	function __construct()
	{
		// Call the Model constructor
		parent::__construct();
		
		$this->fieldmap_lokasi = array(
			'id' => 'ID_LOKASI',
			'idparent' => 'ID_PARENT_LOKASI',
			'lokasi' => 'LOKASI',
			'level' => 'LEVEL_LOKASI'
		);
		
		$this->fieldmap_daftar = array(
			'ID_LOKASI',
			'LOKASI',
			'LEVEL_LOKASI',
			'ID_PARENT_LOKASI',
		);
		
		$this->fieldmap_filter = array(
			'lokasi' => 'lokasi',
		);
	}
	
	function fill_data()
	{
		foreach($this->fieldmap_lokasi as $key => $value){
			switch ($key){
			default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
		}

		if(isset($$key))
		$this->data[$value] = $$key;
		}
	}
		
	// ----- search advance ---- >>
	function get_data_fields()
	{
		$fields = array(
			'lokasi' => array('name' => 'Nama Lokasi', 'kategori'=>'string'),
		);
		return $fields;
	}
	
	function get_data($param, $isCount=FALSE, $CompileOnly=False)
	{
		isset($param['limit']) && $param['limit'] ? $this->db->limit($param['limit']['end'], $param['limit']['start']) : '';
		
		//$this->build_query_daftar();
		//if (empty($param['search_mode']) || count($param['q']) == 0)
		if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))
		{
			$query = $this->db->query("
					WITH RECURSIVE t AS (
						SELECT ID_LOKASI, LOKASI, LEVEL_LOKASI, ID_PARENT_LOKASI FROM LOKASI WHERE ID_PARENT_LOKASI IS NULL
					UNION ALL
						SELECT t1.ID_LOKASI, t1.LOKASI, t1.LEVEL_LOKASI, t1.ID_PARENT_LOKASI FROM t JOIN LOKASI t1 ON (t1.ID_PARENT_LOKASI = t.ID_LOKASI)
					)
					SELECT * FROM t
				"); 
			$ada = $query->result_array();
		}
		else {
			$this->db->select("r.ID_LOKASI, r.LOKASI, r.LEVEL_LOKASI, r.ID_PARENT_LOKASI");
			$this->db->from('LOKASI r');
			$this->db->where('r.ID_LOKASI <>',0);
			//$ada = $this->db->get()->result_array();
		}

		// proses parameter pencarian, jika ada
		if (isset($param['search_mode']) && $param['search_mode'] !=='' )
		{			
			// proses pencarian singkat (simple search)
			if ($param['search_mode'] == 'ss')
			{
				foreach($this->fieldmap_filter as $key => $value){
					$flt[$key] = array('search_str' => $param['q'], 'search_op' => 'cn');
				}
				if (count($flt) > 0)
				{
					$swhere = get_where_str($flt, $this->fieldmap_filter);
					if ($swhere) {
						$swhere = build_or_where($swhere);
						$this->db->where($swhere);
					}
				}
			}
			// proses pencarian lanjut (advanced search)
			else if ($param['search_mode'] == 'as') {
				$fields = $this->get_data_fields();
				if (is_array($param['q']) && count($param['q']) > 0)
				{
					foreach ($param['q'] as $key=>$val) {
						$kolom = $val['c'];
						$search_str = isset($val['s']) ? $val['s'] : '';
						$search_str2 = isset($val['s2']) ? $val['s2'] : '';

						$flt[$kolom] = array(
						'search_str' => $search_str,
						'search_str2' => $search_str2,
						'search_op' => $val['o'],
						'search_datatype' => $fields[$kolom]['kategori'],
						);
					}
					//print_r($flt);
					if (count($flt) > 0)
					{
						$wh = get_where_str($flt, $this->fieldmap_filter);
						$this->db->where($wh);
					}
				}
			}
		}

		// proses jika ada pengurutan
		if (isset($param['sort_by']) && $param['sort_by'] != null && !$isCount && $ob = get_order_by_str($param['sort_by'], $this->fieldmap_filter))
		{
			$this->db->order_by($ob, $param['sort_direction']);
		}

		if ($isCount) {
			if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))	$result = count($ada);
			else $result = $this->db->count_all_results();
			return $result;
		}
		else
		{
			
			if ($CompileOnly)
			{
				//return $this->db->get_compiled_select();
				if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))
				return $this->db->last_query();
				else return $this->db->get_compiled_select();
			}
			else
			{
				//$result = $this->db->get()->result_array();
				if ((empty($param['search_mode'])) || ($param['search_mode'] == 'ss' && empty($param['q'])) || ($param['search_mode'] == 'as' && empty($param['q'])))$result = $ada;
				else $result = $this->db->get()->result_array();
				return $result;
			}
		}
	}
		
	// Lokasi hanya boleh dipakai sekali
	function check_duplikasi_lokasi()
	{
		$id = $this->input->post('id') ? $this->input->post('id') : NULL;
		$lokasi = $this->input->post('lokasi') ? $this->input->post('lokasi') : NULL;
		$idparent = $this->input->post('idparent') ? $this->input->post('idparent') : NULL;
		$level = $this->input->post('level') ? $this->input->post('level') : NULL;
		
		$this->db->select('count(1) dup')
		->where('a.lokasi', $lokasi)
		->where('a.id_parent_lokasi', $idparent)
		->where('a.id_lokasi <>', $id);
		$rs = $this->db->get('lokasi a')->row_array();

		return (integer) $rs['DUP'] < 1;
	}
	
	/* Simpan data Lokasi */
	function insert_lokasi()
	{
		$id = $this->data['ID_LOKASI'];

		$this->db->select('1')->from('lokasi')->where('id_lokasi', $id);
		$rs = $this->db->get()->row_array();

		if ($rs)
		{
			$this->db->where('id_lokasi', $id);
			$this->db->update('lokasi', $this->data);
			$this->check_trans_status('update lokasi failed');
		}
		else
		{
			$id = $this->get_id('g_id_lokasi');
			$this->data['ID_LOKASI'] = $id;
			$this->db->insert('lokasi', $this->data);
			$this->check_trans_status('insert lokasi failed');
		}
		$this->id = $id;
	}

	function save_detail()
	{
		$this->insert_lokasi();
	}
	
	/* query hapus */
	function build_query_hapus($id=0)
	{
		$this->db->where('id_lokasi', $id)->delete('lokasi');
		$this->check_trans_status('delete lokasi failed');
	}
	
	function check_dependency($id)
	{
		$this->db->select("
			(select count(b.ID_LOKASI) from LOKASI_KEGIATAN b where b.ID_LOKASI = a.ID_LOKASI) LOKASI_KEGIATAN_PAKAI,
		");
		$this->db->where('a.ID_LOKASI', $id);
		$result = $this->db->get('LOKASI a')->row_array();

		return !($result['LOKASI_KEGIATAN_PAKAI'] > 0);
	}
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit