private function tmpTableSponPacket($strTableName)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $sqlDelete = "DROP TABLE IF EXISTS {$strTableName} ;";
     $this->db->query($sqlDelete);
     $sqlStr = "\n              CREATE TEMPORARY TABLE {$strTableName}(\n                 tmp_lKeyID     int(11) NOT NULL AUTO_INCREMENT,\n                 tmp_lSponID    int(11) NOT NULL DEFAULT '0',\n                 tmp_lContactID int(11) NOT NULL DEFAULT '0',\n                 tmp_lClientID  int(11) NOT NULL DEFAULT '0',\n                 tmp_bHonoree   tinyint(1) NOT NULL DEFAULT '0',\n                 tmp_lStatusID  int(11) DEFAULT NULL,\n              PRIMARY KEY        (tmp_lKeyID),\n              KEY tmp_lSponID    (tmp_lSponID),\n              KEY tmp_lContactID (tmp_lContactID),\n              KEY tmp_lStatusID  (tmp_lStatusID)\n            ) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
     $this->db->query($sqlStr);
     //------------------------------------------------------------
     // load all active sponsorships associated with clients
     //------------------------------------------------------------
     $sqlStr = "INSERT INTO {$strTableName}\n             (\n                tmp_lSponID,\n                tmp_lContactID,\n                tmp_lClientID,\n                tmp_bHonoree\n             )\n             SELECT\n                sp_lKeyID,\n                IFNULL(sp_lHonoreeID, sp_lForeignID) AS lContactID,\n                sp_lClientID,\n                 IF(sp_lHonoreeID IS NULL, 0, 1)\n             FROM sponsor\n             WHERE NOT sp_bInactive\n                AND NOT sp_bRetired\n                AND sp_lClientID IS NOT NULL\n                ORDER BY sp_lKeyID;";
     $this->db->query($sqlStr);
     //------------------------------------------------------------
     // link the packet status
     //------------------------------------------------------------
     $status = new mclient_status();
     $sqlStr = "SELECT tmp_lKeyID, tmp_lClientID FROM {$strTableName};";
     $query = $this->db->query($sqlStr);
     if ($query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $lTempID = $row->tmp_lKeyID;
             $lClientID = $row->tmp_lClientID;
             $packet = $status->packetStatusInfo($lClientID);
             if (is_null($packet)) {
                 $lStatID = 'null';
             } else {
                 $lStatID = $packet->statusID;
             }
             $this->addTmpStatusID($strTableName, $lTempID, $lStatID);
         }
     }
 }
 function strCViaStatCatIDReport(&$sRpt, $lStatCatID, $lStartRec, $lRecsPerPage)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $bActive = $sRpt->bActive;
     $cClient = new mclients();
     $cStatus = new mclient_status();
     $statCat = $cStatus->strStatCatViaCatID($lStatCatID);
     $strOut = '';
     $cClient->strClientLimit = " LIMIT {$lStartRec}, {$lRecsPerPage} ";
     $cClient->strExtraClientWhere = "  AND (cst_lClientStatusCatID = {$lStatCatID}) " . '  AND ' . ($bActive ? '' : 'NOT ') . ' cst_bShowInDir ';
     $cClient->loadClientsGeneric();
     if ($cClient->lNumClients == 0) {
         return '<i><br>There are no clients who meet your search criteria.</i>';
     } else {
         return $this->strBasicClientRpt($cClient, ($bActive ? 'Active ' : 'Inactive ') . 'Clients in status category "' . htmlspecialchars($statCat) . '"');
     }
 }