Beispiel #1
0
 public function all_classes($x = '')
 {
     $form_id = 8;
     $hrw = get_form_authority($this->session->userdata('group_id'), $form_id);
     if ($hrw == "h") {
         echo "      No privilege ...    . Contact System Administrator ";
         redirect(SITE_LINK . "/security/login", "refresh");
     }
     $action_get = $this->input->get("action");
     $action_post = $this->input->post("action");
     $ajax_data = json_decode($this->input->post("data"));
     $data = array();
     if (empty($x)) {
         $this->db->select("*");
         $this->db->from("class");
         $this->db->limit(1);
         $rr = $this->db->get();
         $r_class = $rr->row();
         $class = $r_class->class_id;
     } else {
         $class = $x;
     }
     $q_stage = $this->db->query('select stage  from v_stage_level_class where class_id="' . $class . '" ');
     $res_stage = $q_stage->row();
     $q_level = $this->db->query('select  level  from v_stage_level_class where class_id="' . $class . '" ');
     $res = $q_level->row();
     $students = $this->mymodel_model->select("users", 'groups="student" and id not in (select student_id from class_students) and stage  in("' . $res_stage->stage . '") and level  in ("' . $res->level . '")  ');
     $class_students = $this->mymodel_model->select("v_class_students", "class_id={$class}");
     if ($action_get == "load_classes") {
         $arr = array();
         $stage_level_class = array();
         $query = $this->db->query('select distinct stage as id , stage_name as text from v_stage_level_class');
         foreach ($query->result() as $row) {
             //  $arr['id']="";
             $arr['text'] = $row->text;
             $arr['children'] = $this->get_level_children($row->id);
             $stage_level_class[] = $arr;
             //    print_r($arr);
         }
         echo json_encode($stage_level_class);
         exit;
     }
     if ($action_post == "distribute_students") {
         $no = "";
         $message = "";
         $big_st_ids = array();
         foreach ($ajax_data->students_inclass as $st) {
             $big_st_ids[] = array("class_id" => $ajax_data->class, "student_id" => $st);
         }
         $this->db->trans_begin();
         $this->db->where("class_id", $ajax_data->class);
         $this->db->delete("class_students");
         if (!empty($big_st_ids)) {
             $this->db->insert_batch("class_students", $big_st_ids);
             if ($this->db->affected_rows() > 0) {
                 $no = $this->db->affected_rows();
                 $message = "success";
                 $this->db->trans_commit();
             } else {
                 $message = "failed  ";
                 $this->db->trans_rollback();
             }
         }
         // echo $this->db->last_query();
         echo json_encode(array("message" => $message, "no" => $no));
         exit;
     }
     $data["js_vars"] = json_encode(array('current_link' => SITE_LINK . "/" . $this->uri->segments[1] . "/" . $this->uri->segments[2], 'controller_link' => SITE_LINK . "/" . $this->uri->segments[1], 'details' => SITE_LINK . "/" . "student/" . "details/", 'main_url' => SITE_LINK . "/" . "security/", 'p_class' => $class, 'hrw' => $hrw));
     $data['hrw'] = $hrw;
     $data['base_url'][] = SITE_LINK;
     // $data['classes'][] = $classes;
     $data['students'][] = $students;
     $data['p_class'][] = $class;
     $data['class_students'][] = $class_students;
     $data['js'][] = "usage/class.js";
     $data['first_title'] = "Home";
     $data['second_title'] = "Class";
     $data['third_title'] = "Distribute Students on Classes ";
     $this->load->view('admin' . DIRECTORY_SEPARATOR . 'class', $data);
 }
Beispiel #2
0
 function expenses()
 {
     $form_id = 10;
     $hrw = get_form_authority($this->session->userdata('group_id'), $form_id);
     if ($hrw == "h") {
         echo "      No privilege ...   . Contact System Administrator ";
         redirect(SITE_LINK . "/security/login", "refresh");
     }
     $action_get = $this->input->get("action");
     $action_post = $this->input->post("action");
     $stage = $this->input->get("stage");
     $level = $this->input->get("level");
     $row_add = json_decode($this->input->post("row_add"));
     $expense = $this->input->get("expense");
     $installment = $this->input->get("installment");
     $stages = $this->mymodel_model->select("stages", '1=1');
     $levels = $this->mymodel_model->select("levels", '1=1');
     $installments = $this->mymodel_model->select("installments", '1=1');
     $teachers = $this->mymodel_model->select("users", 'groups="teacher"');
     $expenses = $this->mymodel_model->select("expenses", '1=1 ');
     if ($this->session->userdata("groups") != "admin") {
         redirect(SITE_LINK . '/security/login', 'refresh');
     } else {
         if ($action_get == "get_data") {
             $back = array();
             $this->db->select('*');
             $this->db->start_cache();
             $this->db->from("v_student_expenses");
             $this->db->where("stage", $stage);
             $this->db->where("level", $level);
             $this->db->where("expenses_id", $expense);
             $this->db->where("installment_id", $installment);
             $flds_array = array('name' => array('where' => "name", 'order' => "name", 'val_template' => '', 'lower' => true), 'amount' => array('where' => "amount", 'order' => "amount", 'val_template' => '', 'lower' => true), 'discount' => array('where' => "discount", 'order' => "discount", 'val_template' => '', 'lower' => true), 'national_id' => array('where' => "national_id", 'order' => "national_id", 'val_template' => '', 'lower' => true), 'paid_date' => array('where' => "religion", 'order' => "paid_date", 'val_template' => '', 'lower' => true));
             $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
             $rows = isset($_GET['rows']) ? intval($_GET['rows']) : 10;
             if (empty($rows)) {
                 $rows = 10;
             }
             if (empty($page)) {
                 $page = 1;
             }
             $offset = ($page - 1) * $rows + 1;
             $sort = isset($_GET['sort']) ? $_GET['sort'] : 'class_id';
             $order = isset($_GET['order']) ? $_GET['order'] : 'asc';
             $filterRules = json_decode($this->input->get('filterRules'));
             $sorting_array = explode(',', $sort);
             $order_array = explode(',', $order);
             if (is_array($filterRules)) {
                 if (count($filterRules) > 0) {
                     foreach ($filterRules as $value) {
                         $where = "where";
                         $op = $value->op;
                         $f = $value->field;
                         $v = $value->value;
                         if (in_array($op, array('contains', 'beginwith', 'endwith'))) {
                             $is_like = true;
                             $where = 'like';
                             if ($op == "beginwith") {
                                 $like_p = 'after';
                             } elseif ($op == "endwith") {
                                 $like_p = 'before';
                             } else {
                                 $like_p = 'both';
                             }
                         } elseif (in_array($op, array('notcontains', 'notbeginwith', 'notendwith'))) {
                             $is_like = true;
                             $where = 'not_like';
                             if ($op == "notbeginwith") {
                                 $like_p = 'after';
                             } elseif ($op == "notendwith") {
                                 $like_p = 'before';
                             } else {
                                 $like_p = 'both';
                             }
                         } else {
                             $is_like = false;
                             if ($op == "notequal") {
                                 $like_p = ' != ';
                             } elseif ($op == "less") {
                                 $like_p = ' < ';
                             } elseif ($op == "lessorequal") {
                                 $like_p = ' <= ';
                             } elseif ($op == "greater") {
                                 $like_p = ' > ';
                             } elseif ($op == "greaterorequal") {
                                 $like_p = ' >= ';
                             } else {
                                 $like_p = '';
                             }
                         }
                         if (array_key_exists($f, $flds_array)) {
                             if ($is_like) {
                                 if (empty($flds_array[$f]["val_template"])) {
                                     if ($flds_array[$f]["lower"]) {
                                         $v = strtolower($v);
                                     }
                                     $this->db->{$where}($flds_array[$f]["where"], $v, $like_p);
                                 } else {
                                     if ($flds_array[$f]["lower"]) {
                                         $v = strtolower($v);
                                     }
                                     $m = str_replace('{the_value}', $v, $flds_array[$f]["val_template"]);
                                     if ($like_p == "after") {
                                         $this->db->{$where}("{$flds_array[$f]["where"]} LIKE '%{$m}''");
                                     } elseif ($like_p == "before") {
                                         $this->db->{$where}("{$flds_array[$f]["where"]} LIKE '{$m}%'");
                                     } else {
                                         $this->db->{$where}("{$flds_array[$f]["where"]} LIKE '%{$m}%'");
                                     }
                                 }
                             } else {
                                 if ($flds_array[$f]["lower"]) {
                                     $v = strtolower($v);
                                 }
                                 if (empty($like_p)) {
                                     $like_p = "=";
                                 }
                                 if (empty($flds_array[$f]["val_template"])) {
                                     if ($like_p == "=") {
                                         $this->db->{$where}($flds_array[$f]["where"] . " {$like_p} '{$v}'");
                                     } else {
                                         $this->db->{$where}("{$flds_array[$f]["where"]} {$like_p}", $v);
                                     }
                                 } else {
                                     $m = str_replace('{the_value}', $v, $flds_array[$f]["val_template"]);
                                     $this->db->{$where}("{$flds_array[$f]["where"]} {$like_p} {$m}");
                                 }
                             }
                         }
                     }
                 }
             }
             // End user filter
             $this->db->stop_cache();
             // start filter
             if (is_array($sorting_array)) {
                 foreach ($sorting_array as $key => $sort) {
                     if (array_key_exists($sort, $flds_array)) {
                         $ord = 'ASC';
                         if (isset($order_array[$key])) {
                             $ord = $order_array[$key] == 'desc' ? 'DESC' : 'ASC';
                         }
                         $this->db->order_by($flds_array[$sort]["order"], $ord);
                     }
                 }
             }
             //Make limit
             $this->db->limit($rows, $offset - 1);
             $rs = $this->db->get();
             //  echo $this->db->last_query();
             if ($rs->num_rows() > 0) {
                 $back = array('total' => $this->db->count_all_results(), 'rows' => $rs->result_array());
             }
             echo json_encode($back);
             exit;
         }
         if ($action_get == "get_students") {
             $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
             $rows = isset($_GET['rows']) ? intval($_GET['rows']) : 10;
             if (empty($rows)) {
                 $rows = 10;
             }
             if (empty($page)) {
                 $page = 1;
             }
             $offset = ($page - 1) * $rows + 1;
             $back = array();
             $this->db->select('*');
             $this->db->start_cache();
             $this->db->from("users");
             $this->db->where("groups", "student");
             $this->db->where("stage", $stage);
             $this->db->where("level", $level);
             $this->db->limit($rows, $offset - 1);
             $rs = $this->db->get();
             // echo $this->db->last_query();
             if ($rs->num_rows() > 0) {
                 $back = array('total' => $this->db->count_all_results(), 'rows' => $rs->result_array());
             }
             echo json_encode($back);
             exit;
         }
         if ($action_post == "add") {
             $dat = array('student_id' => $row_add->student_id, 'installment_id' => $row_add->installment_id, 'paid_date' => $row_add->paid_date, 'amount' => $row_add->amount, 'expenses_discount' => $row_add->expenses_discount);
             $this->db->insert("student_installments", $dat);
             if ($this->db->affected_rows() > 0 || $this->db->affected_rows() == 0) {
                 echo json_encode(array("result" => "success"));
             } else {
                 echo json_encode(array("result" => $this->db->_error_number() . " * " . $this->db->_error_message()));
             }
             exit;
         }
         if ($action_post == "edit") {
             $dat = array('paid_date' => $row_add->paid_date, 'amount' => $row_add->amount, 'expenses_discount' => $row_add->expenses_discount);
             $this->db->where("student_id", $row_add->student_id);
             $this->db->where("installment_id", $row_add->installment_id);
             $this->db->update("student_installments", $dat);
             if ($this->db->affected_rows() > 0 || $this->db->affected_rows() == 0) {
                 echo json_encode(array("result" => "success"));
             } else {
                 echo json_encode(array("result" => $this->db->_error_number() . " * " . $this->db->_error_message()));
             }
             exit;
         }
         if ($action_post == "delete") {
             $this->db->where("class_id", $this->input->post('id'));
             $this->db->delete("class");
             if ($this->db->affected_rows() > 0) {
                 echo json_encode(array("result" => "success"));
             } else {
                 echo json_encode(array("result" => "failed"));
             }
             // echo $this->db->last_query();
             exit;
         }
     }
     $data = array();
     $data["js_vars"] = json_encode(array('current_link' => SITE_LINK . "/" . $this->uri->segments[1] . "/" . $this->uri->segments[2], 'details' => SITE_LINK . "/" . "student/" . "details/", 'main_url' => SITE_LINK . "/" . "security/", 'stages' => $stages, 'levels' => $levels, 'expenses' => $expenses, 'installments' => $installments, 'hrw' => $hrw));
     $data['hrw'] = $hrw;
     $data['base_url'][] = SITE_LINK;
     $data['js'][] = "usage/student_expenses.js";
     $data['main_url'] = SITE_LINK;
     $data['stages'] = $stages;
     $data['levels'] = $levels;
     $data['teachers'] = $teachers;
     $data['expenses'] = $expenses;
     $data['first_title'] = "Home";
     $data['second_title'] = "Finance";
     $data['third_title'] = " Expenses And Fees ";
     $this->load->view('admin' . DIRECTORY_SEPARATOR . 'student_expenses', $data);
 }
Beispiel #3
0
 function index()
 {
     $form_id = 3;
     $hrw = get_form_authority($this->session->userdata('group_id'), $form_id);
     if ($hrw == "h") {
         echo "    No privilege ...   . Contact System Administrator ";
         redirect(SITE_LINK . "/security/login", "refresh");
     }
     $action_get = $this->input->get("action");
     $action_post = $this->input->post("action");
     $id = $this->input->get("id");
     $group = $this->input->get("user_group");
     $row_add = json_decode($this->input->post("row_add"));
     $row = json_decode($this->input->post("row"));
     $ajax_data = json_decode($this->input->post("data"));
     $groups = $this->mymodel_model->select("groups", '1=1 order by sort asc ');
     $stages = $this->mymodel_model->select("stages", '1=1');
     $levels = $this->mymodel_model->select("levels", '1=1');
     if ($action_get == "get_data") {
         $back = array();
         $this->db->select('*');
         $this->db->start_cache();
         $this->db->from("users");
         if ($id) {
             $this->db->where("id", $id);
         } elseif ($group) {
             $this->db->where("groups", $group);
         }
         //User filter
         $flds_array = array('name' => array('where' => "name", 'order' => "name", 'val_template' => '', 'lower' => true), 'username' => array('where' => "username", 'order' => "username", 'val_template' => '', 'lower' => true), 'email' => array('where' => "email", 'order' => "email", 'val_template' => '', 'lower' => true), 'phone' => array('where' => "phone", 'order' => "phone", 'val_template' => '', 'lower' => true), 'national_id' => array('where' => "national_id", 'order' => "national_id", 'val_template' => '', 'lower' => true));
         $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
         $rows = isset($_GET['rows']) ? intval($_GET['rows']) : 10;
         if (empty($rows)) {
             $rows = 10;
         }
         if (empty($page)) {
             $page = 1;
         }
         $offset = ($page - 1) * $rows + 1;
         $sort = isset($_GET['sort']) ? $_GET['sort'] : 'id';
         $order = isset($_GET['order']) ? $_GET['order'] : 'asc';
         $filterRules = json_decode($this->input->get('filterRules'));
         $sorting_array = explode(',', $sort);
         $order_array = explode(',', $order);
         if (is_array($filterRules)) {
             if (count($filterRules) > 0) {
                 foreach ($filterRules as $value) {
                     $where = "where";
                     $op = $value->op;
                     $f = $value->field;
                     $v = $value->value;
                     if (in_array($op, array('contains', 'beginwith', 'endwith'))) {
                         $is_like = true;
                         $where = 'like';
                         if ($op == "beginwith") {
                             $like_p = 'after';
                         } elseif ($op == "endwith") {
                             $like_p = 'before';
                         } else {
                             $like_p = 'both';
                         }
                     } elseif (in_array($op, array('notcontains', 'notbeginwith', 'notendwith'))) {
                         $is_like = true;
                         $where = 'not_like';
                         if ($op == "notbeginwith") {
                             $like_p = 'after';
                         } elseif ($op == "notendwith") {
                             $like_p = 'before';
                         } else {
                             $like_p = 'both';
                         }
                     } else {
                         $is_like = false;
                         if ($op == "notequal") {
                             $like_p = ' != ';
                         } elseif ($op == "less") {
                             $like_p = ' < ';
                         } elseif ($op == "lessorequal") {
                             $like_p = ' <= ';
                         } elseif ($op == "greater") {
                             $like_p = ' > ';
                         } elseif ($op == "greaterorequal") {
                             $like_p = ' >= ';
                         } else {
                             $like_p = '';
                         }
                     }
                     if (array_key_exists($f, $flds_array)) {
                         if ($is_like) {
                             if (empty($flds_array[$f]["val_template"])) {
                                 if ($flds_array[$f]["lower"]) {
                                     $v = strtolower($v);
                                 }
                                 $this->db->{$where}($flds_array[$f]["where"], $v, $like_p);
                             } else {
                                 if ($flds_array[$f]["lower"]) {
                                     $v = strtolower($v);
                                 }
                                 $m = str_replace('{the_value}', $v, $flds_array[$f]["val_template"]);
                                 if ($like_p == "after") {
                                     $this->db->{$where}("{$flds_array[$f]["where"]} LIKE '%{$m}''");
                                 } elseif ($like_p == "before") {
                                     $this->db->{$where}("{$flds_array[$f]["where"]} LIKE '{$m}%'");
                                 } else {
                                     $this->db->{$where}("{$flds_array[$f]["where"]} LIKE '%{$m}%'");
                                 }
                             }
                         } else {
                             if ($flds_array[$f]["lower"]) {
                                 $v = strtolower($v);
                             }
                             if (empty($like_p)) {
                                 $like_p = "=";
                             }
                             if (empty($flds_array[$f]["val_template"])) {
                                 if ($like_p == "=") {
                                     $this->db->{$where}($flds_array[$f]["where"] . " {$like_p} '{$v}'");
                                 } else {
                                     $this->db->{$where}("{$flds_array[$f]["where"]} {$like_p}", $v);
                                 }
                             } else {
                                 $m = str_replace('{the_value}', $v, $flds_array[$f]["val_template"]);
                                 $this->db->{$where}("{$flds_array[$f]["where"]} {$like_p} {$m}");
                             }
                         }
                     }
                 }
             }
         }
         // End user filter
         $this->db->stop_cache();
         // start filter
         if (is_array($sorting_array)) {
             foreach ($sorting_array as $key => $sort) {
                 if (array_key_exists($sort, $flds_array)) {
                     $ord = 'ASC';
                     if (isset($order_array[$key])) {
                         $ord = $order_array[$key] == 'desc' ? 'DESC' : 'ASC';
                     }
                     $this->db->order_by($flds_array[$sort]["order"], $ord);
                 }
             }
         }
         //Make limit
         $this->db->limit($rows, $offset - 1);
         $rs = $this->db->get();
         //  echo $this->db->last_query();
         if ($rs->num_rows() > 0) {
             $back = array('total' => $this->db->count_all_results(), 'rows' => $rs->result_array());
         }
         echo json_encode($back);
         exit;
     }
     if ($action_post == "create_user") {
         $bus_fees = '';
         $salt = '';
         $password = $this->ion_auth->hash_password($row_add->password, $salt);
         if ($row_add->stage) {
             $the_stage = $row_add->stage;
         } else {
             $the_stage = 0;
         }
         if ($row_add->level) {
             $the_level = $row_add->level;
         } else {
             $the_level = 0;
         }
         if ($row_add->job) {
             $job = $row_add->job;
         } else {
             $job = '';
         }
         $dat = array('name' => $row_add->name, 'address' => $row_add->address, 'national_id' => $row_add->national_id, 'sex' => $row_add->sex, 'religion' => $row_add->religion, 'birthday' => $row_add->birthday, 'blood_group' => $row_add->blood_group, 'photo' => $this->session->userdata("image_name"), 'phone' => $row_add->phone, 'username' => $row_add->username, 'groups' => $row_add->groups, 'email' => strtolower($row_add->email), 'password ' => $password, 'bus_fees' => $row_add->bus_fees, 'last_login' => date('d/m/Y  h:m:s'), 'active' => 1, 'stage' => $the_stage, 'level' => $the_level, 'job' => $job);
         if (strlen($dat['photo']) < 3) {
             unset($dat['photo']);
         }
         $this->db->where('national_id', $row_add->national_id);
         $num = $this->db->count_all_results("users");
         //table name from drowp down
         if ($num > 0) {
             $this->db->where("national_id", $row_add->national_id);
             $this->db->update("users", $dat);
         } else {
             $this->db->insert("users", $dat);
         }
         if ($this->db->affected_rows() > 0 || $this->db->affected_rows() == 0) {
             echo json_encode(array("result" => "success"));
         } else {
             echo json_encode(array("result" => $this->db->_error_number() . " * " . $this->db->_error_message()));
         }
         $this->session->unset_userdata('image_name');
         exit;
     }
     if ($action_post == "edit_user") {
         if (!$this->ion_auth->logged_in()) {
             redirect(SITE_LINK . "/security/login", 'refresh');
         }
         $salt = '';
         $password = $this->ion_auth->hash_password($row_add->password, $salt);
         if ($row_add->stage) {
             $the_stage = $row_add->stage;
         } else {
             $the_stage = 0;
         }
         if ($row_add->level) {
             $the_level = $row_add->level;
         } else {
             $the_level = 0;
         }
         if ($row_add->job) {
             $job = $row_add->job;
         } else {
             $job = '';
         }
         if ($this->session->userdata("image_name")) {
             $image = $this->session->userdata("image_name");
         } else {
             $image = "";
         }
         $dat = array('name' => $row_add->name, 'address' => $row_add->address, 'national_id' => $row_add->national_id, 'sex' => $row_add->sex, 'religion' => $row_add->religion, 'birthday' => $row_add->birthday, 'blood_group' => $row_add->blood_group, 'photo' => $image, 'phone' => $row_add->phone, 'username' => $row_add->username, 'groups' => $row_add->groups, 'email' => strtolower($row_add->email), 'bus_fees' => $row_add->bus_fees, 'last_login' => date('d/m/Y h:m:s'), 'stage' => $the_stage, 'level' => $the_level, 'job' => $job);
         if (strlen($dat['photo']) < 3) {
             unset($dat['photo']);
         }
         $this->db->where("id", $row_add->id);
         $this->db->update("users", $dat);
         if ($this->db->affected_rows() > 0) {
             echo json_encode(array("result" => "success"));
         } elseif ($this->db->affected_rows() == 0) {
             echo json_encode(array("result" => "Nothing updated"));
         } else {
             echo json_encode(array("result" => "failed"));
         }
         $this->session->unset_userdata('image_name');
         //echo $this->db->last_query();
         exit;
     }
     if ($action_post == "delete") {
         $this->db->where("id", $row->id);
         $this->db->delete("users");
         if ($this->db->affected_rows() > 0) {
             echo json_encode(array("result" => "success"));
         } else {
             echo json_encode(array("result" => "failed"));
         }
         // echo $this->db->last_query();
         exit;
     }
     if ($action_post == "activation") {
         $new_data = array("active" => $this->input->post('activation'));
         $this->db->where("id", $this->input->post('id'));
         $this->db->update("users", $new_data);
         if ($this->db->affected_rows() > 0) {
             echo json_encode(array("message" => "success"));
         } else {
             echo json_encode(array("message" => "failed"));
         }
         //   echo $this->db->last_query();
         exit;
     }
     if ($action_post == "reset_password") {
         $salt = '';
         $pass = $this->ion_auth->hash_password($this->input->post("password"), $salt);
         $new_data = array("password" => $pass);
         $this->db->where("id", $this->input->post('id'));
         $this->db->update("users", $new_data);
         if ($this->db->affected_rows() > 0) {
             echo json_encode(array("message" => "success"));
         } else {
             echo json_encode(array("message" => "failed"));
         }
         exit;
     }
     if ($action_post == "change_password") {
         $this->form_validation->set_rules('username', 'username', 'required');
         $this->form_validation->set_rules('password', 'password', 'required|min_length[3]|max_length[15]|matches[con_password]');
         if ($this->form_validation->run() == false) {
             $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
             $password = $this->ion_auth->hash_password($ajax_data->password, '');
             $new_data = array("identity" => $ajax_data->username, "password" => $password);
             $this->db->where("id", $id);
             $this->db->update("users", $new_data);
             echo json_encode($this->data['message']);
         } else {
             echo json_encode("Password Changes Successfully ");
         }
         echo json_encode("Password Changes Successfully ");
         exit;
     }
     if ($action_get == "forgot_password") {
         $this->form_validation->set_rules('email', $this->lang->line('forgot_password_validation_email_label'), 'required|valid_email');
         if ($this->form_validation->run() == false) {
             //setup the input
             $this->data['email'] = array('name' => 'email', 'id' => 'email');
             if ($this->config->item('identity', 'ion_auth') == 'username') {
                 $this->data['identity_label'] = $this->lang->line('forgot_password_username_identity_label');
             } else {
                 $this->data['identity_label'] = $this->lang->line('forgot_password_email_identity_label');
             }
             //set any errors and display the form
             $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
             $this->_render_page('security/forgot_password', $this->data);
         } else {
             // get identity from username or email
             if ($this->config->item('identity', 'ion_auth') == 'username') {
                 $identity = $this->ion_auth->where('username', strtolower($this->input->post('email')))->users()->row();
             } else {
                 $identity = $this->ion_auth->where('email', strtolower($this->input->post('email')))->users()->row();
             }
             if (empty($identity)) {
                 $this->ion_auth->set_message('forgot_password_email_not_found');
                 $this->session->set_flashdata('message', $this->ion_auth->messages());
                 redirect(SITE_LINK . "/security/login", 'refresh');
             }
             //run the forgotten password method to email an activation code to the user
             $forgotten = $this->ion_auth->forgotten_password($identity->{$this->config->item('identity', 'ion_auth')});
             if ($forgotten) {
                 //if there were no errors
                 $this->session->set_flashdata('message', $this->ion_auth->messages());
                 redirect(SITE_LINK . "/security/login", 'refresh');
                 //we should display a confirmation page here instead of the login page
             } else {
                 $this->session->set_flashdata('message', $this->ion_auth->errors());
                 redirect(SITE_LINK . "/security/forgot_password", 'refresh');
             }
         }
     }
     $data = array();
     $data["js_vars"] = json_encode(array('current_link' => SITE_LINK . "/" . $this->uri->segments[1], 'details' => SITE_LINK . "/" . "student/" . "details/", 'main_url' => SITE_LINK . "/" . "security/", 'stages' => $stages, 'levels' => $levels, 'hrw' => $hrw));
     $data['base_url'][] = SITE_LINK;
     $data['js'][] = "usage/user.js";
     $data['main_url'] = SITE_LINK;
     $data['stages'] = $stages;
     $data['levels'] = $levels;
     $data['groups'] = $groups;
     $data['hrw'] = $hrw;
     $data['first_title'] = "Home";
     $data['second_title'] = "Security";
     $data['third_title'] = "All Users";
     $data['use_big_model'] = "yes";
     $this->load->view('admin' . DIRECTORY_SEPARATOR . 'user', $data);
 }
Beispiel #4
0
 public function bus_absence()
 {
     $form_id = 6;
     $hrw = get_form_authority($this->session->userdata('group_id'), $form_id);
     if ($hrw == "h") {
         echo "      No privilege ...   . Contact System Administrator ";
         redirect(SITE_LINK . "/security/login", "refresh");
     }
     $action_get = $this->input->get("action");
     $date = $this->input->get("date");
     $p_bus = $this->input->get("bus");
     $action_post = $this->input->post("action");
     $ajax_data = json_decode($this->input->post("data"));
     if ($date) {
         $today = $date;
     } else {
         $today = date("d/m/Y");
     }
     $data = array();
     if (!$p_bus) {
         $this->db->select("*");
         $this->db->from("bus");
         $this->db->limit(1);
         $rr = $this->db->get();
         $r_bus = $rr->row();
         $bus = $r_bus->no;
     } else {
         $bus = $p_bus;
     }
     $buses = $this->mymodel_model->select("bus", "1=1");
     $absence = $this->mymodel_model->select("v_bus_absence", "bus_no='{$bus}' and  day='{$today}'");
     // right - selected
     $set_users = $this->mymodel_model->select("v_bus_students", "bus_no='{$bus}'");
     //left
     if ($action_post == "add") {
         $no = "";
         $message = "";
         $big_st_ids = array();
         foreach ($ajax_data->selection as $st) {
             $big_st_ids[] = array("day" => $ajax_data->date, "student_id" => $st, "bus" => $ajax_data->bus);
         }
         $this->db->trans_begin();
         $this->db->where("day", $ajax_data->date);
         $this->db->where("bus", $ajax_data->bus);
         $this->db->delete("bus_absence");
         // echo $this->db->last_query();
         if (!empty($big_st_ids)) {
             $this->db->insert_batch("bus_absence", $big_st_ids);
             if ($this->db->affected_rows() > 0) {
                 $no = $this->db->affected_rows();
                 $this->db->trans_commit();
                 $message = "success";
             } else {
                 $message = "failed  ";
                 $this->db->trans_rollback();
             }
         }
         //             echo $this->db->last_query();
         echo json_encode(array("message" => $message, "no" => $no));
         exit;
     }
     $data["js_vars"] = json_encode(array('current_link' => SITE_LINK . "/" . $this->uri->segments[1] . "/" . $this->uri->segments[2], 'controller_link' => SITE_LINK . "/" . $this->uri->segments[1], 'main_url' => SITE_LINK . "/" . "security/", 'set_users' => $set_users, 'p_date' => $today, 'absence' => $absence, 'hrw' => $hrw));
     $data['hrw'] = $hrw;
     $data['base_url'][] = SITE_LINK;
     $data['buses'][] = $buses;
     $data['absence'][] = $absence;
     $data['p_bus'][] = $bus;
     $data['set_users'][] = $set_users;
     $data['js'][] = "usage/bus_absence.js";
     $data['first_title'] = "Home";
     $data['second_title'] = "Bus";
     $data['third_title'] = "Bus Absence ";
     $this->load->view('admin' . DIRECTORY_SEPARATOR . 'bus_absence', $data);
 }
Beispiel #5
0
 public function distribute_teachers()
 {
     $form_id = 17;
     $data = array();
     $hrw = get_form_authority($this->session->userdata('group_id'), $form_id);
     if ($hrw == "h") {
         echo "        No privilege ...   . Contact System Administrator ";
         redirect(SITE_LINK . "/security/login", "refresh");
     }
     $action_get = $this->input->get("action");
     $action_post = $this->input->post("action");
     $classes = json_decode($this->input->post("classes"));
     $teacher = $this->input->post("teacher");
     $set_users = $this->mymodel_model->select("users", "groups not  in ('student','not_defined','parent','admin')");
     //$class_students=staff_absence
     if ($action_get == "load_classes") {
         $arr = array();
         $stage_level_class = array();
         $query = $this->db->query('select distinct stage as id , stage_name as text from v_stage_level_class');
         foreach ($query->result() as $row) {
             //  $arr['id']="";
             $arr['text'] = $row->text;
             $arr['children'] = $this->get_level_children($row->id);
             $stage_level_class[] = $arr;
             //    print_r($arr);
         }
         echo json_encode($stage_level_class);
         exit;
     }
     if ($action_post == "get_teacher_classes") {
         $g_classes = $this->mymodel_model->select("teacher_classes", "teacher_id=" . $teacher . " ");
         echo json_encode($g_classes);
         exit;
     }
     if ($action_post == "distribute") {
         $no = "";
         $message = "";
         $big_st_ids = array();
         $this->db->trans_begin();
         $this->db->where("teacher_id", $teacher);
         $this->db->delete("teacher_classes");
         foreach ($classes as $one) {
             if (array_key_exists("id", $one)) {
                 $big_st_ids[] = array("class_id" => $one->id, "teacher_id" => $teacher);
             }
         }
         if (!empty($big_st_ids)) {
             $this->db->insert_batch("teacher_classes", $big_st_ids);
             if ($this->db->affected_rows() > 0) {
                 $no = $this->db->affected_rows();
                 $message = "success";
                 $this->db->trans_commit();
             } else {
                 $message = "failed  ";
                 $this->db->trans_rollback();
             }
         }
         //  echo $this->db->last_query();
         echo json_encode(array("message" => $message, "no" => $no));
         exit;
     }
     $data["js_vars"] = json_encode(array('current_link' => SITE_LINK . "/" . $this->uri->segments[1] . "/" . $this->uri->segments[2], 'controller_link' => SITE_LINK . "/" . $this->uri->segments[1], 'details' => SITE_LINK . "/" . "student/" . "details/", 'main_url' => SITE_LINK . "/" . "security/", 'hrw' => $hrw));
     $data['hrw'] = $hrw;
     $data['set_users'][] = $set_users;
     $data['base_url'][] = SITE_LINK;
     $data['js'][] = "usage/teacher_distribution.js";
     $data['first_title'] = "Home";
     $data['second_title'] = "Teacher";
     $data['third_title'] = "Distribute Classes on Teachers  ";
     $this->load->view("admin/teacher_distribution", $data);
 }
Beispiel #6
0
 public function staff_absence()
 {
     $form_id = 16;
     $hrw = get_form_authority($this->session->userdata('group_id'), $form_id);
     if ($hrw == "h") {
         echo "       No privilege ...   . Contact System Administrator ";
         redirect(SITE_LINK . "/security/login", "refresh");
     }
     $action_get = $this->input->get("action");
     $date = $this->input->get("date");
     $action_post = $this->input->post("action");
     $ajax_data = json_decode($this->input->post("data"));
     if ($date) {
         $today = $date;
     } else {
         $today = date("d/m/Y");
     }
     $data = array();
     $set_users = $this->mymodel_model->select("users", "groups not  in ('student','not_defined','parent')");
     //$class_students=staff_absence
     $absence = $this->mymodel_model->select("v_user_absence", "groups not in ('student','not_defined','parent') and   day='{$today}' ");
     if ($action_post == "add") {
         // take absence
         $no = "";
         $message = "";
         $big_st_ids = array();
         $this->db->trans_begin();
         foreach ($ajax_data->selection as $st) {
             $big_st_ids[] = array("day" => $ajax_data->date, "user_id" => $st);
         }
         $this->db->where("day", $ajax_data->date);
         $this->db->delete("absence");
         if (!empty($big_st_ids)) {
             $this->db->insert_batch("absence", $big_st_ids);
             if ($this->db->affected_rows() > 0) {
                 $no = $this->db->affected_rows();
                 $message = "success";
                 $this->db->trans_commit();
             } else {
                 $message = "failed  ";
                 $this->db->trans_rollback();
             }
         }
         echo json_encode(array("message" => $message, "no" => $no));
         exit;
     }
     $data["js_vars"] = json_encode(array('current_link' => SITE_LINK . "/" . $this->uri->segments[1] . "/" . $this->uri->segments[2], 'controller_link' => SITE_LINK . "/" . $this->uri->segments[1], 'details' => SITE_LINK . "/" . "student/" . "details/", 'main_url' => SITE_LINK . "/" . "security/", 'set_users' => $set_users, 'absence' => $absence, 'p_date' => $today, 'hrw' => $hrw));
     $data['hrw'] = $hrw;
     $data['base_url'][] = SITE_LINK;
     $data['absence'][] = $absence;
     $data['set_users'][] = $set_users;
     $data['js'][] = "usage/staff_absence.js";
     $data['first_title'] = "Home";
     $data['second_title'] = "Absence";
     $data['third_title'] = "Staff Absence  ";
     $this->load->view('admin' . DIRECTORY_SEPARATOR . 'staff_absence', $data);
 }