예제 #1
0
$query = "select vtiger_crmentity.crmid,vtiger_seactivityrel.crmid as setype,vtiger_activity.*,vtiger_activity_reminder.reminder_time,vtiger_activity_reminder.reminder_sent,vtiger_activity_reminder.recurringid,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_activity_reminder on vtiger_activity.activityid=vtiger_activity_reminder.activity_id left outer join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid where DATE_FORMAT(vtiger_activity.date_start,'%Y-%m-%d, %H:%i:%s') >= '" . date('Y-m-d') . "' and vtiger_crmentity.crmid != 0 and vtiger_activity.eventstatus = 'Planned' and vtiger_activity_reminder.reminder_sent = 0 group by vtiger_activity.activityid,vtiger_recurringevents.recurringid";
$result = $adb->pquery($query, array());
if ($adb->num_rows($result) >= 1) {
    while ($result_set = $adb->fetch_array($result)) {
        $date_start = $result_set['date_start'];
        $time_start = $result_set['time_start'];
        $reminder_time = $result_set['reminder_time'];
        $date = new DateTimeField(null);
        $curr_time = strtotime($date->getDisplayDateTimeValue()) / 60;
        $activity_id = $result_set['activityid'];
        $activitymode = $result_set['activitytype'] == "Task" ? "Task" : "Events";
        $parent_type = $result_set['setype'];
        $activity_sub = $result_set['subject'];
        $to_addr = '';
        if ($parent_type != '') {
            $parent_content = getParentInfo($parent_type) . "\n";
        } else {
            $parent_content = "";
        }
        //code included for recurring events by jaguar starts
        $recur_id = $result_set['recurringid'];
        $current_date = date('Y-m-d');
        if ($recur_id == 0) {
            $date_start = $result_set['date_start'];
        } else {
            $date_start = $result_set['recurringdate'];
        }
        //code included for recurring events by jaguar ends
        $date = new DateTimeField("{$date_start} {$time_start}");
        $activity_time = strtotime($date->getDisplayDateTimeValue()) / 60;
        if ($activity_time - $curr_time > 0 && $activity_time - $curr_time <= $reminder_time) {
        } else {
            $result = array();
        }
        return $result;
    }
}
// Set Up the Database Connection
$databaseConnection = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DBNAME);
if ($databaseConnection->connect_errno != 0) {
    SendSingleError(HTTP_INTERNAL_ERROR, $databaseConnection->connect_error, ERRTXT_DBCONN_FAILED);
}
$databaseConnection->set_charset(MYSQL_CHARSET);
// Put data in variables
$category_id = isset($_GET['category_id']) ? $_GET['category_id'] : false;
if ($category_id === false) {
    SendSingleError(HTTP_BAD_REQUEST, "one or more fields not found", ERRTXT_UNSETVARIABLE);
} else {
    $result = array();
    $parentID = $category_id;
    while ($parentID != NULL) {
        $categoryInfo = getParentInfo($databaseConnection, $parentID);
        $justIDAndName = array("category_id" => $categoryInfo["category_id"], "name" => $categoryInfo["name"]);
        array_unshift($result, $justIDAndName);
        $parentID = $categoryInfo["parent"];
    }
    header(HTTP_OK);
    header(API_RESPONSE_CONTENT);
    echo json_encode($result);
    exit;
}
SendSingleError(HTTP_INTERNAL_ERROR, 'php failed', ERRTXT_FAILED);