/**
  * Delete a sale location entry
  *
  * @param \SalesLocations\Event\SalesLocationsDeleteEvent $event
  */
 public function delete(SalesLocationsDeleteEvent $event)
 {
     if (null !== ($saleLocation = SalesLocationsQuery::create()->findPk($event->getSaleLocationId()))) {
         $saleLocation->setDispatcher($event->getDispatcher())->delete();
         $event->setSaleLocation($saleLocation);
     }
 }
 public function parseResults(LoopResult $loopResult)
 {
     foreach ($loopResult->getResultDataCollection() as $location) {
         $loopResultRow = new LoopResultRow($location);
         $loopResultRow->set("ID", $location->getID())->set("COMPANY", $location->getCompany())->set("FIRSTNAME", $location->getFirstname())->set("LASTNAME", $location->getLastname())->set("LAT", $location->getLat())->set("LNG", $location->getLng())->set("ADRESSE1", $location->getAddress1())->set("ADRESSE2", $location->getAddress2())->set("ADRESSE3", $location->getAddress3())->set("ZIPCODE", $location->getZipcode())->set("CITY", $location->getCity())->set("COUNTRY", $location->getCountryId())->set("VISIBLE", $location->getVisible() ? "1" : "0");
         if ($this->getBackend_context() || $this->getWithPrevNextInfo()) {
             // Find previous and next sale location
             $previous = SalesLocationsQuery::create()->filterById($location->getId(), Criteria::LESS_THAN)->orderById(Criteria::DESC)->findOne();
             $next = SalesLocationsQuery::create()->filterById($location->getId(), Criteria::GREATER_THAN)->orderById(Criteria::ASC)->findOne();
             $loopResultRow->set("HAS_PREVIOUS", $previous != null ? 1 : 0)->set("HAS_NEXT", $next != null ? 1 : 0)->set("PREVIOUS", $previous != null ? $previous->getId() : -1)->set("NEXT", $next != null ? $next->getId() : -1);
         }
         $loopResult->addRow($loopResultRow);
     }
     return $loopResult;
 }
 /**
  * Performs an INSERT on the database, given a SalesLocations or Criteria object.
  *
  * @param  mixed               $criteria Criteria or SalesLocations 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(SalesLocationsTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from SalesLocations object
     }
     if ($criteria->containsKey(SalesLocationsTableMap::ID) && $criteria->keyContainsValue(SalesLocationsTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . SalesLocationsTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = SalesLocationsQuery::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;
 }
 protected function getExistingObject()
 {
     $saleslocations = SalesLocationsQuery::create()->findOneById($this->getRequest()->get('salelocation_id', 0));
     return $saleslocations;
 }
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param  ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see SalesLocations::setDeleted()
  * @see SalesLocations::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(SalesLocationsTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildSalesLocationsQuery::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;
     }
 }