Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- DEFINE('SYSTEM_CONST',true);
- require 'initialization.inc.php';
- //---[inicializacia poli a session]------------------------------------
- session_start();
- $content = '';
- $items = array();
- //---[inicializacia kosika a pola s produktami]--------------------------------
- if ($_SESSION['cart'])
- {
- $items = merge_equal_items((array)$_SESSION['cart']);
- }
- else
- {
- $error = CART_NOT_EXISTS."!";
- }
- //--[spracovanie produktov a re-save session]---------------------------
- if ($_GET['action'] == "send")
- {
- $all['price'] = 0;
- $all['price_eu'] = 0;
- foreach ($items as $item)
- {
- $count = $item['count'];
- $id = $item['id'];
- $product = my_fetch_assoc(my_query("SELECT * FROM `products` WHERE `id` = '".$id."' LIMIT 1"));
- $mail_products .= $count.' x '.$product['code'].' ('.$product["name_$lng"].' /'.$product['name_cs'].') - '.PRODUCT_COLOR.'/Barva: '.$item['color'].', '.PRODUCT_LENGTH.'/Délka: '.$item['length'].' '."<br />\n";
- $all['price'] += $count*$product['price'];
- $all['price_eu'] += $count*$product['price_eu'];
- }
- $finaly_price = $all['price'];
- $finaly_price_eu = $all['price_eu'];
- $products_price = $finaly_price;
- $products_price_eu = $finaly_price_eu;
- $deliver_price = ($lng != 'cs') ? 800 : ((round($finaly_price*1.20,1) >= 3000) ? 0 : 130);
- $deliver_price_eu = round($deliver_price/$kurz,1);
- //$finaly_price += $deliver_price;
- //$finaly_price_eu += $deliver_price_eu;
- $deliver_price_text = ($deliver_price > 0 ? '+'.$deliver_price.' Kč' : 'zdarma');
- $deliver_price_eu_text = ($deliver_price_eu > 0 ? '+'.$deliver_price_eu.' €' : 'free');
- if ($_POST['mail'] != '' && $_POST['phone'] != '' && $_POST['name1'] != '' && $_POST['street1'] != '' && $_POST['city1'] != '')
- {
- $mail_text = "<br /><strong>".DATE.":</strong> ".date("d.m.Y")."<br /><br /><strong>".ORDERED_PRODUCTS.":</strong><br />".$mail_products."<br /><br />";
- $mail_text .= ''.PRODUCTS_PRICE.': <strong>'.$products_price.' Kč / '.$products_price_eu.' €</strong><br />
- '.DELIVER_PRICE.': <strong>'.$deliver_price_text.' / '.$deliver_price_eu_text.'</strong><br /><hr style="text-align: left;" width="200" />
- '.FINALLY_PRICE.': <strong>'.($finaly_price + $deliver_price_text).' Kč / '.($finaly_price_eu + $deliver_price_eu_text).' €</strong><br />
- '.FINALLY_PRICE_DUTY.': <strong style="color: blue;">'.round(($finaly_price + $deliver_price) * 1.21,1).' Kč / '.round(($finaly_price_eu + $deliver_price_eu)*1.21,1).' €</strong><br /><br />';
- $mail_text .= "<strong>E-mail:</strong> ".$_POST['mail']."<br />";
- $mail_text .= "<strong>".MAIL_PHONE.":</strong> ".$_POST['phone']."<br />";
- $mail_text .= "<br /><strong>".DELIVER_ADDRESS.":</strong><br /> ".$_POST['company1']."<br />".$_POST['name1']."<br />".$_POST['street1']."<br />".$_POST['city1']."<br />";
- //$mail_text .= "<br/><strong>".KIND_OD_DELIVER.":</strong> ".$_POST['deal']."<br />";
- //$mail_text .= "<strong>Způsob platby / ".KIND_OF_PAYMENT.":</strong> ".$_POST['payment']."<br />";
- if ((isset($_POST['name2']) && $_POST['name2'] != "") || (isset($_POST['company2']) && $_POST['company2'] != ""))
- {
- $mail_text .= "<br /><strong>".PAYMENT_ADDRESS.":</strong><br />";
- $mail_text .= $_POST['company2']."<br />";
- $mail_text .= $_POST['name2']."<br />";
- $mail_text .= $_POST['street2']."<br />";
- $mail_text .= $_POST['city2']."<br />";
- }
- $mail_text .= "<br />";
- if (isset($_POST['ico']) && $_POST['ico'] != "")
- {
- $mail_text .= "<strong>IČO:</strong> ".$_POST['ico']."<br />";
- }
- if (isset($_POST['dic']) && $_POST['dic'] != "")
- {
- $mail_text .= "<strong>DIČ:</strong> ".$_POST['dic']."<br />";
- }
- if (isset($_POST['note']) && $_POST['note'] != "")
- {
- $mail_text .= "<br /><strong>".MAIL_NOTE.":</strong> ".$_POST['note']."<br />";
- }
- $subject = NEW_ORDER;
- $headers .= "From: panda@padla.eu <panda@padla.eu>\n";
- $headers .= "X-Priority: 1\n";
- $headers .= "Return-Path: <panda@padla.eu>\n";
- $headers .= "Content-Type: text/html; charset=utf-8\n";
- $recipient="panda@padla.eu,".$_POST['mail'];
- my_query("INSERT INTO `orders` SET `text` = '".$mail_text."', `new` = '0', `enabled` = '1'");
- $secure = md5($mail_text);
- $order_id = my_insert_id();
- $link = $GLOBALS['domain'].'/objednavka-odeslani.php?lng='.$lng.'&action=agree&order_id='.$order_id.'&secure='.$secure;
- //$uvod_text = ORDER_INTRO_TEXT."<br/><a href=\"".$link."\">".$link."</a><br/><br />";
- //if (mail($GLOBALS['mail'], $subject, $uvod_text.$mail_text, $headers))
- if (mail($recipient, $subject, $uvod_text.$mail_text, $headers))
- {
- $_SESSION['cart'] = $items = array();
- $content .= "<h2>".ORDER_WAS_SUCCESSFULLY_CONFIRMED."!</h2>";
- }
- else
- {
- $content .= "<h2>".ERROR_NOT_ORDERED."!</h2>";
- }
- $content .= '<input type="button" value=" '.CLOSE.' " onclick="window.location=\'./?lng='.$lng.'\';" />';
- }
- else
- {
- $content .= '<h2>'.STRICT_INPUTS.'!</h2><script>alert(\''.STRICT_INPUTS.'\')</script>';
- }
- }
- /*elseif ($_GET['action'] == "agree")
- {
- if (isset($_GET['order_id']) && $_GET['order_id'] != "" && is_numeric($_GET['order_id']))
- {
- $order = my_query("SELECT * FROM `orders` WHERE `id` = '".$_GET['order_id']."' LIMIT 1");
- if (my_num_rows($order) == 1)
- {
- $order = my_fetch_assoc($order);
- if ($_GET['secure'] == md5($order['text']))
- {
- $subject = "Nova (potvrzena) objednavka";
- $headers .= "From: Nova objednavka\n";
- $headers .= "Return-Path: <".$GLOBALS['mail'].">\n";
- $headers .= "Content-Type: text/html; charset=utf-8\n";
- $mail_text = $order['text'];
- my_query("UPDATE `orders` SET `enabled` = '1', `new` = '1' WHERE `id` = '".$_GET['order_id']."' LIMIT 1");
- mail($GLOBALS['mail'], $subject, $mail_text, $headers);
- $error = ORDER_WAS_SUCCESSFULLY_CONFIRMED."!";
- }
- else
- {
- $error = BAD_AUTHENTIFICATION_KEY."!";
- }
- }
- else
- {
- $error = WRONG_ORDER_SPECIFICATION."!";
- }
- }
- else
- {
- $error = WRONG_ORDER_SPECIFICATION."!";
- }
- }*/
- if (count($items) > 0)
- {
- //echo '<pre>'.print_r($items, true).'</pre>';
- if (!is_array($items)) // ak je pole prazdne tak sa vymazali vsetky polozky (prikazom vyssie) a teda pole nieje pole ale prazdny text
- {
- $content .= '<br />'.CART_IS_EMPTY.'!<meta http-equiv="refresh" content="3;url=./objednavka.php?lng='.$lng.'" />';
- }
- else
- {
- $content .= '<table width="100%" border="0">
- <tr>
- <td><strong>'.PIECES.'</strong></td>
- <td><strong>'.PRODUCT_NAME.'</strong></td>
- <td><strong>'.PRODUCT_CODE.'</strong></td>
- <td><strong>'.PRODUCT_PRICE.'</strong></td>
- <td><strong>'.PRODUCT_LENGTH.'</strong></td>
- <td><strong>'.PRODUCT_COLOR.'</strong></td>
- </tr><tr>';
- $all['price'] = 0;
- $all['price_eu'] = 0;
- foreach ($items as $item)
- {
- $count = $item['count'];
- $id = $item['id'];
- if ($count > 0)
- {
- $product = my_fetch_assoc(my_query("SELECT * FROM `products` WHERE `id` = '".$id."' LIMIT 1"));
- $price = $product['price'];
- $price_eu = $product['price_eu'];
- $product_html = '<td colspan="6"><hr /></td></tr><tr>
- <td><strong>'.$count.' x </strong></td>
- <td>'.$product["name_$lng"].'</td>
- <td>'.$product['code'].'</td>
- <td>'.$price.' Kč / '.$price_eu.' €</td>
- <td>'.$item['length'].'</td>
- <td>'.$item['color'].'</td>
- </tr>';
- $all['price'] += $count*$price;
- $all['price_eu'] += $count*$price_eu;
- $content .= $product_html;
- }
- }
- $content .= '</table>';
- $finaly_price = $all['price'];
- $finaly_price_eu = $all['price_eu'];
- $products_price = $finaly_price;
- $products_price_eu = $finaly_price_eu;
- $deliver_price = ($lng != 'cs') ? 800 : ((round($finaly_price*1.21,1) >= 3000) ? 0 : 130);
- $deliver_price_eu = round($deliver_price/$kurz,1);
- //$finaly_price += $deliver_price;
- //$finaly_price_eu += $deliver_price_eu;
- $deliver_price_text = ($deliver_price > 0 ? '+'.$deliver_price.' Kč' : 'zdarma');
- $deliver_price_eu_text = ($deliver_price_eu > 0 ? '+'.$deliver_price_eu.' €' : 'free');
- $content .= '<hr /><!-- div style="color: red;">'.LENGTH_TO_NOTE.'</div --><br />
- <form action="./objednavka-odeslani.php?lng='.$lng.'&action=send" method="post" id="form" name="form" onsubmit="return order_confirm();">
- <input type="hidden" name="all_price" value="'.$finaly_price.'" />
- <input type="hidden" name="all_price_eu" value="'.$finaly_price_eu.'" />
- <table border="0">
- <tr><td>'.PRODUCTS_PRICE.':</td><td><strong>'.$products_price.' Kč / '.$products_price_eu.' €</strong></td></tr>
- <tr><td>'.DELIVER_PRICE.':</td><td><strong>'.$deliver_price_text.' / '.$deliver_price_eu_text.'</strong></td></tr>
- <tr><td colspan="4"><hr style="text-align: left;" width="200" /></td></tr>
- <tr><td>'.FINALLY_PRICE.':</td><td><strong>'.($finaly_price + $deliver_price_text).' Kč / '.($finaly_price_eu + $deliver_price_eu_text).' €</strong></td></tr>
- <tr><td>'.FINALLY_PRICE_DUTY.':</td><td><strong style="color: blue;">'.round(($finaly_price + $deliver_price) * 1.21,1).' Kč / '.round(($finaly_price_eu + $deliver_price_eu)*1.21,1).' €</strong></td></tr>
- <tr><td colspan="4"><hr /></td></tr>
- <tr><td>E-mail: *</td><td><input type="text" name="mail" size="50" maxlength="50" /></td></tr>
- <tr><td>'.PHONE.': *</td><td><input type="text" name="phone" size="50" maxlength="50" /></td></tr>
- <tr><td colspan="4"><hr /></td></tr>
- <tr><td colspan="2"><strong>'.DELIVER_ADDRESS.':</strong></tr>
- <tr><td>'.COMPANY.': </td><td><input type="text" name="company1" size="50" maxlength="50" /></td></tr>
- <tr><td>'.NAME_AND_SURNAME.': *</td><td><input type="text" name="name1" size="50" maxlength="50" /></td></tr>
- <tr><td>'.STREET_AND_NUMBER.': *</td><td><input type="text" name="street1" size="50" maxlength="50" /></td></tr>
- <tr><td>'.CITY.': *</td><td><input type="text" name="city1" size="50" maxlength="50" /></td></tr>
- <tr><td colspan="4"><hr /></td></tr>
- <tr><td colspan="2"><strong>'.PAYMENT_ADDRESS.':</strong> ('.PAYMENT_ADDRESS_NOTE.')</td></tr>
- <tr><td>'.COMPANY.': </td><td><input type="text" name="company2" size="50" maxlength="50" /></td></tr>
- <tr><td>'.NAME_AND_SURNAME.':</td><td><input type="text" name="name2" size="50" maxlength="50" /></td></tr>
- <tr><td>'.STREET_AND_NUMBER.':</td><td><input type="text" name="street2" size="50" maxlength="50" /></td></tr>
- <tr><td>'.CITY.':</td><td><input type="text" name="city2" size="50" maxlength="50" /></td></tr>
- <tr><td colspan="4"><hr /></td></tr>
- <tr><td>IČO:</td><td><input type="text" name="ico" size="50" maxlength="50" /></td></tr>
- <tr><td>DIČ:</td><td><input type="text" name="dic" size="50" maxlength="50" /></td></tr>
- <tr><td colspan="4"><hr /></td></tr>
- <tr><td style="vertical-align: top;">'.NOTE.':</td><td><textarea name="note" cols="50" rows="5"></textarea></td></tr>
- <tr><td colspan="4"><hr /></td></tr>
- <tr><td>Napište hlavní město ČR (vše malým):</td><td><input type="text" name="overeni" size="50" maxlength="50" /></td></tr>
- <tr><td colspan="2" style="text-align: center;"><input type="submit" value=" '.SEND.' " /></td></tr>
- </table>
- </form></div>';
- }
- }
- if ($error != "")
- {
- $content = '<h4 style="color: red;">'.$error.'</h4>
- <meta http-equiv="refresh" content="3;url=./?lng='.$lng.'" />'.$content;
- }
- $_HTML['page_title'] = SENDING_ORDER;
- $_HTML['main_content'] = $content;
- require 'generator.inc.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement