public static function getAppStats($arrStats, $beginDate, $endDate)
 {
     //customer acquisition per day
     //        $ll = new LL_Account();
     //        $arrw = $ll->getWhere("(macc_acquire_date BETWEEN '$beginDate' AND '$endDate')","macc_acquire_date");
     //        pr($arrw);
     //        echo count($arrw);
     $data = array();
     //for begin date sampai end date day by day
     $start = strtotime($beginDate);
     $finish = strtotime($endDate);
     while ($start < $finish) {
         $label = date("d", $start);
         $start = strtotime('+1 day', $start);
         $xLabels[] = $label;
         foreach ($arrStats as $ll => $arrw) {
             $data[$ll][$label] = 0;
             $data["Transactions Value"][$label] = 0;
         }
     }
     //        pr($xLabels);
     //manage data
     $arrData2 = array();
     $colors = array("#00c0ef", "#00a65a", "#f39c12", "#dd4b39");
     //        pr($arrStats);
     foreach ($arrStats as $ll => $arrw) {
         foreach ($arrw as $w) {
             if ($ll == "Transactions Nr.") {
                 $curdate = date("d", strtotime($w->TransactionDateTime));
                 $data[$ll][$curdate]++;
                 $data["Transactions Value"][$curdate] += $w->Cash_Value / 1000;
             }
         }
         //        pr($data);
         $arr = array_values($data[$ll]);
         //        pr($arr);
         $c = new Charting();
         $c->label = "Nr";
         $c->data = $arr;
         $c->color = array_pop($colors);
         $arrData2[] = $c;
         $arr = array_values($data["Transactions Value"]);
         //        pr($arr);
         $c = new Charting();
         $c->label = "Value";
         $c->data = $arr;
         $c->color = array_pop($colors);
         $arrData2[] = $c;
     }
     Charting::chartJSLine("300px", $xLabels, $arrData2, "false", 1, 0, "User Statistic", "info", 1);
     //        pr($data);
     return $data;
 }
 public static function getAcquire($beginDate, $endDate)
 {
     //customer acquisition per day
     $ll = new LL_Account();
     $arrw = $ll->getWhere("(macc_acquire_date BETWEEN '{$beginDate}' AND '{$endDate}')", "macc_acquire_date");
     //        pr($arrw);
     //        echo count($arrw);
     $data = array();
     //for begin date sampai end date day by day
     $start = strtotime($beginDate);
     $finish = strtotime($endDate);
     while ($start <= $finish) {
         $label = date("d", $start);
         $start = strtotime('+1 day', $start);
         $xLabels[] = $label;
         $data[$label] = 0;
     }
     //        pr($xLabels);
     //manage data
     foreach ($arrw as $w) {
         $curdate = date("d", strtotime($w->macc_acquire_date));
         $data[$curdate]++;
     }
     //        pr($data);
     $arr = array_values($data);
     //        pr($arr);
     $c = new Charting();
     $c->label = "User Acquisition";
     $c->data = $arr;
     $c->color = "#AAAAAA";
     $arrData2[] = $c;
     Charting::chartJSLine("300px", $xLabels, $arrData2, "false", 0, 0, "User Acquisition", "info", 0);
     return $arrw;
 }
    function demographic()
    {
        $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();
        //male female
        $ll = new LL_Account();
        global $db;
        $query3 = "Select (Select count(*) from {$ll->table_name} where macc_gender='Male' AND (macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}')) AS Male,\n(Select count(*) from {$ll->table_name} where macc_gender='Female' AND (macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}')) AS Female ";
        $gender = $db->query($query3, 1);
        //        pr($gender);
        //        macc_lyb_status
        $query4 = "Select (Select count(*) from {$ll->table_name} where macc_lyb_status='LYB Club' AND (macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}')) AS Club,\n(Select count(*) from {$ll->table_name} where macc_lyb_status='The Body Shop Friend' AND (macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}')) AS Stampcard,\n(Select count(*) from {$ll->table_name} where macc_lyb_status='LYB Fan' AND (macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}')) AS Fan ";
        $lyb = $db->query($query4, 1);
        //        pr($lyb);
        //macc_address_city
        //        $query5="SELECT DISTINCT macc_address_city FROM {$ll->table_name} ";
        //
        //        $cities = $db->query($query5,2);
        ////        pr($cities);
        //
        //        foreach($cities as $number=>$city){
        //            if($city->macc_address_city!="") {
        //                $city->macc_address_city = str_replace(".","",$city->macc_address_city);
        //                $city->macc_address_city = str_replace(",","",$city->macc_address_city);
        //                $text[] = "(Select count(*) as count from {$ll->table_name} where macc_address_city='{$city->macc_address_city}' AND (macc_acquire_date BETWEEN '$days_ago' AND '$days_now')) AS " . str_replace("/", "", str_replace(" ", "", str_replace("-", "", $city->macc_address_city)));
        //            }
        ////            if($number>10)break;
        //        }
        ////        pr($text);
        //        $imp = "Select ". implode(",",$text)." ORDER BY count DESC";
        global $db;
        $q = "SELECT macc_address_city,COUNT(*) as count FROM {$ll->table_name} GROUP BY macc_address_city ORDER BY count DESC LIMIT 0,20";
        $arrSl = $db->query($q, 2);
        //        pr($arrSl);
        //        echo $imp;
        //        $nrcities = $db->query($imp,2);
        //        pr($nrcities);
        ?>
<div class="row">
    <div class="col-md-12">
        <h1>
            Demographic 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("Demographic","<?php 
        echo _SPPATH;
        ?>
BIWebDemographic/demographic?m="+slc,"fade");
                    });
                </script>
            </li>
        </ol>
    </div>
</div>

        <?php 
        $arrUserswPic = $ll->getWhere("macc_foto != '' AND (macc_acquire_date BETWEEN '{$days_ago}' AND '{$days_now}') ORDER BY macc_acquire_date DESC LIMIT 0,8");
        $arrUsers = $ll->getOrderBy(" macc_acquire_date DESC LIMIT 0,8");
        ?>
        <div class="row">
            <!--<div class="col-md-6">

                <div class="box box-danger">
                    <div class="box-header with-border">
                        <h3 class="box-title">Latest Members</h3>

                        <div class="box-tools pull-right">
                            <span class="label label-danger">8 New Members</span>
                            <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 no-padding">
                        <ul class="users-list clearfix">
                            <?php 
        foreach ($arrUsers as $user) {
            if ($user->macc_foto == "") {
                $url = _SPPATH . "images/noimage.jpg";
            } else {
                $url = "http://43.231.128.129/" . $user->macc_foto;
            }
            ?>
                            <li>
                                <img src="<?php 
            echo $url;
            ?>
" alt="<?php 
            echo $user->macc_first_name . " " . $user->macc_last_name;
            ?>
">
                                <a class="users-list-name" href="#"><?php 
            echo $user->macc_first_name . " " . $user->macc_last_name;
            ?>
</a>
                                <span class="users-list-date"><?php 
            echo ago(strtotime($user->macc_acquire_date));
            ?>
</span>
                            </li>
                            <?php 
        }
        ?>

                        </ul>

                    </div>

                    <div class="box-footer text-center">
                        <a href="javascript::" class="uppercase">View All Users</a>
                    </div>

                </div>

            </div>
            -->
            <div class="col-md-6">
                <!-- USERS LIST -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">Latest Customers</h3>

                        <!--<div class="box-tools pull-right">
                            <span class="label label-danger">8 New Members</span>
                            <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 no-padding">
                        <ul class="users-list clearfix">
                            <?php 
        foreach ($arrUserswPic as $user) {
            ?>
                                <li style="height: 160px;">
                                    <img src="<?php 
            echo _LOKASI;
            echo $user->macc_foto;
            ?>
" alt="User Image">
                                    <span class="users-list-name" ><?php 
            echo $user->macc_first_name . " " . $user->macc_last_name;
            ?>
</span>
                                    <span class="users-list-date"><?php 
            echo ago(strtotime($user->macc_acquire_date));
            ?>
</span>
                                </li>
                            <?php 
        }
        ?>

                        </ul>
                        <!-- /.users-list -->
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer text-center">
                        <a href="javascript:openLw('LL_Account', '<?php 
        echo _SPPATH;
        ?>
LLAccWeb/LL_Account', 'fade'); activkanMenuKiri('LL_Account');" class="uppercase">View All Customers</a>
                    </div>
                    <!-- /.box-footer -->
                </div>
                <!--/.box -->
            </div>

            <?php 
        $arrColor = array("#00a65a", "#00c0ef");
        $c = new Charting();
        $c->color = array_pop($arrColor);
        $c->label = "Male";
        $c->value = $gender->Male;
        $arrData[] = $c;
        $c = new Charting();
        $c->color = array_pop($arrColor);
        $c->label = "Female";
        $c->value = $gender->Female;
        $arrData[] = $c;
        ?>
<div class="col-md-3"><?php 
        Charting::morrisDonut("287px", $arrData, 1, "Gender", "default");
        ?>

            </div>
            <?php 
        $arrColor = array("#4da65a", "#7bcd03", "#53ddde");
        $arrData = array();
        $c = new Charting();
        //            $c->color = array_pop($arrColor);
        $c->color = "#e90057";
        $c->label = "Fan";
        $c->value = $lyb->Fan;
        $arrData[] = $c;
        $c = new Charting();
        //            $c->color = array_pop($arrColor);
        $c->color = "#cd6949";
        $c->label = "Club";
        $c->value = $lyb->Club;
        $arrData[] = $c;
        $c = new Charting();
        //            $c->color = array_pop($arrColor);
        $c->color = "#f4bb1b";
        $c->label = "Stampcard";
        $c->value = $lyb->Stampcard;
        $arrData[] = $c;
        ?>
<div class="col-md-3"><?php 
        Charting::morrisDonut("287px", $arrData, 1, "Member Type", "default");
        ?>

            </div>

            <?php 
        $arrData = array();
        $arrlegend = array();
        foreach ($arrSl as $attr => $value) {
            if ($value->macc_address_city == "") {
                $value->macc_address_city = "Unknown";
            }
            $c = new Charting();
            $c->color = "#" . $this->random_color();
            $c->label = str_replace(" ", "_", $value->macc_address_city);
            $c->value = $value->count;
            $arrData[] = $c;
            //                $arrlegend[$attr] = $value;
        }
        //            asort($arrlegend);
        //pr($arrlegend);
        //            $arrlegend = array_reverse($arrlegend,1);
        //            $arrData = array();
        //            foreach($arrSl as $attr=>$value){
        //                $c = new Charting();
        //                $c->color = "#".$this->random_color();
        //
        //                $c->label = str_replace(" ","_",$value->macc_address_city);
        //                $c->value = $value->count;
        //
        ////                $c->label = ucwords(strtolower(str_replace("_"," ",$attr)));
        ////                $c->value = $value;
        //                $arrData[] = $c;
        //                $arrColors[$attr] = $c->color;
        ////                $arrlegend[$attr] = $value;
        //            }
        ?>
        </div>

        <div class="row">
            <div class="col-md-12">
                <div class="box box-default">
                    <div class="box-header with-border">
                        <h3 class="box-title">Locations</h3>

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

                <div class="col-md-6">
                <?php 
        Charting::morrisDonut("300px", $arrData, 0, "Locations", "default", 0);
        ?>
                </div>
                <div class="col-md-6">
                    <?php 
        ?>
                    <ul class="nav nav-pills nav-stacked">
                        <?php 
        foreach ($arrSl as $attr => $value) {
            if ($value->macc_address_city == "") {
                $value->macc_address_city = "Unknown";
            }
            ?>
                        <li style="line-height: 30px;">
                            <div style="margin-top:5px; float: left; width: 20px; height: 20px; background-color: <?php 
            echo $arrColors[$attr];
            ?>
;"></div>
                            &nbsp; <?php 
            echo ucwords(str_replace("_", " ", strtolower($value->macc_address_city)));
            ?>
                                <span class="pull-right "> <?php 
            echo $value->count;
            ?>
</span></li>

                        <?php 
        }
        ?>
                    </ul>
                </div>

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


        <style>
            ul.legend li{
                list-style: none;
                line-height: 30px;
            }
            ul.legend li div{
                float: left;
                margin-top: 10px;
                margin-right: 15px;
            }
            .legend-item{
                float: left;
                margin: 10px;
                line-height: 30px;
                margin-right: 5px;
            }
            .legend-item div{
                float: left;
                margin-top: 10px;
                margin-right: 5px;
            }
            .breadcrumb {
                padding: 8px 15px;
                margin-bottom: 20px;
                list-style: none;
                background-color: #f5f5f5;
                border-radius: 4px;
            }
            .breadcrumb {
                float: right;
                background: transparent;
                margin-top: 0;
                margin-bottom: 0;
                font-size: 12px;
                padding: 7px 5px;
                position: absolute;
                top: 15px;
                right: 10px;
                border-radius: 2px;
            }
            .users-list-name{
                white-space: nowrap;
            }
        </style>
<?php 
    }
 public static function getAppStats($arrStats, $beginDate, $endDate)
 {
     //customer acquisition per day
     //        $ll = new LL_Account();
     //        $arrw = $ll->getWhere("(macc_acquire_date BETWEEN '$beginDate' AND '$endDate')","macc_acquire_date");
     //        pr($arrw);
     //        echo count($arrw);
     $data = array();
     //for begin date sampai end date day by day
     $start = strtotime($beginDate);
     $finish = strtotime($endDate);
     while ($start < $finish) {
         $label = date("d", $start);
         $start = strtotime('+1 day', $start);
         $xLabels[] = $label;
         foreach ($arrStats as $ll => $arrw) {
             $data[$ll][$label] = 0;
         }
     }
     //        pr($xLabels);
     //manage data
     $arrData2 = array();
     $colors = array_reverse(array("#CCCCCC", "#00a65a", "#f39c12", "#dd4b39"));
     //        pr($arrStats);
     foreach ($arrStats as $ll => $arrw) {
         foreach ($arrw as $w) {
             if ($ll == "Orders") {
                 $curdate = date("d", strtotime($w->detail_date));
                 $data[$ll][$curdate] += $w->detail_price_total;
             }
             if ($ll == "Active Users") {
                 $curdate = date("d", strtotime($w->log_date));
                 $data[$ll][$curdate]++;
             }
             if ($ll == "New Devices") {
                 $curdate = date("d", strtotime($w->firstlogin));
                 $data[$ll][$curdate]++;
             }
             if ($ll == "Active Devices") {
                 $curdate = date("d", strtotime($w->log_date));
                 $data[$ll][$curdate]++;
             }
         }
         //        pr($data);
         $arr = array_values($data[$ll]);
         //        pr($arr);
         $c = new Charting();
         $c->label = $ll;
         $c->data = $arr;
         $c->color = array_pop($colors);
         $arrData2[] = $c;
     }
     //        Charting::chartJSLine("300px",$xLabels,$arrData2,"false",1,1);
     Charting::chartJSLine("300px", $xLabels, $arrData2, "true", 0, 0, "User Statistic", "info", 1);
     //        pr($data);
     return $data;
 }
Пример #5
0
    function campaign()
    {
        $c = new Charting();
        $c->color = "#dceade";
        $c->label = "enak";
        $c->value = 15;
        $arrData[] = $c;
        $c = new Charting();
        $c->color = "#ff0011";
        $c->label = "ga enak";
        $c->value = 35;
        $arrData[] = $c;
        $c = new Charting();
        $c->color = "#6688aa";
        $c->label = "biasa";
        $c->value = 75;
        $arrData[] = $c;
        ?>
<div class="col-md-6"><?php 
        Charting::morrisDonut("300px", $arrData, 1, "Ini morris", "default");
        ?>
</div>
        <div class="col-md-6"><?php 
        Charting::chartJSPie("300px", $arrData, 50, 1, 1, "Bagan keren");
        ?>
</div><?php 
        //for line and area
        $xLabels = array("Jan", "Feb", "Mar", "April", "May");
        $c = new Charting();
        $c->label = "Shoes";
        $c->data = array(10, 15, 30, 12, 21);
        $c->color = "rgba(255,132,123,0.8)";
        $c->strokeColor = "red";
        $c->fillColor = "pink";
        $c->pointColor = "orange";
        $c->pointHighlightStroke = "blue";
        $c->pointStrokeColor = "black";
        $arrData2[] = $c;
        $c = new Charting();
        $c->label = "Apparel";
        $c->data = array(13, 25, 10, 12, 23);
        $c->color = "rgba(255,243,123,0.8)";
        $c->strokeColor = "green";
        $arrData2[] = $c;
        $c = new Charting();
        $c->label = "Books";
        $c->data = array(11, 15, 16, 13, 33);
        $c->color = "rgba(145,255,255,0.8)";
        $arrData2[] = $c;
        ?>
<div class="col-md-6"><?php 
        Charting::chartJSLine("300px", $xLabels, $arrData2, "false", 1, 1, "data kedua", "info");
        ?>
        </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: 20px;
        }
        .legend-item div{
            float: left;
            margin-top: 10px;
            margin-right: 5px;
        }
    </style>
        <div class="col-md-6">
        <?php 
        Charting::chartJSBar("300px", $xLabels, $arrData2, "false", 1, 1, "data terakhir", "danger");
        ?>
</div><?php 
    }
 public static function getAppStats($arrStats, $beginDate, $endDate)
 {
     //customer acquisition per day
     //        pr($arrStats);
     $data = array();
     //for begin date sampai end date day by day
     $start = strtotime($beginDate);
     $finish = strtotime($endDate);
     while ($start < $finish) {
         $label = date("d", $start);
         $start = strtotime('+1 day', $start);
         $xLabels[] = $label;
         foreach ($arrStats as $ll => $arrw) {
             $data[$ll][$label] = 0;
             $data["Transactions Value"][$label] = 0;
         }
     }
     //manage data
     $arrData2 = array();
     $colors = array("#00c0ef", "#00a65a", "#f39c12", "#dd4b39");
     foreach ($arrStats as $ll => $arrw) {
         $curdate = date("d", strtotime($arrw->date));
         $data["Transactions Value"][$curdate] = $arrw->total_sales / 1000;
         $arr = array_values($data["Transactions Value"]);
     }
     $c = new Charting();
     $c->label = "Value";
     $c->data = $arr;
     $c->color = array_pop($colors);
     $arrData2[] = $c;
     Charting::chartJSLine("300px", $xLabels, $arrData2, "false", 1, 0, "User Statistic", "info", 1);
     //        pr($data);
     return $data;
 }