Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 40 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
| LoyaltySMSMessage | |
0.00% |
0 / 40 |
|
0.00% |
0 / 10 |
380 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 | |||
| createMessage | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
| update | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
| deleteMessage | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| getMessageID | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setMessageID | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getShortName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setShortName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\Core\Loyalty; |
| 4 | |
| 5 | class LoyaltySMSMessage extends LoyaltyGroup { |
| 6 | private $db; |
| 7 | public $messageID; |
| 8 | public $message; |
| 9 | public $shortName; |
| 10 | |
| 11 | public function __construct($groupID = null, $typeNum = null, $messageID = null) { |
| 12 | if(parent::__construct($groupID, $typeNum)) { |
| 13 | global $db_name; |
| 14 | $this->db = dbConnectByName($db_name); |
| 15 | if(isset($messageID)) { |
| 16 | $stmt = $this->db->query("SELECT * FROM loyaltySMSMessages WHERE id = ".$messageID); |
| 17 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 18 | if(isset($row['id'])) { |
| 19 | $this->message = $row['message']; |
| 20 | $this->shortName = $row['shortName']; |
| 21 | $this->messageID = $row['id']; |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | public function createMessage() { |
| 27 | if(isset($this->message)) { |
| 28 | $stmt = $this->db->prepare("INSERT INTO loyaltySMSMessages (message, shortName, storeGroup) VALUES (:message, :shortName, :storeGroup)"); |
| 29 | $stmt->bindValue(":message", $this->message); |
| 30 | $stmt->bindValue(":shortName", $this->shortName); |
| 31 | $stmt->bindValue(":storeGroup", $this->getGroupID()); |
| 32 | if($stmt->execute()) { |
| 33 | $this->messageID = $this->db->lastInsertId(); |
| 34 | return true; |
| 35 | } |
| 36 | } |
| 37 | return false; |
| 38 | } |
| 39 | public function update() { |
| 40 | if(isset($this->messageID)) { |
| 41 | $stmt = $this->db->prepare("UPDATE loyaltySMSMessages SET message = :message, shortName = :shortName, storeGroup = :storeGroup WHERE id = :messageID"); |
| 42 | $stmt->bindValue(":message", $this->message); |
| 43 | $stmt->bindValue(":shortName", $this->shortName); |
| 44 | $stmt->bindValue(":storeGroup", $this->getGroupID()); |
| 45 | $stmt->bindValue(":messageID", $this->messageID); |
| 46 | |
| 47 | if($stmt->execute()) { |
| 48 | return true; |
| 49 | } |
| 50 | } |
| 51 | return false; |
| 52 | } |
| 53 | public function deleteMessage() { |
| 54 | if(isset($this->messageID)) { |
| 55 | $stmt = $this->db->prepare("DELETE FROM loyaltySMSMessages WHERE id = :messageID"); |
| 56 | $stmt->bindValue(":messageID", $this->messageID); |
| 57 | if($stmt->execute()) { |
| 58 | return true; |
| 59 | } |
| 60 | } |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @return mixed |
| 66 | */ |
| 67 | public function getMessageID() |
| 68 | { |
| 69 | return $this->messageID; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * @param mixed $messageID |
| 74 | */ |
| 75 | public function setMessageID($messageID) |
| 76 | { |
| 77 | $this->messageID = $messageID; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @return mixed |
| 82 | */ |
| 83 | public function getMessage() |
| 84 | { |
| 85 | return $this->message; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @param mixed $message |
| 90 | */ |
| 91 | public function setMessage($message) |
| 92 | { |
| 93 | $this->message = $message; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @return mixed |
| 98 | */ |
| 99 | public function getShortName() |
| 100 | { |
| 101 | return $this->shortName; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * @param mixed $shortName |
| 106 | */ |
| 107 | public function setShortName($shortName) |
| 108 | { |
| 109 | $this->shortName = $shortName; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | |
| 114 | } |