Modifying appointments+

Hi,

I’ve decided to take the plunge and modify this plugin for many reasons. First things first, I want to add hours for each service – without using the ‘add new user’ method. I have added a new tab called ‘event hours’ and I have loaded in the services as my events. I have added a new table in the database with the same structure as the worker_hours table.

My problem is this; When I click on the event to add hours to, the event list (services list) resets to ‘no specific provider’. How can I write to my table in the database?

Here is the code I have for when the tab is loaded,

<?php

case ‘event_hours’: _e( ‘<i>Here you can define the hours for your events.</i>’, ‘appointments’:wink:; ?>

<?php

$events = $wpdb->get_results( “SELECT * FROM ” . $this->services_table . ” ” );

?>

<?php _e(‘List for:’, ‘appointments’:wink:?>

 

<select id=”app_service_id” name=”app_service_id”>

<option value=”0″><?php _e(‘No specific provider’, ‘appointments’:wink:?></option>

<?php

if ( $events ) {

foreach ( $events as $event ) {

if ( $this->event == $event->ID )

$s = ” selected=’selected'”;

else

$s = ”;

echo ‘<option value=”‘.$event->ID.'”‘.$s.’>’ . $this->get_event_name( $event->ID, false ) . ‘</option>’;

}

}

?>

</select>

<script type=”text/javascript”>

jQuery(document).ready(function($){

$(‘#app_service_id’:wink:.change(function(){

var app_service_id = $(‘#app_service_id option:selected’:wink:.val();

window.location.href = “<?php echo admin_url(‘admin.php?page=app_settings&tab=event_hours’:wink:?>” + “&app_service_id=” + app_service_id;

});

});

</script>

<form method=”post” action=”” >

<table class=”widefat fixed”>

<tr>

<th style=”width:40%”><?php _e( ‘Event Hours’, ‘appointments’ ) ?></th>

<th style=”width:40%”><?php _e( ‘Break Hours’, ‘appointments’ ) ?></th>

<tr>

<td>

<?php echo $this->event_hour_form( ‘open’ ); ?>

</td>

<td>

<?php echo $this->event_hour_form( ‘closed’ ); ?>

</td>

</tr>

</table>

<input type=”hidden” name=”event” value=”0″ />

<input type=”hidden” name=”location” value=”0″ />

<input type=”hidden” name=”action_app” value=”save_event_hours” />

<?php wp_nonce_field( ‘update_app_settings’, ‘app_nonce’ ); ?>

<p class=”submit”>

<input type=”submit” class=”button-primary” value=”<?php _e(‘Save Event Hours’, ‘appointments’:wink: ?>” />

</p>

</form>

<?php break; ?>

Can you help? Thanks.

  • Hakan
    • The Incredible Smush

    Hi,

    Admin side settings, including services and services settings are saved in “admin_init” function starting at around line 6433.

    You can have a look at how services are saved around line 6762 and take it as a model for your application.

    Cheers,

    Hakan

  • karenweider
    • Design Lord, Child of Thor

    Hi thanks for your response. I have taken the code in the admin_init and duplicated part of it, as shown in my first post.

    My problem at the moment I think lies in this part of code,

    jQuery(document).ready(function($){

    $(‘#app_service_id’:wink:.change(function(){

    var app_service_id = $(‘#app_service_id option:selected’:wink:.val();

    window.location.href = “<?php echo admin_url(‘admin.php?page=app_settings&tab=event_hours’:wink:?>” + “&app_service_id=” + app_service_id;

    });

    });

    My new tab is event_hours – which is almost a duplication of the workers_hours and I am listing the services in the drop down list instead of the workers names.

    I get the services to appear but just cant select one to enable me to enter the hours for it. When I try to select from the drop down list it just returns to ‘no specific provider’ in the drop down. When I try to select a service/event the url is

    admin.php?page=app_settings&tab=event_hours&app_service_id=1

    which looks ok to me but as I mentioned the drop down list returns back to ‘no specific provider’ and I cant enter times.

    Any further ideas?

    Thanks.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.