Пример #1
0
 public function loadVolRecs()
 {
     //-----------------------------------------------------------------------
     //
     //-----------------------------------------------------------------------
     $this->volRecs = array();
     $clsPeople = new mpeople();
     if ($this->strOrderExtra . '' == '') {
         $this->strOrderExtra = ' ORDER BY pe_strLName, pe_strFName, pe_strMName, vol_lKeyID ';
     }
     $sqlStr = "SELECT\n            vol_lKeyID, vol_lPeopleID, vol_bInactive, vol_lRegFormID,\n            vol_Notes, vol_bRetired, vol_lOriginID, vol_lLastUpdateID,\n            UNIX_TIMESTAMP(vol_dteInactive) AS dteInactive,\n\n            vreg_strFormName, vreg_strURLHash,\n\n            pe_strLName, pe_strFName,\n            pe_strMName, pe_bRetired,\n            pe_strPreferredName, pe_strTitle,\n            pe_strAddr1, pe_strAddr2,\n            pe_strCity,  pe_strState,\n            pe_strZip,   pe_strCountry,\n            pe_strEmail, pe_strPhone, pe_strCell,\n            pe_lHouseholdID,\n\n            UNIX_TIMESTAMP(vol_dteOrigin)     AS dteOrigin,\n            UNIX_TIMESTAMP(vol_dteLastUpdate) AS dteLastUpdate,\n            uc.us_strFirstName AS strUCFName, uc.us_strLastName AS strUCLName,\n            ul.us_strFirstName AS strULFName, ul.us_strLastName AS strULLName\n\n         FROM volunteers\n            INNER JOIN people_names        ON vol_lPeopleID  = pe_lKeyID\n            INNER JOIN admin_users   AS uc ON uc.us_lKeyID   = vol_lOriginID\n            INNER JOIN admin_users   AS ul ON ul.us_lKeyID   = vol_lLastUpdateID\n            LEFT  JOIN vol_reg             ON vol_lRegFormID = vreg_lKeyID\n\n         WHERE\n            NOT vol_bRetired AND NOT pe_bRetired\n            {$this->strWhereExtra}\n         {$this->strOrderExtra}\n         {$this->sqlLimitExtra};";
     $query = $this->db->query($sqlStr);
     $this->lNumVolRecs = $numRows = $query->num_rows();
     if ($numRows == 0) {
         $this->volRecs[0] = new stdClass();
         $vRec =& $this->volRecs[0];
         $vRec->lKeyID = $vRec->lPeopleID = $vRec->lHouseholdID = $vRec->bInactive = $vRec->Notes = $vRec->bRetired = $vRec->dteInactive = $vRec->strLName = $vRec->strFName = $vRec->strMName = $vRec->strSafeNameFL = $vRec->bRetired = $vRec->strAddr1 = $vRec->strAddr2 = $vRec->strCity = $vRec->strState = $vRec->strZip = $vRec->strCountry = $vRec->strEmail = $vRec->strPhone = $vRec->strCell = $vRec->lOriginID = $vRec->lLastUpdateID = $vRec->dteOrigin = $vRec->dteLastUpdate = $vRec->strUCFName = $vRec->strUCLName = $vRec->strULFName = $vRec->strULLName = null;
     } else {
         $idx = 0;
         foreach ($query->result() as $row) {
             $this->volRecs[$idx] = new stdClass();
             $vRec =& $this->volRecs[$idx];
             $vRec->lKeyID = (int) $row->vol_lKeyID;
             $vRec->lPeopleID = (int) $row->vol_lPeopleID;
             $vRec->lHouseholdID = $lHID = (int) $row->pe_lHouseholdID;
             $vRec->strHouseholdName = $clsPeople->strHouseholdNameViaHID($lHID);
             $vRec->bInactive = $row->vol_bInactive;
             $vRec->Notes = $row->vol_Notes;
             $vRec->bRetired = $row->vol_bRetired;
             $vRec->dteInactive = $row->dteInactive;
             $vRec->strLName = $strLName = $row->pe_strLName;
             $vRec->strFName = $strFName = $row->pe_strFName;
             $vRec->strMName = $strMName = $row->pe_strMName;
             $vRec->strTitle = $strTitle = $row->pe_strTitle;
             $vRec->strPreferred = $strPreferred = $row->pe_strPreferredName;
             $vRec->lRegFormID = (int) $row->vol_lRegFormID;
             $vRec->strFormName = $row->vreg_strFormName;
             $vRec->strURLHash = $row->vreg_strURLHash;
             $vRec->strSafeName = $vRec->strSafeNameFL = htmlspecialchars(strBuildName(false, $strTitle, $strPreferred, $strFName, $strLName, $strMName));
             $vRec->strSafeNameLF = htmlspecialchars(strBuildName(true, $strTitle, $strPreferred, $strFName, $strLName, $strMName));
             $vRec->bRetired = $row->pe_bRetired;
             $vRec->strAddr1 = $row->pe_strAddr1;
             $vRec->strAddr2 = $row->pe_strAddr2;
             $vRec->strCity = $row->pe_strCity;
             $vRec->strState = $row->pe_strState;
             $vRec->strZip = $row->pe_strZip;
             $vRec->strCountry = $row->pe_strCountry;
             $vRec->strEmail = $strEmail = $row->pe_strEmail;
             $vRec->strEmailFormatted = strBuildEmailLink($strEmail, '', false, '');
             $vRec->strPhone = $row->pe_strPhone;
             $vRec->strCell = $row->pe_strCell;
             $vRec->strAddress = strBuildAddress($vRec->strAddr1, $vRec->strAddr2, $vRec->strCity, $vRec->strState, $vRec->strCountry, $vRec->strZip, true);
             $vRec->lOriginID = $row->vol_lOriginID;
             $vRec->lLastUpdateID = $row->vol_lLastUpdateID;
             $vRec->dteOrigin = $row->dteOrigin;
             $vRec->dteLastUpdate = $row->dteLastUpdate;
             $vRec->strUCFName = $row->strUCFName;
             $vRec->strUCLName = $row->strUCLName;
             $vRec->strULFName = $row->strULFName;
             $vRec->strULLName = $row->strULLName;
             ++$idx;
         }
     }
 }
 private function searchPeopleTableGeneric($bHofH, $bBiz, $enumSearchType, $bNewVol)
 {
     //-----------------------------------------------------------------------
     //
     //-----------------------------------------------------------------------
     $clsPeople = new mpeople();
     if ($bHofH) {
         $strWhereHofH = ' AND pe_lKeyID=pe_lHouseholdID ';
     } else {
         $strWhereHofH = '';
     }
     $strWhereVol = $strSelectVol = '';
     if ($enumSearchType == CENUM_CONTEXT_VOLUNTEER) {
         $strSelectVol = ', vol_lKeyID, vol_bInactive ';
         if ($bNewVol) {
             $strInnerVol = ' LEFT JOIN volunteers ON pe_lKeyID=vol_lPeopleID ';
             $strWhereVol = ' AND ((vol_lKeyID IS NULL) OR (vol_bInactive)) ';
         } else {
             $strInnerVol = ' INNER JOIN volunteers ON pe_lKeyID=vol_lPeopleID ';
         }
     } else {
         $strInnerVol = '';
     }
     $strWhereBiz = ' AND ' . ($bBiz ? '' : ' NOT ') . ' pe_bBiz ';
     $sqlStr = "SELECT\n            pe_lKeyID, pe_strFName, pe_strLName, pe_strMName,\n            pe_strPreferredName, pe_strTitle, pe_lHouseholdID,\n            pe_strAddr1, pe_strAddr2, pe_strCity, pe_strState,\n            pe_strCountry, pe_strZip\n            {$strSelectVol}\n         FROM people_names\n            {$strInnerVol}\n         WHERE 1\n            AND NOT pe_bRetired\n            {$strWhereHofH}\n            {$strWhereBiz}\n            {$strWhereVol}\n            {$this->strWhereExtra}\n         ORDER BY pe_strLName, pe_strFName, pe_lKeyID;";
     $query = $this->db->query($sqlStr);
     $numRows = $query->num_rows();
     if ($numRows > 0) {
         $idx = 0;
         foreach ($query->result() as $row) {
             $this->searchResults[$this->lNumSearchResults] = new stdClass();
             $clsResult = $this->searchResults[$this->lNumSearchResults];
             if ($enumSearchType == CENUM_CONTEXT_VOLUNTEER && !$bNewVol) {
                 $clsResult->lKeyID = $row->vol_lKeyID;
             } else {
                 $clsResult->lKeyID = $row->pe_lKeyID;
             }
             $clsResult->enumSearchType = $enumSearchType;
             switch ($enumSearchType) {
                 case CENUM_CONTEXT_HOUSEHOLD:
                     $clsResult->strResult = '<b>The ' . htmlspecialchars($row->pe_strFName . ' ' . $row->pe_strLName) . ' Household</b><br>' . strBuildAddress($row->pe_strAddr1, $row->pe_strAddr2, $row->pe_strCity, $row->pe_strState, $row->pe_strCountry, $row->pe_strZip, true, true);
                     break;
                 case CENUM_CONTEXT_VOLUNTEER:
                     $strSafeNameLF = htmlspecialchars(strBuildName(true, $row->pe_strTitle, $row->pe_strPreferredName, $row->pe_strFName, $row->pe_strLName, $row->pe_strMName));
                     $strFont = $strFontEnd = '';
                     if (!is_null($row->vol_lKeyID) && $row->vol_bInactive) {
                         $strFont = '<font style="color: #777777"><i>';
                         $strFontEnd = '<br>(inactive volunteer)</i></font> ';
                     }
                     $clsResult->strResult = $strFont . '<b>' . $strSafeNameLF . "</b><br>\n" . strBuildAddress($row->pe_strAddr1, $row->pe_strAddr2, $row->pe_strCity, $row->pe_strState, $row->pe_strCountry, $row->pe_strZip, true, true) . $strFontEnd;
                     break;
                 case CENUM_CONTEXT_PEOPLE:
                     $strHousehold = $clsPeople->strHouseholdNameViaHID($row->pe_lHouseholdID);
                     $strSafeNameLF = htmlspecialchars(strBuildName(true, $row->pe_strTitle, $row->pe_strPreferredName, $row->pe_strFName, $row->pe_strLName, $row->pe_strMName));
                     $clsResult->strResult = '<b>' . $strSafeNameLF . "</b><br>\n" . '<i>' . htmlspecialchars($strHousehold) . '</i><br>' . strBuildAddress($row->pe_strAddr1, $row->pe_strAddr2, $row->pe_strCity, $row->pe_strState, $row->pe_strCountry, $row->pe_strZip, true, true);
                     break;
                 case CENUM_CONTEXT_BIZ:
                     $clsResult->strResult = '<b>' . htmlspecialchars($row->pe_strLName) . '</b><br>' . strBuildAddress($row->pe_strAddr1, $row->pe_strAddr2, $row->pe_strCity, $row->pe_strState, $row->pe_strCountry, $row->pe_strZip, true, true);
                     break;
                 default:
                     screamForHelp($enumSearchType . ': invalid switch type<br>error on <b>line:</b> ' . __LINE__ . '<br><b>file: </b>' . __FILE__ . '<br><b>function: </b>' . __FUNCTION__);
                     break;
             }
             ++$this->lNumSearchResults;
             ++$idx;
         }
     }
 }