/**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see AddressSocolissimo::setDeleted()
  * @see AddressSocolissimo::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(AddressSocolissimoTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildAddressSocolissimoQuery::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;
     }
 }
 protected function setExists($id)
 {
     $this->exists = AddressSocolissimoQuery::create()->findPK($id) !== null;
 }
 /**
  * Performs an INSERT on the database, given a AddressSocolissimo or Criteria object.
  *
  * @param mixed               $criteria Criteria or AddressSocolissimo 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(AddressSocolissimoTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from AddressSocolissimo object
     }
     // Set the correct dbName
     $query = AddressSocolissimoQuery::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;
 }
 public function isModuleSoColissimo(OrderEvent $event)
 {
     if ($this->check_module($event->getDeliveryModule())) {
         $request = $this->getRequest();
         $dom = $request->get('socolissimo-home');
         $rdv = $request->get('socolissimo-appointment');
         $pr_code = $request->get('socolissimo_code');
         $request->getSession()->set('SoColissimoDeliveryId', 0);
         $request->getSession()->set('SoColissimoDomicile', 0);
         $request->getSession()->set('SoColissimoRdv', 0);
         if ($dom) {
             $request->getSession()->set('SoColissimoDomicile', 1);
             $customer_name = AddressQuery::create()->findPk($event->getDeliveryAddress());
             $address = AddressSocolissimoQuery::create()->findPk($event->getDeliveryAddress());
             $request->getSession()->set('SoColissimoDeliveryId', $event->getDeliveryAddress());
             if ($address === null) {
                 $address = new AddressSocolissimo();
                 $address->setId($event->getDeliveryAddress());
             }
             // France Métropolitaine
             $address->setCode($pr_code)->setType("DOM")->setCompany($customer_name->getCompany())->setAddress1($customer_name->getAddress1())->setAddress2($customer_name->getAddress2())->setAddress3($customer_name->getAddress3())->setZipcode($customer_name->getZipcode())->setCity($customer_name->getCity())->setFirstname($customer_name->getFirstname())->setLastname($customer_name->getLastname())->setTitleId($customer_name->getTitleId())->setCountryId($customer_name->getCountryId())->setCellphone(null)->save();
         } elseif ($rdv) {
             $request->getSession()->set('SoColissimoRdv', 1);
             $customer_name = AddressQuery::create()->findPk($event->getDeliveryAddress());
             $address = AddressSocolissimoQuery::create()->findPk($event->getDeliveryAddress());
             $request->getSession()->set('SoColissimoDeliveryId', $event->getDeliveryAddress());
             if ($address === null) {
                 $address = new AddressSocolissimo();
                 $address->setId($event->getDeliveryAddress());
             }
             // France Métropolitaine
             $address->setCode($pr_code)->setType("RDV")->setCompany($customer_name->getCompany())->setAddress1($customer_name->getAddress1())->setAddress2($customer_name->getAddress2())->setAddress3($customer_name->getAddress3())->setZipcode($customer_name->getZipcode())->setCity($customer_name->getCity())->setFirstname($customer_name->getFirstname())->setLastname($customer_name->getLastname())->setTitleId($customer_name->getTitleId())->setCountryId($customer_name->getCountryId())->setCellphone($request->get('socolissimo-cellphone'))->save();
         } elseif (!empty($pr_code)) {
             $req = new FindById();
             $req->setId($pr_code)->setLangue("FR")->setDate(date("d/m/Y"))->setAccountNumber(ConfigQuery::read('socolissimo_login'))->setPassword(ConfigQuery::read('socolissimo_pwd'));
             $response = $req->exec();
             $customer_name = AddressQuery::create()->findPk($event->getDeliveryAddress());
             $address = AddressSocolissimoQuery::create()->findPk($event->getDeliveryAddress());
             $request->getSession()->set('SoColissimoDeliveryId', $event->getDeliveryAddress());
             if ($address === null) {
                 $address = new AddressSocolissimo();
                 $address->setId($event->getDeliveryAddress());
             }
             // France Métropolitaine
             $address->setCode($pr_code)->setType($response->typeDePoint)->setCompany($response->nom)->setAddress1($response->adresse1)->setAddress2($response->adresse2)->setAddress3($response->adresse3)->setZipcode($response->codePostal)->setCity($response->localite)->setFirstname($customer_name->getFirstname())->setLastname($customer_name->getLastname())->setTitleId($customer_name->getTitleId())->setCountryId($customer_name->getCountryId())->save();
         }
     }
 }