|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WardCRUD |
|
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 $Format:%H$ |
|
20
|
|
|
* @link http:// |
|
21
|
|
|
* @since File available since Release 1.0.0 |
|
22
|
|
|
* PHP Version 5 |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace Hospitalplugin\Entities; |
|
25
|
|
|
|
|
26
|
|
|
use Hospitalplugin\Entities\Ward; |
|
27
|
|
|
use Hospitalplugin\DB\DoctrineBootstrap; |
|
28
|
|
|
use Hospitalplugin\utils\Utils; |
|
29
|
|
|
|
|
30
|
|
|
class WardCRUD |
|
31
|
|
|
{ |
|
32
|
|
|
private static $wardsArray; |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
*/ |
|
36
|
|
|
public static function getWardIdForUser($userId) |
|
37
|
|
|
{ |
|
38
|
|
|
return WardCRUD::getWardForUser($userId)->getId(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public static function addWard($ward) { |
|
42
|
|
|
$entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
43
|
|
|
$entityManager->persist($ward); |
|
44
|
|
|
$entityManager->flush(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param $userId int |
|
49
|
|
|
* |
|
50
|
|
|
* @return Ward Ward ward |
|
51
|
|
|
* |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function getWardForUser($userId) |
|
54
|
|
|
{ |
|
55
|
|
|
$entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
56
|
|
|
$user = $entityManager->getRepository('Hospitalplugin\Entities\User')->findOneById($userId); |
|
57
|
|
|
return $user->getWard(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public static function getWardById($id) |
|
61
|
|
|
{ |
|
62
|
|
|
$entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
63
|
|
|
$ward = $entityManager->getRepository('Hospitalplugin\Entities\Ward')->findOneById($id); |
|
64
|
|
|
return $ward; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public static function getWardsArray() |
|
68
|
|
|
{ |
|
69
|
|
|
if (WardCRUD::$wardsArray == null) { |
|
70
|
|
|
$entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
71
|
|
|
$query = $entityManager->createQuery('select w FROM Hospitalplugin\Entities\Ward w ORDER BY w.name'); |
|
72
|
|
|
$wards = $query->getResult(); |
|
73
|
|
|
WardCRUD::$wardsArray = $wards; |
|
74
|
|
|
} |
|
75
|
|
|
return WardCRUD::$wardsArray; |
|
76
|
|
|
} |
|
77
|
|
|
} |
This check marks private properties in classes that are never used. Those properties can be removed.