Created
February 19, 2013 18:13
-
-
Save caseydentinger/4988376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getPickingArray () | |
{ | |
$dbi = SparkDBI::getInstance(); | |
$purchased = $dbi->fetchAllRows( | |
'select products_id as id, products_quantity as qty | |
from orders_products | |
where orders_id = ' . $dbi->escape($this->id()) | |
); | |
$picked = $dbi->fetchAllRows( | |
'select products_id as id, adjustment_amount_physical * -1 as qty | |
from products_stock_adjustments | |
where adjustment_amount_physical < 0 | |
and orders_id = ' . $dbi->escape($this->id()) | |
); | |
return array('picked' => $picked, 'purchased' => $purchased); | |
} | |
public function ensurePicked () | |
{ | |
$items = $this->getPickingArray(); | |
if (count($items['purchased']) != count($items['picked'])) | |
return false; | |
return true; | |
} | |
public function ensureUnpicked () | |
{ | |
$items = $this->getPickingArray(); | |
if (count($items['picked'])) | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment