Completed
Push — master ( 1fd7e7...a2c36e )
by Andrzej
03:49
created
src/Entities/HospitalForm.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,6 @@
 block discarded – undo
25 25
 namespace Hospitalplugin\Entities;
26 26
 
27 27
 use Hospitalplugin\DB\DoctrineBootstrap;
28
-use Hospitalplugin\utils\Utils;
29
-use Hospitalplugin\Twig\EscapePLCharsExtension;
30 28
 use Hospitalplugin\Entities\WardCRUD;
31 29
 use Hospitalplugin\Twig\PLTwig;
32 30
 
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@
 block discarded – undo
31 31
 use Hospitalplugin\Twig\PLTwig;
32 32
 
33 33
 class HospitalForm {
34
-	public static function load($yaml, $class, $dir) {
35
-		try {
36
-			$em = DoctrineBootstrap::getEntityManager ();
34
+    public static function load($yaml, $class, $dir) {
35
+        try {
36
+            $em = DoctrineBootstrap::getEntityManager ();
37 37
 			
38
-			$userId = $userId = wp_get_current_user ()->ID;
39
-			$ward = WardCRUD::getWardForUser ( $userId );
40
-			$user = $em->find ( "\Hospitalplugin\Entities\User", $userId );
38
+            $userId = $userId = wp_get_current_user ()->ID;
39
+            $ward = WardCRUD::getWardForUser ( $userId );
40
+            $user = $em->find ( "\Hospitalplugin\Entities\User", $userId );
41 41
 			
42
-			if (! empty ( $_POST )) {
43
-				$args = $_POST;
44
-				$i = new $class ( $args );
45
-				$i->setWard ( $ward );
46
-				$i->setUser ( $user );
47
-				$em->persist ( $i );
48
-				$em->flush ();
49
-			} else {
50
-				$object = \Hospitalplugin\utils\YAML2Object::getObject ( $yaml );
51
-				echo PLTwig::load ( $dir )->render ( 'form.twig', array (
52
-						'infections' => $object 
53
-				) );
54
-			}
55
-		} catch ( Exception $e ) {
56
-			echo "ERR: " . $e;
57
-		}
58
-	}
42
+            if (! empty ( $_POST )) {
43
+                $args = $_POST;
44
+                $i = new $class ( $args );
45
+                $i->setWard ( $ward );
46
+                $i->setUser ( $user );
47
+                $em->persist ( $i );
48
+                $em->flush ();
49
+            } else {
50
+                $object = \Hospitalplugin\utils\YAML2Object::getObject ( $yaml );
51
+                echo PLTwig::load ( $dir )->render ( 'form.twig', array (
52
+                        'infections' => $object 
53
+                ) );
54
+            }
55
+        } catch ( Exception $e ) {
56
+            echo "ERR: " . $e;
57
+        }
58
+    }
59 59
 }
60 60
 ?>
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
src/Entities/InfectionsCRUD.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,6 @@
 block discarded – undo
25 25
 namespace Hospitalplugin\Entities;
26 26
 
27 27
 use Hospitalplugin\DB\DoctrineBootstrap;
28
-use Hospitalplugin\utils\Utils;
29 28
 
30 29
 class InfectionsCRUD {
31 30
 	public static function getInfections($from, $to, $wardId, $class) {
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,44 +28,44 @@
 block discarded – undo
28 28
 use Hospitalplugin\utils\Utils;
29 29
 
30 30
 class InfectionsCRUD {
31
-	public static function getInfections($from, $to, $wardId, $class) {
32
-		$em = ( object ) DoctrineBootstrap::getEntityManager ();
33
-		$qb = $em->createQueryBuilder ();
34
-		$qb->select ( 'i' )->from ( 'Hospitalplugin\Entities\\' . $class, 'i' ) /* */
31
+    public static function getInfections($from, $to, $wardId, $class) {
32
+        $em = ( object ) DoctrineBootstrap::getEntityManager ();
33
+        $qb = $em->createQueryBuilder ();
34
+        $qb->select ( 'i' )->from ( 'Hospitalplugin\Entities\\' . $class, 'i' ) /* */
35 35
         ->addOrderBy ( 'i.dataRaportu', 'DESC' ) /* */
36 36
         ->addOrderBy ( 'i.dataPrzeslania ', 'DESC' ) /* */
37 37
         ->where ( /* */
38
-        		$qb->expr ()->between ( 'i.dataRaportu', ':from', ':to' ) ) /* */
39
-        		->setParameters ( array (
40
-				'from' => $from,
41
-				'to' => $to 
42
-		) );
43
-		if ($wardId != 'all') {
44
-			$qb->andWhere ( $qb->expr ()->eq ( 'i.ward', ':ward' ) ) /* */
45
-        			->setParameter ( 'ward', $wardId );
46
-		}
38
+                $qb->expr ()->between ( 'i.dataRaportu', ':from', ':to' ) ) /* */
39
+                ->setParameters ( array (
40
+                'from' => $from,
41
+                'to' => $to 
42
+        ) );
43
+        if ($wardId != 'all') {
44
+            $qb->andWhere ( $qb->expr ()->eq ( 'i.ward', ':ward' ) ) /* */
45
+                    ->setParameter ( 'ward', $wardId );
46
+        }
47 47
 		
48
-		$query = $qb->getQuery ();
49
-		$infections = $query->getResult ();
48
+        $query = $qb->getQuery ();
49
+        $infections = $query->getResult ();
50 50
 		
51
-		return $infections;
52
-	}
53
-	public static function updateVerification($id, $weryfikacja) {
54
-		if ($id != null && $weryfikacja != null) {
55
-			$em = ( object ) DoctrineBootstrap::getEntityManager ();
56
-			$infection = $em->getRepository ( 'Hospitalplugin\Entities\Infections' )->find ( $id );
57
-			$infection->setWeryfikacja ( $weryfikacja );
58
-			$em->flush ();
59
-		}
60
-	}
61
-	public static function obj2DB($obj) {
62
-		$id = $obj->id;
63
-		$em = DoctrineBootstrap::getEntityManager();
64
-		$infection = $em->getRepository('Hospitalplugin\Entities\Infections')->find($id);
65
-		$infection->setWeryfikacja($obj->value);
66
-		$em->persist($infection);
67
-		$em->flush();
68
-		echo $id;
69
-	}
51
+        return $infections;
52
+    }
53
+    public static function updateVerification($id, $weryfikacja) {
54
+        if ($id != null && $weryfikacja != null) {
55
+            $em = ( object ) DoctrineBootstrap::getEntityManager ();
56
+            $infection = $em->getRepository ( 'Hospitalplugin\Entities\Infections' )->find ( $id );
57
+            $infection->setWeryfikacja ( $weryfikacja );
58
+            $em->flush ();
59
+        }
60
+    }
61
+    public static function obj2DB($obj) {
62
+        $id = $obj->id;
63
+        $em = DoctrineBootstrap::getEntityManager();
64
+        $infection = $em->getRepository('Hospitalplugin\Entities\Infections')->find($id);
65
+        $infection->setWeryfikacja($obj->value);
66
+        $em->persist($infection);
67
+        $em->flush();
68
+        echo $id;
69
+    }
70 70
 }
71 71
 ?>
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
src/Entities/PatientCRUD.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,6 @@
 block discarded – undo
27 27
 use Hospitalplugin\DB\DoctrineBootstrap;
28 28
 use Hospitalplugin\Entities\Patient;
29 29
 use Hospitalplugin\Entities\PatientDeleted;
30
-use Hospitalplugin\Entities\PatientFactory;
31 30
 use Hospitalplugin\utils\Utils;
32 31
 
33 32
 class PatientCRUD {
Please login to merge, or discard this patch.
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -32,120 +32,120 @@
 block discarded – undo
32 32
 
33 33
 class PatientCRUD {
34 34
 	
35
-	/**
36
-	 * getPatients
37
-	 *
38
-	 * @param int $day
39
-	 *        	dayOfTheMonth
40
-	 * @param int $month
41
-	 *        	month
42
-	 *        	
43
-	 * @return Patient array
44
-	 */
45
-	public static function getPatients($month = null, $day = null, $wardId = 0) {
46
-		return PatientCRUD::getPatientsDateRange ( Utils::getStartDate ( $month, $day ), Utils::getEndDate ( $month, $day ), $wardId );
47
-	}
35
+    /**
36
+     * getPatients
37
+     *
38
+     * @param int $day
39
+     *        	dayOfTheMonth
40
+     * @param int $month
41
+     *        	month
42
+     *        	
43
+     * @return Patient array
44
+     */
45
+    public static function getPatients($month = null, $day = null, $wardId = 0) {
46
+        return PatientCRUD::getPatientsDateRange ( Utils::getStartDate ( $month, $day ), Utils::getEndDate ( $month, $day ), $wardId );
47
+    }
48 48
 	
49
-	/**
50
-	 * getPatientsDateRange
51
-	 *
52
-	 * TODO(AM) testy na przypadki graniczne - pacjenci z data przed polnoca, po polnocy, godzina przed obecna, po obecnej
53
-	 *
54
-	 * @param int $day
55
-	 *        	dayOfTheMonth
56
-	 * @param int $month
57
-	 *        	month
58
-	 *        	
59
-	 * @return Patient array
60
-	 */
61
-	public static function getPatientsDateRange($date1, $date2, $wardId = 0) {
62
-		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
63
-		$params = array (
64
-				'from' => $date1,
65
-				'to' => $date2,
66
-				'oddzialId' => $wardId 
67
-		);
68
-		$q = $entityManager->createQuery ( 'select p FROM Hospitalplugin\Entities\Patient p WHERE p.dataKategoryzacji BETWEEN :from AND :to and p.oddzialId = :oddzialId ORDER BY p.name' )->setParameters ( $params )->setFirstResult ( 0 )->setMaxResults ( 1000 );
69
-		$patients = $q->getResult ();
70
-		return $patients;
71
-	}
49
+    /**
50
+     * getPatientsDateRange
51
+     *
52
+     * TODO(AM) testy na przypadki graniczne - pacjenci z data przed polnoca, po polnocy, godzina przed obecna, po obecnej
53
+     *
54
+     * @param int $day
55
+     *        	dayOfTheMonth
56
+     * @param int $month
57
+     *        	month
58
+     *        	
59
+     * @return Patient array
60
+     */
61
+    public static function getPatientsDateRange($date1, $date2, $wardId = 0) {
62
+        $entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
63
+        $params = array (
64
+                'from' => $date1,
65
+                'to' => $date2,
66
+                'oddzialId' => $wardId 
67
+        );
68
+        $q = $entityManager->createQuery ( 'select p FROM Hospitalplugin\Entities\Patient p WHERE p.dataKategoryzacji BETWEEN :from AND :to and p.oddzialId = :oddzialId ORDER BY p.name' )->setParameters ( $params )->setFirstResult ( 0 )->setMaxResults ( 1000 );
69
+        $patients = $q->getResult ();
70
+        return $patients;
71
+    }
72 72
 	
73
-	/**
74
-	 * getPatient
75
-	 *
76
-	 * @param $id $id
77
-	 *        	int
78
-	 *        	
79
-	 * @return Patient Patient
80
-	 */
81
-	public static function getPatient($id, $type = '') {
82
-		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
83
-		$type = 'Hospitalplugin\Entities\Patient' . $type;
84
-		$patient = $entityManager->getRepository ( $type )->findOneBy ( array (
85
-				'id' => $id 
86
-		) );
87
-		return Utils::cast ( $type, ( object ) $patient, 0 );
88
-	}
73
+    /**
74
+     * getPatient
75
+     *
76
+     * @param $id $id
77
+     *        	int
78
+     *        	
79
+     * @return Patient Patient
80
+     */
81
+    public static function getPatient($id, $type = '') {
82
+        $entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
83
+        $type = 'Hospitalplugin\Entities\Patient' . $type;
84
+        $patient = $entityManager->getRepository ( $type )->findOneBy ( array (
85
+                'id' => $id 
86
+        ) );
87
+        return Utils::cast ( $type, ( object ) $patient, 0 );
88
+    }
89 89
 	
90
-	/**
91
-	 * setPatientCategories
92
-	 *
93
-	 * @param Patient $obj        	
94
-	 *
95
-	 * @return Patient
96
-	 */
97
-	public static function setPatientCategories($obj, $type) {
98
-		$entityManager = DoctrineBootstrap::getEntityManager ();
99
-		$patient = PatientCRUD::getPatient ( $obj->id, $type );
100
-		foreach ( get_object_vars ( $obj ) as $key => $value ) {
101
-			call_user_func ( array (
102
-					$patient,
103
-					'set' . ucwords ( $key ) 
104
-			), $value );
105
-		}
106
-		$entityManager->merge ( $patient );
107
-		$entityManager->flush ();
108
-		return $patient;
109
-	}
90
+    /**
91
+     * setPatientCategories
92
+     *
93
+     * @param Patient $obj        	
94
+     *
95
+     * @return Patient
96
+     */
97
+    public static function setPatientCategories($obj, $type) {
98
+        $entityManager = DoctrineBootstrap::getEntityManager ();
99
+        $patient = PatientCRUD::getPatient ( $obj->id, $type );
100
+        foreach ( get_object_vars ( $obj ) as $key => $value ) {
101
+            call_user_func ( array (
102
+                    $patient,
103
+                    'set' . ucwords ( $key ) 
104
+            ), $value );
105
+        }
106
+        $entityManager->merge ( $patient );
107
+        $entityManager->flush ();
108
+        return $patient;
109
+    }
110 110
 	
111
-	/**
112
-	 * setPatientCategories
113
-	 *
114
-	 * @param Patient $obj        	
115
-	 *
116
-	 * @return Patient
117
-	 */
118
-	public static function createPatient($type, $name, $pesel) {
119
-		$entityManager = DoctrineBootstrap::getEntityManager ();
120
-		$type = 'Hospitalplugin\Entities\Patient' . $type;
121
-		$patient = new $type ();
122
-		$patient->setName ( $name );
123
-		$patient->setPesel ( $pesel );
124
-		$entityManager->persist ( $patient );
125
-		$entityManager->flush ();
126
-		return $patient;
127
-	}
111
+    /**
112
+     * setPatientCategories
113
+     *
114
+     * @param Patient $obj        	
115
+     *
116
+     * @return Patient
117
+     */
118
+    public static function createPatient($type, $name, $pesel) {
119
+        $entityManager = DoctrineBootstrap::getEntityManager ();
120
+        $type = 'Hospitalplugin\Entities\Patient' . $type;
121
+        $patient = new $type ();
122
+        $patient->setName ( $name );
123
+        $patient->setPesel ( $pesel );
124
+        $entityManager->persist ( $patient );
125
+        $entityManager->flush ();
126
+        return $patient;
127
+    }
128 128
 	
129
-	/**
130
-	 * deletePatient
131
-	 *
132
-	 * @param $id $id
133
-	 *        	int
134
-	 */
135
-	public static function deletePatient($id, $userId = 0) {
136
-		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
137
-		$type = 'Hospitalplugin\Entities\Patient';
138
-		$patient = $entityManager->getRepository ( $type )->findOneBy ( array (
139
-				'id' => $id 
140
-		) );
141
-		$entityManager->remove ( $patient );
142
-		$log = strval($patient);
143
-		$audit = new PatientDeleted();
144
-		$audit->deletedAt = new \DateTime ();
145
-		$audit->deletedByUserId = $userId;
146
-		$audit->log = $log;
147
-		$entityManager->persist ( $audit );
148
-		$entityManager->flush ();
149
-	}
129
+    /**
130
+     * deletePatient
131
+     *
132
+     * @param $id $id
133
+     *        	int
134
+     */
135
+    public static function deletePatient($id, $userId = 0) {
136
+        $entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
137
+        $type = 'Hospitalplugin\Entities\Patient';
138
+        $patient = $entityManager->getRepository ( $type )->findOneBy ( array (
139
+                'id' => $id 
140
+        ) );
141
+        $entityManager->remove ( $patient );
142
+        $log = strval($patient);
143
+        $audit = new PatientDeleted();
144
+        $audit->deletedAt = new \DateTime ();
145
+        $audit->deletedByUserId = $userId;
146
+        $audit->log = $log;
147
+        $entityManager->persist ( $audit );
148
+        $entityManager->flush ();
149
+    }
150 150
 }
151 151
 ?>
152 152
\ No newline at end of file
Please login to merge, or discard this patch.
src/Entities/PatientRaportOptimized.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,6 @@
 block discarded – undo
3 3
 namespace Hospitalplugin\Entities;
4 4
 
5 5
 use Hospitalplugin\DB\DoctrineBootstrap;
6
-use Hospitalplugin\utils\Utils;
7
-use Doctrine\DBAL\Schema\View;
8
-use Doctrine\ORM\Query\ResultSetMapping;
9 6
 
10 7
 class PatientRaportOptimized {
11 8
 	/**
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,26 +8,26 @@  discard block
 block discarded – undo
8 8
 use Doctrine\ORM\Query\ResultSetMapping;
9 9
 
10 10
 class PatientRaportOptimized {
11
-	/**
12
-	 *
13
-	 * @param unknown $wardId        	
14
-	 * @param unknown $date        	
15
-	 */
16
-	public static function getRaport($wardId, $date) {
17
-		$startDate = $date . '-01';
18
-		$endDate = date ( "Y-m-t 23:59:59", strtotime ( $startDate ) );
11
+    /**
12
+     *
13
+     * @param unknown $wardId        	
14
+     * @param unknown $date        	
15
+     */
16
+    public static function getRaport($wardId, $date) {
17
+        $startDate = $date . '-01';
18
+        $endDate = date ( "Y-m-t 23:59:59", strtotime ( $startDate ) );
19 19
 		
20
-		return PatientRaportOptimized::getRaportBetweenDatesNative ( $wardId, $startDate, $endDate );
21
-	}
22
-	private static function updateNativeRaport() {
23
-		$em = DoctrineBootstrap::getEntityManager ();
24
-		$conn = $em->getConnection ();
25
-		// create report table
26
-		$sql1 = "CREATE TABLE IF NOT EXISTS kategoria_view 
20
+        return PatientRaportOptimized::getRaportBetweenDatesNative ( $wardId, $startDate, $endDate );
21
+    }
22
+    private static function updateNativeRaport() {
23
+        $em = DoctrineBootstrap::getEntityManager ();
24
+        $conn = $em->getConnection ();
25
+        // create report table
26
+        $sql1 = "CREATE TABLE IF NOT EXISTS kategoria_view 
27 27
 					(data DATETIME, oddzialId INT, kategoria INT, suma INT,
28 28
 					PRIMARY KEY (data,oddzialId,kategoria));";
29
-		// update view
30
-		$sql2 = "INSERT INTO kategoria_view 
29
+        // update view
30
+        $sql2 = "INSERT INTO kategoria_view 
31 31
 					SELECT 
32 32
 						date( dataKategoryzacji ), 
33 33
 						oddzialId, 
@@ -48,37 +48,37 @@  discard block
 block discarded – undo
48 48
 					oddzialId, 
49 49
 					date( dataKategoryzacji ) , 
50 50
 					kategoriaPacjenta";
51
-		// select
52
-		try {
53
-			$conn->query ( $sql1 );
54
-			$conn->query ( $sql2 );
55
-		} catch ( Exception $e ) {
56
-			// echo 'Caught exception: ', $e->getMessage(), "\n";
57
-		}
58
-	}
59
-	/**
60
-	 * 
61
-	 * @param unknown $wardId
62
-	 * @param unknown $startDate
63
-	 * @param unknown $endDate
64
-	 */
65
-	public static function getRaportBetweenDatesNative($wardId, $startDate, $endDate) {
66
-		$em = DoctrineBootstrap::getEntityManager ();
67
-		PatientRaportOptimized::updateNativeRaport();
68
-		$conn = $em->getConnection ();
69
-		$sql3 = "SELECT kategoria, date(data) as data, suma FROM kategoria_view WHERE data between :data1 AND :data2 and oddzialId = :oddzialId";
70
-		$stmt = $conn->prepare ( $sql3 );
71
-		$stmt->execute ( array (
72
-				'data1' => $startDate,
73
-				'data2' => $endDate,
74
-				'oddzialId' => $wardId 
75
-		) );
76
-		$result = $stmt->fetchAll();
77
-		$table = array ();
78
-		foreach ( $result as $row ) {
79
-			$table [$row ['data']] [$row ['kategoria']] = $row ['suma'];
80
-		}
81
-		return $table;
82
-	}
51
+        // select
52
+        try {
53
+            $conn->query ( $sql1 );
54
+            $conn->query ( $sql2 );
55
+        } catch ( Exception $e ) {
56
+            // echo 'Caught exception: ', $e->getMessage(), "\n";
57
+        }
58
+    }
59
+    /**
60
+     * 
61
+     * @param unknown $wardId
62
+     * @param unknown $startDate
63
+     * @param unknown $endDate
64
+     */
65
+    public static function getRaportBetweenDatesNative($wardId, $startDate, $endDate) {
66
+        $em = DoctrineBootstrap::getEntityManager ();
67
+        PatientRaportOptimized::updateNativeRaport();
68
+        $conn = $em->getConnection ();
69
+        $sql3 = "SELECT kategoria, date(data) as data, suma FROM kategoria_view WHERE data between :data1 AND :data2 and oddzialId = :oddzialId";
70
+        $stmt = $conn->prepare ( $sql3 );
71
+        $stmt->execute ( array (
72
+                'data1' => $startDate,
73
+                'data2' => $endDate,
74
+                'oddzialId' => $wardId 
75
+        ) );
76
+        $result = $stmt->fetchAll();
77
+        $table = array ();
78
+        foreach ( $result as $row ) {
79
+            $table [$row ['data']] [$row ['kategoria']] = $row ['suma'];
80
+        }
81
+        return $table;
82
+    }
83 83
 	
84 84
 }
85 85
\ No newline at end of file
Please login to merge, or discard this patch.
src/utils/ExcelExport.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace Hospitalplugin\utils;
4 4
 
5
-use Hospitalplugin\Entities\InfectionsCRUD;
6 5
 use Hospitalplugin\Entities\Infections;
7 6
 
8 7
 class ExcelExport {
Please login to merge, or discard this patch.
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -7,119 +7,119 @@
 block discarded – undo
7 7
 
8 8
 class ExcelExport {
9 9
 	
10
-	/**
11
-	 */
12
-	public static function init() {
13
-		add_action ( 'admin_init', array (
14
-				'Hospitalplugin\utils\ExcelExport',
15
-				'excel_export' 
16
-		), 1 );
17
-	}
18
-	/**
19
-	 * 
20
-	 */
21
-	public static function getColumnLetter($num) {
22
-		return chr ( 65 + $num );
23
-	}
24
-	/**
25
-	 */
26
-	static function excel_export() {
27
-		if (! isset ( $_POST ['excel'] )) {
28
-			return;
29
-		} else {
30
-			// dataSetName: Infections, Punction
31
-			$dataSetName = $_POST ['dataSetName'];
32
-			$classname = '\Hospitalplugin\utils\ExcelExport' . $dataSetName;
33
-		}
10
+    /**
11
+     */
12
+    public static function init() {
13
+        add_action ( 'admin_init', array (
14
+                'Hospitalplugin\utils\ExcelExport',
15
+                'excel_export' 
16
+        ), 1 );
17
+    }
18
+    /**
19
+     * 
20
+     */
21
+    public static function getColumnLetter($num) {
22
+        return chr ( 65 + $num );
23
+    }
24
+    /**
25
+     */
26
+    static function excel_export() {
27
+        if (! isset ( $_POST ['excel'] )) {
28
+            return;
29
+        } else {
30
+            // dataSetName: Infections, Punction
31
+            $dataSetName = $_POST ['dataSetName'];
32
+            $classname = '\Hospitalplugin\utils\ExcelExport' . $dataSetName;
33
+        }
34 34
 		
35
-		$objPHPExcel = new \PHPExcel ();
36
-		$classname::fillData ( $objPHPExcel );
35
+        $objPHPExcel = new \PHPExcel ();
36
+        $classname::fillData ( $objPHPExcel );
37 37
 		
38
-		ExcelExport::downloadExcel ( $objPHPExcel, $dataSetName . '.xlsx' );
39
-	}
40
-	/**
41
-	 */
42
-	static function cellColor($objPHPExcel, $cells, $color) {
43
-		$objPHPExcel->getActiveSheet ()->getStyle ( $cells )->getFill ()->applyFromArray ( array (
44
-				'type' => \PHPExcel_Style_Fill::FILL_SOLID,
45
-				'startcolor' => array (
46
-						'rgb' => $color 
47
-				) 
48
-		) );
49
-	}
50
-	/**
51
-	 */
52
-	static function styleActiveSheet($objPHPExcel) {
53
-		$objPHPExcel->getActiveSheet ()->getDefaultStyle ()->getFont ()->setName ( 'Arial' )->setSize ( 8 )->setBold ( false );
54
-		$objPHPExcel->getActiveSheet ()->getDefaultStyle ()->getNumberFormat ()->setFormatCode ( \PHPExcel_Style_NumberFormat::FORMAT_TEXT );
55
-		$objPHPExcel->getActiveSheet ()->freezePane ( 'A3' );
56
-		$style = array (
57
-				'alignment' => array (
58
-						'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
59
-						'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER 
60
-				) 
61
-		);
62
-		$objWorksheet = $objPHPExcel->getActiveSheet ();
63
-		$objWorksheet->getDefaultStyle ()->applyFromArray ( $style );
64
-		$objWorksheet->getStyle ( 'A1:AA2' )->getFont ()->setBold ( true );
65
-		for($col = ord ( 'a' ); $col <= ord ( 'z' ); $col ++) {
66
-			$objWorksheet->getColumnDimension ( chr ( $col ) )->setAutoSize ( true );
67
-		}
68
-		return $objPHPExcel;
69
-	}
70
-	/**
71
-	 *
72
-	 * @param unknown $objPHPExcel        	
73
-	 */
74
-	private static function downloadExcel($objPHPExcel, $filename) {
75
-		ob_end_clean ();
76
-		ob_start ();
77
-		header ( "Content-type: application/vnd.ms-excel; charset=utf-8" );
78
-		header ( "Content-Transfer-Encoding: binary" );
79
-		header ( "Content-Description: File Transfer" );
80
-		header ( "Content-Disposition: attachment; filename=\"" . $filename . "\"" );
81
-		header ( "Cache-Control: max-age=0" );
82
-		header ( "Expires: 0" );
83
-		header ( "Pragma: no-cache" );
38
+        ExcelExport::downloadExcel ( $objPHPExcel, $dataSetName . '.xlsx' );
39
+    }
40
+    /**
41
+     */
42
+    static function cellColor($objPHPExcel, $cells, $color) {
43
+        $objPHPExcel->getActiveSheet ()->getStyle ( $cells )->getFill ()->applyFromArray ( array (
44
+                'type' => \PHPExcel_Style_Fill::FILL_SOLID,
45
+                'startcolor' => array (
46
+                        'rgb' => $color 
47
+                ) 
48
+        ) );
49
+    }
50
+    /**
51
+     */
52
+    static function styleActiveSheet($objPHPExcel) {
53
+        $objPHPExcel->getActiveSheet ()->getDefaultStyle ()->getFont ()->setName ( 'Arial' )->setSize ( 8 )->setBold ( false );
54
+        $objPHPExcel->getActiveSheet ()->getDefaultStyle ()->getNumberFormat ()->setFormatCode ( \PHPExcel_Style_NumberFormat::FORMAT_TEXT );
55
+        $objPHPExcel->getActiveSheet ()->freezePane ( 'A3' );
56
+        $style = array (
57
+                'alignment' => array (
58
+                        'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
59
+                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER 
60
+                ) 
61
+        );
62
+        $objWorksheet = $objPHPExcel->getActiveSheet ();
63
+        $objWorksheet->getDefaultStyle ()->applyFromArray ( $style );
64
+        $objWorksheet->getStyle ( 'A1:AA2' )->getFont ()->setBold ( true );
65
+        for($col = ord ( 'a' ); $col <= ord ( 'z' ); $col ++) {
66
+            $objWorksheet->getColumnDimension ( chr ( $col ) )->setAutoSize ( true );
67
+        }
68
+        return $objPHPExcel;
69
+    }
70
+    /**
71
+     *
72
+     * @param unknown $objPHPExcel        	
73
+     */
74
+    private static function downloadExcel($objPHPExcel, $filename) {
75
+        ob_end_clean ();
76
+        ob_start ();
77
+        header ( "Content-type: application/vnd.ms-excel; charset=utf-8" );
78
+        header ( "Content-Transfer-Encoding: binary" );
79
+        header ( "Content-Description: File Transfer" );
80
+        header ( "Content-Disposition: attachment; filename=\"" . $filename . "\"" );
81
+        header ( "Cache-Control: max-age=0" );
82
+        header ( "Expires: 0" );
83
+        header ( "Pragma: no-cache" );
84 84
 		
85
-		$objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel2007' );
86
-		$objWriter->setPreCalculateFormulas ( true );
87
-		$objWriter->save ( 'php://output' );
88
-		exit ();
89
-	}
90
-	/**
91
-	 * remove special chars and words from string 
92
-	 * @param unknown $string        	
93
-	 */
94
-	private static function clearName($string, $removeWords) {
95
-		$string = str_replace ( ' ', '-', $string );
96
-		$string = preg_replace ( '/[^A-Za-z0-9\-]/', '', $string );
97
-		foreach ( $removeWords as $word ) {
98
-			$string = str_replace ( $word, '', $string );
99
-		}
100
-		$string = substr ( $string, 0, 29 );
101
-		return $string;
102
-	}
103
-	/**
104
-	 * @param unknown $objPHPExcel        	
105
-	 * @param unknown $title        	
106
-	 */
107
-	static function printTitle($objPHPExcel, $title) {
108
-		$objPHPExcel->getActiveSheet ()->setTitle ( ExcelExport::clearName ( $title, array('ddzia') ), true );
109
-		$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 1, $title );
110
-	}
111
-	/**
112
-	 *
113
-	 * @param unknown $objPHPExcel
114
-	 */
115
-	static function newSheet($objPHPExcel, $index = -1) {
116
-		if ($index < 0) {
117
-			$index = $objPHPExcel->getSheetCount ();
118
-		}
119
-		$objPHPExcel->createSheet ( $index );
120
-		$objPHPExcel->setActiveSheetIndex ( $index );
121
-		$sheet = $objPHPExcel->getActiveSheet ();
122
-		return $sheet;
123
-	}
85
+        $objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel2007' );
86
+        $objWriter->setPreCalculateFormulas ( true );
87
+        $objWriter->save ( 'php://output' );
88
+        exit ();
89
+    }
90
+    /**
91
+     * remove special chars and words from string 
92
+     * @param unknown $string        	
93
+     */
94
+    private static function clearName($string, $removeWords) {
95
+        $string = str_replace ( ' ', '-', $string );
96
+        $string = preg_replace ( '/[^A-Za-z0-9\-]/', '', $string );
97
+        foreach ( $removeWords as $word ) {
98
+            $string = str_replace ( $word, '', $string );
99
+        }
100
+        $string = substr ( $string, 0, 29 );
101
+        return $string;
102
+    }
103
+    /**
104
+     * @param unknown $objPHPExcel        	
105
+     * @param unknown $title        	
106
+     */
107
+    static function printTitle($objPHPExcel, $title) {
108
+        $objPHPExcel->getActiveSheet ()->setTitle ( ExcelExport::clearName ( $title, array('ddzia') ), true );
109
+        $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 1, $title );
110
+    }
111
+    /**
112
+     *
113
+     * @param unknown $objPHPExcel
114
+     */
115
+    static function newSheet($objPHPExcel, $index = -1) {
116
+        if ($index < 0) {
117
+            $index = $objPHPExcel->getSheetCount ();
118
+        }
119
+        $objPHPExcel->createSheet ( $index );
120
+        $objPHPExcel->setActiveSheetIndex ( $index );
121
+        $sheet = $objPHPExcel->getActiveSheet ();
122
+        return $sheet;
123
+    }
124 124
 	
125 125
 }
126 126
\ No newline at end of file
Please login to merge, or discard this patch.
src/utils/ExcelExportPunction.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace Hospitalplugin\utils;
4 4
 
5
-use Hospitalplugin\Entities\InfectionsCRUD;
6
-use Hospitalplugin\Entities\Infections;
7 5
 use Hospitalplugin\Entities\PatientRaport;
8 6
 use Hospitalplugin\Entities\WardCRUD;
9 7
 
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -9,133 +9,133 @@
 block discarded – undo
9 9
 
10 10
 class ExcelExportPunction {
11 11
 	
12
-	/**
13
-	 *
14
-	 * @param unknown $id        	
15
-	 */
16
-	private static function getData($id, $type) {
17
-		$raport = PatientRaport::getRaportBetweenDates ( $id, $type, '2014-06-01', (new \DateTime ())->format ( "Y-m-d" ) );
18
-		return $raport;
19
-	}
20
-	/**
21
-	 *
22
-	 * @param unknown $objPHPExcel        	
23
-	 * @param unknown $cols        	
24
-	 */
25
-	private static function printHeaders($objPHPExcel, $cols) {
26
-		$count = 1;
27
-		$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 2, "Data" );
28
-		foreach ( $cols as $col ) {
29
-			$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, 2, sprintf ( "%7s", $col ) );
30
-		}
31
-	}
32
-	/**
33
-	 */
34
-	private static function printData($objPHPExcel, $data, $type) {
35
-		$row = 3;
36
-		$lastColumn = 1;
37
-		$colNumberOfPatients = ExcelExport::getColumnLetter ( 1 );
38
-		$indexes = PatientRaport::getIndexes ( $type );
39
-		foreach ( $data as $rowKey => $rowValue ) {
40
-			// 1 col: date
41
-			$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row, json_encode ( $rowKey ) );
42
-			$count = 1;
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 );
47
-			}
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 );
53
-			// 7-11 tpb1, tpb2, tpb3, 0 (no-cat), 2 (add)
54
-			foreach ( $tpb as $tpbn ) {
55
-				$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, $tpbn );
56
-			}
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 );
63
-			}
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 . ")" );
68
-			$row ++;
69
-			$lastColumn = $count - 1;
70
-		}
71
-		// number of categorization days
72
-		$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 1, 1, '=COUNTIFS(' . $colNumberOfPatients . '3:' . $colNumberOfPatients . ($row - 1) . ',">0")' );
73
-		// sum
74
-		$col5Letter = ExcelExport::getColumnLetter ( $lastColumn );
75
-		$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 2, 1, '=SUM(' . $col5Letter . '3:' . $col5Letter . ($row - 1) . ')/60' );
76
-		return $row;
77
-	}
12
+    /**
13
+     *
14
+     * @param unknown $id        	
15
+     */
16
+    private static function getData($id, $type) {
17
+        $raport = PatientRaport::getRaportBetweenDates ( $id, $type, '2014-06-01', (new \DateTime ())->format ( "Y-m-d" ) );
18
+        return $raport;
19
+    }
20
+    /**
21
+     *
22
+     * @param unknown $objPHPExcel        	
23
+     * @param unknown $cols        	
24
+     */
25
+    private static function printHeaders($objPHPExcel, $cols) {
26
+        $count = 1;
27
+        $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 2, "Data" );
28
+        foreach ( $cols as $col ) {
29
+            $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, 2, sprintf ( "%7s", $col ) );
30
+        }
31
+    }
32
+    /**
33
+     */
34
+    private static function printData($objPHPExcel, $data, $type) {
35
+        $row = 3;
36
+        $lastColumn = 1;
37
+        $colNumberOfPatients = ExcelExport::getColumnLetter ( 1 );
38
+        $indexes = PatientRaport::getIndexes ( $type );
39
+        foreach ( $data as $rowKey => $rowValue ) {
40
+            // 1 col: date
41
+            $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row, json_encode ( $rowKey ) );
42
+            $count = 1;
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 );
47
+            }
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 );
53
+            // 7-11 tpb1, tpb2, tpb3, 0 (no-cat), 2 (add)
54
+            foreach ( $tpb as $tpbn ) {
55
+                $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, $tpbn );
56
+            }
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 );
63
+            }
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 . ")" );
68
+            $row ++;
69
+            $lastColumn = $count - 1;
70
+        }
71
+        // number of categorization days
72
+        $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 1, 1, '=COUNTIFS(' . $colNumberOfPatients . '3:' . $colNumberOfPatients . ($row - 1) . ',">0")' );
73
+        // sum
74
+        $col5Letter = ExcelExport::getColumnLetter ( $lastColumn );
75
+        $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 2, 1, '=SUM(' . $col5Letter . '3:' . $col5Letter . ($row - 1) . ')/60' );
76
+        return $row;
77
+    }
78 78
 	
79
-	/**
80
-	 *
81
-	 * @param unknown $objPHPExcel        	
82
-	 */
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 ) {
99
-				if ($sheetIndex == 0) {
100
-					continue;
101
-				}
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 . ",\"-\")" );
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 );
118
-		}
119
-	}
120
-	static function fillData($objPHPExcel) {
121
-		// no time limit for this script
122
-		set_time_limit ( 0 );
123
-		$time_start = microtime ( true );
124
-		// remove first default sheet
125
-		$objPHPExcel->removeSheetByIndex ( 0 );
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 );
137
-		}
138
-		ExcelExportPunction::fillSummary ( $objPHPExcel );
139
-		$objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 100, "summary " . ($time_start - microtime ( true )) . " s" );
140
-	}
79
+    /**
80
+     *
81
+     * @param unknown $objPHPExcel        	
82
+     */
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 ) {
99
+                if ($sheetIndex == 0) {
100
+                    continue;
101
+                }
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 . ",\"-\")" );
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 );
118
+        }
119
+    }
120
+    static function fillData($objPHPExcel) {
121
+        // no time limit for this script
122
+        set_time_limit ( 0 );
123
+        $time_start = microtime ( true );
124
+        // remove first default sheet
125
+        $objPHPExcel->removeSheetByIndex ( 0 );
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 );
137
+        }
138
+        ExcelExportPunction::fillSummary ( $objPHPExcel );
139
+        $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 100, "summary " . ($time_start - microtime ( true )) . " s" );
140
+    }
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
src/utils/PersonGenerator.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,6 @@
 block discarded – undo
24 24
 namespace Hospitalplugin\utils;
25 25
 
26 26
 use Hospitalplugin\Entities\Patient;
27
-use Hospitalplugin\Entities\PatientZZ;
28 27
 
29 28
 /**
30 29
  * PersonGenerator
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * PersonGenerator
4
- *
5
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7
- *
8
- * Permission is hereby granted to use or copy this program
9
- * for any purpose, provided the above notices are retained on all copies.
10
- * Permission to modify the code and to distribute modified code is granted,
11
- * provided the above notices are retained, and a notice that the code was
12
- * modified is included with the above copyright notice.
13
- *
14
- * @category  Wp
15
- * @package   Punction
16
- * @author    Andrzej Marcinkowski <[email protected]>
17
- * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
18
- * @license   MIT http://opensource.org/licenses/MIT
19
- * @version   1.0 $Id: a88997670673063e272ee5666aa86ed1ec9a1561 $ $Format:%H$
20
- * @link      http://
21
- * @since     File available since Release 1.0.0
22
- * PHP Version 5
23
- */
3
+     * PersonGenerator
4
+     *
5
+     * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6
+     * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7
+     *
8
+     * Permission is hereby granted to use or copy this program
9
+     * for any purpose, provided the above notices are retained on all copies.
10
+     * Permission to modify the code and to distribute modified code is granted,
11
+     * provided the above notices are retained, and a notice that the code was
12
+     * modified is included with the above copyright notice.
13
+     *
14
+     * @category  Wp
15
+     * @package   Punction
16
+     * @author    Andrzej Marcinkowski <[email protected]>
17
+     * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
18
+     * @license   MIT http://opensource.org/licenses/MIT
19
+     * @version   1.0 $Id: a88997670673063e272ee5666aa86ed1ec9a1561 $ $Format:%H$
20
+     * @link      http://
21
+     * @since     File available since Release 1.0.0
22
+     * PHP Version 5
23
+     */
24 24
 namespace Hospitalplugin\utils;
25 25
 
26 26
 use Hospitalplugin\Entities\Patient;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     /**
52 52
      * @return \Hospitalplugin\Entities\Patient
53
-	 */
53
+     */
54 54
     public static function getRandomPerson()
55 55
     {
56 56
         // TODO extract paths
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
     }
94 94
 
95 95
     /**
96
-	 *
97
-	 * @param $date        	
98
-	 * @param $sex
99
-	 *        	'm' / 'f'
100
-	 */
96
+     *
97
+     * @param $date        	
98
+     * @param $sex
99
+     *        	'm' / 'f'
100
+     */
101 101
     public static function getRandomPesel($date, $sex = 'm')
102 102
     {
103 103
         $datetime = new \DateTime($date);
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
         $intSum = 0;
126 126
         for ($i = 0; $i < 10; $i ++) {
127 127
             $intSum += $arrSteps[$i] * $x[$i]; // mnożymy każdy ze znaków
128
-                                                   // przez wagć i sumujemy
129
-                                                   // wszystko
128
+                                                    // przez wagć i sumujemy
129
+                                                    // wszystko
130 130
         }
131 131
         $int = 10 - $intSum % 10; // obliczamy sumć kontrolną
132 132
         $intControlNr = ($int == 10) ? 0 : $int;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * 
140 140
      * @param unknown $arr
141 141
      * @return string random element
142
-	 */
142
+     */
143 143
     public static function getRandom($arr)
144 144
     {
145 145
         return implode('', $arr[array_rand($arr)]);
Please login to merge, or discard this patch.
scripts/migrate_patients.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 use Punction\DB\DoctrineBootstrap;
26 26
 
27 27
 if (! defined ( 'ABSPATH' )) {
28
-	define ( 'WP_USE_THEMES', false );
29
-	require ('/var/www/wp/wp-load.php');
28
+    define ( 'WP_USE_THEMES', false );
29
+    require ('/var/www/wp/wp-load.php');
30 30
 }
31 31
 require_once ('/var/www/vendor/autoload.php');
32 32
 Logger::configure ( '../resources/log4php.xml' );
33 33
 /**
34
- * migration log4php logger
35
- */
34
+     * migration log4php logger
35
+     */
36 36
 $log = Logger::getLogger ( "migration" );
37 37
 $log->info ( "Start!" );
38 38
 
@@ -63,73 +63,73 @@  discard block
 block discarded – undo
63 63
 $entityManager = $db1->getEntityManager ();
64 64
 
65 65
 foreach ( $results as $result ) {
66
-	/**
67
-	 */
68
-	$id = $result ['ID'];
69
-	/**
70
-	 */
71
-	$title = $result ['post_title'];
72
-	/**
73
-	 */
74
-	$pesel = implode ( get_post_meta ( $id, 'pesel' ) );
75
-	/**
76
-	 */
77
-	$oddzid = implode ( get_post_meta ( $id, 'oddzial.ID' ) );
78
-	/**
79
-	 */
66
+    /**
67
+     */
68
+    $id = $result ['ID'];
69
+    /**
70
+     */
71
+    $title = $result ['post_title'];
72
+    /**
73
+     */
74
+    $pesel = implode ( get_post_meta ( $id, 'pesel' ) );
75
+    /**
76
+     */
77
+    $oddzid = implode ( get_post_meta ( $id, 'oddzial.ID' ) );
78
+    /**
79
+     */
80 80
 	
81
-	$numer_historii = implode ( get_post_meta ( $id, 'numer_ksiegi_glownej' ) );
82
-	/**
83
-	 */
84
-	$data_kategoryzacji = implode ( get_post_meta ( $id, 'data_kategoryzacji' ) );
85
-	/**
86
-	 */
87
-	$kategoria_pacjenta = implode ( get_post_meta ( $id, 'kategoria_pacjenta' ) );
88
-	/**
89
-	 */
90
-	$aktywnosc_fizyczna = implode ( get_post_meta ( $id, '1_aktywnosc_fizyczna' ) );
91
-	/**
92
-	 */
93
-	$higiena = implode ( get_post_meta ( $id, '2_higiena' ) );
94
-	/**
95
-	 */
96
-	$odzywianie = implode ( get_post_meta ( $id, '3_odzywianie' ) );
97
-	/**
98
-	 */
99
-	$wydalanie = implode ( get_post_meta ( $id, '4_wydalanie' ) );
100
-	/**
101
-	 */
102
-	$pomiar_objawow_zyciowych = implode ( get_post_meta ( $id, '5_pomiar_objawow_zyciowych' ) );
103
-	/**
104
-	 */
105
-	$leczenie = implode ( get_post_meta ( $id, '6_leczenie' ) );
106
-	/**
107
-	 */
108
-	$edukacja_i_wsparcie_psychiczne = implode ( get_post_meta ( $id, '7_edukacja_i_wsparcie_psychiczne' ) );
81
+    $numer_historii = implode ( get_post_meta ( $id, 'numer_ksiegi_glownej' ) );
82
+    /**
83
+     */
84
+    $data_kategoryzacji = implode ( get_post_meta ( $id, 'data_kategoryzacji' ) );
85
+    /**
86
+     */
87
+    $kategoria_pacjenta = implode ( get_post_meta ( $id, 'kategoria_pacjenta' ) );
88
+    /**
89
+     */
90
+    $aktywnosc_fizyczna = implode ( get_post_meta ( $id, '1_aktywnosc_fizyczna' ) );
91
+    /**
92
+     */
93
+    $higiena = implode ( get_post_meta ( $id, '2_higiena' ) );
94
+    /**
95
+     */
96
+    $odzywianie = implode ( get_post_meta ( $id, '3_odzywianie' ) );
97
+    /**
98
+     */
99
+    $wydalanie = implode ( get_post_meta ( $id, '4_wydalanie' ) );
100
+    /**
101
+     */
102
+    $pomiar_objawow_zyciowych = implode ( get_post_meta ( $id, '5_pomiar_objawow_zyciowych' ) );
103
+    /**
104
+     */
105
+    $leczenie = implode ( get_post_meta ( $id, '6_leczenie' ) );
106
+    /**
107
+     */
108
+    $edukacja_i_wsparcie_psychiczne = implode ( get_post_meta ( $id, '7_edukacja_i_wsparcie_psychiczne' ) );
109 109
 	
110
-	/**
111
-	 */
112
-	$patient = new PatientZZ ();
113
-	$patient->setName ( $title );
114
-	if ($data_kategoryzacji == null) {
115
-		$log->warn ( "Patient " . $id . " missing date. Omitting." );
116
-		continue;
117
-	}
118
-	$patient->setDataKategoryzacji ( \DateTime::createFromFormat ( "d-m-Y", $data_kategoryzacji ) );
119
-	$patient->setOddzialId ( $oddzid );
120
-	$patient->setNumerHistorii ( $numer_historii );
110
+    /**
111
+     */
112
+    $patient = new PatientZZ ();
113
+    $patient->setName ( $title );
114
+    if ($data_kategoryzacji == null) {
115
+        $log->warn ( "Patient " . $id . " missing date. Omitting." );
116
+        continue;
117
+    }
118
+    $patient->setDataKategoryzacji ( \DateTime::createFromFormat ( "d-m-Y", $data_kategoryzacji ) );
119
+    $patient->setOddzialId ( $oddzid );
120
+    $patient->setNumerHistorii ( $numer_historii );
121 121
 	
122
-	$patient->setPesel ( $pesel );
123
-	$patient->setKategoriaPacjenta ( $kategoria_pacjenta );
124
-	$patient->setAktywnoscFizyczna ( $aktywnosc_fizyczna );
125
-	$patient->setHigiena ( $higiena );
126
-	$patient->setOdzywianie ( $odzywianie );
127
-	$patient->setWydalanie ( $wydalanie );
128
-	$patient->setPomiarObjawowZyciowych ( $pomiar_objawow_zyciowych );
129
-	$patient->setLeczenie ( $leczenie );
130
-	$patient->setEdukacjaIWsparciePsychiczne ( $edukacja_i_wsparcie_psychiczne );
122
+    $patient->setPesel ( $pesel );
123
+    $patient->setKategoriaPacjenta ( $kategoria_pacjenta );
124
+    $patient->setAktywnoscFizyczna ( $aktywnosc_fizyczna );
125
+    $patient->setHigiena ( $higiena );
126
+    $patient->setOdzywianie ( $odzywianie );
127
+    $patient->setWydalanie ( $wydalanie );
128
+    $patient->setPomiarObjawowZyciowych ( $pomiar_objawow_zyciowych );
129
+    $patient->setLeczenie ( $leczenie );
130
+    $patient->setEdukacjaIWsparciePsychiczne ( $edukacja_i_wsparcie_psychiczne );
131 131
 	
132
-	$entityManager->persist ( $patient );
132
+    $entityManager->persist ( $patient );
133 133
 }
134 134
 $entityManager->flush ();
135 135
 $log->info ( "Stop!" );
Please login to merge, or discard this patch.
src/Entities/InfectionRaport.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -39,116 +39,116 @@
 block discarded – undo
39 39
  */
40 40
 class InfectionRaport {
41 41
 	
42
-	/**
43
-	 * id
44
-	 * @Id @Column(type="integer") @GeneratedValue
45
-	 */
46
-	public $id;
42
+    /**
43
+     * id
44
+     * @Id @Column(type="integer") @GeneratedValue
45
+     */
46
+    public $id;
47 47
 	
48
-	/**
49
-	 * $dataRaportu datetime
50
-	 * @Column(type="datetime") *
51
-	 */
52
-	public $dataRaportu;
48
+    /**
49
+     * $dataRaportu datetime
50
+     * @Column(type="datetime") *
51
+     */
52
+    public $dataRaportu;
53 53
 	
54
-	/**
55
-	 * $dataPrzeslania datetime
56
-	 * @Column(type="datetime") *
57
-	 */
58
-	public $dataPrzeslania;
54
+    /**
55
+     * $dataPrzeslania datetime
56
+     * @Column(type="datetime") *
57
+     */
58
+    public $dataPrzeslania;
59 59
 	
60
-	/**
61
-	 * @ManyToOne(targetEntity="Hospitalplugin\Entities\Ward")
62
-	 * @JoinColumn(name="oddzialId", referencedColumnName="id")
63
-	 */
64
-	public $ward;
60
+    /**
61
+     * @ManyToOne(targetEntity="Hospitalplugin\Entities\Ward")
62
+     * @JoinColumn(name="oddzialId", referencedColumnName="id")
63
+     */
64
+    public $ward;
65 65
 	
66
-	/**
67
-	 * @ManyToOne(targetEntity="Hospitalplugin\Entities\User")
68
-	 * @JoinColumn(name="userId", referencedColumnName="id")
69
-	 */
70
-	protected $user;
66
+    /**
67
+     * @ManyToOne(targetEntity="Hospitalplugin\Entities\User")
68
+     * @JoinColumn(name="userId", referencedColumnName="id")
69
+     */
70
+    protected $user;
71 71
 	
72
-	function __construct($args) {
73
-		foreach ( $args as $key => $value ) {
74
-			if ($key == 'dataRaportu') {
75
-				$value = new \DateTime ( $value );
76
-			} 
77
-			call_user_func ( array (
78
-					$this,
79
-					'set' . $key 
80
-			), $value );
81
-		}
82
-		$this->dataPrzeslania = new \DateTime ();
83
-		echo '<h3><div class="alert alert-primary">Dziękuję za przesłanie raportu!</div></h3>';
84
-	}
72
+    function __construct($args) {
73
+        foreach ( $args as $key => $value ) {
74
+            if ($key == 'dataRaportu') {
75
+                $value = new \DateTime ( $value );
76
+            } 
77
+            call_user_func ( array (
78
+                    $this,
79
+                    'set' . $key 
80
+            ), $value );
81
+        }
82
+        $this->dataPrzeslania = new \DateTime ();
83
+        echo '<h3><div class="alert alert-primary">Dziękuję za przesłanie raportu!</div></h3>';
84
+    }
85 85
 	
86
-	/**
87
-	 * getId
88
-	 *
89
-	 * @return id
90
-	 */
91
-	public function getId() {
92
-		return $this->id;
93
-	}
86
+    /**
87
+     * getId
88
+     *
89
+     * @return id
90
+     */
91
+    public function getId() {
92
+        return $this->id;
93
+    }
94 94
 	
95
-	/**
96
-	 * sets id
97
-	 *
98
-	 * @param int $id
99
-	 *        	ID
100
-	 *        	
101
-	 * @return \Hospitalplugin\Entities\Patient
102
-	 */
103
-	public function setId($id) {
104
-		$this->id = $id;
105
-		return $this;
106
-	}
95
+    /**
96
+     * sets id
97
+     *
98
+     * @param int $id
99
+     *        	ID
100
+     *        	
101
+     * @return \Hospitalplugin\Entities\Patient
102
+     */
103
+    public function setId($id) {
104
+        $this->id = $id;
105
+        return $this;
106
+    }
107 107
 	
108
-	/**
109
-	 * toString
110
-	 *
111
-	 * @return string
112
-	 */
113
-	public function toString() {
114
-		$txt = $this->getId ();
115
-		$data = $this->getDataRaportu ();
116
-		if ($data instanceof \DateTime) {
117
-			$txt .= $this->getDataRaportu ()->format ( "Y-m-d" );
118
-		} else {
119
-			$txt .= $this->getDataRaportu ();
120
-		}
121
-		return $txt;
122
-	}
123
-	public function getDataRaportu() {
124
-		return $this->dataRaportu;
125
-	}
126
-	public function setDataRaportu($dataRaportu) {
127
-		$this->dataRaportu = $dataRaportu;
128
-		return $this;
129
-	}
108
+    /**
109
+     * toString
110
+     *
111
+     * @return string
112
+     */
113
+    public function toString() {
114
+        $txt = $this->getId ();
115
+        $data = $this->getDataRaportu ();
116
+        if ($data instanceof \DateTime) {
117
+            $txt .= $this->getDataRaportu ()->format ( "Y-m-d" );
118
+        } else {
119
+            $txt .= $this->getDataRaportu ();
120
+        }
121
+        return $txt;
122
+    }
123
+    public function getDataRaportu() {
124
+        return $this->dataRaportu;
125
+    }
126
+    public function setDataRaportu($dataRaportu) {
127
+        $this->dataRaportu = $dataRaportu;
128
+        return $this;
129
+    }
130 130
 	
131
-	public function getDataPrzeslania() {
132
-		return $this->dataPrzeslania;
133
-	}
134
-	public function setDataPrzeslania($dataPrzeslania) {
135
-		$this->dataPrzeslania = $dataPrzeslania;
136
-		return $this;
137
-	}
138
-	public function getWard() {
139
-		return $this->ward;
140
-	}
141
-	public function setWard($ward) {
142
-		$this->ward = $ward;
143
-		return $this;
144
-	}
145
-	public function getUser() {
146
-		return $this->user;
147
-	}
148
-	public function setUser($user) {
149
-		$this->user = $user;
150
-		return $this;
151
-	}
131
+    public function getDataPrzeslania() {
132
+        return $this->dataPrzeslania;
133
+    }
134
+    public function setDataPrzeslania($dataPrzeslania) {
135
+        $this->dataPrzeslania = $dataPrzeslania;
136
+        return $this;
137
+    }
138
+    public function getWard() {
139
+        return $this->ward;
140
+    }
141
+    public function setWard($ward) {
142
+        $this->ward = $ward;
143
+        return $this;
144
+    }
145
+    public function getUser() {
146
+        return $this->user;
147
+    }
148
+    public function setUser($user) {
149
+        $this->user = $user;
150
+        return $this;
151
+    }
152 152
 	
153 153
 	
154 154
 }
Please login to merge, or discard this patch.