Ejemplo n.º 1
0
     //var_dump($courses);
 }
 foreach ($courses as $singlecourse) {
     $courseID = db::esc($singlecourse->ID);
     $instanceID = db::esc($singlecourse->INSTANCEID);
     $locationDataName = db::esc($singlecourse->LOCATION);
     $startDateTime = db::esc($singlecourse->STARTDATE);
     $endDateTime = db::esc($singlecourse->FINISHDATE);
     $courseData = date("Y-m-d", strtotime("" . $startDateTime . ""));
     //NEDS TO BE DATE OF START DATE
     $cost = db::esc($singlecourse->COST);
     $maxparticipants = db::esc($singlecourse->MAXPARTICIPANTS);
     $totalParticipants = db::esc($singlecourse->PARTICIPANTS);
     $totalParticipantsVacancy = db::esc($singlecourse->PARTICIPANTVACANCY);
     $enrolmentOpen = db::esc($singlecourse->ENROLMENTOPEN);
     golog("Syncing {$instanceID}. EO: {$enrolmentOpen}");
     //echo $enrolmentOpen."<br>";
     if ($totalParticipantsVacancy <= 0) {
         $enrolmentOpen = 0;
         //echo($instanceID);
         //echo("<br>");
     }
     $locationID = getLocationIDfromDataName($locationDataName);
     $instance = db::runQuery("select * from events where instanceID = '{$instanceID}'");
     if ($instance) {
         if ($enrolmentOpen == 1) {
             db::insertQuery("update events set courseID = '{$courseID}', locationID = '{$locationID}', startDateTime = '{$startDateTime}', endDateTime = '{$endDateTime}', courseDate = '{$courseData}', cost = '{$cost}', maxparticipants = '{$maxparticipants}', totalParticipants = '{$totalParticipants}', totalParticipantsVacancy = '{$totalParticipantsVacancy}', enrolmentOpen = '{$enrolmentOpen}', updated = now(), processed = '1', active = '1' where instanceID = '{$instanceID}'");
         } else {
             db::insertQuery("update events set courseID = '{$courseID}', locationID = '{$locationID}', startDateTime = '{$startDateTime}', endDateTime = '{$endDateTime}', courseDate = '{$courseData}', cost = '{$cost}', maxparticipants = '{$maxparticipants}', totalParticipants = '{$totalParticipants}', totalParticipantsVacancy = '{$totalParticipantsVacancy}', enrolmentOpen = '{$enrolmentOpen}', updated = now(), processed = '1', active = '0' where instanceID = '{$instanceID}'");
             if (!$instance['enrolmentOpen'] == $enrolmentOpen) {
                 db::insertQuery("insert into log (type,message,instanceID) values('sync','Istance Enrolment Closed','{$instanceID}')");
Ejemplo n.º 2
0
function getLocationIDfromDataName($locationDataName)
{
    if (isset($_SESSION["" . $locationDataName . ""])) {
        golog("Cached location " . $locationDataName);
        return $_SESSION["" . $locationDataName . ""];
    } else {
        golog("Query location " . $locationDataName);
        $locationDataName = db::esc($locationDataName);
        $location = db::runQuery("select * from locations where data_location = '{$locationDataName}'");
        if ($location) {
            $_SESSION["" . $locationDataName . ""] = $location[0]['ID'];
            return $location[0]['ID'];
        } else {
            db::insertQuery("insert into locations (LocationName, data_location) values('{$locationDataName}','{$locationDataName}')");
            $locationID = db::runQuery("SELECT LAST_INSERT_ID() as ID");
            $_SESSION["" . $locationDataName . ""] = $locationID[0]['ID'];
            return $locationID[0]['ID'];
        }
    }
}