Example #1
0
 public static function getDateRangeFromPeriod($period)
 {
     $dateRange = array();
     switch ($period) {
         case 'lifetime':
             $from = '2014-09-01';
             $from = DashboardCommon::getFirstCampaignStartDate();
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'month':
             $from = date('Y-m-d', strtotime("-30 days"));
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'week':
             $from = date('Y-m-d', strtotime("-6 days"));
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'daily':
         case 'today':
             $from = date('Y-m-d');
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'yesterday':
             $from = date('Y-m-d', strtotime("-1 days"));
             $to = date('Y-m-d');
             break;
         case 'last_7_days':
             $from = $calls_date_from = date('Y-m-d', strtotime("-6 days"));
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'last_30_days':
             $from = date('Y-m-d', strtotime("-30 days"));
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'this_month':
             $from = date('Y-m-01');
             $to = date('Y-m-d', strtotime("+1 days"));
             break;
         case 'last_month':
             $from = date("Y-m-d", strtotime("first day of previous month"));
             $to = date("Y-m-d", strtotime("last day of previous month"));
             break;
         case 'custom':
             $timestamp_from = strtotime(trim($_REQUEST['from']));
             $from = date("Y-m-d", $timestamp_from);
             $timestamp_to = strtotime(trim($_REQUEST['to']));
             $to = date("Y-m-d", $timestamp_to);
             break;
     }
     $dateRange['date_from'] = $from;
     $dateRange['date_to'] = $to;
     return $dateRange;
 }
Example #2
0
    }
    ////////////////////////////////////////////////////////////////////////////
    // SAVE DATE RANGE
    ////////////////////////////////////////////////////////////////////////////
    if ($_GET['act'] == 'save_date_range') {
        if (isset($_GET['period'])) {
            $period = $_GET['period'];
            $from = $_GET['from'];
            $to = $_GET['to'];
            require '../classes/dashboard/DashboardCommon.php';
            DashboardCommon::saveDateRangeFilter($period, $to, $from);
            echo "1";
            die;
        }
        echo "0";
        die;
    }
    if ($_GET['act'] == 'get_saved_date_range') {
        require '../classes/dashboard/DashboardCommon.php';
        $date_range = DashboardCommon::getSavedDateRangeFilter();
        header('Content-Type: application/json');
        echo json_encode($date_range);
        die;
    }
    if ($_GET['act'] == 'get_campaign_start_date') {
        require '../classes/dashboard/DashboardCommon.php';
        $start_date = DashboardCommon::getFirstCampaignStartDate();
        echo json_encode($start_date);
        die;
    }
}