private function strGroupRptExport_Client(&$strGroupsReviewed, $bShowAny) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- global $genumDateFormat; $sqlStr = 'SELECT ' . strExportFields_Client() . ' FROM tmpGroupMatch INNER JOIN client_records ON cr_lKeyID = gm_lForeignID INNER JOIN client_location ON cr_lLocationID = cl_lKeyID INNER JOIN client_status_cats ON cr_lStatusCatID = csc_lKeyID INNER JOIN lists_client_vocab ON cr_lVocID = cv_lKeyID INNER JOIN client_status ON csh_lClientID = cr_lKeyID INNER JOIN lists_client_status_entries ON csh_lStatusID = cst_lKeyID LEFT JOIN lists_generic ON cr_lAttributedTo = lgen_lKeyID ORDER BY gm_lKeyID;'; $query = $this->db->query($sqlStr); $rptExport = $this->dbutil->csv_from_result($query); if ($this->config->item('dl_addExportRptInfo')) { $rptExport .= strPrepStr(CS_PROGNAME . " export\n" . 'Created ' . date($genumDateFormat . ' H:i:s e') . "\n" . 'Clients who are in ' . ($bShowAny ? 'any' : 'all') . ' of these groups: ' . $strGroupsReviewed, null, '"'); } return $rptExport; }
public function strExportClients() { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $strDateFormat = strMysqlDateFormat(false); $strDateTimeFormat = strMysqlDateFormat(true); $sqlStr = 'SELECT ' . strExportFields_Client() . "\n FROM client_records\n INNER JOIN client_location ON cr_lLocationID = cl_lKeyID\n INNER JOIN client_status_cats ON cr_lStatusCatID = csc_lKeyID\n INNER JOIN lists_client_vocab ON cr_lVocID = cv_lKeyID\n INNER JOIN client_status ON csh_lClientID = cr_lKeyID\n INNER JOIN lists_client_status_entries ON csh_lStatusID = cst_lKeyID\n LEFT JOIN lists_generic ON cr_lAttributedTo = lgen_lKeyID\n\n -- INNER JOIN client_status_cats ON cst_lClientStatusCatID = curStatSCat.csc_lKeyID\n -- INNER JOIN client_status_cats AS defSCat ON cr_lStatusCatID = defSCat.csc_lKeyID\n\n WHERE NOT cr_bRetired\n {$this->strClientWhere}\n -- ---------------------------------------\n -- subquery to find most current status\n -- ---------------------------------------\n AND csh_lKeyID=(SELECT csh_lKeyID\n FROM client_status\n WHERE csh_lClientID=cr_lKeyID\n AND NOT csh_bRetired\n ORDER BY csh_dteStatusDate DESC, csh_lKeyID DESC\n LIMIT 0,1)\n\n\n ORDER BY cr_lKeyID;"; $query = $this->db->query($sqlStr); return $this->dbutil->csv_from_result($query); }
function strCViaStatCatIDExport(&$sRpt, $lStatCatID) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $strLocWhere = " AND (cst_lClientStatusCatID = {$lStatCatID}) "; sqlQualClientViaStatus($sqlWhereSubquery, $strInner, true, true, false, false); $sqlStr = 'SELECT ' . strExportFields_Client() . "\n FROM client_records\n INNER JOIN client_location ON cr_lLocationID = cl_lKeyID\n INNER JOIN client_status_cats ON cr_lStatusCatID = csc_lKeyID\n INNER JOIN lists_client_vocab ON cr_lVocID = cv_lKeyID\n \n {$strInner}\n \n LEFT JOIN lists_generic ON cr_lAttributedTo = lgen_lKeyID\n WHERE 1\n AND NOT cr_bRetired\n\n {$sqlWhereSubquery}\n {$strLocWhere} ;"; /* $zzzlPos = strrpos(__FILE__, '\\'); $zzzlLen=strlen(__FILE__); $zzzstrFile=substr(__FILE__, strrpos(__FILE__, '\\',-(($zzzlLen-$zzzlPos)+1))); echoT('<font class="debug">'.$zzzstrFile.' Line: <b>'.__LINE__.":</b><br><b>\$sqlStr=</b><br>".nl2br(htmlspecialchars($sqlStr))."<br><br></font>\n"); //die; */ $query = $this->db->query($sqlStr); return $this->dbutil->csv_from_result($query); }