Esempio n. 1
0
 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')));
 }
Esempio n. 2
0
 /**
  * Add Participant (add new Package and set participant)
  * 
  * @param \Entity\User $participant
  * @return \Entity\Order
  */
 public function addParticipant(User $participant)
 {
     $package = new Package();
     $sessionId = $this->getSessionId('package');
     $participant->setSessionId($sessionId);
     $package->setParticipant($participant);
     $package->setSessionId($sessionId);
     $this->packages[] = $package;
     return $this;
 }
Esempio n. 3
0
 /**
  * set Package
  * even if a participant can have multiple packages this service will only 
  * process one of them. So for multiple packages the participant will get 
  * multiple e-Tickets.
  * 
  * @param \ErsBase\Entity\Package $package
  */
 public function setPackage(Entity\Package $package)
 {
     $this->_package = $package;
     $this->setParticipant($package->getParticipant());
     foreach ($package->getItems() as $item) {
         if ($item->getProduct()->getPersonalized()) {
             $this->addPersonalItem($item);
         } else {
             $this->addItem($item);
         }
     }
 }
Esempio n. 4
0
 /**
  * Add Participant (add new Package and set participant)
  * 
  * @param \Entity\User $participant
  * @return \Entity\Order
  */
 public function addParticipant(Entity\User $participant)
 {
     $package = new Entity\Package();
     $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $status = $em->getRepository('ErsBase\\Entity\\Status')->findOneBy(array('value' => 'order pending'));
     if (!$status) {
         throw new \Exception('Please setup status "order pending"');
     }
     $package->setStatus($status);
     $status->addPackage($package);
     $package->setParticipant($participant);
     $this->getOrder()->addPackage($package);
     $package->setOrder($this->getOrder());
     return $this->getOrder();
 }
Esempio n. 5
0
 /**
  * Set Package entity (one to one).
  *
  * @param \Entity\Package $package
  * @return \Entity\Code
  */
 public function setPackage(Package $package = null)
 {
     $package->setCode($this);
     $this->package = $package;
     return $this;
 }
Esempio n. 6
0
 public function transferPackage(Entity\Package $package)
 {
     $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $newPackage = clone $package;
     $newPackage->setOrder($package->getOrder());
     foreach ($package->getItems() as $item) {
         if ($item->hasParentItems()) {
             continue;
         }
         $newItem = clone $item;
         $item->setTransferredItem($newItem);
         $item->setStatus('transferred');
         $item->setPackage($package);
         $em->persist($item);
         $newPackage->addItem($newItem);
         $newItem->setPackage($newPackage);
         $em->persist($newItem);
     }
     $package->setTransferredPackage($newPackage);
     $em->persist($package);
     return $newPackage;
 }