Beispiel #1
0
 /**
  * 根据一个时间戳得到详细信息
  * @param  [type] $time [时间戳]
  * @return [type]
  * @author [yangsheng@yahoo.com]
  */
 function getDateInfo($time)
 {
     $day_of_week_cn = array("日", "一", "二", "三", "四", "五", "六");
     //中文星期
     $week_of_month_cn = array('', '第1周', '第2周', '第3周', '第4周', '第5周', '第6周');
     #本月第几周
     $tenDays = getTenDays(date('j', $time));
     #获得旬
     $quarter = getQuarter(date('n', $time), date('Y', $time));
     # 获取季度
     $dimDate = array('date_key' => strtotime(date('Y-m-d', $time)), 'date_day' => date('Y-m-d', $time), 'current_year' => date('Y', $time), 'current_quarter' => $quarter['current_quarter'], 'quarter_cn' => $quarter['quarter_cn'], 'current_month' => date('n', $time), 'month_cn' => date('Y-m', $time), 'tenday_of_month' => $tenDays['tenday_of_month'], 'tenday_cn' => $tenDays['tenday_cn'], 'week_of_month' => ceil(date('j', $time) / 7), 'week_of_month_cn' => $week_of_month_cn[ceil(date('j', $time) / 7)], 'day_of_year' => date('z', $time) + 1, 'day_of_month' => date('j', $time), 'day_of_week' => date('w', $time) > 0 ? date('w', $time) : 7, 'day_of_week_cn' => '星期' . $day_of_week_cn[date('w', $time)]);
     return $dimDate;
 }
/**
 * Creates one session per course with $administratorId as the creator and
 * adds it to the session starting on $startDate and finishing on $endDate
 * @param   array   $courses Courses
 * @param   int     $administratorId Administrator id
 * @param   date    $startDate First day of the month
 * @param   date    $endDate Last day of the month
 * @return  void
 */
function createCourseSessions($courses, $administratorId, $startDate, $endDate)
{
    echo "\n";
    echo $courses ? "Creating sessions and adding courses for the period between " . $startDate . " and " . $endDate : "Every course is already in session for the period between " . $startDate . " and " . $endDate;
    echo "\n=====================================================================================\n\n";
    // Loop through courses creating one session per each and adding them
    foreach ($courses as $course) {
        //$period = date("m/Y", api_strtotime($startDate));
        $month = date("m", api_strtotime($startDate));
        $year = date("Y", api_strtotime($startDate));
        $quarter = getQuarter($month);
        $quarter = getQuarterRoman($quarter);
        $period = $year . '-' . $quarter;
        $sessionName = '[' . $period . '] ' . $course['title'];
        $sessionId = SessionManager::create_session($sessionName, $startDate, $endDate, null, null, null, null, $administratorId, 0, SESSION_INVISIBLE);
        SessionManager::add_courses_to_session($sessionId, array($course['id']));
        echo "Session '" . $sessionName . "' created.\nCourse '" . $course['title'] . "' added.\n\n";
    }
}
A full copy of the license is included in LICENSE.md.

//////////////////////////////////////////////////////////////////////////////////////////
/////// About this file

Generates departmental summary data for quarterly reports

-->

<?php 
include "../config/default-config.php";
include "../functions/default-functions.php";
$con = connectDB();
// Determine quarter, year, and previous year
$currentQuarter = getQuarter();
$quarterName = $currentQuarter["quarterName"];
$startDate = $currentQuarter["startDate"];
$endDate = $currentQuarter["endDate"];
$currentYear = date("Y", strtotime($startDate));
$previousYear = $currentYear - 1;
// Define log files
$logFileName = "update-quarterly-dept-report_log_" . date("Y-m-d") . "_" . date("hiA") . ".txt";
$logFile = fopen("logs/" . $logFileName, "a");
$outputFileName = $currentYear . "_q" . $quarterName . ".json";
// Record start of process
$eventDescription = "Update data for quarterly department report";
$eventStart = date("Y-m-d H:i:s");
$startProcess = "INSERT INTO events_master (eventType,eventDescription,eventStart,processLogFile,errorLogFile) VALUES('data-update_report-1','{$eventDescription}','{$eventStart}','{$logFileName}','{$logFileName}')";
if (!runQuery($con, $startProcess)) {
    printFile($outputFile, "Error: " . mysqli_error($con) . "\n");