public function viewDetailsRecords($in) { $wo = $this->wo; $tableName = $this->tableName; if (!WOOOF::hasContent($tableName)) { $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1000 No value for tableName"); return false; } $id = $wo->getFromArray($in, 'id'); $wo->debug("Generic.viewDetailsRecords for '{$tableName}' and Record [{$id}]"); $out = ''; $sql = "\n\t\t\tselect\n\t\t\ttmd.tableName, cmd.name, cmd.columnToStore\n\t\t\tfrom\n\t\t\t__columnMetaData cmd, __tableMetaData tmd\n\t\t\twhere\n\t\t\tcmd.valuesTable = '{$tableName}' and\n\t\t\ttmd.id = cmd.tableId\n\t\t"; $detailTables = $wo->db->query($sql); if ($detailTables === FALSE) { $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1080 Failed look for Detail Tables"); return false; } $out .= '<h3>Detail Records</h3>'; while (($aDetailTable = $wo->db->fetchAssoc($detailTables)) !== NULL) { $sql = "select count(*) from {$aDetailTable['tableName']} where {$aDetailTable['name']} = '{$id}'"; $aDetailsCount = $wo->db->query($sql); if ($aDetailsCount === FALSE) { $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1085 Failed look for Detail Count"); return false; } $detailsCount = $wo->db->fetchRow($aDetailsCount)[0]; $out .= '<h4>' . $aDetailTable['tableName'] . ' ' . $detailsCount . '</h4>'; if ($detailsCount > 0) { $detGen = new Generic($aDetailTable['tableName']); $detOutput = $detGen->listRows(array('_where' => "{$aDetailTable['name']} = '{$id}'")); if ($detOutput === FALSE) { return FALSE; } $out .= $detOutput['contentData']; $out .= '<br>'; } } // foreach detail Table return $out; }
//$__isSiteBuilderPage = true; require_once '../setup.inc.php'; $requestedAction = 'read'; $pageLocation = '1'; $browserTitle = 'Generic List'; $timers = array(); $wo = new WOOOF(); if (!$wo->constructedOk) { $wo->handleShowStopperError("1000 Failed to init WOOOF."); } $paramNames = array('_tableName', '_where', '_orderBy', '_fragmentsFile', '_cudFormURL'); $in = $wo->getMultipleGetPost($paramNames); //$in['where'] = "region='Greece'"; $tableName = $in['_tableName']; $table = new Generic($tableName, $wo); $tpl = $table->listRows($in); // if ( $tpl === FALSE ) { $wo->handleShowStopperError( print_r($errors,true) ); } if ($tpl === FALSE) { // $wo->handleShowStopperError( $error ); $tpl = array('browserTitle' => $browserTitle, 'content' => 'Sorry, smg went wrong', 'errorMessage' => nl2br($wo->getErrorsAsStringAndClear()), 'message' => '', 'contentTop' => ''); } else { if (!isset($tpl['browserTitle'])) { $tpl['browserTitle'] = $tableName . ' ' . $browserTitle; } } $showTables = $table->showTablesAs('links'); if ($showTables !== FALSE) { $tpl['contentTop'] .= $showTables . '<br><br>'; } $wo->fetchApplicationFragment('structural/generic_template.php'); // UNREACHEABLE: As generic_template.php exits at its end!