コード例 #1
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Agent has previously
  * been saved, it will retrieve related Profiles from storage.
  * If this Agent is new, it will return
  * an empty collection or the current collection, the criteria
  * is ignored on a new object.
  *
  * @param      Connection $con
  * @param      Criteria $criteria
  * @throws     PropelException
  */
 public function getProfiles($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseProfilePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collProfiles === null) {
         if ($this->isNew()) {
             $this->collProfiles = array();
         } else {
             $criteria->add(ProfilePeer::AGENT_ID, $this->getId());
             ProfilePeer::addSelectColumns($criteria);
             $this->collProfiles = ProfilePeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(ProfilePeer::AGENT_ID, $this->getId());
             ProfilePeer::addSelectColumns($criteria);
             if (!isset($this->lastProfileCriteria) || !$this->lastProfileCriteria->equals($criteria)) {
                 $this->collProfiles = ProfilePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastProfileCriteria = $criteria;
     return $this->collProfiles;
 }
コード例 #2
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ProfilePeer::ID, $pks, Criteria::IN);
         $objs = ProfilePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #3
0
 public function executeValidateFnm($request)
 {
     //      $is_branch_owner = $this->$sf_is_branch_owner;
     $is_branch_owner = $this->sf_is_branch_owner;
     $render_text = array("message" => "");
     $user_id = $this->sf_user_id;
     $branch_id = $branch_ids = null;
     $fname = $request->getParameter('profile_fname', null);
     $lname = $request->getParameter('profile_lname', null);
     $email = $request->getParameter('profile_email', null);
     $phone = $request->getParameter('profile_phone', null);
     $mobile = $request->getParameter('profile_mobile', null);
     $id = $request->getParameter('id');
     $phone = preg_replace('/\\D/', '', $phone);
     $mobile = preg_replace('/\\D/', '', $mobile);
     $branch_id = $request->getParameter('branch_id');
     $branch_ids = $this->sf_owner_branch_ids;
     //    var_dump($branch_id);exit;
     if (!$branch_id && !$is_branch_owner || count($branch_ids) == 1) {
         $branch_id = $this->getUser()->getUserBranch()->getId();
     }
     $c = new Criteria();
     $c->addJoin(ProfilePeer::USER_ID, sfGuardUserPeer::ID);
     $c->addJoin(sfGuardUserPeer::ID, sfGuardUserGroupPeer::USER_ID);
     $c->addJoin(sfGuardGroupPeer::ID, sfGuardUserGroupPeer::GROUP_ID);
     $c->addJoin(sfGuardUserPeer::ID, BranchUsersPeer::USER_ID);
     $c->add(sfGuardGroupPeer::NAME, 'client');
     if ($id) {
         $c->add(ProfilePeer::ID, $id, Criteria::NOT_EQUAL);
     }
     $c->add(BranchUsersPeer::BRANCH_ID, $branch_id);
     $alert_msg = sfConfig::get('mod_client_messages_alert_msg');
     if ($fname) {
         $c->add(ProfilePeer::FNAME, trim($fname));
         $exists = ProfilePeer::doSelect($c);
         $fname_links = ' or to view the client, select';
         foreach ($exists as $fname_exist) {
             //          $names = $fname_exist->getFname().' '.$fname_exist->getLname();
             //          echo link_to($names, 'client/show?id='.$fname_exist->getId(), array());
             $fname_links .= ' <a href="show/id/' . $fname_exist->getId() . '"><strong> ' . $fname_exist->getFname() . ' ' . $fname_exist->getLname() . ' </strong></a>';
         }
         if ($exists) {
             $render_text['message'] = '<strong>' . $fname . '</strong> ' . $alert_msg . ' ' . $fname_links;
         }
     }
     if ($lname) {
         $c->add(ProfilePeer::LNAME, trim($lname));
         $exists = ProfilePeer::doSelect($c);
         $lname_links = ' or to view the client, select';
         foreach ($exists as $lname_exist) {
             $lname_links .= ' <a href="show/id/' . $lname_exist->getId() . '"><strong> ' . $lname_exist->getFname() . ' ' . $lname_exist->getLname() . ' </strong></a>';
         }
         if ($exists) {
             $render_text['message'] = '<strong>' . $lname . '</strong> ' . $alert_msg . ' ' . $lname_links;
         }
     }
     if ($email) {
         $c->add(ProfilePeer::EMAIL, trim($email));
         $exists = ProfilePeer::doSelect($c);
         $email_links = ' or to view the client, select';
         foreach ($exists as $email_exist) {
             $email_links .= ' <a href="show/id/' . $email_exist->getId() . '"><strong> ' . $email_exist->getFname() . ' ' . $email_exist->getLname() . ' </strong></a>';
         }
         if ($exists) {
             $render_text['message'] = '<strong>' . $email . '</strong> ' . $alert_msg . ' ' . $email_links;
         }
     }
     if ($phone) {
         $exists = ProfilePeer::doSelect($c);
         $phone_existing = false;
         $phone_links = ' or to view the client, select';
         foreach ($exists as $phone_exist) {
             $all_phone = preg_replace('/\\D/', '', $phone_exist->getPhone());
             if (strpos($all_phone, $phone) !== false) {
                 $phone_existing = true;
                 $phone_links .= ' <a href="show/id/' . $phone_exist->getId() . '"><strong> ' . $phone_exist->getFname() . ' ' . $phone_exist->getLname() . ' - (' . $phone_exist->getPhone() . ') </strong></a>';
             }
         }
         if ($phone_existing) {
             $render_text['message'] = '<strong>' . $phone . '</strong> ' . $alert_msg . ' ' . $phone_links;
         }
     }
     if ($mobile) {
         $mobile_exists = ProfilePeer::doSelect($c);
         $mobile_existing = false;
         $mobile_links = ' or to view the client, select';
         foreach ($mobile_exists as $mobile_exist) {
             $all_mobile = preg_replace('/\\D/', '', $mobile_exist->getMobile());
             if (strpos($all_mobile, $mobile) !== false) {
                 $mobile_existing = true;
                 $mobile_links .= ' <a href="show/id/' . $mobile_exist->getId() . '"><strong> ' . $mobile_exist->getFname() . ' ' . $mobile_exist->getLname() . ' - (' . $mobile_exist->getMobile() . ') </strong></a>';
             }
         }
         if ($mobile_existing) {
             $render_text['message'] = '<strong>' . $mobile . '</strong> ' . $alert_msg . ' ' . $mobile_links;
         }
     }
     if ($request->isXmlHttpRequest()) {
         return $this->renderText(json_encode($render_text));
     }
     return sfView::NONE;
 }