Ejemplo n.º 1
0
 /**
  *
  * in this function you add all the fields you need for your Form.
  * Form this you have to call add method on $this->formBuilder attribute :
  *
  * $this->formBuilder->add("name", "text")
  *   ->add("email", "email", array(
  *           "attr" => array(
  *               "class" => "field"
  *           ),
  *           "label" => "email",
  *           "constraints" => array(
  *               new \Symfony\Component\Validator\Constraints\NotBlank()
  *           )
  *       )
  *   )
  *   ->add('age', 'integer');
  *
  * @return null
  */
 protected function buildForm()
 {
     $status = OrderStatusQuery::create()->filterByCode(array(OrderStatus::CODE_PAID, OrderStatus::CODE_PROCESSING, OrderStatus::CODE_SENT), Criteria::IN)->find()->toArray("code");
     $query = OrderQuery::create()->filterByDeliveryModuleId(SoColissimo::getModCode())->filterByStatusId(array($status['paid']['Id'], $status['processing']['Id']), Criteria::IN)->find();
     $this->formBuilder->add('new_status_id', 'choice', array('label' => Translator::getInstance()->trans('server'), 'choices' => array("nochange" => Translator::getInstance()->trans("Do not change"), "processing" => Translator::getInstance()->trans("Set orders status as processing"), "sent" => Translator::getInstance()->trans("Set orders status as sent")), 'required' => 'true', 'expanded' => true, 'multiple' => false, 'data' => 'nochange'));
     /** @var \Thelia\Model\Order $order */
     foreach ($query as $order) {
         $this->formBuilder->add("order_" . $order->getId(), "checkbox", array('label' => $order->getRef(), 'label_attr' => array('for' => 'export_' . $order->getId())));
     }
 }
Ejemplo n.º 2
0
 public function delete(ModuleDeleteEvent $event)
 {
     $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
     $con->beginTransaction();
     if (null !== ($module = ModuleQuery::create()->findPk($event->getModuleId(), $con))) {
         try {
             if (null === $module->getFullNamespace()) {
                 throw new \LogicException(Translator::getInstance()->trans('Cannot instantiate module "%name%": the namespace is null. Maybe the model is not loaded ?', ['%name%' => $module->getCode()]));
             }
             // If the module is referenced by an order, display a meaningful error
             // instead of 'delete cannot delete' caused by a constraint violation.
             // FIXME: we hav to find a way to delete modules used by order.
             if (OrderQuery::create()->filterByDeliveryModuleId($module->getId())->count() > 0 || OrderQuery::create()->filterByPaymentModuleId($module->getId())->count() > 0) {
                 throw new \LogicException(Translator::getInstance()->trans('The module "%name%" is currently in use by at least one order, and can\'t be deleted.', ['%name%' => $module->getCode()]));
             }
             try {
                 // First, try to create an instance
                 $instance = $module->createInstance();
                 // Then, if module is activated, check if we can deactivate it
                 if ($module->getActivate()) {
                     // check for modules that depend of this one
                     $this->checkDeactivation($module);
                 }
                 $instance->setContainer($this->container);
                 $path = $module->getAbsoluteBaseDir();
                 $instance->destroy($con, $event->getDeleteData());
                 $fs = new Filesystem();
                 $fs->remove($path);
             } catch (\ReflectionException $ex) {
                 // Happens probably because the module directory has been deleted.
                 // Log a warning, and delete the database entry.
                 Tlog::getInstance()->addWarning(Translator::getInstance()->trans('Failed to create instance of module "%name%" when trying to delete module. Module directory has probably been deleted', ['%name%' => $module->getCode()]));
             } catch (FileNotFoundException $fnfe) {
                 // The module directory has been deleted.
                 // Log a warning, and delete the database entry.
                 Tlog::getInstance()->addWarning(Translator::getInstance()->trans('Module "%name%" directory was not found', ['%name%' => $module->getCode()]));
             }
             $module->delete($con);
             $con->commit();
             $event->setModule($module);
             $this->cacheClear($event->getDispatcher());
         } catch (\Exception $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * this method returns a Propel ModelCriteria
  *
  * @return \Propel\Runtime\ActiveQuery\ModelCriteria
  */
 public function buildModelCriteria()
 {
     $order = OrderQuery::create()->findPk($this->getOrderId());
     $search = TransferPaymentConfigQuery::create();
     if ($order === null || $order->getPaymentModuleId() !== TransferPayment::getModCode()) {
         $search->filterByName("");
     }
     $search->orderBy('placement');
     return $search;
 }
Ejemplo n.º 4
0
 public function checkorder($order_id, &$token)
 {
     $token = $this->getRequest()->getSession()->get('Paypal.token');
     if ($token !== $this->getRequest()->get('token')) {
         throw new \Exception("The token is not valid.");
     }
     $customer_id = $this->getRequest()->getSession()->getCustomerUser()->getId();
     $order = OrderQuery::create()->filterByCustomerId($customer_id)->findPk($order_id);
     if ($order === null) {
         throw new \Exception("The order id is not valid. This order doesn't exists or doesn't belong to you.");
     }
     return $order;
 }