function isiCart()
 {
     $json['bool'] = 0;
     $totalplusdiskon = addslashes($_POST['totalplusdiskon']);
     $total = addslashes($_POST['total']);
     $diskon = addslashes($_POST['diskon']);
     $arr = CartWeb::myCart();
     $mm = new MTranDetail();
     $mm->detail_date = leap_mysqldate();
     $mm->detail_diskon = $diskon;
     $mm->detail_price = $total;
     $mm->detail_price_total = $totalplusdiskon;
     if (MemberLogin::isLogged()) {
         $mm->detail_macc_id = MemberLogin::getID();
     }
     $mm->detail_ses_id = session_id();
     $mm->detail_qty = CartWeb::totalCart();
     if ($mm->save()) {
         foreach ($arr as $obj) {
             $obj->status = 2;
             $obj->load = 1;
             $obj->save();
             //update bought
             $mprod = new MProdModel();
             $mprod->getByID($obj->variant_id);
             $mprod->updateBought();
         }
         session_regenerate_id();
         $json['bool'] = 1;
     }
     //if sukses
     echo json_encode($json);
     die;
 }
    static function graph()
    {
        $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 MTranDetail();
        $arrUserNew = $ll->getWhere("(detail_date BETWEEN '{$days_ago}' AND '{$days_now}')");
        //    //new device
        //    $dev = new DeviceModel();
        //    $arrDevNew = $dev->getWhere(" (firstlogin BETWEEN '$days_ago' AND '$days_now') ");
        //
        //    //device active
        //    $dlog = new DeviceLogger();
        //    global $db;
        //    $q ="SELECT DISTINCT log_dev_id FROM {$dlog->table_name} WHERE (log_date BETWEEN '$days_ago' AND '$days_now')";
        ////        $arrDevActive = $db->query($q,2);
        //    $arrDevActive = $dlog->getWhere(" (log_date BETWEEN '$days_ago' AND '$days_now') ");
        //
        ////        count($arrDevActive);
        //    //user active
        //
        //    $acclog = new LL_AccountLogger();
        //    $q ="SELECT DISTINCT log_acc_id	 FROM {$acclog->table_name} WHERE (log_date BETWEEN '$days_ago' AND '$days_now')";
        ////        $arrUserActive= $db->query($q,2);
        //    $arrUserActive = $acclog->getWhere("(log_date BETWEEN '$days_ago' AND '$days_now')");
        //        count($arrUserActive);
        $arrStats["Orders"] = $arrUserNew;
        //    $arrStats["Active Users"] = $arrUserActive;
        //    $arrStats["New Devices"] = $arrDevNew;
        //    $arrStats["Active Devices"] = $arrDevActive;
        $t = time();
        $mtrans = new MTranDetail();
        global $db;
        $q = "SELECT SUM(detail_price_total) as total, COUNT(*) AS num FROM {$mtrans->table_name}";
        $arrSales = $db->query($q, 1);
        ?>


            <div class="box-header with-border">
                <h3 class="box-title">Monthly Recap Report</h3>

                <div class="box-tools pull-right">
                    <?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;
        ?>
Mdashboard/main?m="+slc,"fade");
                        });
                    </script>
                </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <div class="row">
                    <div class="col-md-8">
                        <p class="text-center">
                            <strong>Sales: <?php 
        echo $bulan;
        ?>
</strong>
                        </p>

                        <div class="chart">
                            <!-- Sales Chart Canvas -->
                            <?php 
        $data = self::getAppStats($arrStats, $days_ago, $days_now);
        ?>
                        </div>
                        <!-- /.chart-responsive -->
                    </div>
                    <!-- /.col -->
                    <div class="col-md-4">
                        <p class="text-center">
                            <strong>Goal Completion</strong>
                        </p>

                        <div class="progress-group">
                            <span class="progress-text">Add Products to Cart</span>
                            <span class="progress-number"><b>160</b>/200</span>

                            <div class="progress sm">
                                <div class="progress-bar progress-bar-aqua" style="width: 80%"></div>
                            </div>
                        </div>
                        <!-- /.progress-group -->
                        <div class="progress-group">
                            <span class="progress-text">Complete Purchase</span>
                            <span class="progress-number"><b>310</b>/400</span>

                            <div class="progress sm">
                                <div class="progress-bar progress-bar-red" style="width: 80%"></div>
                            </div>
                        </div>
                        <!-- /.progress-group -->
                        <div class="progress-group">
                            <span class="progress-text">Visit Premium Page</span>
                            <span class="progress-number"><b>480</b>/800</span>

                            <div class="progress sm">
                                <div class="progress-bar progress-bar-green" style="width: 80%"></div>
                            </div>
                        </div>
                        <!-- /.progress-group -->
                        <div class="progress-group">
                            <span class="progress-text">Send Inquiries</span>
                            <span class="progress-number"><b>250</b>/500</span>

                            <div class="progress sm">
                                <div class="progress-bar progress-bar-yellow" style="width: 80%"></div>
                            </div>
                        </div>
                        <!-- /.progress-group -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- ./box-body -->
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-3 col-xs-6">
                        <div class="description-block border-right">
                            <span class="description-percentage text-green"><i class="fa fa-caret-up"></i> 17%</span>
                            <h5 class="description-header">IDR <?php 
        echo idr($arrSales->total);
        ?>
</h5>
                            <span class="description-text">TOTAL REVENUE</span>
                        </div>
                        <!-- /.description-block -->
                    </div>
                    <!-- /.col -->
                    <div class="col-sm-3 col-xs-6">
                        <div class="description-block border-right">
                            <span class="description-percentage text-yellow"><i class="fa fa-caret-left"></i> 0%</span>
                            <h5 class="description-header">IDR <?php 
        echo idr($arrSales->total / $arrSales->num);
        ?>
</h5>
                            <span class="description-text">AVERAGE ORDER</span>
                        </div>
                        <!-- /.description-block -->
                    </div>
                    <!-- /.col -->
                    <div class="col-sm-3 col-xs-6">
                        <div class="description-block border-right">
                            <span class="description-percentage text-green"><i class="fa fa-caret-up"></i> 20%</span>
                            <h5 class="description-header">$24,813.53</h5>
                            <span class="description-text">MONTHLY REVENUE</span>
                        </div>
                        <!-- /.description-block -->
                    </div>
                    <!-- /.col -->
                    <div class="col-sm-3 col-xs-6">
                        <div class="description-block">
                            <span class="description-percentage text-red"><i class="fa fa-caret-down"></i> 18%</span>
                            <h5 class="description-header">1200</h5>
                            <span class="description-text">MONTHLY ATV</span>
                        </div>
                        <!-- /.description-block -->
                    </div>
                </div>
                <!-- /.row -->
            </div>
            <!-- /.box-footer -->




    <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;
        }
        .description-block>.description-header{
            font-size: 25px;
        }
    </style>

<?php 
    }
    function transaction()
    {
        $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)));
        $t = time();
        //get average transaction value
        //latest transaction
        //max transaction
        //min transaction
        //most buyed products
        //most viewed products
        //        $tt = new LL_AccStatement();
        //        $arrTt = $tt->getWhere("Cash_Value > 0 AND (TransactionDateTime BETWEEN '$days_ago' AND '$days_now') ORDER BY TransactionDateTime DESC");
        $ll = new MTranDetail();
        $arrTt = $ll->getWhere("(detail_date BETWEEN '{$days_ago}' AND '{$days_now}')");
        $value = 0;
        foreach ($arrTt as $tts) {
            $value += $tts->detail_price_total;
        }
        $atv = $value / count($arrTt);
        $arrStats['Orders'] = $arrTt;
        //        pr($arrTt);
        //        echo $atv;
        ?>
<div class="row">
        <div class="col-md-12">
            <h1>
                Transaction 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("Transaction","<?php 
        echo _SPPATH;
        ?>
BIWebTransaction/transaction?m="+slc,"fade");
                        });
                    </script>
                </li>
            </ol>
        </div>
        </div>

        <div class="row">
            <div class="col-md-3">
                <div class="small-box bg-red">
                    <div class="inner">
                        <?php 
        $mtrans = new MTranDetail();
        global $db;
        $q = "SELECT SUM(detail_price_total) as total, COUNT(*) AS num FROM {$mtrans->table_name}";
        $arrTotal = $db->query($q, 1);
        ?>
                        <h3><small style="color: white;font-weight: bold;"><?php 
        echo idr($arrTotal->total);
        ?>
</small></h3>
                        <p>Lifetime Sales</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-aqua">
                    <div class="inner">
                        <h3><small style="color: white;font-weight: bold;"><?php 
        echo idr($atv);
        ?>
</small></h3>
                        <p>Average Transaction Value</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><small style="color: white;font-weight: bold;"><?php 
        echo idr($value);
        ?>
</small></h3>

                        <p>Total Transactions</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($arrTt);
        ?>
</h3>

                        <p>Number of Transactions</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">Transaction 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 = BIPenjualan::getAppStats($arrStats, $days_ago, $days_now);
        //                        $data = self::getAppStats($arrStats,$days_ago,$days_now);
        ?>


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

        </div>

        <?php 
        //latest transactions
        $tt = new MTranDetail();
        $arrTtNew = $tt->getWhere("(detail_date BETWEEN '{$days_ago}' AND '{$days_now}') ORDER BY detail_date DESC LIMIT 0,10");
        ?>
        <div class="row">
            <div class="col-md-6">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">Latest Transactions</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>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <div class="table-responsive">
                            <table class="table no-margin">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Date</th>
                                    <th>Discount</th>
                                    <th>SubTotal</th>
                                    <th>Total</th>

                                </tr>
                                </thead>
                                <tbody>
                                <?php 
        foreach ($arrTtNew as $tt) {
            ?>
                                <tr>
                                    <td><?php 
            echo $tt->detail_id;
            ?>
</td>
                                    <td><?php 
            echo date("d-m-Y", strtotime($tt->detail_date));
            ?>
</td>
                                    <td><?php 
            echo idr($tt->detail_diskon);
            ?>
</td>
                                    <td><?php 
            echo idr($tt->detail_price);
            ?>
</td>
                                    <td><?php 
            echo idr($tt->detail_price_total);
            ?>
</td>

                                </tr>
                                <?php 
        }
        ?>

                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix">

                        <a href="javascript:openLw('Transaction_Detail', '<?php 
        echo _SPPATH;
        ?>
Msales/MTranDetail', 'fade');
                                activkanMenuKiri('Transaction_Detail');" class="btn btn-sm btn-default btn-flat pull-right">View All Transactions</a>
                    </div>
                    <!-- /.box-footer -->
                </div>
            </div>
            <?php 
        $arrSales = array();
        $prods = array();
        //calculate top products based on sales
        $lltt = new CartPortal();
        global $db;
        $q = "SELECT variant_id,COUNT(*) as count FROM {$lltt->table_name} WHERE (date_updated BETWEEN '{$days_ago}' AND '{$days_now}') GROUP BY variant_id ORDER BY count DESC LIMIT 0,10";
        $arrSales2 = $db->query($q, 2);
        //            pr($arrSales2);
        foreach ($arrSales2 as $pp) {
            $prod = new MProdModel();
            $prod->getByID($pp->variant_id);
            $pp->prod = $prod;
        }
        //            pr($arrSales2);
        //            $arrProd =  $lltt->getWhereFromMultipleTable("(date_updated BETWEEN '$days_ago' AND '$days_now') AND VariantID = detail_varian_id ");
        //
        //            foreach($arrTt as $tt){
        //                $arrProd = $lltt->getWhereFromMultipleTable("detail_trans_id = ".$tt->TransactionID." AND VariantID = detail_varian_id ",array("LL_Article_WImage"));
        //
        ////                pr($arrProd);
        //                foreach($arrProd as $prod){
        //                    $arrSales[$prod->VariantID] += $prod->detail_price_total;
        //                    $prods[$prod->VariantID] = $prod;
        //                }
        //            }
        //
        //            arsort($arrSales);
        //            $arrSales = array_reverse($arrSales);
        //            pr($arrSales);
        ?>
            <div class="col-md-6">
                <div class="box box-success">
                    <div class="box-header with-border">
                        <h3 class="box-title">Top Products</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>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <div class="table-responsive">
                            <table class="table no-margin">
                                <thead>
                                <tr>
                                    <th>ID</th>
<!--                                    <th>Picture</th>-->
                                    <th>Name</th>
                                    <th>Qty</th>
                                    <th>Value</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php 
        foreach ($arrSales2 as $varid => $saledata) {
            //                                    if($varid == '2887')continue;
            ?>
                                <tr>
                                    <td><?php 
            echo $saledata->variant_id;
            ?>
</td>

<!--                                    <td>--><?php 
            //=$prods[$varid]->BaseArticleImageFile;
            ?>
<!--</td>-->
                                    <td><?php 
            echo $saledata->prod->BaseArticleNameENG;
            ?>
</td>
                                    <td><?php 
            echo $saledata->count;
            ?>
</td>
                                    <td>
                                        <?php 
            echo idr($saledata->count * $saledata->prod->SellingPrice);
            ?>
                                    </td>
                                </tr>
                                <?php 
        }
        ?>

                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
<!--                     /.box-body-->
                    <div class="box-footer clearfix">
<!--                        <a href="javascript::;" class="btn btn-sm btn-info btn-flat pull-left">Place New Order</a>-->
                        <a href="javascript:openLw('LL_Article', '<?php 
        echo _SPPATH;
        ?>
LLProdWeb/LL_Article_WImage', 'fade');
                                activkanMenuKiri('LL_Article');" class="btn btn-sm btn-default btn-flat pull-right">View All Articles</a>
                    </div>
                    <!-- /.box-footer -->
                </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;
            }
            .users-list-name{
                white-space: nowrap;
            }
        </style>
    <?php 
    }
    function main()
    {
        $mtrans = new MTranDetail();
        //        global $db;
        //        $q = "SELECT SUM(detail_price_total) as total, COUNT(*) AS num FROM {$mtrans->table_name}";
        //        $arr = $db->query($q,1);
        //        pr($arr);
        $arrOrder = $mtrans->getOrderBy(" detail_date DESC LIMIT 0,5");
        //        pr($arrOrder);
        ?>

        <h1 style="margin-top: 0;">Dashboard</h1>
        <div class="penjualan_container">
        <?php 
        BIPenjualan::graph();
        ?>
        </div>

        <div class="row">
            <div class="col-md-6" style="padding-top: 20px;">
                <div class="penjualan_container">

                    <h2 class="penjualan_money_h2">Lifetime Sales</h2>
                    <table class="table no-margin">
                        <thead>
                        <tr>
                            <th>Order ID</th>
                            <th>Item</th>
                            <th>Status</th>
                            <th>Popularity</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR9842</a></td>
                            <td>Call of Duty IV</td>
                            <td><span class="label label-success">Shipped</span></td>
                            <td>
                                <div class="sparkbar" data-color="#00a65a" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR1848</a></td>
                            <td>Samsung Smart TV</td>
                            <td><span class="label label-warning">Pending</span></td>
                            <td>
                                <div class="sparkbar" data-color="#f39c12" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR7429</a></td>
                            <td>iPhone 6 Plus</td>
                            <td><span class="label label-danger">Delivered</span></td>
                            <td>
                                <div class="sparkbar" data-color="#f56954" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR7429</a></td>
                            <td>Samsung Smart TV</td>
                            <td><span class="label label-info">Processing</span></td>
                            <td>
                                <div class="sparkbar" data-color="#00c0ef" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR1848</a></td>
                            <td>Samsung Smart TV</td>
                            <td><span class="label label-warning">Pending</span></td>
                            <td>
                                <div class="sparkbar" data-color="#f39c12" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR7429</a></td>
                            <td>iPhone 6 Plus</td>
                            <td><span class="label label-danger">Delivered</span></td>
                            <td>
                                <div class="sparkbar" data-color="#f56954" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        <tr>
                            <td><a href="pages/examples/invoice.html">OR9842</a></td>
                            <td>Call of Duty IV</td>
                            <td><span class="label label-success">Shipped</span></td>
                            <td>
                                <div class="sparkbar" data-color="#00a65a" data-height="20"><canvas width="34" height="20" style="display: inline-block; width: 34px; height: 20px; vertical-align: top;"></canvas></div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="row">
        <div class="col-md-3">
            <div class="penjualan_container">
            <div class="penjualan">
                <h2 class="penjualan_money_h2">Lifetime Sales</h2>
                <div class="penjualan_money" style="color: #e2007a;">IDR <?php 
        echo idr($arr->total);
        ?>
</div>
            </div>

            <div class="penjualan">
                <h2 class="penjualan_money_h2">Average Order</h2>
                <div class="penjualan_money">IDR <?php 
        echo idr($arr->total / $arr->num);
        ?>
</div>
            </div>
            <hr>

                <div class="penjualan">
                    <h2 class="penjualan_money_h2" style="margin-bottom: 10px;">Latest Transactions</h2>
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>Customer</th>
<!--                            <th>Qty</th>-->
                            <th>Total</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
        foreach ($arrOrder as $order) {
            ?>
                                <tr>
                                    <td><?php 
            if ($order->detail_macc_id > 0) {
                $llac = new LL_Account();
                $llac->getByID($order->detail_macc_id);
                echo $llac->macc_first_name;
            } else {
                echo "unknown";
            }
            ?>
</td>
<!--                                    <td>--><?php 
            //=$order->detail_qty;
            ?>
<!--</td>-->
                                    <td>IDR <?php 
            echo idr($order->detail_price_total);
            ?>
</td>
                                </tr>
                                <?php 
        }
        ?>
                        </tbody>
                    </table>
                </div>
                <hr>
                <div class="penjualan">
                    <h2 class="penjualan_money_h2" style="margin-bottom: 20px;">Last Search Terms</h2>
                    <?php 
        $sL = new MSearchLog();
        $arrSl = $sL->getOrderBy("slog_date DESC LIMIT 0,30");
        if (count($arrSl) > 0) {
            $slsudah = array();
            ?>
                        <table class="table table-striped"><?php 
            foreach ($arrSl as $sll) {
                if (!in_array($sll->slog_keyword, $slsudah)) {
                    $slsudah[] = $sll->slog_keyword;
                    ?>
                                <tr>
                                    <td>
                                        <div class="searchkeyword"><?php 
                    echo $sll->slog_keyword;
                    ?>
</div>
                                    </td>
                                </tr>

                            <?php 
                }
            }
            ?>
</table><?php 
        } else {
            ?>
                        <p>We couldn't find any records.</p>
                        <?php 
        }
        ?>
                </div>
                <hr>
                <div class="penjualan">
                    <h2 class="penjualan_money_h2" style="margin-bottom: 20px;">Top Search Terms</h2>
                    <?php 
        $sL = new MSearchLog();
        global $db;
        $q = "SELECT slog_keyword,COUNT(*) as count FROM {$sL->table_name} GROUP BY slog_keyword ORDER BY count DESC LIMIT 0,10";
        $arrSl = $db->query($q, 2);
        //                    pr($arrSl);
        //                    $arrSl = $sL->getOrderBy("slog_date DESC LIMIT 0,30");
        if (count($arrSl) > 0) {
            $slsudah = array();
            ?>
                        <table class="table table-striped"><?php 
            foreach ($arrSl as $sll) {
                if (!in_array($sll->slog_keyword, $slsudah)) {
                    $slsudah[] = $sll->slog_keyword;
                    ?>
                                <tr>
                                    <td>
                                        <div class="searchkeyword"><?php 
                    echo $sll->slog_keyword;
                    ?>
</div>
                                    </td>
                                    <td>
                                        <div class="searchkeyword"><?php 
                    echo $sll->count;
                    ?>
</div>
                                    </td>
                                </tr>

                            <?php 
                }
            }
            ?>
</table><?php 
        } else {
            ?>
                        <p>We couldn't find any records.</p>
                    <?php 
        }
        ?>
                </div>
            </div>
        </div>
        <style>
            .penjualan_container{
                border: 1px solid #dedede;
                background-color: white;
                padding: 20px;
            }
            .penjualan_money_h2{
                padding: 0;
                margin: 0;
                font-size: 20px;
                margin-bottom: 20px;
                color: #666666;
            }
            .penjualan_money{
                font-size: 25px;
            }
            .penjualan{
                margin-bottom: 20px;
            }
        </style>

            <div class="col-md-9">


                <div class="penjualan_container" style="margin-bottom: 20px;">


                    </div>
                <div class="penjualan_container">
                    <div>

                        <!-- Nav tabs -->
                        <ul class="nav nav-tabs" role="tablist">
                            <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
                            <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
                            <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
                            <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
                        </ul>

                        <!-- Tab panes -->
                        <div class="tab-content">
                            <div role="tabpanel" class="tab-pane active" id="home">ss...</div>
                            <div role="tabpanel" class="tab-pane" id="profile">.bb..</div>
                            <div role="tabpanel" class="tab-pane" id="messages">..cc.</div>
                            <div role="tabpanel" class="tab-pane" id="settings">..dd.</div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        <div class="clearfix"></div>
        </div>
        <?php 
    }