public function editAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/product-variant', array('action' => 'add')); } $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('product-variant-value')) { $forrest->set('product-variant-value', 'admin/product'); } $value = $em->getRepository("ErsBase\\Entity\\ProductVariantValue")->findOneBy(array('id' => $id)); $form = new Form\ProductVariantValue(); $form->bind($value); $form->get('submit')->setAttribute('value', 'Edit'); $request = $this->getRequest(); if ($request->isPost()) { #$form->setInputFilter($value->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $em->persist($form->getData()); $em->flush(); if (!$forrest->exists('product-variant-value')) { $forrest->set('product-variant-value', 'product'); } $breadcrumb = $forrest->get('product-variant-value'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } } return new ViewModel(array('id' => $id, 'breadcrumb' => $forrest->get('product-variant-value'), 'form' => $form)); }
public function deleteAction() { $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('tax')) { $forrest->set('tax', 'admin/tax'); } $breadcrumb = $forrest->get('tax'); $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost('del', 'No'); if ($del == 'Yes') { $id = (int) $request->getPost('id'); $tax = $em->getRepository("ErsBase\\Entity\\Tax")->findOneBy(array('id' => $id)); $em->remove($tax); $em->flush(); } return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } return new ViewModel(array('id' => $id, 'tax' => $tax = $em->getRepository("ErsBase\\Entity\\Tax")->findOneBy(array('id' => $id)), 'breadcrumb' => $breadcrumb)); }
public function termsAction() { $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('terms')) { $forrest->set('terms', 'home'); } return new ViewModel(array('breadcrumb' => $forrest->get('terms'))); }
public function configAction() { $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $breadcrumbService = new Service\BreadcrumbService(); $breadcrumbService->set('tax', 'admin/overview/config'); $breadcrumbService->set('deadline', 'admin/overview/config'); $breadcrumbService->set('agegroup', 'admin/overview/config'); $breadcrumbService->set('payment-type', 'admin/overview/config'); $breadcrumbService->set('counter', 'admin/overview/config'); $breadcrumbService->set('status', 'admin/overview/config'); $breadcrumbService->set('product', 'admin/overview/config'); return new ViewModel(array('taxes' => $em->getRepository("ErsBase\\Entity\\Tax")->findAll(), 'deadlines' => $em->getRepository("ErsBase\\Entity\\Deadline")->findAll(), 'agegroups' => $em->getRepository("ErsBase\\Entity\\Agegroup")->findAll(), 'paymenttypes' => $em->getRepository("ErsBase\\Entity\\PaymentType")->findAll(), 'counters' => $em->getRepository("ErsBase\\Entity\\Counter")->findAll(), 'statuses' => $em->getRepository("ErsBase\\Entity\\Status")->findAll(), 'products' => $em->getRepository("ErsBase\\Entity\\Product")->findAll())); }
public function enterAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/refund', array()); } $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $order = $em->getRepository("ErsBase\\Entity\\Order")->findOneBy(array('id' => $id)); #$form = $this->getServiceLocator()->get('Admin\Form\Product'); $form = new Form\EnterRefund(); #$form->bind($order); $form->get('id')->setValue($order->getId()); $form->get('submit')->setAttribute('value', 'Enter'); $request = $this->getRequest(); if ($request->isPost()) { #$form->setInputFilter($product->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $data = $form->getData(); $order = $em->getRepository("ErsBase\\Entity\\Order")->findOneBy(array('id' => $data['id'])); $order->setRefundSum($order->getRefundSum() + $data['amount']); $em->persist($order); if ($order->getRefundSum() == $order->getPrice('refund')) { foreach ($order->getItemsByStatus('refund') as $item) { $item->setStatus('cancelled'); $em->persist($item); } } $em->flush(); $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('refund')) { $forrest->set('refund', 'admin/refund'); } $breadcrumb = $forrest->get('refund'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } } return new ViewModel(array('id' => $id, 'form' => $form, 'order' => $order)); }
public function viewAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/product', array('action' => 'add')); } $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $product = $em->getRepository("ErsBase\\Entity\\Product")->findOneBy(array('id' => $id)); $forrest = new Service\BreadcrumbService(); $forrest->set('product', 'admin/product', array('action' => 'view', 'id' => $id)); $forrest->set('product-package', 'admin/product', array('action' => 'view', 'id' => $id)); $forrest->set('product-price', 'admin/product', array('action' => 'view', 'id' => $id)); $forrest->set('product-variant', 'admin/product', array('action' => 'view', 'id' => $id)); $forrest->set('product-variant-value', 'admin/product', array('action' => 'view', 'id' => $id)); $deadlines = $em->getRepository("ErsBase\\Entity\\Deadline")->findBy(array('price_change' => '1'), array('deadline' => 'ASC')); $agegroups = $em->getRepository("ErsBase\\Entity\\Agegroup")->findBy(array('price_change' => '1'), array('agegroup' => 'ASC')); return new ViewModel(array('product' => $product, 'agegroups' => $agegroups, 'deadlines' => $deadlines)); }
public function changeAction() { $email = $this->zfcUserAuthentication()->getIdentity()->getEmail(); $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $participant = $em->getRepository("ErsBase\\Entity\\User")->findOneBy(array('email' => $email)); #$form = new Form\Participant(); $form = $this->getServiceLocator()->get('PreReg\\Form\\Participant'); $request = $this->getRequest(); $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('profile')) { $forrest->set('profile', 'profile'); } $form->get('Country_id')->setValueOptions($this->getCountryOptions()); $form->bind($participant); if ($request->isPost()) { #$inputFilter = new InputFilter\Participant(); #$form->setInputFilter($inputFilter->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $participant = $form->getData(); if ($participant->getCountryId() == 0) { $participant->setCountryId(null); $participant->setCountry(null); } $em->persist($participant); $em->flush(); $breadcrumb = $forrest->get('profile'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } else { $logger = $this->getServiceLocator()->get('Logger'); $logger->warn($form->getMessages()); } } $breadcrumb = $forrest->get('profile'); return new ViewModel(array('form' => $form, 'breadcrumb' => $breadcrumb)); }
public function unpaidAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/order', array()); } $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $order = $em->getRepository("ErsBase\\Entity\\Order")->findOneBy(array('id' => $id)); $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('order')) { $forrest->set('order', 'admin/order'); } $request = $this->getRequest(); if ($request->isPost()) { $ret = $request->getPost('del', 'No'); if ($ret == 'Yes') { $id = (int) $request->getPost('id'); $order = $em->getRepository("ErsBase\\Entity\\Order")->findOneBy(array('id' => $id)); $order->setPaymentStatus('unpaid'); $em->persist($order); foreach ($order->getItems() as $item) { $item->setStatus('ordered'); $em->persist($item); } $em->flush(); $breadcrumb = $forrest->get('order'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } } return new ViewModel(array('order' => $order, 'breadcrumb' => $forrest->get('order'))); }
public function deleteAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('participant'); } $breadcrumbService = new Service\BreadcrumbService(); if (!$breadcrumbService->exists('participant')) { $breadcrumbService->set('participant', 'participant'); } $breadcrumb = $breadcrumbService->get('participant'); $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); /*$participant = $em->getRepository('ErsBase\Entity\User') ->findOneBy(array('id' => $id));*/ $orderService = $this->getServiceLocator()->get('ErsBase\\Service\\OrderService'); $order = $orderService->getOrder(); $participant = $order->getParticipantById($id); $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost('del', 'No'); if ($del == 'Yes') { $id = (int) $request->getPost('id'); $participant = $order->getParticipantById($id); if (!$participant) { throw new \Exception('Unable to find participant with id: ' . $id); } $package = $order->getPackageByParticipantId($id); if (!$package) { throw new \Exception('Unable to find package for participant id: ' . $id); } $em->remove($package); $em->flush(); if (!$participant->getActive()) { foreach ($participant->getPackages() as $oldPackage) { $em->remove($oldPackage); } $em->remove($participant); $em->flush(); } } return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } $package = $order->getPackageByParticipantId($id); return new ViewModel(array('id' => $id, 'participant' => $participant, 'package' => $package, 'breadcrumb' => $breadcrumb)); }
public function acceptParticipantChangeAction() { $logger = $this->getServiceLocator()->get('Logger'); $user_id = (int) $this->params()->fromQuery('user_id', 0); $item_id = (int) $this->params()->fromQuery('item_id', 0); $form = new Form\AcceptParticipantChangeItem(); $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $request = $this->getRequest(); if ($request->isPost()) { $inputFilter = $this->getServiceLocator()->get('Admin\\InputFilter\\AcceptParticipantChangeItem'); #$form->setInputFilter($inputFilter->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $data = $form->getData(); $user = $em->getRepository("ErsBase\\Entity\\User")->findOneBy(array('id' => $data['user_id'])); $item = $em->getRepository("ErsBase\\Entity\\Item")->findOneBy(array('id' => $data['item_id'])); $log = new Entity\Log(); $log->setUser($this->zfcUserAuthentication()->getIdentity()); $log->setData('changed participant for item ' . $item->getCode()->getValue() . ': ' . $data['comment']); $em->persist($log); #$em->flush(); $package = $item->getPackage(); # initialize new package $newPackage = new Entity\Package(); $code = new Entity\Code(); $code->genCode(); $codecheck = 1; while ($codecheck != null) { $code->genCode(); $codecheck = $em->getRepository("ErsBase\\Entity\\Code")->findOneBy(array('value' => $code->getValue())); } $newPackage->setCode($code); # set order for package $newPackage->setOrder($package->getOrder()); $cloneService = $this->getServiceLocator()->get('ErsBase\\Service\\CloneService'); $cloneService->setTransfer(true); $newItem = $cloneService->cloneItem($item); #$newItem = clone $item; $newPackage->addItem($newItem); $item->setStatus('transferred'); #$item->setTransferredItem($newItem); $code = new Entity\Code(); $code->genCode(); $codecheck = 1; while ($codecheck != null) { $code->genCode(); $codecheck = $em->getRepository("ErsBase\\Entity\\Code")->findOneBy(array('value' => $code->getValue())); } $newItem->setCode($code); $em->persist($item); $em->persist($newItem); #$newPackage->setTransferredPackage($package); $newPackage->setParticipant($user); $em->persist($newPackage); #$em->persist($package); $em->flush(); $order = $package->getOrder(); return $this->redirect()->toRoute('admin/order', array('action' => 'detail', 'id' => $order->getId())); } else { $logger->warn($form->getMessages()); } } $user = null; if ($user_id != 0) { $user = $em->getRepository("ErsBase\\Entity\\User")->findOneBy(array('id' => $user_id)); } $item = null; if ($item_id != 0) { $item = $em->getRepository("ErsBase\\Entity\\Item")->findOneBy(array('id' => $item_id)); } $form->get('item_id')->setValue($item->getId()); $form->get('user_id')->setValue($user->getId()); $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('item')) { $forrest->set('item', 'admin/order', array('action' => 'search')); } return new ViewModel(array('form' => $form, 'user' => $user, 'item' => $item, 'breadcrumb' => $forrest->get('package'))); }
public function resetAction() { $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('cart')) { $forrest->set('cart', 'order'); } $breadcrumb = $forrest->get('cart'); $emptycart = false; $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost('del', 'No'); if ($del == 'Yes') { $cartContainer = new Container('cart'); $cartContainer->init = 0; $emptycart = true; } } return new ViewModel(array('breadcrumb' => $breadcrumb, 'emptycart' => $emptycart)); }
public function enableAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/matching', array('action' => 'disabled')); } $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $statement = $em->getRepository("ErsBase\\Entity\\BankStatement")->findOneBy(array('id' => $id)); $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('matching')) { $forrest->set('matching', 'admin/matching', array('action' => 'disabled')); } $request = $this->getRequest(); if ($request->isPost()) { $ret = $request->getPost('del', 'No'); if ($ret == 'Yes') { $id = (int) $request->getPost('id'); $statement = $em->getRepository("ErsBase\\Entity\\BankStatement")->findOneBy(array('id' => $id)); $statement->setStatus('new'); $em->persist($statement); $em->flush(); $breadcrumb = $forrest->get('matching'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } } return new ViewModel(array('statement' => $statement, 'breadcrumb' => $forrest->get('matching'))); }
public function deleteAction() { # maybe we do not need to delete a participant here, because the # participants user object is only held in the session and will be # deleted after session is not valid anymore. $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('participant'); } $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('participant')) { $forrest->set('participant', 'participant'); } $breadcrumb = $forrest->get('participant'); $cartContainer = new Container('cart'); $participant = $cartContainer->order->getParticipantBySessionId($id); $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost('del', 'No'); if ($del == 'Yes') { $id = (int) $request->getPost('id'); $cartContainer->order->removeParticipantBySessionId($id); } return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } $package = $cartContainer->order->getPackageByParticipantSessionId($id); return new ViewModel(array('id' => $id, 'participant' => $participant, 'package' => $package, 'breadcrumb' => $breadcrumb)); }
public function checkoutAction() { $container = new Container('initialized'); if (!is_array($container->checkout)) { $container->checkout = array(); } $container->checkout['/order/checkout'] = 1; $cartContainer = new Container('cart'); $orderContainer = new Container('order'); $orderService = $this->getServiceLocator()->get('ErsBase\\Service\\OrderService'); $order = $orderService->getOrder(); #$this->checkItemPrices(); $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $paymenttype = $em->getRepository("ErsBase\\Entity\\PaymentType")->findOneBy(array('id' => $order->getPaymentTypeId())); $order->setPaymentType($paymenttype); if (isset($orderContainer->order_id)) { $order = $em->getRepository("ErsBase\\Entity\\Order")->findOneBy(array('id' => $orderContainer->order_id)); if ($order) { return $this->redirect()->toRoute('order', array('action' => 'view', 'hashkey' => $order->getHashkey())); } } $form = new Form\Checkout(); $request = $this->getRequest(); if ($request->isPost()) { $inputFilter = new InputFilter\Checkout(); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($request->getPost()); foreach ($order->getPackages() as $package) { if (count($package->getItems()) <= 0) { $order->removePackage($package); $em->remove($package); continue; } $participant = $package->getParticipant(); if ($participant->getFirstname() == '' || $participant->getSurname() == '') { $participant = $buyer; } $user = null; if ($participant->getEmail() == '') { $participant->setEmail(null); } else { $user = $em->getRepository("ErsBase\\Entity\\User")->findOneBy(array('email' => $participant->getEmail())); } $role = $em->getRepository("ErsBase\\Entity\\Role")->findOneBy(array('roleId' => 'participant')); if ($user instanceof Entity\User) { $package->setParticipant($user); if (!$user->hasRole($role)) { $user->addRole($role); $em->persist($user); } #$package->setParticipantId($user->getId()); } else { $em->persist($participant); $package->setParticipant($participant); #$package->setParticipantId($participant->getId()); } $country = $em->getRepository("ErsBase\\Entity\\Country")->findOneBy(array('id' => $participant->getCountryId())); if (!$country) { $participant->setCountry(null); } else { $participant->setCountry($country); } } $status = $em->getRepository('ErsBase\\Entity\\Status')->findOneBy(array('value' => 'ordered')); $order->setStatus($status); $em->persist($order); # add log entry $log = new Entity\Log(); $log->setOrder($order); $log->setUser($order->getBuyer()); $log->setData($order->getCode()->getValue() . ' ordered'); $em->persist($log); $em->flush(); $orderContainer->order_id = $order->getId(); $cartContainer->init = 0; $emailService = $this->getServiceLocator()->get('ErsBase\\Service\\EmailService'); $emailService->sendConfirmationEmail($order->getId()); $forrest = new Service\BreadcrumbService(); $forrest->remove('terms'); switch (strtolower($order->getPaymentType()->getType())) { case 'banktransfer': return $this->redirect()->toRoute('payment', array('action' => 'banktransfer', 'hashkey' => $order->getHashkey())); case 'cheque': return $this->redirect()->toRoute('payment', array('action' => 'cheque', 'hashkey' => $order->getHashkey())); case 'creditcard': return $this->redirect()->toRoute('payment', array('action' => 'creditcard', 'hashkey' => $order->getHashkey())); case 'paypal': return $this->redirect()->toRoute('payment', array('action' => 'paypal', 'hashkey' => $order->getHashkey())); break; default: } } $forrest = new Service\BreadcrumbService(); $forrest->set('terms', 'order', array('action' => 'checkout')); /* * Check the buyers email, if it's not valid, delete buyer */ $email_validator = new Validator\EmailAddress(); $buyer = $order->getBuyer(); if ($buyer) { $email = $order->getBuyer()->getEmail(); if (!$email_validator->isValid($email)) { $order->setBuyer(); } } return new ViewModel(array('form' => $form, 'order' => $order)); }
public function addAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/product'); } $forrest = new Service\BreadcrumbService(); $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $productprice = new Entity\ProductPrice(); $productprice->setProductId($id); $form = new Form\ProductPrice(); $form->bind($productprice); $form->get('Deadline_id')->setValueOptions($this->getDeadlineOptions()); $form->get('Agegroup_id')->setValueOptions($this->getAgegroupOptions()); $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($request->isPost()) { $productprice = new Entity\ProductPrice(); #$form->setInputFilter($productprice->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $productprice = $form->getData(); if ($productprice->getDeadlineId() == 0) { $productprice->setDeadline(null); } else { $deadline = $em->getRepository("ErsBase\\Entity\\Deadline")->findOneBy(array('id' => $productprice->getDeadlineId())); $productprice->setDeadline($deadline); } if ($productprice->getAgegroupId() == 0) { $productprice->setAgegroup(null); } else { $agegroup = $em->getRepository("ErsBase\\Entity\\Agegroup")->findOneBy(array('id' => $productprice->getAgegroupId())); $productprice->setAgegroup($agegroup); } $product = $em->getRepository("ErsBase\\Entity\\Product")->findOneBy(array('id' => $productprice->getProductId())); $productprice->setProduct($product); $em->persist($productprice); $em->flush(); if (!$forrest->exists('product-price')) { $forrest->set('product-price', 'product'); } $breadcrumb = $forrest->get('product-price'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } else { $logger = $this->getServiceLocator()->get('Logger'); $logger->warn($form->getMessages()); } } $product = $em->getRepository("ErsBase\\Entity\\Product")->findOneBy(array('id' => $id)); if (!$forrest->exists('product-price')) { $forrest->set('product-price', 'admin/product'); } return new ViewModel(array('product' => $product, 'form' => $form, 'breadcrumb' => $forrest->get('product-price'))); }
public function deleteAction() { $forrest = new Service\BreadcrumbService(); if (!$forrest->exists('product')) { $forrest->set('product', 'order'); } $product_id = (int) $this->params()->fromRoute('product_id', 0); $item_id = (int) $this->params()->fromRoute('item_id', 0); if (!is_numeric($product_id) || !is_numeric($item_id)) { $breadcrumb = $forrest->get('product'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } $orderService = $this->getServiceLocator()->get('ErsBase\\Service\\OrderService'); $order = $orderService->getOrder(); $participant = $order->getParticipantByItemId($item_id); $item = $order->getItem($item_id); $product = $item->getProduct(); $request = $this->getRequest(); if ($request->isPost()) { $del = $request->getPost('del', 'No'); if ($del == 'Yes') { $item_id = (int) $request->getPost('item_id'); $orderService = $this->getServiceLocator()->get('ErsBase\\Service\\OrderService'); $orderService->removeItemById($item_id); #$order->removeItemById($item_id); } $breadcrumb = $forrest->get('product'); return $this->redirect()->toRoute($breadcrumb->route, $breadcrumb->params, $breadcrumb->options); } return new ViewModel(array('id' => $product_id, 'participant' => $participant, 'item' => $item, 'product' => $product, 'breadcrumb' => $forrest->get('product'))); }