function open_csa_wp_edit_user_properties($user, $new_user) { wp_enqueue_script('open-csa-wp-general-scripts'); wp_enqueue_script('open-csa-wp-users-scripts'); wp_enqueue_script('jquery.cluetip'); wp_enqueue_style('jquery.cluetip.style'); $csa_data = array(); $spot_id_preference = null; if (!$new_user) { $csa_data = get_user_meta($user->ID, 'open-csa-wp_user', true); } ?> <h3><?php _e('CSA Properties', OPEN_CSA_WP_DOMAIN); ?> </h3> <table class="form-table"> <tr> <th><?php _e('Type', OPEN_CSA_WP_DOMAIN); ?> </th> <td> <input id="open-csa-wp-consumer_radio" type="radio" name="open-csa-wp_user_type" value="consumer" onclick="open_csa_wp_producer_orders_info_via(document.getElementById('open-csa-wp-consumer_radio'),document.getElementById('open-csa-wp-producer_contact_preference'))" <?php if (!$new_user && isset($csa_data['type'])) { checked($csa_data['type'], "consumer"); } else { if ($new_user || !isset($csa_data['type'])) { echo 'checked = "checked"'; } } ?> > <label for="open-csa-wp-consumer_radio"><?php _e('Consumer', OPEN_CSA_WP_DOMAIN); ?> </label> <br> <input id="open-csa-wp-producer_radio" type="radio" name="open-csa-wp_user_type" value="producer" onclick="open_csa_wp_producer_orders_info_via(document.getElementById('open-csa-wp-producer_radio'),document.getElementById('open-csa-wp-producer_contact_preference'))" <?php if (!$new_user && isset($csa_data['type'])) { checked($csa_data['type'], "producer"); } ?> > <label for="open-csa-wp-producer_radio"><?php _e('Producer', OPEN_CSA_WP_DOMAIN); ?> </label> <br> <input id="open-csa-wp-both_radio" type="radio" name="open-csa-wp_user_type" value="both" onclick="open_csa_wp_producer_orders_info_via(document.getElementById('open-csa-wp-both_radio'),document.getElementById('open-csa-wp-producer_contact_preference'))" <?php if (!$new_user && isset($csa_data['type'])) { checked($csa_data['type'], "both"); } ?> > <label for="open-csa-wp-both_radio"><?php _e('Both', OPEN_CSA_WP_DOMAIN); ?> </label> <div id='open-csa-wp-producer_contact_preference' <?php if (!$new_user && isset($csa_data['type']) && ($csa_data['type'] == 'producer' || $csa_data['type'] == 'both')) { echo "style='display:block'"; } else { echo "style='display:none'"; } ?> > <?php _e('and producer prefers to be informed about orders via', OPEN_CSA_WP_DOMAIN); ?> <select name="open-csa-wp_user_info_via"> <option value="" disabled='disabled' <?php if ($new_user || !isset($csa_data['info-via'])) { echo "selected='selected'"; } ?> ><?php _e('please select ...', OPEN_CSA_WP_DOMAIN); ?> </option> <option value='website' <?php if (!$new_user && isset($csa_data['info-via'])) { selected($csa_data['info-via'], "website"); } ?> ><?php _e('website', OPEN_CSA_WP_DOMAIN); ?> </option> <option value='e-mail' <?php if (!$new_user && isset($csa_data['info-via'])) { selected($csa_data['info-via'], "e-mail"); } ?> ><?php _e('e-mail', OPEN_CSA_WP_DOMAIN); ?> </option> <option value='sms' <?php if (!$new_user && isset($csa_data['info-via'])) { selected($csa_data['info-via'], "sms"); } ?> ><?php _e('sms', OPEN_CSA_WP_DOMAIN); ?> </option> <option value='phone' <?php if (!$new_user && isset($csa_data['info-via'])) { selected($csa_data['info-via'], "phone"); } ?> ><?php _e('phone call', OPEN_CSA_WP_DOMAIN); ?> </option> </select> </div> </td> </tr> <tr> <th><?php _e('Role', OPEN_CSA_WP_DOMAIN); ?> </th> <td> <input id="open-csa-wp-none_radio" type="radio" name="open-csa-wp_user_role" value="none" <?php if (!$new_user && isset($csa_data['role'])) { checked($csa_data['role'], "none"); } else { if ($new_user || !isset($csa_data['role'])) { echo 'checked = "checked"'; } } ?> > <label for="open-csa-wp-none_radio"><?php _e('None', OPEN_CSA_WP_DOMAIN); ?> </label> <br> <input id="open-csa-wp-responsible_radio" type="radio" name="open-csa-wp_user_role" value="responsible" <?php if (!$new_user && isset($csa_data['role'])) { checked($csa_data['role'], "responsible"); } ?> > <span class="open-csa-wp-tip_users" title="Can become responsible for some delivery"><label for="open-csa-wp-responsible_radio"><?php _e('Responsible', OPEN_CSA_WP_DOMAIN); ?> </label></span> <br> <input id="open-csa-wp-administrator_radio" type="radio" name="open-csa-wp_user_role" value="administrator" <?php if (!$new_user && isset($csa_data['role'])) { checked($csa_data['role'], "administrator"); } ?> > <label for="open-csa-wp-administrator_radio"><?php _e('Administrator', OPEN_CSA_WP_DOMAIN); ?> </label> </td> </tr> <tr> <!-- Here starts the creation of the select element regarding the prefered delivery spot --> <th><?php _e('Delivery Spot Preference', OPEN_CSA_WP_DOMAIN); ?> </th> <td> <select id = 'open-csa-wp_user_spot_preference' name = 'open-csa-wp_user_spot_preference' > <option value = "" <?php //If we are about to add a new user or we are reviewing a user without a set delivery spot, select the default message if ($new_user || !isset($csa_data['spot'])) { echo 'selected="selected" '; } ?> disabled="disabled" > <?php _e("select the delivery spot ...", OPEN_CSA_WP_DOMAIN); ?> </option> <!-- Populate the options by calling the function 'open_csa_wp_select_delivery_spots', provide delivery spot preference if it is already set--> <?php if ($selected_csa_data != null && isset($selected_csa_data['spot'])) { $spot_id_preference = $selected_csa_data['spot']; } open_csa_wp_select_delivery_spots($spot_id_preference, ''); ?> </select> </td> </tr> </table> <?php }
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 } }
function open_csa_wp_new_delivery_form($spot_id, $order_deadline_date, $custom_values, $delivery_id, $display) { wp_enqueue_script('open-csa-wp-general-scripts'); wp_enqueue_script('open-csa-wp-deliveries-scripts'); wp_enqueue_script('jquery.cluetip'); wp_enqueue_style('jquery.cluetip.style'); global $days_of_week, $wpdb; $in_charge = null; $custom_bool = false; if ($spot_id != null) { $spot_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . OPEN_CSA_WP_TABLE_SPOTS . " WHERE id=%d", $spot_id))[0]; if ($delivery_id != null) { $delivery_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . OPEN_CSA_WP_TABLE_DELIVERIES . " WHERE id=%d", $delivery_id))[0]; $in_charge = $delivery_info->user_in_charge; $order_deadline_day = (date("w", strtotime($order_deadline_date)) - 1) % 7; if ($order_deadline_day == -1) { $order_deadline_day = 6; // So that the 'if' below (for custom_bool) is executed correctly } $order_deadline_time = open_csa_wp_remove_seconds($delivery_info->order_deadline_time); $delivery_day = (date("w", strtotime($delivery_info->delivery_date)) - 1) % 7; if ($delivery_day == -1) { $delivery_day = 6; // So that the 'if' below (for custom_bool) is executed correctly } $delivery_start_time = open_csa_wp_remove_seconds($delivery_info->delivery_start_time); $delivery_end_time = open_csa_wp_remove_seconds($delivery_info->delivery_end_time); if ($order_deadline_day != $spot_info->default_order_deadline_day || $order_deadline_time != open_csa_wp_remove_seconds($spot_info->default_order_deadline_time) || $delivery_day != $spot_info->default_delivery_day || $delivery_start_time != open_csa_wp_remove_seconds($spot_info->default_delivery_start_time) || $delivery_end_time != open_csa_wp_remove_seconds($spot_info->default_delivery_end_time)) { $custom_bool = true; } } else { $order_deadline_day = $spot_info->default_order_deadline_day; $order_deadline_time = open_csa_wp_remove_seconds($spot_info->default_order_deadline_time); $delivery_day = $spot_info->default_delivery_day; $delivery_start_time = open_csa_wp_remove_seconds($spot_info->default_delivery_start_time); $delivery_end_time = open_csa_wp_remove_seconds($spot_info->default_delivery_end_time); } if (count($custom_values) > 0) { $custom_bool = true; if (isset($custom_values["order_deadline_day"])) { $order_deadline_day = $custom_values["order_deadline_day"]; } if (isset($custom_values["order_deadline_time"])) { $order_deadline_time = $custom_values["order_deadline_time"]; } if (isset($custom_values["delivery_day"])) { $delivery_day = $custom_values["delivery_day"]; } if (isset($custom_values["delivery_start_time"])) { $delivery_start_time = $custom_values["delivery_start_time"]; } if (isset($custom_values["delivery_end_time"])) { $delivery_end_time = $custom_values["delivery_end_time"]; } } else { if ($delivery_id != null && $order_deadline_date == null) { $order_deadline_date = $delivery_info->order_deadline_date; } } } if ($order_deadline_date != null) { $order_deadline_date = explode(";", $order_deadline_date)[0]; if ($spot_id != null && $delivery_id == null) { $delivery_date = date(OPEN_CSA_WP_DATE_FORMAT, strtotime("Next " . $days_of_week[$delivery_day], strtotime($order_deadline_date))); $deliveries_info = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\tSELECT * FROM " . OPEN_CSA_WP_TABLE_DELIVERIES . " \n\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\torder_deadline_date = %s AND\n\t\t\t\t\t\t\t\t\t\t\tdelivery_date=%s\n\t\t\t\t\t\t\t\t\t", $order_deadline_date, $delivery_date)); if ($deliveries_info != null) { $delivery_info = $deliveries_info[0]; $delivery_id = $delivery_info->id; $in_charge = $delivery_info->user_in_charge; } } } ?> <br/> <div id="open-csa-wp-newDelivery_formHeader"> <span id="open-csa-wp-newDelivery_formHeader_text" <?php if ($spot_id == null) { echo 'style="cursor:pointer"'; echo 'onclick="open_csa_wp_toggle_form(\'newDelivery\',\'' . __('Initiate New Delivery', OPEN_CSA_WP_DOMAIN) . '\', \'' . __(' form', OPEN_CSA_WP_DOMAIN) . '\')"'; } ?> ><font size='4'> <?php if ($spot_id == null) { if ($display == false) { echo __('Initiate New Delivery', OPEN_CSA_WP_DOMAIN) . ' (' . __('show form', OPEN_CSA_WP_DOMAIN) . ')'; } else { echo __('Initiate New Delivery', OPEN_CSA_WP_DOMAIN) . ' (' . __('hide form', OPEN_CSA_WP_DOMAIN) . ')'; } } else { if ($delivery_id != null) { echo __('Edit Delivery', OPEN_CSA_WP_DOMAIN) . ' #' . $delivery_id; } else { echo __('Initiating new delivery for ', OPEN_CSA_WP_DOMAIN); } } ?> </font> </span> </div> <div id="open-csa-wp-newDelivery_div" <?php if ($display == false) { echo 'style="display:none"'; } ?> > <form method="POST" id='open-csa-wp-initiateNewDelivery_form_id'> <table class="form-table"> <tr valign="top"> <td> <select name="open-csa-wp-newDelivery_spotDetails_spotID_input" id="open-csa-wp-newDelivery_spotDetails_spotID_input_id" <?php if ($spot_id == null) { echo "style='color:#999'"; } echo "onchange='window.location.replace(\"" . admin_url('/admin.php?page=csa_deliveries_management') . "&id=\" + this.value)'"; ?> > <option value="" <?php if ($spot_id == null) { echo "selected='selected' "; } ?> disabled='disabled' id = "open-csa-wp-newDelivery_spotDetails_spotID_input_disabled_id" ><?php _e('Select Spot', OPEN_CSA_WP_DOMAIN); ?> *</option> <?php echo open_csa_wp_select_delivery_spots($spot_id != null ? $spot_id : null, "Spot "); ?> </select> <span id="open-csa-wp-newDelivery_spotDetails_spotID_input_span_id"> <?php if ($spot_id != null) { if ($order_deadline_date != null) { echo " where"; } else { if ($custom_bool === false) { echo "\n\t\t\t\t\t\t\t\t\t<i style='color:gray' class='open-csa-wp-tip_deliveries' title='\n\t\t\t\t\t\t\t\t\t\t" . __('Below, you can customize the deadline and delivery dates (and times) for this delivery.', OPEN_CSA_WP_DOMAIN) . "\n\t\t\t\t\t\t\t\t\t'> \n\t\t\t\t\t\t\t\t\t\t " . __('with default values... (point here)', OPEN_CSA_WP_DOMAIN) . " \n\t\t\t\t\t\t\t\t\t</i>"; } else { echo "<i style='color:gray'> " . __('with custom values...', OPEN_CSA_WP_DOMAIN) . " </i>"; } } } ?> </span> </tr> <tr <?php if ($spot_id == null) { echo 'style="display:none"'; } ?> > <td> <select <?php if ($order_deadline_date == null) { echo 'style="color:#999"'; } ?> id="open-csa-wp-newDelivery_delivery_deadline_date_input_id" name="open-csa-wp-newDelivery_delivery_deadline_date_input" onchange = ' document.getElementById("open-csa-wp-newDelivery_orderDeadlineDate_choice_id").value = this.options[this.selectedIndex].value; open_csa_wp_new_delivery_format_custom_values( document.getElementById("open-csa-wp-newDeliveryCustomValues_button_id") ) ' > <option disabled="disabled" value="" id = "open-csa-wp-newDelivery_delivery_deadline_date_disabled_id"; <?php if ($order_deadline_date == null) { echo 'selected="selected"'; } ?> > <?php _e('Choose a deadline date', OPEN_CSA_WP_DOMAIN); ?> * </option> <?php $deadline_day = $days_of_week[$order_deadline_day]; for ($i = 0; $i < 5; $i++) { $next_deadline_date = date(OPEN_CSA_WP_DATE_FORMAT, strtotime("Next " . $deadline_day . "+{$i} week")); $next_deadline_date_readable = $deadline_day . ", " . date(OPEN_CSA_WP_DATE_FORMAT_READABLE, strtotime($next_deadline_date)) . ", " . __('up to', OPEN_CSA_WP_DOMAIN) . " " . $order_deadline_time; if ($order_deadline_date == null || $order_deadline_date != $next_deadline_date) { echo "<option \n\t\t\t\t\t\t\t\t\t\tstyle='color:black' \n\t\t\t\t\t\t\t\t\t\tvalue='{$next_deadline_date};{$order_deadline_time}'\n\t\t\t\t\t\t\t\t\t>{$next_deadline_date_readable}</option>"; } else { if ($order_deadline_date == $next_deadline_date) { echo "<option \n\t\t\t\t\t\t\t\t\t\tstyle='color:black' \n\t\t\t\t\t\t\t\t\t\tselected = 'selected' \n\t\t\t\t\t\t\t\t\t\tvalue='{$next_deadline_date};{$order_deadline_time}'\n\t\t\t\t\t\t\t\t\t>" . __('Order deadline is on', OPEN_CSA_WP_DOMAIN) . " {$next_deadline_date_readable}</option>"; } } } ?> </select> <span id="open-csa-wp-newDelivery_delivery_deadline_date_input_span_id" <?php if ($order_deadline_date == null) { echo 'style="display:none"'; } ?> > <?php _e('and', OPEN_CSA_WP_DOMAIN); ?> </span></td> </tr> <tr valign="top" <?php if ($order_deadline_date == null) { echo 'style="display:none"'; } ?> ><td><span> <?php $delivery_date = date(OPEN_CSA_WP_DATE_FORMAT_READABLE, strtotime("Next " . $days_of_week[$delivery_day], strtotime($order_deadline_date))); $value_of_read_only_input = "Delivery is on " . $days_of_week[$delivery_day] . ", " . $delivery_date . ", from {$delivery_start_time} to {$delivery_end_time}"; $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 " \t<input \n\t\t\t\t\t\t\t\tname = 'open-csa-wp-newDelivery_DeliveryDaTeDetails_input'\n\t\t\t\t\t\t\t\ttype = 'text'\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\tstyle='border:none; background-color:white;'\n\t\t\t\t\t\t\t\tsize='{$size_of_read_only_input}'\n\t\t\t\t\t\t\t/>"; ?> </span></td></tr> <tr valign="top" <?php if ($order_deadline_date == null) { echo 'style="display:none"'; } ?> ><td> <select name="open-csa-wp-newDelivery_inCharge_input" id="open-csa-wp-newDelivery_inCharge_input_id" onchange = ' this.style.color="black" if (this.options[this.selectedIndex].text.split(" ")[0] != "<?php _e('Responsible for this delivery is', OPEN_CSA_WP_DOMAIN); ?> ".split(" ")[0]) { this.options[this.selectedIndex].text = <?php _e('Responsible for this delivery is', OPEN_CSA_WP_DOMAIN); ?> + " " + this.options[this.selectedIndex].text; } ' <?php if ($delivery_id == null) { echo "style='color:#999'"; } ?> > <option value="" <?php if ($delivery_id == null) { echo "selected='selected'"; } ?> id = "open-csa-wp-newDelivery_inCharge_input_disabled_id" disabled='disabled' ><?php _e('Do you know who is going to be in charge?', OPEN_CSA_WP_DOMAIN); ?> </option> <?php echo open_csa_wp_select_users_of_type("consumer", $in_charge, __('Responsible for this delivery is', OPEN_CSA_WP_DOMAIN) . " "); ?> </select> </td></tr> <tr valign="top" <?php if ($delivery_id == null) { echo "style='display:none'"; } ?> ><td> <select name="open-csa-wp-delivery_abilityToSubmitOrder_input" id="open-csa-wp-delivery_abilityToSubmitOrder_input_id" <?php if ($delivery_id != null && $delivery_info->are_orders_open == 1) { echo "style='color:green'"; } else { echo "style='color:brown'"; } ?> onchange=' if (this.options[this.selectedIndex].value == "yes") { this.style.color = "green"; this.options[this.selectedIndex].text = "<?php _e('Currently, new orders can be submitted', OPEN_CSA_WP_DOMAIN); ?> " } else { this.style.color = "brown"; this.options[this.selectedIndex].text = "<?php _e('Currently, new orders can not be submitted', OPEN_CSA_WP_DOMAIN); ?> " } ' > <?php if ($delivery_id != null) { echo ' <option value="yes" style="color:green". ' . ($delivery_info->are_orders_open == 1 ? "selected='selected'" : "") . '> ' . __('Currently, new orders can be submitted', OPEN_CSA_WP_DOMAIN) . ' </option> <option value="no" style="color:brown"' . ($delivery_info->are_orders_open == 0 ? "selected='selected'" : "") . '> ' . __('Currently, new orders can not be submitted', OPEN_CSA_WP_DOMAIN) . ' </option> '; } ?> </select> </td> </tr> <tr <?php if ($spot_id == null) { echo 'style="display:none"'; } ?> > <td> <input type="submit" class="button button-primary" id="open-csa-wp-initiateNewDelivery_button_id" <?php if ($delivery_id == null) { echo "\n\t\t\t\t\t\t\t\t\tvalue='" . __('Initiate Delivery', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\t\t\t\t\tonclick='open_csa_wp_request_initiate_new_or_update_delivery(this, null, \"" . admin_url("/admin.php?page=csa_deliveries_management") . "\");'\n\t\t\t\t\t\t\t\t"; } else { echo "\n\t\t\t\t\t\t\t\t\tvalue='" . __('Update Delivery', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\t\t\t\t\tonclick='open_csa_wp_request_initiate_new_or_update_delivery(this, {$delivery_id}, \"" . admin_url("/admin.php?page=csa_deliveries_management") . "\");'\n\t\t\t\t\t\t\t\t"; } ?> /> <input type="button" class="button button-secondary" value="<?php _e('Cancel', OPEN_CSA_WP_DOMAIN); ?> " <?php echo "onclick='window.location.replace(\"" . admin_url('/admin.php?page=csa_deliveries_management') . "\")'"; ?> /> </td> </tr> </table> </form> <form id="open-csa-wp-initiateNewDelivery_spotDetails_form" method="post" <?php if ($spot_id == null) { echo 'style="display:none"'; } ?> action="<?php echo admin_url('/admin.php?page=csa_deliveries_management'); ?> " > <br/> <div id="open-csa-wp-newDelivery_spotDetailsDetails_formHeader"> <span id="open-csa-wp-newDelivery_spotDetailsDetails_formHeader_text" style="cursor:pointer" <?php if ($custom_bool === true) { echo "onclick=\"open_csa_wp_toggle_form('newDelivery_spotDetailsDetails','" . __('Custom values', OPEN_CSA_WP_DOMAIN) . " ', ' " . __('form', OPEN_CSA_WP_DOMAIN) . "', 3, ' ')\""; } else { echo "onclick=\"open_csa_wp_toggle_form('newDelivery_spotDetailsDetails','" . __('Customize default values', OPEN_CSA_WP_DOMAIN) . " ', ' " . __('form', OPEN_CSA_WP_DOMAIN) . "', 3, ' ')\""; } ?> ><font size='3'> <?php $text_hide_show = "hide"; if ($order_deadline_date != null || $delivery_id != null) { $text_hide_show = "show"; } if ($custom_bool === true) { echo " " . __('Custom values', OPEN_CSA_WP_DOMAIN) . " ({$text_hide_show} " . __('form', OPEN_CSA_WP_DOMAIN) . ")"; } else { echo " " . __('Customize default values', OPEN_CSA_WP_DOMAIN) . " ({$text_hide_show} " . __('form', OPEN_CSA_WP_DOMAIN) . ")"; } ?> </font> </span> </div> <div id = "open-csa-wp-newDelivery_spotDetailsDetails_div" <?php if ($order_deadline_date != null || $delivery_id != null) { echo "style='display:none'"; } ?> > <table class="form-table"> <tr hidden="hidden"> <td> <input name='open-csa-wp-newDelivery_spotID_choice' id='open-csa-wp-newDelivery_spotID_choice_id' value="<?php if ($spot_id != null) { echo $spot_id; } ?> "> </td> <tr/> <tr hidden="hidden"> <td> <input name='open-csa-wp-newDelivery_deliveryID_choice' value="<?php if ($delivery_id != null) { echo $delivery_id; } ?> "> </td> <tr/> <tr hidden="hidden"> <td> <input name='open-csa-wp-newDelivery_orderDeadlineDate_choice' id='open-csa-wp-newDelivery_orderDeadlineDate_choice_id' value=""> </td> <tr/> <?php if ($delivery_id != null) { echo "\n\t\t\t\t\t\t\t<tr hidden = 'hidden'> \n\t\t\t\t\t\t\t\t<td> <input name='open-csa-wp-newDelivery_deliveryID' value=\"{$delivery_id}\"/> </td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t"; } ?> <tr valign="top"><td> <select name="open-csa-wp-newDelivery_order_deadline_day_input" id='open-csa-wp-newDelivery_order_deadline_day_input_id' onfocus=' getElementById("open-csa-wp-newDelivery_spotDetails_orderDeadline_span").style.display = "none";' onchange=' if (this.options[this.selectedIndex].text.split(" ")[0] != "order") { this.options[this.selectedIndex].text = "order deadline is on " + this.options[this.selectedIndex].text; } getElementById("open-csa-wp-newDelivery_order_deadline_time_input_id").style.display = "inline" ' > <option value="" selected='selected' disabled="disabled" id="open-csa-wp-newDelivery_order_deadline_day_disabled_id">order deadline day ... *</option> <?php for ($i = 0; $i < 7; $i++) { if ($order_deadline_day == $i) { echo "<option value='{$i}' selected='selected'> " . __('order deadline is on', OPEN_CSA_WP_DOMAIN) . " {$days_of_week[$i]} </option>"; } else { echo "<option value='{$i}'>" . $days_of_week[$i] . "</option>"; } } ?> </select> <input <?php if ($spot_id != null) { echo "value='" . __('up to', OPEN_CSA_WP_DOMAIN) . " {$order_deadline_time}'"; } ?> placeholder="up to... *" id="open-csa-wp-newDelivery_order_deadline_time_input_id" class="textbox-n" type="text" size="10" name="open-csa-wp-newDelivery_order_deadline_time_input" onfocus=' getElementById("open-csa-wp-newDeliveryCustomValues_button_id").disabled = true; <?php if ($custom_bool === true && $delivery_id == null) { echo 'getElementById("open-csa-wp-newDeliveryCustomValues_reset_button_id").disabled = true;'; } ?> if (this.value != "") this.value=this.value.split(" ")[2]; else getElementById("open-csa-wp-newDelivery_spotDetails_orderDeadline_span").style.display = "none"; this.type="time";' onblur=' getElementById("open-csa-wp-newDeliveryCustomValues_button_id").disabled = false; <?php if ($custom_bool === true && $delivery_id == null) { echo 'getElementById("open-csa-wp-newDeliveryCustomValues_reset_button_id").disabled = false;'; } ?> 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-newDelivery_spotDetails_orderDeadline_span" style="display:none"></span> </td></tr> <tr valign="top"><td> <select name="open-csa-wp-newDelivery_delivery_day_input" id="open-csa-wp-newDelivery_delivery_day_input_id" onfocus='getElementById("open-csa-wp-newDelivery_spotDetails_invalidDeliveryTime_span").innerHTML = "";' onchange=' if (this.options[this.selectedIndex].text.split(" ")[0] != "Delivery") { this.options[this.selectedIndex].text = "Delivery day is " + this.options[this.selectedIndex].text; } getElementById("open-csa-wp-newDelivery_spotDetails_delivery_start_time_input_id").style.display = "inline"' > <option value="" disabled="disabled" id="open-csa-wp-newDelivery_delivery_day_disabled_id"><?php _e('Delivery Day', OPEN_CSA_WP_DOMAIN); ?> ... *</option> <?php for ($i = 0; $i < 7; $i++) { if ($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-newDelivery_spotDetails_delivery_start_time_input_id" <?php if ($spot_id != null) { echo "value='from {$delivery_start_time}'"; } ?> placeholder="<?php _e('from', OPEN_CSA_WP_DOMAIN); ?> ... *" class="textbox-n" type="text" size="10" name="open-csa-wp-newDelivery_delivery_start_time_input" onfocus=' getElementById("open-csa-wp-newDeliveryCustomValues_button_id").disabled = true; <?php if ($custom_bool === true && $delivery_id == null) { echo 'getElementById("open-csa-wp-newDeliveryCustomValues_reset_button_id").disabled = true;'; } ?> if (this.value != "") { this.value=this.value.split(" ")[1]; } else { getElementById("open-csa-wp-newDelivery_spotDetails_invalidDeliveryTime_span").style.display = "none"; } this.type="time";' onblur=' getElementById("open-csa-wp-newDeliveryCustomValues_button_id").disabled = false; <?php if ($custom_bool === true && $delivery_id == null) { echo 'getElementById("open-csa-wp-newDeliveryCustomValues_reset_button_id").disabled = false;'; } ?> this.type="text"; if (this.value == "") { getElementById("open-csa-wp-newDelivery_spotDetails_delivery_end_time_input_id").style.display = "none"; getElementById("open-csa-wp-newDelivery_spotDetails_delivery_end_time_input_id").value = ""; } else { this.style.color="black"; this.value = "from " + this.value; getElementById("open-csa-wp-newDelivery_spotDetails_delivery_end_time_input_id").style.display = "inline"; open_csa_wp_validate_delivery_time_period("newDelivery_spotDetails"); }' > <input id="open-csa-wp-newDelivery_spotDetails_delivery_end_time_input_id" <?php if ($spot_id != null) { echo "value='" . __('to', OPEN_CSA_WP_DOMAIN) . " {$delivery_end_time}'"; } ?> placeholder="<?php _e('to', OPEN_CSA_WP_DOMAIN); ?> ... *" class="textbox-n" type="text" size="10" name="open-csa-wp-newDelivery_delivery_end_time_input" onfocus=' getElementById("open-csa-wp-newDeliveryCustomValues_button_id").disabled = true; <?php if ($custom_bool === true && $delivery_id == null) { echo 'getElementById("open-csa-wp-newDeliveryCustomValues_reset_button_id").disabled = true;'; } ?> if (this.value != "") { this.value=this.value.split(" ")[1] } getElementById("open-csa-wp-newDelivery_spotDetails_invalidDeliveryTime_span").style.display = "none"; this.type="time";' onblur=' getElementById("open-csa-wp-newDeliveryCustomValues_button_id").disabled = false; <?php if ($custom_bool === true && $delivery_id == null) { echo 'getElementById("open-csa-wp-newDeliveryCustomValues_reset_button_id").disabled = false;'; } ?> 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("newDelivery_spotDetails"); } ' > <span id="open-csa-wp-newDelivery_spotDetails_invalidDeliveryTime_span"> </span> </td> </tr> <tr valign="top"><td> <input type="submit" class="button button-secondary" id="open-csa-wp-newDeliveryCustomValues_button_id" value="<?php _e('Use Custom Values', OPEN_CSA_WP_DOMAIN); ?> " onclick="open_csa_wp_new_delivery_format_custom_values(this);" /> <?php if ($custom_bool === true && $delivery_id == null) { echo "\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\ttype='submit'\n\t\t\t\t\t\t\t\t\tclass='button button-secondary'\n\t\t\t\t\t\t\t\t\tid='open-csa-wp-newDeliveryCustomValues_reset_button_id'\n\t\t\t\t\t\t\t\t\tvalue='" . __('Reset to default values', OPEN_CSA_WP_DOMAIN) . "'\n\t\t\t\t\t\t\t\t\tonclick='\n\t\t\t\t\t\t\t\t\t\twindow.location.replace(\"" . admin_url('/admin.php?page=csa_deliveries_management') . "&id=" . $spot_id . "\");\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t"; } ?> </td> </tr> </table> </div> </form> </div> <?php }