function loadAuctions()
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $this->auctions = array();
     $sqlStr = "SELECT\n            auc_lKeyID, auc_strAuctionName, auc_strDescription,\n            auc_dteAuctionDate,\n\n            auc_strLocation, auc_strContact, auc_strPhone, auc_strEmail,\n            auc_lDefaultBidSheet, abs_lKeyID, abs_lTemplateID, abs_strSheetName,\n            auc_lCampaignID, gc_strCampaign,\n            ga_lKeyID, ga_strAccount,\n\n            auc_lACOID,\n            aco_strFlag, aco_strCurrencySymbol, aco_strName,\n\n            auc_lOriginID, auc_lLastUpdateID,\n            usersC.us_strFirstName AS strCFName, usersC.us_strLastName AS strCLName,\n            usersL.us_strFirstName AS strLFName, usersL.us_strLastName AS strLLName,\n            UNIX_TIMESTAMP(auc_dteOrigin)     AS dteOrigin,\n            UNIX_TIMESTAMP(auc_dteLastUpdate) AS dteLastUpdate\n\n         FROM gifts_auctions\n            INNER JOIN admin_users AS usersC   ON auc_lOriginID     = usersC.us_lKeyID\n            INNER JOIN admin_users AS usersL   ON auc_lLastUpdateID = usersL.us_lKeyID\n            INNER JOIN admin_aco               ON auc_lACOID        = aco_lKeyID\n            INNER JOIN gifts_campaigns         ON auc_lCampaignID   = gc_lKeyID\n            INNER JOIN gifts_accounts          ON gc_lAcctID        = ga_lKeyID\n            LEFT  JOIN gifts_auctions_bidsheets ON abs_lKeyID        = auc_lDefaultBidSheet\n\n         WHERE NOT auc_bRetired\n            {$this->strWhereExtra}\n         ORDER BY auc_dteAuctionDate DESC, auc_strAuctionName, auc_lKeyID;";
     $query = $this->db->query($sqlStr);
     $this->lNumAuctions = $lNumAuctions = $query->num_rows();
     if ($lNumAuctions == 0) {
         $this->auctions[0] = new stdClass();
         $auction =& $this->auctions[0];
         $auction->lKeyID = $auction->strAuctionName = $auction->strSafeName = $auction->strDescription = $auction->dteAuction = $auction->mdteAuction = $auction->lDefaultBidSheet = $auction->lBidsheetID = $auction->lTemplateID = $auction->tInfo = $auction->strLocation = $auction->strContact = $auction->strPhone = $auction->strEmail = $auction->lCampaignID = $auction->strCampaign = $auction->lAccountID = $auction->strAccount = $auction->lACOID = $auction->strFlag = $auction->strCurrencySymbol = $auction->strACOName = $auction->auc_lOriginID = $auction->auc_lLastUpdateID = $auction->strCFName = $auction->strCLName = $auction->strLFName = $auction->strLLName = $auction->dteOrigin = $auction->dteLastUpdate = null;
     } else {
         $idx = 0;
         $cACO = new madmin_aco();
         foreach ($query->result() as $row) {
             $this->auctions[$idx] = new stdClass();
             $auction =& $this->auctions[$idx];
             $auction->lKeyID = $row->auc_lKeyID;
             $auction->strAuctionName = $row->auc_strAuctionName;
             $auction->strSafeName = htmlspecialchars($row->auc_strAuctionName);
             $auction->strDescription = $row->auc_strDescription;
             $auction->dteAuction = dteMySQLDate2Unix($row->auc_dteAuctionDate);
             $auction->mdteAuction = $row->auc_dteAuctionDate;
             $auction->lDefaultBidSheet = $row->auc_lDefaultBidSheet;
             $auction->lBidsheetID = $row->abs_lKeyID;
             $auction->lTemplateID = $lTemplateID = $row->abs_lTemplateID;
             if (is_null($lTemplateID)) {
                 $auction->tInfo = null;
             } else {
                 strXlateTemplate($lTemplateID, $auction->tInfo);
             }
             $auction->strSheetName = $row->abs_strSheetName;
             $auction->lCampaignID = $row->auc_lCampaignID;
             $auction->strCampaign = $row->gc_strCampaign;
             $auction->lAccountID = $row->ga_lKeyID;
             $auction->strAccount = $row->ga_strAccount;
             $auction->strLocation = $row->auc_strLocation;
             $auction->strContact = $row->auc_strContact;
             $auction->strPhone = $row->auc_strPhone;
             $auction->strEmail = $row->auc_strEmail;
             $auction->lACOID = $row->auc_lACOID;
             $auction->strCurrencySymbol = $row->aco_strCurrencySymbol;
             $auction->strACOName = $row->aco_strName;
             $auction->strFlag = $row->aco_strFlag;
             $auction->strFlagImg = $cACO->strFlagImage($auction->strFlag, $auction->strACOName);
             $auction->auc_lOriginID = $row->auc_lOriginID;
             $auction->auc_lLastUpdateID = $row->auc_lLastUpdateID;
             $auction->strCFName = $row->strCFName;
             $auction->strCLName = $row->strCLName;
             $auction->strLFName = $row->strLFName;
             $auction->strLLName = $row->strLLName;
             $auction->dteOrigin = $row->dteOrigin;
             $auction->dteLastUpdate = $row->dteLastUpdate;
             ++$idx;
         }
     }
 }
 function loadSearchTerms()
 {
     //---------------------------------------------------------------------
     // data loaded in $this->lNumTerms and $this->terms
     //---------------------------------------------------------------------
     $this->lNumTerms = 0;
     $this->terms = array();
     $cACO = new madmin_aco();
     $sqlStr = "SELECT\n               crs_lKeyID, crs_lReportID, crs_lFieldID, crs_strFieldID,\n               crs_lTableID, crs_lNumLParen, crs_lNumRParen, crs_lSortIDX,\n               crs_lCompareOpt,\n               crs_bCompareBool, crs_lCompVal, crs_strCompVal, crs_curCompVal, crs_dteCompVal,\n               crs_bNextTermBoolAND,\n               crs_lOriginID, crs_lLastUpdateID,\n\n               pff_lCurrencyACO,\n               pff_strFieldNameUser, pff_enumFieldType, pft_strUserTableName, pft_enumAttachType\n            FROM creport_search\n               LEFT JOIN uf_fields ON pff_lKeyID   = crs_lFieldID\n               LEFT JOIN uf_tables ON pff_lTableID = pft_lKeyID\n            WHERE 1 {$this->strWhereExtra}\n            ORDER BY crs_lSortIDX, crs_lKeyID;";
     $query = $this->db->query($sqlStr);
     $this->lNumTerms = $lNumTerms = $query->num_rows();
     if ($lNumTerms == 0) {
         $this->terms[0] = new stdClass();
         $term =& $this->terms[0];
         $term->lKeyID = $term->lReportID = $term->lTableID = $term->lFieldID = $term->strFieldID = $term->enumFieldType = $term->enumAttachType = $term->strFieldNameUser = $term->strUserTableName = $term->lNumLParen = $term->lNumRParen = $term->lSortIDX = $term->lCompareOpt = $term->bCompareBool = $term->lCompVal = $term->curCompVal = $term->lCurrencyACO = $term->strCompVal = $term->mdteCompVal = $term->bNextTermBoolAND = $term->lOriginID = $term->lLastUpdateID = null;
     } else {
         $idx = 0;
         foreach ($query->result() as $row) {
             $this->terms[$idx] = new stdClass();
             $term =& $this->terms[$idx];
             $term->lKeyID = (int) $row->crs_lKeyID;
             $term->lReportID = (int) $row->crs_lReportID;
             $term->lTableID = (int) $row->crs_lTableID;
             $term->lFieldID = (int) $row->crs_lFieldID;
             $term->strFieldID = $row->crs_strFieldID;
             if ($term->lTableID <= 0) {
                 crptFieldPropsParentTable($term->lTableID, $term->strFieldID, $term->strUserTableName, $term->enumFieldType, $term->strFieldNameUser, $term->enumAttachType);
             } else {
                 $term->enumFieldType = $row->pff_enumFieldType;
                 $term->strUserTableName = $row->pft_strUserTableName;
                 $term->strFieldNameUser = $row->pff_strFieldNameUser;
                 $term->enumAttachType = $row->pft_enumAttachType;
             }
             $term->lNumLParen = (int) $row->crs_lNumLParen;
             $term->lNumRParen = (int) $row->crs_lNumRParen;
             $term->lSortIDX = (int) $row->crs_lSortIDX;
             $term->lCompareOpt = (int) $row->crs_lCompareOpt;
             $term->bCompareBool = (bool) $row->crs_bCompareBool;
             $term->lCompVal = (int) $row->crs_lCompVal;
             $term->lCurrencyACO = (int) $row->pff_lCurrencyACO;
             if ($term->lCurrencyACO > 0) {
                 $cACO->loadCountries(false, true, true, $term->lCurrencyACO);
                 $term->ACO = clone $cACO->countries[0];
             }
             $term->curCompVal = $row->crs_curCompVal;
             $term->strCompVal = $row->crs_strCompVal;
             $term->mdteCompVal = $row->crs_dteCompVal;
             $term->bNextTermBoolAND = $row->crs_bNextTermBoolAND;
             $term->lOriginID = $row->crs_lOriginID;
             $term->lLastUpdateID = $row->crs_lLastUpdateID;
             ++$idx;
         }
     }
 }
Beispiel #3
0
 public function loadBasicBizInfo()
 {
     //-----------------------------------------------------------------------
     //
     //-----------------------------------------------------------------------
     global $gbDev;
     $clsACO = new madmin_aco();
     if (is_null($this->lBID)) {
         screamForHelp('BIZ ID NOT SET!<br>error on <b>line:</b> ' . __LINE__ . '<br><b>file: </b>' . __FILE__ . '<br><b>function: </b>' . __FUNCTION__);
     }
     $sqlStr = "SELECT\n            pe_strLName,\n            pe_strAddr1,       pe_strAddr2,\n            pe_strCity,        pe_strState,      pe_strCountry,\n            pe_strZip,         pe_strPhone,      pe_strCell,      pe_strEmail,\n            pe_lAttributedTo,  pe_strImportID,   pe_strImportID,\n            pe_lOriginID,      pe_lLastUpdateID, pe_lBizIndustryID, lgen_strListItem,\n\n            pe_lACO, aco_strFlag, aco_strName, aco_strCurrencySymbol,\n\n            usersC.us_strFirstName AS strCFName, usersC.us_strLastName AS strCLName,\n            usersL.us_strFirstName AS strLFName, usersL.us_strLastName AS strLLName,\n            UNIX_TIMESTAMP(pe_dteOrigin)     AS dteOrigin,\n            UNIX_TIMESTAMP(pe_dteLastUpdate) AS dteLastUpdate\n         FROM people_names\n            INNER JOIN admin_users AS usersC ON pe_lOriginID      = usersC.us_lKeyID\n            INNER JOIN admin_users AS usersL ON pe_lLastUpdateID  = usersL.us_lKeyID\n            INNER JOIN admin_aco             ON pe_lACO           = aco_lKeyID\n            LEFT  JOIN lists_generic         ON pe_lBizIndustryID = lgen_lKeyID\n         WHERE pe_lKeyID={$this->lBID}\n            AND NOT pe_bRetired;";
     $query = $this->db->query($sqlStr);
     $numRows = $query->num_rows();
     //      $result = mysql_query($sqlStr);
     //      if (bSQLError('SQL error on line '.__LINE__.', file '.__FILE__.', function '.__FUNCTION__, $sqlStr) ) {
     //         screamForHelp('Unexpected SQL error');
     //      }else{
     //         $numRows = mysql_num_rows($result);
     if ($numRows == 0) {
         if ($gbDev) {
             echo '<font face="monospace" style="font-size: 8pt;">' . __FILE__ . ' Line: <b>' . __LINE__ . ":</b><br><b>\$sqlStr=</b><br>" . nl2br($sqlStr) . "<br><br></font>\n";
         }
         screamForHelp('UNEXPECTED EOF<br>error on <b>line:</b> ' . __LINE__ . '<br><b>file: </b>' . __FILE__ . '<br><b>function: </b>' . __FUNCTION__, true);
     } else {
         //         $row = mysql_fetch_array($result);
         $row = $query->row();
         $this->strBizName = $row->pe_strLName;
         $this->strSafeName = htmlspecialchars($this->strBizName);
         $this->lIndustryID = $row->pe_lBizIndustryID;
         $this->strIndustry = $row->lgen_strListItem;
         $this->strAddr1 = $row->pe_strAddr1;
         $this->strAddr2 = $row->pe_strAddr2;
         $this->strCity = $row->pe_strCity;
         $this->strState = $row->pe_strState;
         $this->strCountry = $row->pe_strCountry;
         $this->strZip = $row->pe_strZip;
         $this->strPhone = $row->pe_strPhone;
         $this->strCell = $row->pe_strCell;
         $this->strAddress = strBuildAddress($this->strAddr1, $this->strAddr2, $this->strCity, $this->strState, $this->strCountry, $this->strZip, true);
         $this->strEmail = $row->pe_strEmail;
         $this->strEmailFormatted = strBuildEmailLink($this->strEmail, '', false, '');
         $this->lACO = $row->pe_lACO;
         $this->strACO = $row->aco_strName;
         $this->strCurSymbol = $row->aco_strCurrencySymbol;
         $this->strFlag = $row->aco_strFlag;
         $this->strFlagImage = $clsACO->strFlagImage($this->strFlag, $this->strACO);
         $this->lAttributedTo = $row->pe_lAttributedTo;
         $this->lImportID = $row->pe_strImportID;
         $this->strImportRecID = $row->pe_strImportID;
         $this->lOriginID = $row->pe_lOriginID;
         $this->lLastUpdateID = $row->pe_lLastUpdateID;
         $this->dteOrigin = $row->dteOrigin;
         $this->dteLastUpdate = $row->dteLastUpdate;
         $this->strStaffCFName = $row->strCFName;
         $this->strStaffCLName = $row->strCLName;
         $this->strStaffLFName = $row->strLFName;
         $this->strStaffLLName = $row->strLLName;
         $this->contactList(true, false, false);
     }
     //      }
 }
 function loadIItems($sqlWhere, &$lNumItems, &$items, $bLoadStatus = false)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $clsACO = new madmin_aco();
     $items = array();
     $sqlStr = "SELECT\n            ivi_lKeyID, ivi_strItemName, ivi_strItemSNa, ivi_strItemSNb,\n            ivi_strLocation, ivi_strDescription, ivi_lCategoryID,\n            ivi_strRParty,\n            ivi_dteObtained, ivi_dteRemInventory, ivi_dteReportedLost,\n            ivi_bAvailForLoan,\n            ivi_strLostNotes,\n            ivi_lFlaggedLostByID, ivi_lRemInventoryByID,\n\n            ivc_strCatName,\n            ivi_lOriginID, ivi_lLastUpdateID,\n            UNIX_TIMESTAMP(ivi_dteOrigin)     AS dteOrigin,\n            UNIX_TIMESTAMP(ivi_dteLastUpdate) AS dteLastUpdate,\n\n            ivi_curEstValue, ivi_lACOID, aco_strFlag, aco_strCurrencySymbol, aco_strName,\n\n            uc.us_strFirstName    AS strCFName,      uc.us_strLastName    AS strCLName,\n            ul.us_strFirstName    AS strLFName,      ul.us_strLastName    AS strLLName,\n            ur.us_strFirstName    AS strRemInvFName, ur.us_strLastName    AS strRemInvLName,\n            ulost.us_strFirstName AS strLostFName,   ulost.us_strLastName AS strLostLName\n\n         FROM inv_items\n               INNER JOIN admin_users  AS uc    ON uc.us_lKeyID    = ivi_lOriginID\n               INNER JOIN admin_users  AS ul    ON ul.us_lKeyID    = ivi_lLastUpdateID\n               LEFT  JOIN admin_users  AS ur    ON ur.us_lKeyID    = ivi_lRemInventoryByID\n               LEFT  JOIN admin_users  AS ulost ON ulost.us_lKeyID = ivi_lFlaggedLostByID\n               INNER JOIN inv_cats              ON ivc_lKeyID      = ivi_lCategoryID\n               INNER JOIN admin_aco             ON ivi_lACOID      = aco_lKeyID\n\n         WHERE NOT ivi_bRetired {$sqlWhere}\n         ORDER BY ivi_strItemName, ivi_lKeyID;";
     $query = $this->db->query($sqlStr);
     $lNumItems = $query->num_rows();
     if ($lNumItems == 0) {
         $items[0] = new stdClass();
         $item =& $items[0];
         $item->lKeyID = null;
         $item->strItemName = $item->strItemSNa = $item->strItemSNb = $item->strLocation = $item->strDescription = $item->lCategoryID = $item->strCatName = $item->dteObtained = $item->strRParty = null;
         $item->bAvailForLoan = $item->dteRemInventory = $item->lRemInventoryByID = $item->strRemInvFName = $item->strRemInvLName = null;
         $item->dteReportedLost = $item->bLost = $item->strLostNotes = $item->lFlaggedLostByID = $item->strLostFName = $item->strLostLName = null;
         $item->curEstValue = $item->lACOID = $item->strFlagImg = $item->strACOCurSymbol = $item->strACOCountry = $item->strFormattedAmnt = null;
         $item->lOriginID = $item->lLastUpdateID = $item->ucstrFName = $item->ucstrLName = $item->ulstrFName = $item->ulstrLName = $item->dteOrigin = $item->dteLastUpdate = null;
     } else {
         $idx = 0;
         foreach ($query->result() as $row) {
             $items[$idx] = new stdClass();
             $item =& $items[$idx];
             $item->lKeyID = $lIItemID = (int) $row->ivi_lKeyID;
             $item->strItemName = $row->ivi_strItemName;
             $item->strItemSNa = $row->ivi_strItemSNa;
             $item->strItemSNb = $row->ivi_strItemSNb;
             $item->strLocation = $row->ivi_strLocation;
             $item->strDescription = $row->ivi_strDescription;
             $item->lCategoryID = (int) $row->ivi_lCategoryID;
             $item->strCatName = $row->ivc_strCatName;
             $item->dteObtained = dteMySQLDate2Unix($row->ivi_dteObtained);
             $item->strRParty = $row->ivi_strRParty;
             $item->bAvailForLoan = (bool) $row->ivi_bAvailForLoan;
             $item->dteRemInventory = dteMySQLDate2Unix($row->ivi_dteRemInventory);
             $item->bRemoved = !is_null($item->dteRemInventory);
             $item->lRemInventoryByID = $row->ivi_lRemInventoryByID;
             $item->strRemInvFName = $row->strRemInvFName;
             $item->strRemInvLName = $row->strRemInvLName;
             $item->dteReportedLost = dteMySQLDate2Unix($row->ivi_dteReportedLost);
             $item->bLost = !is_null($item->dteReportedLost);
             $item->strLostNotes = $row->ivi_strLostNotes;
             $item->lFlaggedLostByID = $row->ivi_lFlaggedLostByID;
             $item->strLostFName = $row->strLostFName;
             $item->strLostLName = $row->strLostLName;
             $item->curEstValue = (double) $row->ivi_curEstValue;
             $item->lACOID = (int) $row->ivi_lACOID;
             $item->strFlagImg = $clsACO->strFlagImage($row->aco_strFlag, $row->aco_strName);
             $item->strACOCurSymbol = $row->aco_strCurrencySymbol;
             $item->strACOCountry = $row->aco_strName;
             $item->strFormattedAmnt = $item->strACOCurSymbol . ' ' . number_format($item->curEstValue, 2) . ' ' . $item->strFlagImg;
             $item->lOriginID = (int) $row->ivi_lOriginID;
             $item->lLastUpdateID = (int) $row->ivi_lLastUpdateID;
             $item->ucstrFName = $row->strCFName;
             $item->ucstrLName = $row->strCLName;
             $item->ulstrFName = $row->strLFName;
             $item->ulstrLName = $row->strLLName;
             $item->dteOrigin = (int) $row->dteOrigin;
             $item->dteLastUpdate = (int) $row->dteLastUpdate;
             if ($bLoadStatus) {
                 $item->statProps = new stdClass();
                 $item->statProps->bAvail = $item->bAvailForLoan;
                 $item->statProps->bLost = $item->bLost;
                 $item->statProps->bCheckedOut = $this->bItemCheckedOutInfo($lIItemID, $item->statProps->strCO_To, $item->statProps->cicoID, $item->statProps->dteCO);
                 $item->statProps->bRemovedFromInv = $item->bRemoved;
                 $item->strStatus = cico\strItemStatus($item->statProps);
             }
             ++$idx;
         }
     }
 }
 public function loadPaymentRecords()
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $clsACO = new madmin_aco();
     $this->paymentRec = array();
     $sqlStr = "SELECT\n               gi_lKeyID,\n\n               gi_lForeignID, gi_lSponsorID, gi_curAmnt, gi_lACOID,\n               gi_dteDonation,\n               gi_strCheckNum, gi_strImportID,\n               gi_lPaymentType, listPayType.lgen_strListItem AS strPaymentType,\n               gi_bRetired,\n\n               gi_lOriginID, gi_lLastUpdateID,\n               UNIX_TIMESTAMP(gi_dteOrigin)     AS dteOrigin,\n               UNIX_TIMESTAMP(gi_dteLastUpdate) AS dteLastUpdate,\n\n               aco_strFlag, aco_strName, aco_strCurrencySymbol,\n\n               sp_lForeignID, sp_bInactive, sp_lClientID,\n               pSpon.pe_bBiz AS bSponBiz,  pSpon.pe_strFName AS strSponFName,  pSpon.pe_strLName AS strSponLName,\n               pDon.pe_bBiz  AS bDonorBiz, pDon.pe_strFName  AS strDonorFName, pDon.pe_strLName  AS strDonorLName,\n               cr_strFName, cr_strLName,\n               cr_lLocationID, cl_strLocation,\n\n               usersC.us_strFirstName AS strCFName, usersC.us_strLastName AS strCLName,\n               usersL.us_strFirstName AS strLFName, usersL.us_strLastName AS strLLName\n\n            FROM gifts\n               INNER JOIN admin_aco               ON gi_lACOID         = aco_lKeyID\n               INNER JOIN sponsor                 ON sp_lKeyID         = gi_lSponsorID\n               INNER JOIN people_names AS pSpon   ON sp_lForeignID     = pSpon.pe_lKeyID\n               INNER JOIN people_names AS pDon    ON gi_lForeignID     = pDon.pe_lKeyID\n\n               INNER JOIN admin_users AS usersC   ON gi_lOriginID      = usersC.us_lKeyID\n               INNER JOIN admin_users AS usersL   ON gi_lLastUpdateID  = usersL.us_lKeyID\n\n               LEFT  JOIN lists_generic AS listPayType ON gi_lPaymentType  = listPayType.lgen_lKeyID\n               LEFT  JOIN client_records               ON sp_lClientID     = cr_lKeyID\n               LEFT  JOIN client_location              ON cr_lLocationID   = cl_lKeyID\n            WHERE NOT gi_bRetired {$this->strPayWhere}\n            {$this->strPayOrderExtra}\n            {$this->strLimit};";
     $query = $this->db->query($sqlStr);
     $this->lNumPayRecs = $numRows = $query->num_rows();
     if ($numRows == 0) {
         $this->paymentRec[0] = new stdClass();
         $payRec =& $this->paymentRec[0];
         $payRec->lKeyID = $payRec->curPaymentAmnt = $payRec->dtePayment = $payRec->strCheckNum = $payRec->lPaymentType = $payRec->strPaymentType = $payRec->strImportID = $payRec->bRetired = $payRec->lACOID = $payRec->strACO = $payRec->strCurSymbol = $payRec->strFlag = $payRec->strFlagImage = null;
         //--------------------------
         // Sponsor/client fields
         //--------------------------
         $payRec->lSponsorshipID = $payRec->lSponPeopleID = $payRec->bInactive = $payRec->lClientID = $payRec->bSponBiz = $payRec->strSponFName = $payRec->strSponLName = $payRec->strSponSafeNameFL = $payRec->strClientFName = $payRec->strClientLName = $payRec->strClientSafeNameFL = $payRec->lLocationID = $payRec->strLocation = null;
         //--------------------------
         // Donor fields
         //--------------------------
         $payRec->lDonorID = $payRec->bDonorBiz = $payRec->strDonorFName = $payRec->strDonorLName = $payRec->strDonorSafeNameFL = $payRec->lOriginID = $payRec->lLastUpdateID = $payRec->dteOrigin = $payRec->dteLastUpdate = $payRec->strStaffCFName = $payRec->strStaffCLName = $payRec->strStaffLFName = $payRec->strStaffLLName = null;
     } else {
         $idx = 0;
         foreach ($query->result() as $row) {
             $this->paymentRec[$idx] = new stdClass();
             $payRec =& $this->paymentRec[$idx];
             $payRec->lKeyID = (int) $row->gi_lKeyID;
             $payRec->curPaymentAmnt = (double) $row->gi_curAmnt;
             $payRec->dtePayment = dteMySQLDate2Unix($row->gi_dteDonation);
             $payRec->strCheckNum = $row->gi_strCheckNum;
             $payRec->lPaymentType = $row->gi_lPaymentType;
             $payRec->strPaymentType = $row->strPaymentType;
             $payRec->strImportID = $row->gi_strImportID;
             $payRec->bRetired = $row->gi_bRetired;
             //---------------
             // ACO fields
             //---------------
             $payRec->lACOID = (int) $row->gi_lACOID;
             $payRec->strACO = $row->aco_strName;
             $payRec->strCurSymbol = $row->aco_strCurrencySymbol;
             $payRec->strFlag = $row->aco_strFlag;
             $payRec->strFlagImage = $clsACO->strFlagImage($row->aco_strFlag, $row->aco_strName);
             //--------------------------
             // Sponsor/client fields
             //--------------------------
             $payRec->lSponsorshipID = $row->gi_lSponsorID;
             $payRec->lSponPeopleID = $row->sp_lForeignID;
             $payRec->bInactive = $row->sp_bInactive;
             $payRec->lClientID = $row->sp_lClientID;
             $payRec->bSponBiz = $row->bSponBiz;
             $payRec->strSponFName = $row->strSponFName;
             $payRec->strSponLName = $row->strSponLName;
             if ($payRec->bSponBiz) {
                 $payRec->strSponSafeNameFL = $payRec->strSponSafeNameLF = htmlspecialchars($row->strSponLName);
             } else {
                 $payRec->strSponSafeNameFL = htmlspecialchars($row->strSponFName . ' ' . $row->strSponLName);
                 $payRec->strSponSafeNameLF = htmlspecialchars($row->strSponLName . ', ' . $row->strSponFName);
             }
             $payRec->strClientFName = $row->cr_strFName;
             $payRec->strClientLName = $row->cr_strLName;
             $payRec->strClientSafeNameFL = htmlspecialchars($row->cr_strFName . ' ' . $row->cr_strLName);
             $payRec->lLocationID = $row->cr_lLocationID;
             $payRec->strLocation = $row->cl_strLocation;
             //--------------------------
             // Donor fields
             //--------------------------
             $payRec->lDonorID = $row->gi_lForeignID;
             $payRec->bDonorBiz = $row->bDonorBiz;
             $payRec->strDonorFName = $row->strDonorFName;
             $payRec->strDonorLName = $row->strDonorLName;
             if ($payRec->bSponBiz) {
                 $payRec->strDonorSafeNameFL = $payRec->strDonorSafeNameLF = htmlspecialchars($row->strSponLName);
             } else {
                 $payRec->strDonorSafeNameFL = htmlspecialchars($row->strDonorFName . ' ' . $row->strDonorLName);
                 $payRec->strDonorSafeNameLF = htmlspecialchars($row->strDonorLName . ', ' . $row->strDonorFName);
             }
             //--------------------------
             // Record info
             //--------------------------
             $payRec->lOriginID = $row->gi_lOriginID;
             $payRec->lLastUpdateID = $row->gi_lLastUpdateID;
             $payRec->dteOrigin = $row->dteOrigin;
             $payRec->dteLastUpdate = $row->dteLastUpdate;
             $payRec->strStaffCFName = $row->strCFName;
             $payRec->strStaffCLName = $row->strCLName;
             $payRec->strStaffLFName = $row->strLFName;
             $payRec->strStaffLLName = $row->strLLName;
             ++$idx;
         }
     }
 }
 function strSponMonthIncomeReport(&$sRpt, &$displayData, $lStartRec, $lRecsPerPage)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $genumDateFormat;
     $strOut = '';
     $strLimit = " LIMIT {$lStartRec}, {$lRecsPerPage} ";
     $this->sponIncomeViaMonthVars($sRpt, $lYear, $lMonth, $lACOID);
     $cACO = new madmin_aco();
     $cACO->loadCountries(false, true, true, $lACOID);
     $cCountry = $cACO->countries[0];
     $strOut = '<table class="enpView">
         <tr>
            <td class="enpViewLabel" colspan="2" style="text-align: left; font-size: 13pt;">
               Sponsorship Income
            </td>
         </tr>
         <tr>
            <td class="enpViewLabel">
               Accounting Country:
            </td>
            <td class="enpView">' . $cCountry->strName . ' ' . $cCountry->strCurrencySymbol . ' ' . $cCountry->strFlagImg . '
            </td>
         </tr>
         <tr>
            <td class="enpViewLabel">
               Month:
            </td>
            <td class="enpView">' . strXlateMonth($lMonth) . ' ' . $lYear . '
            </td>
         </tr>
      </table>';
     $sqlStr = "SELECT\n            gi_lKeyID, gi_lSponsorID,\n            gi_dteDonation,\n            gi_curAmnt, gi_lForeignID, sp_lForeignID,\n            payer.pe_bBiz AS bPayerBiz, payer.pe_strLName AS strPayerLName, payer.pe_strFName AS strPayerFName,\n            payer.pe_strAddr1, payer.pe_strAddr2, payer.pe_strCity, payer.pe_strState, payer.pe_strZip, payer.pe_strCountry,\n            spon.pe_bBiz AS bSponBiz, spon.pe_strLName AS strSponLName, spon.pe_strFName AS strSponFName\n         FROM gifts\n            INNER JOIN people_names AS payer ON gi_lForeignID=payer.pe_lKeyID\n            INNER JOIN sponsor               ON gi_lSponsorID=sp_lKeyID\n            INNER JOIN people_names AS spon  ON sp_lForeignID=spon.pe_lKeyID\n\n         WHERE NOT gi_bRetired\n            AND gi_lACOID={$lACOID}\n            AND MONTH(gi_dteDonation)={$lMonth}\n            AND YEAR (gi_dteDonation)={$lYear}\n            AND gi_lSponsorID IS NOT NULL\n         ORDER BY gi_dteDonation, gi_lKeyID\n         {$strLimit};";
     $query = $this->db->query($sqlStr);
     $lNumRows = $query->num_rows();
     if ($lNumRows > 0) {
         $strOut .= '
         <table class="enpRptC">
            <tr>
               <td class="enpRptLabel">
                  Payment ID
               </td>
               <td class="enpRptLabel">
                  Sponsor ID
               </td>
               <td class="enpRptLabel">
                  Amount
               </td>
               <td class="enpRptLabel">
                  Date
               </td>
               <td class="enpRptLabel">
                  Payer
               </td>
               <td class="enpRptLabel">
                  Sponsor
               </td>
            </tr>';
         foreach ($query->result() as $row) {
             $lPayID = $row->gi_lKeyID;
             $lSponsorID = $row->gi_lSponsorID;
             $lSponsorFID = $row->sp_lForeignID;
             $lPayerID = $row->gi_lForeignID;
             // gift ID
             $strOut .= '
             <tr>
                <td class="enpRpt" style="text-align: center;">' . strLinkView_SponsorPayment($lPayID, 'View payment record', true) . '&nbsp;' . str_pad($lPayID, 5, '0', STR_PAD_LEFT) . '
                </td>';
             // sponsor ID
             $strOut .= '
                <td class="enpRpt" style="text-align: center;">' . strLinkView_Sponsorship($lSponsorID, 'View sponsorship record', true) . '&nbsp;' . str_pad($lSponsorID, 5, '0', STR_PAD_LEFT) . '
                </td>';
             // Amount
             $strOut .= '
                <td class="enpRpt" style="text-align: right; padding-left: 14px;">' . number_format($row->gi_curAmnt, 2) . '
                </td>';
             // Date
             $strOut .= '
                <td class="enpRpt" style="text-align: right;">' . date($genumDateFormat, dteMySQLDate2Unix($row->gi_dteDonation)) . '
                </td>';
             // Payer
             if ($row->bPayerBiz) {
                 $strName = strLinkView_BizRecord($lPayerID, 'View business record', true) . '&nbsp;' . str_pad($lPayerID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . htmlspecialchars($row->strPayerLName) . ' (business)';
             } else {
                 $strName = strLinkView_PeopleRecord($lPayerID, 'View people record', true) . '&nbsp;' . str_pad($lPayerID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . htmlspecialchars($row->strPayerLName . ', ' . $row->strPayerFName);
             }
             $strOut .= '
                <td class="enpRpt" >' . $strName . '
                </td>';
             // Sponsor
             if ($lPayerID == $lSponsorFID) {
                 $strName = '<span style="color: #999; font-style: italic;">(same as payer)';
             } else {
                 if ($row->bSponBiz) {
                     $strName = strLinkView_BizRecord($lSponsorFID, 'View business record', true) . '&nbsp;' . str_pad($lSponsorFID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . htmlspecialchars($row->strSponLName) . ' (business)';
                 } else {
                     $strName = strLinkView_PeopleRecord($lSponsorFID, 'View people record', true) . '&nbsp;' . str_pad($lSponsorFID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . htmlspecialchars($row->strSponLName . ', ' . $row->strSponFName);
                 }
             }
             $strOut .= '
                <td class="enpRpt" >' . $strName . '
                </td>';
             $strOut . '
             </tr>';
         }
         $strOut .= '</table>';
     } else {
         $strOut .= '<br><br><i>There are no records that match your search criteria</i><br>';
     }
     return $strOut;
 }
 function addReportFields(&$fields, &$lFieldIDX, $enumType, $publicName, $internalName, $lCurrencyACO = null, $lFieldID = null)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $fields[$lFieldIDX] = new stdClass();
     $fields[$lFieldIDX]->lFieldID = $lFieldID;
     $fields[$lFieldIDX]->publicName = $publicName;
     $fields[$lFieldIDX]->internalName = $internalName;
     $fields[$lFieldIDX]->enumType = $enumType;
     $fields[$lFieldIDX]->lCurrencyACO = $lCurrencyACO;
     if ($enumType == CS_FT_CURRENCY) {
         $cACO = new madmin_aco();
         $cACO->loadCountries(false, true, true, $lCurrencyACO);
         $fields[$lFieldIDX]->ACO = clone $cACO->countries[0];
     }
     $fields[$lFieldIDX]->fTypeLabel = $this->crptUFields->strFieldTypeLabel($enumType);
     ++$lFieldIDX;
 }
    function strDisplayUserTableSingle(&$clsUserTable)
    {
        //---------------------------------------------------------------------
        //
        //---------------------------------------------------------------------
        global $genumDateFormat, $gbDateFormatUS;
        $clsACO = new madmin_aco();
        $strOut = '';
        $lTableID = $clsUserTable->lKeyID;
        $bCollapsibleHeadings = $clsUserTable->bCollapsibleHeadings;
        $bCollapseDefaultHide = $clsUserTable->bCollapseDefaultHide;
        $strSafeTableName = htmlspecialchars($clsUserTable->strUserTableName);
        $strOut .= $this->strBeginCollapsibleHeading($lTableID, $strSafeTableName, true);
        $this->loadSingleDataRecord($lTableID, $this->lForeignID, $recInfo);
        $lRecID = $recInfo->lRecID;
        $enumTType = $clsUserTable->enumTType;
        $strOut .= '<fieldset class="enpFS" style="width: ' . $this->lFieldSetWidth . 'pt; align: left;">
              <legend class="enpLegend">
                 <b><i>' . $strSafeTableName . '</b></i> ' . strLinkView_UFMFRecordViaRecID($lTableID, $this->lForeignID, $lRecID, 'View record', true, ' id="viewSingle_' . $lTableID . '" ') . '&nbsp;&nbsp;' . "\n" . strLinkEdit_UFMultiRecEntry($enumTType, $lTableID, $this->lForeignID, $lRecID, true, 'Edit table entries', ' id="editSingle_' . $lTableID . '" ') . '&nbsp;&nbsp;' . ($recInfo->bRecordEntered ? '' : '(not written) ') . '

              </legend>';
        $strOut .= '<table class="enpRpt">';
        for ($idx = 0; $idx < $this->lNumFields; ++$idx) {
            $uf =& $this->fields[$idx];
            $enumType = $uf->enumFieldType;
            $userValue = $uf->userValue;
            $lFieldID = $uf->pff_lKeyID;
            if ($enumType == CS_FT_HEADING) {
                $strOut .= '
                  <tr>
                     <td colspan="2" class="enpRptLabel">' . htmlspecialchars($this->fields[$idx]->pff_strFieldNameUser) . '
                     </td>
                  </tr>';
            } else {
                $strOut .= '
                  <tr>
                     <td width="' . $this->lLabelWidth . '" class="enpRptLabel">' . htmlspecialchars($this->fields[$idx]->pff_strFieldNameUser) . '
                     </td>
                     <td class="enpRpt" width="' . $this->lFieldValWidth . '" valign="center">' . "\n";
                if (is_null($userValue) && !($enumType == CS_FT_LOG || $enumType == CS_FT_DDLMULTI)) {
                    $strOut .= '&nbsp';
                } else {
                    switch ($enumType) {
                        case CS_FT_CHECKBOX:
                            $strOut .= (bool) $userValue ? 'Yes' : 'No';
                            break;
                        case CS_FT_DATE:
                            $strOut .= strNumericDateViaMysqlDate($userValue, $gbDateFormatUS);
                            break;
                            //                  case CS_FT_DATETIME:
                            //                     echoT(strNumericDateViaMysqlDate($userValue, $gbDateFormatUS)   date($genumDateFormat.' H:i:s', $userValue));
                            //                     break;
                        //                  case CS_FT_DATETIME:
                        //                     echoT(strNumericDateViaMysqlDate($userValue, $gbDateFormatUS)   date($genumDateFormat.' H:i:s', $userValue));
                        //                     break;
                        case CS_FT_TEXTLONG:
                            $strOut .= nl2br(htmlspecialchars($userValue)) . '&nbsp;';
                            break;
                        case CS_FT_TEXT255:
                        case CS_FT_TEXT80:
                        case CS_FT_TEXT20:
                            $strOut .= htmlspecialchars($userValue) . '&nbsp;';
                            break;
                        case CS_FT_CLIENTID:
                        case CS_FT_INTEGER:
                            $strOut .= number_format($userValue);
                            break;
                        case CS_FT_CURRENCY:
                            $clsACO->loadCountries(false, false, true, $this->fields[$idx]->pff_lCurrencyACO);
                            $strOut .= $clsACO->countries[0]->strCurrencySymbol . ' ' . number_format($userValue, 2) . '&nbsp;' . $clsACO->countries[0]->strFlagImg;
                            break;
                        case CS_FT_DDL:
                            $strOut .= htmlspecialchars($this->strDDLValue($userValue));
                            break;
                        case CS_FT_DDL:
                            $strOut .= htmlspecialchars($this->strDDLValue($userValue));
                            break;
                        case CS_FT_LOG:
                            $strOut .= $this->logDisplay($enumTType, $lFieldID, $lTableID, $this->lForeignID, 5);
                            break;
                        case CS_FT_DDLMULTI:
                            $strDDLMultiFN = $uf->strFieldNameInternal . '_ddlMulti';
                            $this->loadMultiDDLSelects($lTableID, $lFieldID, $lRecID, $uf->{$strDDLMultiFN});
                            $strOut .= $this->strMultiDDLUL($uf->{$strDDLMultiFN});
                            break;
                        default:
                            screamForHelp($enumType . ': invalid field type<br>error on line ' . __LINE__ . ',<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
                            break;
                    }
                }
            }
        }
        $strOut .= '
            </table>' . "\n";
        $strOut .= '
         </fieldset><br>' . "\n";
        //      if ($bCollapsibleHeadings)
        $strOut .= $this->strEndCollapsibleHeading();
        return $strOut;
    }
 function getFulfillments(&$lNumFulfill, &$fulfillment, $lPledgeID, $dteOnOrAfter, $dteBefore)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $clsACO = new madmin_aco();
     $lNumFulfill = 0;
     $fulfillment = array();
     $sqlStr = "SELECT gi_lKeyID, gi_lForeignID,\n             gi_dteDonation,\n             gi_curAmnt, gi_strCheckNum,\n             pe_lKeyID, pe_bBiz, pe_strFName, pe_strLName,\n             gi_lACOID, aco_strFlag, aco_strCurrencySymbol, aco_strName\n           FROM gifts\n            INNER JOIN people_names    ON pe_lKeyID  = gi_lForeignID\n            INNER JOIN admin_aco       ON gi_lACOID  = aco_lKeyID\n           WHERE gi_lPledgeID={$lPledgeID}\n              AND NOT gi_bRetired ";
     if (!is_null($dteOnOrAfter)) {
         $sqlStr .= ' AND gi_dteDonation >= ' . strPrepDate($dteOnOrAfter) . "\n";
     }
     if (!is_null($dteBefore)) {
         $sqlStr .= ' AND gi_dteDonation < ' . strPrepDate($dteBefore) . "\n";
     }
     $sqlStr .= 'ORDER BY gi_dteDonation, gi_lKeyID;';
     $query = $this->db->query($sqlStr);
     $lNumFulfill = $query->num_rows();
     if ($lNumFulfill > 0) {
         $idx = 0;
         foreach ($query->result() as $row) {
             $fulfillment[$idx] = new stdClass();
             $gift =& $fulfillment[$idx];
             $gift->lKeyID = (int) $row->gi_lKeyID;
             $gift->lForeignID = (int) $row->gi_lForeignID;
             $gift->curAmnt = (double) $row->gi_curAmnt;
             $gift->dteDonation = dteMySQLDate2Unix($row->gi_dteDonation);
             $gift->mdteDonation = $row->gi_dteDonation;
             $gift->strCheckNum = $row->gi_strCheckNum;
             $gift->lFID = (int) $row->pe_lKeyID;
             $gift->bBiz = (bool) $row->pe_bBiz;
             $gift->strFName = $row->pe_strFName;
             $gift->strLName = $row->pe_strLName;
             if ($gift->bBiz) {
                 $gift->strSafeName = $gift->strSafeNameLF = htmlspecialchars($row->pe_strLName);
             } else {
                 $gift->strSafeName = htmlspecialchars($row->pe_strFName . ' ' . $row->pe_strLName);
                 $gift->strSafeNameLF = htmlspecialchars($row->pe_strLName . ', ' . $row->pe_strFName);
             }
             $gift->lACOID = (int) $row->gi_lACOID;
             $gift->strFlagImg = $clsACO->strFlagImage($row->aco_strFlag, $row->aco_strName);
             $gift->strACOCurSymbol = $row->aco_strCurrencySymbol;
             $gift->strACOCountry = $row->aco_strName;
             $gift->strFormattedAmnt = $gift->strACOCurSymbol . ' ' . number_format($gift->curAmnt, 2) . ' ' . $gift->strFlagImg;
             ++$idx;
         }
     }
 }
 private function giftNotesSearch(&$results)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $genumDateFormat;
     $results->strLabel = 'Gift notes';
     $results->lNumResults = 0;
     $cACO = new madmin_aco();
     $sqlStr = 'SELECT
            gi_lKeyID, gi_lForeignID, gi_curAmnt, gi_lACOID,
            gi_dteDonation,
            gi_strNotes,
            pe_strLName, pe_strFName, pe_bBiz, gi_lSponsorID
         FROM gifts
            INNER JOIN people_names ON pe_lKeyID=gi_lForeignID
         WHERE NOT gi_bRetired
            AND NOT pe_bRetired AND ' . $this->textSearchWhere('gi_strNotes') . '
         ORDER BY pe_strLName, pe_strFName, gi_lKeyID;';
     $query = $this->db->query($sqlStr);
     $results->lNumResults = $lNumRows = $query->num_rows();
     if ($lNumRows > 0) {
         $idx = 0;
         $results->matches = array();
         foreach ($query->result() as $row) {
             $results->matches[$idx] = new stdClass();
             $match =& $results->matches[$idx];
             $lGiftID = $row->gi_lKeyID;
             $lFID = $row->gi_lForeignID;
             $strFID = str_pad($lFID, 5, '0', STR_PAD_LEFT);
             $bBiz = $row->pe_bBiz;
             $lACOID = $row->gi_lACOID;
             $bSponPay = !is_null($row->gi_lSponsorID);
             $cACO->loadCountries(false, false, true, $lACOID);
             $giftACO =& $cACO->countries[0];
             if ($bSponPay) {
                 $match->links = 'Sponsor Payment ID ' . str_pad($lGiftID, 5, '0', STR_PAD_LEFT) . strLinkView_SponsorPayment($lGiftID, 'View payment record', true) . '&nbsp;&nbsp;&nbsp;';
             } else {
                 $match->links = 'Gift ID ' . str_pad($lGiftID, 5, '0', STR_PAD_LEFT) . strLinkView_GiftsRecord($lGiftID, 'View gift record', true) . '&nbsp;&nbsp;&nbsp;';
             }
             $match->searchInfo = 'Donation record of ' . $giftACO->strCurrencySymbol . ' ' . number_format($row->gi_curAmnt, 2) . ' ' . $giftACO->strFlagImg . ' of ' . date($genumDateFormat, dteMySQLDate2Unix($row->gi_dteDonation)) . ' by ';
             if ($bBiz) {
                 $match->links .= 'Business ID: ' . $strFID . strLinkView_BizRecord($lFID, 'View business record', true);
                 $match->searchInfo .= htmlspecialchars($row->pe_strLName);
             } else {
                 $match->links .= 'People ID: ' . $strFID . strLinkView_PeopleRecord($lFID, 'View people record', true);
                 $match->searchInfo .= htmlspecialchars($row->pe_strFName . ' ' . $row->pe_strLName);
             }
             $match->text = $row->gi_strNotes;
             $match->textHighlighted = $this->highlightMatchedText($row->gi_strNotes);
             ++$idx;
         }
     }
 }
 function strDepositLogReport(&$sRpt, $lStartRec, $lRecsPerPage)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $genumDateFormat;
     $strLimit = " LIMIT {$lStartRec}, {$lRecsPerPage} ";
     $clsACO = new madmin_aco();
     $sqlStr = "SELECT dl_lKeyID,\n               dl_lACOID, dl_dteStart, dl_dteEnd, \n               dl_strBank, dl_strAccount, dl_strNotes,  dl_bRetired,\n               dl_lOriginID, dl_lLastUpdateID,\n               usersC.us_strFirstName AS strCFName, usersC.us_strLastName AS strCLName,\n               usersL.us_strFirstName AS strLFName, usersL.us_strLastName AS strLLName,\n\n               aco_strFlag, aco_strCurrencySymbol, aco_strName,\n\n               UNIX_TIMESTAMP(dl_dteOrigin)     AS dteOrigin,\n               UNIX_TIMESTAMP(dl_dteLastUpdate) AS dteLastUpdate\n\n             FROM deposit_log\n               INNER JOIN admin_users AS usersC ON dl_lOriginID     = usersC.us_lKeyID\n               INNER JOIN admin_users AS usersL ON dl_lLastUpdateID = usersL.us_lKeyID\n               INNER JOIN admin_aco             ON dl_lACOID        = aco_lKeyID\n            WHERE NOT dl_bRetired\n            ORDER BY dl_dteEnd DESC, dl_lKeyID DESC\n            {$strLimit};";
     $query = $this->db->query($sqlStr);
     $lNumRows = $query->num_rows();
     if ($lNumRows == 0) {
         return '<br><i>There are no deposits in your database.</i><br><br>';
     }
     $strOut = strLinkAdd_Deposit('Add new deposit', true) . '&nbsp;' . strLinkAdd_Deposit('Add new deposit', false) . '<br>
       <table class="enpRptC">
          <tr>
             <td class="enpRptTitle" colspan="7">
                Deposit Log
             </td>
          </tr>
          <tr>
             <td class="enpRptLabel">
                Deposit ID
             </td>
             <td class="enpRptLabel">
                ACO
             </td>
             <td class="enpRptLabel">
                Period
             </td>
             <td class="enpRptLabel">
                # Entries
             </td>
             <td class="enpRptLabel">
                Total
             </td>
             <td class="enpRptLabel">
                Bank / Account
             </td>
             <td class="enpRptLabel" style="width: 150pt;">
                Notes
             </td>
          </tr>';
     foreach ($query->result() as $row) {
         $lDepositID = $row->dl_lKeyID;
         $lNumEntries = $this->lNumGiftsViaDeposit($lDepositID, $curTot);
         if ($row->dl_strBank == '' & $row->dl_strAccount == '') {
             $strBA = '&nbsp;';
         } else {
             $strBA = '<b>Bank: </b>' . htmlspecialchars($row->dl_strBank) . '<br>' . '<b>Account: </b>' . htmlspecialchars($row->dl_strAccount);
         }
         $strOut .= '
          <tr class="makeStripe">
             <td class="enpRpt" style="text-align: center;">' . str_pad($lDepositID, 5, '0', STR_PAD_LEFT) . '&nbsp;' . strLinkView_DepositEntry($lDepositID, 'View deposit entry', true) . '
             </td>
             <td class="enpRpt">' . htmlspecialchars($row->aco_strName) . '&nbsp;' . $row->aco_strCurrencySymbol . '&nbsp;' . $clsACO->strFlagImage($row->aco_strFlag, $row->aco_strName) . '
             </td>
             <td class="enpRpt">' . date($genumDateFormat, dteMySQLDate2Unix($row->dl_dteStart)) . ' - ' . date($genumDateFormat, dteMySQLDate2Unix($row->dl_dteEnd)) . '
             </td>
             <td class="enpRpt" style="text-align: center;">' . number_format($lNumEntries) . '
             </td>
             <td class="enpRpt" style="text-align: right;">' . number_format($curTot, 2) . '
             </td>
             <td class="enpRpt">' . $strBA . '
             </td>
             <td class="enpRpt" style="width: 150pt;">' . nl2br(htmlspecialchars($row->dl_strNotes)) . '
             </td>
          </tr>';
     }
     $strOut .= '</table><br><br>';
     return $strOut;
 }
 function loadChapterInfo()
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $clsACO = new madmin_aco();
     if (is_null($this->lChapterID)) {
         screamForHelp('CHAPTER ID NOT SET<br>error on <b>line:</b> ' . __LINE__ . '<br><b>file: </b>' . __FILE__ . '<br><b>function: </b>' . __FUNCTION__);
     }
     $sqlStr = "SELECT\n             ch_lKeyID,\n             ch_strChapterName, ch_strAddress1, ch_strAddress2,\n             ch_strCity, ch_strState, ch_strCountry, ch_strZip,\n             ch_strFax, ch_strPhone, ch_strBannerTagLine,\n             ch_strEmail, ch_strEmailCalDistr, ch_strWebSite,\n             ch_strDefAreaCode, ch_strDefState, ch_strDefCountry,\n             ch_lPW_MinLen, ch_bPW_UpperLower, ch_bPW_Number,\n             ch_bUS_DateFormat, ch_lDefaultACO, ch_lTimeZone,\n             ch_vocZip, ch_vocState, ch_vocJobSkills,\n             aco_strFlag, aco_strCurrencySymbol, aco_strName,\n             ch_bRetired,\n\n             ch_lOrigID, ch_lLastUpdateID,\n             UNIX_TIMESTAMP(ch_dteOrigin) AS dteOrigin,\n             UNIX_TIMESTAMP(ch_dteLastUpdate) AS dteLastUpdate,\n\n             tz_strTimeZone,\n\n             usersC.us_strFirstName AS strCFName, usersC.us_strLastName AS strCLName,\n             usersL.us_strFirstName AS strLFName, usersL.us_strLastName AS strLLName,\n             UNIX_TIMESTAMP(ch_dteOrigin) AS dteOrigin,\n             UNIX_TIMESTAMP(ch_dteLastUpdate) AS dteLastUpdate\n\n          FROM admin_chapters\n            INNER JOIN admin_users AS usersC ON ch_lOrigID       = usersC.us_lKeyID\n            INNER JOIN admin_users AS usersL ON ch_lLastUpdateID = usersL.us_lKeyID\n            INNER JOIN admin_aco             ON ch_lDefaultACO   = aco_lKeyID\n            INNER JOIN lists_tz              ON ch_lTimeZone     = tz_lKeyID\n\n          WHERE ch_lKeyID={$this->lChapterID};";
     $query = $this->db->query($sqlStr);
     $numRows = $query->num_rows();
     if ($numRows == 0) {
         echo "<br><br>{$sqlStr}<br><br>";
         screamForHelp('EOF error on line ' . __LINE__ . ', file ' . __FILE__ . ', function ' . __FUNCTION__);
     } else {
         $row = $query->row();
         $this->chapterRec = new stdClass();
         $this->chapterRec->lKeyID = (int) $row->ch_lKeyID;
         $this->chapterRec->strChapterName = $row->ch_strChapterName;
         $this->chapterRec->strSafeChapterName = htmlspecialchars($row->ch_strChapterName);
         $this->chapterRec->strBannerTagLine = $row->ch_strBannerTagLine;
         $this->chapterRec->strAddress1 = $row->ch_strAddress1;
         $this->chapterRec->strAddress2 = $row->ch_strAddress2;
         $this->chapterRec->strCity = $row->ch_strCity;
         $this->chapterRec->strState = $row->ch_strState;
         $this->chapterRec->strCountry = $row->ch_strCountry;
         $this->chapterRec->strZip = $row->ch_strZip;
         $this->chapterRec->strAddress = strBuildAddress($this->chapterRec->strAddress1, $this->chapterRec->strAddress2, $this->chapterRec->strCity, $this->chapterRec->strState, $this->chapterRec->strCountry, $this->chapterRec->strZip, true);
         $this->chapterRec->strFax = $row->ch_strFax;
         $this->chapterRec->strPhone = $row->ch_strPhone;
         $this->chapterRec->strEmail = $row->ch_strEmail;
         $this->chapterRec->strEmailCalDistLists = $row->ch_strEmailCalDistr;
         $this->chapterRec->strWebSite = $row->ch_strWebSite;
         $this->chapterRec->lTimeZoneID = (int) $row->ch_lTimeZone;
         $this->chapterRec->strTimeZone = $row->tz_strTimeZone;
         $this->chapterRec->strDefAreaCode = $row->ch_strDefAreaCode;
         $this->chapterRec->strDefState = $row->ch_strDefState;
         $this->chapterRec->strDefCountry = $row->ch_strDefCountry;
         $this->chapterRec->bUS_DateFormat = (bool) $row->ch_bUS_DateFormat;
         $this->chapterRec->lDefaultACO = (int) $row->ch_lDefaultACO;
         $this->chapterRec->strFlag = $row->aco_strFlag;
         $this->chapterRec->strFlagImg = $clsACO->strFlagImage($row->aco_strFlag, $row->aco_strName);
         $this->chapterRec->strCurrencySymbol = $row->aco_strCurrencySymbol;
         $this->chapterRec->strCountryName = $row->aco_strName;
         $this->chapterRec->lPW_MinLen = $row->ch_lPW_MinLen;
         $this->chapterRec->bPW_UpperLower = (bool) $row->ch_bPW_UpperLower;
         $this->chapterRec->bPW_Number = (bool) $row->ch_bPW_Number;
         $this->chapterRec->bRetired = (bool) $row->ch_bRetired;
         $this->chapterRec->strStaffCFName = $row->strCFName;
         $this->chapterRec->strStaffCLName = $row->strCLName;
         $this->chapterRec->strStaffLFName = $row->strLFName;
         $this->chapterRec->strStaffLLName = $row->strLLName;
         $this->chapterRec->vocabulary = new stdClass();
         $this->chapterRec->vocabulary->vocZip = $row->ch_vocZip;
         $this->chapterRec->vocabulary->vocState = $row->ch_vocState;
         $this->chapterRec->vocabulary->vocJobSkills = $row->ch_vocJobSkills;
         $this->chapterRec->dteOrigin = $row->dteOrigin;
         $this->chapterRec->dteLastUpdate = $row->dteLastUpdate;
     }
 }
 private function strReportTitle(&$sRpt)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     global $genumDateFormat;
     $strOut = '';
     $strLIStyle = 'margin-left: 20pt; line-height:12pt;';
     switch ($sRpt->rptName) {
         case CENUM_REPORTNAME_GIFTTIMEFRAME:
             $strOut .= '<b>Donation Timeframe Report</b>
                     <ul style="list-style-type: square; display:inline; margin-left: 0; padding: 0pt;">';
             break;
         case CENUM_REPORTNAME_GIFTYEAREND:
             $strOut .= '<b>Donation Year-end Report</b>
                     <ul style="list-style-type: square; display:inline; margin-left: 0; padding: 0pt;">';
             break;
         case CENUM_REPORTNAME_GIFTACCOUNT:
             $cAcct = new maccts_camps();
             $cAcct->loadAccounts(true, true, $sRpt->acctIDs);
             $strOut .= '<b>Donation Account Report</b>
                     <ul style="list-style-type: square; display:inline; margin-left: 0; padding: 0pt;">
                        <li style="' . $strLIStyle . '"><b>Selected Accounts:</b>
                           <ul style="display:inline; margin-left: 0; padding: 0pt;">';
             foreach ($cAcct->accounts as $acct) {
                 $strOut .= '<li style="' . $strLIStyle . '">' . $acct->strSafeName . '</li>' . "\n";
             }
             $strOut .= '</ul></li>';
             break;
         case CENUM_REPORTNAME_GIFTCAMP:
             $cCamp = new maccts_camps();
             $cCamp->loadCampaigns(false, false, null, true, $sRpt->campIDs);
             $strOut = '<b>Donation Campaign Report</b>
                     <ul style="list-style-type: square; display:inline; margin-left: 0; padding: 0pt;">
                        <li style="' . $strLIStyle . '"><b>Selected Campaigns:</b>
                           <ul style="display:inline; margin-left: 0; padding: 0pt;">';
             foreach ($cCamp->campaigns as $camp) {
                 $strOut .= '<li style="' . $strLIStyle . '">' . $camp->strAcctSafeName . ': ' . $camp->strSafeName . '</li>' . "\n";
             }
             $strOut .= '</ul></li>';
             break;
         case CENUM_REPORTNAME_GIFTAGG:
             $strOut .= '<b>Donation Aggregate Report</b>
                     <ul style="list-style-type: square; display:inline; margin-left: 0; padding: 0pt;">';
             break;
         default:
             screamForHelp($sRpt->rptName . ': invalid report type<br>error on line <b> -- ' . __LINE__ . ' --</b>,<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
             break;
     }
     if (isset($sRpt->strDateRange)) {
         $strOut .= '<li style="' . $strLIStyle . '"><b>Date range:</b> ' . $sRpt->strDateRange . '</li>';
         /*
                  $strOut .= '<li style="'.$strLIStyle.'"><b>Date range:</b> '
                                   .date($genumDateFormat, $sRpt->dteStart).' - '
                                   .date($genumDateFormat, $sRpt->dteEnd).'
                              </li>';
         */
     }
     if (isset($sRpt->curMin)) {
         $strOut .= '<li style="' . $strLIStyle . ' "><b>Gift range:</b> ' . number_format($sRpt->curMin, 2) . ' - ' . number_format($sRpt->curMax, 2) . '
                  </li>' . "\n";
     }
     if (isset($sRpt->lACO)) {
         $strOut .= '<li style="' . $strLIStyle . ' "><b>Accounting Country:</b> ';
         if ($sRpt->lACO <= 0) {
             $strOut .= 'All countries</li>';
         } else {
             $cACO = new madmin_aco();
             $cACO->loadCountries(false, false, true, $sRpt->lACO);
             $strOut .= $cACO->countries[0]->strName . ' ' . $cACO->countries[0]->strFlagImg . '</li>';
         }
     }
     if (isset($sRpt->enumInc)) {
         $strOut .= '<li style="' . $strLIStyle . ' "><b>Included Donations: </b>';
         switch ($sRpt->enumInc) {
             case 'all':
                 $strOut .= 'All donations</li>' . "\n";
                 break;
             case 'gift':
                 $strOut .= 'Gifts only (no sponsorship payments)</li>' . "\n";
                 break;
             case 'spon':
                 $strOut .= 'Only sponsorship payments</li>' . "\n";
                 break;
             default:
                 screamForHelp($sRpt->enumInc . ': invalid include type<br>error on line <b> -- ' . __LINE__ . ' --</b>,<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
                 break;
         }
     }
     if (isset($sRpt->lYear)) {
         $strOut .= '<li style="' . $strLIStyle . ' "><b>Year: </b>' . $sRpt->lYear . '</li>' . "\n";
     }
     if (isset($sRpt->bAggregateDonor)) {
         $strOut .= '<li style="' . $strLIStyle . ' "><b>Grouping: </b>' . ($sRpt->bAggregateDonor ? 'By Donor' : 'Individual Donations') . '</li>' . "\n";
     }
     $strOut .= '</ul><br>' . "\n";
     return $strOut;
 }
function showCurrencyOpts($curDef, $lCurrencyACO)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    $clsACO = new madmin_aco();
    if (is_numeric($curDef)) {
        $strCur = number_format($curDef, 2);
    } else {
        $strCur = xss_clean(trim($curDef));
    }
    echoT('
         <tr>
           <td class="enpRptLabel">
              Default:
           </td>
           <td class="enpRpt">
              <input type="text" name="txtDefaultCur"
                  value="' . $strCur . '"
                  size="6">' . form_error('txtDefaultCur') . '
           </td>
        </tr>');
    echoT('
         <tr>
           <td class="enpRptLabel">
              Accounting Country:
           </td>
           <td class="enpRpt">' . $clsACO->strACO_Radios($lCurrencyACO, 'rdoACO') . form_error('rdoACO') . '
           </td>
        </tr>');
}
 function loadPeople($bIncludeSpon, $bIncludeGiftSum, $bPeople)
 {
     //------------------------------------------------------------------------------
     //
     //------------------------------------------------------------------------------
     $clsACO = new madmin_aco();
     $this->people = array();
     if ($bIncludeSpon) {
         $clsSpon = new msponsorship();
     }
     $sqlStr = "SELECT\n            pe_lKeyID,\n            pe_lHouseholdID,   pe_strTitle,      pe_strFName,\n            pe_strMName,       pe_strLName,      pe_strPreferredName,\n            pe_strSalutation,  pe_strAddr1,      pe_strAddr2,\n            pe_strCity,        pe_strState,      pe_strCountry,\n            pe_strZip,         pe_strPhone,      pe_strCell, pe_strEmail,\n            pe_enumGender,     pe_strNotes,      pe_bNoGiftAcknowledge,\n            pe_lAttributedTo,  pe_strImportID,\n            pe_lOriginID,      pe_lLastUpdateID,\n            tblAttrib.lgen_strListItem AS strAttrib,\n\n            pe_lACO, aco_strFlag, aco_strName, aco_strCurrencySymbol,\n\n            pe_dteBirthDate,\n            pe_dteDeathDate,\n            usersC.us_strFirstName AS strCFName, usersC.us_strLastName AS strCLName,\n            usersL.us_strFirstName AS strLFName, usersL.us_strLastName AS strLLName,\n            pe_dteExpire,\n            UNIX_TIMESTAMP(pe_dteOrigin)     AS dteOrigin,\n            UNIX_TIMESTAMP(pe_dteLastUpdate) AS dteLastUpdate\n         FROM people_names\n            INNER JOIN admin_users AS usersC ON pe_lOriginID    = usersC.us_lKeyID\n            INNER JOIN admin_users AS usersL ON pe_lLastUpdateID= usersL.us_lKeyID\n            INNER JOIN admin_aco             ON pe_lACO         = aco_lKeyID\n            {$this->sqlInnerExtra}\n            LEFT  JOIN lists_generic AS tblAttrib ON pe_lAttributedTo=tblAttrib.lgen_lKeyID\n\n         WHERE 1\n            {$this->sqlWhereExtra}\n            AND " . ($bPeople ? 'NOT ' : '') . "pe_bBiz\n            AND NOT pe_bRetired\n         {$this->sqlOrderExtra}\n         {$this->sqlLimitExtra};";
     $query = $this->db->query($sqlStr);
     $this->lNumPeople = $query->num_rows();
     if ($this->lNumPeople == 0) {
         $this->people[0] = new stdClass();
         $pRec =& $this->people[0];
         $pRec->lKeyID = $pRec->lHouseholdID = $pRec->bHOH = $pRec->strHouseholdName = $pRec->strTitle = $pRec->strFName = $pRec->strMName = $pRec->strLName = $pRec->strPreferredName = $pRec->strSafeName = $pRec->strSafeNameLF = null;
         $pRec->strSalutation = $pRec->strAddr1 = $pRec->strAddr2 = $pRec->strCity = $pRec->strState = $pRec->strCountry = $pRec->strZip = $pRec->strPhone = $pRec->strCell = $pRec->strAddress = null;
         $pRec->strEmail = $pRec->strEmailFormatted = $pRec->enumGender = $pRec->lACO = $pRec->strACO = $pRec->strCurSymbol = $pRec->strFlag = $pRec->strFlagImage = $pRec->bNoGiftAcknowledge = $pRec->lAttributedTo = $pRec->strAttrib = $pRec->lImportID = $pRec->strImportRecID = $pRec->dteExpire = $pRec->lOriginID = $pRec->lLastUpdateID = $pRec->dteMysqlBirthDate = $pRec->dteMysqlDeath = $pRec->dteOrigin = $pRec->dteLastUpdate = $pRec->strStaffCFName = $pRec->strStaffCLName = $pRec->strStaffLFName = $pRec->strStaffLLName = null;
     } else {
         $idx = 0;
         if ($bIncludeGiftSum) {
             $clsGifts = new mdonations();
             $clsGifts->bUseDateRange = false;
             $clsGifts->cumulativeOpts = new stdClass();
             $clsGifts->cumulativeOpts->enumCumulativeSource = 'people';
         }
         foreach ($query->result() as $row) {
             $this->people[$idx] = new stdClass();
             $pRec =& $this->people[$idx];
             $pRec->lKeyID = $lPID = $row->pe_lKeyID;
             $pRec->lHouseholdID = $lHID = $row->pe_lHouseholdID;
             $pRec->bHOH = $lHID == $lPID;
             $pRec->strHouseholdName = $this->strHouseholdNameViaHID($lHID);
             $pRec->strTitle = $strTitle = $row->pe_strTitle;
             $pRec->strFName = $strFName = $row->pe_strFName;
             $pRec->strMName = $strMName = $row->pe_strMName;
             $pRec->strLName = $strLName = $row->pe_strLName;
             $pRec->strPreferredName = $strPreferred = $row->pe_strPreferredName;
             $pRec->strSafeName = htmlspecialchars(strBuildName(false, $strTitle, $strPreferred, $strFName, $strLName, $strMName));
             $pRec->strSafeNameLF = htmlspecialchars(strBuildName(true, $strTitle, $strPreferred, $strFName, $strLName, $strMName));
             $pRec->strSalutation = $row->pe_strSalutation;
             $pRec->strAddr1 = $row->pe_strAddr1;
             $pRec->strAddr2 = $row->pe_strAddr2;
             $pRec->strCity = $row->pe_strCity;
             $pRec->strState = $row->pe_strState;
             $pRec->strCountry = $row->pe_strCountry;
             $pRec->strZip = $row->pe_strZip;
             $pRec->strPhone = $row->pe_strPhone;
             $pRec->strCell = $row->pe_strCell;
             $pRec->strAddress = strBuildAddress($pRec->strAddr1, $pRec->strAddr2, $pRec->strCity, $pRec->strState, $pRec->strCountry, $pRec->strZip, true);
             $pRec->strEmail = $row->pe_strEmail;
             $pRec->strEmailFormatted = strBuildEmailLink($pRec->strEmail, '', false, '');
             $pRec->enumGender = $row->pe_enumGender;
             $pRec->lACO = $row->pe_lACO;
             $pRec->strACO = $row->aco_strName;
             $pRec->strCurSymbol = $row->aco_strCurrencySymbol;
             $pRec->strFlag = $row->aco_strFlag;
             $pRec->strFlagImage = $clsACO->strFlagImage($pRec->strFlag, $pRec->strACO);
             $pRec->bNoGiftAcknowledge = $row->pe_bNoGiftAcknowledge;
             $pRec->lAttributedTo = $row->pe_lAttributedTo;
             $pRec->strAttrib = $row->strAttrib;
             $pRec->lImportID = $row->pe_strImportID;
             $pRec->strImportRecID = $row->pe_strImportID;
             $pRec->dteExpire = dteMySQLDate2Unix($row->pe_dteExpire);
             $pRec->lOriginID = $row->pe_lOriginID;
             $pRec->lLastUpdateID = $row->pe_lLastUpdateID;
             $pRec->dteMysqlBirthDate = $row->pe_dteBirthDate;
             $pRec->dteMysqlDeath = $row->pe_dteDeathDate;
             $pRec->strNotes = $row->pe_strNotes;
             $pRec->dteOrigin = $row->dteOrigin;
             $pRec->dteLastUpdate = $row->dteLastUpdate;
             $pRec->strStaffCFName = $row->strCFName;
             $pRec->strStaffCLName = $row->strCLName;
             $pRec->strStaffLFName = $row->strLFName;
             $pRec->strStaffLLName = $row->strLLName;
             //-------------------
             // sponsorship
             //-------------------
             if ($bIncludeSpon) {
                 $clsSpon->sponsorshipInfoViaPID($lPID);
                 $pRec->lNumSponsorship = $lNumSpons = $clsSpon->lNumSponsors;
                 if ($lNumSpons == 0) {
                     $pRec->sponInfo = null;
                 } else {
                     $pRec->sponInfo = $clsSpon->sponInfo;
                 }
             }
             //-------------------
             // cumulative gifts
             //-------------------
             if ($bIncludeGiftSum) {
                 $clsGifts->lPeopleID = $lPID;
                 $clsGifts->cumulativeOpts->enumMoneySet = 'all';
                 $clsGifts->cumulativeOpts->bSoft = false;
                 $clsGifts->cumulativeDonation($clsACO, $pRec->lTotHardGifts);
                 $pRec->lNumACODonationGroups_hard = $clsGifts->lNumCumulative;
                 $pRec->donationsViaACO_hard = $clsGifts->cumulative;
                 $clsGifts->cumulativeOpts->bSoft = true;
                 $clsGifts->cumulativeDonation($clsACO, $pRec->lTotSoftGifts);
                 $pRec->lNumACODonationGroups_soft = $clsGifts->lNumCumulative;
                 $pRec->donationsViaACO_soft = $clsGifts->cumulative;
             } else {
                 $pRec->lNumACODonationGroups_hard = $pRec->donationsViaACO_hard = $pRec->lNumACODonationGroups_soft = $pRec->donationsViaACO_soft = null;
             }
             ++$idx;
         }
     }
 }