Changeset 1658007
- Timestamp:
- 05/15/2017 07:57:28 PM (9 years ago)
- Location:
- redi-restaurant-reservation/branches/andrew
- Files:
-
- 4 edited
-
css/restaurant.css (modified) (1 diff)
-
js/restaurant.js (modified) (10 diffs)
-
redi-restaurant-reservation.php (modified) (15 diffs)
-
templates/frontend.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
redi-restaurant-reservation/branches/andrew/css/restaurant.css
r1600333 r1658007 278 278 279 279 280 .redi-restaurant-time-button {280 .redi-restaurant-time-button, .redi-restaurant-duration-button { 281 281 282 282 float: left; -
redi-restaurant-reservation/branches/andrew/js/restaurant.js
r1623273 r1658007 11 11 jQuery(function () { 12 12 13 jQuery('#step1button').show(); 14 13 jQuery('#step1button').show(); 15 14 jQuery('.disabled').on('click', function (e) { 16 15 e.preventDefault(); … … 45 44 jQuery('#redi-restaurant-startTime-alt').val(jQuery('#redi-restaurant-startHour').val() + ':' + jQuery('#redi-restaurant-startMinute').val()); // update time in hidden field 46 45 } 47 48 49 46 50 47 jQuery('#redi-restaurant-startHour').change(updateTime); … … 65 62 var month1 = jQuery('#redi-restaurant-startDate').datepicker('getDate').getMonth() + 1; 66 63 var year1 = jQuery('#redi-restaurant-startDate').datepicker('getDate').getFullYear(); 67 var fullDate = year1 + '-' + zeroFill(month1) + '-' + zeroFill(day1) 64 var fullDate = year1 + '-' + zeroFill(month1) + '-' + zeroFill(day1); 68 65 if (timeshiftmode === 'byshifts') { 69 66 step1call(fullDate) … … 194 191 UserEmail: jQuery('#UserEmail').val(), 195 192 UserComments: jQuery('#UserComments').val(), 193 Menu: jQuery('#menu').val(), 194 duration: jQuery('#redi-restaurant-durationHidden').val(), 196 195 UserPhone: jQuery('#UserPhone').val(), 197 196 placeID: jQuery('#placeID').val(), 198 197 lang: locale, 199 apikeyid: apikeyid 198 apikeyid: apikeyid 200 199 }; 201 200 var field_1 = jQuery('#field_1'); … … 298 297 startDateISO: jQuery('#redi-restaurant-startDateISO').val(), 299 298 persons: jQuery('#persons').val(), 299 duration: jQuery('#redi-restaurant-durationHidden').val(), 300 300 lang: locale, 301 301 timeshiftmode: timeshiftmode, … … 314 314 if (response['alternativeTime'] !== undefined) { 315 315 switch (response['alternativeTime']) { 316 case 1: //AlternativeTimeBlocks see class AlternativeTime: :316 case 1: //AlternativeTimeBlocks see class AlternativeTime: 317 317 //pass thought 318 318 case 2: //AlternativeTimeByShiftStartTime … … 327 327 } 328 328 if (response[res]['Available']) all_busy = false; 329 } 329 } 330 330 display_all_busy(all_busy); 331 331 break; … … 399 399 display_all_busy(all_busy); 400 400 } 401 402 console.log(response); 403 jQuery('#menu').find('option').remove(); 404 for(var menu in response['menus']){ 405 jQuery('#menu').append(jQuery('<option>', { value : response['menus'][menu]['title'] }).text(response['menus'][menu]['title'])); 406 } 401 407 break; 402 408 } … … 493 499 ID: jQuery('#redi-restaurant-cancelID').val(), 494 500 Email: jQuery('#redi-restaurant-cancelEmail').val(), 495 Reason: jQuery('#redi-restaurant-cancelReason').val(), 501 Reason: jQuery('#redi-restaurant-cancelReason').val(), 496 502 lang: locale, 497 503 apikeyid: apikeyid … … 540 546 jQuery('#step2').show(); 541 547 }); 548 549 jQuery(document).on('click', '.redi-restaurant-duration-button', function(event){ 550 event.preventDefault(); 551 jQuery('#redi-restaurant-durationHidden').val(jQuery(this).val()); 552 553 var day1 = jQuery('#redi-restaurant-startDate').datepicker('getDate').getDate(); 554 var month1 = jQuery('#redi-restaurant-startDate').datepicker('getDate').getMonth() + 1; 555 var year1 = jQuery('#redi-restaurant-startDate').datepicker('getDate').getFullYear(); 556 var fullDate = year1 + '-' + zeroFill(month1) + '-' + zeroFill(day1); 557 step1call(fullDate); 558 }); 542 559 }); 543 560 -
redi-restaurant-reservation/branches/andrew/redi-restaurant-reservation.php
r1654604 r1658007 623 623 } 624 624 625 $reservationTime = $this->getReservationTime();625 //$reservationTime = $this->getReservationTime(); 626 626 627 627 $custom_fields_save_to = $this->GetOption( 'customfields_save_to' ); … … 1076 1076 } 1077 1077 1078 $durations = self::getDurations(); 1079 $defaultDuration = 0; 1080 foreach($durations as $duration){ 1081 if(isset($duration['default'])){ 1082 $defaultDuration = $duration['minutes']; 1083 } 1084 } 1085 $menus = self::getMenus(date('d.m.Y'), date('l')); 1078 1086 $hide_clock = false; 1079 1087 $persons = (int) $this->GetOption( 'MinPersons' ); … … 1093 1101 'startTime' => '0:00', 1094 1102 'persons' => $persons, 1095 'lang' => get_locale() 1103 'lang' => get_locale(), 1104 'duration' => $defaultDuration 1096 1105 ) 1097 1106 ) … … 1133 1142 $manual = true; 1134 1143 } 1144 1135 1145 require_once( REDI_RESTAURANT_TEMPLATE . 'frontend.php' ); 1136 1146 $out = ob_get_contents(); … … 1297 1307 1298 1308 // calculate end time 1299 $endTimeInt = strtotime( '+' . $ this->getReservationTime( $persons ). 'minutes', $startTimeInt );1309 $endTimeInt = strtotime( '+' . $post['duration'] . 'minutes', $startTimeInt ); 1300 1310 1301 1311 // format to ISO … … 1332 1342 1333 1343 case AlternativeTime::AlternativeTimeByDay: 1334 $params['ReservationDuration'] = $ this->getReservationTime( $persons );1344 $params['ReservationDuration'] = $post['duration']; 1335 1345 $query = $this->redi->availabilityByDay( $categoryID, $params ); 1336 1346 break; … … 1362 1372 } 1363 1373 1364 if ( $timeshiftmode === 'byshifts' ) { 1374 if ( $timeshiftmode === 'byshifts' ) { 1375 // var_dump($menus); 1376 $query['menus'] = self::getMenus(date('d.m.Y', $startTimeInt), date('l', $startTimeInt)); 1365 1377 $query['alternativeTime'] = $alternativeTime; 1366 1378 switch ( $alternativeTime ) { … … 1396 1408 } 1397 1409 1410 1398 1411 return $query; 1399 1412 } … … 1423 1436 1424 1437 case 'step2': 1425 1438 echo 'step2'; 1426 1439 $persons = (int) self::GetPost( 'persons' ); 1427 1440 // convert to int … … 1432 1445 1433 1446 // calculate end time 1434 $endTimeInt = strtotime( '+' . $ this->getReservationTime( $persons ). 'minutes', $startTimeInt );1447 $endTimeInt = strtotime( '+' . $post['duration'] . 'minutes', $startTimeInt ); 1435 1448 1436 1449 // format to ISO … … 1449 1462 ); 1450 1463 1451 $params['ReservationDuration'] = $this->getReservationTime( $persons );1464 //$params['ReservationDuration'] = $this->getReservationTime( $persons ); 1452 1465 $query = $this->redi->query( $categoryID, $params ); 1453 1466 … … 1477 1490 1478 1491 // calculate end time 1479 $endTimeInt = strtotime( '+' . $this->getReservationTime( $persons) . 'minutes', $startTimeInt );1492 $endTimeInt = strtotime( '+' . self::GetPost('duration') . 'minutes', $startTimeInt ); 1480 1493 1481 1494 // format to ISO … … 1503 1516 $comment .= '<br/>'; 1504 1517 } 1505 $comment .= mb_substr( self::GetPost( 'UserComments', '' ), 0, 250 ); 1518 $comment .= mb_substr( self::GetPost( 'UserComments' ), 0, 250 ); 1519 $comment .= '<br/>Menu: '.self::GetPost( 'Menu' ); 1506 1520 1507 1521 $params = array( … … 1617 1631 1618 1632 private function getReservationTime( $persons = 0 ) { 1633 echo 'getReservationTime'; 1619 1634 $filename = plugin_dir_path( __FILE__ ) . 'reservationtime.json'; 1620 1635 … … 1665 1680 return str_replace( '_', '-', get_locale()); 1666 1681 } 1682 1683 private function getDurations() 1684 { 1685 $posts = get_posts(array( 1686 'numberposts' => -1, 1687 'post_status' => 'publish', 1688 'post_type' => 'duration', 1689 'order' => 'ASC', 1690 'orderby' => 'meta_value_num', //or 'meta_value_num' 1691 'meta_query' => array(array('key' => 'minutes')) 1692 )); 1693 $durations = []; 1694 1695 foreach ($posts as $post) { 1696 $custom_fields = self::ArrayKeysLowercase(get_post_custom($post->ID)); 1697 $duration = array ( 1698 'title' => $post->post_title 1699 ); 1700 if (isset($custom_fields['minutes'])) { 1701 $duration['minutes'] = $custom_fields['minutes'][0]; 1702 }if (isset($custom_fields['default'])) { 1703 $duration['default'] = true; 1704 } 1705 $durations[] = $duration; 1706 1707 } 1708 1709 return $durations; 1710 } 1711 1712 private function getMenus($date, $dayofweek) 1713 { 1714 $posts = get_posts(array( 1715 'numberposts' => -1, 1716 'post_status' => 'publish', 1717 'post_type' => 'menu', 1718 'meta_query' => array( 1719 'relation' => 'OR', 1720 array( 1721 'relation' => 'AND', 1722 array( 1723 'key' => 'dayofweek', 1724 'value' => $dayofweek 1725 ), 1726 ), 1727 array( 1728 'relation' => 'AND', 1729 array( 1730 'key' => 'dayofweek', 1731 'compare' => 'NOT EXISTS' 1732 ), 1733 ) 1734 ) 1735 ) 1736 ); 1737 $menus = []; 1738 1739 foreach ($posts as $post) { 1740 $menus[] = array( 1741 'title' => $post->post_title, 1742 ); 1743 } 1744 1745 return $menus; 1746 } 1747 1748 public function ArrayKeysLowercase($array){ 1749 $return =[]; 1750 foreach ($array as $key=>$value){ 1751 $return[strtolower($key)] = $value; 1752 } 1753 return $return; 1754 } 1667 1755 } 1668 1756 } -
redi-restaurant-reservation/branches/andrew/templates/frontend.php
r1654604 r1658007 39 39 <input id="redi-restaurant-startDateISO" type="hidden" value="<?php echo $startDateISO ?>" name="startDateISO"/> 40 40 41 42 41 <?php if(!$hide_clock):?> 43 42 <label for="redi-restaurant-startHour"><?php _e('Time', 'redi-restaurant-reservation')?>:<span class="redi_required"> *</span></label> … … 63 62 <?php endif;?> 64 63 <label for="persons"> 65 <?php _e('Persons', 'redi-restaurant-reservation')?>:<span class="redi_required"> *</span></label> 64 <?php _e('Persons', 'redi-restaurant-reservation')?>:<span class="redi_required"> *</span> 65 </label> 66 66 <select name="persons" id="persons" class="redi-reservation-select"> 67 67 <?php for ($i = $minPersons; $i != $maxPersons+1; $i++): ?> … … 76 76 <?php endif ?> 77 77 </select> 78 <?php if ( $timeshiftmode === 'byshifts' || $hidesteps): ?> 78 <div> 79 <label for="menu"> 80 <?php _e('Menu', 'redi-restaurant-reservation')?>:<span class="redi_required"> *</span> 81 </label> 82 83 <select name="menu" id="menu" class="redi-reservation-select"> 84 <?php foreach($menus as $menu):?> 85 <option value="<?php echo $menu['title'] ?>"><?php echo $menu['title'] ?></option> 86 <?php endforeach ?> 87 </select> 88 <label for="duration"> 89 <?php _e('Duration', 'redi-restaurant-reservation')?>:<span class="redi_required"> *</span> 90 </label> 91 <?php $defaultDuration = 0;?> 92 <?php foreach($durations as $duration):?> 93 <?php if(isset($duration['default'])) $defaultDuration = $duration['minutes'];?> 94 <button class="redi-restaurant-duration-button button" value="<?php echo $duration['minutes'] ?>"><?php echo $duration['title'] ?></button> 95 <?php endforeach ?> 96 <input type="hidden" id="redi-restaurant-durationHidden" value="<?php echo $defaultDuration ?> "/> 97 </div> 98 <br/><br/> 99 <?php if ( $timeshiftmode === 'byshifts' || $hidesteps): ?> 79 100 <div id="step1times"> 80 101 <span id="step1buttons"> … … 113 134 <?php endif /* normal */ ?> 114 135 <div id="large_groups_message" style="display: none;" class="redi-reservation-alert-info redi-reservation-alert"><?php echo $largeGroupsMessage?></div> 115 116 117 136 <div id="step1busy" <?php if(!$all_busy):?>style="display: none;"<?php endif; ?> class="redi-reservation-alert-error redi-reservation-alert"> 118 137 <?php _e('Reservation is not available on selected day. Please select another day.', 'redi-restaurant-reservation');?> … … 130 149 </div> 131 150 132 133 <div id="step2" <?php if ($timeshiftmode !=='byshifts' || $hidesteps): ?>style="display: none" <?php endif ?>> 134 151 <div id="step2" <?php if ($timeshiftmode !=='byshifts' || $hidesteps): ?>style="display: none" <?php endif ?>> 135 152 <?php if ( $timeshiftmode !=='byshifts' || $hidesteps ): ?> 136 153 <h2> … … 158 175 <?php if ( isset( $available['Availability'] ) && is_array($available['Availability']) ): ?> 159 176 <?php $all_busy = true; ?> 160 161 177 <?php foreach ( $available['Availability'] as $button ): ?><button title="<?php echo $button['Reason']?>" <?php if(!$button['Available']):?>disabled="disabled"<?php endif?> class="redi-restaurant-time-button button" value="<?php echo $button['StartTimeISO'] ?>"><?php echo $button['StartTime'] ?></button><?php if($button['Available']) $all_busy = false; ?><?php endforeach; ?> 162 178
Note: See TracChangeset
for help on using the changeset viewer.