'), array('c#text-main')); $out .= table_end(); $out .= $added; } else { $out .= table_start(0, 1, 0, '100%'); $out .= table_tr(false, array('d'), array($lang['zadne_objednavky'].'

'), array('c#text-main')); $out .= table_end(); } /* ZOBRAZOVACI CAST SKRIPTU */ $out_body .= content_box( 'big' , $lang['objednavky'] , $out , $link , ( $row['c_photo'] ? sprintf( '%s' , $conf_basedir , $row['c_photo'] , $row['p_x_big'] , $row['p_y_big'] , 0 , $row['p_alt'] ) : false ) ); /* ZOBRAZOVACI CAST SKRIPTU */ require '../../../system/page_start.php'; // hlavicka stranky require '../../../system/page_body.php'; // telo stranky require '../../../system/page_end.php'; // paticka stranky vcetne uzavreni spojeni s databazi /* VYKONNA CAST SKRIPTU */ /* pridani objednavek do systemu */ function add_orders() { global $lang, $err; $form_inputs = array( 'first_name', 'last_name', 'email', 'phone', 'street', 'city', 'zip' ); foreach ( $form_inputs as $input ) { $_GET[$input] = urldecode($_GET[$input]); } if ( !$_GET['first_name'] || !$_GET['last_name'] ) { $err[] = $lang['chybi_jmeno']; } if ( !$_GET['email'] && !$_GET['phone'] ) { $err[] = $lang['mail_nebo_telefon']; } if ( $_GET['email'] && !preg_match('/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/', $_GET['email']) ) { $err[] = $lang['chybny_email']; } if ( !$_GET['clause'] ) { $err[] = $lang['podminky_nesouhlasil']; } if ( count($err) > 0 || !count($_SESSION['ap']) ) { return; } /* created_by * 1 - zakaznik pres web * 2 - admin rucne */ $definite_order = $_GET['definite_order'] ? 'Y' : 'N'; mysql_query(" INSERT INTO c_orders (o_created, o_created_by, email, phone, order_note, first_name, last_name, street, city, zip, language, definite_order) VALUES (NOW(), 1, '{$_GET['email']}', '{$_GET['phone']}', '{$_GET['note']}', '{$_GET['first_name']}', '{$_GET['last_name']}', '{$_GET['street']}', '{$_GET['city']}', '{$_GET['zip']}', {$_SESSION['lng']}, '$definite_order') "); if ( mysql_errno() ) { $err[] = $lang['chyba_db']; $err[] = mysql_error(); return; } $order_id = mysql_insert_id(); $exchange = $_SESSION['lng'] == 1 ? mysql_result(MSQ_utf("SELECT kc2euro FROM c_euro_rate"), 0, 0) : 1; foreach ( (array) $_SESSION['ap'] as $apa_id => $data ) { $from = date('Y-m-d', strtotime($data['od'])); $to = date('Y-m-d', strtotime($data['do'])); if ( occupation_conflict($apa_id, $from, $to) ) { $err[] = str_replace('*', "'{$data['apa_name']}'", $lang['konflikt_terminu_2']); $err[] = $lang['konflikt_terminu_3']; return 1; } $all_prices = get_price($apa_id, $data); $total = $all_prices[0]; $currency = array_pop($all_prices); $break = (int) $data['snidane']; $lunch = (int) $data['obedy']; $dinner = (int) $data['vecere']; $half = $data['penze'] == 1 ? 1 : 0; $full = $data['penze'] == 2 ? 2 : 0; MSQ_utf(" INSERT INTO c_orders_apa (order_id, apa_id, apa_name, term_from, term_to, adults, childs_3, childs_12, childs_18, pets, apa_note, state, price, currency, breakfast, lunch, dinner, half_board, full_board) VALUES ($order_id, $apa_id, '{$data['apa_name']}', '$from', '$to', '{$data['dospeli']}', '{$data['deti_3']}', '{$data['deti_12']}', '{$data['deti_18']}', '{$data['zvirata']}', '{$data['poznamka']}', 1, '$total', '$currency', $break, $lunch, $dinner, $half, $full) "); if ( mysql_errno() ) { $err[] = $lang['chyba_db']; $err[] = mysql_error(); MSQ_utf("DELETE FROM c_orders WHERE order_id=$order_id"); return; } unset($_SESSION['ap'][$apa_id]); } $mail = create_mail(1, $order_id); if ( $_GET['email'] ) { send_mail($_GET['email'], $mail[0], $mail[1]); } send_mail('info@active-holiday.cz', 'Nová objednávka', $mail[1]); return ''; } /* zobrazeni seznamu objednavek */ function show_orders() { global $lang, $err, $conf_basedir; $exchange = mysql_result(MSQ_utf("SELECT kc2euro FROM c_euro_rate"), 0, 0); foreach ( $_SESSION['ap'] as $apa_id => $data ) { list($total, $pri_pri, $pri_tax, $pri_break, $pri_lunch, $pri_dinner, $pri_half, $pri_full, $pri_pets, $pri_air, $pri_internet, $currency) = get_price($apa_id, $data); /* vystup jednotlivych objednanych apartmanu */ $sql = " SELECT a.apa_id, apa_code, apa_beds, apa_bonus, apa_name, obj_price_backup, obj_price_prepay, obj_name FROM c_apartment `a` LEFT JOIN c_apartment_lng `al` ON al.apa_id = a.apa_id AND al.lng_id = {$_SESSION['lng']}, c_object `o` LEFT JOIN c_object_lng `ol` ON ol.obj_id = o.obj_id AND ol.lng_id = {$_SESSION['lng']} WHERE a.apa_id = $apa_id AND a.apa_deleted IS NULL AND a.obj_id = o.obj_id "; $row = @mysql_fetch_assoc(MSQ_utf($sql)); $_SESSION['ap'][$apa_id]['apa_name'] = "{$row['obj_name']} - {$row['apa_name']}"; $out .= table_start(false, false, false, false, false, 'orderdetails'); $out .= table_tr('alt', array('h'), array($row['obj_name'] . ' - ' . $row['apa_name']), array('c#title^l#2') ); $out .= table_tr(false, array('d', 'd'), array( $lang['cena_celkem'] . ':', '' . number_format($total, 0, '.', ' ') . ',- ' . $currency . '' ), array('c#title', 'c#value') ); $out .= table_tr('alt', array('d', 'd'), array($lang['kod_apartmanu'].':', $row['apa_code']), array('c#title', 'c#value') ); $out .= table_tr(false, array('d', 'd'), array($lang['termin'].':', $data['od'].' - '.$data['do']), array('c#title', 'c#value') ); $out .= table_tr('alt', array('d', 'd'), array($lang['dospeli_big'].':', $data['dospeli']), array('c#title', 'c#value') ); $alt = false; if ( $data['deti_3'] > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['deti_3'].':', $data['deti_3']), array('c#title', 'c#value')); $alt = $alt ? false : 'alt'; } if ( $data['deti_12'] > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['deti_12'].':', $data['deti_12']), array('c#title', 'c#value')); $alt = $alt ? false : 'alt'; } if ( $data['deti_18'] > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['deti_18'].':', $data['deti_18']), array('c#title', 'c#value')); $alt = $alt ? false : 'alt'; } if ( $data['zvirata'] > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['zvirata'].':', $data['zvirata']), array('c#title', 'c#value')); $alt = $alt ? false : 'alt'; } if ( $data['poznamka'] ) { $out .= table_tr($alt, array('d', 'd'), array($lang['poznamka'].':', nl2br($data['poznamka'])), array('c#title^v#top', 'c#value')); $alt = $alt ? false : 'alt'; } $out .= table_tr($alt, array('d', 'd', 'd'), array($lang['cena_ubytovani'] . ':', number_format($pri_pri, 0, '.', ' ') . ',- ' . $currency), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; /* if ( $pri_tax > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['pobytova_taxa'].':', show_price($pri_tax)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_break > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['snidane_big'].':', show_price($pri_break)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_lunch > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['obedy_big'].':', show_price($pri_lunch)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_dinner > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['vecere_big'].':', show_price($pri_dinner)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_half > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['polopenze_big'].':', show_price($pri_half)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_full > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['plna_penze_big'].':', show_price($pri_full)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_pets > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['zvirata'].':', show_price($pri_pets)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_air > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['klimatizace'].':', show_price($pri_air)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } if ( $pri_internet > 0 ) { $out .= table_tr($alt, array('d', 'd'), array($lang['internet'].':', show_price($pri_internet)), array('c#title', 'c#value') ); $alt = $alt ? false : 'alt'; } */ $out .= table_tr($alt, array('d'), array($lang['specifikace_ve_fakture']), array('c#value^l#2') ); $out .= table_tr(false, array('d'), array( '
' . a_link( $lang['zrusit_objednavku'] , $_SERVER['PHP_SELF'] . '?del=' . $apa_id , false , 'button' , "return jsConfirm('{$lang['opravdu_zrusit']}');" ) ), array('a#center^l#2') ); $out .= table_end(); } $out .= '
'; $out .= form_start('get', $_SERVER['PHP_SELF']); $out .= table_start(false, false, false, false, false, 'orderdetails'); if ( count($err) > 0 ) { $out .= table_tr('err', array('d'), array( implode("
\n", $err) ), array('a#center^l#2') ); } $out .= table_tr(false, array('d'), array(''), array('c#tr-separator-2^l#2')); $out .= table_tr(false, array('d', 'd'), array($lang['jmeno'].':', form_input('text', 'txt w150', 'first_name', $_GET['first_name'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['prijmeni'].':', form_input('text', 'txt w150', 'last_name', $_GET['last_name'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['mail_mail'].':', form_input('text', 'txt w150', 'email', $_GET['email'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['telefon_big'].':', form_input('text', 'txt w150', 'phone', $_GET['phone'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['mesto'].':', form_input('text', 'txt w150', 'city', $_GET['city'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['ulice'].':', form_input('text', 'txt w150', 'street', $_GET['street'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['psc'].':', form_input('text', 'txt w150', 'zip', $_GET['zip'])), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array($lang['poznamka'].':', form_textarea('txt', 'note', 3, $_GET['note'])), array('c#label^v#top', false) ); $out .= table_tr(false, array('d'), array(''), array('c#tr-separator^l#2')); $out .= table_tr(false, array('d', 'd'), array( '
', form_input('checkbox', '', 'definite_order', 1, ($_GET['definite_order'] ? ' checked' : ''), ' id="definite-order"') . ' ' ), array('c#label', false) ); $out .= table_tr(false, array('d', 'd'), array('
', form_input('checkbox', '', 'clause', 1, ' id="clause-id"') . ' ' . $lang['podminky_souhlas'] . '' ), array('c#label', false) ); $out .= table_tr(false, array('d'), array(''), array('c#tr-separator^l#2')); $out .= table_tr(false, array('d'), array(form_input('submit', 'btnsimple red', 'add', $lang['odeslat_objednavku'])), array('a#center^l#2') ); $out .= table_end(); $out .= form_end(); $result = MSQ_utf(" SELECT c.c_header_show , cl.c_content, cl.c_header FROM c_content `c` , c_content_lng `cl` WHERE c.c_id IN (31, 32) AND c.c_id = cl.c_id AND cl.lng_id = {$_SESSION['lng']} ORDER BY c.c_order "); $out .= '
'; while ( $row = mysql_fetch_assoc( $result ) ) { if ( $row['c_header_show'] ) { $out .= '
' . $row['c_header'] . '
'; } $out .= $row['c_content']; } $out .= '
'; return $out; } /* ceny apartmanu v prubehu roku */ function define_prices($apa_id, $from, $to, $visitors, &$prices, $currency) { $exchange = mysql_result(MSQ_utf("SELECT kc2euro FROM c_euro_rate"), 0, 0); $bonus = mysql_result( MSQ_utf(" SELECT 1 + a.apa_bonus / 100 FROM c_apartment `a` INNER JOIN c_object `o` USING (obj_id) WHERE a.apa_id = $apa_id AND a.apa_deleted IS NULL ") , 0 , 0 ); $result = mysql_query(" SELECT t.from_day, t.from_month, t.to_day, t.to_month FROM c_prices `p` , c_terms `t` WHERE p.apa_id = $apa_id AND p.pri_id = t.pri_id AND ( ( {$from[1]} < t.to_month || ( {$from[1]} = t.to_month AND {$from[0]} <= t.to_day) ) AND ( {$to[1]} > t.from_month || ( {$to[1]} = t.from_month AND {$to[0]} >= t.from_day) ) ) GROUP BY CONCAT(t.from_day, '.', t.from_month, '-', t.to_day, '.', t.to_month) "); if ( mysql_errno() || !$result ) { echo mysql_error(); return false; } $tmp = 0; for ( $i = 1 ; $i <= 12 ; $i++ ) { $tmp += date('t', mktime(0, 0, 0, $i, 1)); $year[$i] = $tmp; } while ( $terms = mysql_fetch_assoc( $result ) ) { $row = @mysql_fetch_assoc( mysql_query(" SELECT p.* , pl.* , t.* FROM c_prices `p` LEFT JOIN c_prices_lng `pl` ON pl.pri_id = p.pri_id AND lng_id = {$_SESSION['lng']} , c_terms `t` WHERE p.apa_id = $apa_id AND p.pri_id = t.pri_id AND t.from_day = {$terms['from_day']} AND t.from_month = {$terms['from_month']} AND t.to_day = {$terms['to_day']} AND t.to_month = {$terms['to_month']} ORDER BY IF( p.pri_type - 1 >= $visitors , p.pri_type , 100 - p.pri_type ) ASC LIMIT 1 ") ); if ( mysql_errno() || !$result ) { echo mysql_error(); return false; } $from = explode('.', $row['term_from']); $to = explode('.', $row['term_to']); $price_list = array( 'pri_type' => $row['pri_type'], 'pri_price' => $row['pri_price'] * $bonus, 'pri_tax' => $row['pri_tax'], 'pri_breakfast' => $row['pri_breakfast'], 'pri_lunch' => $row['pri_lunch'], 'pri_dinner' => $row['pri_dinner'], 'pri_pets' => $row['pri_pets'], 'pri_half' => $row['pri_half'], 'pri_full' => $row['pri_full'], 'pri_internet' => $row['pri_internet'], 'pri_air_condition' => $row['pri_air_condition'], 'pri_discount_type' => $row['pri_discount_type'], 'pri_discount_price' => $row['pri_discount_price'] * $bonus, 'pri_note' => $row['pri_note'] ); $start = $year[$from[1] - 1] + $from[0]; $end = $year[$to[1] - 1] + $to[0]; if ( $start < $end ) { for ($i=$start ; $i<=$end ; $i++) { $prices[$i] = $price_list; } } else { for ($i=$start; $i<=$year[12] ; $i++) { $prices[$i] = $price_list; } for ($i=1; $i<=$end ; $i++) { $prices[$i] = $price_list; } } } } /* vypocet ceny apartmanu */ function get_price($apa_id, $data) { $tmp = 0; for ($i=1 ; $i<=12 ; $i++) { $tmp += date('t', mktime(0, 0, 0, $i, 1)); $year[$i] = $tmp; } $od = explode('.', $data['od']); $do = explode('.', $data['do']); $start = $year[$od[1] - 1] + $od[0]; $end = $year[$do[1] - 1] + $do[0] - 1; $visitors = $data['dospeli'] + $data['deti_3'] + $data['deti_12'] + $data['deti_18']; define_prices($apa_id, $od, $do, $visitors, $prices, $_SESSION['lng']); if ( $start <= $end ) { for ( $i = $start; $i <= $end; $i++) { $pri_pri += $prices[$i]['pri_type'] == 2 ? $visitors * (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1) : (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1); # : $visitors * (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1); $pri_tax += $prices[$i]['pri_tax'] * $visitors; $pri_break += $prices[$i]['pri_breakfast'] * $visitors; $pri_lunch += $prices[$i]['pri_lunch'] * $visitors; $pri_dinner += $prices[$i]['pri_dinner'] * $visitors; $pri_half += $prices[$i]['pri_half'] * $visitors; $pri_full += $prices[$i]['pri_full'] * $visitors; $pri_pets += $prices[$i]['pri_pets'] * $data['zvirata']; $pri_air += $prices[$i]['pri_air_condition']; $pri_internet += $prices[$i]['pri_internet']; $pri_discount_price += $prices[$i]['pri_type'] == 2 ? $visitors * (int) calculate_price( $prices[$i]['pri_discount_price'], $_SESSION['lng'], 1) : (int) calculate_price( $prices[$i]['pri_discount_price'], $_SESSION['lng'], 1); $pri_discount_type = $prices[$i]['pri_discount_type']; } } else { for ($i=$start; $i<=$year[12]; $i++) { $pri_pri += $prices[$i]['pri_type'] == 2 ? $visitors * (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1) : (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1); # : $visitors * (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1); $pri_tax += $prices[$i]['pri_tax']; $pri_break += $prices[$i]['pri_breakfast'] * $visitors; $pri_lunch += $prices[$i]['pri_lunch'] * $visitors; $pri_dinner += $prices[$i]['pri_dinner'] * $visitors; $pri_half += $prices[$i]['pri_half'] * $visitors; $pri_full += $prices[$i]['pri_full'] * $visitors; $pri_pets += $prices[$i]['pri_pets'] * $data['zvirata']; $pri_air += $prices[$i]['pri_air_condition']; $pri_internet += $prices[$i]['pri_internet']; $pri_discount_price += $prices[$i]['pri_type'] == 2 ? $visitors * (int) calculate_price( $prices[$i]['pri_discount_price'], $_SESSION['lng'], 1) : (int) calculate_price( $prices[$i]['pri_discount_price'], $_SESSION['lng'], 1); $pri_discount_type = $prices[$i]['pri_discount_type']; } for ($i=1; $i<=$end; $i++) { $pri_pri += $prices[$i]['pri_type'] == 2 ? $visitors * (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1) : (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1); # : $visitors * (int) calculate_price( $prices[$i]['pri_price'], $_SESSION['lng'], 1); $pri_tax += $prices[$i]['pri_tax']; $pri_break += $prices[$i]['pri_breakfast'] * $visitors; $pri_lunch += $prices[$i]['pri_lunch'] * $visitors; $pri_dinner += $prices[$i]['pri_dinner'] * $visitors; $pri_half += $prices[$i]['pri_half'] * $visitors; $pri_full += $prices[$i]['pri_full'] * $visitors; $pri_pets += $prices[$i]['pri_pets'] * $data['zvirata']; $pri_air += $prices[$i]['pri_air_condition']; $pri_internet += $prices[$i]['pri_internet']; $pri_discount_price += $prices[$i]['pri_type'] == 2 ? $visitors * (int) calculate_price( $prices[$i]['pri_discount_price'], $_SESSION['lng'], 1) : (int) calculate_price( $prices[$i]['pri_discount_price'], $_SESSION['lng'], 1); $pri_discount_type = $prices[$i]['pri_discount_type']; } } $pri_break = $data['snidane'] ? $pri_break : 0; $pri_lunch = $data['obedy'] ? $pri_lunch : 0; $pri_dinner = $data['vecere'] ? $pri_dinner : 0; $pri_half = $data['penze'] == 1 ? $pri_half : 0; $pri_full = $data['penze'] == 2 ? $pri_full : 0; $pri_pets = $data['zvirata'] ? $pri_pets : 0; $pri_pri = $pri_discount_price && $pri_discount_type ? $pri_discount_price : $pri_pri; $total = $pri_pri + $pri_break + $pri_lunch + $pri_dinner + $pri_half + $pri_full; $currency = $_SESSION['lng'] == 1 ? 'Kč' : "\xE2\x82\xAc"; return array( # number_format($total, 0, '.', ' '), # number_format($pri_pri, 0, '.', ' '), $total, $pri_pri, $pri_tax, $pri_break, $pri_lunch, $pri_dinner, $pri_half, $pri_full, $pri_pets, $pri_air, $pri_internet, $currency ); } ?>