function gdlrs_get_summary_form($data, $with_form = true, $coupon = '')
 {
     global $hostel_option;
     $total_price = 0;
     $ret = '<div class="gdlr-price-summary-wrapper" >';
     // display branches if exists
     if (!empty($data['gdlr-hotel-branches'])) {
         $term = get_term_by('id', $data['gdlr-hotel-branches'], 'hostel_room_category');
         $ret .= '<div class="gdlr-price-summary-hotel-branches gdlr-title-font">';
         $ret .= $term->name;
         $ret .= '</div>';
     } else {
         $ret .= '<div class="gdlr-price-summary-head">' . __('Price Breakdown', 'gdlr-hotel') . '</div>';
     }
     // group the customer by room
     $customer_rooms = array();
     for ($i = 0; $i < intval($data['gdlr-room-number']); $i++) {
         $customer_rooms[$data['gdlr-room-id'][$i]] = empty($customer_rooms[$data['gdlr-room-id'][$i]]) ? 1 : $customer_rooms[$data['gdlr-room-id'][$i]] + 1;
     }
     foreach ($customer_rooms as $room_id => $guest_num) {
         $post_option = json_decode(gdlr_decode_preventslashes(get_post_meta($room_id, 'post-option', true)), true);
         $post_option['data'] = array('check-in' => $data['gdlr-check-in'], 'check-out' => $data['gdlr-check-out']);
         $price = gdlrs_get_booking_price($post_option);
         if (empty($post_option['room-type']) || $post_option['room-type'] == 'dorm') {
             $price['total'] = $price['total'] * $guest_num;
         }
         $ret .= '<div class="gdlr-price-room-summary">';
         $ret .= '<div class="gdlr-price-room-summary-title">';
         $ret .= __('Room', 'gdlr-hotel') . ' : ' . get_the_title($room_id);
         $ret .= '<span class="gdlr-price-room-summary-price" href="#" >' . gdlr_hostel_money_format($price['total']) . '</span>';
         $ret .= '</div>';
         $ret .= '<div class="gdlr-price-room-summary-info gdlr-title-font" >';
         $ret .= '<span>' . __('Guest', 'gdlr-hotel') . ' : ' . $guest_num . '</span>';
         $ret .= '</div>';
         $ret .= '</div>';
         $total_price += $price['total'];
     }
     // service
     if (!empty($data['service'])) {
         $services_price = gdlrs_calculate_service_price($data);
         $ret .= '<div class="gdlr-service-price-summary">';
         $ret .= '<div class="gdlr-service-price-summary-head" >' . __('Additional Services', 'gdlr-hotel') . '</div>';
         foreach ($services_price as $key => $service_price) {
             if ($key == 'total') {
                 continue;
             }
             $ret .= '<div class="gdlr-service-price-summary-item">';
             $ret .= '<span class="gdlr-head">' . $service_price['title'] . '</span>';
             $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($service_price['price']) . '</span>';
             $ret .= '<div class="clear"></div>';
             $ret .= '</div>';
         }
         $ret .= '</div>';
         $total_price += $services_price['total'];
     }
     // vat
     if (!empty($hostel_option['booking-vat-amount'])) {
         $ret .= '<div class="gdlr-price-summary-vat" >';
         $ret .= '<div class="gdlr-price-summary-vat-total" >';
         $ret .= '<span class="gdlr-head">' . __('Total', 'gdlr-hotel') . '</span>';
         $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($total_price) . '</span>';
         $ret .= '<div class="clear"></div>';
         $ret .= '</div>';
         // vat-total
         if (!empty($coupon)) {
             $discount = gdlr_get_coupon_discount($data, $coupon);
             $total_price -= $discount;
             $ret .= '<div class="gdlr-price-summary-vat-discount" >';
             $ret .= '<span class="gdlr-head">' . __('Coupon Discount', 'gdlr-hotel') . '</span>';
             $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($discount) . '</span>';
             $ret .= '<div class="clear"></div>';
             $ret .= '</div>';
         }
         $vat_amount = $total_price * floatval($hostel_option['booking-vat-amount']) / 100;
         $total_price += $vat_amount;
         $ret .= '<div class="gdlr-price-summary-vat-amount" >';
         $ret .= '<span class="gdlr-head">' . __('Vat', 'gdlr-hotel') . ' ' . $hostel_option['booking-vat-amount'] . '%</span>';
         $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($vat_amount) . '</span>';
         $ret .= '<div class="clear"></div>';
         $ret .= '</div>';
         // vat-amount
         $ret .= '</div>';
     }
     // deposit
     if ($with_form && !empty($hostel_option['booking-deposit-amount'])) {
         // grand total
         $ret .= '<div class="gdlr-price-summary-grand-total gdlr-active" >';
         $ret .= '<span class="gdlr-head">' . __('Grand Total', 'gdlr-hotel') . '</span>';
         $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($total_price) . '</span>';
         $ret .= '</div>';
         $deposit_text = $hostel_option['booking-deposit-amount'] . '% ' . __('Deposit', 'gdlr-hotel');
         $deposit_amount = $total_price * floatval($hostel_option['booking-deposit-amount']) / 100;
         $ret .= '<div class="gdlr-price-deposit-wrapper">';
         $ret .= '<div class="gdlr-price-deposit-input" >';
         $ret .= '<span class="gdlr-active" ><label class="gdlr-radio-input"><input type="radio" name="pay_deposit" value="false" checked ></label>' . __('Pay Full Amount', 'gdlr-hotel') . '</span>';
         $ret .= '<span><label class="gdlr-radio-input"><input type="radio" name="pay_deposit" value="true" ></label>' . __('Pay', 'gdlr-hotel') . ' ' . $deposit_text . '</span>';
         $ret .= '</div>';
         $ret .= '<div class="gdlr-price-deposit-inner-wrapper">';
         $ret .= '<div class="gdlr-price-deposit-title">' . $deposit_text . '</div>';
         $ret .= '<div class="gdlr-price-deposit-caption">' . __('*Pay the rest on arrival', 'gdlr-hotel') . '</div>';
         $ret .= '<div class="gdlr-price-deposit-amount">' . gdlr_hostel_money_format($deposit_amount) . '</div>';
         $ret .= '</div>';
         $ret .= '</div>';
         $ret .= '<a id="gdlr-edit-booking-button" class="gdlr-edit-booking-button gdlr-button with-border" href="#">' . __('Edit Booking', 'gdlr-hotel') . '</a>';
     } else {
         $ret .= '<div class="gdlr-price-summary-grand-total-wrapper-2" >';
         $ret .= '<div class="gdlr-price-summary-grand-total ';
         $ret .= empty($data['pay_deposit']) || $data['pay_deposit'] == 'false' ? 'gdlr-active' : '';
         $ret .= '" >';
         $ret .= '<span class="gdlr-head">' . __('Grand Total', 'gdlr-hotel') . '</span>';
         $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($total_price) . '</span>';
         $ret .= '</div>';
         if (!empty($data['pay_deposit']) && $data['pay_deposit'] == 'true') {
             $deposit_text = $hostel_option['booking-deposit-amount'] . '% ' . __('Deposit', 'gdlr-hotel');
             $deposit_amount = $total_price * floatval($hostel_option['booking-deposit-amount']) / 100;
             $ret .= '<div class="gdlr-price-deposit-wrapper">';
             $ret .= '<div class="gdlr-price-deposit-inner-wrapper">';
             $ret .= '<div class="gdlr-price-deposit-title">' . $deposit_text . '</div>';
             $ret .= '<div class="gdlr-price-deposit-caption">' . __('*Pay the rest on arrival', 'gdlr-hotel') . '</div>';
             $ret .= '<div class="gdlr-price-deposit-amount">' . gdlr_hostel_money_format($deposit_amount) . '</div>';
             $ret .= '</div>';
             $ret .= '</div>';
             $ret .= '<div class="gdlr-pay-on-arrival" >';
             $ret .= '<span class="gdlr-head">' . __('Pay on arrival', 'gdlr-hotel') . '</span>';
             $ret .= '<span class="gdlr-tail">' . gdlr_hostel_money_format($total_price - $deposit_amount) . '</span>';
             $ret .= '</div>';
         }
         $ret .= '</div>';
     }
     $ret .= '</div>';
     // gdlr-price-summary-wrapper
     return $ret;
 }
 function get_hostel_transaction_room($data)
 {
     $ret = '<div class="transaction-description-wrapper">';
     $ret .= '<i class="close-transaction-description fa fa-remove icon-remove"></i>';
     // display branches if exists
     if (!empty($data['gdlr-hotel-branches'])) {
         $term = get_term_by('id', $data['gdlr-hotel-branches'], 'hostel_room_category');
         $ret .= '<div class="transaction-branches">';
         $ret .= $term->name;
         $ret .= '</div>';
     }
     $ret .= '<div class="transaction-description gdlr-large">';
     $ret .= '<span class="gdlr-head">' . __('Arrival Date :', 'gdlr-hotel') . '</span>';
     $ret .= '<span class="gdlr-tail">' . $data['gdlr-check-in'] . '</span>';
     $ret .= '</div>';
     $ret .= '<div class="transaction-description gdlr-large">';
     $ret .= '<span class="gdlr-head">' . __('Check Out Date :', 'gdlr-hotel') . '</span>';
     $ret .= '<span class="gdlr-tail">' . $data['gdlr-check-out'] . '</span>';
     $ret .= '</div>';
     for ($i = 0; $i < intval($data['gdlr-room-number']); $i++) {
         $ret .= '<div class="transaction-description gdlr-room">';
         $ret .= '<span class="gdlr-head">' . __('Room', 'gdlr-hotel') . ' ' . ($i + 1) . ' :</span>';
         $ret .= '<span class="gdlr-tail"><a target="_blank" href="' . get_edit_post_link($data['gdlr-room-id'][$i]) . '">' . get_the_title($data['gdlr-room-id'][$i]) . '</a></span>';
         $ret .= '</div>';
     }
     if (!empty($data['service'])) {
         $services_price = gdlrs_calculate_service_price($data);
         $ret .= '<div class="transaction-description gdlr-room">';
         $ret .= '<span class="gdlr-head">' . __("Additional Services", "gdlr-hotel") . ' :</span>';
         foreach ($services_price as $key => $service_price) {
             if ($key == 'total') {
                 continue;
             }
             $ret .= '<div class="gdlr-desc">';
             $ret .= $service_price['title'];
             $ret .= '</div>';
         }
     }
     $ret .= '</div>';
     return $ret;
 }
 function gdlrs_get_booking_total_price($data, $coupon = '')
 {
     global $hostel_option;
     $total_price = 0;
     // group the customer by room
     $customer_rooms = array();
     for ($i = 0; $i < intval($data['gdlr-room-number']); $i++) {
         $customer_rooms[$data['gdlr-room-id'][$i]] = empty($customer_rooms[$data['gdlr-room-id'][$i]]) ? 1 : $customer_rooms[$data['gdlr-room-id'][$i]] + 1;
     }
     foreach ($customer_rooms as $room_id => $guest_num) {
         $post_option = json_decode(gdlr_decode_preventslashes(get_post_meta($room_id, 'post-option', true)), true);
         $post_option['data'] = array('check-in' => $data['gdlr-check-in'], 'check-out' => $data['gdlr-check-out']);
         $price = gdlrs_get_booking_price($post_option);
         if (empty($post_option['room-type']) || $post_option['room-type'] == 'dorm') {
             $price['total'] = $price['total'] * $guest_num;
         }
         $total_price += $price['total'];
     }
     // service
     if (!empty($data['service'])) {
         $services_price = gdlrs_calculate_service_price($data);
         $total_price += $services_price['total'];
     }
     // coupon discount
     $discount_price = gdlr_get_coupon_discount($data, $coupon);
     $total_price -= $discount_price;
     if (!empty($hostel_option['booking-vat-amount'])) {
         $vat_amount = $total_price * floatval($hostel_option['booking-vat-amount']) / 100;
         $total_price += $vat_amount;
     }
     $pay_amount = $total_price;
     if (!empty($hostel_option['booking-deposit-amount']) && $data['pay_deposit'] == 'true') {
         $pay_amount = $total_price * floatval($hostel_option['booking-deposit-amount']) / 100;
     }
     return array('total_price' => $total_price, 'pay_amount' => $pay_amount);
 }
 function gdlr_hostel_mail_content($contact, $data, $payment_info, $price)
 {
     $content = __("Contact Info", "gdlr-hotel") . " \n";
     $content .= __("Name :", "gdlr-hotel") . " {$contact['first_name']}\n";
     $content .= __("Last Name :", "gdlr-hotel") . " {$contact['last_name']}\n";
     $content .= __("Phone :", "gdlr-hotel") . " {$contact['phone']}\n";
     $content .= __("Email :", "gdlr-hotel") . " {$contact['email']}\n";
     $content .= __("Address :", "gdlr-hotel") . " {$contact['address']}\n";
     $content .= __("Additional Note :", "gdlr-hotel") . " {$contact['additional-note']}\n";
     $content .= __("Coupon :", "gdlr-hotel") . " {$contact['coupon']}\n";
     if (!empty($data['gdlr-hotel-branches'])) {
         $term = get_term_by('id', $data['gdlr-hotel-branches'], 'hostel_room_category');
         $content .= "Branches : {$term->name}\n";
         $category_meta = get_option('gdlr_hotel_branch', array());
         if (!empty($category_meta[$term->slug]['content'])) {
             $content .= "Location : {$category_meta[$term->slug]['content']}\n";
         }
     }
     $content .= "\n";
     $content .= __("Room Information", "gdlr-hotel") . "\n";
     $customer_rooms = array();
     for ($i = 0; $i < intval($data['gdlr-room-number']); $i++) {
         $customer_rooms[$data['gdlr-room-id'][$i]] = empty($customer_rooms[$data['gdlr-room-id'][$i]]) ? 1 : $customer_rooms[$data['gdlr-room-id'][$i]] + 1;
     }
     foreach ($customer_rooms as $room_id => $guest_num) {
         $content .= __("Room", "gdlr-hotel") . " : " . get_the_title($room_id) . " : {$guest_num} " . __('Guest', 'gdlr-hotel') . " \n";
     }
     $content .= __("Check In :", "gdlr-hotel") . " {$data['gdlr-check-in']} \n";
     $content .= __("Check Out :", "gdlr-hotel") . " {$data['gdlr-check-out']} \n";
     $content .= "\n";
     if (!empty($data['service'])) {
         $content .= __("Additional Services", "gdlr-hotel") . "\n";
         $services_price = gdlrs_calculate_service_price($data);
         foreach ($services_price as $key => $service_price) {
             if ($key == 'total') {
                 continue;
             }
             $service_title = str_replace('<span class="gdlr-sep">/</span>', ' ', $service_price['title']);
             $content .= $service_title . "\n";
         }
         $content .= "\n";
     }
     $content .= __("Payment Information", "gdlr-hotel") . " \n";
     $content .= __("Total Price :", "gdlr-hotel") . " " . gdlr_hostel_money_format($price['total_price']) . " \n";
     $content .= __("Pay Amount :", "gdlr-hotel") . " " . gdlr_hostel_money_format($price['pay_amount']) . " \n";
     if (!empty($price['booking_code'])) {
         $content .= __("Booking Code :", "gdlr-hotel") . " {$price['booking_code']} \n";
     }
     if (!empty($contact['payment-method']) && !empty($payment_info)) {
         if ($contact['payment-method'] == 'stripe') {
             $content .= __("Payment Method : Stripe", "gdlr-hotel") . " \n";
             $content .= __("Transaction ID :", "gdlr-hotel") . " {$payment_info['balance_transaction']} \n";
         } else {
             if ($contact['payment-method'] == 'paypal') {
                 $content .= __("Payment Method : Paypal", "gdlr-hotel") . " \n";
                 $content .= __("Transaction ID :", "gdlr-hotel") . " {$payment_info['txn_id']} \n";
             } else {
                 if ($contact['payment-method'] == 'paymill') {
                     $content .= __("Payment Method : Paymill", "gdlr-hotel") . " \n";
                     $content .= __("Transaction ID :", "gdlr-hotel") . " {$payment_info->getId()} \n";
                 } else {
                     if ($contact['payment-method'] == 'authorize') {
                         $content .= __("Payment Method : Authorize", "gdlr-hotel") . " \n";
                         $content .= __("Transaction ID :", "gdlr-hotel") . " {$payment_info->transaction_id} \n";
                     }
                 }
             }
         }
     }
     return $content;
 }