Hey here's the part of the script I'm running now. It is the part that creates the file. When I manually attach the file through my mail account (gmail) and send it and download it into a windows machine it appears as a .dat file. However when opened with adobe reader 9.1 (or whatever the current version is) it looks exactly the same. So the mail aspect of the script hasn't even been utilized yet in relation to the problem.
the script:
<?php
//THIS WORKS!
require_once('../config/lang/eng.php');
require_once('../tcpdf.php');
require_once 'MDB2.php';
$db = MDB2::connect('mysql://root:');
if (MDB2::isError($db)) { die("Can't connect: " . $db->getMessage()); }
$id = 1;
$firstLastNames = $db->query("SELECT First_Name,Last_Name,Email_Address FROM ShareholderNames WHERE ShareholderID = $id");
$nameArray = $firstLastNames->fetchAll();
$first = $nameArray[0][0];$last = $nameArray[0][1];$email = $nameArray[0][2];
$to = '';
class MYPDF extends TCPDF {
public function Header() {
$this->SetFont('helvetica', '', 8);
$image_file = '.jpg';
$this->Image($image_file,'','','','','JPG', '', 'T', false, 300, 'L', false, false, 0, false, false, false);
$this->Multicell(0,6,'October 11th, 2010',0,'R',0,1,'','',true);
}
public function Footer() {
$this->SetY(-15);
$this->SetFont('helvetica', 'I', 8);
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->setLanguageArray($l);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage('L', 'A4');
$pdf->SetFont('helvetica', '', 8);
$pdf->writeHTMLCell($w=60, $h=12, $x='', $y='22','', $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$pdf->writeHTMLCell($w=35, $h=10, $x='', $y='29','PH: 850-914-0002', $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$first = '';
$last = '';
$name = $last.', '.$first;
$id = '1';
$shareholderID = 'Shareholder ID: '.$id;
$detailedReport = 'Detailed Report';
$summaryReport = 'Summary Report';
$testLine = 'Test';
$pdf->SetFillColor(255);
$pdf->SetFont('helvetica', 'B', 10, '', true);
$pdf->Multicell(0,6,"\n",0,'L',0,1,'','',true);
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='35',$name, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $shareholderID, $border=0, $ln=1, $fill = 0, $resth=true, $align='', $autopadding=true);
$pdf->Multicell(30,0,"\n".$detailedReport,0,'L',0,1,'','',true);
$pdf->SetFont('helvetica', '', 10, '', true);
$pdf->Multicell(30,12, 'Selling Certificate',1,'C',0,0,'','', true);
$pdf->Multicell(30,12, 'Buying Certificate',1,'C',1,0,'','', true);
$pdf->Multicell(32,12, 'Seller',1,'C',1,0,'','', true);
$pdf->Multicell(32,12, 'Buyer',1,'C',1,0,'','', true);
$pdf->Multicell(27,12, 'Share Price',1,'L',1,0,'','', true);
$pdf->Multicell(35,12, 'Number of Shares',1,'L',1,0,'','', true);
$pdf->Multicell(30,12, 'Transaction Date',1,'L',1,0,'','', true);
$pdf->Multicell(52,12, 'Transaction Notes',1,'L',1,1,'','', true);
$currentPrice = $db->queryOne("SELECT Share_Price FROM TransactionHistory ORDER BY Transaction_Date DESC LIMIT 1");//check
$uberPull = $db->query("SELECT TransactionID, Source_Shareholder, Destination_Shareholder, Source_Certificate, Destination_Certificate,Transaction_Date,Share_Price, Number_Of_Shares,Transaction_Notes FROM TransactionHistory WHERE Destination_Shareholder = $id OR Source_Shareholder = $id ORDER BY TransactionID");
$uberArray = $uberPull->fetchAll();$numberofUber = count($uberArray);
$nameArray[0]['Total Shares'] = 0;$totalShares = $nameArray[0]['Total Shares'];
$uberCounter1 = 0;$summaryArrayCounter = 0;$detailedArrayCounter = 0;$uberCounter2 = 0;
while($uberCounter2 < $numberofUber)
{
$detSourceHolder = $uberArray[$uberCounter2][1];$detDestHolder = $uberArray[$uberCounter2][2];$detSourceCert = $uberArray[$uberCounter2][3];$detDestCert = $uberArray[$uberCounter2][4];$detTransDate = $uberArray[$uberCounter2][5];$detSharePrice = $uberArray[$uberCounter2][6];$detNumOfShares = $uberArray[$uberCounter2][7]; $detTransPrice = $detSharePrice * $detNumOfShares;$detTransNotes = $uberArray[$uberCounter2][8];
$detTransPrice = number_format($detTransPrice,2);$detSharePrice = number_format($detSharePrice,2);$detNumOfShares = number_format($detNumOfShares);
if($detSourceHolder == 0){$detSourceHolder = 'Treasury';}
if($detSourceCert == 0){$detSourceCert = 'Treasury Cert';}
if($detDestHolder == 0){$detDestHolder = 'Treasury';}
if($detDestCert == 0){$detDestCert = 'Treasury Cert';}
if($detDestHolder == $id){$detDestHolder = $last.', '.$first;}
if($detSourceHolder == $id){$detSourceHolder = $last.', '.$first;}
if($detSourceHolder == 99999){$detSourceHolder = 'Unissued';}
if($detDestHolder == 4){$detDestHolder = 'Rushe, Randall';}
$pdf->Multicell(30,12, $detSourceCert,1,'C',1,0,'','', true);
$pdf->Multicell(30,12, $detDestCert,1,'C',1,0,'','', true);
$pdf->Multicell(32,12, $detSourceHolder,1,'C',1,0,'','', true);
$pdf->Multicell(32,12, $detDestHolder,1,'C',1,0,'','', true);
$pdf->Multicell(27,12, $detSharePrice,1,'R',1,0,'','', true);
$pdf->Multicell(35,12, $detNumOfShares,1,'R',1,0,'','', true);
$pdf->Multicell(30,12, $detTransDate,1,'C',1,0,'','', true);
$pdf->Multicell(52,12, $detTransNotes,1,'L',1,1,'','', true);
$uberCounter2++;
}
$pdf->SetFont('helvetica', 'B', 10, '', true);
$pdf->Multicell(40,0,"\n".$summaryReport."\n",0,'L',1,1,'','',true);
$pdf->SetFont('helvetica', '', 10, '', true);
$pdf->Multicell(30,12,'Active Certificates',1,'L',1,0,'','',true);
$pdf->Multicell(30,12,'Number of Shares',1,'L',1,0,'','',true);
$pdf->Multicell(30,12,'Current Value',1,'L',1,0,'','',true);
$pdf->Multicell(30,12,'Current Price',1,'L',1,1,'','',true);
while($uberCounter1 < $numberofUber)
{//this is for summary
//looping through each transactionID
$destCert = $uberArray[$uberCounter1][4];$destHolder = $uberArray[$uberCounter1][2];$numOfShares = $uberArray[$uberCounter1][7];
$sharePrice = $uberArray[$uberCounter1][6];$transDate = $uberArray[$uberCounter1][5];//this works...
if($destHolder == $id)//so wont do treasury or whatever else.
{
$innerUber = 0;
while($innerUber < $numberofUber)
{
$innerSource = $uberArray[$innerUber][3];
if($destCert == $innerSource)//need to fix for treasury.
{
//not active cert
break;
}
$summaryFinalTest = $innerUber + 1;
if(($destCert != $innerSource) && ($summaryFinalTest == $numberofUber) && ($destCert != 685) && ($destCert != 686))//first half checks to see if last entry;
{
//active cert
$summaryArray[$summaryArrayCounter]['Share_Price'] = $sharePrice;//purchase price I believe
$summaryArray[$summaryArrayCounter]['CertID'] = $destCert;
$summaryArray[$summaryArrayCounter]['NumOfShares'] = $numOfShares;
$summaryArrayCounter++;
}
$innerUber++;
}
}
$uberCounter1++;
}
$numberofSummary = count($summaryArray);$loopCounter = 0;
while($loopCounter < $numberofSummary)
{
$summaryOutstandingShares += $summaryArray[$loopCounter]['NumOfShares'];
if(($numberofSummary - 1) == $loopCounter)
{
$summaryTotalValue = $summaryOutstandingShares * $currentPrice;
}
$loopCounter++;
}
$loopCounter = 0;$summaryTotalValue = number_format($summaryTotalValue,2);$summaryOutstandingShares = number_format($summaryOutstandingShares);
while($loopCounter < $numberofSummary)
{
$activeCert = $summaryArray[$loopCounter]['CertID'];$activeShares = $summaryArray[$loopCounter]['NumOfShares'];
$activeValue = $currentPrice * $activeShares;$activeValue = number_format($activeValue,2);
$pdf->Multicell(30,12,$activeCert,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,$activeShares,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,'$'.$activeValue,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,'$'.$currentPrice,0,'L',1,1,'','',true);
$loopCounter++;
}
$pdf->Multicell(30,12,"\n",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"",0,'L',1,1,'','',true);
$pdf->Multicell(30,12,"\n",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"Total Shares",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"Total Value",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"",0,'L',1,1,'','',true);
$pdf->Multicell(30,12,"",0,'L',1,0,'','',true);
$pdf->Multicell(30,12,$summaryOutstandingShares,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,'$'.$summaryTotalValue,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,"",0,'L',1,1,'','',true);
$statement = <<< test
test;
$pdf->Multicell(0,0,"\n".$statement,0,'L',1,0,'','',true);
//$pdf->SetProtection($permissions=array('print', 'copy'), $user_pass=, $owner_pass=null, $mode=0, $pubkeys=null);
$pdf->Output('Buddy Test', 'F');
I was hoping it was just some setting I could configure inside the php.ini file on my linux box. Although I've gained a lot of knowledge since finding phpbuilder I'm still quite the newb 🙂 . I was hoping it'd be something super simple. As always, your help is greatly appreciated!
-slight