| Server IP : 188.114.96.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/nicolasj/www/sms.formationlangues.be/application/controllers/BO/ |
Upload File : |
<?php
/*********************
*********************
Template : "forms_teacher.php"
FrontEnd : "hello_teacher.php"
Controller : "Forms_teacher.php"
Creation 25/07/2019
Aernout Guillaume
https://codes.solutions
*********************
*********************/
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Form_teacher extends NS_Controller
{
public 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();
}
public function index()
{
$data['page_name'] = 'form_teacher';
$data['page_title'] = get_phrase('form_teacher');
$data['candidate_list'] = $this->form_model->get_candidate_t();
$data['candidate_pending'] = $this->form_model->get_pending_t();
$this->load->view('backend/index', $data);
}
//
////////////////////////
// Info
////////////////////////
//
public 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_teacher', array('id' => $id));
$res = $query->result_array();
echo json_encode($res);
}
//
////////////////////////
// Action
////////////////////////
//
public function convertCandidate()
{
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post(array('id','targ_lan','bio','email','name','surname','phone','dob','current','add1','add2','pc','country','location','send_param'));
$error = array();
if($this->users_model->check_email_format($data['email']) != true || ($data['email'] == null || $data['email'] == "")) {
array_push($error, "Please enter a valid email");
}
if($this->users_model->email_exist($data['email']) == true) {
array_push($error, "email already exist");
}
if($this->users_model->check_name($data['name']) != true || ($data['name'] == null || $data['name'] == "")) {
array_push($error, "Please enter a correct name");
}
if($this->users_model->check_name($data['surname']) != true || ($data['surname'] == null || $data['surname'] == "")) {
array_push($error, "Please enter a correct firstname");
}
if($this->users_model->check_phone($data['phone']) != true && ($data['phone'] != null || $data['phone'] != "")) {
array_push($error, "Please enter a correct phone number");
}//|| ($data['phone'] == null || $data['phone'] == "" ))
$dob = str_replace('/', '-', $data['dob']);
$dob = date('Y-m-d', strtotime($dob));
if($this->users_model->check_dob($dob) != true && ($data['dob'] != null || $data['dob'] != "")) {
array_push($error, "Please enter a correct date of birth");
}
$error = array_filter($error);
//var_dump($data);
if (empty($error)) {
//create first parent if exist
$pass = $this->security_model->randomPass();
$lang = $this->form_model->match_lang($data['current']);
$userId = $this->users_model->create_user($data['email'], $pass, $data['name'], $data['surname'], $data['phone'], '4', $lang);
$addressId = $this->users_model->create_user_address($data['add1'], $data['add2'], $data['country'], '', $data['location'], $data['pc']);
$this->users_model->create_teacher($userId, $addressId, $data['bio'], $dob, '');
//var_dump($userId);
//echo $lang."=>".$userID."=>".$data['send_param']."/";
if($data['send_param'] == true && $userId > "0") {
//echo "sent";
$name = $data['name']." ". $data['surname'];
$isoLang = $this->profile_model->intToIso($lang);
$this->email_model->account_opening_email($isoLang, "teacher", $name, $data['email'], $pass, $userId);
}
$this->db->set(array('status'=>'1','teacher_id'=>$userId));
$this->db->where('id', $data['id']);
$this->db->update('candidate_teacher');
echo "1";
} else {
var_dump($error);
}
}
//
public function editData()
{
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post([
'id','targ_lan','bio','email','name','surname','phone',
'dob','native','current','add1','add2',
'pc','country','location'
]);
$sql = array(
'teach_lng_id' => $data['targ_lan'],
'bio' => $data['bio'],
'name' => $data['name'],
'surname' => $data['surname'],
'email' => $data['email'],
'phone' => $data['phone'],
'birthdate' => $data['dob'],
'native_lng' => $data['native'],
'spoken_lng' => $data['current'],
'addressline1' => $data['add1'],
'addressline2' => $data['add2'],
'cp' => $data['pc'],
'country' =>$data['country'],
'location' => $data['location'],
);
$this->db->set($sql);
$this->db->where('id', $data['id']);
if($this->db->update('candidate_teacher')) {
echo "1";
} else {
echo "-1";
}
}
//
public function removeData()
{
$this->continueIfAllowed(array('allowed'=>array('admin')));
$id = $this->input->post('id');
$this->db->where('id', $id);
if($this->db->delete('candidate_teacher')) {
echo "1";
} else {
echo "-1";
}
}
}