$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 //////////////////
    $where = array("product.product_id" => "= '{$product->_id}'", "product_order_item_reception.date" => "BETWEEN '{$date}' AND '{$to}'");
    $ljoin = array("product_order_item" => "product_order_item.order_item_id = product_order_item_reception.order_item_id", "product_reference" => "product_reference.reference_id = product_order_item.reference_id", "product" => "product.product_id = product_reference.product_id");
    $lot = new CProductOrderItemReception();
    /** @var CProductOrderItemReception[] $lots */
    $lots = $lot->loadList($where, null, null, null, $ljoin);
    $total = 0;
    foreach ($lots as $_lot) {
        $total += $_lot->quantity;
    }
    $max = max($max, $total);
    $series[0]["data"][] = array(count($series[0]["data"]) * 2 - 0.6, $total);
    // Hack pour les etablissements qui ont un service "Périmés"
    $where_services = array("nom" => "= 'Périmés'");
    $services_expired = new CService();
    $services_expired_ids = $services_expired->loadIds($where_services);
    // Output //////////////////
    $where = array("product_delivery.stock_class" => "= 'CProductStockGroup'", "product_delivery.stock_id" => "= '{$product->_ref_stock_group->_id}'", "product_delivery_trace.date_delivery" => "BETWEEN '{$date}' AND '{$to}'");
    if (count($services_expired_ids)) {
        $where[100] = "(product_delivery.type != 'expired' OR product_delivery.type IS NULL)\r\n                   AND product_delivery.service_id NOT IN (" . implode(',', $services_expired_ids) . ")";
    } else {
Ejemplo n.º 2
0
 /**
  * Load lots
  *
  * @return CProductOrderItemReception[]
  */
 function loadRefsLots()
 {
     $ljoin = array("product_order_item" => "product_order_item_reception.order_item_id = product_order_item.order_item_id", "product_reference" => "product_order_item.reference_id = product_reference.reference_id", "product" => "product_reference.product_id = product.product_id");
     $where = array("product.product_id" => " = '{$this->_id}'");
     $lot = new CProductOrderItemReception();
     return $this->_ref_lots = $lot->loadList($where, "date DESC", null, null, $ljoin);
 }
Ejemplo n.º 3
0
 * @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();
$code = CValue::getOrSession('code');
$codes = array();
$products = array();
if (strlen($code) > 2) {
    $where = array('code' => "LIKE '%{$code}%'");
    $delivery = new CProductDeliveryTrace();
    $list_deliveries = $delivery->loadList($where, 'date_delivery');
    $reception = new CProductOrderItemReception();
    $list_order_reception = $reception->loadList($where, 'date');
    foreach ($list_order_reception as $trace) {
        if (!isset($codes[$trace->code])) {
            $codes[$trace->code] = array();
        }
        $trace->loadRefsFwd();
        if (!isset($products[$trace->code])) {
            $trace->loadRefOrderItem();
            $trace->_ref_order_item->loadReference();
            $trace->_ref_order_item->_ref_reference->loadRefsFwd();
            $products[$trace->code] = $trace->_ref_order_item->_ref_reference->_ref_product;
        }
        // date_reception
        if ($trace->date) {
            if (!isset($codes[$trace->code][$trace->date])) {
                $codes[$trace->code][$trace->date] = array('reception' => null, 'delivery' => null, 'delivery_reception' => null, 'administration' => null);
Ejemplo n.º 4
0
 //mbTrace($price_reference, 'price_reference');
 // CProductOrderItem : quantity and price
 // need to join on the latest log :(
 $oi_where["user_log.date"] = " > '{$_date}' AND user_log.date <= '{$old_date}'";
 $oi_where["product.product_id"] = "= '{$_product->_id}'";
 $ois = $oi->loadList($oi_where, "user_log.date DESC", null, "product_order_item.order_item_id", $oi_ljoin);
 foreach ($ois as $_oi) {
     $_oi->quantity = $_oi->quantity * $quantity_reference * $quantity_product;
     $_oi->unit_price = $_oi->unit_price / ($quantity_reference * $quantity_product);
     $_oi->units_fixed = 1;
     $_oi->store();
 }
 // CProductOrderItemReception : quantity
 $oir_where["product_order_item_reception.date"] = " > '{$_date}' AND product_order_item_reception.date <= '{$old_date}'";
 $oir_where["product.product_id"] = "= '{$_product->_id}'";
 $oirs = $oir->loadList($oir_where, null, null, null, $oir_ljoin);
 foreach ($oirs as $_oir) {
     //mbTrace(sprintf("%d\t >> %d\t", $_oir->quantity, $_oir->quantity * $quantity_reference * $quantity_product), "OIR QTY");
     $_oir->quantity = $_oir->quantity * $quantity_reference * $quantity_product;
     $_oir->units_fixed = 1;
     $_oir->store();
 }
 // Update values and date
 $old_date = $_date;
 $old_values = $_log->getOldValues();
 $_log->user_id = null;
 if (empty($old_values)) {
     //mbTrace("OLD VALUES EMPTY");
     continue;
 }
 switch ($_log->object_class) {