' . esc_attr__( 'Click here', 'supportcandy' ) . ''
);
?>
array(
'relation' => 'AND',
array(
'slug' => 'agent',
'compare' => '>',
'val' => 0,
),
array(
'slug' => 'is_recurring',
'compare' => '=',
'val' => 0,
),
array(
'slug' => 'holiday',
'compare' => 'BETWEEN',
'val' => array(
$start_date->format( 'Y-m-d H:i:s' ),
$end_date->format( 'Y-m-d H:i:s' ),
),
),
),
)
)['results'];
foreach ( $holidays as $holiday ) {
$response[] = array(
'id' => $holiday->id,
'title' => $holiday->agent->name,
'start' => $holiday->holiday->format( 'Y-m-d' ),
'color' => '#f0932b',
'textColor' => '#ffffff',
);
}
// recurring.
$sql = 'SELECT * FROM ' . $wpdb->prefix . 'psmsc_holidays WHERE ';
$sql .= 'is_recurring=1 AND agent > 0 AND ';
$sql .= "DATE_FORMAT(holiday, '%m-%d') BETWEEN '" . $start_date->format( 'm-d' ) . "' and '" . $end_date->format( 'm-d' ) . "'";
$results = $wpdb->get_results( $sql );
foreach ( $results as $holiday ) {
$holiday = new WPSC_Holiday( $holiday->id );
$start = '';
if ( intval( $start_date->format( 'Y' ) ) == intval( $end_date->format( 'Y' ) ) ) {
$start .= $start_date->format( 'Y' ) . '-' . $holiday->holiday->format( 'm-d' );
} elseif ( $holiday->holiday->format( 'm' ) == '12' ) {
$start .= $start_date->format( 'Y' ) . '-' . $holiday->holiday->format( 'm-d' );
} else {
$start .= $end_date->format( 'Y' ) . '-' . $holiday->holiday->format( 'm-d' );
}
$response[] = array(
'id' => $holiday->id,
'title' => $holiday->agent->name,
'start' => $start,
'color' => '#eb4d4b',
'textColor' => '#ffffff',
);
}
wp_send_json( $response, 200 );
}
/**
* Add agent leaves modal
*
* @return void
*/
public static function get_add_agent_leaves() {
if ( check_ajax_referer( 'wpsc_get_add_agent_leaves', '_ajax_nonce', false ) != 1 ) {
wp_send_json_error( 'Unauthorised request!', 401 );
}
if ( ! WPSC_Functions::is_site_admin() ) {
wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
}
$date_selected = isset( $_POST['dateSelected'] ) ? array_filter( array_map( 'sanitize_text_field', wp_unslash( $_POST['dateSelected'] ) ) ) : array();
if ( ! $date_selected ) {
wp_send_json_error( 'Bad Request', 401 );
}
$title = esc_attr( wpsc__( 'Add new', 'supportcandy' ) );
$unique_id = uniqid( 'wpsc_' );
ob_start();
?>