Changeset 1689142
- Timestamp:
- 07/02/2017 06:46:35 PM (9 years ago)
- Location:
- redi-restaurant-reservation/branches/newDesign
- Files:
-
- 4 edited
-
redi-restaurant-booking.php (modified) (10 diffs)
-
redi.php (modified) (3 diffs)
-
templates/admin.php (modified) (2 diffs)
-
templates/frontend.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
redi-restaurant-reservation/branches/newDesign/redi-restaurant-booking.php
r1665936 r1689142 58 58 } 59 59 } 60 if ( ! class_exists( 'CustomFieldsSaveTo' ) ) { 61 class CustomFieldsSaveTo { 62 const WPOptions = 'options'; 63 const API = 'api'; 64 } 65 } 60 66 61 67 class ReDiBooking … … 351 357 $form_valid = false; 352 358 } 353 354 for ($i = 1; $i != CUSTOM_FIELDS; $i++) { 359 $this->options[ 'customfields_save_to' ] = CustomFieldsSaveTo::API; 360 361 for ( $i = 0; $i != CUSTOM_FIELDS; $i++ ) { 362 $field_id = 'field_' . $i . '_id'; 355 363 $field_name = 'field_' . $i . '_name'; 356 364 $field_type = 'field_' . $i . '_type'; … … 358 366 $field_message = 'field_' . $i . '_message'; 359 367 360 if (isset($_POST[$field_name])) { 361 $this->options[$field_name] = $$field_name = self::GetPost($field_name); 362 } 363 if (isset($_POST[$field_type])) { 364 $this->options[$field_type] = $$field_type = self::GetPost($field_type); 365 } 366 $this->options[$field_required] = $$field_required = (self::GetPost($field_required) === 'on'); 367 if (isset($_POST[$field_message])) { 368 $this->options[$field_message] = $$field_message = self::GetPost($field_message); 368 $$field_id = self::GetPost( $field_id ); 369 370 $$field_name = self::GetPost( $field_name ); 371 372 $$field_type = self::GetPost( $field_type ); 373 $$field_required = ( self::GetPost( $field_required ) === 'on' ); 374 375 $$field_message = self::GetPost( $field_message ); 376 377 if ( empty( $$field_name ) && isset( $$field_id ) && $$field_id > 0 ) { //name is empty so delete this field 378 $this->redi->deleteCustomField( self::lang(), $placeID, $$field_id ); 379 } else { 380 //new or update 381 if ( isset( $$field_id ) && $$field_id > 0 ) { 382 $this->redi->updateCustomField( self::lang(), $placeID, $$field_id, array( 383 'customfield' => array( 384 'Name' => $$field_name, 385 'Message' => $$field_message, 386 'Required' => $$field_required ? 'true' : 'false', 387 'Type' => $$field_type 388 ) 389 ) ); 390 } else { 391 $this->redi->saveCustomField( self::lang(), $placeID, array( 392 'customfield' => array( 393 'Name' => $$field_name, 394 'Message' => $$field_message, 395 'Required' => $$field_required ? 'true' : 'false', 396 'Type' => $$field_type 397 ) 398 ) ); 399 } 369 400 } 370 401 } … … 482 513 $reservationTime = $this->getReservationTime(); 483 514 484 for ($i = 1; $i != CUSTOM_FIELDS; $i++) { 515 $custom_fields_save_to = $this->GetOption( 'customfields_save_to' ); 516 517 if ( $custom_fields_save_to === null || $custom_fields_save_to === CustomFieldsSaveTo::WPOptions ) { 518 // Get custom fields from wordpress options 519 $custom_fields = array(); 520 for ( $i = 0; $i != CUSTOM_FIELDS; $i ++ ) { 485 521 $field_name = 'field_' . $i . '_name'; 486 522 $field_type = 'field_' . $i . '_type'; … … 488 524 $field_message = 'field_' . $i . '_message'; 489 525 490 $$field_name = $this->GetOption($field_name); 491 $$field_type = $this->GetOption($field_type); 492 $$field_required = $this->GetOption($field_required); 493 $$field_message = $this->GetOption($field_message); 526 $custom_fields[ $i ] = (object) array( 527 'Id' => 0, 528 'Name' => $this->GetOption( $field_name ), 529 'Type' => $this->GetOption( $field_type ), 530 'Message' => $this->GetOption( $field_message ), 531 'Required' => $this->GetOption( $field_required ) 532 ); 533 } 534 } else { 535 $custom_fields = $this->redi->getCustomField( self::lang(), $placeID ); 494 536 } 495 537 } … … 740 782 public function shortcode($attributes) 741 783 { 742 //global $locale;743 784 if (is_array($attributes) && is_array($this->options)) { 744 785 $this->options = array_merge($this->options, $attributes); … … 746 787 ob_start(); 747 788 wp_enqueue_script('jquery'); 748 //wp_register_style('jquery_ui', null, array('jquery'));749 789 wp_enqueue_style('jquery_ui'); 750 790 … … 850 890 $maxTime = $this->GetOption('MaxTime', 1); 851 891 $thanks = $this->GetOption('Thanks'); 852 $manualReservation = $this->GetOption( 'ManualReservation');892 $manualReservation = $this->GetOption( 'ManualReservation'); 853 893 $time_format_hours = self::dropdown_time_format(); 854 855 for ($i = 1; $i != CUSTOM_FIELDS; $i++) { 856 $field_name = 'field_' . $i . '_name'; 857 $field_type = 'field_' . $i . '_type'; 858 $field_required = 'field_' . $i . '_required'; 859 $field_message = 'field_' . $i . '_message'; 860 861 if (isset($this->options[$field_name])) { 862 if (isset($this->options[$field_name])) { 863 $$field_name = $this->options[$field_name]; 864 } 865 } 866 867 if (isset($this->options[$field_type])) { 868 $$field_type = $this->options[$field_type]; 869 } 870 871 if (isset($this->options[$field_required])) { 872 $$field_required = $this->options[$field_required]; 873 } 874 875 if (isset($this->options[$field_message])) { 876 $$field_message = $this->options[$field_message]; 877 } 878 } 894 $custom_fields_save_to = $this->GetOption( 'customfields_save_to' ); 895 896 if ($custom_fields_save_to == CustomFieldsSaveTo::WPOptions) { 897 // Get custom fields from wordpress options 898 $custom_fields = array(); 899 for ( $i = 0; $i != CUSTOM_FIELDS; $i ++ ) { 900 $field_name = 'field_' . $i . '_name'; 901 $field_type = 'field_' . $i . '_type'; 902 $field_required = 'field_' . $i . '_required'; 903 $field_message = 'field_' . $i . '_message'; 904 905 $custom_fields[ $i ] = (object) array( 906 'Id' => 0, 907 'Name' => $this->GetOption( $field_name ), 908 'Type' => $this->GetOption( $field_type ), 909 'Message' => $this->GetOption( $field_message ), 910 'Required' => $this->GetOption( $field_required ) 911 ); 912 } 913 } else { 914 $custom_fields = $this->redi->getCustomField( self::lang(), $placeID ); 915 } 916 879 917 $hide_clock = false; 880 918 $persons = 1; … … 1147 1185 $currentTimeISO = date('Y-m-d H:i', current_time('timestamp')); 1148 1186 $comment = ''; 1149 for ( $i = 1; $i != CUSTOM_FIELDS; $i++) {1187 for ( $i = 0; $i != CUSTOM_FIELDS; $i++ ) { 1150 1188 if (isset($_POST['field_' . $i])) { 1151 1189 1152 1190 $field_type = 'field_' . $i . '_type'; 1153 1191 1154 if (isset($this->options[$field_type]) && $this->options[$field_type] === 'checkbox') { 1155 $comment .= $this->options['field_' . $i . '_name'] . ': '; 1156 $comment .= (self::GetPost('field_' . $i) === 'on') ? __('Yes', 1157 'redi-booking') : __('No', 'redi-booking'); 1158 $comment .= '<br/>'; 1159 } else { 1160 if (!empty($_POST['field_' . $i])) { 1161 $comment .= $this->options['field_' . $i . '_name'] . ': '; 1162 $comment .= self::GetPost('field_' . $i) . '<br/>'; 1163 } 1192 if ( isset( $this->options[ $field_type ] )){ 1193 $parameters[] = array( 1194 'Name' => $this->options[ 'field_' . $i . '_name' ], 1195 'Type' => strtolower( $this->options[ $field_type ]), 1196 'Value' => 1197 $this->options[ $field_type ] === 'text' ? 1198 self::GetPost( 'field_' . $i ) : (self::GetPost( 'field_' . $i ) === 'on' ? 'true' : 'false')); 1164 1199 } 1165 1200 } … … 1260 1295 return json_decode(json_encode($object), true); 1261 1296 } 1297 private static function lang(){ 1298 return str_replace( '_', '-', get_locale()); 1299 } 1262 1300 } 1263 1301 } -
redi-restaurant-reservation/branches/newDesign/redi.php
r1586737 r1689142 1 1 <?php 2 3 if (!defined('REDI_BOOKING_DEBUG')) { 4 define( 'REDI_BOOKING_DEBUG', false ); 5 } 6 if (!defined('USER')) { 7 define('USER', 'User.svc/'); 8 } 9 if (!defined('USERGET')) { 10 define('USERGET', 'User.svc/get'); 11 } 12 if (!defined('PLACE')) { // 'Place.svc/place' - for old version 13 define('PLACE', 'Place.svc/'); 14 } 15 if (!defined('SERVICE')) { 16 define('SERVICE', 'Service.svc/'); 17 } 18 if (!defined('CATEGORY')) { 19 define('CATEGORY', 'Category.svc/'); 20 } 21 if (!defined('RESERVATION')) { 22 define ('RESERVATION', 'Reservation.svc/'); 23 } 24 if(!defined('EMAILCONTENT')) { 25 define('EMAILCONTENT','emailcontent.svc/'); 26 } 27 if (!defined('POST')) { 28 define('POST', 'POST'); 29 } 30 if (!defined('GET')) { 31 define('GET', 'GET'); 32 } 33 if (!defined('PUT')) { 34 define('PUT', 'PUT'); 35 } 36 if (!defined('DELETE')) { 37 define('DELETE', 'DELETE'); 38 } 39 if (!defined('REDI_SUCCESS')) { 40 define('REDI_SUCCESS', 'SUCCESS'); 2 if ( ! defined( 'USER' ) ) { 3 define( 'USER', 'User.svc/' ); 4 } 5 if ( ! defined( 'USERGET' ) ) { 6 define( 'USERGET', 'User.svc/get' ); 7 } 8 if ( ! defined( 'PLACE' ) ) { // 'Place.svc/place' - for old version 9 define( 'PLACE', 'Place.svc/' ); 10 } 11 if ( ! defined( 'SERVICE' ) ) { 12 define( 'SERVICE', 'Service.svc/' ); 13 } 14 if ( ! defined( 'CATEGORY' ) ) { 15 define( 'CATEGORY', 'Category.svc/' ); 16 } 17 if ( ! defined( 'RESERVATION' ) ) { 18 define( 'RESERVATION', 'Reservation.svc/' ); 19 } 20 if ( ! defined( 'EMAILCONTENT' ) ) { 21 define( 'EMAILCONTENT', 'emailcontent.svc/' ); 22 } 23 if ( ! defined( 'CUSTOMFIELDS' ) ) { 24 define( 'CUSTOMFIELDS', 'CustomFields.svc/' ); 25 } 26 if ( ! defined( 'POST' ) ) { 27 define( 'POST', 'POST' ); 28 } 29 if ( ! defined( 'GET' ) ) { 30 define( 'GET', 'GET' ); 31 } 32 if ( ! defined( 'PUT' ) ) { 33 define( 'PUT', 'PUT' ); 34 } 35 if ( ! defined( 'DELETE' ) ) { 36 define( 'DELETE', 'DELETE' ); 37 } 38 if ( ! defined( 'REDI_SUCCESS' ) ) { 39 define( 'REDI_SUCCESS', 'SUCCESS' ); 41 40 } 42 41 if ( ! defined( 'REDI_BOOKING_API' ) ) { 43 define( 'REDI_BOOKING_API', 'http://api.reservationdiary.eu/service/');42 define( 'REDI_BOOKING_API', 'http://api.reservationdiary.eu/service/' ); 44 43 } 45 44 46 45 if ( ! defined( 'CUSTOM_FIELDS' ) ) { 47 define('CUSTOM_FIELDS', 6);46 define( 'CUSTOM_FIELDS', 6 ); 48 47 } 49 48 50 49 if ( ! class_exists( 'ReDiBookingApi' ) ) { 51 50 class ReDiBookingApi { 52 private $ApiKey;51 private $ApiKey; 53 52 54 53 public function ReDiBookingApi( $ApiKey ) { 55 $this->ApiKey = $ApiKey; 56 } 57 58 public function getReservationUrl($lang){ 59 return 'http://wp.reservationdiary.eu/' . $lang . '/' . $this->ApiKey . '/Reservation/Index'; 60 } 61 62 public function getEmailContent($reservationID, $type, $params){ 54 $this->ApiKey = $ApiKey; 55 } 56 57 public function deleteCustomField( $lang, $placeID, $customFieldID ) { 58 return $this->request( REDI_BOOKING_API . CUSTOMFIELDS . $lang . '/' . $this->ApiKey . '/place/' . $placeID . '/customfield/' . $customFieldID, DELETE ); 59 } 60 61 public function updateCustomField( $lang, $placeID, $customFieldID, $params ) { 62 return $this->request( REDI_BOOKING_API . CUSTOMFIELDS . $lang . '/' . $this->ApiKey . '/place/' . $placeID . '/customfield/' . $customFieldID, PUT, 63 json_encode( self::unescape_array( $params ) ) ); 64 } 65 66 public function saveCustomField( $lang, $placeID, $params ) { 67 return $this->request( REDI_BOOKING_API . CUSTOMFIELDS . $lang . '/' . $this->ApiKey . '/place/' . $placeID, POST, 68 json_encode( self::unescape_array( $params ) ) ); 69 } 70 71 public function getCustomField( $lang, $placeID ) { 72 return $this->request( REDI_BOOKING_API . CUSTOMFIELDS . $lang . '/' . $this->ApiKey . '/place/' . $placeID, GET ); 73 } 74 75 public function getBlockingDates( $lang, $categoryID, $params ) { 76 return $this->request( REDI_BOOKING_API . DATES . $lang . '/' . $this->ApiKey . '/' . $categoryID, GET, self::strParams( $params ) ); 77 } 78 79 public function getReservationUrl( $lang ) { 80 return 'http://wp.reservationdiary.eu/' . $lang . '/' . $this->ApiKey . '/Reservation/Index'; 81 } 82 83 public function getEmailContent( $reservationID, $type, $params ) { 63 84 return $this->request( REDI_BOOKING_API . EMAILCONTENT . $this->ApiKey . '/' . $reservationID . '/ClientReservation' . $type, 64 85 GET, $params ); 65 }66 67 public function cancelReservationByClient( $params ) {68 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/cancelByClient' . self::strParams( $params ), DELETE );69 }70 71 public function cancelReservation( $params ) {86 } 87 88 public function cancelReservationByClient( $params ) { 89 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/cancelByClient' . self::strParams( $params ), DELETE ); 90 } 91 92 public function cancelReservation( $params ) { 72 93 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/cancelByProvider' . self::strParams( $params ), DELETE ); 73 }94 } 74 95 75 96 public function createReservation( $categoryID, $params ) { 76 97 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/' . $categoryID, POST, 77 98 json_encode( self::unescape_array( $params ) ) ); 78 }99 } 79 100 80 101 public function query( $categoryID, $params ) { 81 102 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/' . $categoryID . '/Person', 82 103 GET, $params ); 83 }104 } 84 105 85 106 public function createCategory( $placeID, $params ) { 86 107 return $this->request( REDI_BOOKING_API . CATEGORY . $this->ApiKey . '/' . $placeID, POST, 87 108 json_encode( self::unescape_array( $params ) ) ); 88 }109 } 89 110 90 111 public function getServices( $categoryID ) { 91 return $this->request(REDI_BOOKING_API.SERVICE.$this->ApiKey.'/'.$categoryID.'/Person', GET);92 }112 return $this->request( REDI_BOOKING_API . SERVICE . $this->ApiKey . '/' . $categoryID . '/Person', GET ); 113 } 93 114 94 115 public function deleteServices( $ids ) { 95 116 return $this->request( REDI_BOOKING_API . SERVICE . $this->ApiKey . '?serviceID=' . join( ',', $ids ), 96 117 DELETE ); 97 }118 } 98 119 99 120 public function setServiceTime( $categoryID, $timeSet ) { 100 return $this->request(REDI_BOOKING_API.CATEGORY.$this->ApiKey.'/'.$categoryID.'/time',101 PUT,102 json_encode(self::unescape_array(array ('timeSet' => $timeSet))));103 }121 return $this->request( REDI_BOOKING_API . CATEGORY . $this->ApiKey . '/' . $categoryID . '/time', 122 PUT, 123 json_encode( self::unescape_array( array( 'timeSet' => $timeSet ) ) ) ); 124 } 104 125 105 126 public function getServiceTime( $categoryID ) { 106 return $this->request(REDI_BOOKING_API.CATEGORY.$this->ApiKey.'/'.$categoryID.'/time', GET);107 }127 return $this->request( REDI_BOOKING_API . CATEGORY . $this->ApiKey . '/' . $categoryID . '/time', GET ); 128 } 108 129 109 130 public function createService( $categoryID, $params ) { 110 131 return $this->request( REDI_BOOKING_API . SERVICE . $this->ApiKey . '/' . $categoryID, POST, 111 132 json_encode( self::unescape_array( $params ) ) ); 112 }133 } 113 134 114 135 public function userGetError() { 115 return $this->request(REDI_BOOKING_API.USERGET);116 }136 return $this->request( REDI_BOOKING_API . USERGET ); 137 } 117 138 118 139 public function createUser( $params ) { 119 return $this->request(REDI_BOOKING_API.USER, POST, json_encode(self::unescape_array($params)));120 }140 return $this->request( REDI_BOOKING_API . USER, POST, json_encode( self::unescape_array( $params ) ) ); 141 } 121 142 122 143 public function setPlace( $placeID, $params ) { 123 144 return $this->request( REDI_BOOKING_API . PLACE . $this->ApiKey . '/' . $placeID, PUT, 124 145 json_encode( self::unescape_array( $params ) ) ); 125 }146 } 126 147 127 148 public function createPlace( $params ) { 128 149 return $this->request( REDI_BOOKING_API . PLACE . $this->ApiKey, POST, 129 150 json_encode( self::unescape_array( $params ) ) ); 130 }151 } 131 152 132 153 public function shiftsStartTime( $categoryID, $params ) { 133 154 return $this->request( REDI_BOOKING_API . CATEGORY . $this->ApiKey . '/' . $categoryID . '/shiftsStartTime', 134 GET, $params );135 }155 GET, $params ); 156 } 136 157 137 158 public function availabilityByDay( $categoryID, $params ) { 138 159 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/' . $categoryID . '/availabilityByDay/Person', 139 160 GET, $params ); 140 }161 } 141 162 142 163 public function availabilityByShifts( $categoryID, $params ) { 143 164 return $this->request( REDI_BOOKING_API . RESERVATION . $this->ApiKey . '/' . $categoryID . '/availabilityByShifts/Person', 144 GET, $params );145 }165 GET, $params ); 166 } 146 167 147 168 public function getPlace( $placeID ) { 148 return $this->request(REDI_BOOKING_API.PLACE.$this->ApiKey.'/'.$placeID, GET);149 }169 return $this->request( REDI_BOOKING_API . PLACE . $this->ApiKey . '/' . $placeID, GET ); 170 } 150 171 151 172 public function getPlaceCategories( $placeID ) { 152 return $this->request(REDI_BOOKING_API.PLACE.$this->ApiKey.'/'.$placeID.'/categories', GET);153 }173 return $this->request( REDI_BOOKING_API . PLACE . $this->ApiKey . '/' . $placeID . '/categories', GET ); 174 } 154 175 155 176 public function getPlaces() { 156 return $this->request(REDI_BOOKING_API.PLACE.$this->ApiKey, GET);157 }177 return $this->request( REDI_BOOKING_API . PLACE . $this->ApiKey, GET ); 178 } 158 179 159 180 public function setApiKey( $ApiKey ) { 160 $this->ApiKey = $ApiKey; 161 } 162 163 private static function unescape_array( $array ) { 164 $unescaped_array = array(); 165 foreach ( $array as $key => $val ) { 166 if ( is_array( $val ) ) { 167 $unescaped_array[$key] = self::unescape_array($val); 168 } else { 169 $unescaped_array[$key] = stripslashes($val); 170 } 171 } 172 return $unescaped_array; 173 } 174 175 private static function strParams( $params ) { 181 $this->ApiKey = $ApiKey; 182 } 183 184 private static function strParams( $params ) { 176 185 $url_param = ''; 177 186 $first = 0; … … 186 195 } 187 196 188 private function request( $url, $method = GET, $params = null ) { 189 $request = new WP_Http; 190 $curTime = microtime( true ); 191 192 $output = $request->request( 193 $url, 194 array( 195 'method' => $method, 196 'body' => $params, 197 'headers' => array( 198 'Content-Type' => 'application/json; charset=utf-8' 199 ) 200 ) ); 201 if ( is_wp_error( $output ) ) { 202 return array( 203 'request_time' => round( microtime( true ) - $curTime, 3 ) * 1000, 197 private static function unescape_array( $array ) { 198 $unescaped_array = array(); 199 foreach ( $array as $key => $val ) { 200 if ( is_array( $val ) ) { 201 $unescaped_array[ $key ] = self::unescape_array( $val ); 202 } else { 203 $unescaped_array[ $key ] = stripslashes( $val ); 204 } 205 } 206 207 return $unescaped_array; 208 } 209 210 211 private function request( $url, $method = GET, $params = null ) { 212 $request = new WP_Http; 213 $curTime = microtime( true ); 214 215 $output = $request->request( 216 $url, 217 array( 218 'method' => $method, 219 'body' => $params, 220 'headers' => array( 221 'Content-Type' => 'application/json; charset=utf-8' 222 ) 223 ) ); 224 if ( is_wp_error( $output ) ) { 225 return array( 226 'request_time' => round( microtime( true ) - $curTime, 3 ) * 1000, 204 227 'Error' => __( 'Online reservation service is not available at this time. Try again later or contact us directly.', 205 228 'redi-booking' ), 206 'Wp-Error' => $output->errors 207 ); 208 } 209 229 'Wp-Error' => $output->errors 230 ); 231 } 210 232 if ( $output['response']['code'] != 200 && $output['response']['code'] != 400 ) { 211 233 return array( … … 214 236 ); 215 237 } 216 $output = $output['body'];217 218 219 // convert response220 $output = (array) json_decode( $output );221 if ( REDI_BOOKING_DEBUG ){222 $output['debug'] = array223 (224 'method' => $method,225 'params' => self::p( $params, true ),226 'url' => self::p( $url ,true )227 );228 }229 230 return $output;231 }232 233 public static function d( $object, $color = true ) {234 if ( REDI_BOOKING_DEBUG ) {235 if ( ! $color ) {236 echo '<pre>';237 var_dump($object);238 echo '<pre>';239 240 return;241 }242 $result = highlight_string( "<?php\n" . print_r( $object, true ), true );238 $output = $output['body']; 239 240 241 // convert response 242 $output = (array) json_decode( $output ); 243 if ( REDI_BOOKING_DEBUG ) { 244 $output['debug'] = array 245 ( 246 'method' => $method, 247 'params' => self::p( $params, true ), 248 'url' => self::p( $url, true ) 249 ); 250 } 251 252 return $output; 253 } 254 255 public static function d( $object, $color = true ) { 256 if ( REDI_BOOKING_DEBUG ) { 257 if ( ! $color ) { 258 echo '<pre>'; 259 var_dump( $object ); 260 echo '<pre>'; 261 262 return; 263 } 264 $result = highlight_string( "<?php\n" . print_r( $object, true ), true ); 243 265 echo '<pre style="text-align: left;">' . preg_replace( '/<\\?php<br \\/>/', '', $result, 244 266 1 ) . '</pre><br />'; 245 } 246 267 } 268 269 } 270 271 public static function p( $object ) { 272 273 if ( REDI_BOOKING_DEBUG ) { 274 return var_export( $object, true ); 275 } 276 } 247 277 } 248 249 public static function p( $object ) { 250 if ( REDI_BOOKING_DEBUG ) { 251 return var_export( $object, true ); 252 } 253 } 254 } 255 } 278 } -
redi-restaurant-reservation/branches/newDesign/templates/admin.php
r1598865 r1689142 235 235 <p class="description"> 236 236 <?php _e('Custom fields are meant to allow users define additional fields for collecting more information from customers. You can choose the name of the field, type of field, the constraint whether it is a required field or not and the error message for the required field.', 'redi-booking') ?><br/> 237 <b style="color: red"><?php _e('NOTE: Name, Email and Phone are required fields of reservation form and do esnot need to be defined here as custom fields.', 'redi-booking') ?></b>237 <b style="color: red"><?php _e('NOTE: Name, Email and Phone are required fields of reservation form and do not need to be defined here as custom fields.', 'redi-booking') ?></b> 238 238 </p> 239 239 240 <table class="form-table" style="width: 80%;">240 <table class="form-table" style="width: 90%; text-align: center;"> 241 241 <thead> 242 242 <tr> … … 261 261 </label> 262 262 </th> 263 <th> 264 265 </th> 263 266 </tr> 264 267 </thead> 265 <?php for($i = 1; $i != CUSTOM_FIELDS; $i++):?> 268 269 <?php for ( $i = 0; $i != CUSTOM_FIELDS; $i++ ): 270 if ( ! isset( $custom_fields[ $i ] ) ) { 271 $custom_fields[ $i ] = (object) array( 272 'Id' => 0, 273 'Name' => '', 274 'Type' => 'text', 275 'Message' => '', 276 'Required' => false 277 ); 278 } 279 $custom_field = $custom_fields[ $i ]; 280 ?> 281 <?php $field_id = ('field_'.$i.'_id');?> 282 266 283 <tr> 267 284 <td> 285 <input type="hidden" id="<?php echo $field_id;?>" name="<?php echo $field_id;?>" value="<?php echo $custom_field->Id ?>" /> 268 286 <?php $field_name=('field_'.$i.'_name'); ?> 269 <input type="text" name="<?php echo $field_name; ?>" value="<?php echo $$field_name; ?>"/>270 </td> 271 <td >287 <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" value="<?php echo $custom_field->Name; ?>"/> 288 </td> 289 <td style="vertical-align: top;"> 272 290 <?php $field_type=('field_'.$i.'_type'); ?> 273 <select name="<?php echo $field_type; ?>">274 <option value="text box" <?php if ($$field_type === 'textbox'):?>selected="selected"<?php endif?>>TextBox</option>275 <option value="checkbox" <?php if ($ $field_type === 'checkbox'):?>selected="selected"<?php endif?>>Checkbox</option>291 <select onchange="set_name('<?php echo $field_name; ?>',this.options[this.selectedIndex].value);" class="field_type" name="<?php echo $field_type; ?>" id="<?php echo $field_type; ?>"> 292 <option value="text" <?php if ($custom_field->Type === 'text'):?>selected="selected"<?php endif?>><?php _e('Text field', 'redi-booking'); ?></option> 293 <option value="checkbox" <?php if ($custom_field->Type === 'checkbox'):?>selected="selected"<?php endif?>><?php _e('Check box', 'redi-booking'); ?></option> 276 294 </select> 277 295 </td> 278 296 <td> 279 297 <?php $field_required=('field_'.$i.'_required'); ?> 280 <input type="checkbox" name="<?php echo $field_required; ?>" <?php if ($$field_required): ?>checked="checked"<?php endif?>>298 <input type="checkbox" id="<?php echo $field_required; ?>" name="<?php echo $field_required; ?>" <?php if ($custom_field->Required): ?>checked="checked"<?php endif?>> 281 299 </td> 282 300 <td> 283 301 <?php $field_message=('field_'.$i.'_message'); ?> 284 <input type="text" name="<?php echo $field_message;?>" value="<?php echo $$field_message; ?>" style="width:300px;"> 302 <input type="text" id="<?php echo $field_message;?>" name="<?php echo $field_message;?>" value="<?php echo $custom_field->Message ?>" style="width:250px;"> 303 </td> 304 <td> 305 <a onclick="jQuery('#<?php echo $field_name; ?>').val(''); jQuery('#<?php echo $field_message; ?>').val(''); jQuery('#<?php echo $field_type; ?>').val('text'); jQuery('#<?php echo $field_required; ?>').attr('checked', false);">clear</a> 285 306 </td> 286 307 </tr> 287 308 <?php endfor; ?> 288 309 </table> 310 <!-- /custom fields--> 289 311 <br/> 290 312 <!-- /custom fields--> -
redi-restaurant-reservation/branches/newDesign/templates/frontend.php
r1653008 r1689142 297 297 <br/> 298 298 <!-- custom fields --> 299 <?php for ( $i = 1; $i != 6; $i ++ ): ?> 300 <?php $field_name = 'field_' . $i . '_name'; ?> 301 <?php $field_required = 'field_' . $i . '_required'; ?> 302 <?php $field_type = 'field_' . $i . '_type'; ?> 303 <?php $field_message = 'field_' . $i . '_message'; ?> 304 <?php if ( isset( $$field_name ) && ! empty( $$field_name ) ): ?> 299 <?php $i = 0; ?> 300 <?php foreach ( $custom_fields as $custom_field ):?> 301 <?php $i++; ?> 302 <?php if(isset($custom_field->Name) && !empty($custom_field->Name)):?> 305 303 <div class="f_select2"> 306 304 <div class="f_input_box"> 307 <span class="selectArrow6 <?php if ( isset( $$field_required ) && $$field_required): ?>required<?php endif; ?>"></span>308 <?php switch ( $$field_type ):309 case 'checkbox':310 ?>305 <span class="selectArrow6 <?php if(isset($custom_field->Required) && $custom_field->Required): ?>required<?php endif; ?>"></span> 306 <?php 307 switch($custom_field->Type): 308 case 'checkbox':?> 311 309 <span class="checkbox_field"> 312 310 <input type="checkbox" value="" name="field_<?php echo $i; ?>" 313 311 id="field_<?php echo $i; ?>" 314 class="<?php if ( isset( $ $field_required ) && $$field_required ): ?>field_required<?php endif; ?>"/>312 class="<?php if ( isset( $custom_field->Required ) && $custom_field->Required ): ?>field_required<?php endif; ?>"/> 315 313 <label for="field_<?php echo $i; ?>"> 316 <?php echo $ $field_name; ?>314 <?php echo $custom_field->Name; ?> 317 315 </label> 318 316 </span> … … 321 319 ?> 322 320 <input type="text" 323 placeholder="<?php echo $ $field_name; ?>" value=""321 placeholder="<?php echo $custom_field->Name; ?>" value="" 324 322 name="field_<?php echo $i; ?>" id="field_<?php echo $i; ?>" 325 class="text_field <?php if ( isset( $ $field_required ) && $$field_required ): ?>field_required<?php endif; ?>"/>323 class="text_field <?php if ( isset( $custom_field->Required ) && $custom_field->Required ): ?>field_required<?php endif; ?>"/> 326 324 <?php break; endswitch; ?> 327 325 </div> 328 326 </div> 329 <?php if ( isset( $ $field_required ) && $$field_required ): ?>327 <?php if ( isset( $custom_field->Required ) && $custom_field->Required ): ?> 330 328 <div id="<?php echo 'field_' . $i . '_message'; ?>" style="display:none; text-align: center;"> 331 329 <span class="validation_error"> 332 <?php echo ( ! empty( $ $field_message ) ) ? $$field_message : ( _e( 'Custom field is required', 'redi-booking' ) ); ?>330 <?php echo ( ! empty( $custom_field->Message ) ) ? $custom_field->Message : ( _e( 'Custom field is required', 'redi-booking' ) ); ?> 333 331 </span> 334 332 </div> … … 337 335 <br/> 338 336 <?php endif; ?> 339 <?php endfor ; ?>337 <?php endforeach; ?> 340 338 <!-- /custom fields --> 341 339 <br/>
Note: See TracChangeset
for help on using the changeset viewer.