Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 64 |
|
0.00% |
0 / 21 |
CRAP | |
0.00% |
0 / 1 |
| TextInvoice | |
0.00% |
0 / 64 |
|
0.00% |
0 / 21 |
870 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| numBuyTexts | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
20 | |||
| numAutoTexts | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| numTextBlasts | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| loopCount | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| getNumBuyTexts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setNumBuyTexts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getNumAutoTexts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setNumAutoTexts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getNumTextBlasts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setNumTextBlasts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHasLoop | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setHasLoop | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getNumOptInTexts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setNumOptInTexts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHasLoyalty | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setHasLoyalty | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getNewBilling | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setNewBilling | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getEarliestBuy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setEarliestBuy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\Core; |
| 4 | |
| 5 | class TextInvoice extends Store { |
| 6 | |
| 7 | private $numBuyTexts; |
| 8 | private $numOptInTexts; |
| 9 | private $numAutoTexts; |
| 10 | private $numTextBlasts; |
| 11 | private $hasLoop; |
| 12 | private $hasLoyalty; |
| 13 | private $newBilling; |
| 14 | private $earliestBuy; |
| 15 | |
| 16 | public $startDate; |
| 17 | public $endDate; |
| 18 | |
| 19 | private $globalDB; |
| 20 | |
| 21 | private $db; |
| 22 | |
| 23 | private $log; |
| 24 | |
| 25 | |
| 26 | public function __construct($typeNum, $startDate, $endDate) |
| 27 | { |
| 28 | if(!parent::createStore($typeNum)) { |
| 29 | return null; |
| 30 | } |
| 31 | |
| 32 | $this->startDate = getDateRange($startDate); |
| 33 | $this->endDate = getDateRange($endDate); |
| 34 | global $db_name; |
| 35 | $this->db = dbConnectByName($this->getDbName()); |
| 36 | $this->globalDB = dbConnectByName($db_name); |
| 37 | |
| 38 | $this->numBuyTexts(); |
| 39 | $this->numAutoTexts(); |
| 40 | $this->numTextBlasts(); |
| 41 | $this->loopCount(); |
| 42 | } |
| 43 | private function numBuyTexts() { |
| 44 | $stmt = $this->db->prepare("SELECT SUM(IF(type = 0,1,0))+SUM(IF(type = 2,1,0)) as buyTexts, SUM(IF(type = 1,1,0)) as numOptInTexts FROM (SELECT CEIL(ROUND((UNIX_TIMESTAMP(timestamp)/customerID)*100000)/100000) as combined, type FROM texts WHERE timestamp BETWEEN :start AND :end GROUP BY combined) as A"); |
| 45 | $stmt->bindValue(":start", $this->startDate['dateEnd']->format("Y-m-d H:i:s")); |
| 46 | $stmt->bindValue(":end", $this->endDate['dateEnd']->format("Y-m-d H:i:s")); |
| 47 | $stmt->execute(); |
| 48 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 49 | |
| 50 | if($row['buyTexts'] == null) { |
| 51 | $row['buyTexts'] = 0; |
| 52 | } |
| 53 | if($row['numOptInTexts'] == null) { |
| 54 | $row['numOptInTexts'] = 0; |
| 55 | } |
| 56 | if((int)$row['numOptInTexts'] > 50) { |
| 57 | $this->hasLoyalty = 1; |
| 58 | } |
| 59 | |
| 60 | $this->numBuyTexts = $row['buyTexts']; |
| 61 | $this->numOptInTexts = $row['numOptInTexts']; |
| 62 | } |
| 63 | private function numAutoTexts() { |
| 64 | $stmt = $this->globalDB->prepare("SELECT SUM(messagesSent) as autoTexts FROM loyaltyOutgoing WHERE storeFrom = :typeNum AND triggerID IS NOT NULL AND messagesSent IS NOT NULL AND messagesSent > 0 AND dateSent BETWEEN :start AND :end"); |
| 65 | $stmt->bindValue(":start", $this->startDate['dateEnd']->format("Y-m-d H:i:s")); |
| 66 | $stmt->bindValue(":end", $this->endDate['dateEnd']->format("Y-m-d H:i:s")); |
| 67 | $stmt->bindValue(":typeNum", $this->getTypeNum()); |
| 68 | $stmt->execute(); |
| 69 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 70 | |
| 71 | if($row['autoTexts'] == null) { |
| 72 | $row['autoTexts'] = 0; |
| 73 | } |
| 74 | |
| 75 | $this->numAutoTexts = $row['autoTexts']; |
| 76 | } |
| 77 | |
| 78 | private function numTextBlasts() { |
| 79 | $stmt = $this->globalDB->prepare("SELECT SUM(messagesSent) as massTexts FROM loyaltyOutgoing WHERE storeFrom = :typeNum AND massSMSID IS NOT NULL AND messagesSent IS NOT NULL AND messagesSent > 0 AND dateSent BETWEEN :start AND :end"); |
| 80 | $stmt->bindValue(":start", $this->startDate['dateEnd']->format("Y-m-d H:i:s")); |
| 81 | $stmt->bindValue(":end", $this->endDate['dateEnd']->format("Y-m-d H:i:s")); |
| 82 | $stmt->bindValue(":typeNum", $this->getTypeNum()); |
| 83 | $stmt->execute(); |
| 84 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 85 | |
| 86 | if($row['massTexts'] == null) { |
| 87 | $row['massTexts'] = 0; |
| 88 | } |
| 89 | |
| 90 | $this->numTextBlasts = $row['massTexts']; |
| 91 | } |
| 92 | |
| 93 | private function loopCount() { |
| 94 | $stmt = $this->db->prepare("SELECT count(*) as loopCount FROM dsLoop"); |
| 95 | $stmt->execute(); |
| 96 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 97 | |
| 98 | if((int)$row['loopCount'] > 0 && $row['loopCount'] !== null) { |
| 99 | $this->hasLoop = 1; |
| 100 | } else { |
| 101 | $this->hasLoop = 0; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @return mixed |
| 107 | */ |
| 108 | public function getNumBuyTexts() |
| 109 | { |
| 110 | return $this->numBuyTexts; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @param mixed $numBuyTexts |
| 115 | */ |
| 116 | public function setNumBuyTexts($numBuyTexts) |
| 117 | { |
| 118 | $this->numBuyTexts = $numBuyTexts; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @return mixed |
| 123 | */ |
| 124 | public function getNumAutoTexts() |
| 125 | { |
| 126 | return $this->numAutoTexts; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @param mixed $numAutoTexts |
| 131 | */ |
| 132 | public function setNumAutoTexts($numAutoTexts) |
| 133 | { |
| 134 | $this->numAutoTexts = $numAutoTexts; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @return mixed |
| 139 | */ |
| 140 | public function getNumTextBlasts() |
| 141 | { |
| 142 | return $this->numTextBlasts; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @param mixed $numTextBlasts |
| 147 | */ |
| 148 | public function setNumTextBlasts($numTextBlasts) |
| 149 | { |
| 150 | $this->numTextBlasts = $numTextBlasts; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @return mixed |
| 155 | */ |
| 156 | public function getHasLoop() |
| 157 | { |
| 158 | return $this->hasLoop; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * @param mixed $hasLoop |
| 163 | */ |
| 164 | public function setHasLoop($hasLoop) |
| 165 | { |
| 166 | $this->hasLoop = $hasLoop; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @return mixed |
| 171 | */ |
| 172 | public function getNumOptInTexts() |
| 173 | { |
| 174 | return $this->numOptInTexts; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * @param mixed $numOptInTexts |
| 179 | */ |
| 180 | public function setNumOptInTexts($numOptInTexts) |
| 181 | { |
| 182 | $this->numOptInTexts = $numOptInTexts; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * @return mixed |
| 187 | */ |
| 188 | public function getHasLoyalty() |
| 189 | { |
| 190 | return $this->hasLoyalty; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * @param mixed $hasLoyalty |
| 195 | */ |
| 196 | public function setHasLoyalty($hasLoyalty) |
| 197 | { |
| 198 | $this->hasLoyalty = $hasLoyalty; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * @return mixed |
| 203 | */ |
| 204 | public function getNewBilling() |
| 205 | { |
| 206 | return $this->newBilling; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * @param mixed $newBilling |
| 211 | */ |
| 212 | public function setNewBilling($newBilling) |
| 213 | { |
| 214 | $this->newBilling = $newBilling; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * @return mixed |
| 219 | */ |
| 220 | public function getEarliestBuy() |
| 221 | { |
| 222 | return $this->earliestBuy; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * @param mixed $earliestBuy |
| 227 | */ |
| 228 | public function setEarliestBuy($earliestBuy) |
| 229 | { |
| 230 | $this->earliestBuy = $earliestBuy; |
| 231 | } |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | } |