Example #1
0
 public function feed()
 {
     //require file
     require FCPATH . 'assets/js/fullcalendar/demos/php/utils.php';
     //variable
     $range_start;
     $range_end;
     $timezone = null;
     $output_arrays = array();
     // Short-circuit if the client did not give us a date range.
     if (!isset($_POST['start']) || !isset($_POST['end'])) {
         die("Please provide a date range.");
     }
     // Parse the start/end parameters.
     // These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
     // Since no timezone will be present, they will parsed as UTC.
     $range_start = $_POST['start'];
     $range_end = $_POST['end'];
     // Parse the timezone parameter if it is present.
     if (isset($_GET['timezone'])) {
         $timezone = new DateTimeZone($_GET['timezone']);
     }
     // Read and parse our events JSON file into an array of event data arrays.
     $query = $this->holiday->getListForCalendar($range_start, $range_end);
     if ($query->num_rows() > 0) {
         foreach ($query->result_array() as $row) {
             $data = array();
             $data["title"] = $row["HName"];
             $data["allDay"] = true;
             $data["start"] = $row["HDate"];
             $data["end"] = $row["HDate"];
             $event = new Event($data, $timezone);
             if ($event->isWithinDayRange(parseDateTime($range_start), parseDateTime($range_end))) {
                 $output_arrays[] = $event->toArray();
             }
         }
     }
     // Send JSON to the client.
     echo json_encode($output_arrays);
 }
Example #2
0
// Require our Event class and datetime utilities
require dirname(__FILE__) . '/utils.php';
// Short-circuit if the client did not give us a date range.
if (!isset($_GET['start']) || !isset($_GET['end'])) {
    die("Please provide a date range.");
}
// Parse the start/end parameters.
// These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
// Since no timezone will be present, they will parsed as UTC.
$range_start = parseDateTime($_GET['start']);
$range_end = parseDateTime($_GET['end']);
// Parse the timezone parameter if it is present.
$timezone = null;
if (isset($_GET['timezone'])) {
    $timezone = new DateTimeZone($_GET['timezone']);
}
// Read and parse our events JSON file into an array of event data arrays.
$json = file_get_contents(dirname(__FILE__) . '//json/events.json');
$input_arrays = json_decode($json, true);
// Accumulate an output array of event data arrays.
$output_arrays = array();
foreach ($input_arrays as $array) {
    // Convert the input array into a useful Event object
    $event = new Event($array, $timezone);
    // If the event is in-bounds, add it to the output
    if ($event->isWithinDayRange($range_start, $range_end)) {
        $output_arrays[] = $event->toArray();
    }
}
// Send JSON to the client.
echo json_encode($output_arrays);
function get_free_time_events()
{
    // Require our Event class and datetime utilities
    require plugin_dir_path(__FILE__) . '/php/utils.php';
    $IDU_Type = $_GET['IDU_Type'];
    $IDU = $_GET['IDU'];
    //Salesforce connection setup
    $server_base = $_SERVER['DOCUMENT_ROOT'];
    define("SOAP_CLIENT_BASEDIR", "{$server_base}/wp-content/Force.com-Toolkit-for-PHP-master/soapclient");
    require_once SOAP_CLIENT_BASEDIR . '/SforceEnterpriseClient.php';
    require_once "{$server_base}/wp-content/Force.com-Toolkit-for-PHP-master/samples/userAuth.php";
    ini_set("soap.wsdl_cache_enabled", "0");
    $mySforceConnection = new SforceEnterpriseClient();
    $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR . '/enterprise.wsdl.xml');
    $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
    //Salesforce Query
    $query = "SELECT Id,Free_Json_Times__c,Firstname,Lastname,C_ID__c From Contact  WHERE  Id='{$IDU}'";
    //Salesforce Response
    $response = $mySforceConnection->query($query);
    //exit if nothing returned
    if (count($response->records) == 0) {
        exit;
    }
    foreach ($response->records as $record) {
        $status = $record->Status__c;
        $Leading_Type = $record->Leading_Type__c;
        $json_free_time = $record->Free_Json_Times__c;
    }
    // die( $selected_time);
    // die($json);
    // Short-circuit if the client did not give us a date range.
    if (!isset($_GET['start']) || !isset($_GET['end'])) {
        die("Please provide a date range.");
    }
    // Parse the start/end parameters.
    // These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
    // Since no timezone will be present, they will parsed as UTC.
    $range_start = parseDateTime($_GET['start']);
    $range_end = parseDateTime($_GET['end']);
    // Parse the timezone parameter if it is present.
    $timezone = null;
    if (isset($_GET['timezone']) && $_GET['timezone'] != 'local') {
        $timezone = new DateTimeZone($_GET['timezone']);
    }
    // if (isset($_GET['timezone'])) {
    //     $timezone = new DateTimeZone($_GET['timezone']);
    // }
    // Read and parse our events JSON file into an array of event data arrays.
    $input_arrays = json_decode($json_free_time, true);
    // die($selected_time);
    // Accumulate an output array of event data arrays.
    $output_arrays = array();
    if (count($input_arrays) > 0) {
        foreach ($input_arrays as $array) {
            //     // Convert the input array into a useful Event object
            $event = new Event($array, $timezone);
            // If the event is in-bounds, add it to the output
            if ($event->isWithinDayRange($range_start, $range_end)) {
                $output_arrays[] = $event->toArray();
            }
        }
    }
    // Send JSON to the client.
    die(json_encode($output_arrays));
}
Example #4
0
 function getEventsForHome()
 {
     $this->load->file('php/utils.php', false);
     $all_shows = array();
     $range_start = parseDateTime($_GET['start']);
     $range_end = parseDateTime($_GET['end']);
     if ($this->session->userdata('logged_in')) {
         $session_data = $this->session->userdata('logged_in');
         $usershows = $this->shows_model->get_user_shows($session_data['id']);
         foreach ($usershows as $show) {
             $showArray = array();
             $url = 'http://services.tvrage.com/feeds/episode_list.php?sid=' . $show;
             //				$url = 'xmls/' . $show . '.xml';
             $feed = file_get_contents($url);
             $xml = simplexml_load_string($feed) or die("Error: Cannot create object");
             $show_name = strval($xml->name);
             $dom = new DOMDocument();
             $dom->loadXML($feed);
             $episodes = $xml->xpath('//episode');
             foreach ($episodes as $episode) {
                 if (count($episode->xpath("parent::*/@no")) > 0) {
                     $season = (string) $episode->xpath("parent::*/@no")[0]->no;
                     $episodenr = (string) $episode->seasonnum;
                     array_push($showArray, array('title' => $show_name, 'start' => $episode->airdate, 'season' => $season, 'episodenr' => $episodenr));
                 }
             }
             foreach ($showArray as $array) {
                 // Convert the input array into a useful Event object
                 $event = new Event($array, null);
                 if ($event->isWithinDayRange($range_start, $range_end)) {
                     $all_shows[] = $event->toArray();
                 }
             }
         }
         echo json_encode($all_shows);
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Example #5
0
 public function feed($emp_id = "")
 {
     require FCPATH . 'assets/js/fullcalendar/demos/php/utils.php';
     if ($emp_id !== "") {
         //check can see this profile is_your_headman or is_hr
         $user_detail = getEmployeeDetail($emp_id);
         $checker = FALSE;
         $headman_level = 0;
         list($checker, $headman_level) = is_your_headman($user_detail["UserID"], $this->user_id);
         if ($checker == TRUE || is_hr()) {
             $this->emp_id = $emp_id;
             $this->user_id = $user_detail["UserID"];
         }
     }
     // Short-circuit if the client did not give us a date range.
     if (!isset($_POST['start']) || !isset($_POST['end'])) {
         die("Please provide a date range.");
     }
     // Parse the start/end parameters.
     // These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
     // Since no timezone will be present, they will parsed as UTC.
     $range_start = $_POST['start'];
     $range_end = $_POST['end'];
     // Parse the timezone parameter if it is present.
     $timezone = null;
     if (isset($_GET['timezone'])) {
         $timezone = new DateTimeZone($_GET['timezone']);
     }
     // Read and parse our events JSON file into an array of event data arrays.
     $this->load->model("Worktime_model", "worktime");
     $query = $this->worktime->getListForCalendar($this->user_id, $range_start, $range_end);
     $output_arrays = array();
     if ($query->num_rows() > 0) {
         foreach ($query->result_array() as $row) {
             $data = array();
             $data["title"] = "เข้างาน : " . $row["WTTimeStart"];
             $data["allDay"] = true;
             $data["start"] = $row["WTDate"];
             $data["end"] = $row["WTDate"];
             $event = new Event($data, $timezone);
             if ($event->isWithinDayRange(parseDateTime($range_start), parseDateTime($range_end))) {
                 $output_arrays[] = $event->toArray();
             }
             $data["title"] = "เลิกงาน : " . $row["WTTimeEnd"];
             $data["allDay"] = true;
             $data["start"] = $row["WTDate"];
             $data["end"] = $row["WTDate"];
             $event = new Event($data, $timezone);
             if ($event->isWithinDayRange(parseDateTime($range_start), parseDateTime($range_end))) {
                 $output_arrays[] = $event->toArray();
             }
         }
     }
     // Send JSON to the client.
     echo json_encode($output_arrays);
 }