예제 #1
0
 public function diemdanhAction()
 {
     $lop = new Model_Lophoc();
     $idlop = $classes_id = $_GET['idlop'];
     $buoi = $_GET['buoi'];
     $this->view->idlop = $idlop;
     $this->view->buoi = $buoi;
     $stt = 1;
     $listsv = $lop->listsv($idlop);
     $this->view->listsv = $listsv;
     $lophoc = $lop->findOneLop($classes_id);
     $this->view->lop = $lophoc;
     for ($i = 1; $i <= $lophoc->session_number; $i++) {
         $s[$i] = $lop->buoidadiemdanh($idlop, $i);
     }
     $this->view->s = $s;
     $kiemtra = $lop->kiemtra($idlop, $buoi);
     if ($kiemtra > 0) {
         //printf('buoi hoc nay da diem danh');
     } else {
         $ng = $this->_getParam('ngay');
         $c = $this->_getParam('check');
         $ngoaigio = $this->_getParam('ngoaigio');
         $dataOvertime = array(['classes_id' => $idlop, 'session' => $buoi, 'date_update' => $ng, 'isOvertime' => $ngoaigio]);
         if ($this->_request->isPost()) {
             if ($ng != 0 and $ng >= date('Y-m-d') and $buoi != 0 and $ngoaigio != null) {
                 for ($i = 0; $i < count($c); $i++) {
                     $dihoc = $c[$i];
                     if ($lophoc->session_number == $buoi) {
                         $lop->diemdanh($idlop, $dihoc, $ng, $buoi, $ngoaigio);
                         $lop->buoicuoi($idlop, $stt);
                     } else {
                         $lop->diemdanh($idlop, $dihoc, $ng, $buoi, $ngoaigio);
                     }
                 }
                 if ($ngoaigio != null) {
                     $lop->addOvertime($dataOvertime);
                 }
                 echo "<script>alert('Điểm danh thành công');</script>";
                 $this->redirect('lop/chitietdiemdanh?idlop=' . $idlop);
             } else {
                 echo "<script>alert('Chưa chọn đủ thông tin');</script>";
             }
         }
     }
 }