Esempio n. 1
0
 /**
  * Get all possible and existing RHS for given sejour, by date as keys
  *
  * @param CSejour $sejour Sejour
  *
  * @return CRHS[],null Null if not applyable
  */
 static function getAllRHSsFor(CSejour $sejour)
 {
     if (!$sejour->_id || $sejour->type != "ssr") {
         return null;
     }
     $rhss = array();
     /** @var CRHS $_rhs */
     foreach ($sejour->loadBackRefs("rhss") as $_rhs) {
         $rhss[$_rhs->date_monday] = $_rhs;
     }
     for ($date_monday = CMbDT::date("last sunday + 1 day", $sejour->_entree); $date_monday <= $sejour->_sortie; $date_monday = CMbDT::date("+1 week", $date_monday)) {
         if (!isset($rhss[$date_monday])) {
             $rhs = new CRHS();
             $rhs->sejour_id = $sejour->_id;
             $rhs->date_monday = $date_monday;
             $rhs->updateFormFields();
             $rhss[$date_monday] = $rhs;
         }
     }
     ksort($rhss);
     return $rhss;
 }