prefix . $bookings_table; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, first_name text, last_name text, job text, company text, email text, telephone text, mailinglist boolean, source tinytext, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); add_option("tsbooking_version", $tsbooking_version); } register_activation_hook(__FILE__,'tsbooking_install'); // Brandword Availability Checking function tsbooking_makebooking( $atts ) { global $wpdb; global $bookings_table; $booking_length = get_option('tsbooking_booklength') * 60; extract( shortcode_atts( array(), $atts)); // Get the list of available appointments $table_name = $wpdb->prefix . $bookings_table; $dbresult = $wpdb->get_results("SELECT time FROM $table_name WHERE first_name IS NULL OR LENGTH(first_name) = 0 ORDER BY time"); if (count($dbresult) == 0) { $result = '

There are no appointments currently available.

'; } else { $result = '

*(denotes required field)












'; } return $result; } add_shortcode( 'tsbooking', tsbooking_makebooking); // The Settings Interface add_option('tsbooking_booklength', 15); // Booking Length add_option('tsbooking_email_from', 'No Reply '); // From Email Address add_option('tsbooking_email_bcc', 'my@email.address.com'); // Email BCC Address for confirmation emails add_option('tsbooking_email_subject', "Meeting Booked"); // Email subject prefix add_option('tsbooking_email_message', ", see you there."); // Email message completion function tsbooking_options_page() { global $wpdb; global $bookings_table; $table_name = $wpdb->prefix . $bookings_table; global $tsbooking_version; if (isset($_POST['set_defaults'])) { echo '

'; update_option('tsbooking_booklength', 15); // Booking Length update_option('tsbooking_email_from', 'No Reply '); // From Email Address update_option('tsbooking_email_bcc', 'my@email.address.com'); // Email BCC Address for confirmation emails update_option('tsbooking_email_subject', "Meeting Booked"); // Email subject prefix update_option('tsbooking_email_message', ", see you there."); // Email message completion echo 'Default Options Loaded!'; echo '

'; } else if (isset($_POST['appts_reset'])) { echo '

'; $selectedAppts = $_POST['tsbooking_appt_row']; $itemCount = count($selectedAppts); for ($pos = 0; $pos < $itemCount; ++$pos) { $wpdb->update( $table_name, array( 'first_name' => NULL, 'last_name' => NULL, 'job' => NULL, 'email' => NULL, 'company' => NULL, 'telephone' => NULL, 'source' => NULL, 'mailinglist' => "0"), array( 'id' => $selectedAppts[$pos] ) ); } echo 'Reset ' . $itemCount . ' appointment(s).'; echo '

'; } else if (isset($_POST['appts_delete'])) { echo '

'; $selectedAppts = $_POST['tsbooking_appt_row']; $itemCount = count($selectedAppts); if ($itemCount > 0) { $query = "DELETE FROM $table_name WHERE id IN ("; for ($pos = 0; $pos < $itemCount; ++$pos) { if ($pos != 0) $query .= ','; $query .= "'" . $selectedAppts[$pos] . "'"; } $query .= ")"; $wpdb->query($query); } echo 'Deleted ' . $itemCount . ' appointment(s).'; echo '

'; } else if (isset($_POST['appts_add'])) { echo '

'; $aptsDate = $_POST['tsbooking_apptdate']; $aptsTime = $_POST['tsbooking_appttime']; $newAppt = strtotime($aptsTime . ' ' . $aptsDate); if ($newAppt) { $wpdb->insert( $table_name, array( 'time' => date("Y/m/d H:i:s", $newAppt) ) ); echo 'Added appointment at ' . date("H:i d/m/Y", $newAppt); } else { echo 'Requested appointment date not understood'; } echo '

'; } else if (isset($_POST['info_update'])) { $length = $_POST['tsbooking_settings_length']; $from = $_POST['tsbooking_settings_from']; $bcc = $_POST['tsbooking_settings_bcc']; $subject = $_POST['tsbooking_settings_subject']; $message = $_POST['tsbooking_settings_emailmessage']; echo '

'; update_option('tsbooking_booklength', $length); // Booking Length update_option('tsbooking_email_from', $from); // From Email Address update_option('tsbooking_email_bcc', $bcc); // Email BCC Address for confirmation emails update_option('tsbooking_email_subject', $subject); // Email subject prefix update_option('tsbooking_email_message', $message); // Email message completion echo 'Configuration Updated!'; echo '

'; } ?>

3 Sheep Appointment Booking v

Usage

">

Current Appointments

get_results("SELECT * FROM $table_name ORDER BY time"); $booking_length = get_option('tsbooking_booklength') * 60; foreach($dbresult as $aResult) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } ?>
AppointmentNameJob TitleCompanyEmail AddressTelephoneSourceMailing List
' . date("H:i", strtotime($aResult->time)) . '-' . date("H:i", strtotime($aResult->time) + $booking_length) . ' ' . date("d/m/Y", strtotime($aResult->time)) . '' . $aResult->first_name . ' ' . $aResult->last_name . '' . $aResult->job . '' . $aResult->company . '' . $aResult->email . '' . $aResult->telephone . '' . $aResult->source . '' . ($aResult->mailinglist== 0 ? 'No' : 'Yes') . '
">

Add an Appointment

(i.e. 4 March 2012)
(i.e. 14:30)

Settings

"> minutes


- 10:00- 01/01/2012

"An appointment has been made at 10:00 on 01/01/2012 "