?
Current Path : /home1/savoy/www/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/www/savoyglobal.net/oscardraft/application/models/emailmodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Emailmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function search_send_email() { $data = array(); $data['startpage'] = ''; $data['endpage'] = ''; $data['count'] = ''; $data['results'] = ''; 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'] = 'search_send_email'; 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_email_settings() { $data = array(); $this->db->select('*'); $this->db->from('emailsettings'); $data['results'] = $this->db->get(); return $data; } function insert_email_settings($postdata) { $data = array(); $this->db->trans_begin(); $this->db->truncate('emailsettings'); $tbl1Values = array( 'id' => 1, 'from_email' => $postdata['from_email'], 'from_name' => $postdata['from_name'], 'from_password' => $postdata['from_password'], 'smtp' => $postdata['smtp']); $this->db->insert('emailsettings', $tbl1Values); $data['resfunction'] = 'search_email_settings'; 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_email_template() { $data = array(); $this->db->select('*'); $this->db->from('emailtemplate'); $data['results'] = $this->db->get(); return $data; } function insert_email_template($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values = array( 'template_id' => $masterid, 'template_title' => $postdata['template_title'], 'template_subject' => $postdata['template_subject'], 'template_contents' => $postdata['template_contents']); $this->db->insert('emailtemplate', $tbl1Values); $data['resfunction'] = 'search_email_template'; 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_email_template($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->where('template_id', $postdata['template_id']); $this->db->update('emailtemplate', $tbl1Values); $data['resfunction'] = 'search_email_template'; 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_email_reports() { $data = array(); $this->db->select('*'); $this->db->from('emailreport'); $this->db->order_by('email_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function loadEmailList($postdata) { $data = array(); $sql = ""; if ((isset($postdata['teacher_id']) != 'on') && (isset($postdata['parent_id']) != 'on') && (isset($postdata['staff_id']) != 'on')) { $data['results'] = ""; } else { if (isset($postdata['teacher_id']) == 'on') { $teacher = array(); if (isset($postdata['teacher_class_name_id'])) { for ($i = 0; $i < count($postdata['teacher_class_name_id']); $i++) { $c_id = $postdata['teacher_class_name_id'][$i]; $teacher[] = $c_id; } } if (count($teacher) > 0) { $sql.=" select master_id as sort_id,master_id ,menu_id,employee_name as name, employee_no as reg, nationality_name as nationality, employee_gender as gender, employee.employee_email as email, 'Teacher' as type,class_name_code from employee join nationality on employee.employee_nationality_id=nationality.nationality_id left join class_teacher on class_teacher.teacher_id=employee.employee_id left join class_name on class_name.class_name_id=class_teacher.class_name_id join master on master.master_id= employee.employee_id WHERE class_name.class_name_id in (" . join(',', $teacher) . ") AND `employee_teacher`=1 GROUP BY teacher_id "; if ((isset($postdata['parent_id']) == 'on') || (isset($postdata['staff_id']) == 'on')) $sql.=" union "; } } if (isset($postdata['parent_id']) == 'on') { $parent = array(); if (isset($postdata['parent_class_name_id'])) { for ($i = 0; $i < count($postdata['parent_class_name_id']); $i++) { $c_id = $postdata['parent_class_name_id'][$i]; $parent[] = $c_id; } } if (count($parent) > 0) { $sql.="(select parent.parent_id as sort_id,master_id,menu_id, CONCAT (parent.father_name,' - ',student.first_name,' ',student.last_name) as name,student.reg_no as reg, nationality.nationality_name as nationality, student.gender as gender, parent.father_email as email, 'Father' as type,class_name_code from student_class join class_name on class_name.class_name_id=student_class.class_name_id join student on student.student_id=student_class.student_id join nationality on student.nationality_id=nationality.nationality_id join parent_student on parent_student.student_id=student_class.student_id join parent on parent.parent_id=parent_student.parent_id join master on master.master_id= parent.parent_id left join student_cancellation on student_cancellation.student_class_id=student_class.student_class_id WHERE class_name.class_name_id in (" . join(',', $parent) . ") AND cancellation_id is null GROUP BY parent.parent_id ORDER BY student.student_id )"; $sql.="UNION (select parent.parent_id as sort_id,master_id,menu_id, CONCAT (parent.mother_name,' - ',student.first_name,' ',student.last_name) as name ,student.reg_no as reg , nationality.nationality_name as nationality, student.gender as gender, parent.mother_email as email, 'Mother' as type,class_name_code from student_class join class_name on class_name.class_name_id=student_class.class_name_id join student on student.student_id=student_class.student_id join nationality on student.nationality_id=nationality.nationality_id join parent_student on parent_student.student_id=student_class.student_id join parent on parent.parent_id=parent_student.parent_id join master on master.master_id= parent.parent_id left join student_cancellation on student_cancellation.student_class_id=student_class.student_class_id WHERE class_name.class_name_id in (" . join(',', $parent) . ") AND cancellation_id is null GROUP BY parent.parent_id ORDER BY student.student_id )"; if (isset($postdata['staff_id']) == 'on') $sql.=" UNION "; } } if (isset($postdata['staff_id']) == 'on') { $sql.= "(select master_id as sort_id,master_id ,menu_id,employee_name as name, employee_no as reg1, nationality.nationality_name as nationality, employee_gender as gender, employee.employee_email as email, 'Employee' as type,'' as class_name_code from employee join nationality on employee.employee_nationality_id=nationality.nationality_id join master on master.master_id= employee.employee_id where `employee_teacher`=0 GROUP BY employee.employee_id"; if (isset($postdata['department_id'])) { $ids = join(',', $postdata['department_id']); $sql.=" and employee_department_id in (" . $ids . "))"; } } if ($sql != '') { $sql.=" ORDER BY sort_id ASC "; // echo $sql; $data['results'] = $this->db->query($sql); } else $data['results'] = ""; return $data; } } } ?>