/**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aLeasingCalendar instanceof Persistent) {
             $this->aLeasingCalendar->clearAllReferences($deep);
         }
         if ($this->aLeasingUnit instanceof Persistent) {
             $this->aLeasingUnit->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aLeasingCalendar = null;
     $this->aLeasingUnit = null;
 }
예제 #2
0
 public function saveCalendarAction()
 {
     $request = $this->getRequest();
     $calendar = LeasingCalendarPeer::getCalendarByPostId($request->request->get('calendar_post_id'));
     $units = json_decode($request->request->get('units'));
     if (empty($calendar)) {
         $calendar = new LeasingCalendar();
     }
     $calendar->setName($request->request->get('name'));
     $calendar->setCalendarPostId($request->request->get('calendar_post_id'));
     $calendar->setAvailability($request->request->get('availability'));
     $calendar->setStartDate($request->request->get('start_date'));
     $calendar->setEndDate($request->request->get('end_date'));
     $calendar->save();
     $uc = LeasingUnitCalendarPeer::getUnitCalendarByCalendarId($calendar->getId());
     if (empty($uc)) {
         foreach ($units as $unit) {
             $u = LeasingUnitPeer::getUnitByPostId($unit);
             $uc = new LeasingUnitCalendar();
             $uc->setCalendarId($calendar->getId());
             $uc->setUnitId($u->getId());
             $uc->setStatus(C::ACTIVE);
             $uc->save();
         }
     } else {
         foreach ($uc as $u) {
             $u->setStatus(C::DELETE);
             $u->save();
         }
         foreach ($units as $unit) {
             $fl = 0;
             $lu = LeasingUnitPeer::getUnitByPostId($unit);
             foreach ($uc as $u) {
                 if ($u->getUnitId() == $lu->getId()) {
                     $fl = 1;
                     $u->setStatus(C::ACTIVE);
                     $u->save();
                 }
             }
             if ($fl == 0) {
                 $u = new LeasingUnitCalendar();
                 $u->setCalendarId($calendar->getId());
                 $u->setUnitId($u->getId());
                 $u->setStatus(C::ACTIVE);
                 $u->save();
             }
         }
     }
     return new RedirectResponse('http://leasing.dmcihomes.com.local/wp-admin/post.php');
 }
 /**
  * Exclude object from result
  *
  * @param   LeasingCalendar $leasingCalendar Object to remove from the list of results
  *
  * @return LeasingCalendarQuery The current query, for fluid interface
  */
 public function prune($leasingCalendar = null)
 {
     if ($leasingCalendar) {
         $this->addUsingAlias(LeasingCalendarPeer::ID, $leasingCalendar->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param LeasingCalendar $obj A LeasingCalendar object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         LeasingCalendarPeer::$instances[$key] = $obj;
     }
 }
 /**
  * Filter the query by a related LeasingCalendar object
  *
  * @param   LeasingCalendar|PropelObjectCollection $leasingCalendar The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 LeasingUnitCalendarQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByLeasingCalendar($leasingCalendar, $comparison = null)
 {
     if ($leasingCalendar instanceof LeasingCalendar) {
         return $this->addUsingAlias(LeasingUnitCalendarPeer::CALENDAR_ID, $leasingCalendar->getId(), $comparison);
     } elseif ($leasingCalendar instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(LeasingUnitCalendarPeer::CALENDAR_ID, $leasingCalendar->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByLeasingCalendar() only accepts arguments of type LeasingCalendar or PropelCollection');
     }
 }