public function verifyDeliveryModeExist($value, ExecutionContextInterface $context)
 {
     $mode = SocolissimoDeliveryModeQuery::create()->findPk($value);
     if (null === $mode) {
         $context->addViolation(Translator::getInstance()->trans("This delivery mode doesn't exists."));
     }
 }
 public function buildModelCriteria()
 {
     $mode = $this->getId();
     $modes = SocolissimoDeliveryModeQuery::create();
     if (null !== $mode) {
         $modes->filterById($mode);
     }
     return $modes;
 }
 public function setFreeShippingFrom()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('SoColissimo'), AccessManager::UPDATE))) {
         return $response;
     }
     $data = $this->getRequest()->request;
     $deliveryMode = SocolissimoDeliveryModeQuery::create()->findOneById($data->get('delivery-mode'));
     $price = $data->get("price") === "" ? null : $data->get("price");
     if ($price < 0) {
         $price = null;
     }
     $deliveryMode->setFreeshippingFrom($price)->save();
     return $this->generateRedirectFromRoute("admin.module.configure", array(), array('current_tab' => 'prices_slices_tab_' . $data->get('delivery-mode'), 'module_code' => "SoColissimo", '_controller' => 'Thelia\\Controller\\Admin\\ModuleController::configureAction', 'price_error_id' => null, 'price_error' => null));
 }
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see SocolissimoDeliveryMode::setDeleted()
  * @see SocolissimoDeliveryMode::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(SocolissimoDeliveryModeTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildSocolissimoDeliveryModeQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * Get the associated ChildSocolissimoDeliveryMode object
  *
  * @param      ConnectionInterface $con Optional Connection object.
  * @return                 ChildSocolissimoDeliveryMode The associated ChildSocolissimoDeliveryMode object.
  * @throws PropelException
  */
 public function getSocolissimoDeliveryMode(ConnectionInterface $con = null)
 {
     if ($this->aSocolissimoDeliveryMode === null && $this->delivery_mode_id !== null) {
         $this->aSocolissimoDeliveryMode = ChildSocolissimoDeliveryModeQuery::create()->findPk($this->delivery_mode_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aSocolissimoDeliveryMode->addSocolissimoPrices($this);
            */
     }
     return $this->aSocolissimoDeliveryMode;
 }
 /**
  * Performs an INSERT on the database, given a SocolissimoDeliveryMode or Criteria object.
  *
  * @param mixed               $criteria Criteria or SocolissimoDeliveryMode object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(SocolissimoDeliveryModeTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from SocolissimoDeliveryMode object
     }
     if ($criteria->containsKey(SocolissimoDeliveryModeTableMap::ID) && $criteria->keyContainsValue(SocolissimoDeliveryModeTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . SocolissimoDeliveryModeTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = SocolissimoDeliveryModeQuery::create()->mergeWith($criteria);
     try {
         // use transaction because $criteria could contain info
         // for more than one table (I guess, conceivably)
         $con->beginTransaction();
         $pk = $query->doInsert($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     return $pk;
 }
Example #7
0
 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con);
     try {
         // Security to not erase user config on reactivation
         SocolissimoDeliveryModeQuery::create()->findOne();
     } catch (\Exception $e) {
         $database->insertSql(null, [__DIR__ . '/Config/thelia.sql', __DIR__ . '/Config/insert.sql']);
     }
     try {
         $deliveryModes = SocolissimoDeliveryModeQuery::create()->find();
         foreach ($deliveryModes as $deliveryMode) {
             self::importJsonPrice($deliveryMode, $con);
         }
     } catch (\Exception $e) {
         throw $e;
     }
     ConfigQuery::write('socolissimo_login', null, 1, 1);
     ConfigQuery::write('socolissimo_pwd', null, 1, 1);
     ConfigQuery::write('socolissimo_url_prod', "https://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS/2.0?wsdl", 1, 1);
     ConfigQuery::write('socolissimo_url_test', "https://pfi.telintrans.fr/pointretrait-ws-cxf/PointRetraitServiceWS/2.0?wsdl", 1, 1);
     ConfigQuery::write('socolissimo_test_mode', 1, 1, 1);
     /* insert the images from image folder if first module activation */
     $module = $this->getModuleModel();
     if (ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
         $this->deployImageFolder($module, sprintf('%s/images', __DIR__), $con);
     }
 }