/**
  * Declares an association between this object and a LeasingAppointmentLeads object.
  *
  * @param                  LeasingAppointmentLeads $v
  * @return LeasingAppointments The current object (for fluent API support)
  * @throws PropelException
  */
 public function setLeasingAppointmentLeads(LeasingAppointmentLeads $v = null)
 {
     if ($v === null) {
         $this->setAppointmentLeadsId(NULL);
     } else {
         $this->setAppointmentLeadsId($v->getId());
     }
     $this->aLeasingAppointmentLeads = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the LeasingAppointmentLeads object, it will not be re-added.
     if ($v !== null) {
         $v->addLeasingAppointments($this);
     }
     return $this;
 }
Ejemplo n.º 2
0
 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();
 }
 /**
  * Filter the query by a related LeasingAppointmentLeads object
  *
  * @param   LeasingAppointmentLeads|PropelObjectCollection $leasingAppointmentLeads The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 LeasingAppointmentsQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByLeasingAppointmentLeads($leasingAppointmentLeads, $comparison = null)
 {
     if ($leasingAppointmentLeads instanceof LeasingAppointmentLeads) {
         return $this->addUsingAlias(LeasingAppointmentsPeer::APPOINTMENT_LEADS_ID, $leasingAppointmentLeads->getId(), $comparison);
     } elseif ($leasingAppointmentLeads instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(LeasingAppointmentsPeer::APPOINTMENT_LEADS_ID, $leasingAppointmentLeads->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByLeasingAppointmentLeads() only accepts arguments of type LeasingAppointmentLeads or PropelCollection');
     }
 }
 /**
  * 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 LeasingAppointmentLeads $obj A LeasingAppointmentLeads 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
         LeasingAppointmentLeadsPeer::$instances[$key] = $obj;
     }
 }
 /**
  * Exclude object from result
  *
  * @param   LeasingAppointmentLeads $leasingAppointmentLeads Object to remove from the list of results
  *
  * @return LeasingAppointmentLeadsQuery The current query, for fluid interface
  */
 public function prune($leasingAppointmentLeads = null)
 {
     if ($leasingAppointmentLeads) {
         $this->addUsingAlias(LeasingAppointmentLeadsPeer::ID, $leasingAppointmentLeads->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }