?
<?php
/**
* Includes Cmb2 Custom Html MetaBoxes Functions
*
*/
defined( 'ABSPATH' ) or exit; // Exit if accessed directly
/**
* Provider Work Schedule Markup
*/
function get_ga_provider_work_schedule_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->value();
$description = $field->args( 'description' );
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div class="cmb2-metabox-description"><?php echo $description; ?></div>
<?php
$schedule = new ga_work_schedule( $field->object_id );
echo $schedule->display_schedule( $name, $value );
?>
</div>
</div>
<?php
}
/**
* Provider Breaks Markup
* Needed for saving options
*/
function get_ga_provider_breaks_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->value();
$description = $field->args( 'description' );
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div class="cmb2-metabox-description"><?php echo $description; ?></div>
<?php
$schedule = new ga_work_schedule( $field->object_id );
echo $schedule->display_breaks( $name, $value );
?>
</div>
</div>
<?php
}
/**
* Provider Holidays Markup
*/
function get_ga_provider_holidays_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->value();
$description = $field->args( 'description' );
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div class="cmb2-metabox-description"><?php echo $description; ?></div>
<?php
if( !class_exists('ga_work_schedule') ) {
require_once( ga_base_path . '/admin/includes/ga_work_schedule.php' );
}
$schedule = new ga_work_schedule( $field->object_id );
echo $schedule->display_holidays($name, $value);
?>
</div>
</div>
<?php
}
/**
* Provider Calendar Schedule Markup
*/
function get_ga_provider_calendar_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->escaped_value();
$description = $field->args( 'description' );
$checked = isset( $value ) && $value == 'on' ? ' checked' : '';
//print_r( $value );
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?>">
<div class="cmb-th">
<label><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div class="ga_radio_switch">
<label><input type="radio" class="cmb2-option <?php echo $id; ?>" name="<?php echo $name; ?>" value="on" <?php echo checked( 'on', $value ); ?>><span class="ga-small-text">Yes</span></label>
<label><input type="radio" class="cmb2-option <?php echo $id; ?>" name="<?php echo $name; ?>" value="" <?php echo checked( '', $value ); ?>><span class="ga-small-text">No</span></label>
</div>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php
}
/**
* Validation: Appointment New Customer
*/
function get_ga_appointment_new_client_render_row($field_args, $field) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->escaped_value();
$description = $field->args( 'description' );
$before_row = $field->args( 'before_row' );
$client_name = isset($value['name']) ? $value['name'] : '';
$client_email = isset($value['email']) ? $value['email'] : '';
$client_phone = isset($value['phone']) ? $value['phone'] : '';
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?>">
<?php if ( !empty($before_row) ) {
$before_row = $field->args( 'before_row' );
echo '<h5>'.esc_html($before_row).'</h5>';
} ?>
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div><input type="text" class="regular-text" name="<?php echo $name; ?>[name]" id="<?php echo $id; ?>" value="<?php echo $client_name; ?>" placeholder="Full Name"></div>
<div><input type="text" class="regular-text" name="<?php echo $name; ?>[email]" id="<?php echo $id; ?>" value="<?php echo $client_email; ?>" placeholder="Email"></div>
<div><input type="text" class="regular-text" name="<?php echo $name; ?>[phone]" id="<?php echo $id; ?>" value="<?php echo $client_phone; ?>" placeholder="Phone"></div>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php }
/**
* Services Available Appointment Times Markup
*/
function get_ga_service_times_mode_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->escaped_value();
$description = $field->args( 'description' );
$before_row = $field->args( 'before_row' );
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div class="ga_radio_switch">
<label><input type="radio" class="cmb2-option <?php echo $id; ?>" name="<?php echo $name; ?>" value="interval" <?php echo checked( 'interval', $value ); ?>><span class="ga-large-text">Interval</label>
<label><input type="radio" class="cmb2-option <?php echo $id; ?>" name="<?php echo $name; ?>" value="custom" <?php echo checked( 'custom', $value ); ?>><span class="ga-large-text">Custom</span></label>
<label><input type="radio" class="cmb2-option <?php echo $id; ?>" name="<?php echo $name; ?>" value="no_slots" <?php echo checked( 'no_slots', $value ); ?>><span class="ga-large-text">Dates</span></label>
</div>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php
}
function get_ga_service_category_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->escaped_value();
$description = $field->args( 'description' );
$before_row = $field->args( 'before_row' );
?>
<div class="custom-field-row cmb2-id-<?php echo $id; ?>">
<p style="margin-top: 0px;"><?php echo $description; ?></p>
<div id="taxonomy-ga_service_cat" class="categorydiv">
<div class="ga-service-tabs-panel">
<!-- Need to if all categories are unchecked -->
<input type="hidden" name="tax_input[ga_service_cat][]" value="0">
<!-- Need to if all categories are unchecked -->
<ul id="ga_service_catchecklist" data-wp-lists="list:ga_service_cat" class="categorychecklist form-no-clear">
<?php
$services_cats = get_terms( 'ga_service_cat', array( 'parent' => '', 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC' ) );
$categories = '';
$sel_cats = wp_get_post_terms( $field->object_id, 'ga_service_cat', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'ids') );
if( $services_cats ) {
foreach ( $services_cats as $cat ) {
$checked = in_array($cat->term_id, $sel_cats) ? ' checked="checked"' : '';
$term_id = $cat->term_id;
$name = $cat->name;
$categories .= '<li><input type="checkbox" name="tax_input[ga_service_cat][]" id="ga_service_cat-' .$term_id. '" value="' .$term_id. '"'.$checked.'> <label class="selectit" for="ga_service_cat-' .$term_id. '">'. $name .'</label> <span class="ga_service_cat_delete" term-id="' .$term_id .'">Delete</span></li>';
}
}
echo $categories;
?>
</ul>
</div>
<div id="ga_service_cat-adder">
<div id="ga_service_cat-add">
<input type="text" name="newga_service_cat" id="newga_service_cat" class="form-required form-input-tip" value="" placeholder="New Category Name" aria-required="true">
<input type="button" id="ga_service_cat-add-submit" data-wp-lists="add:ga_service_catchecklist:ga_service_cat-add" class="button button-ga" value="Add New Category">
<?php wp_nonce_field( 'add-ga_service_cat', '_ajax_nonce-add-ga_service_cat', false ); ?>
<span id="ga_service_cat-ajax-response"></span>
</div>
</div>
</div>
</div>
<?php
}
/**
* Services Available Appointment Times Markup
*/
function get_ga_provider_services_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->escaped_value();
$description = $field->args( 'description' );
$before_row = $field->args( 'before_row' );
$provider_categories = (array) get_post_meta( $field->object_id, 'ga_provider_services', true );
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id; ?> cmb-inline">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div id="ga_time_slots_services" class="ga_mb_10">
<?php
$interval = ga_get_services_type_ids('interval');
$custom = ga_get_services_type_ids('custom');
$services = array_unique( array_merge( $interval, $custom ) );
if( $services ) {
echo '<div class="ga_services_type_title">TIME SLOTS</div>';
echo '<ul class="cmb2-checkbox-list no-select-all cmb2-list">';
foreach( $services as $service ) {
$checked = in_array($service, $provider_categories) ? ' checked="checked"' : '';
echo '<li><label class="ga_provider_service_slots"><input type="checkbox" class="cmb2-option ga_provider_service_type" name="ga_provider_services[]" value="'.$service.'"'.$checked.'> '.get_the_title($service).'</label></li>';
}
echo '</ul>';
}
?>
</div>
<div id="ga_dates_services">
<?php
$services = ga_get_services_type_ids('no_slots');
if( $services ) {
echo '<div class="ga_services_type_title">FULL DATES</div>';
echo '<ul class="cmb2-checkbox-list no-select-all cmb2-list">';
foreach( $services as $service ) {
$checked = in_array($service, $provider_categories) ? ' checked="checked"' : '';
echo '<li><label class="ga_provider_service_dates"><input type="checkbox" class="cmb2-option ga_provider_service_type" name="ga_provider_services[]" value="'.$service.'"'.$checked.'> '.get_the_title($service).'</label></li>';
}
echo '</ul>';
}
?>
</div>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php
}
/**
* Service Custom Days Period
*/
function get_ga_service_custom_dates_period_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->value();
$description = $field->args( 'description' );
$period_type = (string) get_post_meta( $field->object_id, 'ga_service_period_type', true );
$class = $period_type == 'custom_dates' ? '' : ' cmb2-hidden';
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id . $class; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td custom_dates_period">
<div id="custom_dates_period">
<div class="custom-date" style="display: none;">
<input type="text" class="cmb2-text-small ga-date-picker" value="" name="<?php echo $name; ?>[]" placeholder="Select date">
<span class="custom-date-delete"></span>
</div>
<?php
$days = $value;
if( $days ) {
foreach( $days as $day ) { ?>
<div class="custom-date">
<input type="text" class="cmb2-text-small ga-date-picker" value="<?php echo $day; ?>" name="<?php echo $name; ?>[]" placeholder="Select date">
<span class="custom-date-delete"></span>
</div>
<?php
}
} ?>
</div>
<span class="ga_add_custom_date button button-ga">Add date</span>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php
}
/**
* Service Date Range Period
*/
function get_ga_service_date_range_period_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->value();
$description = $field->args( 'description' );
$range_from = isset( $value['from'] ) ? $value['from'] : '';
$range_to = isset( $value['to'] ) ? $value['to'] : '';
$period_type = (string) get_post_meta( $field->object_id, 'ga_service_period_type', true );
$class = $period_type == 'date_range' ? '' : ' cmb2-hidden';
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id . $class; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<div class="ga_date_range_period">
<input type="text" class="cmb2-text-small ga-date-picker" value="<?php echo $range_from; ?>" name="<?php echo $name; ?>[from]" placeholder="From">
<span>till</span>
<input type="text" class="cmb2-text-small ga-date-picker" style="margin-left:2px;" value="<?php echo $range_to; ?>" name="<?php echo $name; ?>[to]" placeholder="To">
</div>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php
}
/**
* Service Custom Time Slots
*/
function get_ga_service_custom_slots_render_row( $field_args, $field ) {
$id = $field->args( 'id' );
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$value = $field->value();
$description = $field->args( 'description' );
$service_mode = (string) get_post_meta($field->object_id, 'ga_service_available_times_mode', true);;
$class = $service_mode == 'custom' ? '' : ' cmb2-hidden';
//echo '<pre>';
//var_dump( $value );
//echo '</pre>';
?>
<div class="cmb-row custom-field-row cmb2-id-<?php echo $id . $class; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<table id="ga_custom_slots">
<thead>
<tr>
<th>Start Time</th>
<th>End Time</th>
<th>Availability</th>
<th>Capacity</th>
<th>Price</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if( is_array($value) && count( $value ) > 0 ) {
foreach( $value as $id => $data ) { ?>
<tr>
<td>
<select name="<?php echo "{$name}[{$id}][start]"; ?>">
<?php
foreach( get_ga_appointment_time() as $time => $text ) {
$selected = selected( $data['start'], $time, false);
echo "<option value='{$time}' {$selected}>{$text}</option>";
}
?>
</select>
</td>
<td>
<select name="<?php echo "{$name}[{$id}][end]"; ?>">
<?php
foreach( get_ga_appointment_time($out = false, $_24 = true) as $time => $text ) {
$selected = selected( $data['end'], $time, false);
echo "<option value='{$time}' {$selected}>{$text}</option>";
}
?>
</select>
</td>
<td>
<?php
foreach( array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday') as $week ) {
$week_short = substr( ucfirst($week), 0, 1 );
$checked = isset( $data['availability'] ) && in_array($week, $data['availability']) ? 'checked="checked"' : '';
echo "<div class='ga_week_day'>
<label>
<input type='checkbox' name='{$name}[{$id}][availability][]' value='{$week}' {$checked}>
<span>{$week_short}</span>
</label>
</div>";
}
?>
</td>
<td>
<select name="<?php echo "{$name}[{$id}][capacity]"; ?>">
<?php
foreach( ga_services_capacity_options() as $num => $text ) {
$selected = selected( $data['capacity'], $num, false);
echo "<option value='{$num}' {$selected}>{$text}</option>";
}
?>
</select>
</td>
<td>
<?php echo gf_get_currency_symbol(); ?> <input type="text" class="cmb2-text-small" name="<?php echo "{$name}[{$id}][price]"; ?>" id="" value="<?php echo $data['price']; ?>">
</td>
<td>
<div class="slot-delete">Delete</div>
</td>
</tr>
<?php }
} ?>
</tbody>
<tfoot>
<tr>
<td colspan="6"><div class="add-slot button button-ga">Add new</div></td>
<tr>
</tfoot>
</table>
<p class="cmb2-metabox-description"><?php echo $description; ?></p>
</div>
</div>
<?php
}