| Server IP : 188.114.97.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
/*********************
*********************
Payment Model
Creation 16 october 2019
Aernout Guillaume
http://Codes.Solutions
*********************
*********************/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Payment_model extends CI_Model {
function __construct() {
parent::__construct(array('no_cache'=>1));
//$this->_ci =& get_instance();
$this->load->model('crud_model');
$this->load->database();
}
function payment_request($user,$amount,$comment){
$sql = array(
'Student_ID' => $user,
'Payment_amount' => $amount,
'Method_ID' => '3',
'Status' => '2',
'Date' => date("Y-m-d"),
'Comment' => $comment
);
$this->db->insert('wallet',$sql);
$id = $this->db->insert_id();
return array( "id" => $id, "request" => $this->hash_request($id,$user,$amount,$date));
//echo $data['date'];
}
function get_payment($id){
$query = $this->db->get_where('wallet',array('ID'=>$id));
$data = $query->result_array();
foreach ($data as $row) {
return $row;
}
}
function update_payment($id){
$this->db->set('Status','1');
$this->db->where('ID',$id);
$this->db->update('wallet');
$this->db->set('Status','1');
$this->db->where('Wallet_ID',$id);
$this->db->update('invoices');
}
function hash_request($id,$user,$amount,$date){
$toHash = "$id-$date@$user#$amount";
return md5($toHash);
}
function detect_society($studentId){
$courses = $this->crud_model->get_students_course($studentId);
foreach ($courses as $course) {
$data = $this->crud_model->get_course_info($course);
//return $data;
if($data[0]['CourseSociety'] == "0" || $data[0]['CourseSociety'] ==""){
return "1";
}
else{
return $data[0]['CourseSociety'];
}
}
return "1";
}
function detect_course($studentId){
$courses = $this->crud_model->get_students_course($studentId);
foreach ($courses as $course) {
$data = $this->crud_model->get_course_info($course);
//return $data;
return $data[0]['CourseName'];
}
}
function check_hash($id,$hash){
$query = $this->db->get_where('wallet',array('ID'=>$id));
$data = $query->result_array();
foreach ($data as $row) {
$original_data = $row['ID']."-".$row['Date']."@".$row['Student_ID']."#".$row['Payment_amount'];
//return $original_data;
$original_hash = md5($original_data);
//return $original_hash;
if($original_hash == $hash){
return true;
}
else{
return false;
}
}
}
}
?>