<?php 
defined('BASEPATH') OR exit('No direct script access allowed');

class Call extends CI_Controller {

    public function index()
    {
        $object = array(
            'text'  =>  'call api'
        );
        $this->db->insert('test', $object);
        $success = $this->input->get('success');
        $t = $this->input->get('t');
        $t2 =  $this->input->get('t2');
        $ref = $this->input->get('ref');
        $amount =  $this->input->get('amount');

        if($t == '441ab949bbaa34b4db53ab80f3b647b4' && $t2 == '4216e2')
        {
            if($success == 1)
            {
                $object = array(
                    'id_users'  =>  $ref,
                    'amount'    =>  $amount,
                    'by'        =>  'ธนาคารกสิกร',
                );
                $this->db->insert('logrefill', $object);
                $this->db->query("UPDATE users SET credit = credit +'$amount' WHERE id_users = $ref");
            }else{
                $object = array(
                    'text'  =>  't:'.$t.'|t2:'.$t2.'|status'.$success
                );
                $this->db->insert('test', $object);
            }
        }else{
            $object = array(
                'text'  =>  't:'.$t.'|t2:'.$t2.'|status'.$success
            );
            $this->db->insert('test', $object);
            
        }
    }

}

/* End of file Call.php */
