*/ CCanDo::checkEdit(); $stock_service_id = CValue::getOrSession('stock_service_id'); $category_id = CValue::getOrSession('category_id'); $service_id = CValue::getOrSession('service_id'); $product_id = CValue::get('product_id'); // Loads the stock $stock = new CProductStockService(); // If stock_id has been provided, we load the associated product if ($stock_service_id) { $stock->load($stock_service_id); $stock->loadRefsFwd(); $stock->_ref_product->loadRefsFwd(); } else { if ($product_id) { $product = new CProduct(); $product->load($product_id); $stock->product_id = $product_id; $stock->_ref_product = $product; $stock->updateFormFields(); } else { $stock->loadRefsFwd(); // pour le _ref_product } } // Categories list $list_categories = new CProductCategory(); $list_categories = $list_categories->loadList(null, 'name'); $list_services = CProductStockGroup::getServicesList(); // Création du template $smarty = new CSmartyDP();
/** * @see parent::importObject() */ function importObject(DOMElement $element) { $id = $element->getAttribute("id"); if (isset($this->imported[$id])) { return; } $_class = $element->getAttribute("class"); $imported_object = null; $idex = self::lookupObject($id); if ($idex->_id) { CAppUI::stepAjax("'{$id}' présent en base", UI_MSG_OK); $this->imported[$id] = true; $this->map[$id] = $idex->loadTargetObject()->_guid; return; } switch ($_class) { case "CProductCategory": $imported_object = $this->findOrCreate($element, $_class, array("name"), "Catégorie '%s' retrouvée", "Catégorie '%s' créée"); break; case "CSociete": $imported_object = $this->findOrCreate($element, $_class, array("name"), "Société '%s' retrouvée", "Société '%s' créée"); break; case "CProduct": /** @var CProduct $_object */ $_object = $this->getObjectFromElement($element); $_object_base = new CProduct(); $_object_base->name = $_object->name; $_object_base->loadMatchingObjectEsc(); if (!$_object_base->_id) { $imported_object = $this->findOrCreate($element, $_class, array("code_canonical"), "Produit '%s' retrouvé", "Produit '%s' créé"); break; } else { if ($_object_base->code != $_object->code) { $_object->name .= " (import du " . CMbDT::dateTime() . " - " . substr(uniqid("", true), -5) . ")"; $_similar = new CProduct(); $_similar->code = $_object->code; if (!$_similar->loadMatchingObjectEsc()) { if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); throw new Exception($msg); } CAppUI::stepAjax("Produit '%s' créé", UI_MSG_OK, $_object->_view); } else { $_object = $_similar; CAppUI::stepAjax("Produit '%s' retrouvé", UI_MSG_OK, $_object->_view); } } $imported_object = $_object; } break; case "CProductReference": $imported_object = $this->findOrCreate($element, $_class, array("quantity", "societe_id", "product_id"), "Référence '%s' retrouvée", "Référence '%s' créée"); break; case "CProductStockGroup": $imported_object = $this->findOrCreate($element, $_class, array("product_id", "group_id"), "Stock établissement '%s' retrouvé", "Stock établissement '%s' créé"); break; case "CProductStockService": $imported_object = $this->findOrCreate($element, $_class, array("object_id", "object_class", "product_id"), "Stock service '%s' retrouvé", "Stock service '%s' créé"); break; default: // Ignored classes if (in_array($_class, self::$_ignored_classes)) { break; } $_object = $this->getObjectFromElement($element); if ($msg = $_object->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); break; } CAppUI::stepAjax(CAppUI::tr($_object->_class) . " '%s' créé", UI_MSG_OK, $_object); $imported_object = $_object; break; } // Store idex on new object if ($imported_object && $imported_object->_id) { $idex->setObject($imported_object); $idex->id400 = $id; if ($msg = $idex->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); } } else { if (!in_array($_class, self::$_ignored_classes)) { CAppUI::stepAjax("{$id} sans objet", UI_MSG_WARNING); } } if ($imported_object) { $this->map[$id] = $imported_object->_guid; } $this->imported[$id] = true; }
<?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::checkRead(); $product_id = CValue::get('product_id'); $width = CValue::get('width', 400); $height = CValue::get('height', 100); $product = new CProduct(); $product->load($product_id); $product->loadRefStock(); $series = array(array("label" => utf8_encode("Entrées"), "color" => "#66CC00", "data" => array()), array("label" => utf8_encode("Sorties"), "color" => "#CB4B4B", "data" => array()), array("label" => utf8_encode("Périmés"), "color" => "#6600CC", "data" => array())); $ticks = array(); $max = 1; $now = CMbDT::date(); $date = CMbDT::date("-6 MONTHS"); $i = 0; while ($date < $now) { //$to = CMbDT::date("+1 MONTH", $date); //$ticks[] = "Du ".CMbDT::dateToLocale($date)." au ".CMbDT::dateToLocale($to); $date = CMbDT::format($date, "%Y-%m-01"); $to = CMbDT::date("+1 MONTH", $date); $ticks[] = array(count($ticks) * 2 - 0.4, utf8_encode(CMbDT::format($date, "%b"))); // Input //////////////////
if ($destockages[$code_cip]["stock"]) { $destockages[$code_cip]["stock"]->quantity -= $destockages[$code_cip]["nb_produit"]; $stock = $destockages[$code_cip]["stock"]; $log = new CUserLog(); $where = array(); $order = "date DESC"; $where["object_id"] = " = '{$stock->_id}'"; $where["object_class"] = " = '{$stock->_class}'"; $where["date"] = " BETWEEN '{$date_min}' AND '{$date_max}'"; $where["fields"] = " LIKE '%quantity%'"; $destockages[$code_cip]["stock"]->_ref_logs = $log->loadList($where, $order); foreach ($destockages[$code_cip]["stock"]->_ref_logs as $log) { $log->loadRefsFwd(); } } else { $product = new CProduct(); $product->code = $code_cip; $product->category_id = CAppUI::conf('dPmedicament CBcbProduitLivretTherapeutique product_category_id'); if ($product->loadMatchingObject()) { $stock = new CProductStockService(); $stock->object_id = $service_id; $stock->object_class = "CService"; // XXX $stock->product_id = $product->_id; $stock->store(); $destockages[$code_cip]['stock'] = $stock; } else { $destockages[$code_cip]['stock'] = null; } } }
CValue::setSession("show_all", $show_all); $where = array(); $where["name"] = $letter === "#" ? "RLIKE '^[^A-Z]'" : "LIKE '{$letter}%'"; if ($category_id) { $where['category_id'] = " = '{$category_id}'"; } if ($societe_id) { $where['societe_id'] = " = '{$societe_id}'"; } if ($keywords) { $where[] = "`code` LIKE '%{$keywords}%' OR \r\n `name` LIKE '%{$keywords}%' OR \r\n `classe_comptable` LIKE '%{$keywords}%' OR \r\n `description` LIKE '%{$keywords}%'"; } if (!$show_all) { $where[] = "cancelled = '0' OR cancelled IS NULL"; } $orderby = 'name, code'; $product = new CProduct(); $total = $product->countList($where); $list_products = $product->loadList($where, $orderby, intval($start) . "," . CAppUI::conf("dPstock CProduct pagination_size")); foreach ($list_products as $prod) { $prod->loadRefs(); $prod->getPendingOrderItems(false); } // Smarty template $smarty = new CSmartyDP(); $smarty->assign('list_products', $list_products); $smarty->assign('product_id', $product_id); $smarty->assign('total', $total); $smarty->assign('start', $start); $smarty->assign('letter', $letter); $smarty->display('inc_products_list.tpl');
* @package Mediboard * @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ if (isset($_POST['_code'])) { $stock = CProductStockGroup::getFromCode($_POST['_code']); if ($stock) { $_POST['stock_class'] = "CProductStockGroup"; $_POST['stock_id'] = $stock->_id; $_POST['_code'] = null; } } if (isset($_POST['product_id'])) { $product = new CProduct(); $product->load($_POST['product_id']); if ($product->loadRefStock()->_id) { $_POST["stock_class"] = $product->_ref_stock_group->_class; $_POST["stock_id"] = $product->_ref_stock_group->_id; unset($_POST['product_id']); } else { if (isset($_POST['manual'])) { $stock_group = new CProductStockGroup(); $stock_group->product_id = $product->_id; $stock_group->group_id = CProductStockGroup::getHostGroup(); $stock_group->quantity = $_POST["quantity"]; $stock_group->order_threshold_min = $_POST["quantity"]; CAppUI::displayMsg($stock_group->store(), "CProductStockGroup-msg-create"); $_POST["stock_class"] = $stock_group->_class; $_POST["stock_id"] = $stock_group->_id;
<?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::checkRead(); $product_id = CValue::getOrSession('product_id', null); $product = new CProduct(); $category_id = 0; if ($product->load($product_id)) { $product->loadRefsFwd(); $category_id = $product->_ref_category->_id; } // Création du template $smarty = new CSmartyDP(); $smarty->assign('selected_product', $product->_id); $smarty->assign('selected_category', $category_id); $smarty->display('product_selector.tpl');
<?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(); $product_id = CValue::getOrSession('product_id'); // Loads the required Product and its References $product = new CProduct(); if ($product->load($product_id)) { $product->loadRefsBack(); $endowment_item = new CProductEndowmentItem(); $ljoin = array('product_endowment' => "product_endowment.endowment_id = product_endowment_item.endowment_id"); foreach ($product->_ref_stocks_service as $_stock) { $where = array("product_endowment.service_id" => "= '{$_stock->object_id}'", "product_endowment_item.product_id" => "= '{$product->_id}'"); $_stock->_ref_endowment_items = $endowment_item->loadList($where, null, null, null, $ljoin); } foreach ($product->_ref_references as $_reference) { $_reference->loadRefProduct(); $_reference->loadRefSociete(); } $product->loadRefStock(); $where = array("stock_class" => " = 'CProductStockGroup'", "stock_id" => " = '{$product->_ref_stock_group->stock_id}'"); $delivery = new CProductDelivery(); $product->_ref_deliveries = $delivery->loadList($where, "date_dispensation DESC, date_delivery DESC", 50);
<?php /** * $Id$ * * @package Mediboard * @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ global $g; CCanDo::checkEdit(); $product_id = CValue::get('product_id'); $product = new CProduct(); $product->load($product_id); $list_services = CProductStockGroup::getServicesList(); foreach ($list_services as $_service) { $stock_service = CProductStockService::getFromProduct($product, $_service); if (!$stock_service->_id) { $stock_service->quantity = $product->quantity; $stock_service->order_threshold_min = $product->quantity; } $_service->_ref_stock = $stock_service; } // Création du template $smarty = new CSmartyDP(); $smarty->assign('list_services', $list_services); $smarty->display('inc_list_stock_services.tpl');
<?php /** * $Id: httpreq_product_selector_products_list.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::checkRead(); $category_id = CValue::get('category_id'); $keywords = CValue::get('keywords'); $selected_product = CValue::get('selected_product'); $product = new CProduct(); $category = new CProductCategory(); $total = null; $count = null; $where_or = array(); $order = 'name, code'; //FIXME: changer en seek if ($keywords) { foreach ($product->getSeekables() as $field => $spec) { $where_or[] = "`{$field}` LIKE '%{$keywords}%'"; } $where = array(); $where[] = implode(' OR ', $where_or); $where[] = "cancelled IS NULL OR cancelled = '0'"; $list_products = $product->loadList($where, $order, 20); $total = $product->countList($where);
/** * @see parent::getPerm() */ function getPerm($permType) { $this->loadRefsFwd(); return parent::getPerm($permType) && $this->_ref_endowment->getPerm($permType) && $this->_ref_product->getPerm($permType); }
if (!preg_match('/^MICRO AY ([+-])(\\d{2}).([05])$/', $_product->code, $matches)) { continue; } $old_code = $_product->code; $dioptrie_sign = $matches[1] === "+" ? "1" : "2"; $_product->code = "2808" . $dioptrie_sign . $matches[2] . $matches[3]; CAppUI::stepAjax(" Conversion: \"{$old_code}\" => \"{$_product->code}\""); if ($msg = $_product->store()) { CAppUI::stepAjax("Problème dans la conversion :" . $msg, UI_MSG_WARNING); $errors++; } } // Implants ALCON SN60WF /////////////// $where = array(); $where["code"] = "LIKE 'SN60WF +%'"; $product = new CProduct(); $list_product = $product->loadList($where); CAppUI::stepAjax(count($list_product) . " produit(s) à remplacer (ALCON SN60WF)"); $errors = 0; foreach ($list_product as $_product) { if (!preg_match('/(SN60WF)\\ \\+([0123]\\d)(?:\\.([05]))?/', $_product->code, $matches)) { continue; } $old_code = $_product->code; $_product->code = $matches[1] . "." . $matches[2] . (isset($matches[3]) ? $matches[3] : "0"); CAppUI::stepAjax(" Conversion: \"{$old_code}\" => \"{$_product->code}\""); if ($msg = $_product->store()) { CAppUI::stepAjax("Problème dans la conversion :" . $msg, UI_MSG_WARNING); $errors++; } }