/**
  * Deliver
  *
  * @access public
  * @param string $amount
  * @param object $trigger
  * @param string $comment
  */
 public function deliver($amount, $trigger, $comment = '')
 {
     $stock_object = $this->get_stock_object();
     \Skeleton\Package\Stock\Stock::change($stock_object, $amount, $trigger, $comment);
     $this->delivered += $amount;
     $this->save();
     $purchase_order = \Skeleton\Package\Stock\Purchase\Order::get_by_id($this->purchase_order_id);
     $purchase_order->check_delivered();
 }
 /**
  * add_delivery
  *
  * @access public
  */
 public function display_add_delivery()
 {
     $purchase_order = \Skeleton\Package\Stock\Purchase\Order::get_by_id($_GET['id']);
     if (isset($_POST['purchase_order'])) {
         $purchase_order->load_array($_POST['purchase_order']);
         $purchase_order->save();
     }
     if (isset($_POST['delivery'])) {
         foreach ($_POST['delivery'] as $purchase_order_item_id => $amount) {
             $purchase_order_item = \Skeleton\Package\Stock\Purchase\Order\Item::get_by_id($purchase_order_item_id);
             $purchase_order_item->deliver($amount, $purchase_order, 'Delivery for PO' . $purchase_order->id);
         }
     }
     Session::redirect($this->get_module_path() . '?action=edit&id=' . $purchase_order->id);
 }