<?php /** * $Id: vw_idx_order_manager.php 19286 2013-05-26 16:59:04Z phenxdesign $ * * @package Mediboard * @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 19286 $ */ CCanDo::checkEdit(); $order_id = CValue::getOrSession('order_id'); $category_id = CValue::getOrSession('category_id'); // Loads the expected Order $order = new CProductOrder(); if ($order_id) { $order->load($order_id); $order->updateFormFields(); } $category = new CProductCategory(); $list_categories = $category->loadList(null, 'name'); // Smarty template $smarty = new CSmartyDP(); $smarty->assign('order', $order); $smarty->assign('category_id', $category_id); $smarty->assign('list_categories', $list_categories); $smarty->display('vw_idx_order_manager.tpl');
/** * Find a reception from an order ID * * @param int $order_id Order ID * @param bool $locked Look among locked receptions * * @return array */ function findFromOrder($order_id, $locked = false) { $receptions_prob = array(); $receptions = array(); $order = new CProductOrder(); $order->load($order_id); $order->loadBackRefs("order_items"); foreach ($order->_back["order_items"] as $order_item) { $r = $order_item->loadBackRefs("receptions"); foreach ($r as $_r) { if (!$_r->reception_id) { continue; } $_r->loadRefReception(); if ($locked || $_r->_ref_reception->locked) { continue; } if (!isset($receptions_prob[$_r->reception_id])) { $receptions_prob[$_r->reception_id] = 0; } $receptions_prob[$_r->reception_id]++; $receptions[$_r->reception_id] = $_r->_ref_reception; } } if (!count($receptions_prob)) { return $receptions; } $reception_id = array_search(max($receptions_prob), $receptions_prob); if ($reception_id) { $this->load($reception_id); } return $receptions; }