<?php /** * $Id$ * * @package Mediboard * @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkEdit(); $societe_id = CValue::getOrSession('societe_id'); $suppliers = CValue::getOrSession('suppliers', 1); $manufacturers = CValue::getOrSession('manufacturers', 1); $inactive = CValue::getOrSession('inactive', 1); // Loads the expected Societe $societe = new CSociete(); $societe->load($societe_id); // Smarty template $smarty = new CSmartyDP(); $smarty->assign('societe', $societe); $smarty->assign('suppliers', $suppliers); $smarty->assign('manufacturers', $manufacturers); $smarty->assign('inactive', $inactive); $smarty->display('vw_idx_societe.tpl');
/** * Search a product * * @param string $type The type of orders we are looking for [waiting|locked|pending|received|cancelled] * @param string $keywords [optional] * @param integer $limit = 30 [optional] * @param array $where Where additionnal * * @return self[] The list of orders */ function search($type, $keywords = "", $limit = 30, $where = array()) { global $g; $leftjoin = array(); $leftjoin['product_order_item'] = 'product_order.order_id = product_order_item.order_id'; $leftjoin['product_order_item_reception'] = 'product_order_item.order_item_id = product_order_item_reception.order_item_id'; $leftjoin['product_reference'] = 'product_order_item.reference_id = product_reference.reference_id'; $leftjoin['product'] = 'product_reference.product_id = product.product_id'; // if keywords have been provided if ($keywords) { $societe = new CSociete(); $where_or = array(); // we seek among the societes $where_societe_or = array(); foreach ($societe->getSeekables() as $field => $spec) { $where_societe_or[] = "societe.{$field} LIKE '%{$keywords}%'"; } $where_societe[] = implode(' OR ', $where_societe_or); // we seek among the orders foreach ($this->getSeekables() as $field => $spec) { $where_or[] = "product_order.{$field} LIKE '%{$keywords}%'"; } $where_or[] = 'product_order.societe_id ' . CSQLDataSource::prepareIn(array_keys($societe->loadList($where_societe))); $where[] = implode(' OR ', $where_or); } $orderby = 'product_order.date_ordered DESC, product_order_item_reception.date DESC'; $where['product_order.deleted'] = " = 0"; $where['product_order.cancelled'] = " = 0"; $where['product_order.locked'] = " = 0"; $where['product_order.date_ordered'] = "IS NULL"; $where['product_order.received'] = " != '1'"; // Exclude return orders (Bon de retour) $query = "!= % OR product_order.comments IS NULL"; $where['product_order.comments'] = $this->_spec->ds->prepare($query, CProductOrder::$_return_form_label); switch ($type) { case 'waiting': break; case 'locked': $where['product_order.locked'] = " = 1"; break; case 'pending': $where['product_order.locked'] = " = 1"; $where['product_order.date_ordered'] = "IS NOT NULL"; break; case 'received': $where['product_order.locked'] = " = 1"; $where['product_order.date_ordered'] = "IS NOT NULL"; $where['product_order.received'] = " = '1'"; break; default: case 'cancelled': $where['product_order.cancelled'] = " = 1"; unset($where['product_order.locked']); unset($where['product_order.received']); unset($where['product_order.date_ordered']); break; } $where['product_order.group_id'] = " = '" . CProductStockGroup::getHostGroup() . "'"; $old_limit = $limit; if ($type === 'pending') { $limit = 200; } $groupby = "product_order.order_id"; /** @var self[] $orders_list */ $orders_list = $this->loadList($where, $orderby, $limit, $groupby, $leftjoin); // bons de facturation seulement if ($type === 'pending') { foreach ($orders_list as $_id => $_order) { if (!$_order->containsRenewalLines()) { unset($orders_list[$_id]); } } $this->_search_count = count($orders_list); $orders_list = CRequest::artificialLimit($orders_list, $old_limit); } else { $this->_search_count = count($this->countMultipleList($where, null, $groupby, $leftjoin)); } /*if ($type === 'pending') { $list = array(); foreach ($orders_list as $_order) { if ($_order->countReceivedItems() < $_order->countBackRefs("order_items")) { $list[] = $_order; } } $orders_list = $list; } else if ($type === 'received') { $list = array(); foreach ($orders_list as $_order) { if ($_order->countReceivedItems() >= $_order->countBackRefs("order_items")) { $list[] = $_order; } } $orders_list = $list; }*/ foreach ($orders_list as $_order) { $_order->loadRefsFwd(); } return $orders_list; }
* $Id$ * * @package Mediboard * @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $do = new CDoObjectAddEdit('CProductOrderItemReception'); $reference_id = CValue::post("_reference_id"); $quantity = CValue::post("quantity"); if ($reference_id) { // If it is a societe id if (!is_numeric($reference_id)) { list($societe_id, $product_id) = explode("-", $reference_id); $societe = new CSociete(); $societe->load($societe_id); $product = new CProduct(); $product->load($product_id); $reference = new CProductReference(); $reference->product_id = $product->_id; $reference->societe_id = $societe->_id; $reference->quantity = 1; $reference->price = 0; $reference->store(); } else { // If it is a reference id $reference = new CProductReference(); $reference->load($reference_id); } if (!$reference->_id) {
* @package Mediboard * @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkEdit(); $category_id = CValue::getOrSession('category_id'); $societe_id = CValue::getOrSession('societe_id'); $letter = CValue::getOrSession('letter'); $_autofill = CValue::get('_autofill'); // Categories list $category = new CProductCategory(); $list_categories = $category->loadList(null, 'name'); // Suppliers list $list_societes = CSociete::getSuppliers(false); $order = new CProductOrder(); $list_orders = $order->search("waiting", null, 30); foreach ($list_orders as $_order) { $_order->countBackRefs("order_items"); $_order->loadRefsOrderItems(); } // Smarty template $smarty = new CSmartyDP(); $smarty->assign('_autofill', $_autofill); $smarty->assign('list_categories', $list_categories); $smarty->assign('category_id', $category_id); $smarty->assign('list_societes', $list_societes); $smarty->assign('societe_id', $societe_id); $smarty->assign('letter', $letter); $smarty->assign('list_orders', $list_orders);
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkRead(); $start = CValue::get('start', 0); $keywords = CValue::get('keywords'); $suppliers = CValue::get('suppliers'); $manufacturers = CValue::get('manufacturers'); $inactive = CValue::get('inactive'); CValue::setSession('suppliers', $suppliers); CValue::setSession('manufacturers', $manufacturers); CValue::setSession('inactive', $inactive); if (!$keywords) { $keywords = "%"; } $societe = new CSociete(); $list = $societe->seek($keywords, null, 1000, true); $list_count = $societe->_totalSeek; foreach ($list as $_id => $_societe) { if (!($manufacturers && $_societe->_is_manufacturer || $suppliers && $_societe->_is_supplier || $inactive && (!$_societe->_is_supplier && !$_societe->_is_manufacturer))) { unset($list[$_id]); $list_count--; } else { $_societe->countBackRefs("products"); $_societe->countBackRefs("product_references"); } } $list = array_slice($list, $start, 30); // Smarty template $smarty = new CSmartyDP(); $smarty->assign('list', $list);