| Server IP : 188.114.97.2 / Your IP : 104.23.197.231 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/controllers/BO/ |
Upload File : |
<?php
/*********************
*********************
Template : "forms_student.php"
FrontEnd : "hello_student.php"
Controller : "Forms_student.php"
Creation 25/07/2019
Aernout Guillaume
https://codes.solutions
*********************
*********************/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Form_student extends NS_Controller {
function __construct() {
parent::__construct(array('no_cache'=>1));
if ($this->session->userdata('admin_login') != 1){
$this->error('restricted admin');
//$this->redirect(base_url(), 'refresh');
}
$this->load->helper('generator');
$this->load->model('form_model');
$this->load->model('email_model');
$this->load->model('users_model');
$this->load->model('profile_model');
$this->load->model('address_model');
$this->load->model('security_model');
$this->load->database();
}
function index(){
$data['page_name'] = 'form_student';
$data['page_title'] = get_phrase('form_student');
$data['candidate_list'] = $this->form_model->get_candidate_s();
$data['candidate_pending'] = $this->form_model->get_pending_s();
$this->load->view('backend/index', $data);
}
//
////////////////////////
// Info
////////////////////////
//
function candidateData(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$id = $this->input->post('id');
//$this->db->order_by('LessonDate', 'DESC');
$query = $this->db->get_where('candidate_student', array('id' => $id));
$res = $query->result_array();
echo json_encode($res);
}
//
////////////////////////
// Action
////////////////////////
//
function convertCandidate(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post(array('id','targ_lan','spo','wri','und','rea','remark','s_email','s_name','s_surname','s_phone','s_dob','p_email','p_name','p_surname','p_phone','p_dob','add1','add2','pc','country','location','send_param'));
$error = array();
if($this->users_model->check_email_format($data['s_email']) != TRUE || ($data['s_email'] == null || $data['s_email'] == "" )){ array_push($error,"Please enter a valid student email");}
if($this->users_model->email_exist($data['s_email']) == true){ array_push($error,"student email already exist");}
if($this->users_model->check_name($data['s_name']) != true || ($data['s_name'] == null || $data['s_name'] == "" )){ array_push($error,"Please enter a correct student name");}
if($this->users_model->check_name($data['s_surname']) != true || ($data['s_surname'] == null || $data['s_surname'] == "" )){ array_push($error,"Please enter a correct student surname");}
if($this->users_model->check_phone($data['s_phone']) != true && ($data['s_phone'] != null || $data['s_phone'] != "" )){ array_push($error,"Please enter a correct student phone number");}//|| ($data['phone'] == null || $data['phone'] == "" ))
$dob = str_replace('/', '-', $data['s_dob']);
$dob = date('Y-m-d', strtotime($dob));
if($this->users_model->check_dob($dob) != true && ($data['s_dob'] != null || $data['s_dob'] != "" )){ array_push($error,"Please enter a correct student date of birth");}
//var_dump($data['p_name']);
if($data['p_name']!= ""){
if($this->users_model->check_email_format($data['p_email']) != TRUE || ($data['p_email'] == null || $data['p_email'] == "" )){ array_push($error,"Please enter a valid parent email");}
if($this->users_model->email_exist($data['p_email']) == true){ array_push($error,"parent email already exist");}
if($this->users_model->check_name($data['p_name']) != true || ($data['p_name'] == null || $data['p_name'] == "" )){ array_push($error,"Please enter a correct parent name");}
if($this->users_model->check_name($data['p_surname']) != true || ($data['p_surname'] == null || $data['p_surname'] == "" )){ array_push($error,"Please enter a correct parent surname");}
if($this->users_model->check_phone($data['p_phone']) != true && ($data['p_phone'] != null || $data['p_phone'] != "" )){ array_push($error,"Please enter a correct parent phone number");}//|| ($data['phone'] == null || $data['phone'] == "" ))
}
$error = array_filter($error);
if (empty($error)){
$lang = $this->form_model->match_lang($data['current']);
//create first parent if exist
if(data['p_name']!= null){
$pass1 = $this->security_model->randomPass();
$parentId = $this->users_model->create_user($data['p_email'],$pass1,$data['p_name'],$data['p_surname'],$data['p_phone'],'3',$lang);
$parentAddressId = $this->users_model->create_user_address($data['add1'],$data['add2'],$data['country'],'',$data['location'],$data['pc']);
$this->users_model->create_parent($parentId,$parentAddressId,$data['remark'],$data['p_dob']);
if($data['send_param'] == true && $parentId > "0" && ($data['p_email'] != $data['s_email'])){
$name = $data['p_name']." ". $data['p_surname'];
$isoLang = $this->profile_model->intToIso($lang);
$this->email_model->account_opening_email($isoLang,"parent",$name,$data['p_email'],$pass1,$parentId);
}
}
$pass2 = $this->security_model->randomPass();
$userId = $this->users_model->create_user($data['s_email'],$pass,$data['s_name'],$data['s_surname'],$data['s_phone'],'4',$lang);
$addressId = $this->users_model->create_user_address($data['add1'],$data['add2'],$data['country'],'',$data['location'],$data['pc']);
$this->users_model->create_student($userId,$addressId,$data['remark'],$dob,$parentId);
if($data['send_param'] == true && $userId > "0"){
$name = $data['s_name']." ". $data['s_surname'];
$isoLang = $this->profile_model->intToIso($lang);
$this->email_model->account_opening_email($isoLang,"student",$name,$data['s_email'],$pass2,$userId);
}
$this->db->set(array('status'=>'1','student_id'=>$userId));
$this->db->where('id',$data['id']);
$this->db->update('candidate_student');
echo "1";
}
else{
var_dump($error);
}
}
//
function editData(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post(array('id','targ_lan','native','current','spo','wri','und','rea','remark','s_email','s_name','s_surname','s_phone','s_dob','p_email','p_name','p_surname','p_phone','p_dob','add1','add2','pc','counrty','location'));
$sql = array(
learn_lng_id => $data['targ_lan'],
native_lng => $data['native'],
spoken_lng => $data['current'],
spoken => $data['spo'],
written => $data['wri'],
understand => $data['und'],
reading => $data['rea'],
remark => $data['remark'],
name => $data['s_name'],
surname => $data['s_surname'],
email => $data['s_email'],
phone => $data['s_phone'],
birthdate => $data['s_dob'],
parent_name => $data['p_name'],
parent_surname => $data['p_surname'],
parent_email => $data['p_email'],
parent_phone => $data['p_phone'],
);
$this->db->set($sql);
$this->db->where('id',$data['id']);
if($this->db->update('candidate_student')){
echo "1";
}else {
echo "-1";
}
}
//
function removeData(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$id = $this->input->post('id');
$this->db->where('id', $id);
if($this->db->delete('candidate_student')){
echo "1";
}else{
echo "-1";
}
}
}
?>