Skip to content

Instantly share code, notes, and snippets.

@caseydentinger
Created February 19, 2013 18:13
Show Gist options
  • Save caseydentinger/4988376 to your computer and use it in GitHub Desktop.
Save caseydentinger/4988376 to your computer and use it in GitHub Desktop.
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