/**
  * Selects a collection of LeasingUnitCalendar objects pre-filled with all related objects except LeasingCalendar.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of LeasingUnitCalendar objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptLeasingCalendar(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(LeasingUnitCalendarPeer::DATABASE_NAME);
     }
     LeasingUnitCalendarPeer::addSelectColumns($criteria);
     $startcol2 = LeasingUnitCalendarPeer::NUM_HYDRATE_COLUMNS;
     LeasingUnitPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + LeasingUnitPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(LeasingUnitCalendarPeer::UNIT_ID, LeasingUnitPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = LeasingUnitCalendarPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = LeasingUnitCalendarPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = LeasingUnitCalendarPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             LeasingUnitCalendarPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined LeasingUnit rows
         $key2 = LeasingUnitPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = LeasingUnitPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = LeasingUnitPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 LeasingUnitPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (LeasingUnitCalendar) to the collection in $obj2 (LeasingUnit)
             $obj2->addLeasingUnitCalendar($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Esempio 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');
 }
 public function saveAppointmentRequestAction()
 {
     $request = $this->getRequest();
     $postid = $request->request->get('unitid');
     $date = $request->request->get('date');
     $time = $request->request->get('time');
     $leasePeriod = $request->request->get('leasePeriod');
     $targetMoveIn = $request->request->get('targetMoveIn');
     $fname = $request->request->get('fname');
     $lname = $request->request->get('lname');
     $contact = $request->request->get('contact');
     $email = $request->request->get('email');
     $country = LeasingCountryPeer::getIdByCountryName($request->request->get('country'));
     $nationality = LeasingNationalityPeer::getIdByNationalityName($request->request->get('nationality'));
     $notes = $request->request->get('notes');
     $clientIp = $request->request->get('clientIp');
     $firstHeard = $request->request->get('firstHeard');
     //UNIT DETAILS
     $unit = LeasingUnitPeer::getUnitByPostId($postid);
     $lead = new LeasingAppointmentLeads();
     $lead->setFname($fname);
     $lead->setLname($lname);
     $lead->setEmail($email);
     $lead->setMobile($contact);
     $lead->setCountryId($country->getId());
     $lead->setNationalityId($nationality->getId());
     $lead->setClientIp($clientIp);
     $lead->save();
     $now = new \DateTime('now');
     $app = new LeasingAppointments();
     $app->setAppointmentLeadsId($lead->getId());
     $app->setUnitId($unit->getId());
     $app->setPreferredDate($date);
     $app->setPreferredTime($time);
     $app->setLeasePeriod($leasePeriod);
     $app->setTargetMoveIn($targetMoveIn);
     $app->setFirstHeard($firstHeard);
     $app->setNotes($notes);
     $app->setDateAdded($now->format(C::DATETIMEFORMAT));
     $app->setStatus(C::PENDING);
     $app->setPrevStatus(C::PENDING);
     $app->save();
     $tl1 = new LeasingTimelineActivity();
     $tl1->setLeadTypeId(C::APPOINTMENT);
     $tl1->setLeadId($lead->getId());
     $tl1->setUser('Lead');
     $tl1->setActivity('Requested Unit Viewing');
     $tl1->setTimestamp($now->format(C::DATETIMEFORMAT));
     $tl1->setStatus('Pending');
     $tl1->setStatusId(C::PENDING);
     $tl1->save();
     $this->get('session')->set('thank-you', 1);
     $client = new GlobeClient();
     $msg = "Thank you, " . $lead->getFname() . " " . $lead->getLname() . "! Your request to view " . $app->getLeasingUnit()->getName() . " is now being processed. We will update you ASAP once an agent is assigned to assist you. This msg is FREE.";
     $sms = $client->sms($this->globeShortCode);
     $response = $sms->sendMessage($lead->getMobile(), $msg, $this->appId, $this->appSecret);
     if ($response && !isset($response['error'])) {
         $badge = new LeasingLeadBadges();
         $badge->setBadgeId(11);
         $badge->setLeadTypeId(C::APPOINTMENT);
         $badge->setLeadId($lead->getId());
         $badge->setStatus(1);
         $badge->save();
         $tl2 = new LeasingTimelineActivity();
         $tl2->setLeadTypeId(C::APPOINTMENT);
         $tl2->setLeadId($lead->getId());
         $tl2->setUser('System');
         $tl2->setActivity('Verified mobile number');
         $tl2->setTimestamp($now->format(C::DATETIMEFORMAT));
         $tl2->setStatus('Mobile Verified');
         $tl2->setStatusId(C::MOBILE_VERIFIED);
         $tl2->save();
     }
     $ve = VerifyEmail::verifyThisEmail($lead->getEmail());
     if ($ve = 'valid') {
         $badge = new LeasingLeadBadges();
         $badge->setBadgeId(12);
         $badge->setLeadTypeId(C::PARKING);
         $badge->setLeadId($lead->getId());
         $badge->setStatus(1);
         $badge->save();
         $tl3 = new LeasingTimelineActivity();
         $tl3->setLeadTypeId(C::PARKING);
         $tl3->setLeadId($lead->getId());
         $tl3->setUser('System');
         $tl3->setActivity('Verified email address');
         $tl3->setTimestamp($now->format(C::DATETIMEFORMAT));
         $tl3->setStatus('Email Verified');
         $tl3->setStatusId(C::EMAIL_VERIFIED);
         $tl3->save();
     }
     echo 1;
     exit;
     return new Response();
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @return LeasingUnit[]
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(LeasingUnitPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(LeasingUnitPeer::DATABASE_NAME);
         $criteria->add(LeasingUnitPeer::ID, $pks, Criteria::IN);
         $objs = LeasingUnitPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 5
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's BasePeer::TYPE_PHPNAME
  *
  * @param array  $arr     An array to populate the object from.
  * @param string $keyType The type of keys the array uses.
  * @return void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = LeasingUnitPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setPostId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setSlug($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setContent($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setAvailability($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setPriceRange($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setStatus($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setUnitTypeId($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setLocationId($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setLeaseTypeId($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setProjectId($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setBrId($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setDressUpId($arr[$keys[13]]);
     }
 }
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 LeasingUnit A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `name`, `post_id`, `slug`, `content`, `availability`, `price_range`, `status`, `unit_type_id`, `location_id`, `lease_type_id`, `project_id`, `br_id`, `dress_up_id` FROM `unit` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new LeasingUnit();
         $obj->hydrate($row);
         LeasingUnitPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }