Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 47 |
|
0.00% |
0 / 17 |
CRAP | |
0.00% |
0 / 1 |
| Alert | |
0.00% |
0 / 47 |
|
0.00% |
0 / 17 |
506 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| getAlertByID | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
12 | |||
| updateAlert | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 | |||
| getCustomerID | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setCustomerID | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getComment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setComment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRepeat | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setRepeat | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCleared | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setCleared | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDateAdded | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setDateAdded | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\Core; |
| 4 | |
| 5 | /** |
| 6 | * Alert |
| 7 | * |
| 8 | * Represents a customer alert in the system. |
| 9 | * |
| 10 | * @package BuyerKiosk\Core |
| 11 | */ |
| 12 | class Alert { |
| 13 | private $db; |
| 14 | private $id; |
| 15 | private $store; |
| 16 | public $customerID; |
| 17 | public $type; |
| 18 | public $comment; |
| 19 | public $class; |
| 20 | public $repeat; |
| 21 | public $cleared; |
| 22 | public $dateAdded; |
| 23 | |
| 24 | public function __construct($alertID, $typeNum) { |
| 25 | $this->store = new Store(); |
| 26 | if($this->store->createStore($typeNum)) { |
| 27 | $this->db = dbConnectByName($this->store->getDbName()); |
| 28 | $this->id = $alertID; |
| 29 | if($this->getAlertByID($alertID)) { |
| 30 | return true; |
| 31 | } |
| 32 | } |
| 33 | return false; |
| 34 | } |
| 35 | private function getAlertByID($alertID) { |
| 36 | $stmt = $this->db->prepare("SELECT * FROM customerAlerts WHERE id = :alertID"); |
| 37 | $stmt->bindParam(":alertID", $alertID); |
| 38 | if($stmt->execute()) { |
| 39 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 40 | if(isset($row['customerID'])) { |
| 41 | $this->customerID = $row['customerID']; |
| 42 | $this->type = $row['type']; |
| 43 | $this->comment = $row['comment']; |
| 44 | $this->class = $row['class']; |
| 45 | $this->repeat = $row['repeat']; |
| 46 | $this->cleared = $row['cleared']; |
| 47 | $this->dateAdded = $row['dateAdded']; |
| 48 | return true; |
| 49 | } |
| 50 | } |
| 51 | return false; |
| 52 | } |
| 53 | public function updateAlert() { |
| 54 | $stmt = $this->db->prepare("UPDATE customerAlerts SET customerID = :customer, `type` = :type, comment = :comment, class = :class, repeat = :repeat, cleared = :cleared, dateAdded = :dateAdded WHERE id = :alertID"); |
| 55 | $stmt->bindParam(":customerID", $this->customerID); |
| 56 | $stmt->bindParam(":type", $this->type); |
| 57 | $stmt->bindParam(":comment", $this->comment); |
| 58 | $stmt->bindParam(":class", $this->class); |
| 59 | $stmt->bindParam(":repeat", $this->repeat); |
| 60 | $stmt->bindParam(":cleared", $this->cleared); |
| 61 | $stmt->bindParam(":dateAdded", $this->dateAdded); |
| 62 | $stmt->bindParam(":alertID", $this->id); |
| 63 | if($stmt->execute()) |
| 64 | return true; |
| 65 | return false; |
| 66 | } |
| 67 | /** |
| 68 | * @return mixed |
| 69 | */ |
| 70 | public function getCustomerID() |
| 71 | { |
| 72 | return $this->customerID; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @param mixed $customerID |
| 77 | */ |
| 78 | public function setCustomerID($customerID) |
| 79 | { |
| 80 | $this->customerID = $customerID; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @return mixed |
| 85 | */ |
| 86 | public function getType() |
| 87 | { |
| 88 | return $this->type; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param mixed $type |
| 93 | */ |
| 94 | public function setType($type) |
| 95 | { |
| 96 | $this->type = $type; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @return mixed |
| 101 | */ |
| 102 | public function getComment() |
| 103 | { |
| 104 | return $this->comment; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * @param mixed $comment |
| 109 | */ |
| 110 | public function setComment($comment) |
| 111 | { |
| 112 | $this->comment = $comment; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * @return mixed |
| 117 | */ |
| 118 | public function getClass() |
| 119 | { |
| 120 | return $this->class; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * @param mixed $class |
| 125 | */ |
| 126 | public function setClass($class) |
| 127 | { |
| 128 | $this->class = $class; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * @return mixed |
| 133 | */ |
| 134 | public function getRepeat() |
| 135 | { |
| 136 | return $this->repeat; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * @param mixed $repeat |
| 141 | */ |
| 142 | public function setRepeat($repeat) |
| 143 | { |
| 144 | $this->repeat = $repeat; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * @return mixed |
| 149 | */ |
| 150 | public function getCleared() |
| 151 | { |
| 152 | return $this->cleared; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * @param mixed $cleared |
| 157 | */ |
| 158 | public function setCleared($cleared) |
| 159 | { |
| 160 | $this->cleared = $cleared; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * @return mixed |
| 165 | */ |
| 166 | public function getDateAdded() |
| 167 | { |
| 168 | return $this->dateAdded; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * @param mixed $dateAdded |
| 173 | */ |
| 174 | public function setDateAdded($dateAdded) |
| 175 | { |
| 176 | $this->dateAdded = $dateAdded; |
| 177 | } |
| 178 | } |