SHARE
TWEET

Untitled

a guest Nov 17th, 2016 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. set_time_limit(0);
  4. header('Content-type: application/json');
  5.  
  6. date_default_timezone_set($_SESSION['merchant_timezone']);
  7.  
  8. require_once('setting.php');
  9. require_once('clover-api.php');
  10.  
  11. $filter = [];
  12. switch ($_POST['date_range']) {
  13.     case 'TODAY':
  14.         $filter[] = 'clientCreatedTime>=' . (strtotime(date('Y-m-d') . '00:00:00')*1000);
  15.         break;
  16.  
  17.     case 'YESTERDAY':
  18.         $filter[] = 'clientCreatedTime>=' . (strtotime(date('Y-m-d', strtotime('-1 days')) . '00:00:00')*1000);
  19.         $filter[] = 'clientCreatedTime<=' . (strtotime(date('Y-m-d') . '00:00:00')*1000);
  20.         break;
  21.    
  22.     case 'LAST_7_DAYS':
  23.         $filter[] = 'clientCreatedTime>=' . (strtotime(date('Y-m-d', strtotime('-7 days')) . '00:00:00')*1000);
  24.         break;
  25.  
  26.     case 'CUSTOM':
  27.         $filter[] = 'clientCreatedTime>=' . (strtotime($_POST['start_date'] . '00:00:00')*1000);
  28.         //$filter[] = 'clientCreatedTime<=' . (strtotime($_POST['end_date'] . '00:00:00')*1000);
  29.         $filter[] = 'clientCreatedTime<=' . (strtotime('+1 days', strtotime($_POST['end_date'] . '00:00:00'))*1000);
  30. }
  31.  
  32.  
  33. try {
  34.  
  35.     $clover_api = new CloverApi();
  36.     $orders = $clover_api->GetOrders($_SESSION['merchant_id'], $_SESSION['access_token'], $filter, 1);
  37.    
  38.     echo json_encode([ 'orders' => $orders ]);
  39. }
  40. catch(Exception $e) {
  41.     echo $e->getMessage();
  42. }
  43.  
  44. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top