@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @param unknown $id |
| 15 | 15 | */ |
| 16 | 16 | private static function getData($id, $type) { |
| 17 | - $raport = PatientRaport::getRaportBetweenDates ( $id, $type, '2014-06-01', (new \DateTime ())->format ( "Y-m-d" ) ); |
|
| 17 | + $raport = PatientRaport::getRaportBetweenDates($id, $type, '2014-06-01', (new \DateTime())->format("Y-m-d")); |
|
| 18 | 18 | return $raport; |
| 19 | 19 | } |
| 20 | 20 | /** |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | private static function printHeaders($objPHPExcel, $cols) { |
| 26 | 26 | $count = 1; |
| 27 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 2, "Data" ); |
|
| 28 | - foreach ( $cols as $col ) { |
|
| 29 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, 2, sprintf ( "%7s", $col ) ); |
|
| 27 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 2, "Data"); |
|
| 28 | + foreach ($cols as $col) { |
|
| 29 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, 2, sprintf("%7s", $col)); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | /** |
@@ -34,45 +34,45 @@ discard block |
||
| 34 | 34 | private static function printData($objPHPExcel, $data, $type) { |
| 35 | 35 | $row = 3; |
| 36 | 36 | $lastColumn = 1; |
| 37 | - $colNumberOfPatients = ExcelExport::getColumnLetter ( 1 ); |
|
| 38 | - $indexes = PatientRaport::getIndexes ( $type ); |
|
| 39 | - foreach ( $data as $rowKey => $rowValue ) { |
|
| 37 | + $colNumberOfPatients = ExcelExport::getColumnLetter(1); |
|
| 38 | + $indexes = PatientRaport::getIndexes($type); |
|
| 39 | + foreach ($data as $rowKey => $rowValue) { |
|
| 40 | 40 | // 1 col: date |
| 41 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row, json_encode ( $rowKey ) ); |
|
| 41 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row, json_encode($rowKey)); |
|
| 42 | 42 | $count = 1; |
| 43 | 43 | // 2-5 cols: N1 N2 N3 N0 |
| 44 | - foreach ( $indexes as $index ) { |
|
| 45 | - $value = isset ( $rowValue [$index] ) ? $rowValue [$index] : "0"; |
|
| 46 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, $value ); |
|
| 44 | + foreach ($indexes as $index) { |
|
| 45 | + $value = isset ($rowValue [$index]) ? $rowValue [$index] : "0"; |
|
| 46 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, $value); |
|
| 47 | 47 | } |
| 48 | 48 | // 6 col: num of categorized (N = N1+N2+N3) |
| 49 | - $colHighestCategory = ExcelExport::getColumnLetter ( $count - 2 ); |
|
| 50 | - $colNumberOfPatients = ExcelExport::getColumnLetter ( $count ); |
|
| 51 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, '=SUM(B' . $row . ':' . $colHighestCategory . $row . ')' ); |
|
| 52 | - $tpb = PatientRaport::getTpb ( $type ); |
|
| 49 | + $colHighestCategory = ExcelExport::getColumnLetter($count - 2); |
|
| 50 | + $colNumberOfPatients = ExcelExport::getColumnLetter($count); |
|
| 51 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, '=SUM(B'.$row.':'.$colHighestCategory.$row.')'); |
|
| 52 | + $tpb = PatientRaport::getTpb($type); |
|
| 53 | 53 | // 7-11 tpb1, tpb2, tpb3, 0 (no-cat), 2 (add) |
| 54 | - foreach ( $tpb as $tpbn ) { |
|
| 55 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, $tpbn ); |
|
| 54 | + foreach ($tpb as $tpbn) { |
|
| 55 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, $tpbn); |
|
| 56 | 56 | } |
| 57 | 57 | // 9-11: Tpb1*N1,Tpb2*N2,Tpb3*N3+2xN |
| 58 | - $tpbSize = count ( $tpb ); |
|
| 59 | - foreach ( $tpb as $tpbn ) { |
|
| 60 | - $col1Letter = ExcelExport::getColumnLetter ( $count - 2 * $tpbSize ); |
|
| 61 | - $col2Letter = ExcelExport::getColumnLetter ( $count - $tpbSize ); |
|
| 62 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, '=' . $col1Letter . $row . "*" . $col2Letter . $row ); |
|
| 58 | + $tpbSize = count($tpb); |
|
| 59 | + foreach ($tpb as $tpbn) { |
|
| 60 | + $col1Letter = ExcelExport::getColumnLetter($count - 2 * $tpbSize); |
|
| 61 | + $col2Letter = ExcelExport::getColumnLetter($count - $tpbSize); |
|
| 62 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, '='.$col1Letter.$row."*".$col2Letter.$row); |
|
| 63 | 63 | } |
| 64 | 64 | // SUM Tpb |
| 65 | - $col3Letter = ExcelExport::getColumnLetter ( $count - $tpbSize ); |
|
| 66 | - $col4Letter = ExcelExport::getColumnLetter ( $count - 1 ); |
|
| 67 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, '=SUM(' . $col3Letter . $row . ":" . $col4Letter . $row . ")" ); |
|
| 65 | + $col3Letter = ExcelExport::getColumnLetter($count - $tpbSize); |
|
| 66 | + $col4Letter = ExcelExport::getColumnLetter($count - 1); |
|
| 67 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, '=SUM('.$col3Letter.$row.":".$col4Letter.$row.")"); |
|
| 68 | 68 | $row ++; |
| 69 | 69 | $lastColumn = $count - 1; |
| 70 | 70 | } |
| 71 | 71 | // number of categorization days |
| 72 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 1, 1, '=COUNTIFS(' . $colNumberOfPatients . '3:' . $colNumberOfPatients . ($row - 1) . ',">0")' ); |
|
| 72 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, '=COUNTIFS('.$colNumberOfPatients.'3:'.$colNumberOfPatients.($row - 1).',">0")'); |
|
| 73 | 73 | // sum |
| 74 | - $col5Letter = ExcelExport::getColumnLetter ( $lastColumn ); |
|
| 75 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 2, 1, '=SUM(' . $col5Letter . '3:' . $col5Letter . ($row - 1) . ')/60' ); |
|
| 74 | + $col5Letter = ExcelExport::getColumnLetter($lastColumn); |
|
| 75 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 1, '=SUM('.$col5Letter.'3:'.$col5Letter.($row - 1).')/60'); |
|
| 76 | 76 | return $row; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -81,61 +81,61 @@ discard block |
||
| 81 | 81 | * @param unknown $objPHPExcel |
| 82 | 82 | */ |
| 83 | 83 | static function fillSummary($objPHPExcel) { |
| 84 | - ExcelExport::newSheet ( $objPHPExcel, 0 ); |
|
| 85 | - ExcelExport::printTitle ( $objPHPExcel, "Raport" ); |
|
| 86 | - $sheetCount = $objPHPExcel->getSheetCount (); |
|
| 87 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'A2', 'Oddz.' ); |
|
| 88 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'B2', 'Dni' ); |
|
| 89 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'C2', 'Tpb' ); |
|
| 90 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'D2', 'Tśpb' ); |
|
| 91 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'E2', 'Tśpc*' ); |
|
| 92 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'F2', 'Tśpc**' ); |
|
| 93 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'G2', 'Td***' ); |
|
| 94 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'H2', 'Le*' ); |
|
| 95 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'I2', 'Le**' ); |
|
| 96 | - for($i = 1; $i < $sheetCount; $i ++) { |
|
| 97 | - $loadedSheetNames = $objPHPExcel->getSheetNames (); |
|
| 98 | - foreach ( $loadedSheetNames as $sheetIndex => $loadedSheetName ) { |
|
| 84 | + ExcelExport::newSheet($objPHPExcel, 0); |
|
| 85 | + ExcelExport::printTitle($objPHPExcel, "Raport"); |
|
| 86 | + $sheetCount = $objPHPExcel->getSheetCount(); |
|
| 87 | + $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Oddz.'); |
|
| 88 | + $objPHPExcel->getActiveSheet()->setCellValue('B2', 'Dni'); |
|
| 89 | + $objPHPExcel->getActiveSheet()->setCellValue('C2', 'Tpb'); |
|
| 90 | + $objPHPExcel->getActiveSheet()->setCellValue('D2', 'Tśpb'); |
|
| 91 | + $objPHPExcel->getActiveSheet()->setCellValue('E2', 'Tśpc*'); |
|
| 92 | + $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Tśpc**'); |
|
| 93 | + $objPHPExcel->getActiveSheet()->setCellValue('G2', 'Td***'); |
|
| 94 | + $objPHPExcel->getActiveSheet()->setCellValue('H2', 'Le*'); |
|
| 95 | + $objPHPExcel->getActiveSheet()->setCellValue('I2', 'Le**'); |
|
| 96 | + for ($i = 1; $i < $sheetCount; $i ++) { |
|
| 97 | + $loadedSheetNames = $objPHPExcel->getSheetNames(); |
|
| 98 | + foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
| 99 | 99 | if ($sheetIndex == 0) { |
| 100 | 100 | continue; |
| 101 | 101 | } |
| 102 | 102 | $row = $sheetIndex + 2; |
| 103 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'A' . $row, "='" . $loadedSheetName . "'!A1" ); |
|
| 104 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'B' . $row, "='" . $loadedSheetName . "'!B1" ); |
|
| 105 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'C' . $row, "='" . $loadedSheetName . "'!C1" ); |
|
| 106 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 3, $row, "=IF(C" . $row . ">0,C" . $row . "/B" . $row . ",0)" ); |
|
| 107 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 4, $row, "=D" . $row . "*110%" ); |
|
| 108 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 5, $row, "=D" . $row . "*125%" ); |
|
| 109 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 6, $row, "1531" ); |
|
| 110 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 7, $row, "=IF(E" . $row . ">0,E" . $row . "*365/G" . $row . ",\"-\")" ); |
|
| 111 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 8, $row, "=IF(F" . $row . ">0,F" . $row . "*365/G" . $row . ",\"-\")" ); |
|
| 103 | + $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, "='".$loadedSheetName."'!A1"); |
|
| 104 | + $objPHPExcel->getActiveSheet()->setCellValue('B'.$row, "='".$loadedSheetName."'!B1"); |
|
| 105 | + $objPHPExcel->getActiveSheet()->setCellValue('C'.$row, "='".$loadedSheetName."'!C1"); |
|
| 106 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $row, "=IF(C".$row.">0,C".$row."/B".$row.",0)"); |
|
| 107 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $row, "=D".$row."*110%"); |
|
| 108 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $row, "=D".$row."*125%"); |
|
| 109 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $row, "1531"); |
|
| 110 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $row, "=IF(E".$row.">0,E".$row."*365/G".$row.",\"-\")"); |
|
| 111 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $row, "=IF(F".$row.">0,F".$row."*365/G".$row.",\"-\")"); |
|
| 112 | 112 | } |
| 113 | - $objPHPExcel->getActiveSheet ()->getStyle ( 'C3:I100' )->getNumberFormat ()->setFormatCode ( '#,##0.0' ); |
|
| 114 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row + 1, "* Czas pielęgnacji pośredniej jako 10% czasu pielęgnacji bezpośredniej" ); |
|
| 115 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row + 2, "** Czas pielęgnacji pośredniej jako 25% czasu pielęgnacji bezpośredniej" ); |
|
| 116 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row + 3, "*** Czas dyspozycyjny - propozycja z Rozporządzenia MZ: 202 dni x 7,58 h" ); |
|
| 117 | - ExcelExport::styleActiveSheet ( $objPHPExcel ); |
|
| 113 | + $objPHPExcel->getActiveSheet()->getStyle('C3:I100')->getNumberFormat()->setFormatCode('#,##0.0'); |
|
| 114 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row + 1, "* Czas pielęgnacji pośredniej jako 10% czasu pielęgnacji bezpośredniej"); |
|
| 115 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row + 2, "** Czas pielęgnacji pośredniej jako 25% czasu pielęgnacji bezpośredniej"); |
|
| 116 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row + 3, "*** Czas dyspozycyjny - propozycja z Rozporządzenia MZ: 202 dni x 7,58 h"); |
|
| 117 | + ExcelExport::styleActiveSheet($objPHPExcel); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | static function fillData($objPHPExcel) { |
| 121 | 121 | // no time limit for this script |
| 122 | - set_time_limit ( 0 ); |
|
| 123 | - $time_start = microtime ( true ); |
|
| 122 | + set_time_limit(0); |
|
| 123 | + $time_start = microtime(true); |
|
| 124 | 124 | // remove first default sheet |
| 125 | - $objPHPExcel->removeSheetByIndex ( 0 ); |
|
| 125 | + $objPHPExcel->removeSheetByIndex(0); |
|
| 126 | 126 | // get wards |
| 127 | - $wards = WardCRUD::getWardsArray (); |
|
| 128 | - foreach ( $wards as $ward ) { |
|
| 129 | - ExcelExport::newSheet ( $objPHPExcel ); |
|
| 130 | - $wardName = $ward->name . " (" . $ward->getTypOddzialu () . ")"; |
|
| 131 | - ExcelExport::printTitle ( $objPHPExcel, $wardName ); |
|
| 132 | - $data = ExcelExportPunction::getData ( $ward->id, $ward->getTypOddzialu () ); |
|
| 133 | - $cols = PatientRaport::getColumns ( $ward->getTypOddzialu () ); |
|
| 134 | - ExcelExportPunction::printHeaders ( $objPHPExcel, $cols ); |
|
| 135 | - ExcelExportPunction::printData ( $objPHPExcel, $data, $ward->getTypOddzialu () ); |
|
| 136 | - ExcelExport::styleActiveSheet ( $objPHPExcel ); |
|
| 127 | + $wards = WardCRUD::getWardsArray(); |
|
| 128 | + foreach ($wards as $ward) { |
|
| 129 | + ExcelExport::newSheet($objPHPExcel); |
|
| 130 | + $wardName = $ward->name." (".$ward->getTypOddzialu().")"; |
|
| 131 | + ExcelExport::printTitle($objPHPExcel, $wardName); |
|
| 132 | + $data = ExcelExportPunction::getData($ward->id, $ward->getTypOddzialu()); |
|
| 133 | + $cols = PatientRaport::getColumns($ward->getTypOddzialu()); |
|
| 134 | + ExcelExportPunction::printHeaders($objPHPExcel, $cols); |
|
| 135 | + ExcelExportPunction::printData($objPHPExcel, $data, $ward->getTypOddzialu()); |
|
| 136 | + ExcelExport::styleActiveSheet($objPHPExcel); |
|
| 137 | 137 | } |
| 138 | - ExcelExportPunction::fillSummary ( $objPHPExcel ); |
|
| 139 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 100, "summary " . ($time_start - microtime ( true )) . " s" ); |
|
| 138 | + ExcelExportPunction::fillSummary($objPHPExcel); |
|
| 139 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 100, "summary ".($time_start - microtime(true))." s"); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | \ No newline at end of file |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | public static function getRandomPerson() |
| 55 | 55 | { |
| 56 | 56 | // TODO extract paths |
| 57 | - self::$names = Utils::readFileToArray(__DIR__ . '/../../resources/pl_names.csv'); |
|
| 58 | - self::$mnames = Utils::readFileToArray(__DIR__ . '/../../resources/pl_mnames.csv'); |
|
| 59 | - self::$fnames = Utils::readFileToArray(__DIR__ . '/../../resources/pl_fnames.csv'); |
|
| 57 | + self::$names = Utils::readFileToArray(__DIR__.'/../../resources/pl_names.csv'); |
|
| 58 | + self::$mnames = Utils::readFileToArray(__DIR__.'/../../resources/pl_mnames.csv'); |
|
| 59 | + self::$fnames = Utils::readFileToArray(__DIR__.'/../../resources/pl_fnames.csv'); |
|
| 60 | 60 | // var_dump(self::$mnames); |
| 61 | 61 | $sex = (rand(0, 1) == 0 ? 'm' : 'f'); |
| 62 | 62 | $firstname = ($sex == 'm' ? self::getRandom(self::$mnames) : self::getRandom(self::$fnames)); |
| 63 | 63 | $lastname = self::getRandom(self::$names); |
| 64 | 64 | if ($sex == 'f' && self::endsWith($lastname, 'i')) { |
| 65 | - $lastname = rtrim($lastname, "i") . 'a'; |
|
| 65 | + $lastname = rtrim($lastname, "i").'a'; |
|
| 66 | 66 | } |
| 67 | 67 | $bdate = self::getRandomBirthDate(); |
| 68 | 68 | $pesel = self::getRandomPesel($bdate, $sex); |
| 69 | - return $firstname . ' ' . $lastname . '|' . $pesel; |
|
| 69 | + return $firstname.' '.$lastname.'|'.$pesel; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $age = rand(0, 100); |
| 88 | 88 | $dayOfYear = rand(0, 365); |
| 89 | - $interval = new \DateInterval('P' . $age . 'Y' . $dayOfYear . 'D'); |
|
| 89 | + $interval = new \DateInterval('P'.$age.'Y'.$dayOfYear.'D'); |
|
| 90 | 90 | $date = new \DateTime(); |
| 91 | 91 | $birth = $date->sub($interval); |
| 92 | 92 | return $birth->format('Y-m-d'); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public static function getNextDay($month, $day) |
| 67 | 67 | { |
| 68 | - return Utils::getNextDayDate('Y-' . $month . '-' . $day); |
|
| 68 | + return Utils::getNextDayDate('Y-'.$month.'-'.$day); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public static function getNextMonthFirstDay($month, $day) |
| 104 | 104 | { |
| 105 | - return date('Y-m-d', strtotime('+1 month', strtotime(date('Y-' . $month . '-01')))); |
|
| 105 | + return date('Y-m-d', strtotime('+1 month', strtotime(date('Y-'.$month.'-01')))); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | } else |
| 130 | 130 | if ($day == null) { |
| 131 | 131 | // first day of mnth |
| 132 | - $date = new \DateTime(date('Y-') . $month . '-01'); |
|
| 132 | + $date = new \DateTime(date('Y-').$month.'-01'); |
|
| 133 | 133 | } else { |
| 134 | 134 | // date |
| 135 | - $date = new \DateTime(date('Y-' . $month . '-' . $day)); |
|
| 135 | + $date = new \DateTime(date('Y-'.$month.'-'.$day)); |
|
| 136 | 136 | } |
| 137 | 137 | return $date->format('Y-m-d'); |
| 138 | 138 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public static function getStartEndDate($dateParam) |
| 172 | 172 | { |
| 173 | - if (empty($dateParam) || ! in_array($dateParam, array( |
|
| 173 | + if (empty($dateParam) || !in_array($dateParam, array( |
|
| 174 | 174 | 0, |
| 175 | 175 | 1, |
| 176 | 176 | 7 |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | * loading envs |
| 56 | 56 | */ |
| 57 | 57 | private static function _loadEnv() { |
| 58 | - if (getenv ( 'DB_NAME' ) != null && getenv ( 'DB_NAME' ) != "") { |
|
| 58 | + if (getenv('DB_NAME') != null && getenv('DB_NAME') != "") { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | - if (defined ( 'ABSPATH' )) { |
|
| 62 | - \Dotenv::load ( ABSPATH ); |
|
| 61 | + if (defined('ABSPATH')) { |
|
| 62 | + \Dotenv::load(ABSPATH); |
|
| 63 | 63 | } else { |
| 64 | - \Dotenv::load ( getenv ( 'HOME' ) ); |
|
| 64 | + \Dotenv::load(getenv('HOME')); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | private static function getPaths() { |
| 68 | - if (file_exists ( getcwd () . "/src/Entities" )) { |
|
| 69 | - return array ( |
|
| 70 | - getcwd () . "/src/Entities" |
|
| 68 | + if (file_exists(getcwd()."/src/Entities")) { |
|
| 69 | + return array( |
|
| 70 | + getcwd()."/src/Entities" |
|
| 71 | 71 | ); |
| 72 | 72 | } else { |
| 73 | - return array ( |
|
| 74 | - getcwd () . "/vendor/amarcinkowski/hospitalplugin/src/Entities" |
|
| 73 | + return array( |
|
| 74 | + getcwd()."/vendor/amarcinkowski/hospitalplugin/src/Entities" |
|
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private static function _getInstance() { |
| 84 | 84 | $isDevMode = true; |
| 85 | - $config = Setup::createAnnotationMetadataConfiguration ( self::getPaths (), $isDevMode ); |
|
| 86 | - self::_loadEnv (); |
|
| 87 | - $conn = array ( |
|
| 88 | - 'dbname' => getenv ( 'DB_NAME' ), |
|
| 89 | - 'user' => getenv ( 'DB_USER' ), |
|
| 90 | - 'password' => getenv ( 'DB_PASSWORD' ), |
|
| 91 | - 'host' => getenv ( 'DB_HOST' ), |
|
| 85 | + $config = Setup::createAnnotationMetadataConfiguration(self::getPaths(), $isDevMode); |
|
| 86 | + self::_loadEnv(); |
|
| 87 | + $conn = array( |
|
| 88 | + 'dbname' => getenv('DB_NAME'), |
|
| 89 | + 'user' => getenv('DB_USER'), |
|
| 90 | + 'password' => getenv('DB_PASSWORD'), |
|
| 91 | + 'host' => getenv('DB_HOST'), |
|
| 92 | 92 | 'driver' => 'pdo_mysql', |
| 93 | 93 | 'charset' => 'utf8', |
| 94 | - 'driverOptions' => array ( |
|
| 94 | + 'driverOptions' => array( |
|
| 95 | 95 | 1002 => 'SET NAMES utf8' |
| 96 | 96 | ), |
| 97 | 97 | 'mapping_types' => 'enum:string' |
| 98 | 98 | ); |
| 99 | - return EntityManager::create ( $conn, $config ); |
|
| 99 | + return EntityManager::create($conn, $config); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static function getEntityManager() { |
| 108 | 108 | if (self::$_entityManager == null) { |
| 109 | - self::$_entityManager = self::_getInstance (); |
|
| 109 | + self::$_entityManager = self::_getInstance(); |
|
| 110 | 110 | } |
| 111 | 111 | return self::$_entityManager; |
| 112 | 112 | } |
| 113 | 113 | public static function getCli() { |
| 114 | - $em = DoctrineBootstrap::getEntityManager (); |
|
| 115 | - $em->getConnection ()->getDatabasePlatform ()->registerDoctrineTypeMapping ( 'enum', 'string' ); |
|
| 116 | - return ConsoleRunner::createHelperSet ( $em ); |
|
| 114 | + $em = DoctrineBootstrap::getEntityManager(); |
|
| 115 | + $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); |
|
| 116 | + return ConsoleRunner::createHelperSet($em); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |