function viewed()
 {
     $app_id = addslashes($_POST['app_id']);
     $key = addslashes($_POST['key']);
     $app = new AppAccount();
     if ($app_id == "" || $key == "") {
         $json['status_code'] = 0;
         echo json_encode($json);
         die;
     } else {
         $app->getByID($app_id);
         if ($app->app_token != $key) {
             $json['status_code'] = 0;
             $json['status_message'] = "wrong key";
             echo json_encode($json);
             die;
         }
     }
     $client_camp_id = addslashes($_POST['camp_id']);
     $device_id = addslashes($_POST['device_id']);
     $dl = new PushLogger();
     global $db;
     $q = "UPDATE {$dl->table_name} SET log_seen = 1, log_seen_date = '" . leap_mysqldate() . "' WHERE log_app_id = '{$app_id}' AND log_device_id = '{$device_id}' AND log_client_id = '{$client_camp_id}' ";
     //        echo $q;
     $db->query($q, 0);
     $gcm = new GCMResult();
     $arr = $gcm->getWhere("client_camp_id = '{$client_camp_id}' AND app_id = '{$app_id}' LIMIT 0,1");
     $total = 0;
     foreach ($arr as $up) {
         $q = "SELECT count(*) AS nr FROM {$dl->table_name} WHERE log_camp_id = '{$up->camp_id}' AND log_seen = 1";
         $nr = $db->query($q, 1);
         $total += $nr->nr;
         //get GCM and Update
         $up->seen_by = $nr->nr;
         $up->load = 1;
         $up->save();
     }
     $json['status_code'] = 1;
     $json['status_message'] = "Success";
     $json['total_dilihat'] = $total;
     echo json_encode($json);
     die;
 }
 static function verify()
 {
     $app_id = addslashes($_POST['app_id']);
     $key = addslashes($_POST['key']);
     //        echo $app_id;
     //        echo $key;
     if ($app_id == "" || $key == "") {
         $json['status_code'] = 0;
         $json['status_message'] = "Key Missing";
         die(json_encode($json));
     }
     $app = new AppAccount();
     $app->getByID($app_id);
     //        pr($app);
     if ($app->app_token != $key) {
         $json['status_code'] = 0;
         $json['status_message'] = "Key Mismatched";
         die(json_encode($json));
     }
     return $app;
 }
 static function kerjakan($psn)
 {
     $dev = new DeviceModel();
     $arrDevs = $dev->getWhere("dev_app_id = '{$psn->camp_app_id}' AND dev_not_send = 0 ");
     //app details
     $app = new AppAccount();
     $app->getByID($psn->camp_app_id);
     $array_id = array();
     if (count($arrDevs) > 0) {
         foreach ($arrDevs as $dev) {
             if ($_GET['test']) {
                 echo " acc_id : " . $dev->acc_id;
                 echo "<br> dev_id : " . $dev->device_id;
                 echo "<br> type : " . $dev->device_type;
                 echo "<br>";
             }
             $array_id[] = $dev->device_id;
         }
         $url2push = _BPATH . "WebViewer/messages/" . $psn->camp_id;
         $arrhasil = self::pushAfteriOS($array_id, $psn->camp_title, $url2push, $app);
         self::simpanHasilGCM($arrhasil, $psn, $array_id, $arrDevs, $app);
     }
 }
 public function getSetting()
 {
     IMBAuth::checkOAuth();
     $app_id = addslashes($_POST['app_id']);
     $app_token = addslashes($_POST['app_token']);
     $app = new AppAccount();
     $app->getByID($app_id);
     if ($app_token != $app->app_token) {
         $json['status_code'] = 0;
         $json['status_message'] = "Token Mismatched";
         echo json_encode($json);
         die;
     }
     $str = file_get_contents(_PHOTOPATH . "json/" . $app->app_keywords . ".json");
     //        pr($str);
     $json = json_decode($str);
     //        pr($json);
     //ditambahi
     $json->powered_by_link = Efiwebsetting::getData("Powered_By_Link");
     $json->status_code = 1;
     echo json_encode($json);
     die;
 }
Example #5
0
 function edit()
 {
     //cek ID
     if (isset($_GET['id'])) {
         $id = addslashes($_GET['id']);
         $appAcc = new AppAccount();
         $appAcc->getByID($id);
         if ($appAcc->app_client_id != Account::getMyID() && !in_array("master_admin", Account::getMyRoles())) {
             die("Owner's ID Mismatch");
         } else {
             //                ZAppFeature::clearSession();
             //load
             //                session_id($appAcc->app_keywords);
             FeatureSessionLayer::loadJSON($appAcc->app_keywords, $appAcc->app_id);
             //                sleep(1);
             //                pr($_SESSION);
             header("Location:" . _SPPATH . "apps/make?id=" . $id);
             die;
         }
     } else {
         header("Location:" . _SPPATH . "apps/makenew");
         die;
     }
 }
 function saveIntoApp()
 {
     $app = new AppAccount();
     if (isset($_GET['id']) && $_GET['id'] > 0) {
         $id = addslashes($_GET['id']);
         $app->getByID($id);
         $app->load = 1;
         if ($app->app_client_id != Account::getMyID()) {
             die("Owner's ID Mismatch");
         }
     }
     $detail = ZAppFeature::loadDetails();
     $app->app_client_id = Account::getMyID();
     $app->app_name = $detail['app_name'];
     $app->app_create_date = leap_mysqldate();
     $app->app_api_access_key = Efiwebsetting::getData('GCM_ACCESS_KEY');
     $app->app_token = md5(leap_mysqldate());
     $app->app_icon = $detail['app_icon'];
     $app->app_shortdes = $detail['app_des_short'];
     $app->app_feat = $detail['app_feature_img'];
     $app->app_fulldes = $detail['app_des_long'];
     if (isset($_GET['id']) && $_GET['id'] > 0) {
         $app->save();
         $appID = $app->app_id;
     } else {
         $app->app_keywords = session_id();
         $app->app_active = 0;
         $appID = $app->save();
         if ($appID) {
             $app2acc = new App2Acc();
             $app2acc->ac_admin_id = Account::getMyID();
             $app2acc->ac_app_id = $appID;
             $appID2 = $app2acc->save();
         }
     }
     $json['id'] = $appID;
     echo json_encode($json);
     //        echo $appID;
     die;
 }
 function placeOrder()
 {
     //sementara semua credit card
     //$order = $_REQUEST['order'];
     //$order['payment_method'] == 'credit_card';
     $json['paystate'] = 0;
     //langkah pertama daftarkan cc
     $creditCardId = $this->daftarkanCC();
     $currency = 'USD';
     $amount = addslashes($_POST['appprice']);
     $descr = addslashes($_POST['appdescr']);
     $app_id = addslashes($_POST['appid']);
     if ($creditCardId != NULL) {
         try {
             $paypal = new PaypalWrap();
             $payment = $paypal->makePaymentUsingCC($creditCardId, $amount, $currency, $descr);
             //                pr($payment);
             $order = new PaypalOrder();
             $order->amount = $amount;
             $order->created_time = leap_mysqldate();
             $order->currency = $currency;
             $order->description = $descr;
             $order->user_id = Account::getMyID();
             $order->payment_id = $payment->getId();
             $order->state = $payment->getState();
             $orderId = $order->save();
             $state = $order->state;
             if ($state == "approved") {
                 $json['paystate'] = 1;
                 //update paket active
                 $app = new AppAccount();
                 $app->getByID($app_id);
                 $app->app_active = 1;
                 $app->app_contract_start = leap_mysqldate();
                 $app->app_pulsa = 1000;
                 $app->app_contract_end = date('Y-m-d', strtotime('+1 year'));
                 $app->load = 1;
                 $app->save();
             }
             $message = "Your order has been placed successfully. Your Order id is <b>{$orderId}</b>";
             $messageType = 1;
         } catch (\PayPal\Exception\PPConnectionException $ex) {
             $message = parseApiError($ex->getData());
             $messageType = 0;
         } catch (Exception $ex) {
             $message = $ex->getMessage();
             $messageType = 0;
         }
     } else {
         $messageType = 0;
         $message = "credit card ID registration error";
     }
     $json['bool'] = $messageType;
     $json['err'] = $message;
     echo json_encode($json);
     die;
     //        if($_SERVER['REQUEST_METHOD'] == 'POST') {
     //
     //            try {
     //                if($order['payment_method'] == 'credit_card') {
     //
     //                    // Make a payment using credit card.
     //                    $user = getUser(getSignedInUser());
     //                    $payment = makePaymentUsingCC($user['creditcard_id'], $order['amount'], 'USD', $order['description']);
     //                    $orderId = addOrder(getSignedInUser(), $payment->getId(), $payment->getState(),
     //                        $order['amount'], $order['description']);
     //                    $message = "Your order has been placed successfully. Your Order id is <b>$orderId</b>";
     //                    $messageType = "success";
     //
     //                } else if($order['payment_method'] == 'paypal') {
     //
     //                    $orderId = addOrder(getSignedInUser(), NULL, NULL, $order['amount'], $order['description']);
     //                    // Create the payment and redirect buyer to paypal for payment approval.
     //                    $baseUrl = getBaseUrl() . "/order_completion.php?orderId=$orderId";
     //                    $payment = makePaymentUsingPayPal($order['amount'], 'USD', $order['description'],
     //                        "$baseUrl&success=true", "$baseUrl&success=false");
     //                    updateOrder($orderId, $payment->getState(), $payment->getId());
     //                    header("Location: " . getLink($payment->getLinks(), "approval_url") );
     //                    exit;
     //                }
     //            } catch (\PayPal\Exception\PPConnectionException $ex) {
     //                $message = parseApiError($ex->getData());
     //                $messageType = "error";
     //            } catch (Exception $ex) {
     //                $message = $ex->getMessage();
     //                $messageType = "error";
     //            }
     //        }
 }
    public static function myorderspage()
    {
        $arrPaymentStatus = array("1" => array("settlement", "success"), "2" => array("success", "success"), "3" => array("challenge", "failed"), "4" => array("pending", "pending"), "5" => array("deny", "denied"), "6" => array("cancel", "canceled"));
        ?>
        <style>

            @media (max-width: 768px) {

                .monly {
                    display: initial;
                }

                .donly {
                    display: none;
                }

            }

            @media (min-width: 768px) {
                .monly {
                    display: none;
                }

                .donly {
                    display: initial;
                }



            }

        </style>
        <style>
            .heading_earning{
                font-size: 17px;
                font-style: italic;
            }
            .heading_amount{
                font-size: 40px;
            }

            .inside{
                padding: 20px;
            }
            .selectMonth{
                /*padding-left: 10px;*/
            }
            .payout{
                color: #95abc2;
            }
            .money{
                font-size: 22px;
                color: #73879C;
            }
            .big{
                font-size: 25px;
                color: #73879C;
            }
            .rev_item{
                background-color: #ffffff;
                margin-top: 20px;
                margin-bottom: 20px;
            }
            .order_id{
                font-size: 20px;
                color: #73879C;
            }
            .pdate{
                color: #73879C;
                font-style: italic;
            }
            .heading_amount{
                font-size: 30px;
                text-align: right;
                padding-bottom: 100px;
            }
            .heading_amount_Sales{
                font-size: 18px;
                text-align: right;
                /*padding-bottom: 20px;*/
            }

            @media (max-width: 768px) {

                .monly {
                    display: initial;
                }

                .donly {
                    display: none;
                }

                .selectMonth{
                    padding-left: 0px;
                    padding-bottom: 20px;
                    border-bottom: 1px solid #CCCCCC;
                }
                .rightborder{
                    border-bottom: 1px solid #CCCCCC;
                }
                .leftborder{
                    border-top: 1px solid #CCCCCC;
                }
                .inside{
                    padding: 10px;
                }
                .tarmob{
                    /*text-align: right;*/
                }

            }

            @media (min-width: 768px) {
                .monly {
                    display: none;
                }

                .donly {
                    display: initial;
                }

                .leftborder{
                    border-left: 1px solid #CCCCCC;
                    min-height: 120px;
                }

                .rightborder{
                    border-right: 1px solid #CCCCCC;
                }
            }
        </style>
        <div class="container attop"  >
            <div class="col-md-12">
                <div class="appear_logo_pages">
                    <a href="<?php 
        echo _SPPATH;
        ?>
">
                        <img src="<?php 
        echo _SPPATH;
        ?>
images/appear-order.png" >
                    </a>
                </div>
                <?php 
        $orders = new VpTransaction();
        $arrOrder = $orders->getWhere("order_acc_id = '" . Account::getMyID() . "' ORDER BY order_date DESC");
        if (count($arrOrder) > 0) {
            foreach ($arrOrder as $num => $orders) {
                $app = new AppAccount();
                $app->getByID($orders->order_app_id);
                $paket = new Paket();
                $paket->getByID($orders->order_paket_id);
                ?>
                        <div class="rev_item col-md-12">
                            <div class="col-md-5 ">
                                <div class="inside">
                                    <div class="payout col-md-6 col-sm-6 col-xs-6">
                                        <div class="rev_details2">
                                            <small>Order ID</small>
                                            <div class="order_id"><?php 
                echo $orders->order_id;
                ?>
</div>
                                        </div>
                                    </div>
                                    <div class="payout col-md-6 col-sm-6 col-xs-6">
                                        <div class="rev_details">
                                            Date : <?php 
                echo date("F j, Y, g:i a", strtotime($orders->order_date));
                ?>
                                        </div>
                                        <div class="rev_details">
                                            App : <?php 
                echo $app->app_name;
                ?>
                                        </div>

                                        <div class="rev_details">
                                            Paket  : <?php 
                echo $paket->paket_name;
                ?>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                            </div>



                            <div class="col-md-3 payout leftborder rightborder">
                                <div class="inside">
                                    <div class="komisi tarmob">
                                        Order Value
                                        <div class="order_id"> IDR <?php 
                echo idr($orders->order_value);
                ?>
</div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 ">
                                <div class="inside tarmob">
                                    <small>Status</small>
                                    <div class="money big"><?php 
                echo $arrPaymentStatus[$orders->order_status][1];
                ?>
</div>
                                    <?php 
                if ($orders->order_status == "1" || $orders->order_status == "2") {
                    ?>
                                        <a href="<?php 
                    echo _SPPATH;
                    ?>
PaymentWeb/receipt?order_id=<?php 
                    echo $orders->order_id;
                    ?>
">receipt</a>
                                    <?php 
                }
                ?>
                                    <?php 
                if ($orders->order_status != "1" && $orders->order_status != "2" && $orders->order_status != "4") {
                    if ($app->app_active == 0) {
                        ?>
                                            <a href="<?php 
                        echo _SPPATH;
                        ?>
PaymentWeb/pay?app_id=<?php 
                        echo $app->app_id;
                        ?>
">pay again using different method</a>
                                        <?php 
                    }
                }
                ?>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                    <?php 
            }
            ?>
                    <div class="clearfix"></div>


                <?php 
        } else {
            ?>
                    <h1>No orders has been made yet</h1>
                <?php 
        }
        ?>
            </div>
        </div>
    <?php 
    }
 public static function payoutWS($acc)
 {
     $agent_id = $acc->admin_id;
     $mon = isset($_GET['mon']) ? addslashes($_GET['mon']) : date("n");
     $y = isset($_GET['y']) ? addslashes($_GET['y']) : date("Y");
     $json['acc_id'] = $acc->admin_id;
     $json['mon'] = $mon;
     $json['y'] = $y;
     $arr = AppearSales::getPayoutArray($acc->admin_id, $mon, $y);
     foreach ($arr['pertama'] as $tt) {
         $app = new AppAccount();
         $app->getByID($tt->komisi_app_id);
         $acc = new Account();
         $acc->getByID($tt->komisi_app_client_id);
         $paket = new Paket();
         $paket->getByID($tt->komisi_paket_id);
         $earn = array();
         $earn['order_id'] = $tt->komisi_order_id;
         $earn['komisi_app_date'] = $tt->komisi_app_date;
         $earn['app_name'] = $app->app_name;
         $earn['app_id'] = $app->app_id;
         $earn['client_name'] = $acc->admin_nama_depan;
         $earn['paket_id'] = $paket->paket_id;
         $earn['paket_name'] = $paket->paket_name;
         //            $earn['komisi_tingtong'] = $tt->komisi_ting_tong;
         //            $earn['komisi_tingtong_date'] = $tt->komisi_tingtong_date;
         $earn['komisi_bagi_pertama_value'] = $tt->komisi_bagi_pertama_value;
         $earn['komisi_bagi_pertama_date'] = date("F Y", strtotime($tt->komisi_bagi_pertama_date));
         $earn['komisi_bagi_kedua_value'] = $tt->komisi_bagi_kedua_value;
         $earn['komisi_bagi_kedua_date'] = date("F Y", strtotime($tt->komisi_bagi_kedua_date));
         $earn['total_komisi'] = $tt->komisi_value;
         $json['payout']['first'][] = $earn;
     }
     foreach ($arr['kedua'] as $tt) {
         $app = new AppAccount();
         $app->getByID($tt->komisi_app_id);
         $acc = new Account();
         $acc->getByID($tt->komisi_app_client_id);
         $paket = new Paket();
         $paket->getByID($tt->komisi_paket_id);
         $earn = array();
         $earn['order_id'] = $tt->komisi_order_id;
         $earn['komisi_app_date'] = $tt->komisi_app_date;
         $earn['app_name'] = $app->app_name;
         $earn['app_id'] = $app->app_id;
         $earn['client_name'] = $acc->admin_nama_depan;
         $earn['paket_id'] = $paket->paket_id;
         $earn['paket_name'] = $paket->paket_name;
         //            $earn['komisi_tingtong'] = $tt->komisi_ting_tong;
         //            $earn['komisi_tingtong_date'] = $tt->komisi_tingtong_date;
         $earn['komisi_bagi_pertama_value'] = $tt->komisi_bagi_pertama_value;
         $earn['komisi_bagi_pertama_date'] = date("F Y", strtotime($tt->komisi_bagi_pertama_date));
         $earn['komisi_bagi_kedua_value'] = $tt->komisi_bagi_kedua_value;
         $earn['komisi_bagi_kedua_date'] = date("F Y", strtotime($tt->komisi_bagi_kedua_date));
         $earn['total_komisi'] = $tt->komisi_value;
         $json['payout']['kedua'][] = $earn;
     }
     foreach ($arr['bonus'] as $tt) {
         $app = new BonusKomisi();
         $app->getByID($tt->bagi_bk_id);
         $acc = new Account();
         $acc->getByID($tt->bagi_acc_id);
         $earn = array();
         $earn['bonus_name'] = "Bonus " . $tt->bagi_bk_id;
         $earn['bonus_date'] = $tt->bagi_date_acquire;
         $earn['bonus_value'] = $tt->bagi_value;
         $json['payout']['bonus'][] = $earn;
     }
     $json['payout_total'] = AppearSales::calculatePayout($agent_id, $mon, $y)['total'];
     $json['status_code'] = 1;
     $json['status_message'] = "Success";
     echo json_encode($json);
     die;
 }
Example #10
0
 function testDate()
 {
     $date = new DateTime();
     $date->setDate(2016, 31, 1);
     $ymd = $date->format('Y-m-d');
     $ymd = "2016-01-31";
     $prev_mon = date('Y-m-d', strtotime($ymd . " +1 month"));
     $prev_year = date('Y-m-d', strtotime($ymd . " +4 months"));
     echo "     &nbsp; &nbsp; &nbsp; " . $prev_mon . " " . $prev_year;
     $curMonth = 7;
     $curYear = 2016;
     if ($curMonth == 12) {
         $firstDayNextMonth = mktime(0, 0, 0, 0, 0, $curYear + 1);
     } else {
         $firstDayNextMonth = mktime(0, 0, 0, $curMonth + 1, 1);
     }
     pr(date("Y-m-d", $firstDayNextMonth));
     pr(getFirstDayOfNextMonth($curMonth, $curYear));
     pr(getFirstDayOfNext4Month($curMonth, $curYear));
     $app = new AppAccount();
     $app->getByID(19);
     $vpt = new VpTransaction();
     $vpt->getByID("14720056041915");
     $vpt->order_id = 1122;
     //        KomisiModel::log($app,$vpt);
     $nn = new AppFree();
     $nn->printColumlistAsAttributes();
 }
 function addpulsatrans()
 {
     $app_id = addslashes($_POST['app_id']);
     $jml = addslashes($_POST['jml']);
     if ($jml < 1) {
         die("jumlah nol");
     }
     if ($app_id == "" || $app_id < 1) {
         die("app id nol");
     }
     $app = new AppAccount();
     $app->getByID($app_id);
     $add = new AppPulsa();
     $add->pulsa_acc_id = Account::getMyID();
     $add->pulsa_action = 'credit';
     $add->pulsa_jumlah = $jml;
     $add->pulsa_app_id = $app_id;
     $add->pulsa_old = $app->app_pulsa;
     $add->pulsa_new = $app->app_pulsa + $jml;
     $add->pulsa_date = leap_mysqldate();
     $add->pulsa_camp_id = 0;
     $s1 = $add->save();
     if ($s1) {
         $app->app_pulsa = $add->pulsa_new;
         $app->load = 1;
         $s2 = $app->save();
         if ($s2) {
             die("Saved");
         } else {
             die("Error on adding pulsa to AppAcc");
         }
     } else {
         die("Error on adding pulsa to AppPulsa");
     }
 }
 function doPushByDevIDwithFile()
 {
     /*
      * apa yang dibutuhkan
      */
     //        $client_id = addslashes($_POST['client_id']);
     $app_id = addslashes($_POST['app_id']);
     $key = addslashes($_POST['key']);
     $ipaddress = $_SERVER['REMOTE_ADDR'];
     //        pr($_POST['devs']);
     $app = new AppAccount();
     if ($app_id == "" || $key == "") {
         $json['status_code'] = 0;
         echo json_encode($json);
         die;
     } else {
         $app->getByID($app_id);
         //            $acc = new Account();
         //            $acc->getByID($app->app_client_id);
         if ($app->app_token != $key) {
             $json['status_code'] = 0;
             $json['status_message'] = "wrong key";
             echo json_encode($json);
             die;
         }
         if ($app->app_allowed_ip != "" && $app->app_allowed_ip != $ipaddress) {
             $json['status_code'] = 0;
             $json['status_message'] = "wrong ip, your ip is " . $ipaddress;
             echo json_encode($json);
             die;
         }
     }
     $start = addslashes($_POST['start']);
     $dest_url = addslashes($_POST['devs']);
     $devs = file_get_contents($dest_url);
     $client_camp_id = addslashes($_POST['camp_id']);
     $camp_name = addslashes($_POST['camp_name']);
     $camp_title = addslashes($_POST['camp_title']);
     //yg hrs ada cuman camp_title
     $camp_msg = addslashes($_POST['camp_msg']);
     $camp_url = addslashes($_POST['camp_url']);
     $camp_create_by = "API_" . $ipaddress;
     $camp_active = 1;
     $camp_status = 0;
     $camp_send_date = leap_mysqldate();
     $array_ids = explode(",", $devs);
     $isTest = addslashes($_POST['isTest']);
     //check pulsa
     if (count($array_ids) > $app->app_pulsa) {
         $json['status_code'] = 0;
         $json['status_message'] = "Pulsa tidak cukup";
         echo json_encode($json);
         die;
     } else {
         //  check isTest , test max ke 2 devices
         if ($isTest != "") {
             if (count($array_ids) > 5) {
                 $json['status_code'] = 0;
                 $json['status_message'] = "Test can only use 5 IDS";
                 echo json_encode($json);
                 die;
             }
         }
         //create local campaign
         $cm = new PushNotCamp();
         $cm->camp_client_id = $client_camp_id;
         //ini buat id nya di client
         $cm->camp_app_id = $app_id;
         $cm->camp_start = leap_mysqldate();
         $cm->camp_hour = 0;
         $cm->camp_name = $camp_name;
         $cm->camp_title = $camp_title;
         $cm->camp_msg = $camp_msg;
         $cm->camp_url = $camp_url;
         $cm->camp_create_by = $camp_create_by;
         $cm->camp_active = $camp_active;
         $cm->camp_status = $camp_status;
         $cm->camp_dev_ids = $devs;
         $camp_id = $cm->save();
         $cm->camp_id = $camp_id;
         $res = self::push($app, $array_ids, $camp_title, $camp_url, $camp_id);
         $json = self::processGCM($res, $app_id, $cm, $array_ids, $app, $isTest);
         echo json_encode($json);
         die;
     }
 }
 function addConfirm()
 {
     $err = array();
     $json['bool'] = 0;
     //       $json['err'] = array("apptitle"=>"harus diisi");
     $ttdate = addslashes($_POST['ttdate']);
     if ($ttdate == "") {
         $err['ttdate'] = "Date must be filled";
     }
     $ttname = addslashes($_POST['ttname']);
     if ($ttname == "") {
         $err['ttname'] = "Name must be filled";
     }
     $ttamount = addslashes($_POST['ttamount']);
     if ($ttamount == "") {
         $err['ttamount'] = "Amount must be filled";
     }
     $ttto = addslashes($_POST['ttto']);
     if ($ttto == "") {
         $err['ttto'] = "Bank Account must be filled";
     }
     if (count($err) > 0) {
         $json['bool'] = 0;
         $json['err'] = $err;
     } else {
         //save here
         $pc = new PaymentConfirm();
         $pc->confirm_app_id = addslashes($_POST['appid']);
         $pc->confirm_bank = $ttto;
         $pc->confirm_amount = $ttamount;
         $pc->confirm_create_date = leap_mysqldate();
         $pc->confirm_date = $ttdate;
         $pc->confirm_name = $ttname;
         $pc->confirm_receipt = addslashes($_POST['ttfile']);
         $pc->confirm_status = "not reviewed";
         $pc->confirm_user_id = Account::getMyID();
         $confirmID = $pc->save();
         if ($confirmID) {
             $app = new AppAccount();
             $app->getByID($pc->confirm_app_id);
             $app->app_active = 2;
             $app->load = 1;
             $app->app_pulsa = 1000;
             $app->save();
             $paket = new Paket();
             $paket->getByID($app->app_paket_id);
             //add pporder
             $ppo = new PaypalOrder();
             $ppo->payment_id = $confirmID;
             $ppo->payment_type = "banktt";
             $ppo->amount = $pc->confirm_amount;
             $ppo->currency = "IDR";
             $ppo->created_time = leap_mysqldate();
             $ppo->state = "pending";
             $ppo->user_id = Account::getMyID();
             $ppo->description = "Payment " . $app->app_name . " Paket " . $paket->paket_name . " ID : " . $app->app_id;
             $succ = $ppo->save();
             if ($succ) {
                 $json['bool'] = 1;
                 $json['order_id'] = $succ;
             } else {
                 $json['bool'] = 0;
                 $json['all'] = "Saving PPO Error";
             }
         } else {
             $json['bool'] = 0;
             $json['all'] = "Saving PConfirm Error";
         }
     }
     echo json_encode($json);
     die;
 }
Example #14
0
 function actionfree()
 {
     $id = addslashes($_POST['app_id']);
     $action = addslashes($_POST['action']);
     $app = new AppAccount();
     $app->getByID($id);
     $acc = new Account();
     $acc->getByID($app->app_client_id);
     $agent = new Account();
     if ($acc->admin_marketer != "") {
         $agent->getByUsername($acc->admin_marketer);
     }
     $dataemail = new DataEmail();
     $json['bool'] = 0;
     if ($action == "accept") {
         //status = 1 tetap
         $app->app_type = 0;
         //type = 0
         //contract start n end
         $app->app_contract_start = date("Y-m-d");
         $app->app_contract_end = date('Y-m-d', strtotime(date("Y-m-d", mktime()) . " + 365 day"));
         $app->app_paket_id = 1;
         //free
         $succ = $app->save();
         //spy masuk ke job queue
         //email ke marcel
         //komisi untuk agent nya...
         if ($succ) {
             //notify Admins kalau ada app active
             $dataemail->appBisaDibuat($app->app_name, $app->app_id, "Free App Accepted");
             //notify User
             $dataemail->freeAppAccepted($acc->admin_email, $acc->admin_username, $app->app_name);
             $vpt = new VpTransaction();
             $vpt->order_id = time();
             //hitung komisi
             //ini belum bener
             //TODO 31 maret 2016
             KomisiModel::log($app, $vpt);
             $json['bool'] = $succ;
         }
     }
     if ($action == "reject") {
         //status = 0
         $app->app_active = 0;
         //type = 0
         $app->app_type = 0;
         $app->app_paket_id = 0;
         $succ = $app->save();
         //email ke client & agent
         if ($succ) {
             $dataemail->freeRequestRejected($acc->admin_email, $acc->admin_username, $app->app_name);
             if ($acc->admin_marketer != "") {
                 $dataemail->freeRequestRejectedAgent($agent->admin_email, $acc->admin_username, $app->app_name, $agent->admin_username);
             }
             $json['bool'] = $succ;
         }
     }
     echo json_encode($json);
     die;
 }
 function pusher()
 {
     IMBAuth::checkOAuth();
     //        pr($_POST);
     //        if($_POST['ids'] == "")die("Please insert Customer ID");
     if ($_POST['camp_id'] == "") {
         die("Please insert Campaign ID");
     }
     //        $ids = addslashes($_POST['ids']);
     $ps = new PushNotCamp();
     $ps->getByID(addslashes($_POST['camp_id']));
     $app = new AppAccount();
     $app->getByID($ps->camp_client_id);
     $arrAcc = $ps->camp_client_id;
     //from acc get device ID
     Pusher::sendUsingArrayAcc($arrAcc, $ps, $app, 1);
     //1 for testing
 }
 public function constraints()
 {
     //err id => err msg
     $err = array();
     if (!isset($this->camp_start)) {
         $err['camp_start'] = Lang::t('Start cannot be empty');
     }
     if (!isset($this->camp_hour)) {
         $err['camp_hour'] = Lang::t('Time cannot be empty');
     }
     if (!isset($this->camp_msg) && !isset($this->camp_url)) {
         $err['camp_msg'] = Lang::t('Either Msg or URL must be filled');
         $err['camp_url'] = Lang::t('Either Msg or URL must be filled');
     }
     if (!isset($this->camp_name)) {
         $err['camp_name'] = Lang::t('Name cannot be empty');
     }
     if (!isset($this->camp_title)) {
         $err['camp_title'] = Lang::t('Title cannot be empty');
     }
     if (isset($this->camp_app_id)) {
         $app = new AppAccount();
         $app->getByID($this->camp_app_id);
         $this->camp_client_id = $app->app_client_id;
     }
     return $err;
 }
 public function registerPushNotif()
 {
     IMBAuth::checkOAuth();
     $app_id = addslashes($_POST['app_id']);
     $app_token = addslashes($_POST['app_token']);
     $app = new AppAccount();
     $app->getByID($app_id);
     if ($app->app_token != $app_token) {
         $json['status_code'] = 0;
         $json['status_message'] = "Token Mismatched";
         echo json_encode($json);
         die;
     }
     $acc_id = addslashes($_POST['acc_id']);
     $now = addslashes($_POST['now']);
     $ios = addslashes($_POST['ios']);
     $_GET['ios'] = $ios;
     $push_title = addslashes($_POST['push_title']);
     $push_msg = addslashes($_POST['push_msg']);
     $push_url = addslashes($_POST['push_url']);
     $push_img = addslashes($_POST['push_img']);
     $push_date = date("Y-m-d", strtotime(addslashes($_POST['push_date'])));
     $push_time = (int) addslashes($_POST['push_time']);
     $img = '';
     if ($push_img != '') {
         $img = Crud::savePic($push_img);
     }
     $push = new PushNotCamp();
     $push->camp_client_id = $app->app_client_id;
     $push->camp_img = $img;
     $push->camp_name = $push_title;
     $push->camp_title = $push_title;
     $push->camp_active = 1;
     $push->camp_start = $push_date;
     $push->camp_hour = $push_time;
     $push->camp_msg = $push_msg;
     $push->camp_url = $push_url;
     $push->camp_create_by = $acc_id;
     $push->camp_app_id = $app->app_id;
     $camp_id = $push->save();
     if ($camp_id) {
         $json['status_code'] = 1;
         if ($now) {
             //langsung do push
             $succ = Pusher::pushbyID($camp_id);
             $json['status_message'] = "Push Notifications Pushed";
             echo json_encode($json);
             die;
         } else {
             $json['status_message'] = "Push Notifications Registration Success";
             echo json_encode($json);
             die;
         }
     } else {
         $json['status_code'] = 0;
         $json['status_message'] = "Push Notifications Registration Failed";
         echo json_encode($json);
         die;
     }
 }
 public static function processFree()
 {
     $json = array();
     $json['err'] = "";
     $json['bool'] = 0;
     $rand = $_SESSION['rand'];
     $token = $_POST['token'];
     if ($rand != $token) {
         $json['err'] .= "Wrong Token<br>";
     }
     $id = addslashes($_POST['app_id']);
     $app = new AppAccount();
     $app->getByID($id);
     AppAccount::checkOwnership($app);
     if ($app->app_active) {
         $json['err'] .= "App already active<br>";
     }
     //        reason += validateEmpty(theForm.tos);
     //
     //        reason += validateEmpty(theForm.org_name);
     //        reason += validateEmpty(theForm.org_type);
     //
     //        reason += validateEmpty(theForm.org_doc);
     //        reason += validateEmpty(theForm.org_addresss);
     //        reason += validateEmpty(theForm.contact_name);
     //        reason += validateEmpty(theForm.contact_phone);
     //        reason += validateEmpty(theForm.contact_email);
     //check username
     $tos = addslashes($_POST['tos']);
     if ($tos == "") {
         $json['err'] .= "Please accept Terms of Service<br>";
     }
     //check username
     $org_name = addslashes($_POST['org_name']);
     if ($org_name == "") {
         $json['err'] .= "Organization Name cannot be empty<br>";
     }
     //check username
     $org_type = addslashes($_POST['org_type']);
     if ($org_type == "") {
         $json['err'] .= "Organization Type cannot be empty<br>";
     }
     //check username
     $org_doc = addslashes($_POST['org_doc']);
     if ($org_doc == "") {
         $json['err'] .= "Documents cannot be empty<br>";
     }
     //check username
     $org_addresss = addslashes($_POST['org_addresss']);
     if ($org_addresss == "") {
         $json['err'] .= "Adress cannot be empty<br>";
     }
     //check username
     $contact_name = addslashes($_POST['contact_name']);
     if ($contact_name == "") {
         $json['err'] .= "Contact cannot be empty<br>";
     }
     //check username
     $contact_phone = addslashes($_POST['contact_phone']);
     if ($contact_phone == "") {
         $json['err'] .= "Phone cannot be empty<br>";
     }
     //check username
     $contact_email = addslashes($_POST['contact_email']);
     if ($contact_email == "") {
         $json['err'] .= "Email cannot be empty<br>";
     }
     if ($json['err'] == "") {
         $app->app_type = 1;
         $app->app_paket_id = 1;
         //FREE
         $app->app_active = 1;
         $succ = $app->save();
         //TODO hahah
         if ($succ) {
             $free = new AppFree();
             $free->free_app_id = $app->app_id;
             $free->free_address = $org_addresss;
             $free->free_contact_email = $contact_email;
             $free->free_org_name = $org_name;
             $free->free_org_docs = $org_doc;
             $free->free_org_type = $org_type;
             $free->free_contact_name = $contact_name;
             $free->free_contact_phone = $contact_phone;
             $free->free_date = leap_mysqldate();
             $free->save(1);
         }
         $json['bool'] = $succ;
     }
     //        $json['post'] = $_POST;
     echo json_encode($json);
     die;
 }
    public function loadDataApp($app_id)
    {
        if ($app_id == "") {
            die("Please insert App ID");
        }
        $app = new AppAccount();
        $app->getByID($app_id);
        //        pr($app);
        $acc = new Account();
        $acc->getByID($app->app_client_id);
        ?>
        <div class="row">

            <div class="col-md-4">
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h3><?php 
        echo $acc->admin_pulsa;
        ?>
</h3>
                        <p>Kuota Push Notifications</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-bag"></i>
                    </div>
                    <!--                            <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>-->
                </div>
            </div>
        </div>

        <?php 
        $bulan = addslashes($_GET['m']);
        if ($bulan == "") {
            $bulan = date("F Y");
            $days_ago = date('Y-m-01');
            // hard-coded '01' for first day
            $days_now = date('Y-m-t');
        } else {
            $bulan = urldecode($bulan);
            $days_ago = date('Y-m-01', strtotime($bulan));
            // hard-coded '01' for first day
            $days_now = date('Y-m-t', strtotime($bulan));
        }
        $numberDays = cal_days_in_month(CAL_GREGORIAN, date('n', strtotime($bulan)), date('Y', strtotime($bulan)));
        $days_ago = date('Y-m-01', strtotime($bulan));
        // hard-coded '01' for first day
        $days_now = date('Y-m-01', strtotime('+1 month', strtotime($bulan)));
        //user acquisitions
        $ll = new LL_Account();
        $arrUserNew = $ll->getWhere("(macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}')", "macc_acquire_date");
        //new device
        $dev = new DeviceModel();
        $arrDevNew = $dev->getWhere(" (firstlogin BETWEEN '{$days_ago}' AND '{$days_now}') ");
        //device active
        $dlog = new DeviceLogger();
        $arrDevActive = $dlog->getWhere(" (log_date BETWEEN '{$days_ago}' AND '{$days_now}') ");
        //        count($arrDevActive);
        //user active
        $acclog = new LL_AccountLogger();
        $arrUserActive = $acclog->getWhere("(log_date BETWEEN '{$days_ago}' AND '{$days_now}')");
        //        count($arrUserActive);
        $arrStats["New Users"] = $arrUserNew;
        $arrStats["Active Users"] = $arrUserActive;
        $arrStats["New Devices"] = $arrDevNew;
        $arrStats["Active Devices"] = $arrDevActive;
        $t = time();
        ?>
        <div class="row">
            <div class="col-md-12">
                <h1>
                    App Dashboard
                    <small><?php 
        echo $bulan;
        ?>
</small>
                </h1>
                <ol class="breadcrumb">
                    <li>
                        <?php 
        echo Lang::t('Select Timeframe');
        ?>
                    </li>
                    <li class="active">
                        <?php 
        $start = new DateTime('11 months ago');
        // So you don't skip February if today is day the 29th, 30th, or 31st
        $start->modify('first day of this month');
        $end = new DateTime();
        $interval = new DateInterval('P1M');
        $period = new DatePeriod($start, $interval, $end);
        ?>
                        <select id="apptimeselector_<?php 
        echo $t;
        ?>
">
                            <?php 
        foreach ($period as $dt) {
            ?>
                                <option value="<?php 
            echo urlencode($dt->format('F Y'));
            ?>
" <?php 
            if ($dt->format('F Y') == $bulan) {
                echo "selected";
            }
            ?>
>
                                    <?php 
            echo $dt->format('F Y') . "<br>";
            ?>
                                </option>
                            <?php 
        }
        ?>

                        </select>
                        <script>
                            $("#apptimeselector_<?php 
        echo $t;
        ?>
").change(function(){
                                var slc = $("#apptimeselector_<?php 
        echo $t;
        ?>
").val();
                                openLw("App","<?php 
        echo _SPPATH;
        ?>
BIWebProd/app?m="+slc,"fade");
                            });
                        </script>
                    </li>
                </ol>
            </div>
        </div>
        <div class="row">
            <div class="col-md-3">
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h3><?php 
        echo count($arrUserNew);
        ?>
</h3>
                        <p>New Users</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-bag"></i>
                    </div>
                    <!--                            <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>-->
                </div>
            </div>
            <div class="col-md-3">
                <div class="small-box bg-green">
                    <div class="inner">

                        <h3><?php 
        echo count($arrUserActive);
        ?>
</h3>

                        <p>Active Users</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-stats-bars"></i>
                    </div>
                    <!--                            <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>-->
                </div>
            </div>
            <div class="col-md-3">
                <div class="small-box bg-yellow">
                    <div class="inner">


                        <h3><?php 
        echo count($arrDevNew);
        ?>
</h3>

                        <p>New Devices</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-stats-bars"></i>
                    </div>
                    <!--                            <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>-->
                </div>
            </div>
            <div class="col-md-3">
                <div class="small-box bg-red">
                    <div class="inner">
                        <?php 
        ?>

                        <h3><?php 
        echo count($arrDevActive);
        ?>
</h3>

                        <p>Active Devices</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-stats-bars"></i>
                    </div>
                    <!--                            <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>-->
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="box box-default">
                    <div class="box-header with-border">
                        <h3 class="box-title">User Stats</h3>

                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                        </div>
                    </div>
                    <div class="box-body chart-responsive">

                        <?php 
        //            $days_ago = date('Y-m-d', strtotime('-30 days', time()));
        //            $days_now =  date("Y-m-d");
        $data = self::getAppStats($arrStats, $days_ago, $days_now);
        ?>


                    </div>
                    <!-- /.box-body -->
                </div>
            </div>

        </div>
        <div class="row">

            <?php 
        $arrDType = array();
        foreach ($arrDevActive as $de) {
            $arrDType[$de->log_dev_type][] = $de;
        }
        $arrColor = array("#00a65a", "#00c0ef");
        foreach ($arrDType as $type => $arrDe) {
            $c = new Charting();
            $c->color = array_pop($arrColor);
            $c->label = $type;
            $c->value = count($arrDe);
            $totalanDevType[$type] = $c->value;
            $arrData[] = $c;
        }
        //                pr($arrData);
        ?>
<div class="col-md-6"><?php 
        Charting::morrisDonut("300px", $arrData, 1, "Device Type", "default");
        ?>

            </div>
            <div class="col-md-6">
                <div class="box box-default">
                    <div class="box-header with-border">
                        <h3 class="box-title">Average</h3>

                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                        </div>
                    </div>
                    <div class="box-body chart-responsive">
                        <div class="average" style="padding: 20px;">
                            <?php 
        //                                pr($data);
        $maxUsers = max($data['New Users']);
        $maxActiveUsers = max($data['Active Users']);
        $maxNewDevice = max($data['New Devices']);
        $maxActiveDevice = max($data['Active Devices']);
        ?>
                            <p class="text-center">
                                <strong></strong>
                            </p>


                            <!-- /.progress-group -->
                            <div class="progress-group">
                                <span class="progress-text">New Users per Day</span>
                                <span class="progress-number"><b><?php 
        echo round(count($arrUserNew) / $numberDays, 2);
        ?>
</b>/<?php 
        echo $maxUsers;
        ?>
</span>

                                <div class="progress sm">
                                    <?php 
        $percent = ceil(count($arrUserNew) / $numberDays) / $maxUsers * 100;
        ?>
                                    <div class="progress-bar progress-bar-red" style="width: <?php 
        echo $percent;
        ?>
%"></div>
                                </div>
                            </div>
                            <!-- /.progress-group -->
                            <div class="progress-group">
                                <?php 
        $rata2 = round(count($arrUserActive) / $numberDays, 2);
        $percent = round($rata2 / $maxActiveUsers * 100);
        ?>
                                <span class="progress-text">Active Users per Day</span>
                                <span class="progress-number"><b><?php 
        echo $rata2;
        ?>
</b>/<?php 
        echo $maxActiveUsers;
        ?>
</span>

                                <div class="progress sm">
                                    <div class="progress-bar progress-bar-yellow" style="width: <?php 
        echo $percent;
        ?>
%"></div>
                                </div>
                            </div>
                            <!-- /.progress-group -->
                            <div class="progress-group">
                                <?php 
        $rata2 = round(count($arrDevNew) / $numberDays, 2);
        $percent = round($rata2 / $maxNewDevice * 100);
        ?>

                                <span class="progress-text">New Device per Day</span>
                                <span class="progress-number"><b><?php 
        echo $rata2;
        ?>
</b>/<?php 
        echo $maxNewDevice;
        ?>
</span>

                                <div class="progress sm">
                                    <div class="progress-bar progress-bar-red" style="width: <?php 
        echo $percent;
        ?>
%"></div>
                                </div>
                            </div>
                            <!-- /.progress-group -->
                            <!-- /.progress-group -->
                            <div class="progress-group">
                                <?php 
        $rata2 = round(count($arrDevActive) / $numberDays, 2);
        $percent = round($rata2 / $maxActiveDevice * 100);
        ?>

                                <span class="progress-text">Active Device per Day</span>
                                <span class="progress-number"><b><?php 
        echo $rata2;
        ?>
</b>/<?php 
        echo $maxActiveDevice;
        ?>
</span>

                                <div class="progress sm">
                                    <div class="progress-bar progress-bar-yellow" style="width: <?php 
        echo $percent;
        ?>
%"></div>
                                </div>
                            </div>
                            <!-- /.progress-group -->
                            <div class="progress-group">
                                <span class="progress-text">Android vs iOS</span>
                                <span class="progress-number"><b><?php 
        echo $totalanDevType['android'];
        ?>
</b>/<?php 
        echo $totalanDevType['android'] + $totalanDevType['ios'];
        ?>
</span>

                                <div class="progress sm">
                                    <?php 
        $percent = round($totalanDevType['android'] / ($totalanDevType['android'] + $totalanDevType['ios']) * 100);
        ?>
                                    <div class="progress-bar progress-bar-aqua" style="width: <?php 
        echo $percent;
        ?>
%"></div>
                                </div>
                            </div>
                            <!-- /.progress-group -->
                            <div class="progress-group">
                                <span class="progress-text">iOS vs Android</span>
                                <span class="progress-number"><b><?php 
        echo $totalanDevType['ios'];
        ?>
</b>/<?php 
        echo $totalanDevType['android'] + $totalanDevType['ios'];
        ?>
</span>

                                <div class="progress sm">
                                    <?php 
        $percent = round($totalanDevType['ios'] / ($totalanDevType['android'] + $totalanDevType['ios']) * 100);
        ?>
                                    <div class="progress-bar progress-bar-green" style="width: <?php 
        echo $percent;
        ?>
%"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-body -->
                </div>

            </div>
        </div>
        <style>
            ul.legend li{
                list-style: none;
                line-height: 30px;
            }
            ul.legend li div{
                float: left;
                margin-top: 10px;
                margin-right: 15px;
            }
            .legend-item{
                float: left;
                margin: 10px;
                line-height: 30px;
                margin-right: 5px;
            }
            .legend-item div{
                float: left;
                margin-top: 10px;
                margin-right: 5px;
            }
            .breadcrumb {
                padding: 8px 15px;
                margin-bottom: 20px;
                list-style: none;
                background-color: #f5f5f5;
                border-radius: 4px;
            }
            .breadcrumb {
                float: right;
                background: transparent;
                margin-top: 0;
                margin-bottom: 0;
                font-size: 12px;
                padding: 7px 5px;
                position: absolute;
                top: 15px;
                right: 10px;
                border-radius: 2px;
            }
        </style>

    <?php 
    }
 public static function getActiveAppObject()
 {
     $app = new AppAccount();
     $app->getByID(self::getAppID());
     return $app;
 }
 function selanjutnya()
 {
     $app_id = addslashes($_POST['app_id']);
     $key = addslashes($_POST['key']);
     $device_id = addslashes($_POST['device_id']);
     $type = addslashes($_POST['type']);
     $lat = addslashes($_POST['lat']);
     $lng = addslashes($_POST['long']);
     $acc = isset($_POST['acc_id']) ? addslashes($_POST['acc_id']) : 0;
     $log_page_id = addslashes($_POST['page_id']);
     if ($device_id == "" || $type == "") {
         $json['status_code'] = 0;
         echo json_encode($json);
         die;
     }
     if ($app_id == "" || $key == "") {
         $json['status_code'] = 0;
         echo json_encode($json);
         die;
     } else {
         $app = new AppAccount();
         $app->getByID($app_id);
         //            $acc = new Account();
         //            $acc->getByID($app->app_client_id);
         if ($app->app_token != $key) {
             $json['status_code'] = 0;
             $json['status_message'] = "wrong key";
             echo json_encode($json);
             die;
         }
     }
     $logged = new DeviceLogger();
     $logged->log_acc_id = $acc;
     $logged->log_date = leap_mysqldate();
     $logged->log_dev_id = $device_id;
     $logged->log_dev_type = $type;
     $logged->log_app_id = $app_id;
     $logged->log_lat = $lat;
     $logged->log_lng = $lng;
     $logged->log_page_id = $log_page_id;
     $logged->save();
     $json['status_code'] = 1;
     echo json_encode($json);
     die;
 }
    function receipt()
    {
        $order_id = addslashes($_GET['order_id']);
        $order = new VpTransaction();
        $order->getByID($order_id);
        //        pr($order);
        //TODO : harus dibikin
        if ($order->order_acc_id != Account::getMyID() && !in_array("master_admin", Account::getMyRoles())) {
            die("hacking attempt");
        }
        $app = new AppAccount();
        $app->getByID($order->order_app_id);
        if ($app->app_active == 0) {
            die("App not active");
        }
        $acc = new Account();
        $acc->getByID($app->app_client_id);
        $paket = new Paket();
        $paket->getByID($order->order_paket_id);
        $vpData = new VpData();
        $arr = $vpData->getWhere("order_id = '{$order_id}' LIMIT 0,1");
        if (count($arr) > 0) {
            $data = $arr[0];
        } else {
            $data = new VpData();
        }
        if ($acc->admin_marketer != "") {
            $arrAg = $acc->getWhere("admin_username = '******' LIMIT 0,1");
            if (count($arrAg) > 0) {
                $agent = $arrAg[0];
            }
        }
        //        pr($arr);
        ?>
        <style>
            h1{
                font-size: 25px;
                padding-top: 30px;
            }
            h3{
                font-size: 20px;
                font-style: italic;
            }
            h4{
                font-size: 17px;
                margin-top: 20px;
                margin-bottom: 30px;
            }
            .billings td{
                padding-right: 20px;
                padding-bottom: 10px;
            }
            @media (max-width: 768px) {

                .monly {
                    display: initial;
                }

                .donly {
                    display: none;
                }

                h1{
                    font-size: 20px;
                }
                h3{
                    font-size: 17px;
                    font-style: italic;
                }
                h4{
                    font-size: 14px;
                    margin-bottom: 30px;
                }
                .billings td{
                    padding-bottom: 10px;
                }
            }

            @media (min-width: 768px) {
                .monly {
                    display: none;
                }

                .donly {
                    display: initial;
                }



            }
            @media print {
                .pure-toggle-label[data-toggle-label='left']{
                    display: none;
                }
                #printme{
                    display: none;
                }
                body{
                    background-color: #ffffff;
                }
            }
        </style>
        <div class="container attop"  >
                <div class="col-md-8 col-md-offset-2">


                    <div style="text-align: center; background-color: #ffffff; padding: 20px; min-height: 800px;  margin-top: 20px; padding-top: 20px; padding-bottom: 20px; ">
                        <img src="<?php 
        echo _SPPATH;
        ?>
images/header_appear.jpg" width="100%">

                        <h1>PAYMENT RECEIPT</h1>
                        <h3>Your payment has been completed successfully</h3>
                        <div class="receipt" style=" margin-top: 30px;">
                        <h4>TRANSACTION DETAILS</h4>
                        <table class="billings" align="center" style="text-align: left;">
                            <tr>
                                <td>ORDER ID</td>
                                <td><?php 
        echo $order_id;
        ?>
</td>
                            </tr>
                            <tr>
                                <td>PAYMENT DATE / TIME</td>
                                <td><?php 
        echo date("F j, Y, g:i a", strtotime($order->order_date));
        ?>
</td>
                            </tr>
                            <tr>
                                <td>PACKAGE NAME</td>
                                <td><?php 
        echo $paket->paket_name;
        ?>
</td>
                            </tr>
                            <tr>
                                <td>APP ID</td>
                                <td><?php 
        echo $app->app_id;
        ?>
</td>
                            </tr>
                            <tr>
                                <td>ACCOUNT ID</td>
                                <td><?php 
        echo $acc->admin_nama_depan;
        ?>
</td>
                            </tr>
                            <tr>
                                <td>AMOUNT</td>
                                <td>IDR <?php 
        echo idr($paket->paket_price);
        ?>
</td>
                            </tr>
                            <tr>
                                <td>STATUS</td>
                                <td><?php 
        echo $data->transaction_status;
        ?>
</td>
                            </tr>
                            <tr>
                                <td>PAYMENT TYPE</td>
                                <td><?php 
        echo $data->payment_type;
        ?>
</td>
                            </tr>
                            <tr>
                                <td>BANK NAME</td>
                                <td><?php 
        echo $data->bank;
        ?>
</td>
                            </tr>
                            <?php 
        if (count($arrAg) > 0) {
            ?>
                            <tr>
                                <td>AGENT ID</td>
                                <td><?php 
            echo $agent->admin_username;
            ?>
</td>
                            </tr>
                            <?php 
        }
        ?>
                        </table>
                        </div>


                    </div>
                    <div id="printme" style="text-align: right; margin-top: 5px; margin-bottom: 100px;" >
                         <a href="#" onclick="window.print();"><i class="glyphicon glyphicon-print"></i> print</a> |
                        <a href="<?php 
        echo _SPPATH;
        ?>
myOrders">back to my transactions</a>
                    </div>
                </div>
            </div>
        <?php 
    }
Example #23
0
    function error()
    {
        $order_id = addslashes($_GET['order_id']);
        $status_code = addslashes($_GET['status_code']);
        $transaction_status = addslashes($_GET['transaction_status']);
        $vpt = new VpTransaction();
        $vpt->getByID($order_id);
        $app = new AppAccount();
        $app->getByID($vpt->order_app_id);
        AppAccount::checkOwnership($app);
        $vpt->order_status_from = $status_code;
        $vpt->save();
        ?>
        <div class="container attop"  >
            <div class="col-md-8 col-md-offset-2">

                <div style="text-align: center; padding: 20px;">
                    <a href="<?php 
        echo _SPPATH;
        ?>
">
                        <img src="<?php 
        echo _SPPATH;
        ?>
images/appear-icontext.png" style="max-width: 300px;">
                    </a>
                </div>
                <?php 
        ?>

                <h1>Error</h1>
                <p>Your Payment Error</p>

                <p>
                    Please <a href="<?php 
        echo _SPPATH;
        ?>
contact">contact us</a> for more details.
                </p>

                <a class="btn btn-default" href="<?php 
        echo _SPPATH;
        ?>
myApps">back to my Apps</a>
                <?php 
        ?>
            </div>
        </div>
        <?php 
        /*
        * Array
        (
            [url] => vp/error
            [order_id] => 70872981
            [status_code] => 202
            [transaction_status] => deny
        )
        */
    }
    function appView()
    {
        $id = addslashes($_GET['id']);
        if (in_array("master_admin", Account::getMyRoles())) {
            //            $acc = new AppAccount();
            //            $apps = $acc->getAll();
            //
            $app = new AppAccount();
            $app->getByID($id);
        } else {
            $acc = new App2Acc();
            //AND app_active = 1
            $apps = $acc->getWhereFromMultipleTable("ac_admin_id = '" . Account::getMyID() . "' AND ac_app_id = app_id AND ac_app_id = '{$id}' ", array("AppAccount"));
            //            pr($apps);
            if (count($apps) < 1) {
                die("hacking attempt");
            } else {
                $app = $apps[0];
            }
        }
        $paket = new Paket();
        $paket->getByID($app->app_paket_id);
        if (!$app->app_active) {
            header("Location:" . _SPPATH . "PaymentWeb/payfor?app_id=" . $app->app_id);
            die;
        }
        ?>
        <div class="container attop" >
        <div class="col-md-8 col-md-offset-2">
        <small><a href="<?php 
        echo _SPPATH;
        ?>
mydashboard">back to dashboard</a> </small>
        <h1><?php 
        echo $app->app_name;
        ?>
 <small><a href="">edit app</a></small></h1>

        <div class="paket">Paket : <b style="font-size: 18px;"><?php 
        echo $paket->paket_name;
        ?>
</b> &nbsp; <i>[<a href="">Edit Paket</a>]</i> </div>
        <div style="padding: 10px;">
            <?php 
        if (!$app->app_active) {
            ?>

                <a class="btn btn-success btn-lg" href="<?php 
            echo _SPPATH;
            ?>
PaymentWeb/payfor?app_id=<?php 
            echo $app->app_id;
            ?>
">Payment</a>
            <?php 
        } else {
            ?>
                <a class="btn btn-success btn-lg" href="<?php 
            echo _SPPATH;
            ?>
PushHome/setID?app_id=<?php 
            echo $app->app_id;
            ?>
">Admin Panel</a>
            <?php 
        }
        ?>
            </div>
        </div>

        </div>
        <?php 
        //        pr($app);
    }
 function save()
 {
     $device_id = addslashes($_POST['device_id']);
     $type = addslashes($_POST['type']);
     $app_id = isset($_POST['app_id']) ? addslashes($_POST['app_id']) : 0;
     //completion check
     if ($device_id == "" || $type == "" || $app_id == 0) {
         $json['status_code'] = 0;
         $json['status_message'] = "Incomplete Request";
         echo json_encode($json);
         die;
     }
     $appAcc = new AppAccount();
     $appAcc->getByID($app_id);
     //verify app active
     if ($appAcc->app_active != 2) {
         $json['status_code'] = 0;
         $json['status_message'] = "Please activate App";
         echo json_encode($json);
         die;
     }
     //verify token
     $token = addslashes($_POST['app_token']);
     if ($token != $appAcc->app_token) {
         $json['status_code'] = 0;
         $json['status_message'] = "Token Mismatched";
         echo json_encode($json);
         die;
     }
     //check account..
     $acc = isset($_POST['acc_id']) ? addslashes($_POST['acc_id']) : 0;
     IMBAuth::checkOAuth();
     $dn = new DeviceModel();
     $dnquery = new DeviceModel();
     // langkah 1 , device ID ada device type ada
     $arrs = $dnquery->getWhere("device_id = '{$device_id}' AND device_type = '{$type}' AND dev_app_id = '{$app_id}'");
     $dn = $arrs[0];
     if ($dn->did == "") {
         $dn = new DeviceModel();
         $dn->device_id = $device_id;
         $dn->device_type = $type;
         $dn->acc_id = $acc;
         $dn->firstlogin = leap_mysqldate();
         $dn->dev_app_id = $app_id;
     } else {
         //kalau device id ada, acc di update
         $dn->load = 1;
         $dn->acc_id = $acc;
     }
     $dn->dev_lng = addslashes($_POST['lng']);
     $dn->dev_lat = addslashes($_POST['lat']);
     $dn->logindate = leap_mysqldate();
     if ($dn->save()) {
         $json['save_status'] = 1;
         //logged all device login 19 nov 2015 roy
         //            $logged = new DeviceLogger();
         //            $logged->log_acc_id = $dn->acc_id;
         //            $logged->log_date = leap_mysqldate();
         //            $logged->log_dev_id = $dn->device_id;
         //            $logged->log_dev_type = $dn->device_type;
         //            $logged->save();
     } else {
         $json['save_status'] = 0;
     }
     $json['status_code'] = 1;
     echo json_encode($json);
     die;
 }