?
Current Path : /home1/savoy/public_html/savoyglobal.net/simsdemo/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/simsdemo/school/application/models/emailmodel.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 Emailmodel extends Model { function Emailmodel() { parent::Model(); } function searchsendemail($postdata,$pagenum) { $data=array(); $arr=$this->fpaginate->paginate($pagenum,1); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=1; $data['results']=1; return $data; } function searchemailtemplate($postdata,$pagenum) { $data=array(); $this->db->from('emailtemplate'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $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']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('emailtemplate'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertemailtemplate($postdata) { $data=array(); $this->db->trans_begin(); $tbl1Values=array( 'template_title'=>$postdata['template_title'], 'template_subject'=>$postdata['template_subject'], 'template_contents'=>$postdata['template_contents']); $this->db->insert('emailtemplate', $tbl1Values); $data['resfunction']='searchemailtemplate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updateemailtemplate($postdata) { $data=array(); $this->db->trans_begin(); $tbl2Values=array( 'template_title'=>$postdata['template_title'], 'template_subject'=>$postdata['template_subject'], 'template_contents'=>$postdata['template_contents']); $this->db->where('template_id',$postdata['template_id']); $this->db->update('emailtemplate', $tbl2Values); $data['resfunction']='searchemailtemplate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function searchemailreport($postdata,$pagenum) { $data=array(); $this->db->from('emailreport'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $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']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('emailreport'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertemail($postdata) { $data=array(); $this->db->trans_begin(); $this->load->library('mail'); $from_details=$this->mastermodel->get_data_srow('emailsettings','1','id'); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array( 'email_id'=>$masterid, 'email_subject'=>$postdata['template_subject'], 'email_contents'=>$postdata['template_contents'], 'email_date'=>date("Y-m-d"), 'status'=>'Sent'); $this->db->insert('emailreport', $tbl1Values); for($i=1;$i<=$postdata['email_count'];$i++) { if(isset($postdata['check_email_'.$i])=="on" && ($postdata['check_email_'.$i] !='')) { $tbl1Values=array( 'email_id'=>$masterid, 'receipent_email'=>$postdata['check_email_'.$i], 'receipent_name'=>$postdata['receipent_name_'.$i], 'receipent_type'=>$postdata['receipent_type_'.$i], ); $this->db->insert('email_receipents', $tbl1Values); $this->mail->send($postdata['template_contents'], $postdata['check_email_'.$i],$postdata['template_subject'],$from_details->from_email,$from_details->from_name,$from_details->from_password,$from_details->smtp); } } $data['resfunction']='searchsendemail'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function loademaillist($postdata) { $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1'); $data=array(); $sql=""; if((isset($postdata['student_id']) != 'on')&&(isset($postdata['teacher_id']) != 'on')&&(isset($postdata['parent_id']) != 'on')&&(isset($postdata['staff_id']) != 'on')) { $data['results']=""; } else { if(isset($postdata['student_id'])== 'on') { $sql.= "select masterid,student.first_name as name,student.mobile_no,student.email,module_id from student join master on master.masterid= student.student_id where master.deleted=0 and ayear=$ayear"; if(isset ($postdata['studclasslevel_id'])) { $ids = join(',',$postdata['studclasslevel_id']); $sql.=" and classlevel_id in (".$ids.")"; } if((isset($postdata['teacher_id']) == 'on')||(isset($postdata['parent_id']) == 'on')||(isset($postdata['staff_id']) == 'on')) $sql.=" union "; } if(isset($postdata['teacher_id']) == 'on') { $sql.= "select masterid,teacher.first_name as name,teacher.mobile_no,teacher.email,module_id from teacher join teacher_subject on teacher_subject.teacher_id=teacher.teacher_id join subject on subject.subject_id =teacher_subject.subject_id join master on master.masterid= teacher.teacher_id where master.deleted=0 and ayear=$ayear"; if(isset ($postdata['studclasslevel_id'])) { $ids = join(',',$postdata['teachclasslevel_id']); $sql.=" and classlevel_id in (".$ids.")"; } if((isset($postdata['parent_id'])== 'on')||(isset($postdata['staff_id']) == 'on')) $sql.=" union "; } if(isset($postdata['parent_id'])== 'on') { $sql.= "select masterid,parent.name as name,parent.mobile_no,parent.email,module_id from parent join parent_student on parent.parent_id = parent_student.parent_id join student on student.student_id=parent_student.student_id join master on master.masterid= parent.parent_id where master.deleted=0 and ayear=$ayear"; if(isset($postdata['parclasslevel_id'])) { $ids = join(',',$postdata['parclasslevel_id']); $sql.=" and classlevel_id in (".$ids.")"; } if(isset($postdata['staff_id'])== 'on') $sql.=" union "; } if(isset($postdata['staff_id'])== 'on') { $sql.= "select masterid,staff.name as name,staff.mobile_no,staff.email,module_id from staff join master on master.masterid= staff.staff_id where master.deleted=0 and ayear=$ayear"; if(isset($postdata['department_id'])) { $ids = join(',',$postdata['department_id']); $sql.=" and department_id in (".$ids.")"; } } $data['results']=$this->db->query($sql); } $data['startpage']=''; $data['endpage']=''; $data['count']=''; return $data; } function searchemailsettings($postdata,$pagenum) { $data=array(); $arr=$this->fpaginate->paginate($pagenum,1); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=1; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('emailsettings'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertemailsettings($postdata) { $data=array(); $this->db->trans_begin(); $this->db->truncate('smssettings'); $tbl1Values=array( 'from_email'=>$postdata['from_email'], 'from_name'=>$postdata['from_name'], 'from_password'=>$postdata['from_password'], 'smtp'=>$postdata['smtp']); $this->db->where('id', '1'); $this->db->update('emailsettings', $tbl1Values); $data['resfunction']='searchemailsettings'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } }