function open_csa_wp_show_order_form($user_id, $spot_id, $delivery_id, $display, $page_url, $personal_order)
{
    wp_enqueue_script('open-csa-wp-general-scripts');
    wp_enqueue_script('open-csa-wp-orders-scripts');
    wp_enqueue_script('jquery.cluetip');
    wp_enqueue_style('jquery.cluetip.style');
    global $wpdb;
    if ($spot_id != null) {
        $spot_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . OPEN_CSA_WP_TABLE_SPOTS . " WHERE id=%d", $spot_id))[0];
    }
    $edit_order_bool = false;
    $header_text = __("Submit New Order", OPEN_CSA_WP_DOMAIN);
    if (isset($_POST["open-csa-wp-showEditableUserOrderForm_user_input"]) or $user_id != null && $delivery_id != null && open_csa_wp_user_order_exists_for_delivery($user_id, $delivery_id) === true) {
        $edit_order_bool = true;
        $header_text = __("Edit Order", OPEN_CSA_WP_DOMAIN);
    }
    ?>

	<br/>

	<div id="open-csa-wp-showNewOrderForm_formHeader">
		<span 
			id="open-csa-wp-showNewOrderForm_formHeader_text"
			style="cursor:pointer"
			onclick="open_csa_wp_toggle_form('showNewOrderForm','<?php 
    echo $header_text;
    ?>
', ' <?php 
    _e('form', OPEN_CSA_WP_DOMAIN);
    ?>
');"
		>
		<?php 
    if ($display === false) {
        echo "<font size=4> {$header_text} (" . __("show form", OPEN_CSA_WP_DOMAIN) . ") </font>";
    } else {
        echo "<font size=4> {$header_text} (" . __("hide form", OPEN_CSA_WP_DOMAIN) . ") </font>";
    }
    ?>
		</span>
	</div>
	<div 
		id="open-csa-wp-showNewOrderForm_div" 
		<?php 
    if ($display === false) {
        echo 'style="display:none"';
    }
    ?>
	
	>
		<form method="POST" id="open-csa-wp-showNewOrderForm_form_id">
			<table class="form-table">
				<tr valign="top" 
					<?php 
    if ($personal_order === true) {
        echo "style='display:none'";
    }
    ?>
				>
					<td id = "open-csa-wp-showNewOrderForm_user_input_td_id">
						<select
							name = 'open-csa-wp-showNewOrderForm_user_input'
							onchange = 'getElementById ("open-csa-wp-showNewOrderForm_form_id").submit()'
						>
							<option
								value=""
								selected="selected"
								disabled="disabled"
							> <?php 
    _e('Select the user submitting the order', OPEN_CSA_WP_DOMAIN);
    ?>
 ...
							</option>
							<?php 
    open_csa_wp_select_users($user_id, __('for user', OPEN_CSA_WP_DOMAIN) . ": ");
    ?>
						</select>
					</td>
				</tr>
				
				<tr valign="top"
				<?php 
    if ($user_id == null) {
        echo "style = 'display:none'";
    }
    ?>
				>
				<td>
					<select
						name = 'open-csa-wp-showSelectSpotForm_spot_input'
						onchange = 'getElementById("open-csa-wp-showNewOrderForm_form_id").submit();'
					>
						<option 
							value="" 
							selected="selected" 
							disabled="disabled"
						> 
						<?php 
    if ($personal_order === false) {
        _e("now, select the delivery spot ...", OPEN_CSA_WP_DOMAIN);
    } else {
        _e("select the delivery spot ...", OPEN_CSA_WP_DOMAIN);
    }
    ?>
						
						</option>
						<?php 
    open_csa_wp_select_delivery_spots($spot_id, __("on delivery spot", OPEN_CSA_WP_DOMAIN) . ": ");
    ?>
					</select>
				</td>
				</tr>
				
				<tr valign = "top"
				<?php 
    if ($spot_id == null) {
        echo "style = 'display:none'";
    }
    ?>
				><td>
				
				
				
				<div id="open-csa-wp-showNewOrderForm_spotDetails_formHeader">
					<span 
						id="open-csa-wp-showNewOrderForm_spotDetails_formHeader_text"
						style="cursor:pointer"
						onclick="open_csa_wp_toggle_form('showNewOrderForm_spotDetails','<?php 
    _e('spot details', OPEN_CSA_WP_DOMAIN);
    ?>
...', '', 2);"
					><font size=2> <?php 
    echo __('spot details', OPEN_CSA_WP_DOMAIN) . "... (" . __('show', OPEN_CSA_WP_DOMAIN) . ")";
    ?>
 </font>
					</span>
				</div>
				<div 
					id="open-csa-wp-showNewOrderForm_spotDetails_div" 
					style="display:none"
				>
				
				<?php 
    if ($spot_id != null) {
        echo "\n\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr valign='top'><td>\n\t\t\t\t\t\t\t\t<input \n\t\t\t\t\t\t\t\t\ttype='text' \n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\tvalue='" . $spot_info->street_name . "'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<input \n\t\t\t\t\t\t\t\t\ttype='text' \n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\tvalue='" . $spot_info->street_number . "'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t\t\t<tr valign='top'><td>\n\t\t\t\t\t\t\t\t<input \n\t\t\t\t\t\t\t\t\ttype='text' \n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\tvalue='" . $spot_info->city . "'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<input \n\t\t\t\t\t\t\t\t\ttype='text' \n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\tvalue='" . $spot_info->region . "'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t\t\t<tr valign='top'><td>\n\t\t\t\t\t\t\t\t<textarea \n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\trows='3' \n\t\t\t\t\t\t\t\t\tcols='30' >" . $spot_info->description . "</textarea>\n\t\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<tr valign='top'><td>\n\t\t\t\t\t\t\t\t<input \n\t\t\t\t\t\t\t\t\ttype='text'\n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\tvalue='parking is " . $spot_info->parking . "'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</td></tr>\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<tr valign='top'><td>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\ttype='text'\n\t\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:#999'\n\t\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\t\tvalue='" . ($spot_info->has_refrigerator == 1 ? __('It has refrigerator to store products', OPEN_CSA_WP_DOMAIN) . "! :) " : __('It does not have refrigerator to store products', OPEN_CSA_WP_DOMAIN) . "! :(") . "'\n\t\t\t\t\t\t\t\t\tsize = '40px'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</td></tr>\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t";
    }
    ?>
				</div></td></tr>
				
				
				<tr valign = "top" 
				<?php 
    if ($spot_id == null) {
        echo "style = 'display:none'";
    }
    ?>
				>
				<td id = "open-csa-wp-showSelectSpotForm_delivery_input_td_id">
					<?php 
    if (open_csa_wp_active_deliveries_exist_for_spot($spot_id) == true) {
        ?>
						<select
							name = 'open-csa-wp-showSelectSpotForm_delivery_input'
							onchange = 'getElementById("open-csa-wp-showNewOrderForm_form_id").submit();'
						>
							<option 
								value="" 
								selected="selected" 
								disabled="disabled"
							> <?php 
        _e('now, select one of the active deliveries', OPEN_CSA_WP_DOMAIN);
        ?>
 ...
							</option>
							<?php 
        if ($spot_id != null) {
            open_csa_wp_select_deliveries($spot_id, $delivery_id, __('for delivery with', OPEN_CSA_WP_DOMAIN) . ": ");
        }
        ?>
						</select>
					<?php 
    } else {
        $value_of_read_only_input = __("currently, this delivery spot has no active deliveries", OPEN_CSA_WP_DOMAIN);
        $value_of_read_only_input_len = strlen($value_of_read_only_input);
        $size_of_read_only_input = $value_of_read_only_input_len + 1 . '"px\\"';
        echo "\n\t\t\t\t\t\t\t<input \n\t\t\t\t\t\t\t\ttype='text' \n\t\t\t\t\t\t\t\tstyle='border:none; background-color:white; color:brown'\n\t\t\t\t\t\t\t\treadonly='readonly'\n\t\t\t\t\t\t\t\tvalue = '{$value_of_read_only_input}'\n\t\t\t\t\t\t\t\tsize = '{$size_of_read_only_input}'\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t";
    }
    ?>
				</td>
			</tr>
			</table>	
		</form>
	</div>
<?php 
    if ($edit_order_bool === true) {
        open_csa_wp_show_editable_user_order($user_id, $delivery_id, true, $page_url);
    } else {
        if ($delivery_id != null) {
            open_csa_wp_show_new_order_user_form($delivery_id, $user_id, false, $page_url);
        }
    }
    if ($edit_order_bool === false && $user_id != null && $delivery_id == null && ($personal_order === false || $spot_id != null)) {
        ?>
		<input 
		type="button"
		class="button button-secondary"
		value='cancel'
		onclick='window.location.replace(" <?php 
        echo $page_url;
        ?>
 ");'
		/>	
		<?php 
    }
}
Ejemplo n.º 2
0
function open_csa_wp_spot_form($spot_id, $display)
{
    wp_enqueue_script('open-csa-wp-general-scripts');
    wp_enqueue_script('open-csa-wp-spots-scripts');
    wp_enqueue_script('jquery.cluetip');
    wp_enqueue_style('jquery.cluetip.style');
    global $days_of_week, $wpdb;
    $spot_info;
    if ($spot_id != null) {
        $spot_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . OPEN_CSA_WP_TABLE_SPOTS . " WHERE id=%d", $spot_id));
    }
    ?>
	
	<br />
	<div id="open-csa-wp-showNewSpot_formHeader">
		<span 	
			id="open-csa-wp-showNewSpot_formHeader_text" 
			<?php 
    if ($spot_id == null) {
        echo 'style="cursor:pointer"';
        echo 'onclick="open_csa_wp_toggle_form(\'showNewSpot\',\'' . __('Add New Spot', OPEN_CSA_WP_DOMAIN) . '\', \' ' . __('form', OPEN_CSA_WP_DOMAIN) . '\')"';
    }
    ?>
>
			<font size='4'>
			<?php 
    if ($spot_id == null) {
        if ($display == false) {
            _e('Add New Spot (show form)', OPEN_CSA_WP_DOMAIN);
        } else {
            _e('Add New Spot (hide form)', OPEN_CSA_WP_DOMAIN);
        }
    } else {
        echo __('Edit Spot #', OPEN_CSA_WP_DOMAIN) . $spot_id;
    }
    ?>
		</font></span></div>
	<div id="open-csa-wp-showNewSpot_div" 
		<?php 
    if ($display == false) {
        echo "style='display:none'";
    }
    ?>
>
		<form method="POST" id="open-csa-wp-showNewSpot_form">
			<table class="form-table">
				<tr valign="top"><td>
					<input type="text" 
						<?php 
    if ($spot_id != null && $spot_info[0]->spot_name != "" && $spot_info[0]->spot_name != null) {
        echo "value='" . $spot_info[0]->spot_name . "'";
    }
    echo "placeholder=\"" . __('Spot Name *', OPEN_CSA_WP_DOMAIN) . "\"";
    ?>
						required 
						name="open-csa-wp-spots_spot_name_input" 
						onchange="open_csa_wp_request_spot_name_validity(this.value, <?php 
    echo $spot_id != null ? $spot_id : "null";
    ?>
 , 0, null)">
					<span id="open-csa-wp-showNewSpot_name_span_id" style="display:none"></span></td></tr>
				<tr valign="top"><td>
					<input 
						type="text" 
						<?php 
    if ($spot_id != null && $spot_info[0]->street_name != "" && $spot_info[0]->street_name != null) {
        echo "value='" . $spot_info[0]->street_name . "'";
    }
    echo "placeholder=\"" . __('Street Name *', OPEN_CSA_WP_DOMAIN) . "\"";
    ?>
						required 
						name="open-csa-wp-spots_street_name_input">
					<input 
						type="text" 
						<?php 
    if ($spot_id != null && $spot_info[0]->street_number != "" && $spot_info[0]->street_number != null) {
        echo "value='" . $spot_info[0]->street_number . "'";
    }
    echo "placeholder=\"" . __('Street Number *', OPEN_CSA_WP_DOMAIN) . "\"";
    ?>
						required 
						name="open-csa-wp-spots_street_number_input"></td></tr>
				<tr valign="top"><td>
					<input 
						type="text" 
						<?php 
    if ($spot_id != null && $spot_info[0]->city != "" && $spot_info[0]->city != null) {
        echo "value='" . $spot_info[0]->city . "'";
    }
    echo "placeholder=\"" . __('City *', OPEN_CSA_WP_DOMAIN) . "\"";
    ?>
						required 
						name="open-csa-wp-spots_city_input">
					<input 
						type="text" 
						<?php 
    if ($spot_id != null && $spot_info[0]->region != "" && $spot_info[0]->region != null) {
        echo "value='" . $spot_info[0]->region . "'";
    }
    echo "placeholder=\"" . __('Region *', OPEN_CSA_WP_DOMAIN) . "\"";
    ?>
						required 
						name="open-csa-wp-spots_region_input"></td></tr>
				<tr valign="top"><td>
					<textarea name="open-csa-wp-spots_description_input" rows="3" cols="30" 
						<?php 
    _e('placeholder="Description"', OPEN_CSA_WP_DOMAIN);
    ?>
						><?php 
    if ($spot_id != null) {
        echo $spot_info[0]->description;
    }
    ?>
</textarea></td></tr>
				
				<tr valign="top"><td>
					<select name="open-csa-wp-spots_is_delivery_spot_input" id="open-csa-wp-spots_is_delivery_spot_input_id"  onchange='open_csa_wp_show_new_spot_is_delivery_selection(this,<?php 
    echo $spot_id ? $spot_id : "null";
    ?>
)'
					<?php 
    if ($spot_id == null) {
        echo "style='color:#999'";
    }
    ?>
>
						<?php 
    if ($spot_id != null) {
        echo '
								<option value="" style="color:#999" disabled="disabled">Is this a delivery spot? *</option>
								<option value="yes" style="color:black". ' . ($spot_info[0]->is_delivery_spot == 1 ? "selected='selected'> it is a delivery spot" : ">yes") . ' </option>
								<option value="no" style="color:black"' . ($spot_info[0]->is_delivery_spot == 0 ? "selected='selected'> it is not a delivery spot" : ">no") . ' </option>
								';
    } else {
        ?>
							<option value="" selected="selected" disabled="disabled">Is this a delivery spot? *</option>
							<option value="yes" style="color:black"><?php 
        _e('yes', OPEN_CSA_WP_DOMAIN);
        ?>
</option>
							<option value="no" style="color:black"><?php 
        _e('no', OPEN_CSA_WP_DOMAIN);
        ?>
</option>
						<?php 
    }
    ?>
					</select> 
					<span id="open-csa-wp-showNewSpotForm_deliverySpot_span"></span>
				
				</td></tr>				
				
			</table> 
			<div id = "open-csa-wp-spots_deliverySpot_div" 
				<?php 
    $is_delivery_spot = $spot_id != null && $spot_info[0]->is_delivery_spot == 1 ? 1 : 0;
    if ($is_delivery_spot) {
        "style='display:block'";
    } else {
        echo "style='display:none'";
    }
    ?>
>
				<table class="form-table">		
				
				<tr valign="top"><td>
					<select 
						name="open-csa-wp-delivery_spot_owner_input" 
						id="open-csa-wp-delivery_spot_owner_input_id"
						<?php 
    if (!$is_delivery_spot) {
        echo "style='color:#999'";
    }
    ?>
						
						onfocus='getElementById("open-csa-wp-delivery_spot_owner_span_id").style.display = "none";'
						onchange='
							if (this.options[this.selectedIndex].text.split(" ")[0] != "<?php 
    _e('The owner of this delivery spot is', OPEN_CSA_WP_DOMAIN);
    ?>
".split(" ")[0]) 
								this.options[this.selectedIndex].text = "<?php 
    _e('The owner of this delivery spot is', OPEN_CSA_WP_DOMAIN);
    ?>
: "+ this.options[this.selectedIndex].text;
							(this.style.color=this.options[this.selectedIndex].style.color);'
					>
						<option value="" 
							<?php 
    if (!$is_delivery_spot) {
        echo "selected='selected'";
    }
    ?>
 
							disabled="disabled" id="open-csa-wp-delivery_spot_owner_disabled_id"><?php 
    _e('Owner of this delivery spot... *', OPEN_CSA_WP_DOMAIN);
    ?>
						</option>
						<?php 
    $spot_owner_id = null;
    if ($is_delivery_spot) {
        $spot_owner_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM " . OPEN_CSA_WP_TABLE_SPOTS_TO_USERS . " WHERE spot_id=%d AND type='delivery' ", $spot_id), 0, 0);
    }
    open_csa_wp_select_users($spot_owner_id, __("The owner of this delivery spot is: ", OPEN_CSA_WP_DOMAIN));
    ?>
					</select> 
					<span style="display:none;color:blue" id="open-csa-wp-delivery_spot_owner_span_id"></span>
				</td></tr>
			
				<tr valign="top"><td>
					<select 
						name="open-csa-wp-spots_order_deadline_day_input"
						id='open-csa-wp-spots_order_deadline_day_input_id'
						onfocus='document.getElementById("open-csa-wp-showNewSpotForm_orderDeadline_span").style.display = "none";'
						onchange='
							this.style.color="black";
							if (this.options[this.selectedIndex].text.split(" ")[0] != "<?php 
    _e('Order deadline is on', OPEN_CSA_WP_DOMAIN);
    ?>
".split(" ")[0])
								this.options[this.selectedIndex].text = "<?php 
    _e('Order deadline is on', OPEN_CSA_WP_DOMAIN);
    ?>
: " + this.options[this.selectedIndex].text;
							getElementById("open-csa-wp-spots_order_deadline_time_input_id").style.display = "inline"
							'
						<?php 
    if (!$is_delivery_spot) {
        echo "style='color:#999'";
    }
    ?>
					>
					<option value="" 
						<?php 
    if (!$is_delivery_spot) {
        echo "selected='selected'";
    }
    ?>
						disabled="disabled" id="open-csa-wp-spots_order_deadline_day_disabled_id"><?php 
    _e('Order deadline day... *', OPEN_CSA_WP_DOMAIN);
    ?>
 </option>
					<?php 
    for ($i = 0; $i < 7; $i++) {
        if ($is_delivery_spot && $spot_info[0]->default_order_deadline_day == $i) {
            echo "<option value='{$i}' selected='selected' style='color:black'>" . __('Order deadline is on ', OPEN_CSA_WP_DOMAIN) . " {$days_of_week[$i]} </option>";
        } else {
            echo "<option value='{$i}' style='color:black'>" . $days_of_week[$i] . "</option>";
        }
    }
    ?>
					</select> 	
					<input 
						<?php 
    if ($is_delivery_spot && $spot_info[0]->default_order_deadline_time != "" && $spot_info[0]->default_order_deadline_time != null) {
        echo "value='" . __('up to', OPEN_CSA_WP_DOMAIN) . " " . open_csa_wp_remove_seconds($spot_info[0]->default_order_deadline_time) . "'";
    }
    if (!$is_delivery_spot) {
        echo "style='display:none'";
    }
    echo "placeholder=\"" . __('up to', OPEN_CSA_WP_DOMAIN) . "... *\"";
    ?>
						id="open-csa-wp-spots_order_deadline_time_input_id"
						class="textbox-n" type="text" size="10" name="open-csa-wp-spots_order_deadline_time_input"
						onfocus='
							if (this.value != "") {
								this.value=this.value.split(" ")[2];
							} else {
								getElementById("open-csa-wp-showNewSpotForm_orderDeadline_span").style.display = "none";
							}
							this.type="time";'
						onblur='
							this.type="text";
							if (this.value != "") {
								this.style.color="black";
								this.value = "<?php 
    _e('up to', OPEN_CSA_WP_DOMAIN);
    ?>
 " + this.value;
							}'>
					<span id="open-csa-wp-showNewSpotForm_orderDeadline_span" style="display:none"></span>
				</td></tr>
								
				<tr valign="top"><td>
					<select 
						name="open-csa-wp-spots_delivery_day_input" 
						id="open-csa-wp-spots_delivery_day_input_id"
						onfocus='getElementById("open-csa-wp-showNewSpotForm_invalidDeliveryTime_span").innerHTML = "";'
						onchange='
							this.style.color="black";
							if (this.options[this.selectedIndex].text.split(" ")[0] != "<?php 
    _e('Delivery day is', OPEN_CSA_WP_DOMAIN);
    ?>
".split(" ")[0]) {
								this.options[this.selectedIndex].text = "<?php 
    _e('Delivery day is', OPEN_CSA_WP_DOMAIN);
    ?>
 " + this.options[this.selectedIndex].text;
							}
							
							getElementById("open-csa-wp-showNewSpotForm_delivery_start_time_input_id").style.display = "inline"
							getElementById("open-csa-wp-showNewSpotForm_delivery_end_time_input_id").style.display = "inline";
						'
						<?php 
    if (!$is_delivery_spot) {
        echo "style='color:#999'";
    }
    ?>
>
					<option value="" disabled="disabled" 
						<?php 
    if (!$is_delivery_spot) {
        echo "selected='selected'";
    }
    ?>
						id="open-csa-wp-spots_delivery_day_disabled_id"><?php 
    _e('Delivery day', OPEN_CSA_WP_DOMAIN);
    ?>
... *</option>
					<?php 
    for ($i = 0; $i < 7; $i++) {
        if ($is_delivery_spot && $spot_info[0]->default_delivery_day == $i) {
            echo "<option value='{$i}' selected='selected'>" . __('Delivery day is', OPEN_CSA_WP_DOMAIN) . " {$days_of_week[$i]} </option>";
        } else {
            echo "<option value='{$i}'>" . $days_of_week[$i] . "</option>";
        }
    }
    ?>
					</select> 
					<input id="open-csa-wp-showNewSpotForm_delivery_start_time_input_id"
						<?php 
    if ($is_delivery_spot && $spot_info[0]->default_delivery_start_time != "" && $spot_info[0]->default_delivery_start_time != null) {
        echo "value='" . __('from', OPEN_CSA_WP_DOMAIN) . " " . open_csa_wp_remove_seconds($spot_info[0]->default_delivery_start_time) . "'";
    }
    if (!$is_delivery_spot) {
        echo "style='display:none'";
    }
    echo "placeholder=\"" . __('from', OPEN_CSA_WP_DOMAIN) . "... *\"";
    ?>
						class="textbox-n" type="text" size="10" name="open-csa-wp-spots_delivery_start_time_input"

						onfocus='
							if (this.value != "") {
								this.value=this.value.split(" ")[1];
							} else {
								getElementById("open-csa-wp-showNewSpotForm_invalidDeliveryTime_span").style.display = "none";
							}
							this.type="time";'
						onblur='
							this.type="text";
							if (this.value == "") {
								getElementById("open-csa-wp-showNewSpotForm_delivery_end_time_input_id").value = "";
							}
							else {
								this.style.color="black";
								this.value = "<?php 
    _e('from', OPEN_CSA_WP_DOMAIN);
    ?>
 " + this.value;
								open_csa_wp_validate_delivery_time_period("showNewSpotForm");
							}'>
					<input id="open-csa-wp-showNewSpotForm_delivery_end_time_input_id"
						<?php 
    if ($is_delivery_spot && $spot_info[0]->default_delivery_end_time != "" && $spot_info[0]->default_delivery_end_time != null) {
        echo "value='" . __('to', OPEN_CSA_WP_DOMAIN) . " " . open_csa_wp_remove_seconds($spot_info[0]->default_delivery_end_time) . "'";
    }
    if (!$is_delivery_spot) {
        echo "style='display:none'";
    }
    echo "placeholder=\"" . __('to', OPEN_CSA_WP_DOMAIN) . "... *\"";
    ?>
						class="textbox-n" type="text" size="10" name="open-csa-wp-spots_delivery_end_time_input"
						
						onfocus='
							if (this.value != "") { 
								this.value=this.value.split(" ")[1];
							}
							getElementById("open-csa-wp-showNewSpotForm_invalidDeliveryTime_span").style.display = "none";
							this.type="time";'
						onblur='
							this.type="text";
							if (this.value != "") {
								this.style.color="black";
								this.value = "<?php 
    _e('to', OPEN_CSA_WP_DOMAIN);
    ?>
 " + this.value;
								open_csa_wp_validate_delivery_time_period("showNewSpotForm");
							}
						'>
					<span id="open-csa-wp-showNewSpotForm_invalidDeliveryTime_span"> </span>
				</td></tr>
			
				<tr valign="top"><td>
				<select 
					name="open-csa-wp-spots_close_input" 
					id="open-csa-wp-spots_close_input_id"
					<?php 
    if (!$is_delivery_spot) {
        echo "style='color:#999'";
    }
    ?>
					onfocus='getElementById("open-csa-wp-showNewSpotForm_ordersClose_span_id").innerHTML = "";'
					onchange='
						this.style.color="black";
						if (this.options[this.selectedIndex].text.split(" ")[0] != "<?php 
    _e('Order close', OPEN_CSA_WP_DOMAIN);
    ?>
".split(" ")[0]) {
							this.options[this.selectedIndex].text = "<?php 
    _e('Order close', OPEN_CSA_WP_DOMAIN);
    ?>
 "+this.options[this.selectedIndex].text;
						}
						getElementById("open-csa-wp-spots_close_"+ this.options[this.selectedIndex].value).style.display= "inline";
						getElementById("open-csa-wp-spots_close_"+ this.options[((this.selectedIndex-1)+1)%2+1].value).style.display="none"'>
					<option value="" 
						<?php 
    if (!$is_delivery_spot) {
        echo "selected='selected'";
    }
    ?>
 
						disabled="disabled" id="open-csa-wp-spots_close_disabled_id"><?php 
    _e('Order close', OPEN_CSA_WP_DOMAIN);
    ?>
... *</option>
					<option value="automatic" 
						<?php 
    if ($is_delivery_spot && $spot_info[0]->close_order == "automatic") {
        echo "selected='selected'";
    }
    ?>
 
						title="<?php 
    _e("Orders' submission will be closed automatically when order submission deadline is reached", OPEN_CSA_WP_DOMAIN);
    ?>
">
						<?php 
    if ($is_delivery_spot && $spot_info[0]->close_order == "automatic") {
        echo __('Order close', OPEN_CSA_WP_DOMAIN) . " ";
    }
    ?>
						automatically</option>
					<option value="manual" 
						<?php 
    if ($is_delivery_spot && $spot_info[0]->close_order == "manual") {
        echo "selected='selected'";
    }
    ?>
 
						title="<?php 
    _e("Orders' submission will be closed manually by the user that is responsible for the delivery", OPEN_CSA_WP_DOMAIN);
    ?>
">
						<?php 
    if ($is_delivery_spot && $spot_info[0]->close_order == "manual") {
        echo __('Order close', OPEN_CSA_WP_DOMAIN) . " ";
    }
    ?>
						manually</option>
				</select>
				<span 
					<?php 
    if (!$is_delivery_spot || $spot_info[0]->close_order != "automatic") {
        echo "style='display:none;color:gray'";
    } else {
        echo "style='color:gray'";
    }
    ?>
 
					id="open-csa-wp-spots_close_automatic" 
					class="open-csa-wp-tip_spots"
					title="<?php 
    _e("Orders' submission will be closed automatically when order submission deadline is reached", OPEN_CSA_WP_DOMAIN);
    ?>
"
				>&nbsp;i.e. ... (point here)</span>
				<span 
					<?php 
    if (!$is_delivery_spot || $spot_info[0]->close_order != "manual") {
        echo "style='display:none;color:gray'";
    } else {
        echo "style='color:gray'";
    }
    ?>
 
					id="open-csa-wp-spots_close_manual"
					class="open-csa-wp-tip_spots"
					title="<?php 
    _e("Orders' submission will be closed manually by the user that is responsible for the delivery", OPEN_CSA_WP_DOMAIN);
    ?>
"
				>&nbsp;i.e. ... (point here)</span>
				<span id="open-csa-wp-showNewSpotForm_ordersClose_span_id"></span>
				</td></tr>

				<tr valign="top"><td>
					<select 
						name="open-csa-wp-spots_parking_input" 
						id="open-csa-wp-spots_parking_input_id"
						<?php 
    $styleAttributes = "style='color:";
    if (!$is_delivery_spot || $spot_info[0]->parking == "") {
        $styleAttributes = $styleAttributes . "#999'";
    } else {
        if ($spot_info[0]->parking == "easy") {
            $styleAttributes = $styleAttributes . "blue'";
        } else {
            if ($spot_info[0]->parking == "possible") {
                $styleAttributes = $styleAttributes . "green'";
            } else {
                if ($spot_info[0]->parking == "hard") {
                    $styleAttributes = $styleAttributes . "orange'";
                } else {
                    if ($spot_info[0]->parking == "impossible") {
                        $styleAttributes = $styleAttributes . "brown'";
                    }
                }
            }
        }
    }
    echo $styleAttributes;
    ?>
						
						onfocus='getElementById("open-csa-wp-showNewSpotForm_parkingSpace_span_id").style.display = "none";'
						onchange='
							this.style.color=this.options[this.selectedIndex].style.color;
							if (this.options[this.selectedIndex].text.split(" ")[0] != "Finding") {
								this.options[this.selectedIndex].text = "Finding parking space is " + this.options[this.selectedIndex].text;
							}'
					>
						<option value="" 
						<?php 
    if (!$is_delivery_spot || $spot_info[0]->parking == "") {
        echo "selected='selected'";
    }
    ?>
 
							disabled="disabled" id="open-csa-wp-spots_parking_disabled_id"><?php 
    _e("Finding parking space is", OPEN_CSA_WP_DOMAIN);
    ?>
...</option>
						<option value="easy" 
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "easy") {
        echo "selected='selected'";
    }
    ?>
 
							style="color:blue">
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "easy") {
        echo __('Finding parking space is', OPEN_CSA_WP_DOMAIN) . " ";
    }
    ?>
							easy :)</option>
						<option value="possible" 
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "possible") {
        echo "selected='selected'";
    }
    ?>
 
							style="color:green">
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "possible") {
        echo __('Finding parking space is', OPEN_CSA_WP_DOMAIN) . " ";
    }
    ?>
							possible :)</option>
						<option value="hard" 
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "hard") {
        echo "selected='selected'";
    }
    ?>
 
							style="color:orange">
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "hard") {
        echo __('Finding parking space is', OPEN_CSA_WP_DOMAIN) . " ";
    }
    ?>
							hard :(</option>
						<option value="impossible" 
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "impossible") {
        echo "selected='selected'";
    }
    ?>
 
							style="color:brown">
							<?php 
    if ($is_delivery_spot && $spot_info[0]->parking != "" && $spot_info[0]->parking == "impossible") {
        echo __('Finding parking space is', OPEN_CSA_WP_DOMAIN) . " ";
    }
    ?>
							impossible :(</option>
					</select>
					<span style="display:none;color:blue" id="open-csa-wp-showNewSpotForm_parkingSpace_span_id"></span>
				</td></tr>
				<tr valign="top"><td>
					<select 
						name="open-csa-wp-spots_refrigerator_input" 
						id="open-csa-wp-spots_refrigerator_input_id"
						<?php 
    $styleAttributes = "style='color:";
    if (!$is_delivery_spot || $spot_info[0]->has_refrigerator == "") {
        $styleAttributes = $styleAttributes . "#999'";
    } else {
        if ($spot_info[0]->has_refrigerator == "1") {
            $styleAttributes = $styleAttributes . "green'";
        } else {
            if ($spot_info[0]->has_refrigerator == "0") {
                $styleAttributes = $styleAttributes . "brown'";
            }
        }
    }
    echo $styleAttributes;
    ?>
						
						onfocus='getElementById("open-csa-wp-showNewSpotForm_hasRefrigerator_span_id").style.display = "none";'
						onchange='
							(this.style.color=this.options[this.selectedIndex].style.color);
							if (this.options[this.selectedIndex].value == "yes") {
								this.options[this.selectedIndex].text = "<?php 
    _e('It has refrigerator to store products', OPEN_CSA_WP_DOMAIN);
    ?>
! :)";
							}
							else {
								this.options[this.selectedIndex].text = "<?php 
    _e('It does not have refrigerator to store products', OPEN_CSA_WP_DOMAIN);
    ?>
! :("
							}'
					>
						<option value="" 
							<?php 
    if (!$is_delivery_spot || $spot_info[0]->has_refrigerator == "") {
        echo "selected='selected'";
    }
    ?>
 
							disabled="disabled" id="open-csa-wp-spots_refrigerator_disabled_id"><?php 
    _e('Does it have refrigerator to store products', OPEN_CSA_WP_DOMAIN);
    ?>
...?</option>
						<option value="yes" style="color:green"
							<?php 
    if ($is_delivery_spot && $spot_info[0]->has_refrigerator != "" && $spot_info[0]->has_refrigerator == "1") {
        echo "selected='selected'";
    }
    ?>
 
							>
							<?php 
    if ($is_delivery_spot && $spot_info[0]->has_refrigerator != "" && $spot_info[0]->has_refrigerator == "1") {
        echo __('It has refrigerator to store products', OPEN_CSA_WP_DOMAIN) . "! :) ";
    } else {
        echo __("yes", OPEN_CSA_WP_DOMAIN);
    }
    ?>
 </option>
						<option value="no" style="color:brown"
							<?php 
    if ($is_delivery_spot && $spot_info[0]->has_refrigerator != "" && $spot_info[0]->has_refrigerator == "0") {
        echo "selected='selected'";
    }
    ?>
 
							>
							<?php 
    if ($is_delivery_spot && $spot_info[0]->has_refrigerator != "" && $spot_info[0]->has_refrigerator == "0") {
        echo _e('It does not have refrigerator to store products', OPEN_CSA_WP_DOMAIN) . "! :( ";
    } else {
        echo __("no", OPEN_CSA_WP_DOMAIN);
    }
    ?>
</option>
					</select> 
					<span style="display:none;color:blue" id="open-csa-wp-showNewSpotForm_hasRefrigerator_span_id"></span>
				</td></tr>
				
			</table> 
			</div>
			<input 
				type="submit" 
				name="open-csa-wp-showNewSpot_button" 
				id="open-csa-wp-showNewSpot_button_id"
				<?php 
    if ($spot_id == null) {
        echo "\n\t\t\t\t\t\t\tvalue='" . __('Add Spot', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\t\t\tonclick='open_csa_wp_new_spot_fields_validation(this, null, \"" . admin_url("/admin.php?page=csa_spots_management") . "\")'\n\t\t\t\t\t\t";
    } else {
        echo "\n\t\t\t\t\t\t\tvalue='" . __('Update Spot', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\t\t\tonclick='open_csa_wp_new_spot_fields_validation(this, {$spot_id}, \"" . admin_url("/admin.php?page=csa_spots_management") . "\")'\n\t\t\t\t\t\t";
    }
    ?>
				class="button button-primary"
				title="<?php 
    __('Please fill in required fields, i.e. those marked with (*)', OPEN_CSA_WP_DOMAIN);
    ?>
"
			/>
			<input 
				type="button"
				class="button button-secondary"
				<?php 
    if ($spot_id == null) {
        echo "\n\t\t\t\t\tvalue='" . __('Reset Info', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\tonclick='open_csa_wp_reset_spot_form();'";
    } else {
        echo "\n\t\t\t\t\tvalue='" . __('Cancel', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\tonclick='window.location.replace(\"" . admin_url('/admin.php?page=csa_spots_management') . "\")'\n\t\t\t\t\t'";
    }
    ?>
			/>
		</form>
		<br/><br/>
	</div>
	
<?php 
}