コード例 #1
0
                        }
                    }
                }
            }
            /////
        }
    }
    //Write $teacherListArray into database
    $teacherListArrayCount0 = count($teacherListArray);
    for ($i = 0; $i < $teacherListArrayCount0; $i++) {
        $targetId = $teacherListArray[$i]['ID'];
        table_data_change($TEACHER_TABLE_NAME, $TEACHER_TABLE_KEY_NAMES_ARRAY, $targetId, $teacherListArray[$i]);
    }
    //Write $classroomScheduleArray into database
    $classroomScheduleArrayCount0 = count($classroomScheduleArray);
    vars_checkout($classroomScheduleArrayCount0, "classroomScheduleArrayCount0");
    for ($i = 0; $i < $classroomScheduleArrayCount0; $i++) {
        table_data_add($CLASSROOM_SCHEDULE_TABLE_NAME, $CLASSROOM_SCHEDULE_TABLE_KEY_NAMES_ARRAY, $classroomScheduleArray[$i]);
    }
}
//Bracket for reschedule determinative syntax
//Load in session for global table name load.
$_SESSION['targetTableName'] = $CLASSROOM_SCHEDULE_TABLE_NAME;
$_SESSION['targetPageSwitch'] = $PAGE_SWITCH;
//Load the course key-name union array
$courseKeyNameUnionArray = course_key_name_union_array_get($courseListArray);
//Reunion the classroom array for classroom schedule output
$classroomScheduleArrayReunion = classroom_schedule_array_reunion($classroomScheduleArray, $courseKeyNameUnionArray);
//------  -[ Views Functions ]-  ------
div_head_output_with_class_option("mainMiddle");
//Print Main Title
コード例 #2
0
/**
*	total_schedule_excel_export Function
*	This function export the excel documents by PHPExcel plugins.
*
*	@category   PHPExcel
*	@copyright  Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*	@license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
*	@version    1.7.7, 2012-05-19
*	@param 		array $total_schedule_array, string $target_semester, string $target_week, array $course_key_name_union_array
*	@return 	false
*/
function total_schedule_excel_export($total_schedule_array, $target_semester, $target_week, $course_key_name_union_array)
{
    $totalScheduleArrayCount0 = count($total_schedule_array);
    $courseKeyNameUnionArrayCount0 = count($course_key_name_union_array);
    $target_week++;
    //For week value
    $excelFileName = __DIR__ . "\\..\\temp\\totalSchedule_S" . $target_semester . "W" . $target_week . ".xlsx";
    // Create new PHPExcel object
    echo date('H:i:s'), " Create new PHPExcel object", PHP_EOL;
    $objPHPExcel = new PHPExcel();
    // Set document properties
    echo date('H:i:s'), " Set document properties", PHP_EOL;
    $objPHPExcel->getProperties()->setCreator("default")->setLastModifiedBy("default")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
    echo date('H:i:s'), " Adding data", PHP_EOL;
    //Export title
    $titleName = $target_semester . "学年度 第" . $target_week . "周 总课表";
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A1", $titleName);
    //Export title info
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A2", "工种");
    $titleColCounter = "B";
    for ($i = 1; $i < $courseKeyNameUnionArrayCount0; $i++) {
        $courseKeyName = "COURSE_" . $i;
        $titleCol = $titleColCounter . "2";
        $courseName = $course_key_name_union_array[$courseKeyName];
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($titleCol, $courseName);
        for ($j = 0; $j < 2; $j++) {
            $titleColCounter++;
        }
    }
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A3", "课节");
    $titleColCounter = "B";
    for ($i = 1; $i < $courseKeyNameUnionArrayCount0; $i++) {
        $partName = "1234";
        $titleCol = $titleColCounter . "3";
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($titleCol, $partName);
        $titleColCounter++;
        $partName = "5678";
        $titleCol = $titleColCounter . "3";
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($titleCol, $partName);
        $titleColCounter++;
    }
    //Export main info
    $colCounter = 4;
    //Title line will take 3 line
    $lastWeek = -1;
    for ($totalScheduleArrayCounter = 0; $totalScheduleArrayCounter < $totalScheduleArrayCount0; $totalScheduleArrayCounter++) {
        $rowCounter = 'A';
        $week = $total_schedule_array[$totalScheduleArrayCounter]['WEEK'];
        //Blank line confirm
        $avaliableCourseCounter = 0;
        for ($i = 1; $i < $courseKeyNameUnionArrayCount0; $i++) {
            for ($j = 0; $j < 4; $j++) {
                $coursePartKeyName = "COURSE_" . $i . "_" . $j;
                if ($total_schedule_array[$totalScheduleArrayCounter][$coursePartKeyName]) {
                    $avaliableCourseCounter++;
                }
            }
        }
        vars_checkout($avaliableCourseCounter, "avaliableCourseCounter");
        if ($total_schedule_array[$totalScheduleArrayCounter]['COURSE_0_0'] && $avaliableCourseCounter == 0) {
            continue;
        }
        foreach ($total_schedule_array[$totalScheduleArrayCounter] as $key => $value) {
            if ($key == "id") {
                continue;
            }
            //Print week
            if ($key == "WEEK" && $week != $lastWeek) {
                if ($week == 0) {
                    $value = '周一';
                } elseif ($week == 1) {
                    $value = '周二';
                } elseif ($week == 2) {
                    $value = '周三';
                } elseif ($week == 3) {
                    $value = '周四';
                } elseif ($week == 4) {
                    $value = '周五';
                }
            } elseif ($key == "WEEK") {
                $value = '';
            }
            if ($key == "SEMESTER_WEEK") {
                continue;
            }
            if ($key == 'COURSE_0_0' || $key == 'COURSE_0_1' || $key == "COURSE_0_2" || $key == "COURSE_0_3") {
                continue;
            }
            $explodeUnderlineKey = explode("_", $key);
            $courseSerialNumber = $explodeUnderlineKey[1];
            $coursePartSerialNumber = $explodeUnderlineKey[2];
            if ($key == 'COURSE_' . $courseSerialNumber . '_1' || $key == 'COURSE_' . $courseSerialNumber . '_3') {
                continue;
            }
            // ignore the next part of course
            $serial = $rowCounter . $colCounter;
            //Create
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue($serial, $value);
            //print "<br />[".$serial."]".$value;	//For test
            $rowCounter++;
        }
        //Update the lastWeek and $colCounter
        $lastWeek = $week;
        $colCounter++;
    }
    // Rename worksheet
    echo date('H:i:s'), " Rename worksheet", PHP_EOL;
    $objPHPExcel->getActiveSheet()->setTitle('Simple');
    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $objPHPExcel->setActiveSheetIndex(0);
    // Save Excel 2007 file
    echo date('H:i:s'), " Write to Excel2007 format", PHP_EOL;
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    $objWriter->save($excelFileName);
    echo date('H:i:s'), " File written to ", $excelFileName, PHP_EOL;
    // Echo memory peak usage
    echo date('H:i:s'), " Peak memory usage: ", memory_get_peak_usage(true) / 1024 / 1024, " MB", PHP_EOL;
    // Echo done
    echo date('H:i:s'), " Done writing file", PHP_EOL;
}
コード例 #3
0
     if ($courseTakeRound >= $totalCourseTakeQuantityInArrange / 2) {
         $courseCapabilityLeftCounter += $courseCapabilityArray[$dayCounter][$courseKeyName];
     }
     $dayCourseCounter++;
 }
 //排列课程并写入临时数组
 //可排课判断条件为 课程有可用量 与 该班级有这门课且未曾上过 与 周课程量有剩余
 if ($courseCapabilityLeftCounter >= $coursePeriod / 2 && $appointedClassArray[$classCounter][$courseName] != 0 && $appointedClassArray[$classCounter][$courseName] != "F" && $totalCourseTakeQuantityInArrange < $MAX_TAKE_COURSE_A_WEEK) {
     //检测是否为概论课
     vars_checkout($courseListArray[$courseCounter]['COURSE_STYLE'], "courseListArray[\$courseCounter]['COURSE_STYLE']");
     if ($courseListArray[$courseCounter]['COURSE_STYLE'] == "G") {
         //周课程量-1 概论课占用实训课第一节
         $totalCourseTakeQuantityInArrange - 2;
     }
     //检测是否为工艺设计, 所有训练科目结束之后方可进行工艺设计
     vars_checkout($allTrainCourseLeft, "allTrainCourseLeft");
     if ($courseListArray[$courseCounter]['COURSE_STYLE'] == "GY" && $allTrainCourseLeft != 0) {
         continue;
     }
     //检测是否为考试
     if ($courseListArray[$courseCounter]['COURSE_STYLE'] == "K" && $allCourseLeft != 0) {
         continue;
     }
     //上课名称及数量
     $courseTakeInArrangeArray[$courseTakeCounter]['COURSE_KEY_NAME'] = $courseName;
     $courseTakeInArrangeArray[$courseTakeCounter]['COURSE_STYLE'] = $courseStyle;
     //$!!!courseTakeInArrangeArray[$courseTakeCounter]['QUANTITY'] = $appointedClassArray[$classCounter][$courseName]/$ONE_COURSE_PERIOD;
     $courseTakeInArrangeArray[$courseTakeCounter]['QUANTITY'] = $coursePeriod;
     //从数组中填充排列完的课程
     $appointedClassArray[$classCounter][$courseName] = "F";
     //填充F.Finish