예제 #1
0
 public function nhapdiemAction()
 {
     $lop = new Model_Lophoc();
     $idlop = $classes_id = $_GET['idlop'];
     $listsv = $lop->listsv($idlop);
     $this->view->listsv = $listsv;
     $lophoc = $lop->findOneLop($classes_id);
     $this->view->lop = $lophoc;
     $hocky = $lop->findschoolyears($lophoc->schoolyears_id);
     $this->view->hocky = $hocky;
     $diemtru = $lop->diemtru();
     $this->view->diemtru = $diemtru;
     //echo '<pre>';
     //print_r($diemtru[0]->minus_point);
     //echo '</pre>';
     foreach ($listsv as $sv) {
         $masv = $sv->student_id;
         $dihoc[$masv] = $lop->dihoc($idlop, $masv);
     }
     $this->view->dihoc = $dihoc;
     $listnhap = $lop->kiemtranhapdiem($idlop);
     $this->view->listnhap = $listnhap;
     foreach ($listsv as $sv) {
         $masv = $sv->student_id;
         $diem[$masv] = $lop->indiem($idlop, $masv);
     }
     $this->view->diem = $diem;
     $idsv = $this->_getParam('id');
     $diemchuyencan = $this->_getParam('diemchuyencan');
     $diemquatrinh = $this->_getParam('diemquatrinh');
     if ($this->_request->isPost()) {
         $kiemtra = $lop->kiemtranhapdiem($idlop);
         if (count($kiemtra) > 0) {
             for ($i = 0; $i < count($idsv); $i++) {
                 $student_id = $idsv[$i];
                 $dcc = $diemchuyencan[$i];
                 $dqt = $diemquatrinh[$i];
                 $lop->updatediem($student_id, $idlop, $dcc, $dqt);
             }
             // $this->redirect('nhapdiem/nhapdiem?idlop='.$idlop);
             header("Refresh:0");
             echo "<script>alert('Nhập điểm thành công');</script>";
         } else {
             for ($i = 0; $i < count($idsv); $i++) {
                 $student_id = $idsv[$i];
                 $dcc = $diemchuyencan[$i];
                 $dqt = $diemquatrinh[$i];
                 $lop->nhapdiem($student_id, $idlop, $dcc, $dqt);
             }
             //$this->redirect('nhapdiem/nhapdiem?idlop='.$idlop);
             header("Refresh:0");
             echo "<script>alert('Nhập điểm thành công');</script>";
         }
     }
 }