Advertisement
michal_loksik

Untitled

Nov 29th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1.         /**
  2.          * ak klient ma stale platny program cviceni, nastavi sa mu cviciaci tyzden
  3.          */
  4.         $todayDatetime = \Nette\Utils\DateTime::from('now');
  5.         $mainDatetime = \Nette\Utils\DateTime::from($lastQuestionnaire->created);
  6.  
  7.         if ($todayDatetime === $mainDatetime) {
  8.             $currentExcerciseWeek = 1;
  9.  
  10.         } else {
  11.             $currentExcerciseWeek = $todayDatetime->diff($mainDatetime, TRUE);
  12.             $currentExcerciseWeek = $currentExcerciseWeek->format('%a');
  13.             $currentExcerciseWeek = ceil($currentExcerciseWeek / 7);
  14.             $currentExcerciseWeek = intval($currentExcerciseWeek);
  15.         }
  16.  
  17.         if ($currentExcerciseWeek === 0) {
  18.             $currentExcerciseWeek = 1;
  19.         }
  20.  
  21.         /**
  22.          * ak ma klient viac dotaznikov,
  23.          * zapocita sa mu do aktualneho tyzdna dlzka z minulych programov
  24.          */
  25.         $previosProgramLength = 0;
  26.  
  27.         if (count($questionnaires) > 1) {
  28.             for ($i = 1; $i < count($questionnaires); $i++) {
  29.                 //v tyzdnoch
  30.                 $previosProgramLength = $questionnaires[$i]->product->excerciseDuration * 4;
  31.  
  32.                 $currentExcerciseWeek += $previosProgramLength;
  33.             }
  34.         }
  35.  
  36.  
  37.         if (!empty($client->excercisePauseDuration)) {
  38.             $currentExcerciseWeek = $currentExcerciseWeek - floor($client->excercisePauseDuration / 7);
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement