| 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_2017_sekolah/application/modules/pengumuman/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pengumuman_model extends Base_Model {
var $fieldmap_pengumuman;
var $data_pengumuman;
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->fieldmap_pengumuman = array(
'aktif' => 'PENGUMUMAN_AKTIF',
'isi' => 'PENGUMUMAN_ISI',
'tgl_awal' => 'PENGUMUMAN_TANGGAL_AWAL',
'tgl_akhir' => 'PENGUMUMAN_TANGGAL_AKHIR',
);
}
function fill_data()
{
foreach($this->fieldmap_pengumuman as $key => $value){
switch ($key)
{
default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
}
$this->data_pengumuman[$value] = $$key;
}
}
function get_setting()
{
$this->db->select('first 1 a.pengumuman_aktif, a.pengumuman_tanggal_awal, a.pengumuman_tanggal_akhir, a.pengumuman_isi')
->from('pengumuman a')
->where('appid', $this->app_id)
->where('tahun', $this->tahun)
->where('status', $this->status);
$result = $this->db->get()->row_array();
if ( count($result) == 0){
$data = array(
'pengumuman_aktif' => 0,
'pengumuman_isi' => '',
'appid' => $this->app_id,
'tahun' => $this->tahun,
'status' => $this->status,
);
$this->db->insert('pengumuman', $data);
$this->db->select('first 1 a.pengumuman_aktif, a.pengumuman_tanggal_awal, a.pengumuman_tanggal_akhir, a.pengumuman_isi')
->from('pengumuman a')
->where('appid', $this->app_id)
->where('tahun', $this->tahun)
->where('status', $this->status);
$result = $this->db->get()->row_array();
}
return $result;
}
function save_setting()
{
$this->db->trans_begin();
try {
$this->db->where('appid', $this->app_id);
$this->db->where('tahun', $this->tahun);
$this->db->where('status', $this->status);
$this->db->set($this->data_pengumuman)->update('pengumuman');
}
catch(Exception $e){
//TODO : log error to file
}
if ($this->db->trans_status() === FALSE)
{
$this->id = NULL;
$this->last_error_id = $this->db->_error_number();
$this->last_error_message = $this->db->_error_message();
$this->db->trans_rollback();
return FALSE;
}
return TRUE;
}
}