Exemplo n.º 1
0
 public function insertanpaimanual($stname, $xh, $whichweek, $weekday, $zhibantime)
 {
     $year_xq = $this->xuenianxueqi();
     //判断该学生这班是否有空
     $content = self::getemptyst($whichweek, $weekday, $zhibantime);
     $num = 0;
     foreach ($content as $key => $value) {
         if (in_array($xh, $value)) {
             $num = 1;
         } else {
             continue;
         }
     }
     //如果课程不冲突
     if ($num == 1) {
         $newzhiban = new Zhibantable();
         $newzhiban->stname = $stname;
         $newzhiban->stid = $xh;
         $newzhiban->date_zhoushu = $whichweek;
         $newzhiban->date_weekday = $weekday;
         $newzhiban->date_turn = $zhibantime;
         $newzhiban->year_xq = $year_xq;
         //判断该学生是否已经这一天这一班有安排了
         $sql1 = "select * from zhibantable WHERE stname='{$stname}' AND stid='{$xh}' AND date_zhoushu='{$whichweek}' AND date_weekday='{$weekday}' AND date_turn='{$zhibantime}'AND year_xq='{$year_xq}'";
         //判断这一天这一班是否满了
         $sql2 = "select COUNT(*) from zhibantable WHERE   date_zhoushu='{$whichweek}' AND date_weekday='{$weekday}' AND date_turn='{$zhibantime}'AND year_xq='{$year_xq}'";
         if (Yii::$app->db->createCommand($sql1)->queryOne()) {
             $result = '{"success":false,"msg":"该学生已经安排过此日期的排班了"}';
         } else {
             if (Yii::$app->db->createCommand($sql2)->queryScalar() >= 2) {
                 $result = '{"success":false,"msg":"这一班已经安排满了"}';
             } else {
                 $newzhiban->save(false);
                 $result = '{"success":true,"msg":"安排值班成功"}';
             }
         }
         return $result;
     } else {
         $newzhiban = new Zhibantable();
         $newzhiban->stname = $stname;
         $newzhiban->stid = $xh;
         $newzhiban->date_zhoushu = $whichweek;
         $newzhiban->date_weekday = $weekday;
         $newzhiban->date_turn = $zhibantime;
         $newzhiban->year_xq = $year_xq;
         $newzhiban->conflict_class = "有课程冲突";
         //判断该学生是否已经这一天这一班有安排了
         $sql1 = "select * from zhibantable WHERE stname='{$stname}' AND stid='{$xh}' AND date_zhoushu='{$whichweek}' AND date_weekday='{$weekday}' AND date_turn='{$zhibantime}'AND year_xq='{$year_xq}'";
         //判断这一天这一班是否满了
         $sql2 = "select COUNT(*) from zhibantable WHERE   date_zhoushu='{$whichweek}' AND date_weekday='{$weekday}' AND date_turn='{$zhibantime}'AND year_xq='{$year_xq}'";
         if (Yii::$app->db->createCommand($sql1)->queryOne()) {
             $result = '{"success":false,"msg":"该学生已经安排过此日期的排班了"}';
         } else {
             if (Yii::$app->db->createCommand($sql2)->queryScalar() >= 2) {
                 $result = '{"success":false,"msg":"这一班已经安排满了"}';
             } else {
                 $newzhiban->save(false);
                 $result = '{"success":true,"msg":"安排值班成功(有课程冲突)"}';
             }
         }
         return $result;
     }
 }
 public function actionSearchorder()
 {
     $nowuser = \Yii::$app->user->identity->XH_ID;
     $usertb = new UserTb();
     $name = $usertb->getName($nowuser);
     $request = Yii::$app->request;
     $session = Yii::$app->session;
     $whichweek = $request->get('whichweek_user');
     $weekday = $request->get('weekday_user');
     $session['whichweek_2'] = $whichweek;
     $session['weekday_2'] = $weekday;
     $anpaitable = new Zhibantable();
     $year_xq = $anpaitable->xuenianxueqi();
     $content = $anpaitable->findanpaidata_2($session['whichweek_2'], $session['weekday_2'], $year_xq, $nowuser);
     echo '{"success":true,"name":"' . $name . '","anpai":' . json_encode($content, JSON_UNESCAPED_UNICODE) . '}';
 }