$smarty->assign("services", $services);
if (!$service_id) {
    $smarty->display("inc_form_stats.tpl");
    CAppUI::stepMessage(UI_MSG_ALERT, "warning-hospi-stats-choose_service");
    return;
}
$ds = CSQLDataSource::get("std");
$dates = array();
$date_temp = $date_min;
$series = array();
while ($date_temp <= $date_max) {
    $dates[] = array(count($dates), CMbDT::dateToLocale($date_temp));
    $date_temp = CMbDT::date("+1 day", $date_temp);
}
// Table temporaraire de dates pour les jointures
$tab_name = CSQLDataSource::tempTableDates($date_min, $date_max);
// Nombre de lits totaux sur le service
$lit = new C**t();
$where = array();
$ljoin = array();
$ljoin["chambre"] = "chambre.chambre_id = lit.chambre_id";
$where["service_id"] = " = '{$service_id}'";
$where["lit.annule"] = " = '0'";
$nb_lits = $lit->countList($where, null, $ljoin);
if (!$nb_lits) {
    $smarty->display("inc_form_stats.tpl");
    CAppUI::stepMessage(UI_MSG_WARNING, "warning-hospi-stats-no_beds");
    return;
}
// Lits ouverts (non bloqués - non compris les blocages des urgence)
$serie = array("data" => array(), "label" => utf8_encode("Ouvert / Total"), "markers" => array("show" => true));