Пример #1
0
/**
 * Update the Addons select list based on Package selections
 *
 * @param	str		$package	Optional: The slug of the current package. If empty (default), no current package
 *								Otherwise query package for it's items and remove those from available addons
 *			str		$dj			The DJ for the event
 * @return	arr		$addons		array of 
 */
function update_addon_options()
{
    $dj = $_POST['dj'];
    $event_package = $_POST['package'];
    $addons = mdjm_addons_dropdown(array('name' => 'event_addons', 'dj' => !empty($dj) ? $dj : '', 'package' => !empty($event_package) ? $event_package : ''), false);
    if (!empty($addons)) {
        $result['type'] = 'success';
        $result['addons'] = $addons;
    } else {
        $result['type'] = 'success';
        $result['addons'] = '<option value="0" disabled="disabled">' . __('No addons available', 'mobile-dj-manager') . '</option>';
    }
    echo json_encode($result);
    die;
}
Пример #2
0
 function edit_event_form($event_id)
 {
     global $post, $mdjm;
     $post = get_post($event_id);
     $eventinfo = MDJM()->events->event_detail($post->ID);
     $existing_event_type = wp_get_object_terms($post->ID, 'event-types');
     echo '<form name="edit_client_event" id="edit_client_event" method="post" action="' . mdjm_get_formatted_url(MDJM_HOME, true) . 'action=view_event&event_id=' . $event_id . '">' . "\r\n";
     echo '<input type="hidden" name="event_id" id="event_id" value="' . $post->ID . '" />' . "\r\n";
     echo '<input type="hidden" name="event_dj" id="event_dj" value="' . (isset($eventinfo['dj']->ID) ? $eventinfo['dj']->ID : '0') . '" />' . "\r\n";
     wp_nonce_field('manage_event', '__mdjm_event');
     echo '<div id="mdjm-event-container">' . "\r\n";
     echo '<div id="mdjm-event-table">' . "\r\n";
     echo '<table id="mdjm-event-listing">' . "\r\n";
     echo '<tr>' . "\r\n";
     echo '<th colspan="4"><span style="text-decoration: underline;">' . __('Event Details') . '</th>' . "\r\n";
     echo '</tr>' . "\r\n";
     echo '<tr>' . "\r\n";
     echo '<th style="width: 20%;"><label for="_mdjm_event_name">' . __('Event Name:') . '</label></th>' . "\r\n";
     echo '<td colspan="3"><input type="text" name="_mdjm_event_name" id="_mdjm_event_name" value="' . (!empty($eventinfo['name']) ? esc_attr($eventinfo['name']) : $eventinfo['type']) . '" /></td>' . "\r\n";
     echo '</tr>' . "\r\n";
     echo '<tr>' . "\r\n";
     echo '<th style="width: 20%;"><label for="display_event_date">' . __('Event Date:') . '</label></th>' . "\r\n";
     echo '<td style="width: 30%;"><input type="text" class="mdjm_date required" name="display_event_date" id="display_event_date" ' . 'value="' . (get_post_meta($post->ID, '_mdjm_event_date', true) ? date(MDJM_SHORTDATE_FORMAT, $eventinfo['date']) : '') . '" disabled="disabled" />' . '<input type="hidden" name="_mdjm_event_date" id="_mdjm_event_date" value="' . (!empty($eventinfo['date']) ? date(MDJM_SHORTDATE_FORMAT, $eventinfo['date']) : '') . '" /></td>' . "\r\n";
     echo '<th style="width: 20%;"><label for="mdjm_event_type">' . __('Event Type:') . '</label></th>' . "\r\n";
     echo '<td style="width: 30%;">';
     wp_dropdown_categories(array('taxonomy' => 'event-types', 'hide_empty' => 0, 'name' => 'mdjm_event_type', 'id' => 'mdjm_event_type', 'selected' => isset($existing_event_type[0]->term_id) ? $existing_event_type[0]->term_id : '', 'orderby' => 'name', 'hierarchical' => 0, 'class' => 'mdjm-meta required'));
     '</td>' . "\r\n";
     echo '</tr>' . "\r\n";
     echo '<tr>' . "\r\n";
     echo '<th style="width: 20%;"><label for="event_start_hr">' . __('Start Time:') . '</label></th>' . "\r\n";
     echo '<td style="width: 30%;">';
     echo '<select name="event_start_hr" id="event_start_hr">' . "\r\n";
     $minutes = array('00', '15', '30', '45');
     if (MDJM_TIME_FORMAT == 'H:i') {
         $i = '00';
         $x = '23';
         $comp = 'H';
     } else {
         $i = '1';
         $x = '12';
         $comp = 'g';
     }
     while ($i <= $x) {
         if ($i != 0 && $i < 10 && $comp == 'H') {
             $i = '0' . $i;
         }
         echo '<option value="' . $i . '"';
         selected(date($comp, strtotime($eventinfo['start'])), $i);
         echo '>' . $i . '</option>' . "\r\n";
         $i++;
     }
     echo '</select>' . "\r\n";
     echo '<select name="event_start_min" id="event_start_min">' . "\r\n";
     foreach ($minutes as $minute) {
         echo '<option value="' . $minute . '"';
         selected(date('i', strtotime($eventinfo['start'])), $minute);
         echo '>' . $minute . '</option>' . "\r\n";
     }
     echo '</select>' . "\r\n";
     if (MDJM_TIME_FORMAT != 'H:i') {
         echo '&nbsp;<select name="event_start_period" id="event_start_period">' . "\r\n";
         echo '<option value="AM"';
         selected(date('A', strtotime($eventinfo['start'])), 'AM');
         echo '>AM</option>' . "\r\n";
         echo '<option value="PM"';
         selected(date('A', strtotime($eventinfo['start'])), 'PM');
         echo '>PM</option>' . "\r\n";
         echo '</select>' . "\r\n";
     }
     echo '</td>' . "\r\n";
     echo '<th style="width: 20%;"><label for="event_finish_hr">' . __('End Time:') . '</label></th>' . "\r\n";
     echo '<td style="width: 30%;">';
     echo '<select name="event_finish_hr" id="event_finish_hr">' . "\r\n";
     $minutes = array('00', '15', '30', '45');
     if (MDJM_TIME_FORMAT == 'H:i') {
         $i = '00';
         $x = '23';
         $comp = 'H';
     } else {
         $i = '1';
         $x = '12';
         $comp = 'g';
     }
     while ($i <= $x) {
         if ($i != 0 && $i < 10 && $comp == 'H') {
             $i = '0' . $i;
         }
         echo '<option value="' . $i . '"';
         selected(date($comp, strtotime($eventinfo['finish'])), $i);
         echo '>' . $i . '</option>' . "\r\n";
         $i++;
     }
     echo '</select>' . "\r\n";
     echo '<select name="event_finish_min" id="event_finish_min">' . "\r\n";
     foreach ($minutes as $minute) {
         echo '<option value="' . $minute . '"';
         selected(date('i', strtotime($eventinfo['finish'])), $minute);
         echo '>' . $minute . '</option>' . "\r\n";
     }
     echo '</select>' . "\r\n";
     if (MDJM_TIME_FORMAT != 'H:i') {
         echo '&nbsp;<select name="event_finish_period" id="event_finish_period">' . "\r\n";
         echo '<option value="AM"';
         selected(date('A', strtotime($eventinfo['finish'])), 'AM');
         echo '>AM</option>' . "\r\n";
         echo '<option value="PM"';
         selected(date('A', strtotime($eventinfo['finish'])), 'PM');
         echo '>PM</option>' . "\r\n";
         echo '</select>' . "\r\n";
     }
     echo '</td>' . "\r\n";
     echo '</tr>' . "\r\n";
     if (MDJM_PACKAGES == true) {
         echo '<tr>' . "\r\n";
         echo '<th style="width: 20%;"><label for="_mdjm_event_package">' . __('Package:') . '</label></th>' . "\r\n";
         echo '<td style="width: 30%;">' . mdjm_package_dropdown(array('selected' => !empty($eventinfo['package']['slug']) ? $eventinfo['package']['slug'] : '', 'dj' => $eventinfo['dj'] != 'Not Assigned' ? $eventinfo['dj']->ID : ''));
         echo '</td>' . "\r\n";
         echo '<th style="width: 20%;"><label for="_mdjm_event_addons">' . __('Addons:') . '</label></th>' . "\r\n";
         echo '<td style="width: 30%;">' . mdjm_addons_dropdown(array('name' => 'event_addons', 'selected' => !empty($eventinfo['addons']) ? $eventinfo['addons'] : '', 'dj' => $eventinfo['dj'] != 'Not Assigned' ? $eventinfo['dj']->ID : '', 'package' => !empty($eventinfo['package']['slug']) ? $eventinfo['package']['slug'] : ''));
         echo '</td>' . "\r\n";
         echo '</tr>' . "\r\n";
     }
     echo '<tr>' . "\r\n";
     echo '<th style="width: 20%;"><label for="_mdjm_event_notes">' . __('Notes:') . '</label></th>' . "\r\n";
     echo '<td colspan="3"><textarea name="_mdjm_event_notes" id="_mdjm_event_notes" cols="50" rows="5">' . esc_attr($eventinfo['notes']) . '</textarea></td>' . "\r\n";
     echo '</tr>' . "\r\n";
     echo '<tr>' . "\r\n";
     echo '<th style="width: 20%;"><label for="mdjm_reason">' . __('Reason for Changes:') . '</label></th>' . "\r\n";
     echo '<td colspan="3"><textarea name="mdjm_reason" id="mdjm_reason" cols="50" rows="5" placeholder="' . __('If you are making any changes to your event, please enter the reason here') . '"></textarea></td>' . "\r\n";
     echo '</tr>' . "\r\n";
     echo '<tr>' . "\r\n";
     echo '<td colspan="2"><input type="submit" name="submit" id="submit" value="Submit Changes" /></td>' . "\r\n";
     echo '<td colspan="2"><button type="reset" onclick="location.href=\'' . mdjm_get_formatted_url(MDJM_HOME, true) . 'action=view_event&amp;event_id=' . $post->ID . '\'">' . __('Cancel Changes') . '</button></td>' . "\r\n";
     echo '</tr>' . "\r\n";
     echo '</table>' . "\r\n";
     echo '</div>' . "\r\n";
     // End div mdjm-event-table
     echo '</div>' . "\r\n";
     // End div mdjm-event-container
     echo '</form>' . "\r\n";
 }