File: /home/mckernan/public_html/iJournal/includes/client/rptinfo.php
<?php
// client information report
$types = array(0 => 'Phone', 1 => 'FAX', 2 => 'Email', 3 => 'Website');
// init database name
$database = DB_PREFIX;
$leftmarg = 50;
$orgtype = array(0 => 'Sole Proprietorship', 1 => 'Partnership', 2 => "C Corp", 3 => "S Corp", 4 => "LLC / LLP");
$fye = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April',
5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
$freq = array(0 => 'Monthly', 1 => 'Quarterly', 2 => 'Semi-Annually', 3 => 'Annually', 4 => 'Periodic');
// process request
if ($sid != '')
{
// sid check
require "includes/session/sidck.php";
// fetch database name / open db
$dbn = '';
if ( isset($_POST['db']) ) $dbn = $_POST['db'];
if ( isset($_GET['db']) ) $dbn = $_GET['db'];
if ($dbn == '') die();
$database .= $dbn;
require "includes/db.php";
// fetch client info
$client = '';
$query = "SELECT * FROM client";
if ($result = $db->query($query))
{
$row = $result->fetch_assoc();
$client = $row['cli_sortname'];
$mailaddress = $row['cli_mailname1'] . "\n";
if ($row['cli_mailname2'] != '') $mailaddress .= $row['cli_mailname2'] . "\n";
$mailaddress .= $row['cli_str1'] . "\n";
if ($row['cli_str2'] != '') $mailaddress .= $row['cli_str2'] . "\n";
$mailaddress .= $row['cli_city'] . " " . $row['cli_state'] . " " . $row['cli_zipc'];
$status = ($row['cli_active'] == 1) ? 'Active' : 'Inactive';
}
// fetch contacts
$data = array();
$query = "SELECT * FROM contacts WHERE c_active = 1 ORDER BY c_descrip ASC, c_type ASC";
if ($result = $db->query($query))
{
while ($row2 = $result->fetch_assoc())
{
if ($row2['c_type'] < 2)
{
$details = substr($row2['c_details'], 0, 3) . '-' . substr($row2['c_details'], 3, 3) . '-' . substr($row2['c_details'], 6, 4);
if (strlen($row2['c_details']) > 10)
{
$details .= ' x ' . substr($row2['c_details'], 10);
}
}
else
{
$details = $row2['c_details'];
}
$data[] = array(
'type' => $types[$row2['c_type']],
'descr' => $row2['c_descrip'],
'details' => $details,
'comments' => $row2['c_comments']
);
}
}
// report
require "ClientInfoReportClass.php";
$pdf = new PDF($client);
$pdf->AliasNbPages();
$pdf->SetDrawColor(150, 150, 150);
$pdf->SetFillColor(242, 242, 242);
$pdf->SetFont('Arial', '', '9');
$pdf->AddPage();
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Sort Name:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->Cell(100, 5, $client, 0, 1, "L");
$pdf->Ln(3);
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Client:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->MultiCell(100, 4, $mailaddress, 0, "L");
$pdf->Ln(3);
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Salutation:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->Cell(100, 5, $row['cli_salute'], 0, 1, "L");
$pdf->Ln(3);
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Organization:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->Cell(100, 5, $orgtype[$row['cli_type']], 0, 1, "L");
$pdf->Ln(3);
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Fiscal Year Ends:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->Cell(100, 5, $fye[$row['cli_fye']], 0, 1, "L");
$pdf->Ln(3);
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Frequency:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->Cell(100, 5, $freq[$row['cli_freq']], 0, 1, "L");
$pdf->Ln(3);
$pdf->SetX($leftmarg);
$pdf->SetFont('Arial', '', '7');
$pdf->Cell(40, 5, 'Status:', 0, 0, "R");
$pdf->SetFont('Arial', 'B', '9');
$pdf->Cell(100, 5, $status, 0, 1, "L");
if(sizeof($data) > 0)
{
$pdf->Ln(12);
$pdf->SetX(20);
$pdf->SetFont('Arial', 'B', '8');
$pdf->SetDrawColor(255, 255, 255);
$pdf->SetFillColor(0, 0, 0);
$pdf->SetTextColor(255, 255, 255);
$pdf->Cell(55, 5, 'Contact', 1, 0, "C", true);
$pdf->Cell(20, 5, 'Type', 1, 0, "C", true);
$pdf->Cell(60, 5, 'Details', 1, 0, "C", true);
$pdf->Cell(50, 5, 'Comments', 1, 1, "C", true);
$pdf->SetFont('Arial', '', '9');
$pdf->SetDrawColor(150, 150, 150);
$pdf->SetFillColor(242, 242, 242);
$pdf->SetTextColor(0, 0, 0);
$fill = false;
foreach($data as $c)
{
$pdf->SetX(20);
$pdf->Cell(55, 6, $c['descr'], 1, 0, "L", $fill);
$pdf->Cell(20, 6, $c['type'], 1, 0, "L", $fill);
$pdf->Cell(60, 6, $c['details'], 1, 0, "L", $fill);
$pdf->Cell(50, 6, $c['comments'], 1, 1, "L", $fill);
$fill = !$fill;
}
}
$pdf->Output();
}
?>