Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.77 KB | None | 0 0
  1. <?php
  2. DEFINE('SYSTEM_CONST',true);
  3.  
  4. require 'initialization.inc.php';
  5. //---[inicializacia poli a session]------------------------------------
  6. session_start();
  7.  
  8. $content = '';
  9. $items = array();
  10. //---[inicializacia kosika a pola s produktami]--------------------------------
  11. if ($_SESSION['cart'])
  12. {
  13. $items = merge_equal_items((array)$_SESSION['cart']);
  14. }
  15. else
  16. {
  17. $error = CART_NOT_EXISTS."!";
  18. }
  19.  
  20. //--[spracovanie produktov a re-save session]---------------------------
  21. if ($_GET['action'] == "send")
  22. {
  23. $all['price'] = 0;
  24. $all['price_eu'] = 0;
  25. foreach ($items as $item)
  26. {
  27. $count = $item['count'];
  28. $id = $item['id'];
  29. $product = my_fetch_assoc(my_query("SELECT * FROM `products` WHERE `id` = '".$id."' LIMIT 1"));
  30. $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";
  31. $all['price'] += $count*$product['price'];
  32. $all['price_eu'] += $count*$product['price_eu'];
  33. }
  34.  
  35.  
  36. $finaly_price = $all['price'];
  37. $finaly_price_eu = $all['price_eu'];
  38.  
  39. $products_price = $finaly_price;
  40. $products_price_eu = $finaly_price_eu;
  41.  
  42. $deliver_price = ($lng != 'cs') ? 800 : ((round($finaly_price*1.20,1) >= 3000) ? 0 : 130);
  43. $deliver_price_eu = round($deliver_price/$kurz,1);
  44.  
  45. //$finaly_price += $deliver_price;
  46. //$finaly_price_eu += $deliver_price_eu;
  47.  
  48. $deliver_price_text = ($deliver_price > 0 ? '+'.$deliver_price.' Kč' : 'zdarma');
  49. $deliver_price_eu_text = ($deliver_price_eu > 0 ? '+'.$deliver_price_eu.' &euro;' : 'free');
  50.  
  51.  
  52. if ($_POST['mail'] != '' && $_POST['phone'] != '' && $_POST['name1'] != '' && $_POST['street1'] != '' && $_POST['city1'] != '')
  53. {
  54. $mail_text = "<br /><strong>".DATE.":</strong> ".date("d.m.Y")."<br /><br /><strong>".ORDERED_PRODUCTS.":</strong><br />".$mail_products."<br /><br />";
  55. $mail_text .= ''.PRODUCTS_PRICE.': <strong>'.$products_price.' Kč / '.$products_price_eu.' &euro;</strong><br />
  56. '.DELIVER_PRICE.': <strong>'.$deliver_price_text.' / '.$deliver_price_eu_text.'</strong><br /><hr style="text-align: left;" width="200" />
  57. '.FINALLY_PRICE.': <strong>'.($finaly_price + $deliver_price_text).' Kč / '.($finaly_price_eu + $deliver_price_eu_text).' &euro;</strong><br />
  58. '.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).' &euro;</strong><br /><br />';
  59. $mail_text .= "<strong>E-mail:</strong> ".$_POST['mail']."<br />";
  60. $mail_text .= "<strong>".MAIL_PHONE.":</strong> ".$_POST['phone']."<br />";
  61. $mail_text .= "<br /><strong>".DELIVER_ADDRESS.":</strong><br /> ".$_POST['company1']."<br />".$_POST['name1']."<br />".$_POST['street1']."<br />".$_POST['city1']."<br />";
  62. //$mail_text .= "<br/><strong>".KIND_OD_DELIVER.":</strong> ".$_POST['deal']."<br />";
  63. //$mail_text .= "<strong>Způsob platby / ".KIND_OF_PAYMENT.":</strong> ".$_POST['payment']."<br />";
  64. if ((isset($_POST['name2']) && $_POST['name2'] != "") || (isset($_POST['company2']) && $_POST['company2'] != ""))
  65. {
  66. $mail_text .= "<br /><strong>".PAYMENT_ADDRESS.":</strong><br />";
  67. $mail_text .= $_POST['company2']."<br />";
  68. $mail_text .= $_POST['name2']."<br />";
  69. $mail_text .= $_POST['street2']."<br />";
  70. $mail_text .= $_POST['city2']."<br />";
  71. }
  72. $mail_text .= "<br />";
  73. if (isset($_POST['ico']) && $_POST['ico'] != "")
  74. {
  75. $mail_text .= "<strong>IČO:</strong> ".$_POST['ico']."<br />";
  76. }
  77. if (isset($_POST['dic']) && $_POST['dic'] != "")
  78. {
  79. $mail_text .= "<strong>DIČ:</strong> ".$_POST['dic']."<br />";
  80. }
  81.  
  82. if (isset($_POST['note']) && $_POST['note'] != "")
  83. {
  84. $mail_text .= "<br /><strong>".MAIL_NOTE.":</strong> ".$_POST['note']."<br />";
  85. }
  86.  
  87.  
  88. $subject = NEW_ORDER;
  89.  
  90. $headers .= "From: panda@padla.eu <panda@padla.eu>\n";
  91. $headers .= "X-Priority: 1\n";
  92. $headers .= "Return-Path: <panda@padla.eu>\n";
  93. $headers .= "Content-Type: text/html; charset=utf-8\n";
  94.  
  95. $recipient="panda@padla.eu,".$_POST['mail'];
  96.  
  97. my_query("INSERT INTO `orders` SET `text` = '".$mail_text."', `new` = '0', `enabled` = '1'");
  98. $secure = md5($mail_text);
  99. $order_id = my_insert_id();
  100.  
  101. $link = $GLOBALS['domain'].'/objednavka-odeslani.php?lng='.$lng.'&amp;action=agree&order_id='.$order_id.'&secure='.$secure;
  102. //$uvod_text = ORDER_INTRO_TEXT."<br/><a href=\"".$link."\">".$link."</a><br/><br />";
  103.  
  104. //if (mail($GLOBALS['mail'], $subject, $uvod_text.$mail_text, $headers))
  105. if (mail($recipient, $subject, $uvod_text.$mail_text, $headers))
  106. {
  107. $_SESSION['cart'] = $items = array();
  108. $content .= "<h2>".ORDER_WAS_SUCCESSFULLY_CONFIRMED."!</h2>";
  109. }
  110. else
  111. {
  112. $content .= "<h2>".ERROR_NOT_ORDERED."!</h2>";
  113. }
  114.  
  115. $content .= '<input type="button" value=" '.CLOSE.' " onclick="window.location=\'./?lng='.$lng.'\';" />';
  116. }
  117. else
  118. {
  119. $content .= '<h2>'.STRICT_INPUTS.'!</h2><script>alert(\''.STRICT_INPUTS.'\')</script>';
  120. }
  121. }
  122. /*elseif ($_GET['action'] == "agree")
  123. {
  124. if (isset($_GET['order_id']) && $_GET['order_id'] != "" && is_numeric($_GET['order_id']))
  125. {
  126. $order = my_query("SELECT * FROM `orders` WHERE `id` = '".$_GET['order_id']."' LIMIT 1");
  127. if (my_num_rows($order) == 1)
  128. {
  129. $order = my_fetch_assoc($order);
  130. if ($_GET['secure'] == md5($order['text']))
  131. {
  132. $subject = "Nova (potvrzena) objednavka";
  133.  
  134. $headers .= "From: Nova objednavka\n";
  135. $headers .= "Return-Path: <".$GLOBALS['mail'].">\n";
  136. $headers .= "Content-Type: text/html; charset=utf-8\n";
  137.  
  138. $mail_text = $order['text'];
  139. my_query("UPDATE `orders` SET `enabled` = '1', `new` = '1' WHERE `id` = '".$_GET['order_id']."' LIMIT 1");
  140. mail($GLOBALS['mail'], $subject, $mail_text, $headers);
  141.  
  142. $error = ORDER_WAS_SUCCESSFULLY_CONFIRMED."!";
  143. }
  144. else
  145. {
  146. $error = BAD_AUTHENTIFICATION_KEY."!";
  147. }
  148. }
  149. else
  150. {
  151. $error = WRONG_ORDER_SPECIFICATION."!";
  152. }
  153. }
  154. else
  155. {
  156. $error = WRONG_ORDER_SPECIFICATION."!";
  157. }
  158. }*/
  159. if (count($items) > 0)
  160. {
  161. //echo '<pre>'.print_r($items, true).'</pre>';
  162.  
  163. if (!is_array($items)) // ak je pole prazdne tak sa vymazali vsetky polozky (prikazom vyssie) a teda pole nieje pole ale prazdny text
  164. {
  165. $content .= '<br />'.CART_IS_EMPTY.'!<meta http-equiv="refresh" content="3;url=./objednavka.php?lng='.$lng.'" />';
  166. }
  167. else
  168. {
  169. $content .= '<table width="100%" border="0">
  170. <tr>
  171. <td><strong>'.PIECES.'</strong></td>
  172. <td><strong>'.PRODUCT_NAME.'</strong></td>
  173. <td><strong>'.PRODUCT_CODE.'</strong></td>
  174. <td><strong>'.PRODUCT_PRICE.'</strong></td>
  175. <td><strong>'.PRODUCT_LENGTH.'</strong></td>
  176. <td><strong>'.PRODUCT_COLOR.'</strong></td>
  177. </tr><tr>';
  178. $all['price'] = 0;
  179. $all['price_eu'] = 0;
  180. foreach ($items as $item)
  181. {
  182. $count = $item['count'];
  183. $id = $item['id'];
  184. if ($count > 0)
  185. {
  186. $product = my_fetch_assoc(my_query("SELECT * FROM `products` WHERE `id` = '".$id."' LIMIT 1"));
  187.  
  188. $price = $product['price'];
  189. $price_eu = $product['price_eu'];
  190.  
  191. $product_html = '<td colspan="6"><hr /></td></tr><tr>
  192. <td><strong>'.$count.' x </strong></td>
  193. <td>'.$product["name_$lng"].'</td>
  194. <td>'.$product['code'].'</td>
  195. <td>'.$price.' Kč / '.$price_eu.' &euro;</td>
  196. <td>'.$item['length'].'</td>
  197. <td>'.$item['color'].'</td>
  198. </tr>';
  199. $all['price'] += $count*$price;
  200. $all['price_eu'] += $count*$price_eu;
  201.  
  202. $content .= $product_html;
  203. }
  204. }
  205. $content .= '</table>';
  206.  
  207. $finaly_price = $all['price'];
  208. $finaly_price_eu = $all['price_eu'];
  209.  
  210. $products_price = $finaly_price;
  211. $products_price_eu = $finaly_price_eu;
  212.  
  213. $deliver_price = ($lng != 'cs') ? 800 : ((round($finaly_price*1.21,1) >= 3000) ? 0 : 130);
  214. $deliver_price_eu = round($deliver_price/$kurz,1);
  215.  
  216. //$finaly_price += $deliver_price;
  217. //$finaly_price_eu += $deliver_price_eu;
  218.  
  219. $deliver_price_text = ($deliver_price > 0 ? '+'.$deliver_price.' Kč' : 'zdarma');
  220. $deliver_price_eu_text = ($deliver_price_eu > 0 ? '+'.$deliver_price_eu.' &euro;' : 'free');
  221.  
  222.  
  223. $content .= '<hr /><!-- div style="color: red;">'.LENGTH_TO_NOTE.'</div --><br />
  224. <form action="./objednavka-odeslani.php?lng='.$lng.'&amp;action=send" method="post" id="form" name="form" onsubmit="return order_confirm();">
  225. <input type="hidden" name="all_price" value="'.$finaly_price.'" />
  226. <input type="hidden" name="all_price_eu" value="'.$finaly_price_eu.'" />
  227. <table border="0">
  228. <tr><td>'.PRODUCTS_PRICE.':</td><td><strong>'.$products_price.' Kč / '.$products_price_eu.' &euro;</strong></td></tr>
  229. <tr><td>'.DELIVER_PRICE.':</td><td><strong>'.$deliver_price_text.' / '.$deliver_price_eu_text.'</strong></td></tr>
  230. <tr><td colspan="4"><hr style="text-align: left;" width="200" /></td></tr>
  231. <tr><td>'.FINALLY_PRICE.':</td><td><strong>'.($finaly_price + $deliver_price_text).' Kč / '.($finaly_price_eu + $deliver_price_eu_text).' &euro;</strong></td></tr>
  232. <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).' &euro;</strong></td></tr>
  233. <tr><td colspan="4"><hr /></td></tr>
  234. <tr><td>E-mail: *</td><td><input type="text" name="mail" size="50" maxlength="50" /></td></tr>
  235. <tr><td>'.PHONE.': *</td><td><input type="text" name="phone" size="50" maxlength="50" /></td></tr>
  236. <tr><td colspan="4"><hr /></td></tr>
  237. <tr><td colspan="2"><strong>'.DELIVER_ADDRESS.':</strong></tr>
  238. <tr><td>'.COMPANY.': </td><td><input type="text" name="company1" size="50" maxlength="50" /></td></tr>
  239. <tr><td>'.NAME_AND_SURNAME.': *</td><td><input type="text" name="name1" size="50" maxlength="50" /></td></tr>
  240. <tr><td>'.STREET_AND_NUMBER.': *</td><td><input type="text" name="street1" size="50" maxlength="50" /></td></tr>
  241. <tr><td>'.CITY.': *</td><td><input type="text" name="city1" size="50" maxlength="50" /></td></tr>
  242. <tr><td colspan="4"><hr /></td></tr>
  243. <tr><td colspan="2"><strong>'.PAYMENT_ADDRESS.':</strong> ('.PAYMENT_ADDRESS_NOTE.')</td></tr>
  244. <tr><td>'.COMPANY.': </td><td><input type="text" name="company2" size="50" maxlength="50" /></td></tr>
  245. <tr><td>'.NAME_AND_SURNAME.':</td><td><input type="text" name="name2" size="50" maxlength="50" /></td></tr>
  246. <tr><td>'.STREET_AND_NUMBER.':</td><td><input type="text" name="street2" size="50" maxlength="50" /></td></tr>
  247. <tr><td>'.CITY.':</td><td><input type="text" name="city2" size="50" maxlength="50" /></td></tr>
  248. <tr><td colspan="4"><hr /></td></tr>
  249. <tr><td>IČO:</td><td><input type="text" name="ico" size="50" maxlength="50" /></td></tr>
  250. <tr><td>DIČ:</td><td><input type="text" name="dic" size="50" maxlength="50" /></td></tr>
  251. <tr><td colspan="4"><hr /></td></tr>
  252. <tr><td style="vertical-align: top;">'.NOTE.':</td><td><textarea name="note" cols="50" rows="5"></textarea></td></tr>
  253. <tr><td colspan="4"><hr /></td></tr>
  254. <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>
  255. <tr><td colspan="2" style="text-align: center;"><input type="submit" value=" '.SEND.' " /></td></tr>
  256. </table>
  257. </form></div>';
  258. }
  259. }
  260. if ($error != "")
  261. {
  262. $content = '<h4 style="color: red;">'.$error.'</h4>
  263. <meta http-equiv="refresh" content="3;url=./?lng='.$lng.'" />'.$content;
  264. }
  265.  
  266. $_HTML['page_title'] = SENDING_ORDER;
  267. $_HTML['main_content'] = $content;
  268. require 'generator.inc.php';
  269.  
  270. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement