PageRenderTime 66ms CodeModel.GetById 42ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/models/saveCart.php

https://bitbucket.org/designbyheart/original
PHP | 51 lines | 33 code | 4 blank | 14 comment | 5 complexity | 76a5eea089771d4d8d26dd4e1923e3bf MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Created by JetBrains PhpStorm.
  4. * User: predragjevtic
  5. * Date: 9/15/12
  6. * Time: 8:44 PM
  7. * To change this template use File | Settings | File Templates.
  8. */
  9. require_once('../lib/setup.php');
  10. if (isset($_POST['cancelOrder']) || !isset($_POST['submitOrder'])) {
  11. $log = new Log();
  12. $log->note = "Narudžbina je otkazana";
  13. $log->userID = $_SESSION['clientID'];
  14. $log->eventTime = time();
  15. $log->selectedProducts = "";
  16. $log->save();
  17. $session->message("Porudžbina je otkazana");
  18. redirect_to(SITE_ROOT."my-account");
  19. } else {
  20. $order = new Order();
  21. $order->customerID = $_SESSION['clientID'];
  22. $order->orderDate = time();
  23. $address = Address::find_by_customer($_SESSION['clientID']);
  24. $order->status = 7;
  25. //notCompleteOrder 7
  26. //pending =1
  27. //confirmed =2
  28. //payed = 3
  29. //sentProducts = 4
  30. //closed = 5
  31. $products = array();
  32. $order->totalPrice =(float)$_POST['totalPrice'];
  33. $order->ipAddress = $_SERVER['REMOTE_ADDR'];
  34. foreach($_POST['numberOfItems'] as $key=>$value){
  35. for($i = 0; $i<$value; $i++){
  36. $products[] = $key;
  37. }
  38. }
  39. $order->products = str_replace('\n', '', str_replace('\r', '', $_POST['products']));
  40. $order->customerID = $_SESSION['clientID'];
  41. // print_r($order);
  42. $order->save();
  43. if (isset($order->id)) {
  44. $_SESSION['orderID'] = $order->id;
  45. }
  46. redirect_to(SITE_ROOT.'sendOrder');
  47. }