Ejemplo n.º 1
0
/* $Id: do_delivery_aed.php 6067 2009-04-14 08:04:15Z phenxdesign $ */
/**
 * @package Mediboard
 * @subpackage soins
 * @version $Revision: 6067 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
$service_id = CValue::get('service_id');
$date_min = CValue::get('date_min');
$date_max = CValue::get('date_max');
$service = new CService();
$orders = array();
if ($service->load($service_id) && $date_min && $date_max) {
    $stocks = $service->loadBackRefs('product_stock_services');
    if ($stocks) {
        foreach ($stocks as $stock) {
            $stock->loadRefsFwd();
            $stock_group = CProductStockGroup::getFromCode($stock->_ref_product->code);
            $target_quantity = $stock->order_threshold_optimum ? $stock->order_threshold_optimum : $stock->order_threshold_max;
            if (CAppUI::conf('dPstock CProductStockService infinite_quantity') != 1) {
                $effective_quantity = $stock->quantity;
                $where = array('product_delivery.date_dispensation' => "BETWEEN '{$date_min} 00:00:00' AND '{$date_max} 23:59:59'", 'product_delivery.stock_id' => " = '{$stock_group->_id}'", 'product_delivery.stock_class' => " = '{$stock_group->_class}'", 'product.category_id' => " = '" . CAppUI::conf('dPmedicament CBcbProduitLivretTherapeutique product_category_id') . "'");
                $ljoin = array('product_stock_group' => 'product_delivery.stock_id = product_stock_group.stock_id', 'product' => 'product.product_id = product_stock_group.product_id');
                $delivery = new CProductDelivery();
                $deliveries = $delivery->loadList($where, null, null, null, $ljoin);
                foreach ($deliveries as $delivery) {
                    if ($delivery->order == 1 && $delivery->quantity > 0) {
                        $effective_quantity += $delivery->quantity;
                    }
Ejemplo n.º 2
0
 * @version $Revision: 6146 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkRead();
$service_id = CValue::get('service_id');
$start = intval(CValue::getOrSession('start', 0));
$letter = CValue::getOrSession("letter", "");
$only_service_stocks = CValue::getOrSession('only_service_stocks', 1);
$only_common = CValue::getOrSession('only_common');
$keywords = CValue::getOrSession('keywords');
$endowment_id = CValue::get('endowment_id');
$endowment_item_id = CValue::get('endowment_item_id');
$service = new CService();
$service->load($service_id);
$service->loadBackRefs("endowments");
if ($endowment_id === null && count($service->_back["endowments"])) {
    $first = reset($service->_back["endowments"]);
    $endowment_id = $first->_id;
}
// Calcul de date_max et date_min
$date_min = CValue::get('_date_min');
$date_max = CValue::get('_date_max');
if (!$date_min) {
    $date_min = CValue::session('_date_delivrance_min', CMbDT::date("-1 DAY"));
}
if (!$date_max) {
    $date_max = CValue::session('_date_delivrance_max', CMbDT::date());
}
CValue::setSession('_date_delivrance_min', $date_min);
CValue::setSession('_date_delivrance_max', $date_max);