Files
CHIEFSOFT\ameye 0b6bc3019e amount fix
2024-07-04 11:01:49 -04:00

316 lines
14 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Confg extends Bko_Controller {
public function siteitems() {
$data["title"] = "Withdraws Report";
$mysql = "SELECT m.added::date AS date,m.terminatingamount*0.01 AS amount,m.fee*0.01 as fee, "
. "mm.firstname||' '||mm.lastname||'<br>Email:'||mm.email AS Sender,"
. "r.firstname||' '||r.lastname||'<br><b>Acc:</b>'||r.account_no||'-'||b.name AS Recitient,mp.confirmation,"
. "CASE WHEN m.status=1 THEN 'Pending' WHEN m.status=3 THEN 'Cancelled' WHEN m.status=5 THEN 'Completed' ELSE '' END AS Status "
. "FROM money_transfer m "
. "LEFT JOIN sendmoney_recipient r ON r.id = m.recipientid "
. " LEFT JOIN members mm ON mm.id = m.member_id "
. "LEFT JOIN bank_entity_codes b ON b.code = r.bank_code "
. "LEFT JOIN members_payments mp ON mp.what_sendmoney = m.id "
. "WHERE mp.confirmation IS NOT NULL ORDER BY m.id DESC LIMIT 4000";
// $query = $this->db->query($mysql);
// $this->table->set_heading('Date', 'Amount', 'Fee', 'Recipient', 'Confirmation', 'Status')
//$this->table->set_heading('Date', 'Amount','Fee','Recipient','Confirmation', 'Status');
// $data['mysql'] = $mysql;
// $this->renderbkoreportpage($data);
$data = array();
$data['page_title'] = "Configurations";
$this->renderAdminPage('configure/view_bko_configure', $data);
}
public function selpage() {
$data = array();
$data['page_id'] = trim($this->input->get('page_id'));
if ($data['page_id'] != '') {
switch ($data['page_id']) {
case 'APPHELP':
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT id ,uid ,icon ,title ,contents FROM help_items WHERE status = 1 ORDER BY id ASC"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
$data['faq_result'] = $query->result();
$data['faq_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/appfaq_form', $data);
break;
case "JOBCATEG":
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT * FROM skill_category ORDER BY category ASC";
$query = $this->db->query($mysql);
// $this->table->set_heading(array('data' => 'Key', 'style' => 'width:60px'), 'Reason', array('data' => 'Action', 'style' => 'width:100px'));
$data['skill_category_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/jobcaregory_form', $data);
break;
case "JOBSKILLTYPE":
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT * FROM skill_category ORDER BY category ASC"; // temporary
$query = $this->db->query($mysql);
$data['skill_category_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/jobskill_form', $data);
break;
case "AREASON":
case "MREASON":
$mysql = "SELECT * FROM reason_type WHERE rkey='" . $data['page_id'] . "'";
$q = $this->db->query($mysql);
$row = $q->row();
if (isset($row)) {
$data['reason_name'] = $row->rname;
$data['reason_key'] = $row->rkey;
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT lkey,name,'<button onclick=\"deleteReason('||id||'.'||lkey||');\">Del</button>' FROM reason_items WHERE rkey='" . $data['page_id'] . "'"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
$this->table->set_heading(array('data' => 'Key', 'style' => 'width:60px'), 'Reason', array('data' => 'Action', 'style' => 'width:100px'));
$data['reason_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/reason_form', $data);
}
break;
case "LANGUAGE":
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT * FROM languages ORDER BY language ASC"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
// $this->table->set_heading(array('data' => 'Key', 'style' => 'width:60px'), 'Reason', array('data' => 'Action', 'style' => 'width:100px'));
$data['language_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/language_form', $data);
break;
case "COUNTRY":
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT id,code,country,phone_code,
(CASE WHEN
allow IS NULL
THEN '<div id=\"allow-'||code||'\" ><button onclick=\"allowStatus('''||code||''',1);\" type=\"button\" class=\"btn btn-danger\">Enable</button></div>'
ELSE
'<a id=\"allow-'||code||'\" ><button onclick=\"allowStatus('''||code||''',0);\" >'||allow::date::text||'</a>'
END)
AS Allow,
'<a href=\"#\" >'|| jobs::date||'</a>' AS Jobs,
status
FROM country
ORDER BY allow, jobs, status,country ASC"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
// $this->table->set_heading(array('data' => 'Key', 'style' => 'width:60px'), 'Reason', array('data' => 'Action', 'style' => 'width:100px'));
$data['country_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/country_form', $data);
break;
case "UTRANSPRICE":
$data["form_title"] = "User Transport Pricing";
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT * FROM country ORDER BY country ASC"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
// $this->table->set_heading(array('data' => 'Key', 'style' => 'width:60px'), 'Reason', array('data' => 'Action', 'style' => 'width:100px'));
$data['country_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/pricing_form', $data);
break;
case "ULATORPRICE":
$data["form_title"] = "User Translator Pricing";
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT * FROM country ORDER BY country ASC"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
// $this->table->set_heading(array('data' => 'Key', 'style' => 'width:60px'), 'Reason', array('data' => 'Action', 'style' => 'width:100px'));
$data['country_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/pricing_form', $data);
break;
case "FAQSET":
$mysql2 = " SELECT code,description FROM faq_category";
$query2 = $this->db->query($mysql2);
$data['faq_category'] = $query2->result();
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT id,title,dir,msg,flags,added,status,code FROM faq ORDER BY id desc"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
$data['faq_result'] = $query->result();
$data['faq_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/faq_form', $data);
break;
case "CRONJOBS":
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT * FROM cron_jobs ORDER BY updated desc"; // WHERE agent_id = " . $data['agent_id'];
$query = $this->db->query($mysql);
$data['cron_jobs_result'] = $query->result();
$data['cron_jobs_table'] = $this->table->generate($query);
$this->load->view('bko/configure/extra/cron_jobs', $data);
break;
case "GENCOUPONS":
$this->load->view('bko/configure/extra/gen_coupons', $data);
break;
default:
echo "Your favorite color is neither red, blue, nor green!";
}
}
}
//define('WRENCHBOARD_COUPON_CREATE', 85010);
public function addCoupons(){
echo 'Ameye....';
if ($_GET) {
$amount = $this->input->get('amount');
$quantity = trim($this->input->get('quantity'));
if($amount !='' & $quantity !='' & $quantity > 0 ){
$this->load->model('backend_model');
$data['action'] = WRENCHBOARD_COUPON_CREATE;
$out = array();
$result ='';
for ($i = 1; $i <= $quantity; $i++) {
$data['amount'] = $amount*100;
$data['code'] = strtoupper( $this->getCouponsCode(10) );
$data['description'] = "Back Office Coupons Gen";
$res = $this->backend_model->wrenchboard_api($data, $out);
$result .= $data['code']." - ".$res." \n";
}
echo $result;
}
else{
echo 'Not Generated';
}
}
}
private function getCouponsCode($n) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $n; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
return $randomString;
}
public function allowCountry(){
if ($_GET) {
$countyry_code = trim( $this->input->get('countyry_code') );
$action = trim($this->input->get('action'));
//echo "ameye-ameye 22 - ".$countyry_code;
if($countyry_code !='' & $action !='' & $action == 1 ){
$sql1 = "UPDATE country SET allow=now(), status = 1 WHERE code= '$countyry_code' ";
$this->db->query($sql1);
echo 'Updated';
}
// else{
// echo 'Not Updated';
// }
if($countyry_code !='' & $action !='' & $action == 0 ){
$sql1 = "UPDATE country SET allow=NULL,status = 0 WHERE code= '$countyry_code' ";
$this->db->query($sql1);
echo 'Disabled';
}
// else{
// echo 'Not Updated';
// }
}
}
public function updateHelpfaq(){
if ($_GET) {
$faq_id = $this->input->get('faq_id');
$title = trim($this->input->get('title'));
$faq_uid = trim($this->input->get('faq_uid'));
$msg = trim($this->input->get('msg'));
if($title !='' & $msg !='' & $faq_id > 0 ){
$sql1 = "UPDATE help_items SET title='$title',contents='$msg' WHERE id = $faq_id AND uid='$faq_uid' ";
$this->db->query($sql1);
echo 'Updated';
}
else{
echo 'Not Updated';
}
}
}
public function updatefaq(){
// url: "/confg/updatefaq?faq_id=" + page_id + "&title=" + title + "&code=" + code + "&msg=" + msg
if ($_GET) {
$faq_id = $this->input->get('faq_id');
$title = trim($this->input->get('title'));
$code = trim($this->input->get('code'));
$msg = trim($this->input->get('msg'));
if($title !='' & $msg !='' & $faq_id > 0 ){
$sql1 = "UPDATE faq SET title='$title',msg='$msg', code='$code' WHERE id = $faq_id";
$this->db->query($sql1);
echo 'Updated';
}
else{
echo 'Not Updated';
}
}
}
public function addSkill() {
$data = array();
$data['rkey'] = trim($this->input->get('page_id'));
$data['skill_name'] = trim($this->input->get('skill_name'));
$mysql = "SELECT * FROM skill_category WHERE LOWER(category) = LOWER('" . $data['skill_name'] . "')";
$q = $this->db->query($mysql);
$nr = $q->num_rows();
if ($nr > 0) {
echo 'Duplicate Detected';
} else {
// echo 'Now Insert';
$mysql = "INSERT INTO skill_category (category) VALUES('" . $data['skill_name'] . "')";
$q = $this->db->query($mysql);
}
echo '0';
}
private function renderAdminPage($page_name, $data) {
$this->load->view('bko/view_bko_header', $data);
$this->load->view('bko/' . $page_name, $data);
$this->load->view('bko/view_bko_footer', $data);
}
}