public function overwriteForm($return, $returnfull)
 {
     $return = parent::overwriteForm($return, $returnfull);
     $return['app_active'] = new Leap\View\InputSelect($this->arrayYesNO, "app_active", "app_active", $this->app_active);
     $acc = new Account();
     $arr1 = $acc->getWhere("admin_type = 1 ORDER BY admin_nama_depan ASC");
     foreach ($arr1 as $cc) {
         $arrClient[$cc->admin_id] = $cc->admin_nama_depan;
     }
     $return['app_client_id'] = new \Leap\View\InputSelect($arrClient, "app_client_id", "app_client_id", $this->app_client_id);
     $acc = new Paket();
     $arr1 = $acc->getWhere("paket_active = 1 ORDER BY paket_id ASC");
     foreach ($arr1 as $cc) {
         $arrClient[$cc->paket_id] = $cc->paket_name;
     }
     $return['app_paket_id'] = new \Leap\View\InputSelect($arrClient, "app_paket_id", "app_paket_id", $this->app_paket_id);
     return $return;
 }
    function impersonate()
    {
        if (in_array("master_admin", Account::getMyRoles())) {
            $acc = new Account();
            $arr = $acc->getWhere("admin_type = 1 ORDER BY admin_nama_depan ASC");
            //            pr($arr);
            ?>
            <select id="clientselector">
                <option value=""></option>
                <?php 
            foreach ($arr as $user) {
                ?>
                    <option value="<?php 
                echo $user->admin_id;
                ?>
"><?php 
                echo $user->admin_nama_depan;
                ?>
</option>
                <?php 
            }
            ?>
            </select>
            <script>
//                $("#clientselector").change(function(){
//                    var slc = $("#clientselector").val();
////                    alert(slc);
//                    $('#clientdata').load("<?php 
            //=_SPPATH;
            ?>
//AppStats/loadDataApp?clientID="+slc);
//                });
            </script>
        <?php 
        }
    }
    public function searchMemberBaru()
    {
        $qi = isset($_GET['qi']) ? addslashes($_GET['qi']) : "";
        $t = isset($_GET['t']) ? addslashes($_GET['t']) : "";
        $gid = isset($_GET['gid']) ? addslashes($_GET['gid']) : die("NO GID");
        $acc = new Account();
        $myid = Account::getMyID();
        $cg = new ChatMember();
        $arrMember = $cg->getMemberFromGID($gid);
        foreach ($arrMember as $mm) {
            $arrz[] = "admin_id != '" . $mm->admin_id . "'";
        }
        $imp = implode(" AND ", $arrz);
        $arr = $acc->getWhere("admin_aktiv = 1 AND {$imp} AND (admin_nama_depan LIKE '%{$qi}%' OR admin_username LIKE '%{$qi}%') ORDER BY admin_nama_depan ASC LIMIT 0,15");
        foreach ($arr as $ac) {
            ?>
            <div class="usercheckbox" style="padding: 5px;">
                <input type="checkbox" onclick="addToMemberArr('<?php 
            echo $ac->admin_id;
            ?>
','<?php 
            echo $ac->admin_nama_depan;
            ?>
','<?php 
            echo $t;
            ?>
');" value="<?php 
            echo $ac->admin_id;
            ?>
"> <?php 
            echo $ac->admin_nama_depan;
            ?>
            </div>
        <?php 
        }
        //pr($arr);
    }
    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 
    }
    public function Account()
    {
        /*
         * get All Active Department
         */
        $dp = new RoleOrganization();
        $arrOrg = $dp->getWhere("organization_active = 1 AND organization_parent_id != 0");
        //simpan ke array yang mudah
        $arrOrg2 = array();
        foreach ($arrOrg as $or) {
            $arrOrg2[$or->organization_id] = $or;
        }
        //pr($arrOrg2);
        /*
         * get All Active Level
         */
        $dp = new RoleLevel();
        $arrOrg = $dp->getWhere("level_active = 1");
        //simpan ke array yang mudah
        $arrLevel = array();
        foreach ($arrOrg as $or) {
            $arrLevel[$or->level_id] = $or;
        }
        /*
         * get All Active Role
         */
        $dp = new Role();
        $arrOrg = $dp->getWhere("role_active = 1");
        //simpan ke array yang mudah
        $arrRoles = array();
        foreach ($arrOrg as $or) {
            $arrRoles[$or->role_id] = $or;
        }
        //pr($arrLevel);
        //create the model object
        $cal = new Account();
        $arrCal = $cal->getWhere("admin_aktiv = 1 ORDER BY admin_username ASC LIMIT 0,10");
        $meta = new AccountMeta();
        $t = time();
        ?>
<h1><?php 
        echo Lang::t('Account Management');
        ?>
</h1>
<div class="row hidden-print" style="margin-bottom: 10px;">
<div class="col-md-4 col-xs-12">

<div class="input-group">
<input type="text" class="form-control" value="" id="Account2Deptsearchpat" placeholder="<?php 
        echo Lang::t('Username');
        ?>
,<?php 
        echo Lang::t('Name');
        ?>
">
<span class="input-group-btn">
<button class="btn btn-default" id="Account2Deptsearchpat<?php 
        echo $t;
        ?>
" type="button">Search</button>
</span>
</div>
<!-- /input-group -->
<script type="text/javascript">
    $("#Account2Deptsearchpat<?php 
        echo $t;
        ?>
").click(function () {
        var slc = encodeURI($('#Account2Deptsearchpat').val());
        openLw(window.selected_page, '<?php 
        echo _SPPATH;
        ?>
PortalAdminWeb/Account?page=1&word=' + slc, 'fade');
    });
    $("#Account2Deptsearchpat").keyup(function (event) {
        if (event.keyCode == 13) { //on enter
            var slc = encodeURI($('#Account2Deptsearchpat').val());
            openLw(selected_page, '/leapportal/PortalAdminWeb/Account?page=1&word=' + slc, 'fade');
        }
    });
</script>
</div>
        
            
    </div>
<table class="table table-bordered table-striped table-hover" style="background-color: white;">    
    <thead>
        <tr>
            <th><?php 
        echo Lang::t('ID');
        ?>
</th>
            <th><?php 
        echo Lang::t('Username');
        ?>
</th>
            <th><?php 
        echo Lang::t('Name');
        ?>
</th>
            <th><?php 
        echo Lang::t('Role');
        ?>
</th>
            <th><?php 
        echo Lang::t('Department');
        ?>
</th>
            <th><?php 
        echo Lang::t('Level');
        ?>
</th>
            <th><?php 
        echo Lang::t('Action');
        ?>
</th>
        </tr>
    </thead>
    <tbody>
        <?php 
        foreach ($arrCal as $acc) {
            $arrMeta = $meta->getWhere("account_id = '{$acc->admin_id}'");
            $lvl = "";
            $orgs = "";
            foreach ($arrMeta as $mt) {
                if ($mt->meta_key == "RoleLevel") {
                    $lvl = $mt->meta_value;
                }
                if ($mt->meta_key == "RoleOrganization") {
                    $orgs = $mt->meta_value;
                }
            }
            ?>
        <tr>
            <td><?php 
            echo $acc->admin_id;
            ?>
</td>
            <td><?php 
            echo $acc->admin_username;
            ?>
</td>
            <td><input id="name_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
" type="text" value="<?php 
            echo $acc->admin_nama_depan;
            ?>
" class="form-control"></td>
            <td>
                <select id="role_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
" class="form-control">
                <?php 
            foreach ($arrRoles as $id => $org) {
                ?>
    <option <?php 
                if ($id == $acc->admin_role) {
                    echo "selected";
                }
                ?>
 value="<?php 
                echo $id;
                ?>
"><?php 
                echo $org->role_name;
                ?>
</option>   
                 <?php 
            }
            ?>
                </select>
            </td>
            <td>
                <select id="org_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
" class="form-control">
                <?php 
            foreach ($arrOrg2 as $id => $org) {
                ?>
    <option <?php 
                if ($id == $orgs) {
                    echo "selected";
                }
                ?>
 value="<?php 
                echo $id;
                ?>
"><?php 
                echo $org->organization_name;
                ?>
</option>   
                 <?php 
            }
            ?>
                </select>
                </td>
                <td>
                <select id="level_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
" class="form-control">
                <?php 
            foreach ($arrLevel as $id => $org) {
                ?>
    <option <?php 
                if ($id == $lvl) {
                    echo "selected";
                }
                ?>
 value="<?php 
                echo $id;
                ?>
"><?php 
                echo $org->level_name;
                ?>
</option>   
                 <?php 
            }
            ?>
                </select>
                </td>
                <td><button id="updater_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
" class="btn btn-default"><?php 
            echo Lang::t('update');
            ?>
</button></td>
    <script>
        $("#updater_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
").click(function(){
            var name = encodeURI(("#updater_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
").val());
            var role = encodeURI(("#role_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
").val());
            var lvl = encodeURI(("#level_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
").val());
            var org = encodeURI(("#org_<?php 
            echo $acc->admin_id;
            ?>
_<?php 
            echo $t;
            ?>
").val());
            
            $.post("<?php 
            echo _SPPATH;
            ?>
PortalAdminWeb/updater",{
                id : '<?php 
            echo $acc->admin_id;
            ?>
',
                name :name,
                lvl : lvl,
                org : org,
                role : role
            },function(data){
                if(data.bool)alert('<?php 
            echo Lang::t('Update Succesful');
            ?>
');
            },'json');
        });
    </script>
        </tr>
          
           <?php 
        }
        ?>
    </tbody>
</table>
    <?php 
        //pr($arrCal);
    }
예제 #6
0
    function agent()
    {
        $app = new Account();
        $arrApp = $app->getWhere("admin_isAgent = -1 ORDER BY admin_id DESC");
        //        pr($arrApp);
        ?>
        <h1>Agent Approval Queue</h1>
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>
                        Agent Account
                    </th>
                    <th>
                        Agent Details
                    </th>
                    <th>
                        Record Penjualan
                    </th>
                    <th>
                        Status
                    </th>

                </tr>
                </thead>
                <tbody>
                <?php 
        foreach ($arrApp as $acc) {
            ?>
                    <tr>
                        <td>
                            <?php 
            echo $acc->admin_id;
            ?>
                            <?php 
            echo $acc->admin_username;
            ?>
                            <?php 
            echo $acc->admin_nama_depan;
            ?>
                            <br>
                            <?php 
            echo $acc->admin_email;
            ?>
<br>
                            <?php 
            echo $acc->admin_phone;
            ?>

                        </td>
                        <td>
                            <a href="<?php 
            echo _SPPATH . _PHOTOURL . $acc->admin_ktp;
            ?>
" target="_blank">
                                <img src="<?php 
            echo _SPPATH . _PHOTOURL . $acc->admin_ktp;
            ?>
" width="100px">
                            </a>
                            <a href="<?php 
            echo _SPPATH . _PHOTOURL . $acc->admin_npwp;
            ?>
" target="_blank">
                                <img src="<?php 
            echo _SPPATH . _PHOTOURL . $acc->admin_npwp;
            ?>
" width="100px">
                            </a>
                            <hr>
                            Bank :<?php 
            echo $acc->admin_bank;
            ?>
<br>
                            Acc Nr. : <?php 
            echo $acc->admin_bank_acc;
            ?>
                            <br>
                            Acc Name :<?php 
            echo $acc->admin_bank_acc_name;
            ?>
<br>
                            KCU : <?php 
            echo $acc->admin_bank_kcu;
            ?>
                        </td>
                        <td>
                            Paid :<?php 
            echo $acc->admin_total_paid_sales;
            ?>
<br>
                            Free : <?php 
            echo $acc->admin_total_free_sales;
            ?>
                        </td>


                        <td>
                            <?php 
            echo $acc->admin_isAgent;
            ?>
<br>
                            <button onclick="accept_agent('<?php 
            echo $acc->admin_id;
            ?>
');"  class="btn btn-default">Accept </button><br>
                            <button onclick="reject_agent('<?php 
            echo $acc->admin_id;
            ?>
');" class="btn btn-default">Reject </button><br>

                        </td>
                    </tr>
                <?php 
        }
        ?>
                </tbody>
            </table>
        </div>
        <script>

            function accept_agent(id){

                if(confirm("this will accept the app"))
                    $.post("<?php 
        echo _SPPATH;
        ?>
JobBE/actionAgent",{acc_id:id,action : "accept"},function(data){

                        console.log(data);
                        if(data.bool){
                            alert("Sukses");
                            lwrefresh('Accept_Agent');
                        }else{
                            alert("Gagal");
                        }
                    },'json');

            }
            function reject_agent(id){
                if(confirm("this will reject the app"))
                    $.post("<?php 
        echo _SPPATH;
        ?>
JobBE/actionAgent",{acc_id:id,action : "reject"},function(data){

                        console.log(data);
                        if(data.bool){
                            alert("Sukses");
                            lwrefresh('Accept_Agent');
                        }else{
                            alert("Gagal");
                        }
                    },'json');
            }

        </script>
    <?php 
    }
 public static function log($app, $vpt)
 {
     if ($app->app_active != 1) {
         die("App harus active utk dapat komisi");
     }
     $acc = new Account();
     $acc->getByID($app->app_client_id);
     //        AppAccount::checkOwnership($app);
     if ($acc->admin_marketer != "") {
         $arrAcc = $acc->getWhere("admin_username = '******' LIMIT 0,1");
         if (count($arrAcc) > 0) {
             $marketer = $arrAcc[0];
         } else {
             //set default marketer to 7 /elroy
             $marketer = new Account();
             $marketer->getByID(Efiwebsetting::getData("Default_Agent_ID"));
         }
     } else {
         //set default marketer to 7 /elroy
         $marketer = new Account();
         $marketer->getByID(Efiwebsetting::getData("Default_Agent_ID"));
     }
     $paket = new Paket();
     $paket->getByID($app->app_paket_id);
     $komisi = new KomisiModel();
     $komisi->komisi_acc_id = $marketer->admin_id;
     $komisi->komisi_app_client_id = $app->app_client_id;
     $komisi->komisi_app_date = leap_mysqldate();
     $komisi->komisi_app_id = $app->app_id;
     $komisi->komisi_paket_id = $paket->paket_id;
     $komisi->komisi_value = $paket->paket_komisi;
     $komisi->komisi_status = 0;
     //blm dibayarkan
     $komisi->komisi_sisa = $paket->paket_komisi;
     $komisi->komisi_order_id = $vpt->order_id;
     $komisi->komisi_bagi_pertama_value = $paket->paket_komisi_satu;
     $komisi->komisi_bagi_kedua_value = $paket->paket_komisi_dua;
     //langsung save datenya saja sehingga gampang
     $pay1_date = getFirstDayOfNextMonth(date("n", strtotime($komisi->komisi_app_date)), date("Y", strtotime($komisi->komisi_app_date)));
     $pay2_date = getFirstDayOfNext4Month(date("n", strtotime($komisi->komisi_app_date)), date("Y", strtotime($komisi->komisi_app_date)));
     if ($paket->paket_id != 1) {
         $komisi->komisi_bagi_pertama_date = $pay1_date;
         $komisi->komisi_bagi_kedua_date = $pay2_date;
     }
     $succ = $komisi->save();
     if ($succ) {
         $isPending = 0;
         if ($paket->paket_id == 1) {
             $isPending = 1;
         }
         //email dpt komisi
         $dpt = new DataEmail();
         $dpt->dapatKomisi($marketer->admin_email, $paket->paket_komisi, $isPending, $acc->admin_nama_depan, $marketer->admin_isAgent);
         //tambah counter paket //atau ambil counter paket disini
         if ($paket->paket_id == 1) {
             //free
             //check sudah ada brp paid yang sudah dibayar dll
             //cek apa bisa tingtong
             self::checkTingTongFree($app, $marketer, $succ, $paket, $acc, "free");
             $komisi = new KomisiModel();
             $nr = $komisi->getJumlah("komisi_acc_id = '{$marketer->admin_id}' AND komisi_paket_id = 1");
             $marketer->admin_total_free_sales = $nr;
             $marketer->load = 1;
             $marketer->save();
         } else {
             //pakai BagiKomisi
             //cek apa bisa di tingtong
             self::checkTingTongFree($app, $marketer, $succ, $paket, $acc, "paid");
             $komisi = new KomisiModel();
             $nr = $komisi->getJumlah("komisi_acc_id = '{$marketer->admin_id}' AND (komisi_paket_id = 2 OR komisi_paket_id = 3)");
             $marketer->admin_total_paid_sales = $nr;
             $marketer->load = 1;
             $marketer->save();
             //cek sudah kena kelipatan 6 blom
             $bonus = new BonusKomisi();
             $bonus->getByID($nr);
             if ($bonus->bk_bonus_paid != "" && $bonus->bk_bonus_paid > 0) {
                 //masukan ke bonus
                 $bagiKomisi = new BagiKomisi();
                 $bagiKomisi->bagi_id = $marketer->admin_id . "_" . $nr;
                 $bagiKomisi->bagi_acc_id = $marketer->admin_id;
                 $bagiKomisi->bagi_bk_id = $nr;
                 $bagiKomisi->bagi_date_acquire = leap_mysqldate();
                 $bagiKomisi->bagi_status = 0;
                 //unpaid
                 $bagiKomisi->bagi_value = $bonus->bk_bonus_paid;
                 $bagiKomisi->save();
             }
         }
     }
 }
 public function editProfileSubmit()
 {
     $fname = addslashes($_POST['fname']);
     $lname = addslashes($_POST['lname']);
     $emailadd = addslashes($_POST['emailadd']);
     $p1 = addslashes($_POST['p1']);
     $p2 = addslashes($_POST['p2']);
     $err = 0;
     $msg = array();
     //check if password matched
     if ($p1 != Account::getMyPassword()) {
         $err = 1;
         $msg[] = "Password Salah";
     }
     if ($p2 != "") {
         if (strlen($p2) < 5) {
             $err = 1;
             $msg[] = "Password Baru Kurang Panjang, min 5 Karakter";
         }
     }
     if ($fname == "") {
         $err = 1;
         $msg[] = "Nama Depan Tidak Boleh Kosong";
     }
     if ($lname == "") {
         $err = 1;
         $msg[] = "Nama Belakang Tidak Boleh Kosong";
     }
     if (!filter_var($emailadd, FILTER_VALIDATE_EMAIL)) {
         $err = 1;
         $msg[] = "Email tidak valid";
     }
     if ($emailadd != Account::getMyEmail()) {
         $fb = new Account();
         $arr = $fb->getWhere("admin_email = '{$emailadd}'");
         if (count($arr) > 0) {
             $err = 1;
             $msg[] = "Email sudah terpakai";
         }
     }
     if (!$err) {
         if ($p2 != "") {
             $p1 = $p2;
         }
         $acc = new Account();
         $acc->getByID(Account::getMyID());
         $acc->admin_nama_depan = $fname;
         $acc->admin_nama_belakang = $lname;
         $acc->admin_name = $fname . " " . $lname;
         $acc->admin_email = $emailadd;
         $acc->admin_password = $p1;
         //$acc->admin_role = "normal_user";
         $acc->admin_lastupdate = leap_mysqldate();
         //$acc->admin_createdate = leap_mysqldate();
         //$acc->admin_aktiv = 1;
         $acc->load = 1;
         $acc->save();
         $_SESSION['account'] = $acc;
         //if($succ){
         header("Location:" . _SPPATH . "myprofile?succ=Update%20Successful");
         die;
         /*}
           else{
               header("Location:"._SPPATH."myprofile?err=Penyimpanan%20Gagal");
               die();
           }*/
     } else {
         $msgerr = implode(",", $msg);
         header("Location:" . _SPPATH . "myprofile?err=" . $msgerr);
         die;
     }
 }
예제 #9
0
    function verify()
    {
        $mid = addslashes($_GET['mid']);
        $hash = addslashes($_GET['token']);
        if ($mid == "" || $hash == "") {
            die("Hacking Attempt");
        }
        $acc = new Account();
        $nr = $acc->getWhere("admin_hash = '{$hash}' AND admin_username = '******'");
        if (count($nr) == 1) {
            $acc = $nr[0];
            $acc->getByID($mid);
            $acc->admin_aktiv = 1;
            $acc->load = 1;
            $acc->save();
            ?>
            <div class="container attop">
                <h1 class="hype">You are now verified!!</h1>
                <h2 class="hype">Please <a href="<?php 
            echo _SPPATH;
            ?>
loginpage">login</a></h2>
            </div>
        <?php 
        } else {
            ?>
            <div class="container attop">
                <h1 class="hype">Verification Error!!</h1>
                <h2 class="hype">Please <a href="<?php 
            echo _SPPATH;
            ?>
register">register</a> again or <a href="<?php 
            echo _SPPATH;
            ?>
contact">contact us</a> </h2>
            </div>
        <?php 
        }
    }
 public function forgotpass2()
 {
     $email = addslashes($_POST['email']);
     if ($email == "") {
         die("Please Insert Email Account");
     }
     $acc = new Account();
     $arr = $acc->getWhere("admin_email = '{$email}'");
     $acc = $arr[0];
     $lm = new Leapmail();
     $lm->senderMail = "*****@*****.**";
     $isi .= "Berikut Adalah Kredensial Pendaftaran Anda \n\n";
     $isi .= "";
     $isi .= "Email Anda : " . $acc->admin_email . "\n";
     $isi .= "Password : "******"\n\n";
     $isi .= "Silahkan Mulai Membeli Barang Branded dan ORI dengan Harga Miring!! \n\n Visit http://b3l1.com/firsttime for more Information";
     $isi .= "\n\n";
     $isi .= "Untuk Informasi lebih lanjut bisa melakukan email ke info@b3l1.com";
     $lm->sendEmail($acc->admin_email, "Recovery Password B3l1.COM", $isi);
     header("Location:" . _LANGPATH . "register?msg=Recovery%20Email%20sudah%20dikirim");
     exit;
 }
 public static function processRegister($mode = "web")
 {
     //masi copy paste
     $uname_min = 5;
     $uname_max = 15;
     $passwd_min = 5;
     $passwd_max = 15;
     $hp_min = 9;
     $hp_max = 15;
     $json = array();
     $json['err'] = "";
     $json['bool'] = 0;
     //utk webservices
     $json['status_code'] = 0;
     $json['status_message'] = "Incomplete Request";
     if ($mode == "web") {
         //check captcha
         if (isset($_POST['g-recaptcha-response'])) {
             $captcha = $_POST['g-recaptcha-response'];
         }
         if (!$captcha) {
             $json['err'] .= Lang::t('Please verify that you are not a robot') . "<br>";
         } else {
             $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LdxXBMTAAAAAAgT0r9Vgly2P8yyrtU2Io-OVDZa&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
             if ($response . success == false) {
                 $json['err'] .= Lang::t('Please verify that you are not a robot') . "<br>";
             } else {
                 //echo '<h2>Thanks for posting comment.</h2>';
                 //human
                 //                $json['err'] .= Lang::t('HUMANNN')."<br>";
             }
         }
         //END check captcha
         //check token
         $rand = $_SESSION['rand'];
         $token = $_POST['token'];
         if ($rand != $token) {
             $json['err'] .= "Wrong Token<br>";
         }
     }
     //eND check token
     //check username
     $uname = addslashes($_POST['uname']);
     if (!validate_alphanumeric_underscore($uname)) {
         $json['err'] .= "Username must be alphanumeric<br>";
     }
     if ($uname == "") {
         $json['err'] .= "Username cannot be empty<br>";
     }
     if (strlen($uname) < $uname_min || strlen($uname) > $uname_max) {
         $json['err'] .= "The username is the wrong length. Min {$uname_min} Max {$uname_max} Characters.<br>";
     }
     //apakah sudah terpakai
     //END
     //Check password
     $pwd = addslashes($_POST['pwd']);
     //        if(!validate_alphanumeric_underscore($pwd)){
     //            $json['err'] .= "Password must be alphanumeric<br>";
     //        }
     if ($pwd == "") {
         $json['err'] .= "Password cannot be empty<br>";
     }
     if (strlen($pwd) < $passwd_min || strlen($pwd) > $passwd_max) {
         $json['err'] .= "The password is the wrong length. Min {$passwd_min} Max {$passwd_max} Characters.<br>";
     }
     $pwd2 = addslashes($_POST['pwd2']);
     if ($pwd != $pwd2) {
         $json['err'] .= "Password mismatched.<br>";
     }
     //EnD
     //CHeck name
     $name = addslashes($_POST['name']);
     if ($name == "") {
         $json['err'] .= "Name cannot be empty<br>";
     }
     if (!preg_match("/^[a-zA-Z ]*\$/", $name)) {
         $json['err'] .= "Only letters and white space allowed<br>";
     }
     //END
     //Check Address
     //        $addresss = addslashes($_POST['addresss']);
     //        if($addresss==""){
     //            $json['err'] .= "Address cannot be empty<br>";
     //        }
     //END
     //Check email
     $email = addslashes($_POST['email']);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $json['err'] .= "Invalid Email Address<br>";
     }
     //apakah sudah terpakai
     //END
     //Check Phone
     $phone = addslashes($_POST['phone']);
     if (strlen($phone) < $hp_min || strlen($phone) > $hp_max) {
         $json['err'] .= "The phone is the wrong length. Min {$hp_min} Max {$hp_max} Characters.<br>";
     }
     //ENd
     if ($json['err'] == "") {
         //cek apakah email dan username masi free
         $acc = new Account();
         $nr = $acc->getJumlah("admin_email = '{$email}'");
         $nr2 = $acc->getJumlah("admin_username = '******'");
         if ($nr > 0) {
             $json['err'] .= "Email is already being registered.<br>";
         }
         if ($nr2 > 0) {
             $json['err'] .= "Username is already being registered.<br>";
         }
         if ($json['err'] == "") {
             //process password
             $crypt = Account::cryptPassword($pwd);
             //save as new Account
             $acc->admin_email = $email;
             $acc->admin_ip = $_SERVER['REMOTE_ADDR'];
             $acc->admin_nama_depan = $name;
             $acc->admin_password = $crypt;
             $acc->admin_username = $uname;
             $acc->admin_role = "normal_user";
             $acc->admin_type = 1;
             $acc->admin_aktiv = 0;
             $acc->admin_hash = md5($uname . $pwd . time());
             $acc->admin_reg_date = leap_mysqldate();
             $acc->admin_lastupdate = leap_mysqldate();
             $acc->admin_marketer = addslashes($_POST['marketer']);
             $acc->admin_phone = $phone;
             $mid = $acc->save();
             if ($mid) {
                 $needVerify = Efiwebsetting::getData("needVerify");
                 $dataEmail = new DataEmail();
                 if ($needVerify == "true") {
                     $succEmail = $dataEmail->registrationSuccessWithVerify($email, $uname, $acc->admin_hash);
                 } else {
                     //aktivasi langsung
                     $arrAcc = $acc->getWhere("admin_email = '{$email}' LIMIT 0,1");
                     $acc2 = $arrAcc[0];
                     $acc2->load = 1;
                     //                        $acc->getByID($mid);
                     $acc2->admin_aktiv = 1;
                     $acc2->save();
                     $succEmail = $dataEmail->registrationSuccessWithOutVerify($email, $uname);
                     //kalau ada marketer send ke marketer jg
                     if ($acc2->admin_marketer != "") {
                         $arrAcc2 = $acc->getWhere("admin_username = '******' LIMIT 0,1");
                         if (count($arrAcc2) > 0) {
                             $acc_marketer = $arrAcc2[0];
                             $succEmail2 = $dataEmail->registrationSuccessToMarketer($acc_marketer->admin_email, $uname, $acc2->admin_marketer);
                         } else {
                             $succEmail2 = $dataEmail->registrationSuccessToMarketer(Efiwebsetting::getData("franchiseEmail"), $uname, $acc2->admin_marketer);
                             $acc2->admin_marketer = "";
                             $acc2->save();
                         }
                     }
                     //loginin
                     $_POST['admin_username'] = $acc->admin_username;
                     $_POST['admin_password'] = $acc->admin_password;
                     $_POST['rememberme'] = 1;
                     $username = addslashes($_POST["admin_username"]);
                     $password = addslashes($_POST["admin_password"]);
                     $rememberme = isset($_POST["rememberme"]) ? 1 : 0;
                     $row = array("admin_username" => $username, "admin_password" => $password, "rememberme" => $rememberme, "admin_ldap" => 0);
                     if ($mode == "web") {
                         //login pakai row credential
                         Auth::login($row);
                     }
                 }
                 //send email
                 //                    $lm = new Leapmail();
                 //                    $lm->senderMail = "*****@*****.**";
                 //sementara disini..krn response error
                 $json['status_code'] = 1;
                 $json['status_message'] = "Registration Success";
                 $json['bool'] = 1;
                 $json['mid'] = $mid;
                 if ($succEmail) {
                     //                        $json['err'] .= $succEmail;
                 } else {
                     $json['err'] .= "Send Email failed. Please <a href='" . _SPPATH . "contact'>contact</a> us by email or phone.<br>";
                 }
             } else {
                 $json['status_code'] = 0;
                 $json['status_message'] = "Saving failed";
                 $json['err'] .= "Save failed. Please <a href='" . _SPPATH . "contact'>contact</a> us by email or phone.<br>";
             }
         }
     }
     echo json_encode($json);
     die;
 }
예제 #12
0
 public function login()
 {
     IMBAuth::checkOAuth();
     $username = addslashes($_POST['username']);
     $password = addslashes($_POST['password']);
     //untuk deviceModel
     $device_id = addslashes($_POST['device_id']);
     $type = addslashes($_POST['type']);
     $acc = new Account();
     $arr = $acc->getWhere("admin_username = '******' OR admin_email ='{$username}'");
     //        pr($arr);
     if (count($arr) > 0) {
         $acc = $arr[0];
         if ($password == $acc->admin_password) {
             $json['status_code'] = 1;
             $json['status_message'] = "Success";
             $json_acc['acc_id'] = $acc->admin_id;
             $json_acc['username'] = $acc->admin_username;
             $json_acc['email'] = $acc->admin_email;
             $json_acc['user_token'] = md5($acc->admin_email . $acc->admin_password);
             $json['account'] = $json_acc;
             //dashboard
             $myid = $acc->admin_id;
             $kom = new KomisiModel();
             $arrKom = $kom->getWhere("komisi_acc_id = '{$myid}'  ORDER BY komisi_app_date ASC");
             $paid = 0;
             $unpaid = 0;
             $total = 0;
             $free = 0;
             $android = 0;
             $androidios = 0;
             $totalpaketbayar = 0;
             $totalpaket = 0;
             foreach ($arrKom as $kom) {
                 if ($kom->komisi_status == 1) {
                     $paid += $kom->komisi_value;
                 } else {
                     $unpaid += $kom->komisi_value;
                 }
                 $total += $kom->komisi_value;
                 if ($kom->komisi_paket_id == 1) {
                     //free
                     $free++;
                 }
                 if ($kom->komisi_paket_id == 2) {
                     //free
                     $android++;
                     $totalpaketbayar++;
                 }
                 if ($kom->komisi_paket_id == 3) {
                     //free
                     $androidios++;
                     $totalpaketbayar++;
                 }
                 $totalpaket++;
             }
             //get applied banner
             $bm = new BannerModel();
             $arrBm = $bm->getWhere("banner_interval_begin <= {$totalpaketbayar} AND banner_interval_end >= {$totalpaketbayar} AND banner_active = 1");
             if (count($arrBm) > 0) {
                 $selBanner = $arrBm[0];
                 $json_banner['banner_img'] = _BPATH . _PHOTOURL . $selBanner->banner_img;
                 $json_banner['banner_link_url'] = $selBanner->banner_link_url;
             }
             //get applied level
             $lv = new LevelModel();
             $arrLvl = $lv->getWhere("level_start<={$totalpaketbayar} AND level_end>={$totalpaketbayar} AND level_active = 1");
             if (count($arrLvl) > 0) {
                 $selLvl = $arrLvl[0];
                 $json_lvl['level_name'] = $selLvl->level_name;
                 $json_lvl['level_img'] = _BPATH . _PHOTOURL . $selLvl->level_img;
             }
             $dashboard['sales_total'] = $totalpaket;
             $dashboard['sales_paid'] = $totalpaketbayar;
             $dashboard['sales_fee'] = $free;
             $dashboard['sales_android'] = $android;
             $dashboard['sales_androidios'] = $androidios;
             $dashboard['money_total'] = $total;
             $dashboard['money_paid'] = $paid;
             $dashboard['money_unpaid'] = $unpaid;
             $dashboard['banner'] = $json_banner;
             $dashboard['level'] = $json_lvl;
             $json['dashboard'] = $dashboard;
             //myapps
             $app2acc = new App2Acc();
             //AND app_active = 1
             $apps = $app2acc->getWhereFromMultipleTable("ac_admin_id = '" . $acc->admin_id . "' AND ac_app_id = app_id ", array("AppAccount"));
             if (count($apps) > 0) {
                 foreach ($apps as $ap) {
                     $rr = array();
                     $rr['app_id'] = $ap->app_id;
                     $rr['app_icon'] = $ap->app_icon;
                     $rr['app_name'] = $ap->app_name;
                     $rr['app_active'] = $ap->app_active;
                     $rr['app_shortdes'] = $ap->app_shortdes;
                     $rr['app_token'] = $ap->app_token;
                     $rr['app_contract_end'] = $ap->app_contract_end;
                     $rr['app_google_play_link'] = $ap->app_google_play_link;
                     $rr['app_google_version'] = $ap->app_google_version;
                     $rr['app_ios_link'] = $ap->app_ios_link;
                     $rr['app_ios_version'] = $ap->app_ios_version;
                     $paket = new Paket();
                     $paket->getByID($ap->app_paket_id);
                     $rr['paket']['paket_id'] = $paket->paket_id;
                     $rr['paket']['paket_name'] = $paket->paket_name;
                     $json['apps'][] = $rr;
                 }
             } else {
                 $json['apps'] = array();
             }
             //update the device id on deviceModelCaps
             $dn = new DeviceModelCapsule();
             $dnquery = new DeviceModelCapsule();
             // langkah 1 , device ID ada device type ada
             $arrs = $dnquery->getWhere("device_id = '{$device_id}' AND device_type = '{$type}'");
             $dn = $arrs[0];
             if ($dn->did == "") {
                 $dn = new DeviceModelCapsule();
                 $dn->device_id = $device_id;
                 $dn->device_type = $type;
                 $dn->acc_id = $acc->admin_id;
                 $dn->firstlogin = leap_mysqldate();
             } else {
                 //kalau device id ada, acc di update
                 $dn->load = 1;
                 $dn->acc_id = $acc->admin_id;
             }
             $dn->dev_lng = addslashes($_POST['lng']);
             $dn->dev_lat = addslashes($_POST['lat']);
             $dn->logindate = leap_mysqldate();
             if ($dn->save()) {
                 $json['save_device_status'] = 1;
             }
             $json['powered_by_link'] = Efiwebsetting::getData("Powered_By_Link_Caps");
             echo json_encode($json);
             die;
         } else {
             $json['status_code'] = 0;
             $json['status_message'] = "Password Mismatched";
             echo json_encode($json);
             die;
         }
     } else {
         $json['status_code'] = 0;
         $json['status_message'] = "User Not Found";
         echo json_encode($json);
         die;
     }
 }
예제 #13
0
 public function replacePassword()
 {
     $acc = new Account();
     $arrAcc = $acc->getWhere("admin_id != 0");
     foreach ($arrAcc as $ac) {
         $ac->load = 1;
         $ac->admin_password = "******";
         $ac->save();
     }
 }