/* searchCombined.php - 07/18/12 - D:\svn\html\PubApps\ - Set up and search tool for combined program and organization search Summary: Notes: see /pubApps/programServiceListing.php as model (used for servedc, brevard and LAMP) CREATE TABLE `platform`.`ProgMasterNpc` ( `ID` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY , `OrgID` INT NULL DEFAULT NULL , `EIN` VARCHAR( 9 ) NULL , `NPC` VARCHAR( 9 ) NOT NULL , `NTEE` VARCHAR( 9 ) NOT NULL , INDEX ( `OrgID`), INDEX (EIN), INDEX (NPC), INDEX (NTEE) ) ENGINE = MYISAM ; select code, name, ntee from lookup.npc2004a order by code; select topic, notes from nccs_links.topics where platform='newmexico' */ /***********************************************************/ session_start(); require_once('Bootstrap.php'); $bootstrap = Bootstrap::create(); $smallBanner = 0; include($bootstrap->libraryDirectory.'settings.php'); include($bootstrap->libraryDirectory.'head.php'); require($bootstrap->libraryDirectory.'proclib.php'); include($bootstrap->libraryDirectory.'datacon.php'); include($bootstrap->libraryDirectory.'nteecc-config.php'); include($bootstrap->libraryDirectory.'htmLawed.php'); $whereGeo = "zip = '20001'"; $whereActivity "between 'I' and 'P'"; $whereNpc = "a.npcNoPunc ".$whereActivity; $whereNtee = "nteeFinal ".$whereActivity; // select programs: // select orgs without programs // select programs or dummy program $qOrgs = " select a.ein, a.name, a.address, a.city from nccs.nteedocAllEins a where $whereGeo and $whereNtee "; // get programs: $qProgs = " select a.ein, substr(if(a.name, a.name, a.prgDesc),1,80) as Program, npcNoPunc, a.orgName, l.address, l.city FROM platform.ProgMaster a INNER JOIN platform.location l ON a.ID = l.ProgID where a.isactive = 1 and a.isApproved = 1 and a.isDeleted = 0 and l.$whereGeo and $whereNpc "; // check npc-ntee crosswalk = loadNpcJoin(1,1000); /***********************************************************/ function loadNpcJoin($start, $end){ $q = "select id, npcNoPunc from platform.ProgMaster LIMIT $start, $end"; $r = runSql($q,1); foreach ($r as $s){ $id = $s[0]; echo $id.' - '.$s[1].'
'; $aNpc = explode(',', $s[1]); foreach ($aNpc as $npc){ $ntee = get1value("select code, ntee, name FROM lookup.npc2004a where code = '$npc'"); $q2 = "insert into platform.ProgMasterNpc (id, npc, ntee) values ($id, '$npc', '$ntee')"; runSql($q2); } } }