Ejemplo n.º 1
0
        // confirm booking
        update_post_meta($booking_id, 'booking_status', 'confirmed');
        $curent_listng_id = get_post_meta($booking_id, 'booking_id', true);
        $reservation_array = wpestate_get_booking_dates($curent_listng_id);
        update_post_meta($curent_listng_id, 'booking_dates', $reservation_array);
        // set invoice to paid
        update_post_meta($invoice_id, 'invoice_status', 'confirmed');
        update_post_meta($invoice_id, 'depozit_paid', $depozit / 100);
        /////////////////////////////////////////////////////////////////////////////
        // send confirmation emails
        /////////////////////////////////////////////////////////////////////////////
        wpestate_send_booking_email("bookingconfirmeduser", $user_email);
        $receiver_id = wpsestate_get_author($invoice_id);
        $receiver_email = get_the_author_meta('user_email', $receiver_id);
        $receiver_name = get_the_author_meta('user_login', $receiver_id);
        wpestate_send_booking_email("bookingconfirmed", $receiver_email);
        // add messages to inbox
        $subject = esc_html__('Booking Confirmation', 'wpestate');
        $description = esc_html__('A booking was confirmed', 'wpestate');
        wpestate_add_to_inbox($userID, $userID, $receiver_id, $subject, $description, 1);
        ////redirect catre bookng list
        $redirect = wpestate_my_reservations_link();
        wp_redirect($redirect);
        exit;
    } catch (Exception $e) {
        $error = '<div class="alert alert-danger">
                        <strong>Error!</strong> ' . $e->getMessage() . '
                    </div>';
        print $error;
    }
} else {
 function wpestate_ajax_add_booking_font_end()
 {
     check_ajax_referer('booking_ajax_nonce', 'security');
     global $current_user;
     get_currentuserinfo();
     $userID = $current_user->ID;
     $user_login = $current_user->user_login;
     $comment = trim($_POST['comment']);
     $property_id = intval($_POST['property_id']);
     $fromdate = trim($_POST['fromdate']);
     $to_date = trim($_POST['todate']);
     $guests = trim($_POST['guests']);
     $event_name = esc_html__('Booking Request', 'wpestate');
     $post = array('post_title' => $event_name, 'post_content' => $comment, 'post_status' => 'publish', 'post_type' => 'wpestate_booking', 'post_author' => $userID);
     $post_id = wp_insert_post($post);
     $post = array('ID' => $post_id, 'post_title' => $event_name . ' ' . $post_id);
     wp_update_post($post);
     update_post_meta($post_id, 'booking_id', $property_id);
     update_post_meta($post_id, 'booking_from_date', $fromdate);
     update_post_meta($post_id, 'booking_to_date', $to_date);
     update_post_meta($post_id, 'booking_status', 'pending');
     update_post_meta($post_id, 'booking_invoice_no', 0);
     update_post_meta($post_id, 'booking_pay_ammount', 0);
     update_post_meta($post_id, 'booking_guests', $guests);
     // build the reservation array
     $reservation_array = wpestate_get_booking_dates($property_id);
     update_post_meta($property_id, 'booking_dates', $reservation_array);
     // send the email
     $property_title = get_the_title($property_id);
     $owner_id = wpse119881_get_author($property_id);
     $owner = get_userdata($owner_id);
     $owner_email = $owner->user_email;
     $owner_login = $owner->user_login;
     wpestate_send_booking_email('newbook', $owner_email);
     // add into inbox
     $subject = 'New Booking Request';
     $message_user = '******' . $property_title;
     wpestate_add_to_inbox($userID, $user_login, $owner_login, $subject, $message_user);
     // add into inbox
     print esc_html__('Booking request sent! You will receive an email if the owner approves or rejects the request.', 'wpestate');
     die;
 }
Ejemplo n.º 3
0
 function wpestate_ajax_add_booking()
 {
     //  check_ajax_referer( 'booking_ajax_nonce','security');
     global $current_user;
     get_currentuserinfo();
     $allowded_html = array();
     $userID = $current_user->ID;
     $from = $current_user->user_login;
     $comment = '';
     $status = 'pending';
     if (isset($_POST['comment'])) {
         $comment = wp_kses($_POST['comment'], $allowded_html);
     }
     $booking_guest_no = 0;
     if (isset($_POST['booking_guest_no'])) {
         $booking_guest_no = intval($_POST['booking_guest_no']);
     }
     if (isset($_POST['confirmed'])) {
         if (intval($_POST['confirmed']) == 1) {
             $status = 'confirmed';
         }
     }
     $property_id = intval($_POST['listing_edit']);
     $owner_id = wpsestate_get_author($property_id);
     $fromdate = wp_kses($_POST['fromdate'], $allowded_html);
     $to_date = wp_kses($_POST['todate'], $allowded_html);
     $event_name = esc_html__('Booking Request', 'wpestate');
     $post = array('post_title' => $event_name, 'post_content' => $comment, 'post_status' => 'publish', 'post_type' => 'wpestate_booking', 'post_author' => $userID);
     $post_id = wp_insert_post($post);
     $post = array('ID' => $post_id, 'post_title' => $event_name . ' ' . $post_id);
     wp_update_post($post);
     update_post_meta($post_id, 'booking_status', $status);
     update_post_meta($post_id, 'booking_id', $property_id);
     update_post_meta($post_id, 'owner_id', $owner_id);
     update_post_meta($post_id, 'booking_from_date', $fromdate);
     update_post_meta($post_id, 'booking_to_date', $to_date);
     update_post_meta($post_id, 'booking_invoice_no', 0);
     update_post_meta($post_id, 'booking_pay_ammount', 0);
     update_post_meta($post_id, 'booking_guests', $booking_guest_no);
     // build the reservation array
     $reservation_array = wpestate_get_booking_dates($property_id);
     update_post_meta($property_id, 'booking_dates', $reservation_array);
     if ($owner_id == $userID) {
         $subject = esc_html__('You reserved a period', 'wpestate');
         $description = esc_html__('You have reserverd a period on your own listing', 'wpestate');
         $from = $current_user->user_login;
         $to = $owner_id;
         $receiver = get_userdata($owner_id);
         $receiver_email = $receiver->user_email;
         wpestate_add_to_inbox($userID, $from, $to, $subject, $description);
         wpestate_send_booking_email('mynewbook', $receiver_email);
     } else {
         $subject = esc_html__('New Booking Request from ', 'wpestate');
         $description = esc_html__('You have received a new booking request', 'wpestate');
         $from = $current_user->ID;
         $to = $owner_id;
         $receiver = get_userdata($owner_id);
         $receiver_email = $receiver->user_email;
         wpestate_add_to_inbox($userID, $userID, $to, $subject, $description, 1);
         wpestate_send_booking_email('newbook', $receiver_email);
     }
     die;
 }