?
Current Path : /home1/savoy/public_html/savoyglobal.net/oscardraft/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/oscardraft/application/models/calendarmodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Calendarmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function search_calendar($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('calendar'); $this->db->order_by('calendar_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insertcalevent($title,$start,$end) { $calendar_start_date=$this->mastermodel->convertdateformat($start); $calendar_end_date=$this->mastermodel->convertdateformat($end); $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array( 'calendar_id'=>$masterid, 'calendar_title'=>$title, 'calendar_start_date'=>$calendar_start_date, 'calendar_end_date'=>$calendar_end_date); $this->db->insert('calendar', $tbl1Values); $data['resfunction'] = 'searchcalendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function search_events($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('calendar'); $this->db->join('master', 'master_id=calendar_id'); $this->db->order_by('calendar_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_event($postdata) { $calendar_start_date=$this->mastermodel->convertdateformat($postdata['calendar_start_date']); $calendar_end_date=$this->mastermodel->convertdateformat($postdata['calendar_end_date']); $data=array(); $this->db->trans_begin(); $master_id = $this->mastermodel->insertmasterdata(); $tbl1Values=array( 'calendar_id'=>$master_id, 'calendar_title'=>$postdata['calendar_title'], 'calendar_start_date'=>$calendar_start_date, 'calendar_end_date'=>$calendar_end_date, 'calendar_description'=>$postdata['calendar_description']); $this->db->insert('calendar', $tbl1Values); $data['resfunction'] = 'searchcalendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_event($postdata) { $data=array(); $calendar_start_date=$this->mastermodel->convertdateformat($postdata['calendar_start_date']); $calendar_end_date=$this->mastermodel->convertdateformat($postdata['calendar_end_date']); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['calendar_id']); $tbl2Values=array( 'calendar_title'=>$postdata['calendar_title'], 'calendar_start_date'=>$calendar_start_date, 'calendar_end_date'=>$calendar_end_date, 'calendar_description'=>$postdata['calendar_description']); $this->db->where('calendar_id',$postdata['calendar_id']); $this->db->update('calendar', $tbl2Values); $data['resfunction'] = 'searchcalendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function searchcalendar($postdata,$pagenum) { // $syear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1'); $data=array(); $this->db->from('calendar'); $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; $this->db->select('calendar_id,calendar_start_date,calendar_end_date,calendar_title,calendar_description'); $this->db->from('calendar'); $this->db->join('master','master.master_id=calendar.calendar_id'); // $this->db->where('deleted', '0'); // $this->db->where('ayear', $ayear); $this->db->order_by('master_id ', 'desc'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } } ?>