<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$operation = new COperation();
$max_uscpo = $operation->_specs["duree_uscpo"]->max;
$default_week = $operation->conf("default_week_stat_uscpo");
/** @var date $date_min */
/** @var date $date_max */
$date_min = CValue::getOrSession("date_min", CMbDT::date($default_week == "last" ? "-1 week" : null));
$date_max = CValue::getOrSession("date_max", CMbDT::date($default_week == "next" ? "+1 week" : null));
$service_id = CValue::getOrSession("service_id", "");
if ($date_min > $date_max) {
    list($date_min, $date_max) = array($date_max, $date_min);
}
$operation = new COperation();
$where = array();
$ljoin = array();
$where["duree_uscpo"] = "> 0";
$where["annulee"] = "!= '1'";
$where[] = "operations.passage_uscpo = '1' or operations.passage_uscpo IS NULL";
if ($service_id) {
    $ljoin["sejour"] = "sejour.sejour_id = operations.sejour_id";