| 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/git/sms.edl.codes.solutions/application/controllers/BO/ |
Upload File : |
<?php
/*********************
*********************
Indian Controller : "Parent_old_old.php"
Indian Template : "parent_old.php"
controller fix 23 april 2019
Aernout Guillaume
http://Codes.Solutions
*********************
*********************/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Parents extends NS_Controller {
//$session = "";
function __construct() {
parent::__construct(array('no_cache'=>1));
$this->load->helper('generator');
$this->load->model('users_model');
$this->load->model('profile_model');
$this->load->model('address_model');
$this->load->database();
}
////////////////////////
// Fonction controller
////////////////////////
function index() {
$this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
$data['page_name'] = 'parent';
$data['language'] = $this->profile_model->language();
$data['page_title'] = get_phrase('parent');
$data['parent_list'] = $this->crud_model->get_parent_list();
$this->load->view('backend/index', $data);
}
function getParent(){
$this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
$id = $this->input->post('id');
$parent = $this->crud_model->get_parent_info($id);
$user = $this->crud_model->get_user_info($id);
$address = $this->crud_model->get_user_address($parent[0]['residential_address_id']);
$jsonData = "{ \"user_id\":\"".$id."\",\"address_id\":\"".$parent[0]['residential_address_id']."\",\"email\" :\"".$user[0]['email']."\",\"lang\" :\"".$user[0]['lang']."\",\"firstName\" :\"".$user[0]['first_name']."\",\"lastName\" :\"".$user[0]['last_name']."\",\"phone\" :\"".$user[0]['phone']."\"";
$jsonData = $jsonData .",\"comment\" : \"".preg_replace('/\R/', '', $parent[0]['admin_comment'])."\",\"ispaid\" : \"".$parent[0]['is_paid']."\",\"dob\" : \"".$parent[0]['dob']."\"";
$jsonData = $jsonData .",\"line1\" : \"".$address[0]['line_1']."\",\"line2\" : \"".$address[0]['line_2']."\",\"state\" : \"".$address[0]['state']."\",\"location\" : \"".$address[0]['location']."\",\"postcode\" : \"".$address[0]['postcode']."\",\"country\" : \"".$address[0]['country']."\"}";
echo $jsonData;
}
function save(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post(array('email','pass','name1','name2','pic','phone','dob','line_1','line_2','country','state','location','postcode','comment','lang'));
$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_pass($data['pass']) != true || ($data['pass'] == null || $data['pass'] == "" )){ array_push($error,"Password should be at least 6 characters in length and should include at least one upper case letter, one number, and one special character");}
if($this->users_model->check_name($data['name1']) != true || ($data['name1'] == null || $data['name1'] == "" )){ array_push($error,"Please enter a correct name");}
if($this->users_model->check_name($data['name2']) != true || ($data['name2'] == null || $data['name2'] == "" )){ array_push($error,"Please enter a correct name");}
if($this->users_model->check_phone($data['phone']) != true || ($data['phone'] == null || $data['phone'] == "" )){ array_push($error,"Please enter a correct phone number");}
$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");}
//if($this->users_model->check_address($data['line_1'],$data['line_2'],$data['country'],$data['state'],$data['postcode']) != true){array_push($error,"Please enter a correct address");}
//var_dump($data['line_1'].$data['line_2'].$data['country'].$data['state'].$data['postcode']);
$error = array_filter($error);
if (empty($error)){
//create user and get the user_id
$userId = $this->users_model->create_user($data['email'],$data['pass'],$data['name1'],$data['name2'],$data['phone'],'3',$data['lang']);
$addressId = $this->users_model->create_user_address($data['line_1'],$data['line_2'],$data['country'],$data['state'],$data['location'],$data['postcode']);
$this->users_model->create_parent($userId,$addressId,$data['comment'],$dob);
//var_dump($userId);
echo "1";
}
else{
var_dump($error);
}
}
function edit(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post(array('user_id','address_id','email','pass','name1','name2','pic','phone','dob','line_1','line_2','country','state','location','postcode','comment','statut','lang'));
$error = array();
if($data['user_id'] == null || $data['user_id'] == "" ){ array_push($error,"Error on processing : no id");}
if($data['address_id'] == null || $data['address_id'] == "" ){ array_push($error,"Error on processing : no address id");}
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_pass($data['pass']) != true || ($data['pass'] == null || $data['pass'] == "" )){ array_push($error,"Password should be at least 6 characters in length and should include at least one upper case letter, one number, and one special character");}
if($this->users_model->check_name($data['name1']) != true || ($data['name1'] == null || $data['name1'] == "" )){ array_push($error,"Please enter a correct name");}
if($this->users_model->check_name($data['name2']) != true || ($data['name2'] == null || $data['name2'] == "" )){ array_push($error,"Please enter a correct name");}
if($this->users_model->check_phone($data['phone']) != true || ($data['phone'] == null || $data['phone'] == "" )){ array_push($error,"Please enter a correct phone number");}
$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");}
//if($this->users_model->check_address($data['line_1'],$data['line_2'],$data['country'],$data['state'],$data['postcode']) != true){array_push($error,"Please enter a correct address");}
//var_dump($data['line_1'].$data['line_2'].$data['country'].$data['state'].$data['postcode']);
$error = array_filter($error);
if (empty($error)){
//update user + parent + address
if(!$this->users_model->update_user($data['user_id'],$data['email'],$data['pass'],$data['name1'],$data['name2'],$data['phone'],$data['lang'])){
echo "email already exit or sql crash";
return false;
}
$this->users_model->update_user_address($data['address_id'],$data['line_1'],$data['line_2'],$data['country'],$data['state'],$data['location'],$data['postcode']);
$this->users_model->update_parent($data['user_id'],$data['comment'],$dob);
//var_dump($userId);
echo "1";
}
else{
var_dump($error);
}
}
function delete(){
$this->continueIfAllowed(array('allowed'=>array('admin')));
$data = $this->input->post(array('userId','addressId'));
if(isset($data['userId']) && isset($data['addressId'])){
$this->db->delete('parent',array('parent_id' => $data['userId']));
$this->db->delete('user',array('user_id' => $data['userId']));
$this->db->delete('address',array('address_id' => $data['addressId']));
echo "1";
}
}
}