Exemplo n.º 1
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     $classid = $this->getRequest()->getParam('ClassID');
     $data = array();
     if (empty($classid)) {
         $data['pagename'] = '课程添加';
         $data['info'] = array();
     } else {
         $data['pagename'] = '课程编辑';
         $data['info'] = Admin_ClassesModel::instance()->fetchRow(array('condition' => 'classid = ?', 'bind' => array($classid)));
     }
     $data['grade'] = RThink_Config::get('app.grade');
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     $post = $this->getRequest()->getPost();
     $imageKey = RThink_Config::get('app.imageKey');
     $videoKey = RThink_Config::get('app.videoKey');
     $pt = '.';
     $imageName = $videoName = '';
     //上传图片和视频
     if ($_FILES['Image']['error'] == 0) {
         $imageName = md5($imageKey . $post['ClassNo']) . $pt . $this->getFileExtend($post['file_0']);
         move_uploaded_file($_FILES['Image']['tmp_name'], RThink_Config::get('app.imagePath') . '\\' . $imageName);
     }
     if ($_FILES['Video']['error'] == 0) {
         $videoName = md5($videoKey . $post['ClassNo']) . $pt . $this->getFileExtend($post['file_1']);
         move_uploaded_file($_FILES['Video']['tmp_name'], RThink_Config::get('app.videoPath') . '\\' . $videoName);
     }
     $params = array('No' => $post['No'], 'ClassType' => $post['ClassType'], 'ClassNo' => $post['ClassNo'], 'Grade' => $post['Grade'], 'SubjectID' => $post['SubjectID'], 'Chapter' => $post['Chapter'], 'Name' => $post['Name'], 'Teacher' => $post['Teacher'], 'Desc' => $post['Desc'], 'Price' => $post['Price'], 'UpdateTime' => date('Y-m-d H:i:s'));
     if ($imageName != '') {
         $params['Image'] = $imageName;
     }
     if ($videoName != '') {
         $params['Video'] = $videoName;
     }
     $ClassID = $this->getRequest()->getPost('ClassID');
     if (null != $ClassID) {
         Admin_ClassesModel::instance()->update($params, array('ClassID' => $ClassID));
     } else {
         $params['CreateTime'] = date('Y-m-d H:i:s');
         Admin_ClassesModel::instance()->add($params);
     }
     $this->sendMsg(1, "操作成功");
 }
Exemplo n.º 3
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     $ClassID = $this->getRequest()->getParam('ClassID');
     Admin_ClassesModel::instance()->delete(array('ClassID' => $ClassID));
     $this->sendMsg(1, '删除成功');
 }
Exemplo n.º 4
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     $Grade = $this->getRequest()->getParam('Grade');
     $SubjectID = $this->getRequest()->getParam('SubjectID');
     $Chapter = $this->getRequest()->getParam('Chapter');
     $ClassType = $this->getRequest()->getParam('ClassType');
     if (empty($Grade) || empty($SubjectID) || empty($Chapter)) {
         $this->sendMsg(1, '请将课程信息填写完整');
     }
     $option = array('condition' => 'Grade = ? and SubjectID = ? and Chapter = ? and ClassType = ? ', 'bind' => array($Grade, $SubjectID, $Chapter, $ClassType), 'order' => 'No desc', 'limit' => '');
     $maxNo = Admin_ClassesModel::instance()->getMaxNo($option);
     $No = $maxNo ? $maxNo + 1 : 1;
     $option1 = array('condition' => 'SubjectID = ? ', 'bind' => array($SubjectID), 'limit' => '');
     $SubjectType = Admin_SubjectModel::instance()->getSubjectType($option1);
     $data['ClassNo'] = sprintf("%d%02d%02d%02d", $SubjectType, $Grade, $Chapter, $No);
     $data['No'] = $No;
     $this->sendMsg(0, '成功', $data);
 }
Exemplo n.º 5
0
 public function indexAction()
 {
     //检查权限
     $this->verify(__METHOD__);
     $show['pagename'] = '课程列表';
     $grade = $this->getRequest()->getQuery('Grade');
     $subject = $this->getRequest()->getQuery('SubjectID');
     $chapter = $this->getRequest()->getQuery('Chapter');
     $classno = $this->getRequest()->getQuery('ClassNo');
     $memberID = $this->getRequest()->getQuery('MemberID');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     $option = array('condition' => '', 'order' => 'ClassNo asc,Grade asc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     $data['count'] = Admin_AdminModel::instance()->count($count_opt);
     $conditionArr = $bindArr = array();
     if (!empty($grade)) {
         $conditionArr[] = "grade = ?";
         $bindArr[] = $grade;
     }
     if (!empty($subject)) {
         $conditionArr[] = "subjectid = ?";
         $bindArr[] = $subject;
     }
     if (!empty($classno)) {
         $conditionArr[] = "classno = ?";
         $bindArr[] = $classno;
     }
     if (!empty($chapter)) {
         $conditionArr[] = "chapter = ?";
         $bindArr[] = $chapter;
     }
     $option['condition'] = $count_opt['condition'] = implode(' and ', $conditionArr);
     $option['bind'] = $count_opt['bind'] = $bindArr;
     // print_r($option);exit;
     $data['classList'] = Admin_ClassesModel::instance()->fetchAll($option);
     $data['count'] = Admin_ClassesModel::instance()->count($count_opt);
     $data['grade'] = RThink_Config::get('app.grade');
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $data['query'] = array('ClassNo' => $classno, 'Grade' => $grade, 'SubjectID' => $subject, 'Chapter' => $chapter, 'MemberID' => $memberID);
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $recommendClassIds = array();
     if (!empty($memberID)) {
         $recommend_option = array('fields' => 'ClassID', 'condition' => 'MemberID = ?', 'bind' => array($memberID), 'order' => 'ClassID desc', 'limit' => '');
         $recommendClasses = Admin_RecommendModel::instance()->fetchAll($recommend_option);
         foreach ($recommendClasses as $key => $value) {
             $recommendClassIds[] = $value['ClassID'];
         }
     }
     $data['recommendClassIds'] = $recommendClassIds;
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }