Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| AccountMapper | |
0.00% |
0 / 22 |
|
0.00% |
0 / 4 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| mapDrsAccountIDtoQBAccountID | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 | |||
| checkIfDRSIDIsMapped | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| updateDRSIDMapping | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\QuickBooks; |
| 4 | |
| 5 | class AccountMapper extends QuickBooks { |
| 6 | |
| 7 | private $config; |
| 8 | public function __construct(\Store $store = null) |
| 9 | { |
| 10 | parent::__construct($store); |
| 11 | |
| 12 | } |
| 13 | public function mapDrsAccountIDtoQBAccountID($drsID, $qbID) { |
| 14 | //Check if this drsField ID is already mapped. If so, use an UPDATE query |
| 15 | if($this->checkIfDRSIDIsMapped($drsID)) { |
| 16 | return $this->updateDRSIDMapping($drsID, $qbID); |
| 17 | } |
| 18 | //This drsField ID is not already mapped. Use and INSERT query |
| 19 | $stmt = $this->storeDB->prepare("INSERT INTO drsFieldMapping (drsID, qbID) VALUES (:drsID, :qbID)"); |
| 20 | $stmt->bindParam(':drsID', $drsID); |
| 21 | $stmt->bindParam(':qbID', $qbID); |
| 22 | if($stmt->execute()) { |
| 23 | return true; |
| 24 | } |
| 25 | return false; |
| 26 | } |
| 27 | public function checkIfDRSIDIsMapped($drsID) { |
| 28 | $stmt = $this->storeDB->prepare("SELECT * FROM drsFieldMapping WHERE drsID = :drsID"); |
| 29 | $stmt->bindParam(':drsID', $drsID); |
| 30 | $stmt->execute(); |
| 31 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 32 | if($row) { |
| 33 | return true; |
| 34 | } |
| 35 | return false; |
| 36 | } |
| 37 | public function updateDRSIDMapping($drsID, $qbID) { |
| 38 | $stmt = $this->storeDB->prepare("UPDATE drsFieldMapping SET qbID = :qbID WHERE drsID = :drsID"); |
| 39 | $stmt->bindParam(':drsID', $drsID); |
| 40 | $stmt->bindParam(':qbID', $qbID); |
| 41 | if($stmt->execute()) { |
| 42 | return true; |
| 43 | } |
| 44 | return false; |
| 45 | } |
| 46 | } |