Пример #1
0
 public function baocaotongketAction()
 {
     $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;
     foreach ($listsv as $sv) {
         $masv = $sv->student_id;
         $diem[$masv] = $lop->indiem($idlop, $masv);
     }
     $this->view->diem = $diem;
 }
Пример #2
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>";
         }
     }
 }
Пример #3
0
 private function createCSVFinal()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $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;
     $schoolyears_name = $lop->findschoolyears($lophoc->schoolyears_id);
     $this->view->schoolyears_name = $schoolyears_name;
     $diemtru = $lop->diemtru();
     $this->view->diemtru = $diemtru;
     foreach ($listsv as $sv) {
         $masv = $sv->student_id;
         $dihoc[$masv] = $lop->dihoc($idlop, $masv);
     }
     $this->view->dihoc = $dihoc;
     foreach ($listsv as $sv) {
         $masv = $sv->student_id;
         $diem[$masv] = $lop->indiem($idlop, $masv);
     }
     //Create Excel file
     $header = "Ma SV" . ",\t";
     $header .= "Ten SV" . ",\t";
     $header .= "Diem Chuyen Can" . ",\t";
     $header .= "Diem Kiem Tra" . ",\t";
     $header .= "Diem Qua Trinh" . ",\t";
     $header .= "Ghi Chu" . ",\t\n";
     $line = '';
     //var_dump($header); exit;
     foreach ($listsv as $listsv) {
         $dcc = 10 - $diemtru[0]->minus_point * ($lophoc->session_number - count($dihoc[$listsv->student_id]));
         $tong = $dcc * 0.3 + $diem[$listsv->student_id][0]->process_grade * 0.7;
         $value1 = str_replace('"', '""', $listsv->student_id);
         $value2 = str_replace('"', '""', $listsv->student_name);
         $value3 = str_replace('"', '""', $dcc);
         $value4 = str_replace('"', '""', $diem[$listsv->student_id][0]->process_grade);
         $value5 = str_replace('"', '""', $tong);
         $value6 = str_replace('"', '""', $tong > 5 ? 'Đ' : 'K');
         $value = '"' . $value1 . '"' . ",\t" . $value2 . ",\t" . $value3 . ",\t" . $value4 . ",\t" . $value5 . ",\t" . $value6 . ",\t\n";
         $line .= $value;
     }
     $data .= trim($line) . "\n";
     $data = str_replace("\r", "", $data);
     // output data
     echo $header . "\n" . $data;
     header('Content-Encoding: UTF-8');
     header("Content-type: application/csv; name='excel';charset='UTF-8'");
     header("Content-Disposition: attachment; filename=" . $lophoc->classes_name . ".csv");
     header("Pragma: no-cache");
     header("Expires: 0");
 }