Changeset 873 for trunk/Modules/OpeningHours/OpeningHours.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/OpeningHours/OpeningHours.php
r738 r873 15 15 $Hours = floor($Time / 60); 16 16 $Minutes = $Time - $Hours * 60; 17 if ($Minutes < 10) $Minutes = '0'.$Minutes;17 if ($Minutes < 10) $Minutes = '0'.$Minutes; 18 18 $Hours = $Hours % 24; 19 return ($Hours.':'.$Minutes);19 return ($Hours.':'.$Minutes); 20 20 } 21 21 … … 28 28 $Minutes = $Time; 29 29 $Output = ''; 30 if ($Days > 0) $Output .= $Days.' dnů, ';31 if ($Hours > 0) $Output .= $Hours.' hodin, ';32 if ($Minutes > 0) $Output .= $Minutes.' minut';33 return ($Output);30 if ($Days > 0) $Output .= $Days.' dnů, '; 31 if ($Hours > 0) $Output .= $Hours.' hodin, '; 32 if ($Minutes > 0) $Output .= $Minutes.' minut'; 33 return ($Output); 34 34 } 35 35 36 36 function EditSubject($Id) 37 37 { 38 if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))38 if ($this->System->User->CheckPermission('OpeningHours', 'Edit')) 39 39 { 40 40 $Output = '<div class="Centred">'; … … 46 46 $Day = array(); 47 47 $DbResult = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Id); 48 while ($DbRow = $DbResult->fetch_assoc())48 while ($DbRow = $DbResult->fetch_assoc()) 49 49 $Day[$DbRow['Day']] = $DbRow; 50 foreach ($this->DaysOfWeek as $Index => $Name)51 { 52 if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0);50 foreach ($this->DaysOfWeek as $Index => $Name) 51 { 52 if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0); 53 53 $Output .= '<tr><td>'.$Name.'</td>'. 54 54 '<td><input type="text" name="day'.$Index.'_open1_h" value="'.floor($Day[$Index]['Open1'] / 60).'" size="2" />'. … … 70 70 '</form></div>'; 71 71 } else $Output = 'Nemáte oprávnění'; 72 return ($Output);72 return ($Output); 73 73 } 74 74 … … 78 78 79 79 $Output = ''; 80 if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))80 if ($this->System->User->CheckPermission('OpeningHours', 'Edit')) 81 81 { 82 82 $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id); 83 foreach ($this->DaysOfWeek as $Index => $Name)84 { 85 if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24;86 if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24;87 if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24;88 if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24;89 if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59;90 if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59;91 if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59;92 if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59;83 foreach ($this->DaysOfWeek as $Index => $Name) 84 { 85 if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24; 86 if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24; 87 if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24; 88 if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24; 89 if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59; 90 if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59; 91 if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59; 92 if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59; 93 93 $Day = array('Subject' => $Id, 'Day' => $Index); 94 94 $Day['Open1'] = $_POST['day'.$Index.'_open1_m'] + $_POST['day'.$Index.'_open1_h'] * 60; … … 111 111 $this->Database->update('SubjectOpenTime', 'Subject='.$Id, array('UpdateTime' => 'NOW()', 'Notice' => $_POST['notice'], 'Photo' => $FileId)); 112 112 } else $Output = 'Nemáte oprávnění'; 113 return ($Output);113 return ($Output); 114 114 } 115 115 … … 118 118 $Output = '<div class="Centred">'; 119 119 $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, Subject.Id, Subject.Name as Name FROM SubjectOpenTime JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name'); 120 while ($Subject = $DbResult->fetch_assoc())120 while ($Subject = $DbResult->fetch_assoc()) 121 121 { 122 122 $Output .= '<strong>'.$Subject['Name'].':</strong><br />'; … … 125 125 $Events = array(); 126 126 $DbResult2 = $this->Database->query('SELECT * FROM `SubjectOpenTimeDay` WHERE Subject='.$Subject['Subject'].' ORDER BY Day ASC'); 127 while ($DbRow = $DbResult2->fetch_assoc())128 { 129 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))127 while ($DbRow = $DbResult2->fetch_assoc()) 128 { 129 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1'])) 130 130 { 131 131 $Events[] = array('Time' => $DbRow['Open1'] + $DbRow['Day'] * 24 * 60, 'Type' => 1); 132 132 $Events[] = array('Time' => $DbRow['Close1'] + $DbRow['Day'] * 24 * 60, 'Type' => 2); 133 133 } 134 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))134 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2'])) 135 135 { 136 136 $Events[] = array('Time' => $DbRow['Open2'] + $DbRow['Day'] * 24 * 60, 'Type' => 1); … … 141 141 142 142 // Calculate time to next event 143 if (count($Events) > 0)143 if (count($Events) > 0) 144 144 { 145 145 $CurrentTime = ((date('w') + 6) % 7) * 24 * 60 + date('G') * 60 + date('i'); 146 146 147 147 $I = 0; 148 while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime))148 while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime)) 149 149 $I++; 150 if ($I < count($Events))150 if ($I < count($Events)) 151 151 { 152 152 $NextTime = $Events[$I]['Time']; … … 160 160 $TimeDelta = $NextTime - $CurrentTime; 161 161 //$Output .= $CurrentTime.' '.$NextTime; 162 if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta);162 if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta); 163 163 else $Output .= 'Otevírá za '.$this->ToHumanTime2($TimeDelta); 164 164 } … … 166 166 // Show time inteval table 167 167 $Output .= '<table class="WideTable"><tr><th>Den</th><th>Čas</th></tr>'; 168 foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek)168 foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek) 169 169 { 170 170 $DbResult2 = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Subject['Subject'].' AND Day='.$DayIndex); 171 171 $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">'; 172 if ($DbResult2->num_rows)172 if ($DbResult2->num_rows) 173 173 { 174 174 $DbRow = $DbResult2->fetch_assoc(); 175 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))175 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1'])) 176 176 { 177 177 $Output .= $this->ToHumanTime($DbRow['Open1']).' - '.$this->ToHumanTime($DbRow['Close1']).' '; 178 178 } 179 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))179 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2'])) 180 180 { 181 181 $Output .= $this->ToHumanTime($DbRow['Open2']).' - '.$this->ToHumanTime($DbRow['Close2']).''; … … 186 186 } 187 187 $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />'; 188 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />';189 190 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';191 192 if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))188 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />'; 189 190 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 191 192 if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit')) 193 193 $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />'; 194 194 $Output .= '<br />'; 195 195 } 196 196 $Output .= '</div>'; 197 return ($Output);197 return ($Output); 198 198 } 199 199 200 200 function Show() 201 201 { 202 if (count($this->System->PathItems) > 1)203 { 204 if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']);205 else if ($this->System->PathItems[1] == 'save')202 if (count($this->System->PathItems) > 1) 203 { 204 if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']); 205 else if ($this->System->PathItems[1] == 'save') 206 206 { 207 207 $Output = $this->SaveSubject($_GET['Subject']); … … 209 209 } else $Output = PAGE_NOT_FOUND; 210 210 } else $Output = $this->ShowAll(); 211 return ($Output);211 return ($Output); 212 212 } 213 213 }
Note:
See TracChangeset
for help on using the changeset viewer.