/**
  * 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 LeasingUnitCalendar $obj A LeasingUnitCalendar 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
         LeasingUnitCalendarPeer::$instances[$key] = $obj;
     }
 }
Exemplo n.º 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');
 }
Exemplo n.º 3
0
 /**
  * @param	LeasingUnitCalendar $leasingUnitCalendar The leasingUnitCalendar object to add.
  */
 protected function doAddLeasingUnitCalendar($leasingUnitCalendar)
 {
     $this->collLeasingUnitCalendars[] = $leasingUnitCalendar;
     $leasingUnitCalendar->setLeasingUnit($this);
 }
 /**
  * Filter the query by a related LeasingUnitCalendar object
  *
  * @param   LeasingUnitCalendar|PropelObjectCollection $leasingUnitCalendar  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 LeasingCalendarQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByLeasingUnitCalendar($leasingUnitCalendar, $comparison = null)
 {
     if ($leasingUnitCalendar instanceof LeasingUnitCalendar) {
         return $this->addUsingAlias(LeasingCalendarPeer::ID, $leasingUnitCalendar->getCalendarId(), $comparison);
     } elseif ($leasingUnitCalendar instanceof PropelObjectCollection) {
         return $this->useLeasingUnitCalendarQuery()->filterByPrimaryKeys($leasingUnitCalendar->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByLeasingUnitCalendar() only accepts arguments of type LeasingUnitCalendar or PropelCollection');
     }
 }
 /**
  * Exclude object from result
  *
  * @param   LeasingUnitCalendar $leasingUnitCalendar Object to remove from the list of results
  *
  * @return LeasingUnitCalendarQuery The current query, for fluid interface
  */
 public function prune($leasingUnitCalendar = null)
 {
     if ($leasingUnitCalendar) {
         $this->addUsingAlias(LeasingUnitCalendarPeer::ID, $leasingUnitCalendar->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }