function client($postData, $infos, $arrive, $departure, $selected_rooms, $roominfo, $hgconf)
 {
     include JPATH_COMPONENT . DS . 'assets/css/sendmail_style.php';
     $arrive = date("F d, Y", $arrive);
     $departure = date("F d, Y", $departure);
     $body .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <meta http-equiv="Content-Language" content="en-us">
         <title>' . $infos->title . "-" . $postData['lastname'] . "/" . $infos->cityname . "-" . $infos->countryname . " (" . $arrive . " > " . $departure . ")" . '</title>
     </head>
     <body style=" font-family:verdana; font-size:10px; margin-top:0px; margin-bottom:0px;">
     <table width="740" border="0" cellpadding="5" cellspacing="0" align="center">
       <tr>
         <td align="left" valign="top" style="' . $fondocell . '">
             <div style="' . $style3 . '">
                 <p>Dear ' . $postData['gender'] . ' ' . $postData['firstname'] . ' ' . $postData['lastname'] . '</p>
                 <p>We thank you for choosing us.</p>
                 <p>Here are the details of the booking request you just sent to ' . $infos->title . ' at ' . $infos->cityname . ', ' . $infos->countryname . ': </p>
             </div>
         </td>
       </tr>          
       <tr>
         <td align="left" valign="top" style="' . $fondomain . '">';
     if ($infos->travel_agency == 1 and $postData['BookingForSomeoneElse'] == 'true') {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_GUEST_NAME') . ': ' . $postData['guest_gender'] . ' ' . $postData['guest_firstname'] . ' ' . $postData['guest_lastname'] . '</font><br>';
     } else {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_NAME') . ': ' . $postData['gender'] . ' ' . $postData['firstname'] . ' ' . $postData['lastname'] . '</font><br>';
     }
     $body .= '<font style="' . $style3 . '">' . JText::_('HG_ARRIVAL_DATE') . ': ' . $arrive . '</font><br>
             <font style="' . $style3 . '">' . JText::_('HG_DEPARTURE_DATE') . ': ' . $departure . '</font><br>
             <font style="' . $style3 . '">' . hg_sendmail::show_adults_childrens_ages($postData['adult'], $postData['children'], $postData['children_ages']) . '</font><br><br>';
     //Agrupa las habitaciones seleccionadas en una sola linea
     for ($i = 0; $i < count($selected_rooms); $i++) {
         if (!$infos->upon_request) {
             if ($roominfo[$i]->bedtype != $roominfo[$i]->roomtitle) {
                 if (trim($roominfo[$i]->bedtype) != "") {
                     $info_bed_type = $roominfo[$i]->bedtype . " ";
                 }
             }
             if ($roominfo[$i]->maxguest > 1) {
                 $maxguest = ' (' . $info_bed_type . JText::sprintf('HG_MAX_PERSONS', $roominfo[$i]->maxguest) . ')';
             } else {
                 $maxguest = ' (' . $info_bed_type . JText::_('HG_SINGLE_OCCUPANCY') . ')';
             }
         }
         if ($i == 0) {
             $rooms_selected = $selected_rooms[$i]['valor'] . ' ' . $roominfo[$i]->roomtitle . $maxguest;
         } else {
             $rooms_selected = $selected_rooms[$i]['valor'] . ' ' . $roominfo[$i]->roomtitle . $maxguest . '; ' . $rooms_selected;
         }
     }
     $body .= '<font style="' . $style3 . '">' . JText::_('HG_ROOM_TYPE') . ': ' . $rooms_selected . '</font><br>' . "\n";
     if (!empty($postData['total_cost_input'])) {
         $body .= '<br><font style="' . $style3 . '">' . JText::_('HG_TOTAL_ROOM_CHARGE') . ': ' . $infos->currency . ' ' . $postData['total_cost_input'] . '</font><br>' . "\n";
     }
     if (!empty($postData['roomfacilities'])) {
         $body .= '<br><font style="' . $style3 . '">' . JText::_('HG_ROOM_FACILITIES') . ': ' . $postData['roomfacilities'] . '</font><br>' . "\n";
     }
     if ($postData['comment'] != "") {
         $body .= '<br><font style="' . $style3 . '">' . JText::_('HG_SPECIAL_REQUEST') . ': ' . $postData['comment'] . '</font><br>' . "\n";
     }
     if ($postData['credit_card_num'] != "" and $postData['r_ExpirationMonth1'] != "Month" and $postData['rd_ExpirationYear1'] != "Year" and $postData['r_NameOnTheCard1'] != "") {
         $body .= '<br><font style="' . $style3 . '">' . $postData['r_CardType1'] . ' ' . $postData['credit_card_num'] . ' exp ' . $postData['r_ExpirationMonth1'] . ' ' . $postData['rd_ExpirationYear1'] . ' of ' . $postData['r_NameOnTheCard1'] . '</font><br>' . "\n";
     }
     $body .= '</td></tr>
         <tr>
             <td>
                 <font style="' . $style3 . '">
                     <p>
                         This is not an official confirmation; it is just an acknowledgement that the above described request has been received. 
                         You shall receive an official reply from an authorized employee of the reservations department / front desk, 
                         who you may contact at any time, for anything you may want while staying at ' . $infos->title . '.
                     </p>
                     <p>Regards,</p>
                     <p>Reservations Department</p>
                     <p>P.S. Following are your contact details as we received them:</p>
                 </font>
             </td>
         </tr>
         <tr>
             <td>';
     if (!empty($postData['firstname']) or !empty($postData['lastname'])) {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_NAME') . ': ' . $postData['gender'] . ' ' . $postData['firstname'] . ' ' . $postData['lastname'] . '</font><br>';
     }
     if (!empty($postData['agency_name'])) {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_AGENCY_NAME') . ': ' . $postData['agency_name'] . '</font><br>';
     }
     if (!empty($postData['iata_number'])) {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_IATA_NUMBER') . ': ' . $postData['iata_number'] . '</font><br>';
     }
     $body .= '<br><font style="' . $style3 . '">' . JText::_('HG_COUNTRY_OF_PASSPORT') . ': ' . $postData['country_client'] . '</font><br>';
     if (!empty($postData['state'])) {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_STATE_PROVINCE') . ': ' . $postData['state'] . '</font><br>';
     }
     $body .= '<font style="' . $style3 . '">' . JText::_('HG_CITY') . ': ' . $postData['city_client'] . '</font><br>
                   <font style="' . $style3 . '">' . JText::_('HG_TELEPHONE_BOOKING') . ': ' . $postData['phone'] . '</font><br>';
     if (!empty($postData['fax'])) {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_FAX') . ': ' . $postData['fax'] . '</font><br>';
     }
     $body .= '<font style="' . $style3 . '">' . JText::_('HG_EMAIL_ADDRESS') . ': ' . $postData['email'] . '</font><br>';
     if (!empty($postData['alternative_email'])) {
         $body .= '<font style="' . $style3 . '">' . JText::_('HG_ALTERNATIVE_EMAIL') . ': ' . $postData['alternative_email'] . '</font><br>';
     }
     $body .= '</td>
       </tr>
     </table>
     </body>
     </html>';
     return $body;
 }
 function sendmail()
 {
     global $hgconf;
     jimport('joomla.mail.helper');
     jimport('joomla.utilities.utility');
     $config =& JFactory::getConfig();
     $db =& JFactory::getDBO();
     $postData['email'] = JMailHelper::cleanAddress(JRequest::getVar('email', ''));
     $postData['alternative_email'] = JMailHelper::cleanAddress(JRequest::getVar('alternative_email', ''));
     $postData['gender'] = JRequest::getVar('gender', '');
     $postData['guest_gender'] = JRequest::getVar('guest_gender', '');
     $postData['firstname'] = JRequest::getVar('firstname', '');
     $postData['lastname'] = JRequest::getVar('lastname', '');
     $postData['guest_firstname'] = JRequest::getVar('guest_firstname', '');
     $postData['guest_lastname'] = JRequest::getVar('guest_lastname', '');
     $postData['BookingForSomeoneElse'] = JRequest::getVar('BookingForSomeoneElse', '');
     $postData['iata_number'] = JRequest::getVar('iata_number', '');
     $postData['agency_name'] = JRequest::getVar('agency_name', '');
     $postData['travelAgent'] = JRequest::getVar('travelAgent', '');
     $postData['hotel'] = (int) JRequest::getVar('hotel', '');
     $postData['city'] = JRequest::getVar('city', '');
     $postData['state'] = JRequest::getVar('state', '');
     $postData['city_client'] = JRequest::getVar('city_client', '');
     $postData['hotel_country'] = JRequest::getVar('hotel_country', '');
     $postData['roomtype'] = (int) JRequest::getVar('roomtypelist', '');
     $postData['bedtype'] = JRequest::getVar('bedtypelist', '');
     $postData['bedtype'] = stripcslashes($postData['bedtype']);
     $postData['bedtype'] = stripcslashes($postData['bedtype']);
     $bedtype = stripcslashes($postData['bedtype']);
     $postData['adult'] = (int) JRequest::getVar('adult', '');
     $postData['children'] = (int) JRequest::getVar('children', '');
     $postData['children_ages'] = JRequest::getVar('children_ages', '');
     $postData['rooms'] = (int) JRequest::getVar('rooms', '');
     $postData['breakfast'] = (int) JRequest::getVar('breakfast', '');
     $postData['total_cost_input'] = JRequest::getVar('total_cost_input', '');
     $inyear = substr(JRequest::getVar('indate-sel-mm'), -4);
     $inmonth = substr(JRequest::getVar('indate-sel-mm'), 0, -4);
     $inday = JRequest::getVar('indate-sel-dd');
     $postData['checkin'] = $inyear . '-' . $inmonth . '-' . $inday;
     $outyear = substr(JRequest::getVar('outdate-sel-mm'), -4);
     $outmonth = substr(JRequest::getVar('outdate-sel-mm'), 0, -4);
     $outday = JRequest::getVar('outdate-sel-dd');
     $postData['checkout'] = $outyear . '-' . $outmonth . '-' . $outday;
     $postData['country'] = JRequest::getVar('country', '');
     $postData['phone'] = JRequest::getVar('phone', '');
     $postData['fax'] = JRequest::getVar('fax', '');
     $postData['comment'] = JRequest::getVar('comment', '');
     $postData['roomfacilities'] = JRequest::getVar('roomfacilities', '');
     $postData['r_CardType1'] = JRequest::getVar('r_CardType1', '');
     $postData['r_NameOnTheCard1'] = JRequest::getVar('r_NameOnTheCard1', '');
     $postData['credit_card_num'] = JRequest::getVar('n1') . JRequest::getVar('n2') . JRequest::getVar('n3') . JRequest::getVar('n4');
     $postData['r_ExpirationMonth1'] = JRequest::getVar('r_ExpirationMonth1', '');
     $postData['rd_ExpirationYear1'] = JRequest::getVar('rd_ExpirationYear1', '');
     $postData['status'] = 2;
     $postData['sender_ip'] = $_SERVER['REMOTE_ADDR'];
     $postData['rdate'] = gmdate('Y-m-d H:i:s');
     $id = JRequest::getVar('id', '');
     $subject = $hgconf->subject;
     $header = $hgconf->form_header;
     $note = $hgconf->form_note;
     $policy = $hgconf->form_policy;
     $card = 0;
     //Bandera usada para ver si viene o no los datos de la tajeta de credito
     $postData['browser'] = $_SERVER['HTTP_USER_AGENT'];
     //Detecta de el explorador del cual fue enviado la reserva
     $query = 'SELECT h.title, h.address, co.name AS countryname, c.name AS cityname, h.alias,' . 'h.id_jpmoser, h.email, h.upon_request, h.phone, h.fax, h.send_reserve_directly, ' . 'h.discount, h.travel_agency, h.travel_agency_commission, cur.code AS currency' . ' FROM #__hg_hotelitems AS h' . ' LEFT JOIN #__hg_countries AS co ON co.id = h.country' . ' LEFT JOIN #__hg_cities AS c ON c.id = h.city' . ' LEFT JOIN #__hg_currency AS cur ON cur.id = h.currency' . ' WHERE h.id = ' . $id;
     $db->setQuery($query);
     if (!$db->query()) {
         JError::raiseError(500, $db->stderr(true));
         return;
     }
     $infos = $db->loadObject();
     $query = 'SELECT c.name FROM #__hg_countries AS c WHERE c.id=' . $postData['country'];
     $db->setQuery($query);
     if (!$db->query()) {
         JError::raiseError(500, $db->stderr(true));
         return;
     }
     $country_client = $db->loadObject();
     $postData['country_client'] = $country_client->name;
     ////////////Start Validation Form/////////////////////////
     for ($i = 1; $i <= 20; $i++) {
         $error[$i] = 0;
     }
     //Titulo de los errores posibles////////////////////
     $err_msg[1] = "Please Insert the Adults Number";
     $err_msg[2] = "Invalid arrival or departure date...<br><strong>Please insert valid dates!</strong>";
     $err_msg[3] = "Please Insert only Number";
     $err_msg[4] = "Please Select Quantity of Room";
     $err_msg[5] = "E-Mail Address is not valid";
     $err_msg[6] = "Select your type of room";
     $err_msg[7] = "Provide Your Name";
     $err_msg[8] = "Provide Your LastName";
     $err_msg[9] = "Provide your Telephone(s)";
     $err_msg[10] = "Provide a Card Holder's Name";
     $err_msg[11] = "This is not a valid Credit Card Number";
     $err_msg[12] = "Provide a Valid Exp. Date";
     $err_msg[13] = "Provide your Country";
     $err_msg[14] = "Provide your Credit Card Details";
     $err_msg[15] = "Sorry, you have provided an invalid security code, please go back and click on the image once to reload a new one";
     $err_msg[16] = "Provide your City";
     $err_msg[17] = "Provide Ages of Childrens";
     $err_msg[18] = "Provide No. of Children";
     $err_msg[19] = "Provide your Guest Name";
     $err_msg[20] = "Provide Name of Travel Agency";
     //Validaciones por cada campo
     if ($infos->travel_agency == "1" and $postData['BookingForSomeoneElse'] == "true") {
         if ($postData['guest_firstname'] == "" or $postData['guest_lastname'] == "") {
             $error[19] = 1;
         }
         if ($postData['travelAgent'] == "on" and $postData['agency_name'] == "") {
             $error[20] = 1;
         }
     }
     //Esta es una validacion para los casos cuando no son una agencia de viajes y no hayan marcada la opcion Booking for some else
     if ($postData['firstname'] == "") {
         $error[7] = 1;
     }
     if ($postData['lastname'] == "") {
         $error[8] = 1;
     }
     if ($postData['country'] == "") {
         $error[13] = 1;
     }
     if ($postData['email'] == "") {
         $error[5] = 1;
     }
     if ($postData['phone'] == "") {
         $error[9] = 1;
     }
     if ($postData['city_client'] == "") {
         $error[16] = 1;
     }
     //if ($postData['bedtype']=="0") { $error[6] = 1; }
     $firstinput1 = $postData['checkin'];
     $secondinput1 = $postData['checkout'];
     if ($firstinput1 != "") {
         $timestamp1 = strtotime($firstinput1);
         $firstinput1 = date('d/m/Y', $timestamp1);
     }
     if ($secondinput1 != "") {
         $timestamp2 = strtotime($secondinput1);
         $secondinput1 = date('d/m/Y', $timestamp2);
     }
     ///////////////////Formato de fecha dd/mm/yyyy/////////////////////
     //descomponer fecha de llegada
     $arrivalday = substr($firstinput1, 0, 2);
     $arrivalmonth = substr($firstinput1, 3, 2);
     $arrivalyear = substr($firstinput1, 6, 4);
     //descomponer fecha de salida
     $depday = substr($secondinput1, 0, 2);
     $depmonth = substr($secondinput1, 3, 2);
     $depyear = substr($secondinput1, 6, 4);
     ///////////Cambio de nombre de los d�as y a�os//////////////////
     $previous_date = date("Y/m/d", strtotime(date("Y/m/d") . ' -2 day'));
     $llegada = $arrivalyear . "/" . $arrivalmonth . "/" . $arrivalday;
     $salida = $depyear . "/" . $depmonth . "/" . $depday;
     if ($previous_date < $llegada and $llegada < $salida) {
     } else {
         $error[2] = 1;
     }
     //Validacion si alguien trata de enviar T.C. incompleta:
     if ($postData['r_NameOnTheCard1'] != "" or $postData['credit_card_num'] != "" or $postData['r_ExpirationMonth1'] != "Month" or $postData['rd_ExpirationYear1'] != "Year") {
         //Valida el campo Card Name
         if ($postData['r_NameOnTheCard1'] == "") {
             $error[10] = 1;
         }
         //Valida si ingresaron numero de tarjeta
         if ($postData['credit_card_num'] == "") {
             $error[11] = 1;
         }
         //Valida el campo Exp Date
         if ($postData['r_ExpirationMonth1'] == "Month" or $postData['rd_ExpirationYear1'] == "Year") {
             $error[12] = 1;
         }
     } else {
         //Hace obligatorio la T.C. para los hoteles que no son Upon Request
         if (!$infos->upon_request) {
             //Si no existe nada en los campos de la tarjeta de credito (Es obligatorio la T.C)
             $error[14] = 1;
         }
     }
     $s = count($error);
     for ($i = 1; $i <= $s; $i++) {
         if ($error[$i] == 1) {
             //Si hay un error que se valide en php, será enviado por correo a la cuenta especificada
             $body = 'http://www.jpmoser.com/' . $infos->alias . '.html<br><br>';
             $body .= 'From ' . $firstinput1 . ' to ' . $secondinput1 . '<br><br>';
             $body .= 'Error: ' . $err_msg[$i];
             JUtility::sendMail('*****@*****.**', 'Reserve', '*****@*****.**', 'Error for ' . $infos->title, $body, $mode = true, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null);
             //Pagina en Yumi que muestra el error, uno por uno
             header("Location: " . $this->baseurl . "/jpmoser_guide/index.php?option=com_jumi&fileid=4&err_msg=" . $err_msg[$i]);
             die;
         } else {
             $errores = $errores + 1;
         }
     }
     ////////////End Validation Form/////////////////////////
     if ($postData['comment'] == JText::_('HG_SPECIAL_REQUESTS')) {
         $postData['comment'] = '';
     }
     $in = mktime(0, 0, 0, $inmonth, $inday, $inyear);
     $out = mktime(0, 0, 0, $outmonth, $outday, $outyear);
     $duration = round(abs($out - $in) / 86400);
     $mode = $hgconf->emailmode ? true : false;
     eval("\$selected_rooms=" . $bedtype . ";");
     for ($i = 0; $i < count($selected_rooms); $i++) {
         if ($infos->upon_request) {
             $query = 'SELECT i.title AS roomtitle' . ' FROM #__hg_roomitems AS i' . ' WHERE i.id = ' . $selected_rooms[$i]['idroom'];
         } else {
             $query = 'SELECT r.*, i.title AS roomtitle, r.bedtype AS bedtype' . ' FROM #__hg_roomitems AS i' . ' LEFT JOIN #__hg_roomrates AS r ON i.id = r.room_id' . ' WHERE r.id = ' . $selected_rooms[$i]['idroom'];
         }
         $db->setQuery($query);
         if (!$db->query()) {
             JError::raiseError(500, $db->stderr(true));
             return;
         }
         $roominfo[] = $db->loadObject();
     }
     //Este ciclo reune todas las room facilities seleccionadas como checkbox
     if ($postData['roomfacilities']) {
         for ($i = 0; $i < count($postData['roomfacilities']); $i++) {
             $query = 'SELECT name FROM #__hg_roomfacilities AS i WHERE i.id = ' . $postData['roomfacilities'][$i];
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseError(500, $db->stderr(true));
                 return;
             }
             $roomfacility = $db->loadObject();
             if ($i == 0) {
                 $room_facility_save = $roomfacility->name;
             } else {
                 $room_facility_save = $roomfacility->name . '; ' . $room_facility_save;
             }
         }
         $postData['roomfacilities'] = $room_facility_save;
     }
     //OJO - TENGO QUE PRESTARLE ATENCION A LA VARIABLE ROOMTYPE PORQUE PARA LOS HOTELES UPON REQUEST ESTO VENDRA VACIO
     /*if ($postData['roomtype']!=""){
           $query = 'SELECT title'
                           . ' FROM #__hg_roomitems'
                           . ' WHERE id = '.$postData['roomtype']
                           ;                
           $db->setQuery($query);
           if (!$db->query()) {
                   JError::raiseError( 500, $db->stderr(true));
                   return;
           }
           $roominfo_upon_request = $db->loadObject();
       }*/
     $total = 0;
     $total_discout = 0;
     //Si el hotel es Upon Request entonces:
     if (!$infos->upon_request) {
         for ($i = 0; $i < $duration; $i++) {
             $monref = date('n', $in + 86400 * $i);
             $dayref = date('j', $in + 86400 * $i) - 1;
             $day_rate = $this->getReserveRates($roominfo, $monref);
             //		$output .= ($i+1).'.&nbsp;'.date( 'D M d Y', ($in+86400*$i)).'&nbsp;-&nbsp;';
             //		$output .= '<strong>'.$currency.'&nbsp;'.number_format($day_rate[0][$dayref] * ((100 - $day_rate[1][$dayref]) / 100), 2, '.', '').'</strong><br />';
             $total += $day_rate[0][$dayref] * ((100 - $day_rate[1][$dayref]) / 100) * $postData['rooms'];
             $total_discout += $day_rate[1][$dayref];
         }
     }
     $total += $total * (($roominfo->taxes + $roominfo->fees) / 100);
     if ($postData['breakfast']) {
         $total += $postData['breakfast'] * $postData['adult'] * $roominfo->breakfastprice;
     }
     $postData['tamount'] = $total;
     $postData['damount'] = $total;
     if (!empty($roominfo)) {
         for ($i = 0; $i < count($selected_rooms); $i++) {
             if ($i == 0) {
                 $rooms_save = $selected_rooms[$i]['valor'] . ' ' . $roominfo[$i]->roomtitle . ' ' . $roominfo[$i]->maxguest;
             } else {
                 $rooms_save = $selected_rooms[$i]['valor'] . ' ' . $roominfo[$i]->roomtitle . ' ' . $roominfo[$i]->maxguest . '; ' . $rooms_save;
             }
         }
     } else {
         $postData['bedtype'] = "0";
     }
     $postData['roomtype'] = $rooms_save;
     // initialize email recipients list
     $email_recipients = $postData['email'];
     $array_copy_hotel = explode("|", $hgconf->config_email_copy_hotel);
     if ($hgconf->sendmail_test == '1') {
         //Envia solo reservas de pruebas a mi cuenta
         $body_email2 = hg_sendmail::backup($postData, $infos, $in, $out, $selected_rooms, $roominfo, $hgconf);
         $array_copy_us = explode("|", $hgconf->config_email_copy_bck);
         $subject_email2 = sprintf($array_copy_hotel[2], $infos->title, $postData['lastname'], $infos->cityname, $infos->countryname, date("F d, Y", $in), date("F d, Y", $out));
         JUtility::sendMail($array_copy_us[0], $array_copy_us[1], "*****@*****.**", $subject_email2, $body_email2, $mode, null, null, null, $array_copy_us[6], $array_copy_us[7]);
     } else {
         //Este correo se envia al hotel solo si esta marcado en sistema como NO, en el campo que pregunta si la reserva se enviara directamente a nosotros
         if (!$infos->send_reserve_directly) {
             //Correo para el hotel
             $body_email1 = hg_sendmail::hotel($postData, $infos, $in, $out, $selected_rooms, $roominfo, $hgconf);
             $subject_email1 = sprintf($array_copy_hotel[2], $infos->title, $postData['lastname'], $infos->cityname, $infos->countryname, date("F d, Y", $in), date("F d, Y", $out));
             $sendOk = JUtility::sendMail($array_copy_hotel[0], $array_copy_hotel[1], $infos->email, $subject_email1, $body_email1, $mode, $array_copy_hotel[3], $array_copy_hotel[4], null, $array_copy_hotel[5], $array_copy_hotel[6]);
         }
         //Copia a nosotros
         $body_email2 = hg_sendmail::backup($postData, $infos, $in, $out, $selected_rooms, $roominfo, $hgconf);
         $array_copy_us = explode("|", $hgconf->config_email_copy_bck);
         $subject_email2 = sprintf($array_copy_hotel[2], $infos->title, $postData['lastname'], $infos->cityname, $infos->countryname, date("F d, Y", $in), date("F d, Y", $out));
         $sendOk = JUtility::sendMail($array_copy_us[0], $array_copy_us[1], $array_copy_us[2], $subject_email2, $body_email2, $mode, $array_copy_us[4], $array_copy_us[5], null, $array_copy_us[6], $array_copy_us[7]);
         //Este es otro email que nos llega a nosotros para usarlo como respuesta una vez contactado al hotel
         $body_email3 = hg_sendmail::response_client($postData, $infos, $in, $out, $selected_rooms, $roominfo, $hgconf);
         $array_client_response_mail = explode("|", $hgconf->config_email_response_client);
         $subject_email3 = sprintf($array_client_response_mail[3], $infos->title, $postData['lastname'], $infos->cityname, $infos->countryname, date("F d, Y", $in), date("F d, Y", $out));
         $sendOk = JUtility::sendMail($array_client_response_mail[0], $array_client_response_mail[1], $array_client_response_mail[2], $subject_email3, $body_email3, $mode, $array_client_response_mail[4], $array_client_response_mail[5], null, $email_recipients, $postData['firstname'] . " " . $postData['lastname']);
         //Email para el cliente de confirmacion de envio de reserva
         $body_email4 = hg_sendmail::client($postData, $infos, $in, $out, $selected_rooms, $roominfo, $hgconf);
         $array_client_mail = explode("|", $hgconf->config_email_sent_client);
         $subject_email4 = sprintf($array_client_mail[2], $infos->title, $postData['lastname'], $infos->cityname, $infos->countryname, date("F d, Y", $in), date("F d, Y", $out));
         $sendOk = JUtility::sendMail($array_client_mail[0], $array_client_mail[1], $email_recipients, $subject_email4, $body_email4, $mode, $array_client_mail[4], $array_client_mail[5], null, $array_client_mail[6], $array_client_mail[7]);
     }
     if ($sendOk) {
         $mainframe =& JFactory::getApplication();
         $mainframe->enqueueMessage(JText::_('HG_THANK_YOU_FOR_YOUR_RESERVATION'));
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_hotelguide' . DS . 'tables');
         $dataRow =& JTable::getInstance('hg_reservations', '');
         // bind the data sent from the form to the table fields
         $dataRow->bind($postData);
         // store the message
         $dataRow->store();
         // record the message id so the attached files can be deleted
         $id = $dataRow->id;
         /*
         			$query = 'UPDATE #__reservations SET id = ' . $id . ' WHERE id = 0 and r_id = '.$postData['r_id'];
         			$db->setQuery($query);
         			$db->query();*/
     }
     header("Location: " . $this->baseurl . "/jpmoser_guide/index.php?option=com_jumi&fileid=5&hotelname=" . $infos->title);
     exit;
     //$this->display();
 }