Пример #1
0
/**
 * $Id: vw_idx_stock_service.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();
$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
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$service_id = CValue::get('service_id');
$keywords = CValue::get('keywords');
$limit = CValue::get('limit');
// Service's stocks
$where = array();
if ($service_id) {
    $where['product_stock_service.object_id'] = " = '{$service_id}'";
    $where['product_stock_service.object_class'] = " = 'CService'";
    // XXX
}
if ($keywords) {
    $where[] = "product.code LIKE '%{$keywords}%' OR \r\n              product.name LIKE '%{$keywords}%' OR \r\n              product.description LIKE '%{$keywords}%'";
}
$orderby = 'product.name ASC';
$leftjoin = array();
$leftjoin['product'] = 'product.product_id = product_stock_service.product_id';
// product to stock
$stock = new CProductStockService();
$list_stocks_count = $stock->countList($where, null, $leftjoin);
$list_stocks = $stock->loadList($where, $orderby, $limit ? $limit : 30, null, $leftjoin);
// Smarty template
$smarty = new CSmartyDP();
$smarty->assign('stock', $stock);
$smarty->assign('list_stocks', $list_stocks);
$smarty->assign('list_stocks_count', $list_stocks_count);
$smarty->display('inc_stocks_list.tpl');
$patients = array();
if (count($deliveries)) {
    foreach ($deliveries as $_delivery) {
        $_delivery->loadRefsFwd();
        $_delivery->loadRefsBack();
        $_delivery->_ref_stock->loadRefsFwd();
        $_delivery->loadRefPatient();
        $_delivery->loadRefSejour();
        $_delivery->loadRefService();
        $_delivery->getInitialQuantity();
        $_delivery->loadRefPreparateur();
        /*if($_delivery->patient_id){
            $_delivery->loadRefPatient();
            $deliveries_nominatif[$_delivery->_id] = $_delivery;
          } else {
            $_delivery->loadRefService();
            $deliveries_global[$_delivery->_id] = $_delivery;
          }*/
        $stocks_service[$_delivery->_id] = CProductStockService::getFromCode($_delivery->_ref_stock->_ref_product->code, $service_id);
    }
}
$smarty = new CSmartyDP();
$smarty->assign('deliveries', $deliveries);
$smarty->assign('deliveries_count', $deliveries_count);
$smarty->assign('service_id', $service_id);
$smarty->assign('start', $start);
if (!$mode) {
    $smarty->display('inc_stock_reception.tpl');
} else {
    $smarty->display('print_stock_reception.tpl');
}
Пример #4
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Stock
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
// If it is a return to the group stock
if (isset($_POST['_return']) && isset($_POST['_code'])) {
    $stock_service = CProductStockService::getFromCode($_POST['_code']);
    $stock_group = CProductStockGroup::getFromCode($_POST['_code']);
    $_POST['quantity'] = -abs($_POST['quantity']);
    $_POST['_code'] = null;
    $_POST['_return'] = null;
    if ($stock_service && $stock_group) {
        $delivery = new CProductDelivery();
        $where = array('stock_id' => "= '{$stock_group->_id}'", 'stock_class' => "= 'CProductStockGroup'", 'service_id' => "= '{$stock_service->service_id}'", 'quantity' => "< 0");
        if (!$delivery->loadObject($where)) {
            $delivery->stock_id = $stock_group->_id;
            $delivery->stock_class = $stock_group->_class;
            $delivery->service_id = $stock_service->service_id;
        }
        $delivery->quantity += $_POST['quantity'];
        $delivery->date_dispensation = CMbDT::dateTime();
        if ($msg = $delivery->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        }
Пример #5
0
    $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;
    } else {
        $stock->loadRefsFwd();
    }
}
$stock->updateFormFields();
$list_services = CProductStockGroup::getServicesList();
foreach ($list_services as $_service) {
    $stock_service = new CProductStockService();
    $stock_service->object_id = $_service->_id;
    $stock_service->object_class = $_service->_class;
    $stock_service->product_id = $stock->product_id;
    if (!$stock_service->loadMatchingObject()) {
        $stock_service->quantity = $stock->_ref_product->quantity;
        $stock_service->order_threshold_min = $stock->_ref_product->quantity;
        $stock_service->order_threshold_optimum = max($stock->getOptimumQuantity(), $stock_service->quantity);
    }
    $_service->_ref_stock = $stock_service;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign('stock', $stock);
$smarty->assign('list_services', $list_services);
$smarty->display('inc_edit_stock_group.tpl');
        $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;
        }
    }
}
if ($all_stocks) {
    $stock = new CProductStockService();
    $stock->object_id = $service_id;
    $stock->object_class = "CService";
    // XXX
    $list_stocks = $stock->loadMatchingList();
    foreach ($list_stocks as $sto) {
        $sto->loadRefsFwd();
        $already = false;
        foreach ($destockages as $code => $desto) {
            if ($sto->_ref_product->code == $code) {
                $already = true;
            }
        }
        if (!$already) {
            $destockages[$sto->_ref_product->code]['stock'] = $sto;
            $destockages[$sto->_ref_product->code]['nb_produit'] = $stock->quantity;
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField('delivery_id', 'quantity', 'date_delivery', 'date_reception');
     $this->loadRefsFwd();
     $stock = $this->getStock();
     $stock->loadRefsFwd();
     $infinite_group_stock = CAppUI::conf('dPstock CProductStockGroup infinite_quantity') == '1';
     $stock_service = new CProductStockService();
     $stock_service->product_id = $stock->product_id;
     $stock_service->object_id = $this->_ref_delivery->service_id;
     $stock_service->object_class = "CService";
     // XXX
     $stock_service->loadMatchingObject();
     if (!$infinite_group_stock && $this->date_delivery) {
         $stock->quantity += $this->quantity;
         if ($msg = $stock->store()) {
             return $msg;
         }
     }
     if ($stock_service->_id && $this->date_reception) {
         $stock_service->quantity -= $this->quantity;
         if ($msg = $stock_service->store()) {
             return $msg;
         }
     }
     // Calcul du stock du sejour
     if ($this->_code_cis && $this->_ref_delivery->sejour_id && CModule::getActive("pharmacie")) {
         $stock_sejour = CStockSejour::getFromCIS($this->_code_cis, $this->_ref_delivery->sejour_id);
         if ($stock_sejour->_id) {
             $codes_cip = CMedicamentProduit::getArticleCodes($this->_code_cis);
             $ds = $this->getDS();
             $where = array();
             $where["product.code"] = $ds->prepareIn($codes_cip);
             $where["product_delivery.sejour_id"] = $ds->prepare("= '{$this->_ref_delivery->sejour_id}'");
             $ljoin = array();
             $ljoin["product_stock_group"] = "product_stock_group.stock_id = product_delivery.stock_id\r\n                                           AND product_delivery.stock_class = 'CProductStockGroup'";
             $ljoin["product"] = "product.product_id = product_stock_group.product_id";
             $delivery = new CProductDelivery();
             $delivery->loadObject($where, "product_delivery.date_dispensation DESC", null, $ljoin);
             // Si la delivrance actuelle est la derniere pour ce sejour et ce CIS
             if ($delivery->_id == $this->delivery_id) {
                 // Mise a jour de la quantité du stock en quantité d'administration
                 $code_cip = $this->_ref_delivery->loadRefStock()->loadRefProduct()->code;
                 $product = CMedicamentArticle::get($code_cip);
                 if ($product->getId()) {
                     $ratio = $product->_ratio_cis_cip;
                     // Mise à jour du stock
                     $stock_sejour->datetime = $this->_ref_delivery->datetime_min;
                     $stock_sejour->quantite -= $this->quantity / $ratio;
                     $stock_sejour->quantite = round($stock_sejour->quantite, 4);
                     if ($msg = $stock_sejour->store()) {
                         return $msg;
                     }
                 }
             }
         }
     }
     return parent::delete();
 }
<?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');
Пример #9
0
 /**
  * Load target stock
  *
  * @return CProductStockService
  */
 function loadRefTargetStock()
 {
     $this->loadRefStock();
     $stock_service = new CProductStockService();
     $this->completeField("service_id");
     if ($this->service_id) {
         $stock_service->product_id = $this->_ref_stock->product_id;
         $stock_service->object_id = $this->service_id;
         $stock_service->object_class = "CService";
         // XXX
         $stock_service->loadMatchingObject();
     }
     return $this->_ref_stock_service = $stock_service;
 }
$stock_id = CValue::getOrSession('stock_service_id');
$category_id = CValue::get('category_id');
$object_id = CValue::get('object_id');
$keywords = CValue::get('keywords');
$start = CValue::get('start');
CValue::setSession('category_id', $category_id);
$where = array("service.group_id" => "= '" . CProductStockGroup::getHostGroup() . "'");
if ($object_id) {
    $where['product_stock_service.object_id'] = " = '{$object_id}'";
    $where['product_stock_service.object_class'] = " = 'CService'";
    // XXX
}
if ($category_id) {
    $where['product.category_id'] = " = '{$category_id}'";
}
if ($keywords) {
    $where[] = "product.code LIKE '%{$keywords}%' OR \r\n              product.name LIKE '%{$keywords}%' OR \r\n              product.description LIKE '%{$keywords}%'";
}
$leftjoin = array("product" => "product.product_id = product_stock_service.product_id", "service" => "service.service_id = product_stock_service.object_id");
$stock = new CProductStockService();
$list_stocks_count = $stock->countList($where, null, $leftjoin);
$pagination_size = CAppUI::conf("dPstock CProductStockService pagination_size");
$list_stocks = $stock->loadList($where, 'product.name ASC', intval($start) . ",{$pagination_size}", null, $leftjoin);
// Smarty template
$smarty = new CSmartyDP();
$smarty->assign('stock', $stock);
$smarty->assign('stock_id', $stock_id);
$smarty->assign('list_stocks', $list_stocks);
$smarty->assign('list_stocks_count', $list_stocks_count);
$smarty->assign('start', $start);
$smarty->display('inc_stocks_list.tpl');
Пример #11
0
    foreach ($endowment_items as $_item) {
        $_item->loadRefsFwd();
        $stock_service = CProductStockService::getFromProduct($_item->_ref_product, $service);
        $stock = new CProductStockGroup();
        $stock->product_id = $_item->_ref_product->_id;
        $stock->group_id = $group_id;
        $stock->loadMatchingObject();
        $stock->updateFormFields();
        $stock->_ref_stock_service = $stock_service;
        $stock->quantity = $_item->quantity;
        $stock->_endowment_item_id = $_item->_id;
        $stocks[] = $stock;
    }
} else {
    if ($only_service_stocks == 1 || $only_common == 1) {
        $stock = new CProductStockService();
        $ljoin = array('product' => 'product.product_id = product_stock_service.product_id');
        $where['product_stock_service.object_id'] = "= '{$service_id}'";
        $where['product_stock_service.object_class'] = "= 'CService'";
        // XXX
        if ($only_common) {
            $where['product_stock_service.common'] = "= '1'";
        }
        if ($keywords) {
            $where['product.name'] = $stock->_spec->ds->prepareLike("%{$keywords}%");
        }
        /** @var CProductStockService[] $stocks_service */
        $stocks_service = $stock->seek($keywords, $where, $limit, true, $ljoin, 'product.name');
        $count_stocks = $stock->_totalSeek;
        $stocks = array();
        if ($stocks_service) {