?
Current Path : /home1/savoy/public_html/savoyglobal.net/koolkids/school/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/koolkids/school/application/models/calendarmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?> <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class Calendarmodel extends Model { function Calendarmodel() { parent::Model(); } function searchcalendar($postdata,$pagenum) { $ayear = $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; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; if($searchfield=="start_date" || $searchfield=="end_date") { $searchtext=$this->mastermodel->convdatforsearch($searchtext); $this->db->like($searchfield, $searchtext); } else { $this->db->like($searchfield, $searchtext); } } $this->db->select('id,start_date,end_date,title,description'); $this->db->from('calendar'); $this->db->join('master','master.masterid=calendar.id'); $this->db->where('deleted', '0'); $this->db->where('ayear', $ayear); $this->db->order_by('masterid', 'desc'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertevent($postdata) { $start_date=$this->mastermodel->convertdateformat($postdata['start_date']); $end_date=$this->mastermodel->convertdateformat($postdata['end_date']); $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array( 'id'=>$masterid, 'title'=>$postdata['title'], 'start_date'=>$start_date, 'end_date'=>$end_date, 'description'=>$postdata['description']); $this->db->insert('calendar', $tbl1Values); $data['resfunction']='searchcalendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updateevent($postdata) { $data=array(); $start_date=$this->mastermodel->convertdateformat($postdata['start_date']); $end_date=$this->mastermodel->convertdateformat($postdata['end_date']); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['masterid']); $tbl2Values=array( 'title'=>$postdata['title'], 'start_date'=>$start_date, 'end_date'=>$end_date, 'description'=>$postdata['description']); $this->db->where('id',$postdata['masterid']); $this->db->update('calendar', $tbl2Values); $data['resfunction']='searchcalendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function insertcalevent($title,$start,$end) { $start_date=$this->mastermodel->convertdateformat($start); $end_date=$this->mastermodel->convertdateformat($end); $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array( 'id'=>$masterid, 'title'=>$title, 'start_date'=>$start_date, 'end_date'=>$end_date); $this->db->insert('calendar', $tbl1Values); $data['resfunction']='searchcalendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function searchnoticeboard($postdata,$pagenum) { $data=array(); $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1'); $this->db->from('noticeboard'); $this->db->join('master','master.masterid=noticeboard.id'); $this->db->where('deleted', '0'); $this->db->where('ayear', $ayear); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; if($searchfield=="posted_date") { $searchtext=$this->mastermodel->convdatforsearch($searchtext); $this->db->like($searchfield, $searchtext, 'before'); } else { $this->db->like($searchfield, $searchtext); } } $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; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; if($searchfield=="posted_date") { $searchtext=$this->mastermodel->convdatforsearch($searchtext); $this->db->like($searchfield, $searchtext, 'before'); } else { $this->db->like($searchfield, $searchtext); } } $this->db->select('noticeboard.id,noticeboard.title,noticeboard.note,noticeboard.posted_date,noticeboard.from_date,noticeboard.to_date'); $this->db->from('noticeboard'); $this->db->join('master','master.masterid=noticeboard.id'); $this->db->where('deleted', '0'); $this->db->where('ayear', $ayear); $this->db->order_by('masterid', 'desc'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertnoticeboard($postdata) { $from_date=$this->mastermodel->convertdateformat($postdata['from_date']); $to_date=$this->mastermodel->convertdateformat($postdata['to_date']); $current_date=date("Y-m-d"); $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $permission_list=''; foreach($postdata['permission'] as $permission) { $permission_list .= $permission.','; } $permission_list=substr($permission_list, 0, -1); $tbl1Values=array( 'id'=>$masterid, 'title'=>$postdata['title'], 'note'=>$postdata['note'], 'posted_date'=>$current_date, 'from_date'=>$from_date, 'to_date'=>$to_date, 'permission'=>$permission_list); $this->db->insert('noticeboard', $tbl1Values); $data['resfunction']='searchnoticeboard'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updatenoticeboard($postdata) { $from_date=$this->mastermodel->convertdateformat($postdata['from_date']); $to_date=$this->mastermodel->convertdateformat($postdata['to_date']); $current_date=date("Y-m-d"); $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['masterid']); $permission_list=''; foreach($postdata['permission'] as $permission) { $permission_list .= $permission.','; } $permission_list=substr($permission_list, 0, -1); $tbl1Values=array( 'title'=>$postdata['title'], 'note'=>$postdata['note'], 'posted_date'=>$current_date, 'from_date'=>$from_date, 'to_date'=>$to_date, 'permission'=>$permission_list); $this->db->where('id', $postdata['masterid']); $this->db->update('noticeboard', $tbl1Values); $data['resfunction']='searchnoticeboard'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } }