diff --git a/~dev_rating/application/classes/Controller/Handler/FileCreator.php b/~dev_rating/application/classes/Controller/Handler/FileCreator.php index 82901f13667dc4a5fbe270325edc2ec1f4858291..88a3841bf4459099986823d0566acdc3e11a8f2a 100644 --- a/~dev_rating/application/classes/Controller/Handler/FileCreator.php +++ b/~dev_rating/application/classes/Controller/Handler/FileCreator.php @@ -173,31 +173,30 @@ class Controller_Handler_FileCreator extends Controller_Handler // Ведомость public function action_GenerateExcelStatement() { - // TODO CHECK!!! - - // parameters - $disciplineID = $this->post->offsetGet('disciplineID'); + // TODO CHECK!!! + + // parameters + $disciplineID = $this->post->offsetGet('disciplineID'); $groupID = $this->post->offsetGet('studyGroupID'); - - //$disciplineID = 266; - //$groupID = 11; - - // preparation - $db = $this->model; + // preparation + $db = $this->model; $info = $db->getFinalFormInfo($disciplineID, $groupID); $type = $info[0]['ExamType']; - // $specName = ''; <------- TODO - - $templateFile = DOCROOT."docs/template $type.xls"; + $templateFile = DOCROOT."docs/template $type.xls"; if (!file_exists($templateFile)) { exit("template wasn't found" . PHP_EOL); // TODO } + $objPHPExcel = PHPExcel_IOFactory::load($templateFile); + $objPHPExcel->setActiveSheetIndex(0); + $index = 1; + + // $specName = ''; <------- TODO $result = $db->getRatesForStudentsGroup($this->user['TeacherID'], $disciplineID, $groupID); $rowsCount = count($result); // Получаем количество записей $objPHPExcel = PHPExcel_IOFactory::load($templateFile); - $objPHPExcel->setActiveSheetIndex(0); + $objPHPExcel->setActiveSheetIndex(0); // fill header @@ -221,13 +220,13 @@ class Controller_Handler_FileCreator extends Controller_Handler $objPHPExcel->getActiveSheet()->setCellValue("$range", date("d.m.y")); $range = $objPHPExcel->getNamedRange("Date")->getRange(); if ($type == 'exam') - $controlDate = "Дата экзамена \n__________"; + $controlDate = '__________'; else - $controlDate = "Дата зачета \n30.12.2014"; - $objPHPExcel->getActiveSheet()->setCellValue("$range", $controlDate); + $controlDate = '30.12.2014'; + $objPHPExcel->getActiveSheet()->setCellValue("$range", "Дата зачета \n$controlDate"); // fill students rows - $startRow = 12; + $startRow = 13; $finalRow = 52; $indPosition = 'A'; // Номер $namePosition = 'B'; // Р¤РРћ @@ -236,8 +235,14 @@ class Controller_Handler_FileCreator extends Controller_Handler $bonusRatePosition = 'I'; // Бонусные баллы $rowNumber = $startRow; $index = 1; + foreach($result as $studentInfo){ - + + $objPHPExcel->getActiveSheet()->insertNewRowBefore($rowNumber + 1, 1); + $objPHPExcel->getActiveSheet()->getStyle("A".$rowNumber.":S".$rowNumber)->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); + + $objPHPExcel->getActiveSheet()->mergeCells("B".$rowNumber.":F".$rowNumber); + $lastName = $studentInfo['Last']; $firstName = $studentInfo['First']; $secondName = $studentInfo['Second']; @@ -245,24 +250,33 @@ class Controller_Handler_FileCreator extends Controller_Handler $bonus = (int)$studentInfo['bonus']; $fullName = "$lastName $firstName $secondName"; $totalRate = $rate + $bonus; - + + if($totalRate < 60) + { + $tempRate = " "; + $tempStr = "РЅРµ зачтено"; + } + else + { + $tempStr = "зачтено"; + $tempRate = $totalRate; + } + $objPHPExcel->getActiveSheet()->setCellValue("$indPosition$rowNumber", "$index") ->setCellValue("$namePosition$rowNumber", "$fullName") - ->setCellValue("$totalRatePosition$rowNumber", "$totalRate") + ->setCellValue("$totalRatePosition$rowNumber", "$tempRate") ->setCellValue("$semesterRatePosition$rowNumber","$rate") - ->setCellValue("$bonusRatePosition$rowNumber","$bonus"); + ->setCellValue("$bonusRatePosition$rowNumber","$bonus") + ->setCellValue("J".$rowNumber,$tempStr); + $rowNumber++; - $index++; + $index++; } - - // delete rest rows - $objPHPExcel->getActiveSheet()->removeRow($rowNumber+1, $finalRow); - - $this->GetHeaders('FinalForm'); + $this->GetHeaders("FinalForm".$disciplineID."_".$groupID); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); - } + } // Выводим HTTP-заголовки public function GetHeaders($filename = 'excel') diff --git a/~dev_rating/docs/template credit.xls b/~dev_rating/docs/template credit.xls index c94873a0a043c1f27038116883bc280c31c100c6..3efe9c7f2eecc7d658d857fb90e482818417b15a 100644 Binary files a/~dev_rating/docs/template credit.xls and b/~dev_rating/docs/template credit.xls differ diff --git a/~dev_rating/docs/template exam.xls b/~dev_rating/docs/template exam.xls index b272e99f3b750f5b97c13fe99a67e7af4eb5f5eb..682553295565fb2e1931608da9f2bebac94b6c46 100644 Binary files a/~dev_rating/docs/template exam.xls and b/~dev_rating/docs/template exam.xls differ