diff --git a/data/status.sql b/data/status.sql new file mode 100644 index 00000000..addebdda --- /dev/null +++ b/data/status.sql @@ -0,0 +1,30 @@ +# add roles +INSERT INTO `role` (`id`, `parent_id`, `roleId`, `active`, `updated`, `created`) VALUES +(NULL, NULL, 'onsitereg', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'), +(NULL, NULL, 'supradm', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'), +(NULL, NULL, 'preregcoordinator', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'), +(NULL, NULL, 'user', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'), +(NULL, NULL, 'admin', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'), +(NULL, NULL, 'guest', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'), +(NULL, NULL, 'participant', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'); +(NULL, NULL, 'buyer', 1, '2017-02-11 13:37:00', '2017-02-11 13:37:00'); + +# add admin user: admin@ers.inbaz.org +# tax examples +# deadline examples +# agegroup examples + +# add status +INSERT INTO `status` (`id`, `position`, `value`, `description`, `updated`, `created`, `active`) VALUES +(1, 1, 'order pending', '', NULL, NULL, 0), +(2, 2, 'ordered', '', NULL, NULL, 1), +(3, 3, 'paid', '', NULL, NULL, 1), +(4, 4, 'shipped', '', NULL, NULL, 1), +(5, 5, 'cancelled', '', NULL, NULL, 0), +(6, 6, 'transferred', '', NULL, NULL, 0); + +INSERT INTO `user` (`id`, `username`, `email`, `email_status`, `display_name`, `firstname`, `surname`, `gender`, `Country_id`, `password`, `hashkey`, `state`, `active`, `birthday`, `login_count`, `newsletter`, `updated`, `created`) VALUES +(NULL, NULL, 'andi@inbaz.org', NULL, NULL, 'Andi', 'Nitsche', NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, '2017-02-11 00:00:00', '2017-02-11 00:00:00'); + +INSERT INTO `user_has_role` (`user_id`, `role_id`) VALUES +('1', '5'); \ No newline at end of file diff --git a/module/ErsBase/src/ErsBase/Service/OrderService.php b/module/ErsBase/src/ErsBase/Service/OrderService.php index 43349aa0..3a16e6ab 100644 --- a/module/ErsBase/src/ErsBase/Service/OrderService.php +++ b/module/ErsBase/src/ErsBase/Service/OrderService.php @@ -53,40 +53,37 @@ public function getOrder() { $em = $this->getServiceLocator() ->get('Doctrine\ORM\EntityManager'); if(isset($cartContainer->order_id) && is_numeric($cartContainer->order_id)) { - $order = $em->getRepository('ErsBase\Entity\Order') + $checkOrder = $em->getRepository('ErsBase\Entity\Order') ->findOneBy(array('id' => $cartContainer->order_id)); - if(!$order) { - # Cannot find order with given id: Creating new order... - $order = new Entity\Order(); - $status = $em->getRepository('ErsBase\Entity\Status') - ->findOneBy(array('value' => 'order pending')); - $order->setStatus($status); - - $em->persist($order); - $em->flush(); - - $cartContainer->order_id = $order->getId(); + if($checkOrder) { + $this->order = $checkOrder; + $this->addLoggedInUser(); + return $checkOrder; } - - $this->order = $order; - $this->addLoggedInUser(); - return $order; - } else { - $order = new Entity\Order(); - $status = $em->getRepository('ErsBase\Entity\Status') - ->findOneBy(array('value' => 'order pending')); - $order->setStatus($status); - - $em->persist($order); - $em->flush(); - - $cartContainer->order_id = $order->getId(); - - $this->order = $order; - $this->addLoggedInUser(); - - return $order; } + + $newOrder = $this->createNewOrder(); + + $cartContainer->order_id = $newOrder->getId(); + + $this->order = $newOrder; + $this->addLoggedInUser(); + + return $newOrder; + } + + private function createNewOrder() { + $em = $this->getServiceLocator() + ->get('Doctrine\ORM\EntityManager'); + $newOrder = new Entity\Order(); + $status = $em->getRepository('ErsBase\Entity\Status') + ->findOneBy(array('value' => 'order pending')); + $newOrder->setStatus($status); + + $em->persist($newOrder); + $em->flush(); + + return $newOrder; } public function addLoggedInUser() { diff --git a/module/PreReg/src/PreReg/Controller/ProductController.php b/module/PreReg/src/PreReg/Controller/ProductController.php index 8aadebca..18dcb4fe 100644 --- a/module/PreReg/src/PreReg/Controller/ProductController.php +++ b/module/PreReg/src/PreReg/Controller/ProductController.php @@ -64,17 +64,6 @@ public function indexAction() )); } - /* - * initialize shopping cart - */ - /*private function initializeCart() { - $cartContainer = new Container('cart'); - if(!isset($cartContainer->init) && $cartContainer->init == 1) { - $cartContainer->order = new Entity\Order(); - $cartContainer->init = 1; - } - }*/ - public function addAction() { $this->getServiceLocator()->get('ErsBase\Service\TicketCounterService') ->checkLimits();