예제 #1
0
 /**
  * If no training associations, delete course. 
  */
 public static function deleteIfNotFound($training_title_option_id, $training_id = 0)
 {
     $tableObj = new Course();
     $select = $tableObj->select()->from('training', array('COUNT(id) AS training_count'))->setIntegrityCheck(false)->where("course_id = {$training_title_option_id} AND id != {$training_id}");
     $row = $tableObj->fetchRow($select);
     if (!$row->training_count) {
         $tableObj = new Course();
         $tableObj->delete("training_title_option_id = {$training_title_option_id}");
         $tableObj = new ITechTable(array('name' => 'training_title_option'));
         $tableObj->delete("id = {$training_title_option_id}");
     }
 }
<?php

include_once $CFG->dirroot . "/lib/classes/" . "application/Course.Class.php5";
$courseObj = new Course();
$GeneralObj->getRequestVars();
$mode = $_REQUEST['mode'];
if ($mode == "Update") {
    $courseObj->select($iCourseId);
    $courseObj->getAllVar();
    if ($dCourseDateTime != "0000-00-00 00:00:00") {
        $iStarttime = date("H", strtotime($dCourseDateTime));
        $iStartTimeMM = date("i", strtotime($dCourseDateTime));
        $dCourseDateTime = substr($dCourseDateTime, 0, 10);
    }
    if ($iStarttime > 12) {
        $iStarttime = $iStarttime - 12;
        $SAMPM = "PM";
    } else {
        $SAMPM = "AM";
    }
} else {
    $mode = "Add";
}
if ($file != '') {
    $link = "index.php?file=" . $file . "&mode=" . $mode . "&listfile=" . $listfile;
}
$section = "Courses";
$TOP_HEADER = $mode . ' ' . $section;
if ($mode == 'Update') {
    $TOP_HEADER .= ' [' . $vCoursename . ']';
}
예제 #3
0
 public function sortDataCourseJson()
 {
     ini_set('max_execution_time', 600000000);
     $listCourse = Course::select('id', 'name', 'desc', 'subject', 'word')->get();
     $size = count($listCourse);
     for ($i = 0; $i < $size; $i++) {
         $course = $listCourse[$i];
         $subject = Subject::where('id_course', $course->id)->count();
         $word = Word::where('id_course', $course->id)->count();
         Course::where('id', $course->id)->update(array('subject' => $subject, 'word' => $word));
     }
     try {
         $strListCourse = json_encode(Course::select('id', 'name', 'desc', 'subject', 'word', 'status', 'srclang', 'deslang')->where('status', 1)->get());
         $fileNameCourse = public_path() . '/AllData/courses.json';
         $fileCourse = fopen($fileNameCourse, "w");
         if (fwrite($fileCourse, $strListCourse)) {
             fclose($fileCourse);
             return Redirect::back()->with('notify', 'Xuất dữ liệu thành công');
         } else {
             fclose($fileCourse);
             return Redirect::back()->with('error', 'Có lỗi trong quá trình xuất dữ liệu');
         }
     } catch (Exception $e) {
         return Redirect::back()->with('error', 'Có lỗi trong quá trình xuất dữ liệu');
     }
 }