| Server IP : 188.114.96.2 / Your IP : 104.23.243.201 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/git/sms.edl.codes.solutions/application/models/ |
Upload File : |
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Dash_model extends CI_Model {
function __construct() {
parent::__construct();
//$this->_ci =& get_instance();
$this->load->model('crud_model');
}
function clear_cache() {
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
}
function get_weekly_courses_p($week,$action){
if(isset($week) && isset($action)){
//$query = "monday $action week $week";
$week_start = date("Y-m-d", strtotime('monday '.$action.' week '.$week));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday '.$action.' week '.$week));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
else{
$week_start = date("Y-m-d", strtotime('monday this week'));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday this week'));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
$this->db->select('*');
$this->db->from('course_scheduled_new');
$this->db->where('LessonDate <=',$week_end);
$this->db->where('LessonDate >=',$week_start);
$data = $this->db->get();
$courses = $data->result_array();
$jsonHours = "";
$debug ="";
foreach ($courses as $key => $row) {
$array = $this->crud_model->get_lesson_teacher($row['ID']);
//var_dump($array);
$teachers = array();
//var_dump($array);
foreach ($array as $key2 => $row2) {
//echo $row2;
array_push($teachers,$this->crud_model->get_teacher_name($row2));
}
$teacherList = implode(",", $teachers);
//$debug = $this->crud_model->check_child_course($this->crud_model->get_students($row['CourseID']),$this->userInfo['user_id']);
if($this->crud_model->check_child_course($this->crud_model->get_students($row['CourseID']),$this->userInfo['user_id'])){
$jsonHours = $jsonHours . "\"". $key."\":{\"id\":\"".$row['ID']."\",\"name\":\"".$this->crud_model->get_course_name($row['CourseID']);
$jsonHours = $jsonHours . "\",\"count\":\"".$this->crud_model->get_students_count($row['CourseID'])."\",\"courseId\":\"".$row['CourseID'];
$jsonHours = $jsonHours . "\",\"lan\":\"".$this->crud_model->get_course_language($row['CourseID'])."\",\"teacher\":\"".$teacherList."\",\"date\":\"".$row['LessonDate']."\",\"start\":\"".$row['LessonStart']."\",\"end\":\"".$row['LessonEnd']."\",\"done\":\"".$row['LessonDone']."\",\"comment\":\"".$row['LessonComment']."\"},";
}
}
$jsonHours = "{".rtrim($jsonHours,',')."}";
return $jsonHours;
}
function get_weekly_courses_s($week,$action){
if(isset($week) && isset($action)){
//$query = "monday $action week $week";
$week_start = date("Y-m-d", strtotime('monday '.$action.' week '.$week));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday '.$action.' week '.$week));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
else{
$week_start = date("Y-m-d", strtotime('monday this week'));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday this week'));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
$this->db->select('*');
$this->db->from('course_scheduled_new');
$this->db->where('LessonDate <=',$week_end);
$this->db->where('LessonDate >=',$week_start);
$data = $this->db->get();
$courses = $data->result_array();
$jsonHours = "";
$debug ="";
foreach ($courses as $key => $row) {
$array = $this->crud_model->get_lesson_teacher($row['ID']);
//var_dump($array);
$teachers = array();
//var_dump($array);
foreach ($array as $key2 => $row2) {
//echo $row2;
array_push($teachers,$this->crud_model->get_teacher_name($row2));
}
$teacherList = implode(",", $teachers);
$debug = $this->in_array_r($this->userInfo['user_id'],$this->crud_model->get_students($row['CourseID']));
if($this->in_array_r($this->userInfo['user_id'],$this->crud_model->get_students($row['CourseID']))){
$jsonHours = $jsonHours . "\"". $key."\":{\"id\":\"".$row['ID']."\",\"name\":\"".$this->crud_model->get_course_name($row['CourseID']);
$jsonHours = $jsonHours . "\",\"count\":\"".$this->crud_model->get_students_count($row['CourseID'])."\",\"courseId\":\"".$row['CourseID'];
$jsonHours = $jsonHours . "\",\"lan\":\"".$this->crud_model->get_course_language($row['CourseID'])."\",\"teacher\":\"".$teacherList."\",\"date\":\"".$row['LessonDate']."\",\"start\":\"".$row['LessonStart']."\",\"end\":\"".$row['LessonEnd']."\",\"done\":\"".$row['LessonDone']."\",\"comment\":\"".$row['LessonComment']."\"},";
}
}
$jsonHours = "{".rtrim($jsonHours,',')."}";
return $jsonHours;
}
function get_weekly_courses_t($week,$action){
if(isset($week) && isset($action)){
//$query = "monday $action week $week";
$week_start = date("Y-m-d", strtotime('monday '.$action.' week '.$week));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday '.$action.' week '.$week));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
else{
$week_start = date("Y-m-d", strtotime('monday this week'));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday this week'));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
$this->db->select('*');
$this->db->from('course_scheduled_new');
$this->db->where('LessonDate <=',$week_end);
$this->db->where('LessonDate >=',$week_start);
$data = $this->db->get();
$courses = $data->result_array();
$jsonHours = "";
$debug ="";
foreach ($courses as $key => $row) {
$array = $this->crud_model->get_lesson_teacher($row['ID']);
//return $row['ID'];
//return var_dump($array);
$teachers = array();
//var_dump($array);
foreach ($array as $key2 => $row2) {
//echo $row2;
array_push($teachers,$this->crud_model->get_teacher_name($row2));
}
//return var_dump($teachers);
$teacherList = implode(",", $teachers);
//$debug = $this->in_array_r($this->userInfo['user_id'],$this->crud_model->get_teachers($row['CourseID']));
if($this->in_array_r($this->userInfo['user_id'],$this->crud_model->get_course_teacher($row['CourseID']))){
$jsonHours = $jsonHours . "\"". $key."\":{\"id\":\"".$row['ID']."\",\"name\":\"".$this->crud_model->get_course_name($row['CourseID']);
$jsonHours = $jsonHours . "\",\"count\":\"".$this->crud_model->get_students_count($row['CourseID'])."\",\"courseId\":\"".$row['CourseID'];
$jsonHours = $jsonHours . "\",\"lan\":\"".$this->crud_model->get_course_language($row['CourseID'])."\",\"teacher\":\"".$teacherList."\",\"date\":\"".$row['LessonDate']."\",\"start\":\"".$row['LessonStart']."\",\"end\":\"".$row['LessonEnd']."\",\"done\":\"".$row['LessonDone']."\",\"comment\":\"".$row['LessonComment']."\"},";
}
}
$jsonHours = "{".rtrim($jsonHours,',')."}";
return $jsonHours;
}
////////////////////////////
function in_array_r($needle, $haystack) {
$found = false;
foreach ($haystack as $item) {
if ($item === $needle) {
$found = true;
break;
} else if (is_array($item)) {
$found = $this->in_array_r($needle, $item);
if($found) {
break;
}
}
}
return $found;
}
function get_weekly_courses($week,$action){
if(isset($week) && isset($action)){
//$query = "monday $action week $week";
$week_start = date("Y-m-d", strtotime('monday '.$action.' week '.$week));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday '.$action.' week '.$week));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
else{
$week_start = date("Y-m-d", strtotime('monday this week'));//date('Y-m-d', strtotime('-'.$day.' days'));
$week_end = date("Y-m-d", strtotime('sunday this week'));//date('Y-m-d', strtotime('+'.(6-$day).' days'));
}
$this->db->select('*');
$this->db->from('course_scheduled_new');
$this->db->where('LessonDate <=',$week_end);
$this->db->where('LessonDate >=',$week_start);
$data = $this->db->get();
$courses = $data->result_array();
$jsonHours = "";
foreach ($courses as $key => $row) {
$array = $this->crud_model->get_lesson_teacher($row['ID']);
//var_dump($array);
$teachers = array();
//var_dump($array);
foreach ($array as $key2 => $row2) {
//echo $row2;
array_push($teachers,$this->crud_model->get_teacher_name($row2));
}
$teacherList = implode(",", $teachers);
$jsonHours = $jsonHours . "\"". $key."\":{\"id\":\"".$row['ID']."\",\"name\":\"".$this->crud_model->get_course_name($row['CourseID']);
$jsonHours = $jsonHours . "\",\"count\":\"".$this->crud_model->get_students_count($row['CourseID'])."\",\"courseId\":\"".$row['CourseID'];
$jsonHours = $jsonHours . "\",\"lan\":\"".$this->crud_model->get_course_language($row['CourseID'])."\",\"teacher\":\"".$teacherList."\",\"date\":\"".$row['LessonDate']."\",\"start\":\"".$row['LessonStart']."\",\"end\":\"".$row['LessonEnd']."\",\"done\":\"".$row['LessonDone']."\",\"comment\":\"".$row['LessonComment']."\"},";
}
$jsonHours = "{".rtrim($jsonHours,',')."}";
return $jsonHours;
}
}
?>