public static function get_currency_symbol($currency)
 {
     if (empty($currency)) {
         return false;
     }
     if (!self::$_currency_symbols) {
         self::$_currency_symbols = apply_filters('app-template-currency_symbols', array('AUD' => __('AUD', 'appointments'), 'BRL' => __('BRL', 'appointments'), 'CAD' => __('CAD', 'appointments'), 'CHF' => __('CHF', 'appointments'), 'CZK' => __('CZK', 'appointments'), 'DKK' => __('DKK', 'appointments'), 'EUR' => __('EUR', 'appointments'), 'GBP' => __('GBP', 'appointments'), 'ILS' => __('ILS', 'appointments'), 'HKD' => __('HKD', 'appointments'), 'HUF' => __('HUF', 'appointments'), 'JPY' => __('JPY', 'appointments'), 'MYR' => __('MYR', 'appointments'), 'MXN' => __('MXN', 'appointments'), 'NOK' => __('NOK', 'appointments'), 'NZD' => __('NZD', 'appointments'), 'PHP' => __('PHP', 'appointments'), 'PLN' => __('PLN', 'appointments'), 'SEK' => __('SEK', 'appointments'), 'SGD' => __('SGD', 'appointments'), 'TWD' => __('TWD', 'appointments'), 'THB' => __('THB', 'appointments'), 'TRY' => __('TRY', 'appointments'), 'USD' => __('USD', 'appointments')));
     }
     return !empty(self::$_currency_symbols[$currency]) ? self::$_currency_symbols[$currency] : false;
 }
Exemplo n.º 2
0
?>
				<input value="<?php 
echo esc_attr($rn_subject);
?>
" size="90" name="removal_notification_subject" type="text" />
			</td>
		</tr>

		<tr>
			<th scope="row"><?php 
_e('Removal Notification Email Message', 'appointments');
?>
</th>
			<td>
				<?php 
$rn_msg = !empty($appointments->options['removal_notification_message']) ? $appointments->options['removal_notification_message'] : App_Template::get_default_removal_notification_message();
?>
				<textarea cols="90" name="removal_notification_message"><?php 
echo esc_textarea($rn_msg);
?>
</textarea>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row" ><?php 
_e('Log Sent email Records', 'appointments');
?>
</th>
			<td colspan="2">
				<select name="log_emails">
 public function process_shortcode($args = array(), $content = '')
 {
     extract(wp_parse_args($args, $this->_defaults_to_args()));
     global $post, $current_user, $appointments;
     if ('Payment for SERVICE' == $item_name && (isset($appointments->options["percent_deposit"]) && $appointments->options["percent_deposit"] || isset($appointments->options["fixed_deposit"]) && $appointments->options["fixed_deposit"])) {
         $item_name = __('Deposit for SERVICE', 'appointments');
     }
     $item_name = apply_filters('app_paypal_item_name', $item_name);
     // Let's be on the safe side and select the default currency
     if (empty($appointments->options['currency'])) {
         $appointments->options['currency'] = 'USD';
     }
     if (!isset($appointments->options["return"]) || !($return = get_permalink($appointments->options["return"]))) {
         $return = get_permalink($post->ID);
     }
     // Never let an undefined page, just in case
     if (!$return) {
         $return = home_url();
     }
     $return = apply_filters('app_paypal_return', $return);
     $cancel_return = apply_filters('app_paypal_cancel_return', get_option('home'));
     $form = '';
     $form .= '<div class="appointments-paypal">';
     if ($appointments->options['mode'] == 'live') {
         $form .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
     } else {
         $form .= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
     }
     $form .= '<input type="hidden" name="business" value="' . esc_attr($appointments->options['merchant_email']) . '" />';
     $form .= '<input type="hidden" name="cmd" value="_xclick">';
     $form .= '<input type="hidden" class="app_item_name" name="item_name" value="' . $item_name . '" />';
     $form .= '<input type="hidden" name="no_shipping" value="1" />';
     $form .= '<input type="hidden" name="currency_code" value="' . $appointments->options['currency'] . '" />';
     $form .= '<input type="hidden" name="return" value="' . $return . '" />';
     $form .= '<input type="hidden" name="cancel_return" value="' . $cancel_return . '" />';
     $form .= '<input type="hidden" name="notify_url" value="' . admin_url('admin-ajax.php?action=app_paypal_ipn') . '" />';
     $form .= '<input type="hidden" name="src" value="0" />';
     $form .= '<input class="app_custom" type="hidden" name="custom" value="" />';
     $form .= '<input class="app_amount" type="hidden" name="amount" value="" />';
     $form .= '<input class="app_submit_btn';
     // Add a class if user not logged in. May be required for addons.
     if (!is_user_logged_in()) {
         $form .= ' app_not_loggedin';
     }
     $display_currency = App_Template::get_currency_symbol($appointments->options["currency"]);
     $form .= '" type="submit" name="submit_btn" value="' . str_replace(array("CURRENCY"), array($display_currency), $button_text) . '" />';
     // They say Paypal uses this for tracking. I would prefer to remove it if it is not mandatory.
     $form .= '<img style="display:none" alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" />';
     $form = apply_filters('app_paypal_additional_fields', $form, $appointments->location, $appointments->service, $appointments->worker);
     $form .= '</form>';
     $form .= '</div>';
     return $form;
 }
Exemplo n.º 4
0
$appointments->myapps($type);
?>
	<br />
	<br />
	<form action="<?php 
echo admin_url('admin-ajax.php?action=app_export');
?>
" method="post">
		<input type="hidden" name="action" value="app_export" />
		<input type="hidden" name="export_type" id="app-export_type" value="type" />
		<input type="submit" id="app-export-selected" class="app-export_trigger button-secondary" value="<?php 
esc_attr_e(__('Export selected Appointments', 'appointments'));
?>
" />
		<input type="submit" id="app-export-type" class="app-export_trigger button-primary" value="<?php 
esc_attr_e(sprintf(__('Export %s Appointments', 'appointments'), App_Template::get_status_name($type)));
?>
" data-type="<?php 
esc_attr_e($type);
?>
" />
		<input type="submit" id="app-export-all" class="app-export_trigger button-secondary" value="<?php 
_e('Export all Appointments', 'appointments');
?>
" title="<?php 
_e('If you click this button a CSV file containing ALL appointment records will be saved on your PC', 'appointments');
?>
" />
<script>
(function ($) {
function toggle_selected_export () {
Exemplo n.º 5
0
 function inline_edit()
 {
     $safe_date_format = $this->safe_date_format();
     // Make a locale check to update locale_error flag
     $date_check = $this->to_us(date_i18n($safe_date_format, strtotime('today')));
     global $wpdb;
     $app_id = $_POST["app_id"];
     if ($app_id) {
         $app = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$this->app_table} WHERE ID=%d", $app_id));
         $start_date_timestamp = date("Y-m-d", strtotime($app->start));
         if ($this->locale_error) {
             $start_date = date($safe_date_format, strtotime($app->start));
         } else {
             $start_date = date_i18n($safe_date_format, strtotime($app->start));
         }
         $start_time = date_i18n($this->time_format, strtotime($app->start));
         $end_datetime = date_i18n($this->datetime_format, strtotime($app->end));
         // Is this a registered user?
         if ($app->user) {
             $name = get_user_meta($app->user, 'app_name', true);
             if ($name) {
                 $app->name = $app->name && !(defined('APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES') && APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES) ? $app->name : $name;
             }
             $email = get_user_meta($app->user, 'app_email', true);
             if ($email) {
                 $app->email = $app->email && !(defined('APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES') && APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES) ? $app->email : $email;
             }
             $phone = get_user_meta($app->user, 'app_phone', true);
             if ($phone) {
                 $app->phone = $app->phone && !(defined('APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES') && APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES) ? $app->phone : $phone;
             }
             $address = get_user_meta($app->user, 'app_address', true);
             if ($address) {
                 $app->address = $app->address && !(defined('APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES') && APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES) ? $app->address : $address;
             }
             $city = get_user_meta($app->user, 'app_city', true);
             if ($city) {
                 $app->city = $app->city && !(defined('APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES') && APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES) ? $app->city : $city;
             }
         }
     } else {
         $app = new stdClass();
         // This means insert a new app object
         /*
         //DO NOT DO THIS!!!!
         //This is just begging for a race condition issue >.<
         			// Get maximum ID
         			$app_max = $wpdb->get_var( "SELECT MAX(ID) FROM " . $this->app_table . " " );
         			// Check if nothing has saved yet
         			if ( !$app_max )
         				$app_max = 0;
         			$app->ID = $app_max + 1 ; // We want to create a new record
         */
         $app->ID = 0;
         // Set other fields to default so that we don't get notice messages
         $app->user = $app->location = $app->worker = 0;
         $app->created = $app->end = $app->name = $app->email = $app->phone = $app->address = $app->city = $app->status = $app->sent = $app->sent_worker = $app->note = '';
         // Get first service and its price
         $app->service = $this->get_first_service_id();
         $_REQUEST['app_service_id'] = $app->service;
         $_REQUEST['app_provider_id'] = 0;
         $app->price = $this->get_price();
         // Select time as next 1 hour
         $start_time = date_i18n($this->time_format, intval(($this->local_time + 60 * $this->get_min_time()) / 3600) * 3600);
         $start_date_timestamp = date("Y-m-d", $this->local_time + 60 * $this->get_min_time());
         // Set start date as now + 60 minutes.
         if ($this->locale_error) {
             $start_date = date($safe_date_format, $this->local_time + 60 * $this->get_min_time());
         } else {
             $start_date = date_i18n($safe_date_format, $this->local_time + 60 * $this->get_min_time());
         }
     }
     $html = '';
     $html .= '<tr class="inline-edit-row inline-edit-row-post quick-edit-row-post">';
     if (isset($_POST["col_len"])) {
         $html .= '<td colspan="' . $_POST["col_len"] . '" class="colspanchange">';
     } else {
         $html .= '<td colspan="6" class="colspanchange">';
     }
     $html .= '<fieldset class="inline-edit-col-left" style="width:33%">';
     $html .= '<div class="inline-edit-col">';
     $html .= '<h4>' . __('CLIENT', 'appointments') . '</h4>';
     /* user */
     $html .= '<label>';
     $html .= '<span class="title">' . __('User', 'appointments') . '</span>';
     $html .= wp_dropdown_users(array('show_option_all' => __('Not registered user', 'appointments'), 'show' => 'user_login', 'echo' => 0, 'selected' => $app->user, 'name' => 'user'));
     $html .= '</label>';
     /* Client name */
     $html .= '<label>';
     $html .= '<span class="title">' . $this->get_field_name('name') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="text" name="cname" class="ptitle" value="' . stripslashes($app->name) . '" />';
     $html .= '</span>';
     $html .= '</label>';
     /* Client email */
     $html .= '<label>';
     $html .= '<span class="title">' . $this->get_field_name('email') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="text" name="email" class="ptitle" value="' . $app->email . '" />';
     $html .= '</span>';
     $html .= '</label>';
     /* Client Phone */
     $html .= '<label>';
     $html .= '<span class="title">' . $this->get_field_name('phone') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="text" name="phone" class="ptitle" value="' . stripslashes($app->phone) . '" />';
     $html .= '</span>';
     $html .= '</label>';
     /* Client Address */
     $html .= '<label>';
     $html .= '<span class="title">' . $this->get_field_name('address') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="text" name="address" class="ptitle" value="' . stripslashes($app->address) . '" />';
     $html .= '</span>';
     $html .= '</label>';
     /* Client City */
     $html .= '<label>';
     $html .= '<span class="title">' . $this->get_field_name('city') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="text" name="city" class="ptitle" value="' . stripslashes($app->city) . '" />';
     $html .= '</span>';
     $html .= '</label>';
     $html .= apply_filters('app-appointments_list-edit-client', '', $app);
     $html .= '</div>';
     $html .= '</fieldset>';
     $html .= '<fieldset class="inline-edit-col-center" style="width:28%">';
     $html .= '<div class="inline-edit-col">';
     $html .= '<h4>' . __('SERVICE', 'appointments') . '</h4>';
     /* Services */
     $services = $this->get_services();
     $html .= '<label>';
     $html .= '<span class="title">' . __('Name', 'appointments') . '</span>';
     $html .= '<select name="service">';
     if ($services) {
         foreach ($services as $service) {
             if ($app->service == $service->ID) {
                 $sel = ' selected="selected"';
             } else {
                 $sel = '';
             }
             $html .= '<option value="' . $service->ID . '"' . $sel . '>' . stripslashes($service->name) . '</option>';
         }
     }
     $html .= '</select>';
     $html .= '</label>';
     /* Workers */
     $workers = $wpdb->get_results("SELECT * FROM " . $this->workers_table . " ");
     $html .= '<label>';
     $html .= '<span class="title">' . __('Provider', 'appointments') . '</span>';
     $html .= '<select name="worker">';
     // Always add an "Our staff" field
     $html .= '<option value="0">' . __('No specific provider', 'appointments') . '</option>';
     if ($workers) {
         foreach ($workers as $worker) {
             if ($app->worker == $worker->ID) {
                 $sel = ' selected="selected"';
             } else {
                 $sel = '';
             }
             $html .= '<option value="' . $worker->ID . '"' . $sel . '>' . $this->get_worker_name($worker->ID, false) . '</option>';
         }
     }
     $html .= '</select>';
     $html .= '</label>';
     /* Price */
     $html .= '<label>';
     $html .= '<span class="title">' . __('Price', 'appointments') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="text" name="price" style="width:50%" class="ptitle" value="' . $app->price . '" />';
     $html .= '</span>';
     $html .= '</label>';
     $html .= '</label>';
     $html .= apply_filters('app-appointments_list-edit-services', '', $app);
     $html .= '</div>';
     $html .= '</fieldset>';
     $html .= '<fieldset class="inline-edit-col-right" style="width:38%">';
     $html .= '<div class="inline-edit-col">';
     $html .= '<h4>' . __('APPOINTMENT', 'appointments') . '</h4>';
     /* Created - Don't show for a new app */
     if ($app_id) {
         $html .= '<label>';
         $html .= '<span class="title">' . __('Created', 'appointments') . '</span>';
         $html .= '<span class="input-text-wrap" style="height:26px;padding-top:4px;">';
         $html .= date_i18n($this->datetime_format, strtotime($app->created));
         $html .= '</span>';
         $html .= '</label>';
     }
     /* Start */
     $html .= '<label style="float:left;width:65%">';
     $html .= '<span class="title">' . __('Start', 'appointments') . '</span>';
     $html .= '<span class="input-text-wrap" >';
     $html .= '<input type="text" name="date" class="datepicker" size="12" value="' . $start_date . '" data-timestamp="' . esc_attr($start_date_timestamp) . '"  />';
     $html .= '</label>';
     $html .= '<label style="float:left;width:30%; padding-left:5px;">';
     // Check if an admin min time (time base) is set. @since 1.0.2
     if (isset($this->options["admin_min_time"]) && $this->options["admin_min_time"]) {
         $min_time = $this->options["admin_min_time"];
     } else {
         $min_time = $this->get_min_time();
     }
     $min_secs = 60 * apply_filters('app_admin_min_time', $min_time);
     $html .= '<select name="time" >';
     for ($t = 0; $t < 3600 * 24; $t = $t + $min_secs) {
         $dhours = $this->secs2hours($t);
         // Hours in 08:30 format
         if ($dhours == $start_time) {
             $s = " selected='selected'";
         } else {
             $s = '';
         }
         $html .= '<option' . $s . '>';
         $html .= $dhours;
         $html .= '</option>';
     }
     $html .= '</select>';
     $html .= '</span>';
     $html .= '</label>';
     $html .= '<div style="clear:both; height:0"></div>';
     /* End - Don't show for a new app */
     if ($app_id) {
         $html .= '<label style="margin-top:8px">';
         $html .= '<span class="title">' . __('End', 'appointments') . '</span>';
         $html .= '<span class="input-text-wrap" style="height:26px;padding-top:4px;">';
         $html .= $end_datetime;
         $html .= '</span>';
         $html .= '</label>';
     }
     /* Note */
     $html .= '<label>';
     $html .= '<span class="title">' . $this->get_field_name('note') . '</span>';
     $html .= '<textarea cols="22" rows=1">';
     $html .= stripslashes($app->note);
     $html .= '</textarea>';
     $html .= '</label>';
     /* Status */
     //$statuses = $this->get_statuses();
     $statuses = App_Template::get_status_names();
     $html .= '<label>';
     $html .= '<span class="title">' . __('Status', 'appointments') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<select name="status">';
     if ($statuses) {
         foreach ($statuses as $status => $status_name) {
             if ($app->status == $status) {
                 $sel = ' selected="selected"';
             } else {
                 $sel = '';
             }
             $html .= '<option value="' . $status . '"' . $sel . '>' . $status_name . '</option>';
         }
     }
     $html .= '</select>';
     $html .= '</span>';
     $html .= '</label>';
     /* Confirmation email */
     // Default is "checked" for a new appointment
     if ($app_id) {
         $c = '';
         $text = __('(Re)send confirmation email', 'appointments');
     } else {
         $c = ' checked="checked"';
         $text = __('Send confirmation email', 'appointments');
     }
     $html .= '<label>';
     $html .= '<span class="title">' . __('Confirm', 'appointments') . '</span>';
     $html .= '<span class="input-text-wrap">';
     $html .= '<input type="checkbox" name="resend" value="1" ' . $c . ' />&nbsp;' . $text;
     $html .= '</span>';
     $html .= '</label>';
     $html .= '</div>';
     $html .= '</fieldset>';
     /* General fields required for save and cancel */
     $html .= '<p class="submit inline-edit-save">';
     $html .= '<a href="javascript:void(0)" title="' . _x('Cancel', 'Drop current action', 'appointments') . '" class="button-secondary cancel alignleft">' . _x('Cancel', 'Drop current action', 'appointments') . '</a>';
     if ('reserved' == $app->status) {
         $js = 'style="display:none"';
         $title = __('GCal reserved appointments cannot be edited here. Edit them in your Google calendar.', 'appointments');
     } else {
         $js = 'href="javascript:void(0)"';
         $title = __('Click to save or update', 'appointments');
     }
     $html .= '<a ' . $js . ' title="' . $title . '" class="button-primary save alignright">' . __('Save / Update', 'appointments') . '</a>';
     $html .= '<img class="waiting" style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" alt="">';
     $html .= '<input type="hidden" name="app_id" value="' . $app->ID . '">';
     $html .= '<span class="error" style="display:none"></span>';
     $html .= '<br class="clear">';
     $html .= '</p>';
     $html .= '</td>';
     $html .= '</tr>';
     die(json_encode(array('result' => $html)));
 }
    public function process_shortcode($args = array(), $content = '')
    {
        extract(wp_parse_args($args, $this->_defaults_to_args()));
        global $wpdb, $current_user, $bp, $appointments;
        $statuses = explode(',', $status);
        if (!is_array($statuses) || empty($statuses)) {
            return '';
        }
        if (!trim($order_by)) {
            $order_by = 'ID';
        }
        $stat = '';
        foreach ($statuses as $s) {
            // Allow only defined stats
            if (array_key_exists(trim($s), App_Template::get_status_names())) {
                $stat .= " status='" . trim($s) . "' OR ";
            }
        }
        $stat = rtrim($stat, "OR ");
        // If this is a client shortcode
        if (!$provider) {
            if (isset($_COOKIE["wpmudev_appointments"])) {
                $apps = unserialize(stripslashes($_COOKIE["wpmudev_appointments"]));
            } else {
                $apps = array();
            }
            if (!is_array($apps)) {
                return '';
            }
            $provider_or_client = __('Provider', 'appointments');
            $q = '';
            if ($strict) {
                // Strict matching
                if (is_user_logged_in()) {
                    $q = "user={$current_user->ID}";
                    // If the user is logged in, show just those apps
                } else {
                    // Otherwise, deal with the cookie-cached ones
                    $apps = array_values(array_filter(array_map('intval', $apps)));
                    if (!empty($apps)) {
                        $q = "ID IN(" . join(',', $apps) . ")";
                    }
                }
            } else {
                // Non-strict matching
                foreach ($apps as $app_id) {
                    if (is_numeric($app_id)) {
                        $q .= " ID=" . $app_id . " OR ";
                    }
                }
                $q = rtrim($q, "OR ");
                // But he may as well has appointments added manually (requires being registered user)
                if (is_user_logged_in()) {
                    $q .= " OR user="******" OR");
                }
            }
            if ($q && $stat) {
                $results = $wpdb->get_results("SELECT * FROM " . $appointments->app_table . " WHERE (" . $q . ") AND (" . $stat . ") ORDER BY " . $appointments->sanitize_order_by($order_by));
            } else {
                $results = false;
            }
        } else {
            $provider_or_client = __('Client', 'appointments');
            // If no id is given, get current user
            if (!$provider_id) {
                $provider_id = $current_user->ID;
            }
            // Special case: If this is a single provider website, show staff appointments in his schedule too
            $workers = $appointments->get_workers();
            if (App_Roles::current_user_can('manage_options', App_Roles::CTX_STAFF) && ($workers && count($workers) == 1 || !$workers)) {
                $provider_id .= ' OR worker=0';
            }
            $results = $wpdb->get_results("SELECT * FROM " . $appointments->app_table . " WHERE (worker=" . $provider_id . ") AND (" . $stat . ") ORDER BY " . $order_by . " ");
        }
        // Can worker confirm pending appointments?
        if ($_allow_confirm && appointments_is_worker($current_user->ID) && isset($appointments->options['allow_worker_confirm']) && 'yes' == $appointments->options['allow_worker_confirm']) {
            $allow_confirm = true;
        } else {
            $allow_confirm = false;
        }
        // Can client cancel appointments?
        if ($allow_cancel && !$provider && isset($appointments->options['allow_cancel']) && 'yes' == $appointments->options['allow_cancel']) {
            $a_cancel = true;
        } else {
            $a_cancel = false;
        }
        $ret = '';
        $ret .= '<div class="appointments-my-appointments">';
        // Make this a form for BP if confirmation is allowed, but not on admin side user profile page
        if ($this->_can_display_editable($allow_confirm)) {
            $ret .= '<form method="post">';
        }
        $ret .= $title;
        $ret = apply_filters('app_my_appointments_before_table', $ret);
        $ret .= '<table class="my-appointments tablesorter"><thead>';
        $ret .= apply_filters('app_my_appointments_column_name', '<th class="my-appointments-service">' . __('Service', 'appointments') . '</th><th class="my-appointments-worker">' . $provider_or_client . '</th><th class="my-appointments-date">' . __('Date/time', 'appointments') . '</th><th class="my-appointments-status">' . __('Status', 'appointments') . '</th>');
        $colspan = 4;
        if ($allow_confirm) {
            $ret .= '<th class="my-appointments-confirm">' . __('Confirm', 'appointments') . '</th>';
            $colspan++;
        }
        if ($a_cancel) {
            $ret .= '<th class="my-appointments-cancel">' . _x('Cancel', 'Discard existing info', 'appointments') . '</th>';
            $colspan++;
        }
        if ($gcal && 'yes' == $appointments->options['gcal']) {
            $ret .= '<th class="my-appointments-gcal">&nbsp;</th>';
            $colspan++;
        }
        $ret .= '</thead><tbody>';
        if ($results) {
            foreach ($results as $r) {
                $ret .= '<tr><td>';
                $ret .= $appointments->get_service_name($r->service) . '</td>';
                $ret .= apply_filters('app-shortcode-my_appointments-after_service', '', $r);
                $ret .= '<td>';
                if (!$provider) {
                    $ret .= $appointments->get_worker_name($r->worker) . '</td>';
                } else {
                    $ret .= $appointments->get_client_name($r->ID) . '</td>';
                }
                $ret .= apply_filters('app-shortcode-my_appointments-after_worker', '', $r);
                $ret .= '<td>';
                $ret .= date_i18n($appointments->datetime_format, strtotime($r->start)) . '</td>';
                $ret .= apply_filters('app-shortcode-my_appointments-after_date', '', $r);
                $ret .= '<td>';
                $ret .= App_Template::get_status_name($r->status);
                $ret .= '</td>';
                $ret .= apply_filters('app-shortcode-my_appointments-after_status', '', $r);
                // If allowed so, a worker can confirm an appointment himself
                if ($allow_confirm) {
                    if ('pending' == $r->status) {
                        $is_readonly = '';
                    } else {
                        $is_readonly = ' readonly="readonly"';
                    }
                    $ret .= '<td><input class="app-my-appointments-confirm" type="checkbox" name="app_confirm[' . $r->ID . ']" ' . $is_readonly . ' /></td>';
                }
                // If allowed so, a client can cancel an appointment
                if ($a_cancel) {
                    // We don't want completed appointments to be cancelled
                    $stat = $r->status;
                    $in_allowed_stat = apply_filters('app_cancel_allowed_status', 'pending' == $stat || 'confirmed' == $stat || 'paid' == $stat, $stat, $r->ID);
                    if ($in_allowed_stat) {
                        $is_readonly = '';
                    } else {
                        $is_readonly = ' readonly="readonly"';
                    }
                    $ret .= '<td><input class="app-my-appointments-cancel" type="checkbox" name="app_cancel[' . $r->ID . ']" ' . $is_readonly . ' /></td>';
                }
                if ($gcal && 'yes' == $appointments->options['gcal']) {
                    if (isset($appointments->options["gcal_same_window"]) && $appointments->options["gcal_same_window"]) {
                        $target = '_self';
                    } else {
                        $target = '_blank';
                    }
                    $ret .= '<td><a title="' . __('Click to submit this appointment to your Google Calendar account', 'appointments') . '" href="' . $appointments->gcal($r->service, strtotime($r->start, $appointments->local_time), strtotime($r->end, $appointments->local_time), true, $r->address, $r->city) . '" target="' . $target . '">' . $appointments->gcal_image . '</a></td>';
                }
                $ret .= apply_filters('app_my_appointments_add_cell', '', $r);
                $ret .= '</tr>';
            }
        } else {
            $ret .= '<tr><td colspan="' . $colspan . '">' . __('No appointments', 'appointments') . '</td></tr>';
        }
        $ret .= '</tbody></table>';
        $ret = apply_filters('app_my_appointments_after_table', $ret, $results);
        if ($this->_can_display_editable($allow_confirm)) {
            $ret .= '<div class="submit">' . '<input type="submit" name="app_bp_settings_submit" value="' . esc_attr(__('Submit Confirm', 'appointments')) . '" class="auto">' . '<input type="hidden" name="app_bp_settings_user" value="' . esc_attr($bp->displayed_user->id) . '">' . wp_nonce_field('app_bp_settings_submit', 'app_bp_settings_submit', true, false) . '</div>';
            $ret .= '</form>';
        }
        $ret .= '</div>';
        $sorter = 'usLongDate';
        $dateformat = 'us';
        // Search for formats where day is at the beginning
        if (stripos(str_replace(array('/', '-'), '', $appointments->date_format), 'dmY') !== false) {
            $sorter = 'shortDate';
            $dateformat = 'uk';
        }
        // Sort table from front end
        if ($_tablesorter && file_exists($appointments->plugin_dir . '/js/jquery.tablesorter.min.js')) {
            $appointments->add2footer('
				$(".my-appointments").tablesorter({
					dateFormat: "' . $dateformat . '",
					headers: {
						2: {
							sorter:"' . $sorter . '"
						}
					}
				});
				$("th.my-appointments-gcal,th.my-appointments-confirm,th.my-appointments-cancel").removeClass("header");

				$(".app-my-appointments-cancel").change( function() {
					if ( $(this).is(":checked") ) {
						var cancel_box = $(this);
						if ( !confirm("' . esc_js(__("Are you sure you want to cancel the selected appointment?", "appointments")) . '") ) {
							cancel_box.attr("checked", false);
							return false;
						}
						else{
							var cancel_id = $(this).attr("name").replace("app_cancel[","").replace("]","");
							if (cancel_id) {
								var cancel_data = {action: "cancel_app", app_id: cancel_id, cancel_nonce: "' . wp_create_nonce() . '"};
								$.post(_appointments_data.ajax_url, cancel_data, function(response) {
									if (response && response.error ) {
										cancel_box.attr("disabled",true);
										alert(response.error);
									}
									else if (response && response.success) {
										alert("' . esc_js(__("Selected appointment cancelled.", "appointments")) . '");
										cancel_box.closest("tr").css("opacity","0.3");
										cancel_box.attr("disabled",true);
									}
									else {
										cancel_box.attr("disabled",true);
										alert("' . esc_js(__("A connection error occurred.", "appointments")) . '");
									}
								}, "json");
							}
						}
					}

				});');
        }
        return $ret;
    }
        ?>
						</td>
						<td class="column-service">
							<?php 
        echo $appointments->get_service_name($app->service);
        ?>
						</td>
						<td class="column-worker">
							<?php 
        echo $appointments->get_worker_name($app->worker);
        ?>
						</td>
						<td class="column-status">
							<?php 
        if (!empty($app->status)) {
            echo App_Template::get_status_name($app->status);
        } else {
            echo __('None yet', 'appointments');
        }
        ?>
						</td>
						<td class="column-status">
							<?php 
        echo $app->coupon;
        ?>
						</td>
					</tr>
					<?php 
    }
} else {
    $columncount = count($columns);
Exemplo n.º 8
0
 function render(App_Grid_Filter $filter, $exportLayout, $page, $fileName, App_Template $template)
 {
     $pdf = new mypdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->caption = $this->caption;
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 048');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 048', PDF_HEADER_STRING);
     // set header and footer fonts
     //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetMargins(2, 0, 5);
     //$pdf->SetHeaderMargin(2);
     //$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     //$pdf->setLanguageArray($l);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', 'B', 20);
     // add a page
     // -----------------------------------------------------------------------------
     // -----------------------------------------------------------------------------
     $totalpage = $this->filter()->getTotalPage();
     if ($page == 'all') {
         $startPage = 1;
         $endPage = $totalpage;
     } elseif (is_array($page)) {
         $startPage = (int) $page['0'];
         $endPage = (int) $page['1'];
     } elseif (is_numeric($page)) {
         $startPage = $endPage = (int) $page;
     }
     if ($startPage < 0) {
         $startPage = 1;
     }
     if ($endPage == '') {
         $endPage = $startPage;
     }
     if ($endPage > $totalpage) {
         $endPage = $totalpage;
     }
     for ($i = $startPage; $i <= $endPage; $i++) {
         $filter->setPage($i);
         $list = $filter->getList();
         foreach ($list as $id => $row) {
             $pdf->AddPage($exportLayout);
             $pdf->SetFont('freeserif', '', 7);
             $pdf->SetX(5);
             $pdf->SetY(10);
             $mConfig = $filter->getModelConfig();
             $fileds = $mConfig->getFieldsList();
             foreach ($fileds as $filed) {
                 //echo $filed->input;
                 $prop = $mConfig->getPropByName($filed);
                 if ($prop->input == 'filepicker') {
                     $file = new Sys_Model_File();
                     $name = basename($row->{$filed});
                     $file = $file->fetchRow($file->select()->where("NAME=?", $name));
                     $template->assign($filed, $file->getPath());
                 } else {
                     $template->assign($filed, $this->filter()->fieldTranform($row, $filed));
                 }
                 $template->assign($filed . ":label", $this->_translate($prop->label));
             }
             $tbl = $template->getOutput();
             $pdf->writeHTML($tbl, true, true, false, false, '');
         }
     }
     //Close and output PDF document
     if ('' == $fileName) {
         $fileName = uniqid();
     }
     $filePath = App_Env::getPathOfUserTemporaryFolder() . "/" . $fileName . '.pdf';
     $pdf->Output($filePath, 'F');
     $pdf->Output(null, 'I');
     //============================================================+
     // END OF FILE
     //============================================================+
 }
 /**
  * Check and return necessary fields to the front end
  * @return json object
  */
 function pre_confirmation()
 {
     global $appointments;
     $values = explode(":", $_POST["value"]);
     $location = $values[0];
     $service = $values[1];
     $worker = $values[2];
     $start = $values[3];
     $end = $values[4];
     // A little trick to pass correct lsw variables to the get_price, is_busy and get_capacity functions
     $_REQUEST["app_location_id"] = $location;
     $_REQUEST["app_service_id"] = $service;
     $_REQUEST["app_provider_id"] = $worker;
     $appointments->get_lsw();
     // Alright, so before we go further, let's check if we can
     if (!is_user_logged_in() && (!empty($appointments->options['login_required']) && 'yes' == $appointments->options['login_required'])) {
         die(json_encode(array('error' => __('You need to login to make an appointment.', 'appointments'))));
     }
     $price = $appointments->get_price();
     // It is possible to apply special discounts
     $price = apply_filters('app_display_amount', $price, $service, $worker);
     $price = apply_filters('app_pre_confirmation_price', $price, $service, $worker, $start, $end);
     $display_currency = !empty($appointments->options["currency"]) ? App_Template::get_currency_symbol($appointments->options["currency"]) : App_Template::get_currency_symbol('USD');
     if ($appointments->is_busy($start, $end, $appointments->get_capacity())) {
         die(json_encode(array("error" => apply_filters('app_booked_message', __('We are sorry, but this time slot is no longer available. Please refresh the page and try another time slot. Thank you.', 'appointments')))));
     }
     $service_obj = $appointments->get_service($service);
     $service = '<label><span>' . __('Service name: ', 'appointments') . '</span>' . apply_filters('app_confirmation_service', stripslashes($service_obj->name), $service_obj->name) . '</label>';
     $start = '<label><span>' . __('Date and time: ', 'appointments') . '</span>' . apply_filters('app_confirmation_start', date_i18n($appointments->datetime_format, $start), $start) . '</label>';
     $end = '<label><span>' . __('Lasts (approx): ', 'appointments') . '</span>' . apply_filters('app_confirmation_lasts', $service_obj->duration . " " . __('minutes', 'appointments'), $service_obj->duration) . '</label>';
     $price = $price > 0 ? '<label><span>' . __('Price: ', 'appointments') . '</span>' . apply_filters('app_confirmation_price', $price . " " . $display_currency, $price) . '</label>' : 0;
     $worker = !empty($worker) ? '<label><span>' . __('Service provider: ', 'appointments') . '</span>' . apply_filters('app_confirmation_worker', stripslashes($appointments->get_worker_name($worker)), $worker) . '</label>' : '';
     $ask_name = !empty($appointments->options['ask_name']) ? 'ask' : '';
     $ask_email = !empty($appointments->options['ask_email']) ? 'ask' : '';
     $ask_phone = !empty($appointments->options['ask_phone']) ? 'ask' : '';
     $ask_address = !empty($appointments->options['ask_address']) ? 'ask' : '';
     $ask_city = !empty($appointments->options['ask_city']) ? 'ask' : '';
     $ask_note = !empty($appointments->options['ask_note']) ? 'ask' : '';
     $ask_gcal = isset($appointments->options["gcal"]) && 'yes' == $appointments->options["gcal"] ? 'ask' : '';
     $reply_array = array('service' => $service, 'worker' => $worker, 'start' => $start, 'end' => $end, 'price' => $price, 'name' => $ask_name, 'email' => $ask_email, 'phone' => $ask_phone, 'address' => $ask_address, 'city' => $ask_city, 'note' => $ask_note, 'gcal' => $ask_gcal);
     $reply_array = apply_filters('app_pre_confirmation_reply', $reply_array);
     die(json_encode($reply_array));
 }
    /**
     * Admin settings HTML code
     */
    function settings()
    {
        global $appointments;
        if (!App_Roles::current_user_can('manage_options', App_Roles::CTX_PAGE_SETTINGS)) {
            wp_die(__('You do not have sufficient permissions to access this page.', 'appointments'));
        }
        $appointments->get_lsw();
        global $wpdb;
        ?>
		<div class="wrap">
			<div class="icon32" style="margin:10px 0 0 0"><img src="<?php 
        echo $appointments->plugin_url . '/images/general.png';
        ?>
" /></div>
			<h2><?php 
        echo __('Appointments+ Settings', 'appointments');
        ?>
</h2>
			<h3 class="nav-tab-wrapper">
				<?php 
        $tab = !empty($_GET['tab']) ? $_GET['tab'] : 'main';
        $tabs = array('gcal' => __('Google Calendar', 'appointments'), 'working_hours' => __('Working Hours', 'appointments'), 'exceptions' => __('Exceptions', 'appointments'), 'services' => __('Services', 'appointments'), 'workers' => __('Service Providers', 'appointments'), 'addons' => __('Add-ons', 'appointments'), 'log' => __('Logs', 'appointments'));
        $tabhtml = array();
        // If someone wants to remove or add a tab
        $tabs = apply_filters('appointments_tabs', $tabs);
        $class = 'main' == $tab ? ' nav-tab-active' : '';
        $tabhtml[] = '	<a href="' . admin_url('admin.php?page=app_settings') . '" class="nav-tab' . $class . '">' . __('General', 'appointments') . '</a>';
        foreach ($tabs as $stub => $title) {
            $class = $stub == $tab ? ' nav-tab-active' : '';
            $tabhtml[] = '	<a href="' . admin_url('admin.php?page=app_settings&amp;tab=' . $stub) . '" class="nav-tab' . $class . '" id="app_tab_' . $stub . '">' . $title . '</a>';
        }
        echo implode("\n", $tabhtml);
        ?>
			</h3>
			<div class="clear"></div>
			<?php 
        App_Template::admin_settings_tab($tab);
        ?>
		</div>
		<?php 
    }
 function mytransactions($type = 'past')
 {
     App_Template::admin_my_transactions_list($type);
 }