function viewed() { $app_id = addslashes($_POST['app_id']); $key = addslashes($_POST['key']); $app = new AppAccount(); if ($app_id == "" || $key == "") { $json['status_code'] = 0; echo json_encode($json); die; } else { $app->getByID($app_id); if ($app->app_token != $key) { $json['status_code'] = 0; $json['status_message'] = "wrong key"; echo json_encode($json); die; } } $client_camp_id = addslashes($_POST['camp_id']); $device_id = addslashes($_POST['device_id']); $dl = new PushLogger(); global $db; $q = "UPDATE {$dl->table_name} SET log_seen = 1, log_seen_date = '" . leap_mysqldate() . "' WHERE log_app_id = '{$app_id}' AND log_device_id = '{$device_id}' AND log_client_id = '{$client_camp_id}' "; // echo $q; $db->query($q, 0); $gcm = new GCMResult(); $arr = $gcm->getWhere("client_camp_id = '{$client_camp_id}' AND app_id = '{$app_id}' LIMIT 0,1"); $total = 0; foreach ($arr as $up) { $q = "SELECT count(*) AS nr FROM {$dl->table_name} WHERE log_camp_id = '{$up->camp_id}' AND log_seen = 1"; $nr = $db->query($q, 1); $total += $nr->nr; //get GCM and Update $up->seen_by = $nr->nr; $up->load = 1; $up->save(); } $json['status_code'] = 1; $json['status_message'] = "Success"; $json['total_dilihat'] = $total; echo json_encode($json); die; }
function res() { // echo IMBAuth::createOAuth(); // echo "<br>"; // echo $_GET['token']; IMBAuth::checkOAuth(); $id = addslashes($_GET['id']); // echo $id; if ($id == "" || $id < 1) { die("No ID"); } $ps = new PushNotCamp(); $ps->getByID($id); // pr($ps); $pss = new GCMResult(); $arrs = $pss->getWhere("camp_id = '{$id}' ORDER BY gcm_date DESC"); ?> <html> <head> <link href="<?php echo _SPPATH; ?> themes/adminlte/css/bootstrap.min.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" href="<?php echo _SPPATH; ?> themes/adminlte/css/jqueryui.css"> <script src="<?php echo _SPPATH; ?> themes/adminlte/js/jquery-1.11.1.min.js"></script> <script src="<?php echo _SPPATH; ?> js/jqueryui.js"></script> <script src="<?php echo _SPPATH; ?> themes/adminlte/js/bootstrap.min.js" type="text/javascript"></script> </head> <body> <div id="wait" style="display: none; position: absolute; width: 100%; line-height: 30px; text-align: center; font-weight: bold;"> <span style="background-color: red; color:white; padding: 10px; margin-top: 20px;">Loading....</span></div> <div class="container"> <h1><?php echo $ps->camp_name; ?> </h1> <table class="table table-bordered"> <thead> <tr> <th>No.</th> <th>Date</th> <th>Is Test?</th> <th>Success</th> <th>Failure</th> <th>Summary</th> <th>Results</th> </tr> <?php $cnt = 0; foreach ($arrs as $cc) { $cnt++; ?> <tr> <td> <?php echo $cnt; ?> </td> <td> <?php echo indonesian_date($cc->gcm_date); ?> </td> <td> <?php if ($cc->gcm_test) { echo "Yes"; } else { echo "No"; } ?> </td> <td> <?php echo $cc->success; ?> </td> <td> <?php echo $cc->failure; ?> </td> <td> <?php echo round($cc->success / ($cc->failure + $cc->success) * 100, 3); echo " %"; ?> </td> <td> <button class="btn btn-primary" id="detail_<?php echo $cc->multicast_id; ?> ">Details</button> <div id="multicast_<?php echo $cc->multicast_id; ?> " style="padding: 10px; display: none;"></div> <script> $("#detail_<?php echo $cc->multicast_id; ?> ").click(function(){ var isHidden = $( "#multicast_<?php echo $cc->multicast_id; ?> " ).is( ":hidden" ); if(isHidden) { $.get("<?php echo _SPPATH; ?> PushNotResults/detail?id=<?php echo $cc->multicast_id; ?> ", function (data) { $("#multicast_<?php echo $cc->multicast_id; ?> ").html(data); $("#multicast_<?php echo $cc->multicast_id; ?> ").show(); }); } else{ $("#multicast_<?php echo $cc->multicast_id; ?> ").hide(); } }); </script> <?php // $ress = unserialize($cc->results); pr($ress); ?> </td> </tr> <?php } ?> </thead> </table> </div> <?php // pr($arrs); ?> <script> $(document).ajaxStart(function(){ $("#wait").css("display", "block"); }); $(document).ajaxComplete(function(){ $("#wait").css("display", "none"); }); </script> <style> .hasil{ border: 1px dashed #cccccc; margin: 5px; padding: 5px; } .red{ color:red; } .green{ color :darkgreen; } </style> </body> </html> <?php }
public function exportIt($return) { $id = addslashes($_GET['cid']); // echo $id; if ($id == "" || $id < 1) { die("no id"); } $camp = new PushNotCamp(); $camp->getByID($id); $arrStatus = array("0" => "Not Pushed", "1" => "Pushed"); if ($camp->camp_app_id != AppAccount::getAppID()) { die("camp mismatched"); } // pr($camp); $onDate = ""; if ($camp->camp_status == 1) { $onDate = " on " . indonesian_date($camp->camp_send_date); } //hitung openrate dll $targetedDev = count(explode(",", $camp->camp_dev_ids)); $gcm = new GCMResult(); $arrGCM = $gcm->getWhere("camp_id = '{$id}' ORDER BY gcm_date DESC"); $succ = 0; $fail = 0; $seen_by = 0; foreach ($arrGCM as $cc) { $succ += $cc->success; $fail += $cc->failure; $seen_by += $cc->seen_by; } $openrate = round($seen_by / $succ * 100, 3); $del = round($succ / ($succ + $fail) * 100, 3); $filename = urlencode(str_replace(" ", "_", $camp->camp_name)) . "_" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"{$filename}\""); header("Content-Type: application/vnd.ms-excel"); $flag = false; print "Campaign Name : \t" . $camp->camp_title; //judul print "\n"; print "Status : \t" . $arrStatus[$camp->camp_status] . $onDate; //status and delieverd date print "\n"; print "Content : \t" . $camp->camp_title; print "\n"; print "Open Rate : \t" . $openrate; print "\n"; print "Seen By : \t" . $seen_by; print "\n"; print "Deliverable Percentage : \t" . $del; print "\n"; print "Targeted Devices : \t" . $targetedDev; print "\n"; print "Success : \t" . $succ; print "\n"; print "Failed : \t" . $fail; print "\n"; print "\n"; $logs = new PushLogger(); $objs = $logs->getWhere("log_camp_id = '{$id}'"); $filter = explode(",", $logs->exportList); foreach ($objs as $key => $obj) { foreach ($obj as $name => $value) { if (in_array($name, $filter)) { echo Lang::t($name) . "\t"; } } break; } print "\n"; foreach ($objs as $key => $obj) { foreach ($obj as $name => $value) { if (in_array($name, $filter)) { echo $value . "\t"; } } print "\n"; } exit; }