Company Detail
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n\n\n";
echo $form;
//used tables
$tablecomp = "company";
$tablesic = "SICCode";
$tablecompsiclink = "companysiclink";
$tableclass = "otClassification";
$tablecompclasslink = "companyclasslink";
$tablereport = "report";
$tablegrp = "companygrp";
$tablecompgrplink = "companygrplink";
$tablehistoric = "historic";
$SQL = "SELECT $tablecomp.companyID, $tablecomp.name, $tablecomp.note, $tablecomp.incorporated, $tablecomp.defunct, $tablecomp.URL, $tablecomp.SEDAR FROM $tablecomp WHERE (companyID LIKE '$ID')";
$QUERY = db_query(array($dbname, $SQL, $conn));
$row = db_fetch_row(array($QUERY));
//echo "$SQL
";
echo "
";
$fmt = "\$str1: \$str2 ";
displayfield("Company Name",$row[name],$fmt);
displayfield("Note",$row[note],$fmt);
if($row[incorporated] !="" && $row[incorporated] !="0")
{
displayfield("Incorporated",$row[incorporated],$fmt);
}
if($row[defunct] !="" && $row[defunct] !="0")
{
displayfield("Defunct",$row[defunct],$fmt);
}
$urlfmt = str_replace('$str2','$str2 ',$fmt);
displayfield("URL",$row[URL],$urlfmt);
$sedarfmt = str_replace('$str2','Current reports for this company are available in SEDAR',$fmt);
if($row[SEDAR] != '0')
{
displayfield("SEDAR",$row[SEDAR],$sedarfmt);
}
/*************************************************HISTORIC ENTRIES*****************************************************************/
//show historic entries
$historydisplay = false;
//preceded by
$HSQL = "SELECT historyID,predecessorID,linktext,date from $tablehistoric where (successorID = '$ID')";
$HQUERY = db_query(array($dbname,$HSQL,$conn));
$HREC = db_num_rows(array($HQUERY));
if($HREC > 0)
{
echo "Historic Entries: ";
$historydisplay = true;
while($HROW = db_fetch_row(array($HQUERY)))
{
$sql = "select name from $tablecomp where (companyID = '$HROW[predecessorID]')";
$q = db_query(array($dbname,$sql,$conn));
$rowpredecessor = db_fetch_row(array($q));
$rec = db_num_rows(array($q));
if($rec > 0)
{
echo "Preceded by: ";
echo "$rowpredecessor[name] $HROW[linktext] $row[name]";
if($HROW[date] !="" && $HROW[date] !="0") { echo ", $HROW[date] "; }
}
echo " ";
}
}
unset($rec);
//succeeded by
$SSQL = "SELECT historyID,successorID,linktext,date from $tablehistoric where (predecessorID = '$ID')";
$SQUERY = db_query(array($dbname,$SSQL,$conn));
$SREC = db_num_rows(array($SQUERY));
if($SREC > 0)
{
if($historydisplay != true)
{
echo "Historic Entries: ";
$historydisplay = true;
}
while($SROW = db_fetch_row(array($SQUERY)))
{
$sql = "select name from $tablecomp where (companyID = '$SROW[successorID]')";
$q = db_query(array($dbname,$sql,$conn));
$rowsuccessor = db_fetch_row(array($q));
$rec = db_num_rows(array($q));
if($rec > 0)
{
echo "Succeeded by: ";
echo "$row[name] $SROW[linktext] $rowsuccessor[name]";
if($SROW[date] !="" && $SROW[date] !="0") { echo ", $SROW[date] "; }
}
echo " ";
}
}
if($historydisplay != false)
{
echo "
";
}
unset($rec);
/**********************************************************SICCODE ENTRIES******************************************************/
$sicsql = "SELECT $tablesic.sicID, sicDesc, sicCode FROM $tablecompsiclink left join $tablesic using(sicID) where ($tablecompsiclink.companyID = '$ID')";
$sicq = db_query(array($dbname,$sicsql,$conn));
$rec = db_num_rows(array($sicq));
if($rec > 0)
{
echo "SIC Codes and Descriptions: ";
while($sicrow = db_fetch_row(array($sicq)))
{
echo "$sicrow[sicCode] $sicrow[sicDesc] ";
}
echo " ";
}
unset($rec);
/**********************************************************Other Classification***************************************************/
$classsql = "SELECT $tableclass.classID, description FROM $tablecompclasslink left join $tableclass using(classID) where ($tablecompclasslink.companyID = '$ID')";
$classq = db_query(array($dbname,$classsql,$conn));
$rec = db_num_rows(array($classq));
if($rec > 0)
{
echo "Other Classification: ";
while($classrow = db_fetch_row(array($classq)))
{
echo "$classrow[description]";
}
echo " ";
}
unset($rec);
/**********************************************************Reports****************************************************************/ //report
$rptsql = "SELECT reportID, startYear, endYear, filename, filesize FROM $tablereport where ($tablereport.companyID = '$ID') order by startYear";
$rptq = db_query(array($dbname,$rptsql,$conn));
$rec = mysql_num_rows($rptq);
$rowcount = 1;
echo "Holding(s): ";
if($rec > 0)
{
$samestartyear;
$sameendyear;
$char = 98; //the letter b
echo "";
while($rptrow = mysql_fetch_array($rptq))
{
if($rptrow[startYear] == $rptrow[endYear])
{
if($rptrow[filename] == "")
{
if ($rptrow[startYear] != $samestartyear)
{
echo "$rptrow[startYear] ";
$char = 98;
}
else
{
echo $rptrow[startYear].chr($char);
$char++;
}
}
else
{
if ($rptrow[startYear] != $samestartyear)
{
echo "$rptrow[startYear] ($rptrow[filesize]) ";
$char = 98;
}
else
{
echo "".$rptrow[startYear].chr($char)." ($rptrow[filesize]) ";
$char++;
}
}
}
else
{
if ($rptrow[filename] == "")
{
if ($rptrow[startYear] != $samestartyear || $rptrow[endYear] != $sameendyear)
{
echo "$rptrow[startYear]/$rptrow[endYear] ";
$char = 98;
}
else
{
echo "$rptrow[startYear]/$rptrow[endYear]".chr($char)." ";
$char++;
}
}
else
{
if ($rptrow[startYear] != $samestartyear || $rptrow[endYear] != $sameendyear)
{
echo "$rptrow[startYear]/$rptrow[endYear] ($rptrow[filesize]) ";
$char = 98;
}
else
{
echo "$rptrow[startYear]/$rptrow[endYear]".chr($char)." ($rptrow[filesize]) ";
$char++;
}
}
}
if($rowcount % 4 == 0)
{
echo " ";
}
$rowcount++;
$samestartyear = $rptrow[startYear];
$sameendyear = $rptrow[endYear];
}
echo "
";
}
else
{
echo "No holdings information available";
}
/**********************************************************Group*****************************************************************/
//group
$grpsql = "SELECT $tablegrp.grpID, grpname FROM $tablecompgrplink left join $tablegrp using (grpID) where ($tablecompgrplink.companyID = '$ID') order by $tablegrp.grpname";
$grpq = db_query(array($dbname,$grpsql,$conn));
$rec = db_num_rows(array($grpq));
if($rec > 0)
{
echo "See Also: ";
while($grprow = db_fetch_row(array($grpq)))
{
//list- name of other companies in the same group
$compsql = "SELECT $tablecomp.name,$tablecomp.companyID FROM $tablecomp left join $tablecompgrplink using (companyID) WHERE ($tablecompgrplink.grpID = '$grprow[grpID]') AND ($tablecompgrplink.companyID NOT LIKE '$ID')";
$qcomp = db_query(array($dbname,$compsql,$conn));
$num_rows = db_num_rows(array($qcomp));
if($num_rows > 0 )
{
while($rcomp = db_fetch_row(array($qcomp)))
{ echo "$rcomp[name] "; }//inner while
}//if $num_rows
}//outer while
echo " ";
}
unset($rec);
echo"Return to Results New Search ";
?>