?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec/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/sec/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'); $this->db->order_by('template_id','desc'); $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['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') { $student = array(); if (isset($postdata['student_course_level'])) { for ($i = 0; $i < count($postdata['student_course_level']); $i++) { $c_id = $postdata['student_course_level'][$i]; if ($postdata['student_course_level_count_' . $c_id] > 0) { if (isset($postdata['student_batch_level'][$c_id]) ) { for ($j = 0; $j < count($postdata['student_batch_level'][$c_id]); $j++) { $student[] = $postdata['student_batch_level'][$c_id][$j]; } } } } } if (count($student) > 0) { $sql.="select student.student_id as sort_id,master_id,menu_id,concat(student.first_name,' ',student.last_name) as name,student.reg_no as reg, student.nationality as nationality, student.gender as gender, student.email as email,'Student' as type, batch_no from student_batch join batch on batch_id=current_batch_id join student on student.student_id=student_batch.student_id join master on master.master_id= student.student_id left join student_cancellation on student_cancellation.student_batch_id=student_batch.student_batch_id WHERE current_batch_id in (" . join(',', $student) . ") AND cancellation_id is null GROUP BY student_batch.student_id"; if ((isset($postdata['teacher_id']) == 'on') || (isset($postdata['parent_id']) == 'on') || (isset($postdata['staff_id']) == 'on')) $sql.=" union "; } } if (isset($postdata['teacher_id']) == 'on') { $teacher = array(); if (isset($postdata['teach_course_level'])) { for ($i = 0; $i < count($postdata['teach_course_level']); $i++) { $c_id = $postdata['teach_course_level'][$i]; if ($postdata['teach_course_level_count_' . $c_id] > 0) { if (isset($postdata['teach_batch_level'][$c_id])) { for ($j = 0; $j < count($postdata['teach_batch_level'][$c_id]); $j++) { $teacher[] = $postdata['teach_batch_level'][$c_id][$j]; } } } } } if (count($teacher) > 0) { $sql.="select master_id as sort_id,master_id ,menu_id,employee_name as name, employee_no as reg, employee_nationality as nationality, employee_gender as gender, employee.employee_email as email, 'Teacher' as type,batch_no from employee left join batch on batch.teacher_id=employee.employee_id join master on master.master_id= employee.employee_id WHERE batch_id in (" . join(',', $teacher) . ") AND `employee_teacher`=1 GROUP BY employee.employee_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_course_level'])) { for ($i = 0; $i < count($postdata['parent_course_level']); $i++) { $c_id = $postdata['parent_course_level'][$i]; if ($postdata['parent_course_level_count_' . $c_id] > 0) { if (isset($postdata['parent_batch_level'][$c_id])) { for ($j = 0; $j < count($postdata['parent_batch_level'][$c_id]); $j++) { $parent[] = $postdata['parent_batch_level'][$c_id][$j]; } } } } } 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, student.nationality as nationality, student.gender as gender, parent.father_email as email, 'Father' as type,batch_no from student_batch join batch on batch_id=current_batch_id join student on student.student_id=student_batch.student_id join parent_student on parent_student.student_id=student_batch.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_batch_id=student_batch.student_batch_id WHERE current_batch_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 , student.nationality as nationality, student.gender as gender, parent.mother_email as email, 'Mother' as type,batch_no from student_batch join batch on batch_id=current_batch_id join student on student.student_id=student_batch.student_id join parent_student on parent_student.student_id=student_batch.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_batch_id=student_batch.student_batch_id WHERE current_batch_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, employee_nationality as nationality, employee_gender as gender, employee.employee_email as email, 'Employee' as type,'' as batch_no from employee 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 "; $data['results'] = $this->db->query($sql); } else $data['results'] = ""; return $data; } } } ?>