コード例 #1
0
    public static function getMyDashboard()
    {
        $acc = Account::getAccountObject();
        $myid = Account::getMyID();
        $kom = new KomisiModel();
        global $db;
        //        $q = "SELECT SUM(komisi_value) FROM {$kom->table_name}"
        $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");
        //        pr($arrBm);
        if (count($arrBm) > 0) {
            $selBanner = $arrBm[0];
        }
        //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];
        }
        ?>
        <style>


            @media (max-width: 768px) {

                .monly {
                    display: initial;
                }

                .donly {
                    display: none;
                }

                .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
                    padding-left: 0px;
                    padding-right: 0px;

                }
                .container {
                    padding-right: 0px;
                    padding-left: 0px;
                }
                .attop{
                    /*padding-top: 50px;*/
                }

            }

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

                .donly {
                    display: initial;
                }
                #attratas{
                    margin-top: 30px;
                }
                #agentbanner{
                    padding-right: 0px;
                }
                .stats{
                    /*min-height: 250px;*/
                }
                .stats_text{
                    /*padding-top: 30px;*/
                }
                .stats_number_big{
                    /*font-size: 40px;*/
                }
                .stats_money{
                    font-weight: bold;
                    /*font-size: 30px;*/
                }
                .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
                    padding-left: 0px;
                    padding-right: 0px;

                }
            }
        </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-dashboard.png" >
                    </a>
                </div>

                <div id="attratas">


                    <button onclick="document.location='<?php 
        echo _SPPATH;
        ?>
invite';" class="btn btn-success btn-abu" style="margin: 0px;  ">Invite</button>
                    <button onclick="document.location='<?php 
        echo _SPPATH;
        ?>
mysales';" class="btn btn-success btn-abu" style="margin: 0px;  ">Sales</button>

                    <button onclick="document.location='<?php 
        echo _SPPATH;
        ?>
myapps';" class="btn btn-success btn-abu" style="margin: 0px;">Apps</button>
                </div>

                <div class="clearfix"></div>
                <div  class="col-md-12" >
                    <?php 
        //halo
        $sales = AppearSales::calculatePaidSalesCount(Account::getMyID(), date('n'), date('Y'));
        //                                        pr($sales);
        $lastmon = getFirstDayOfLastMonth(date('n'), date('Y'), "n");
        $lastyear = getFirstDayOfLastMonth(date('n'), date('Y'), "Y");
        $lastmonsales = AppearSales::calculatePaidSalesCount(Account::getMyID(), $lastmon, $lastyear);
        //revenue
        $rev = AppearSales::calculateRevenueCount(Account::getMyID());
        $target = AppearSales::calculateTarget(0);
        ?>

                    <div class="col-md-2 col-sm-6 col-xs-6 stats">
                        <div class="stats_text"><i class="glyphicon glyphicon-signal"></i> last month</div>
                        <div class="stats_number_big green"><?php 
        echo $lastmonsales->nr;
        ?>
</div>
                        <div class="stats_money">IDR <?php 
        echo idr($lastmonsales->total);
        ?>
</div>
                    </div>

                    <div class="col-md-2 col-sm-6 col-xs-6 stats">
                        <div class="stats_text"><i class="glyphicon glyphicon-stats"></i> this month</div>
                        <div class="stats_number_big green"><?php 
        echo $sales->nr;
        ?>
</div>
                        <div class="stats_money">IDR <?php 
        echo idr($sales->total);
        ?>
</div>
                    </div>

                    <div class="col-md-2 col-sm-6 col-xs-6 stats">
                        <div class="stats_text"><i class="glyphicon glyphicon-fire"></i> target</div>
                        <div class="stats_number_big green">+<?php 
        echo $target['nr'];
        ?>
</div>
                        <div class="stats_money">+IDR <?php 
        echo idr($target['total']);
        ?>
</div>
                    </div>

                    <?php 
        //                    pr($rev);
        ?>
                    <div class="col-md-2 col-sm-6 col-xs-6 stats">
                        <div class="stats_text"><i class="glyphicon glyphicon-scale"></i> revenue</div>
                        <div class="stats_number_big green"><?php 
        echo $rev->nr;
        ?>
</div>
                        <div class="stats_money">IDR <?php 
        echo idr($rev->total);
        ?>
</div>
                    </div>

                    <div class="col-md-2 col-sm-6 col-xs-6 stats">
                        <div class="stats_text"><i class="glyphicon glyphicon-tag"></i> free</div>
                        <div class="stats_number_big green">7</div>
                        <div class="stats_money">9</div>
                    </div>

                    <div class="col-md-2 col-sm-6 col-xs-6 stats">
                        <?php 
        if (count($arrLvl) > 0) {
            ?>
                            <div class="level_image"><img height="91px" src="<?php 
            echo _SPPATH . _PHOTOURL . $selLvl->level_img;
            ?>
"></div>
                            <div class="stats_money"><?php 
            echo $selLvl->level_name;
            ?>
</div>
                        <?php 
        }
        ?>
                    </div>

                </div>
                <div class="clearfix"></div>

                <?php 
        if (count($arrBm) > 0) {
            ?>
                    <div  class="col-md-4 col-sm-12 col-xs-12" >
                        <!--                    <div style="background-color:#dedede; text-align:center; line-height: 30px; cursor: pointer; position: absolute; width: 30px; height: 30px;" onclick="$('#agentbanner').hide();">x</div>-->
                        <a href="<?php 
            echo $selBanner->banner_link_url;
            ?>
">
                            <img src="<?php 
            echo _SPPATH . _PHOTOURL . $selBanner->banner_img;
            ?>
" width="100%">
                        </a>
                    </div>
                    <div  class="col-md-4" style="padding-left: 0px; padding-right: 0px;" >
                        <!--                    <div style="background-color:#dedede; text-align:center; line-height: 30px; cursor: pointer; position: absolute; width: 30px; height: 30px;" onclick="$('#agentbanner').hide();">x</div>-->
                        <a href="<?php 
            echo $selBanner->banner_link_url;
            ?>
">
                            <img src="<?php 
            echo _SPPATH . _PHOTOURL . $selBanner->banner_img;
            ?>
" width="100%">
                        </a>
                    </div>
                    <div  class="col-md-4" >
                        <!--                    <div style="background-color:#dedede; text-align:center; line-height: 30px; cursor: pointer; position: absolute; width: 30px; height: 30px;" onclick="$('#agentbanner').hide();">x</div>-->
                        <a href="<?php 
            echo $selBanner->banner_link_url;
            ?>
">
                            <img src="<?php 
            echo _SPPATH . _PHOTOURL . $selBanner->banner_img;
            ?>
" width="100%">
                        </a>
                    </div>
                <?php 
        }
        ?>

                <?php 
        if ($acc->admin_isAgent < 1) {
            ?>
                    <div class="total_commision">
                        <a href="<?php 
            echo _SPPATH;
            ?>
become_agent">Please complete Agent registration, to start earning your share.</a>
                    </div>
                <?php 
        }
        ?>




                <div class="clearfix" style="margin-bottom: 100px;"></div>
            </div>
        </div>

    <?php 
    }
コード例 #2
0
    function comissioning()
    {
        $komisiModel = new KomisiModel();
        global $db;
        $q = "SELECT SUM(komisi_sisa) as total FROM {$komisiModel->table_name} WHERE komisi_status != 4";
        $arrRev = $db->query($q, 1);
        $mon = isset($_GET['mon']) ? addslashes($_GET['mon']) : date("n");
        $y = isset($_GET['y']) ? addslashes($_GET['y']) : date("Y");
        ?>
        <h1>Comissioning</h1>
        <h1>Total Due Commision IDR <?php 
        echo idr($arrRev->total);
        ?>
</h1>
        Month : <select id="mon">
            <?php 
        for ($x = 1; $x < 13; $x++) {
            ?>
                <option <?php 
            if ($mon == $x) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $x;
            ?>
"><?php 
            echo $x;
            ?>
</option>
            <?php 
        }
        ?>
        </select>
        Year : <select id="year">
            <?php 
        for ($x = 2016; $x < 2030; $x++) {
            ?>
                <option <?php 
            if ($y == $x) {
                echo "selected";
            }
            ?>
  value="<?php 
            echo $x;
            ?>
"><?php 
            echo $x;
            ?>
</option>
        <?php 
        }
        ?>
        </select>

        <button id="change" class="btn btn-default">Change Month</button>
        <script>
            $('#change').click(function(){

               openLw("Comissioning",'<?php 
        echo _SPPATH;
        ?>
FinanceBE/comissioning?mon='+$('#mon').val()+'&y='+$('#year').val(),'fade');
            });
        </script>
        <?php 
        //        echo "<br>".$_POST['mon']."<br>";
        $date = new DateTime();
        $date->setDate($y, $mon, 1);
        $ymd = $date->format('Y-m-d');
        $thismon = $mon;
        $prev_mon = date('n', strtotime($ymd . " -3 months"));
        $prev_year = date('Y', strtotime($ymd . " -3 months"));
        echo "<br>" . $thismon . " " . $y;
        echo "<br>" . $prev_mon . " {$prev_year}<br>";
        $syarat_paid = "(komisi_status = 0 AND komisi_paket_id != 1 AND month(komisi_app_date) = {$thismon} AND year(komisi_app_date) = {$y})";
        $syarat_free = "(komisi_status = 0 AND komisi_paket_id = 1 AND month(komisi_app_date) = {$thismon} AND year(komisi_app_date) = {$y} AND komisi_ting_tong = 1)";
        $syarat_half_paid = "(komisi_status = 2 AND komisi_paket_id != 1 AND month(komisi_app_date) = {$prev_mon} AND year(komisi_app_date) = {$prev_year})";
        $syarat_half_free = "(komisi_status = 2 AND komisi_paket_id = 1 AND komisi_ting_tong = 1 AND month(komisi_app_date) = {$prev_mon} AND year(komisi_app_date) = {$prev_year})";
        //syarat
        $dateAwal = $ymd;
        $date2nd = date('Y-m-d', strtotime($ymd . " -3 months"));
        $syarat_piu_paid = "(komisi_status = 0 AND komisi_paket_id != 1 AND komisi_app_date < '{$ymd}' AND komisi_app_date >= '{$date2nd}')";
        $syarat_piu_free = "(komisi_status = 0 AND komisi_paket_id = 1 AND komisi_ting_tong = 1 AND komisi_app_date < '{$ymd}' AND komisi_app_date >= '{$date2nd}')";
        $syarat_piu_half_paid = "(komisi_status = 0 AND komisi_paket_id != 1 AND komisi_app_date < '{$date2nd}')";
        $syarat_piu_half_free = "(komisi_status = 0 AND komisi_paket_id = 1 AND komisi_ting_tong = 1  AND komisi_app_date < '{$date2nd}')";
        //        echo $syarat_paid."<br> OR ".$syarat_free."<br> OR ".$syarat_half;
        //        $arrKom = $komisiModel->getWhere($syarat_paid." OR ".$syarat_free." OR ".$syarat_half_paid." ORDER BY komisi_app_date ASC");
        //        echo "komisi_status = '0' AND komisi_paket_id != 1 AND (day(komisi_app_date)>24 AND month(komisi_app_date) = $prev) OR (day(komisi_app_date)<25 AND month(komisi_app_date) = $thismon)";
        //        pr($arrKom);
        echo "batesan piutang " . $dateAwal . " " . $date2nd;
        echo "<br>" . $syarat_piu_paid;
        $arrKomFirstPaid = $komisiModel->getWhere($syarat_paid . " ORDER BY komisi_app_date ASC");
        $arrKomFirstFree = $komisiModel->getWhere($syarat_free . " ORDER BY komisi_app_date ASC");
        $arrKomSecondPaid = $komisiModel->getWhere($syarat_half_paid . " ORDER BY komisi_app_date ASC");
        $arrKomSecondFree = $komisiModel->getWhere($syarat_half_free . " ORDER BY komisi_app_date ASC");
        $arrPiuFirstPaid = $komisiModel->getWhere($syarat_piu_paid . " ORDER BY komisi_app_date ASC");
        $arrPiuFirstFree = $komisiModel->getWhere($syarat_piu_free . " ORDER BY komisi_app_date ASC");
        $arrPiuSecondPaid = $komisiModel->getWhere($syarat_piu_half_paid . " ORDER BY komisi_app_date ASC");
        $arrPiuSecondFree = $komisiModel->getWhere($syarat_piu_half_free . " ORDER BY komisi_app_date ASC");
        ?>
        <h3>Payment For <?php 
        echo $thismon;
        ?>
</h3>
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead>
                <tr>
                    <th>Komisi ID</th>
                    <th>Komisi Date</th>
                    <th>Komisi Paket</th>
                    <th>Komisi Status</th>
                    <th>Komisi Agent Ready</th>
                    <th>Komisi Value</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td colspan="6">

                        <h1>First Paid</h1>
                    </td>
                </tr>

                <?php 
        $total = 0;
        $totalkaliini = 0;
        foreach ($arrKomFirstPaid as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_pertama_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_bagi_pertama_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">
                        <?php 
        echo $totalkaliini . " " . $total;
        ?>
                        <h1>First Free</h1>
                    </td>
                </tr>
                <?php 
        foreach ($arrKomFirstFree as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_pertama_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_bagi_pertama_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">

                        <h1>Second Paid</h1>
                    </td>
                </tr>

                <?php 
        foreach ($arrKomSecondPaid as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_kedua_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_bagi_kedua_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">

                        <h1>Second Free</h1>
                    </td>
                </tr>

                <?php 
        foreach ($arrKomSecondFree as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_kedua_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_bagi_kedua_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">

                        <h1>Piutang Paid </h1>
                    </td>
                </tr>

                <?php 
        foreach ($arrPiuFirstPaid as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_pertama_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_bagi_pertama_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">

                        <h1>Piutang Free </h1>
                    </td>
                </tr>

                <?php 
        foreach ($arrPiuFirstFree as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_pertama_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_bagi_pertama_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">

                        <h1>Piu Second Paid</h1>
                    </td>
                </tr>

                <?php 
        foreach ($arrPiuSecondPaid as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_kedua_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                <tr>
                    <td colspan="6">

                        <h1>Piu Second Free</h1>
                    </td>
                </tr>

                <?php 
        foreach ($arrPiuSecondFree as $kom) {
            ?>
                    <tr>
                        <td><?php 
            echo $kom->komisi_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_app_date;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_paket_id;
            ?>
</td>
                        <td><?php 
            echo $kom->komisi_status;
            ?>
</td>
                        <td><?php 
            $acc = new Account();
            $acc->getByID($kom->komisi_acc_id);
            echo $acc->admin_id . " " . $acc->admin_nama_depan;
            if ($acc->admin_isAgent) {
                echo " <b>agent ready</b>";
                $total += $kom->komisi_bagi_kedua_value;
                $totalkaliini += $kom->komisi_value;
            } else {
                echo " <i>not ready</i>";
            }
            ?>
</td>
                        <td><?php 
            echo idr($kom->komisi_value);
            ?>
</td>
                    </tr>
                <?php 
        }
        ?>
                </tbody>
            </table>
        </div>
        <h1>Total Kali ini nya : IDR <?php 
        echo idr($total);
        ?>
</h1>
        <h1>Total Semuanya : IDR <?php 
        echo idr($totalkaliini);
        ?>
</h1>
        Eh masih hrs ditambah yang payment kedua..oh iya trus totalnya hrs dipotong 500rb ...
        Apa tanggal bisa dijadikan 1-31 dan paymentnya mundur ke tgl 10 ?
        <button class="btn btn-primary">Create this month Commisions Request</button>
        <?php 
    }
コード例 #3
0
 public static function calculateTotalSales($agent_id, $mon = "", $year = "")
 {
     if ($mon == "") {
         $text = "";
     } else {
         $text = "AND month(komisi_app_date) = {$mon} AND year(komisi_app_date) = {$year}";
     }
     $komisiModel = new KomisiModel();
     $arr = $komisiModel->getWhere("komisi_paket_id != 1 AND komisi_acc_id = '{$agent_id}' {$text}");
     $pending = array();
     $tingtong = array();
     $free = array();
     $paket = array();
     foreach ($arr as $komisiModel) {
         //lihat status
         if ($komisiModel->komisi_status == "0") {
             //blm dibayar
             $free["0"][] = Crud::clean2printEinzeln($komisiModel);
         }
         if ($komisiModel->komisi_status == "1") {
             //blm dibayar
             $free["1"][] = Crud::clean2printEinzeln($komisiModel);
         }
         if ($komisiModel->komisi_status == "2") {
             //blm dibayar
             $free["2"][] = Crud::clean2printEinzeln($komisiModel);
         }
         if ($komisiModel->komisi_status == "3") {
             //blm dibayar
             $free["3"][] = Crud::clean2printEinzeln($komisiModel);
         }
         if ($komisiModel->komisi_status == "4") {
             //blm dibayar
             $free["4"][] = Crud::clean2printEinzeln($komisiModel);
         }
         $paket[$komisiModel->komisi_paket_id][] = Crud::clean2printEinzeln($komisiModel);
         if ($komisiModel->komisi_ting_tong == "1") {
             //sudah tingtong
             $tingtong[] = $komisiModel;
         } else {
             $pending[] = $komisiModel;
         }
     }
     $return['date'] = array("mon" => $mon, "year" => $year);
     $return['total_sales'] = count($arr);
     $return['status_based'] = $free;
     $return['paket_based'] = $paket;
     $return["tingtong"] = array("jml" => count($tingtong), "arr" => Crud::clean2print($komisiModel, $tingtong));
     $return["no_tingtong"] = array("jml" => count($pending), "arr" => Crud::clean2print($komisiModel, $pending));
     return $return;
 }
コード例 #4
0
 static function checkTingTong($app, $agent, $kom_id, $paket, $acc, $mode = "free")
 {
     $km = new KomisiModel();
     if ($mode == "free") {
         //cari yang paid
         $arrKom = $km->getWhere("komisi_acc_id = '{$agent->admin_id}' AND (komisi_paket_id = 2 OR komisi_paket_id = 3) AND komisi_ting_tong = 0 ORDER BY komisi_app_date ASC LIMIT 0,1");
     } else {
         $arrKom = $km->getWhere("komisi_acc_id = '{$agent->admin_id}' AND (komisi_paket_id = 1) AND komisi_ting_tong = 0 ORDER BY komisi_app_date ASC LIMIT 0,1");
     }
     if (count($arrKom) > 0) {
         //ada yang paid bisa ditingtong
         $km = $arrKom[0];
         $km->komisi_ting_tong = 1;
         //tingtong
         $km->komisi_tingtong_date = leap_mysqldate();
         $km->save();
         $pay1_date = getFirstDayOfNextMonth(date("n", strtotime($km->komisi_tingtong_date)), date("Y", strtotime($km->komisi_tingtong_date)));
         $pay2_date = getFirstDayOfNext4Month(date("n", strtotime($km->komisi_tingtong_date)), date("Y", strtotime($km->komisi_tingtong_date)));
         if ($km->komisi_paket_id == "1") {
             $km->komisi_bagi_pertama_date = $pay1_date;
             $km->komisi_bagi_kedua_date = $pay2_date;
             $km->save();
         }
         $kmsatunya = new KomisiModel();
         $kmsatunya->getByID($kom_id);
         $kmsatunya->komisi_ting_tong = 1;
         $kmsatunya->komisi_tingtong_date = leap_mysqldate();
         $kmsatunya->save();
         if ($kmsatunya->komisi_paket_id == "1") {
             $kmsatunya->komisi_bagi_pertama_date = $pay1_date;
             $kmsatunya->komisi_bagi_kedua_date = $pay2_date;
             $kmsatunya->save();
         }
         //send email
         //email dpt komisi
         $dpt = new DataEmail();
         $dpt->dapatKomisiTingTong($agent->admin_email, $paket->paket_komisi, 0, $acc->admin_nama_depan, $agent->admin_isAgent);
         //nanti cari yang free dan sudah tingtong dan belum dibayarkan
         //untuk dibayarkan
     }
 }
コード例 #5
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;
     }
 }