Example #1
0
 public function forgotPass_exec($data)
 {
     $response_array = array();
     $email = $data['email'];
     //        CHECK EMAIL IN SYSTEM
     $emailExist = user::checkExist("user_accounts", "email = '{$email}'");
     if (!$emailExist) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><strong>{$email}</strong> is not registered email.</div>";
     } else {
         //            CHECK ACCOUNT STATUS
         $userdata = $this->db->select("user_accounts", "*", "email = '{$email}'", "fetch");
         $activate = $userdata['activate'];
         if ($activate == 0) {
             $response_array['r'] = "false";
             $response_array['msg'] = "<div><strong>{$email}</strong> is not activate. Please request your activation link (if you don't receive activation email) by clicking '<b>Don't receive activation email? Click here.</b>' link below. </div>";
         } else {
             //            RESET PASSWORD
             //            SEND PASSWORD TO AGENT
             $response_array['r'] = "true";
             $response_array['msg'] = "{$userdata}";
         }
     }
     return $response_array;
 }
Example #2
0
 public static function loginAuth($from)
 {
     //check token remember me
     //check session
     $db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS);
     if (cookie::exists(TOKEN_NAME)) {
         $token = cookie::get(TOKEN_NAME);
         $checkExist = user::checkExist("users_session", "token = '{$token}'");
         if ($checkExist) {
             $sessionData = $db->select("users_session", "*", "token = '{$token}'", "fetch");
             $agent_id = $sessionData['agent_id'];
             user::login($agent_id);
             $userData = $db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch");
             if ($from == 'login') {
                 self::accountCheck($userData);
                 redirect::to("dashboard");
             } else {
                 self::accountCheck($userData);
             }
         } else {
             user::logout();
         }
     } elseif (session::exist(AGENT_LOGIN_SESSION) && session::exist(AGENT_SESSION_NAME)) {
         $agent_id = session::get(AGENT_SESSION_NAME);
         $check_agentExist = user::checkExist("user_accounts", "agent_id = '{$agent_id}'");
         $userData = $db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch");
         if (!$check_agentExist) {
             user::logout();
         }
         user::login($agent_id);
         if ($from == 'login') {
             self::accountCheck($userData);
             redirect::to("dashboard");
         } else {
             self::accountCheck($userData);
         }
     } else {
         if ($from != 'login') {
             user::logout();
         }
     }
 }
Example #3
0
 function success($agent_id = NULL)
 {
     $this->breadcrumb->add("Successful", "join/success");
     $this->view->breadcrumbs = $this->breadcrumb->get();
     if (isset($agent_id)) {
         $verify = user::checkExist("user_accounts", "agent_id = '{$agent_id}'");
         if (!$verify) {
             redirect::to();
             exit;
         } else {
             $data = user::getUserData("agent_id", $agent_id);
             $this->view->userdata = $data;
             $this->view->js = array('join/js/success.js');
             $this->view->render('join/success');
         }
     } else {
         redirect::to();
         exit;
     }
 }
Example #4
0
 public function s($sponsor)
 {
     $userData = user::checkExist("user_accounts", "agent_id = '{$sponsor}' or username = '******'");
     if ($userData == 1) {
         $getUserData = $this->db->select("user_accounts", "agent_id, username", "agent_id = '{$sponsor}' or username = '******'", "fetch");
         $chkCookie = cookie::exists(COOKIE_SPONSOR_NAME);
         if ($chkCookie) {
             $cookieName = cookie::get(COOKIE_SPONSOR_NAME);
             if ($cookieName != $getUserData['agent_id']) {
                 cookie::delete(COOKIE_SPONSOR_NAME);
                 cookie::set(COOKIE_SPONSOR_NAME, $getUserData['agent_id'], COOKIE_EXPIRY);
             }
         } else {
             cookie::set(COOKIE_SPONSOR_NAME, $getUserData['agent_id'], COOKIE_EXPIRY);
         }
     } else {
         cookie::delete(COOKIE_SPONSOR_NAME);
     }
     redirect::to(BASE_PATH, TRUE);
 }
Example #5
0
 function success($supplier_username = NULL)
 {
     $this->breadcrumb->add("Registration", "supp/register");
     $this->breadcrumb->add("Successful", "supp/success");
     $this->view->breadcrumbs = $this->breadcrumb->get();
     if (isset($supplier_username)) {
         $verify = user::checkExist("supplier", "username = '******'");
         if (!$verify) {
             redirect::to();
             exit;
         } else {
             $data = user::getSupplierData("username", $supplier_username);
             $this->view->userdata = $data;
             $this->view->js = array('supp/js/success.js');
             $this->view->render('supp/success');
         }
     } else {
         redirect::to();
         exit;
     }
 }
Example #6
0
 function __construct()
 {
     session::init();
     $this->breadcrumb = new breadcrumb();
     $this->view = new view();
     $this->_userProfileImages = IMAGES_PATH . "user-default.png";
     if (session::exist(AGENT_SESSION_NAME) and session::exist(AGENT_LOGIN_SESSION)) {
         $agent_id = session::get(AGENT_SESSION_NAME);
         $userData = new user();
         //            USERDATA
         $this->_userData = $userData->getUserData('agent_id', $agent_id);
         $user = $this->_userData;
         //            USER ACC. TYPE
         $userAccType = user::getAccType($user['acc_type']);
         $this->_userAccType = $userAccType['label'];
         //            PROFILE IMAGE
         $profileImageExist = user::checkExist("user_images", "agent_id = '{$agent_id}' AND profile = '1'");
         if ($profileImageExist) {
             $image = user::getUserImages($agent_id, TRUE);
             $this->_userProfileImages = IMAGES_PATH . "users/" . $image['filename'];
         }
         //            AVAILABLE COMMISSION
         $this->_availableCommission = user::getAvailableComm($agent_id);
         //            BADGE
         $countAccPaymentBadge = user::countBadge("user_payment", "status = '0'");
         $this->_accPaymentBadge = $countAccPaymentBadge > 0 ? $countAccPaymentBadge : "";
         $countWithdrawalBadge = user::countBadge("user_withdrawal", "status = '0' OR status = '1'");
         $this->_withdrawalBadge = $countWithdrawalBadge > 0 ? $countWithdrawalBadge : "";
         //            $countMessageBadge = user::countBadge("user_messages", "agent_id = '$agent_id' AND status = '0'");
         //            $this->_messageBadge = ($countMessageBadge > 0) ? $countMessageBadge : "";
     }
     $this->view->_userData = $this->_userData;
     $this->view->_userAccType = $this->_userAccType;
     $this->view->_userProfileImages = $this->_userProfileImages;
     $this->view->_availableCommission = $this->_availableCommission;
     //        BADGE
     $this->view->_accPaymentBadge = $this->_accPaymentBadge;
     $this->view->_withdrawalBadge = $this->_withdrawalBadge;
     //        $this->view->_messageBadge = $this->_messageBadge;
 }
Example #7
0
 public function getSponsorId($agent_id)
 {
     $owner_ID = session::get(AGENT_SESSION_NAME);
     $mydata = $this->db->select("user_accounts", "agent_id,username", "agent_id = '{$owner_ID}'", "fetch");
     $cond = "(agent_id LIKE '%{$agent_id}%' OR username LIKE '%{$agent_id}%') AND (lv1 = '{$owner_ID}' OR lv2 = '{$owner_ID}' OR lv3 = '{$owner_ID}' OR lv4 = '{$owner_ID}' OR lv5 = '{$owner_ID}' OR lv6 = '{$owner_ID}' OR lv7 = '{$owner_ID}' OR lv8 = '{$owner_ID}' OR lv9 = '{$owner_ID}' OR lv10 = '{$owner_ID}') LIMIT 0,10";
     $usersData = $this->db->select("user_accounts", "agent_id, username", $cond);
     if (strpos($mydata['agent_id'], $agent_id) !== FALSE or strpos($mydata['username'], $agent_id) !== FALSE) {
         $usersData[] = $mydata;
     }
     foreach ($usersData as $key => $value) {
         $userID = $value['agent_id'];
         $imageExist = user::checkExist("user_images", "agent_id = '{$userID}' and profile = '1'");
         if ($imageExist) {
             $image = user::getUserImages($userID, TRUE);
             $imagePath = IMAGES_PATH . "users/" . $image['filename'];
         } else {
             $imagePath = IMAGES_PATH . "user-default.png";
         }
         $usersData[$key]['image'] = $imagePath;
     }
     return $usersData;
 }
Example #8
0
 function complete()
 {
     $userdata = $this->user;
     $agent_id = $userdata['agent_id'];
     $paymentComplete = TRUE;
     $db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS);
     $hasPayment = user::checkExist("user_payment", "agent_id = '{$agent_id}'");
     $paymentDetails = $db->select("user_payment", "payment_date, payment_time, from_acc, to_acc, payment_type", "agent_id = '{$agent_id}'", "fetch");
     if ($paymentDetails != FALSE) {
         foreach ($paymentDetails as $key => $value) {
             if (empty($value)) {
                 $paymentComplete = FALSE;
             }
         }
     } else {
         $paymentComplete = FALSE;
     }
     if (!$hasPayment or !$paymentComplete) {
         redirect::to("setup/payment");
     }
     $this->breadcrumb->add("Complete", "setup/complete");
     $this->view->breadcrumbs = $this->breadcrumb->get();
     $this->view->js = array('setup/js/setup.js');
     $this->view->render('setup/complete', 'backoffice');
 }
Example #9
0
 public function checkPin($data)
 {
     $response_array = array();
     $agent_id = $data['pin'];
     $userExist = user::checkExist("user_accounts", "agent_id = '{$agent_id}'");
     if (!$userExist) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Advertisement Pin</b> not valid!</div>";
     } else {
         $userdata = $this->db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch");
         $header = "<table class='table table-bordered table-condensed'><thead><tr class='active'><th class='text-center' width='50'>#</th><th class='text-center' width='150'>Available Pin</th><th class='text-center'  width='200'>Pin Code</th><th class='text-center'>Acc. Type</th><th class='text-center' width='150'>Action</th></tr></thead><tbody>";
         $content = "";
         $footer = "</tbody></table>";
         $acc_type = $userdata['acc_type'];
         $activate = $userdata['activate'];
         $payment = $userdata['payment'];
         $available_pin = $userdata['available_pin'];
         if ($acc_type == "pb" or $acc_type == "aa" or $activate == 0 or $payment != 2) {
             $response_array['r'] = "false";
             $response_array['msg'] = "<div><b>Advertisement Pin</b> not valid!</div>";
         } elseif ($available_pin == 0) {
             $response_array['r'] = "false";
             $response_array['msg'] = "<div>Insufficient <b>Advertisement Pin</b> balance!</div>";
         } else {
             //                CONSTRUCT CONTENT
             $highlight = $userdata['acc_type'] == "ep" ? "warning" : NULL;
             $pin_code = $userdata['agent_id'];
             $accType = user::getAccType($acc_type);
             $accType = $accType['label'];
             $content .= "<tr class='text-center {$highlight}'>";
             $content .= "<td>1</td>";
             $content .= "<td>{$available_pin}</td>";
             $content .= "<td>{$pin_code}</td>";
             $content .= "<td>{$accType}</td>";
             $content .= "<td><button class='btnSelect btn btn-primary btn-xs' type='button' data-pin='{$pin_code}'>Select</button></td>";
             $content .= "</tr>";
             $result = $header . $content . $footer;
             $response_array['r'] = "true";
             $response_array['msg'] = $result;
         }
     }
     return $response_array;
 }
Example #10
0
 public function addagent_success($agent_id)
 {
     $this->breadcrumb->add("Geneology", "mynetwork/geneology");
     $this->breadcrumb->add("Add Agent", "mynetwork/addagent");
     $this->breadcrumb->add("Successful", "mynetwork/addagent_success");
     $this->view->breadcrumbs = $this->breadcrumb->get();
     if (isset($agent_id)) {
         $verify = user::checkExist("user_accounts", "agent_id = '{$agent_id}'");
         if (!$verify) {
             redirect::to("mynetwork/geneology");
             exit;
         } else {
             $data = user::getUserData("agent_id", $agent_id);
             $this->view->userdata = $data;
             $this->view->js = array('mynetwork/js/addagent_success.js');
             $this->view->render('mynetwork/addagent_success', "backoffice");
         }
     } else {
         redirect::to();
         exit;
     }
 }
Example #11
0
 public function advertisementList()
 {
     $self_address = BASE_PATH . "management/advertisement";
     if (!isset($_REQUEST['s'])) {
         $_GET['s'] = NULL;
     }
     if (!isset($_REQUEST['p'])) {
         $_GET['p'] = 1;
     }
     $header = "<table class='table table-bordered table-condensed'><thead><tr><th class='text-center' width='50px'>#</th><th class='text-center' width='150px'>Ads ID</th><th class='text-center' width='150px'>Ads Pin</th><th class='text-center' >Supplier Name</th><th class='text-center' >Ads Name</th><th class='text-center' width='150px'>Document Date</th><th class='text-center' width='150px'>Receive Date</th><th class='text-center' width='150px'>Status</th><th class='text-center' width='150px'>Start Date</th><th class='text-center' width='150px'>Expiry Date</th><th class='text-center' width='300px'></th></tr></thead><tbody>";
     $content = "";
     $pagination = "";
     $listExist = user::checkExist("advertisement_view");
     if (!$listExist) {
         $content .= "<tr><td class ='text-center' colspan='11'>No advertisement record.</td></tr>";
     } else {
         if (isset($_REQUEST['s'])) {
             $s = $_GET['s'];
             if ($_GET['s'] != "") {
                 $searchItm = $s;
                 $searchSQL = " AND (ads_name LIKE '%{$searchItm}%') OR (supplier_id LIKE '%{$searchItm}%') OR (ads_id LIKE '%{$searchItm}%')";
                 $get_search = "&s={$searchItm}";
             } else {
                 $searchItm = NULL;
                 $searchSQL = NULL;
                 $get_search = NULL;
             }
         } else {
             $searchItm = NULL;
             $searchSQL = NULL;
             $get_search = NULL;
         }
         $page = $_GET['p'];
         $current_page = $page;
         $prev_page = $current_page - 1;
         $next_page = $current_page + 1;
         $max_result = 15;
         $from = $current_page * $max_result - $max_result;
         if (isset($_REQUEST['sid']) and isset($_REQUEST['aid'])) {
             $aid = $_GET['aid'];
             $sid = $_GET['sid'];
             $cond = "agent_id = '{$aid}' AND supplier_id = '{$sid}'";
         } else {
             $cond = "agent_id != 'NULL'";
         }
         if ($searchItm == NULL) {
             $advertisementList_full = $this->db->select("advertisement_view", "*", "{$cond} ORDER BY id DESC");
         } else {
             $advertisementList_full = $this->db->select("advertisement_view", "*", "{$cond} {$searchSQL} ORDER BY id DESC");
         }
         //
         $total_row = count($advertisementList_full);
         $total_pages = ceil($total_row / $max_result);
         $pagination .= "<ul class='pagination pagination-sm'>";
         if ($current_page > 1) {
             $pagination .= "<li><a href='{$self_address}?p={$prev_page}{$get_search}'><span class='fa fa-angle-double-left fa-fw'></span> Back</a></li>";
         } else {
             $pagination .= "<li class='disabled'><a href='#'><span class='fa fa-angle-double-left fa-fw'></span> Back</a></li>";
         }
         if ($current_page >= 7) {
             $pagination .= "<li><a href='{$self_address}?p=1{$get_search}'>1</a></li>";
             $pagination .= "<li class='disabled'><a href='#'>..</a></li>";
         }
         for ($i = max(1, $current_page - 5); $i <= min($current_page + 5, $total_pages); $i++) {
             if ($current_page == $i) {
                 $pagination .= "<li class='active'><a href='#'>{$i}</a></li>";
             } else {
                 $pagination .= "<li><a href='{$self_address}?p={$i}{$get_search}'>{$i}</a></li>";
             }
         }
         if ($current_page < $total_pages - 5) {
             $pagination .= "<li class='disabled'><a href='#'>..</a></li>";
             $pagination .= "<li><a href='{$self_address}?p={$total_pages}{$get_search}'>{$total_pages}</a></li>";
         }
         if ($current_page < $total_pages) {
             $pagination .= "<li><a href='{$self_address}?p={$next_page}{$get_search}'>Next <span class='fa fa-angle-double-right fa-fw'></span></a></li>";
         } else {
             $pagination .= "<li class='disabled'><a href='#'>Next <span class='fa fa-angle-double-right fa-fw'></span></a></li>";
         }
         $pagination .= "</ul>";
         if ($searchItm == NULL) {
             $advertisementList_limit = $this->db->select("advertisement_view", "*", "{$cond} ORDER BY id DESC LIMIT {$from},{$max_result}");
         } else {
             $advertisementList_limit = $this->db->select("advertisement_view", "*", "{$cond} {$searchSQL} ORDER BY id DESC LIMIT {$from},{$max_result}");
         }
         if ($total_row == 0) {
             $content .= "<tr><td class ='text-center' colspan='11'>No advertisement record.</td></tr>";
             $pagination = NULL;
         } else {
             if ($total_row <= $max_result) {
                 $pagination = NULL;
             }
             $x = $from + 1;
             foreach ($advertisementList_limit as $value) {
                 //                CONSTRUCT CONTENT
                 $ads_id = $value['ads_id'];
                 $ads_pin = $value['ads_pin'] ? "Yes" : "No";
                 $supplier_data = user::getSupplierData("supplier_id", $value['supplier_id']);
                 $supplier_name = "<a href='" . BASE_PATH . "management/supplier?s=" . $supplier_data['comp_name'] . "'>" . $supplier_data['comp_name'] . "</a>";
                 $ads_name = $value['ads_name'];
                 $doc_date = $value['date_doc'] != NULL ? date("d M Y", strtotime($value['date_doc'])) : "N/A";
                 $receive_date = $value['date_receive'] != NULL ? date("d M Y", strtotime($value['date_receive'])) : "N/A";
                 $ads_status = $value['ads_status'];
                 $date_start = $value['date_start'] != NULL ? date("d M Y", strtotime($value['date_start'])) : "N/A";
                 $date_end = $value['date_end'] != NULL ? date("d M Y", strtotime($value['date_end'])) : "N/A";
                 $action = "<button type='button' class='btn btn-primary btn-xs btn-details-toggles' data-toggle='modal' data-target='#detailsModal' data-adsid='{$ads_id}' data-url='" . BASE_PATH . "management/ajaxAdsDetails'><i class='fa fa-file-text fa-fw'></i> Details</button>";
                 $content .= "<tr class='text-center'>";
                 $content .= "<td>{$x}</td>";
                 $content .= "<td>{$ads_id}</td>";
                 $content .= "<td>{$ads_pin}</td>";
                 $content .= "<td>{$supplier_name}</td>";
                 $content .= "<td>{$ads_name}</td>";
                 $content .= "<td>{$doc_date}</td>";
                 $content .= "<td>{$receive_date}</td>";
                 $content .= "<td>{$ads_status}</td>";
                 $content .= "<td>{$date_start}</td>";
                 $content .= "<td>{$date_end}</td>";
                 $content .= "<td class='details'>{$action}</td>";
                 $content .= "</tr>";
                 $x++;
             }
         }
     }
     $footer = "</tbody></table>";
     $result = $header . $content . $footer . $pagination;
     return $result;
 }
Example #12
0
 public function getWithdrawalStatement($agent_id)
 {
     $self_address = BASE_PATH . "comm/withdrawal";
     $header = "<table class='table table-bordered table-condensed'><thead><tr><th class='text-center' width='50'>#</th><th class='text-center' width='150'>Date Request</th><th class='text-center'>Acount Details</th><th class='text-center' width='150'>Amount</th><th class='text-center' width='300'>Remarks</th><th class='text-center' width='150'>Status</th><th class='text-center' width='100'>Action</th></tr></thead> <tbody>";
     $content = "";
     $pagination = "";
     $recordExist = user::checkExist("user_withdrawal", "agent_id = '{$agent_id}'");
     if (!$recordExist) {
         $content .= "<tr><td class ='text-center' colspan='7'>No withdrawal record.</td></tr>";
     } else {
         $filterItm = $_GET['f'] != "" ? $_GET['f'] : NULL;
         if ($filterItm != NULL) {
             $filter = "AND date_request LIKE '%{$filterItm}%'";
         } else {
             $filter = NULL;
         }
         $page = $_GET['p'];
         $current_page = $page;
         $prev_page = $current_page - 1;
         $next_page = $current_page + 1;
         $max_result = 30;
         $from = $current_page * $max_result - $max_result;
         $withdrawalList_full = $this->db->select("user_withdrawal", "*", "agent_id = '{$agent_id}' {$filter} ORDER BY id DESC");
         $total_row = count($withdrawalList_full);
         $total_pages = ceil($total_row / $max_result);
         $pagination .= "<ul class='pagination pagination-sm'>";
         $filterLink = $filterItm != NULL ? "&s={$filterItm}" : NULL;
         if ($current_page > 1) {
             $pagination .= "<li><a href='{$self_address}?p={$prev_page}{$filterLink}'><span class='fa fa-angle-double-left fa-fw'></span> Back</a></li>";
         } else {
             $pagination .= "<li class='disabled'><a href='#'><span class='fa fa-angle-double-left fa-fw'></span> Back</a></li>";
         }
         if ($current_page >= 7) {
             $pagination .= "<li><a href='#'>1</a></li>";
             $pagination .= "<li class='disabled'><a href='#'>..</a></li>";
         }
         for ($i = max(1, $current_page - 5); $i <= min($current_page + 5, $total_pages); $i++) {
             if ($current_page == $i) {
                 $pagination .= "<li class='active'><a href='#'>{$i}</a></li>";
             } else {
                 $pagination .= "<li><a href='{$self_address}?p={$i}{$filterLink}'>{$i}</a></li>";
             }
         }
         if ($current_page < $total_pages - 5) {
             $pagination .= "<li class='disabled'><a href='#'>..</a></li>";
             $pagination .= "<li><a href='#'>{$total_pages}</a></li>";
         }
         if ($current_page < $total_pages) {
             $pagination .= "<li><a href='{$self_address}?p={$next_page}{$filterLink}'>Next <span class='fa fa-angle-double-right fa-fw'></span></a></li>";
         } else {
             $pagination .= "<li class='disabled'><a href='#'>Next <span class='fa fa-angle-double-right fa-fw'></span></a></li>";
         }
         $pagination .= "</ul>";
         $withdrawalList_limit = $this->db->select("user_withdrawal", "*", "agent_id = '{$agent_id}' {$filter} ORDER BY id DESC LIMIT {$from},{$max_result}");
         if ($total_row == 0) {
             $content .= "<tr><td class ='text-center' colspan='7'>No withdrawal record.</td></tr>";
             $pagination = NULL;
         } else {
             if ($total_row <= $max_result) {
                 $pagination = NULL;
             }
             $x = $from + 1;
             $total_withdrawal = 0;
             foreach ($withdrawalList_limit as $value) {
                 //                CONSTRUCT CONTENT
                 $id = $value['id'];
                 $datetime = date("d M Y-h:i A", strtotime($value['date_request']));
                 $date_request = str_replace("-", "<br/>", $datetime);
                 $holder_name = $value['holder_name'];
                 $bank_name = strtoupper($value['bank_name']);
                 $acc_no = $value['acc_no'];
                 $account_details = $holder_name . "<br/>" . $bank_name . " - " . $acc_no;
                 $amount = $value['amount'];
                 $remarks = $value['remarks'];
                 $status_code = $value['status'];
                 $date_review = date("d M Y", strtotime($value['date_review']));
                 switch ($status_code) {
                     case "-1":
                         $status = "<abbr title='Withdrawal request rejected.'><span class='label label-danger'>Rejected</span></abbr><br/>{$date_review}";
                         $action = "";
                         break;
                     case "1":
                         $status = "<abbr title='Withdrawal request in process.'><span class='label label-info'>Process</span></abbr><br/>{$date_review}";
                         $action = "";
                         break;
                     case "2":
                         $status = "<abbr title='Payment complete.'><span class='label label-success'>Success</span></abbr><br/>{$date_review}";
                         $action = "";
                         break;
                     default:
                         $status = "<abbr title='Waiting for review process.'><span class='label label-warning'>Pending</span></abbr>";
                         $action = "<a class='btn btn-link btn-cancel-withdraw' data-no='{$x}' data-id='{$id}' href='" . BASE_PATH . "comm/cancelWithdraw'>Cancel</a>";
                         break;
                 }
                 $content .= "<tr class='text-center'>";
                 $content .= "<td>{$x}</td>";
                 $content .= "<td>{$date_request}</td>";
                 $content .= "<td>{$account_details}</td>";
                 $content .= "<td>RM" . number_format($amount) . "</td>";
                 $content .= "<td>{$remarks}</td>";
                 $content .= "<td>{$status}</td>";
                 $content .= "<td>{$action}</td>";
                 $content .= "</tr>";
                 if ($value['status'] == "2") {
                     $total_withdrawal = $total_withdrawal + $amount;
                 }
                 $x++;
             }
             $content .= "<tr class='active'>";
             $content .= "<th class='text-center' colspan='3'>Total Successful Withdrawal</th>";
             $content .= "<th class='text-center'>RM" . number_format($total_withdrawal) . "</th>";
             $content .= "<th class='text-center' colspan='3'></th>";
             $content .= "</tr>";
         }
     }
     $footer = "</tbody></table>";
     $result = $header . $content . $footer . $pagination;
     echo json_encode($result);
 }
Example #13
0
 public function ajaxSupplierList()
 {
     $self_address = BASE_PATH . "supplier";
     $header = "<table class='table table-bordered table-condensed'><thead><tr><th class='text-center' width='50px'>#</th><th class='text-center' width='100px'>Type</th><th class='text-center' width='250px'>Name</th><th class='text-center' width='150px'>Category</th><th class='text-center' width='150px'>State, Country</th><th class='text-center' width='400px'>Business Desc</th><th class='text-center' width='150px'>Advertisement</th><th class='text-center' width='150px'>Status</th><th class='text-center' width='250px'>Action</th></tr></thead><tbody>";
     $content = "";
     $pagination = "";
     $agent_id = session::get(AGENT_SESSION_NAME);
     $listExist = user::checkExist("user_suppliers", "agent_id = '{$agent_id}'");
     if (!$listExist) {
         $content .= "<tr><td class ='text-center' colspan='9'>No supplier record.</td></tr>";
     } else {
         if (isset($_REQUEST['s'])) {
             $s = $_GET['s'];
             if ($_GET['s'] != "") {
                 $searchItm = $s;
                 $searchSQL = " AND (comp_name LIKE '%{$searchItm}%')";
                 $get_search = "&s={$searchItm}";
             } else {
                 $searchItm = NULL;
                 $searchSQL = NULL;
                 $get_search = NULL;
             }
         } else {
             $searchItm = NULL;
             $searchSQL = NULL;
             $get_search = NULL;
         }
         $page = $_GET['p'];
         $current_page = $page;
         $prev_page = $current_page - 1;
         $next_page = $current_page + 1;
         $max_result = 15;
         $from = $current_page * $max_result - $max_result;
         if ($searchItm == NULL) {
             $supplierList_full = $this->db->select("user_suppliers", "*", "agent_id = '{$agent_id}' ORDER BY id DESC");
         } else {
             $supplierList_full = $this->db->select("user_suppliers", "*", "agent_id = '{$agent_id}' {$searchSQL} ORDER BY id DESC");
         }
         //
         $total_row = count($supplierList_full);
         $total_pages = ceil($total_row / $max_result);
         $pagination .= "<ul class='pagination pagination-sm'>";
         if ($current_page > 1) {
             $pagination .= "<li><a href='{$self_address}?p={$prev_page}{$get_search}'><span class='fa fa-angle-double-left fa-fw'></span> Back</a></li>";
         } else {
             $pagination .= "<li class='disabled'><a href='#'><span class='fa fa-angle-double-left fa-fw'></span> Back</a></li>";
         }
         if ($current_page >= 7) {
             $pagination .= "<li><a href='{$self_address}?p=1{$get_search}'>1</a></li>";
             $pagination .= "<li class='disabled'><a href='#'>..</a></li>";
         }
         for ($i = max(1, $current_page - 5); $i <= min($current_page + 5, $total_pages); $i++) {
             if ($current_page == $i) {
                 $pagination .= "<li class='active'><a href='#'>{$i}</a></li>";
             } else {
                 $pagination .= "<li><a href='{$self_address}?p={$i}{$get_search}'>{$i}</a></li>";
             }
         }
         if ($current_page < $total_pages - 5) {
             $pagination .= "<li class='disabled'><a href='#'>..</a></li>";
             $pagination .= "<li><a href='{$self_address}?p={$total_pages}{$get_search}'>{$total_pages}</a></li>";
         }
         if ($current_page < $total_pages) {
             $pagination .= "<li><a href='{$self_address}?p={$next_page}{$get_search}'>Next <span class='fa fa-angle-double-right fa-fw'></span></a></li>";
         } else {
             $pagination .= "<li class='disabled'><a href='#'>Next <span class='fa fa-angle-double-right fa-fw'></span></a></li>";
         }
         $pagination .= "</ul>";
         if ($searchItm == NULL) {
             $supplierList_limit = $this->db->select("user_suppliers", "*", "agent_id = '{$agent_id}' ORDER BY id DESC LIMIT {$from},{$max_result}");
         } else {
             $supplierList_limit = $this->db->select("user_suppliers", "*", "agent_id = '{$agent_id}' {$searchSQL} ORDER BY id DESC LIMIT {$from},{$max_result}");
         }
         if ($total_row == 0) {
             $content .= "<tr><td class ='text-center' colspan='9'>No supplier record.</td></tr>";
             $pagination = NULL;
         } else {
             if ($total_row <= $max_result) {
                 $pagination = NULL;
             }
             $x = $from + 1;
             foreach ($supplierList_limit as $value) {
                 //                CONSTRUCT CONTENT
                 $supplier_id = $value['supplier_id'];
                 switch ($value['type']) {
                     case 1:
                         $type = "Paid";
                         $color = "bg-highlight";
                         break;
                     default:
                         $type = "Free";
                         $color = NULL;
                         break;
                 }
                 $name = ucwords(strtolower($value['comp_name']));
                 $categotyData = $this->db->select("category", "*", "id = '" . $value['category'] . "'", "fetch");
                 $category = $categotyData['category'] . " - " . $categotyData['subcategory'];
                 if ($value['comp_state'] == "oth") {
                     $state = $value['state_other'];
                 } else {
                     $stateData = user::getStates($value['comp_country']);
                     $statesArr = $stateData[0]['states'];
                     $statesArr = json_decode($statesArr);
                     $statesArr = get_object_vars($statesArr);
                     foreach ($statesArr as $key2 => $value2) {
                         if ($key2 == $value['comp_state']) {
                             $state = $value2;
                         }
                     }
                 }
                 $country = $this->db->select("country", "*", "code = '" . $value['comp_country'] . "'", "fetch");
                 $stateCountry = $state . ", " . $country['name'];
                 $descLenght = strlen($value['desc']);
                 if ($descLenght > 50) {
                     $desc = "<span class='desc'>" . substr($value['desc'], 0, 50) . "... </span>";
                     $desc .= "<a class='btn btn-xs btn-info btn-more-desc' href='{$self_address}/ajaxSupplierDesc' data-view='0' data-supplier='{$supplier_id}' title='Read more'><i class='fa fa-angle-down fa-fw'></i></a>";
                 } else {
                     $desc = "<span class='desc'>" . $value['desc'] . "</span>";
                 }
                 $count_ads = $this->db->count("advertisement_view", "supplier_id = {$supplier_id}");
                 $ads_count = "<a class='btn btn-xs btn-link' href='" . BASE_PATH . "advertisement?sid={$supplier_id}' title='View all advertisement from this supplier.'>{$count_ads}</a>";
                 $total_ads = $ads_count;
                 $status = $value['status'] == 0 ? "<span class='text-danger'>Waiting to verify</span>" : "<span class='text-success'>Verified</span>";
                 $action = "<div class='col-xs-12'><a class='btn btn-xs btn-info' href='{$self_address}/details?sid={$supplier_id}' title='View supplier details.'><i class='fa fa-file-text fa-fw'></i> Details</a></div>";
                 $content .= "<tr class='text-center {$color}'>";
                 $content .= "<td>{$x}</td>";
                 $content .= "<td>{$type}</td>";
                 $content .= "<td>{$name}</td>";
                 $content .= "<td>{$category}</td>";
                 $content .= "<td>{$stateCountry}</td>";
                 $content .= "<td>{$desc}</td>";
                 $content .= "<td>{$total_ads}</td>";
                 $content .= "<td>{$status}</td>";
                 $content .= "<td>{$action}</td>";
                 $content .= "</tr>";
                 $x++;
             }
         }
     }
     $footer = "</tbody></table>";
     $result = $header . $content . $footer . $pagination;
     return $result;
 }
Example #14
0
 public function join_exec($data)
 {
     $response_array = array();
     $agent = new user();
     $data['fullname'] = strtoupper($data['fullname']);
     $data['agent_id'] = $agent->generateID();
     $data['tmp_password'] = strtoupper(hash::create('crc32', uniqid(), HASH_PASSWORD_KEY));
     $data['activate_code'] = $agent->generateActivationCode($data['email']);
     $acc_type = $data['acc_type'];
     switch ($acc_type) {
         case "pb":
             $ads_pin_limit = "na";
             $available_pin = 0;
             break;
         case "aa":
             $ads_pin_limit = "na";
             $available_pin = 0;
             break;
         case "ed":
             $ads_pin_limit = 10;
             $available_pin = 10;
             break;
         case "ep":
             $ads_pin_limit = 40;
             $available_pin = 40;
             break;
         default:
             $ads_pin_limit = "unlimited";
             $available_pin = 40;
             break;
     }
     $data['ads_pin_limit'] = $ads_pin_limit;
     $data['available_pin'] = $available_pin;
     $checkEmail = $agent->checkEmail($data['email']);
     $checkCEmail = $agent->checkCdata($data['email'], $data['cemail']);
     $checkUsername = $data['chkusername'];
     $sponsor_id = $data['sponsor_id'];
     $checkSponsodID = user::checkExist("user_accounts", "agent_id = '{$sponsor_id}'");
     if (!$checkCEmail) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Confirm Email</b> not match!</div>";
     } elseif (!$checkEmail) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Email</b> already exist!</div>";
     } elseif ($checkUsername == 0) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div>Please <b>Check Username</b> availability!<div>";
     } elseif ($checkUsername == '-1') {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Username</b> not available! Please choose another username.<div>";
     } elseif (!$checkSponsodID) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Refferal ID</b> not valid! Please ask Refferal ID from the person who introduce you to 1STG Programs. If you don't have any refferal, you can directly <a href='" . BASE_PATH . "contact'>contact us</a> for an assistance.<div>";
     } else {
         unset($data['cemail']);
         unset($data['chkusername']);
         $link = BASE_PATH . 'join/verify?a=' . $data['activate_code'] . '&s=' . $data['username'];
         $agent_id = $data['sponsor_id'];
         $upline_id = $agent->generateUpline($agent_id);
         $newUplineData = $this->newUplineData($upline_id);
         foreach ($newUplineData as $key => $value) {
             $data[$key] = $value;
         }
         //            Insert into Database
         $this->db->insert("user_accounts", $data);
         //            Generate Email BODY
         $html = file_get_contents(BASE_PATH . 'email_template/activation');
         $html = htmlspecialchars($html);
         $html = str_replace('[USERNAME]', ucfirst($data['username']), $html);
         $html = str_replace('[ACTIVATION_CODE]', $link, $html);
         $html = html_entity_decode($html);
         $body = $html;
         //            Send Email
         $mailer = new mailer();
         $mailer->IsSMTP();
         // set mailer to use SMTP
         $mailer->Port = EMAIL_PORT;
         $mailer->Host = EMAIL_HOST;
         // specify main and backup server
         $mailer->SMTPAuth = true;
         // turn on SMTP authentication
         $mailer->Username = NOREPLY_EMAIL;
         // SMTP username
         $mailer->Password = NOREPLY_PASS;
         // SMTP password
         $mailer->From = NOREPLY_EMAIL;
         $mailer->FromName = SUPPORT_NAME;
         $mailer->AddAddress($data['email']);
         $mailer->IsHTML(true);
         $mailer->Subject = "Email verification to " . $data['email'];
         $mailer->Body = $body;
         if (!$mailer->Send()) {
             $response_array['r'] = "false";
             $response_array['msg'] = "Mailer Error: " . $mailer->ErrorInfo;
         } else {
             $response_array['r'] = "true";
             $response_array['msg'] = BASE_PATH . "join/success/" . $data['agent_id'];
         }
     }
     return $response_array;
 }
Example #15
0
 function agentUpgrade()
 {
     $agent_id = $_REQUEST['agent_id'] ? $_GET['agent_id'] : redirect::to("management/agentList");
     $validateID = user::checkExist("user_accounts", "agent_id = {$agent_id}");
     if (!$validateID) {
         redirect::to("management/agentList");
     } else {
         $userData = user::getUserData("agent_id", $agent_id);
     }
     $this->view->userdata = $userData;
     $this->view->user_acc_type = user::getAccType($userData['acc_type']);
     $this->view->acc_type_list = user::getAccType();
     $this->view->paymentMethodList = user::getPaymentMethod();
     $this->view->bankList = user::getBanks();
     $this->breadcrumb->add("Agent List", "management/agentList");
     $this->breadcrumb->add("Agent Upgrade - " . $userData['fullname'], "management/agentUpgrade");
     $this->view->breadcrumbs = $this->breadcrumb->get();
     $this->view->js = array('management/js/agentUpgrade.js');
     $this->view->render('management/agentUpgrade', 'backoffice');
 }
Example #16
0
 function details()
 {
     $supplier_id = isset($_GET['sid']) ? $_GET['sid'] : header("location: " . BASE_PATH . "supplier");
     $supplier_exist = user::checkExist("user_suppliers", "supplier_id = {$supplier_id}");
     if ($supplier_exist) {
         $supplier_data = user::getSupplierData("supplier_id", $supplier_id);
     } else {
         header("location: " . BASE_PATH . "supplier");
     }
     $this->view->supplier_data = $supplier_data;
     $this->view->breadcrumbs = $this->breadcrumb->add("Details", "supplier/details");
     $this->view->breadcrumbs = $this->breadcrumb->get();
     $this->view->js = array('supplier/js/details.js');
     $this->view->render('supplier/details', 'backoffice');
 }