0

I would like to make a an invoice for bus agencies with their logo in the top left, their address in top right. then in the middle their info name,surname,destinatin,cost.. etc. then in the bottom maybe some more info.. It is going to take a lot of time to build this but I thought maybe there is somewhere an already made script for this so I need your help if anyone knows then I am going to spare a lot of time.

Thank you for your time and help.

TooCooL
  • 20,356
  • 6
  • 30
  • 49
  • http://net.tutsplus.com/tutorials/other/how-to-generate-pdfs-with-php-new-plus-tutorial/ 9 bucks but is the most comprehensive tutorial around. – Mike Soule May 14 '11 at 18:41
  • http://stackoverflow.com/questions/124959/create-word-document-using-php-in-linux/132054#132054 Then, instead of odt -> doc, you run odt -> pdf conversion via the OpenOffice command line interface – Ivan Krechetov May 14 '11 at 18:45

1 Answers1

0

I did something similar using the FILE_PDF PHP library. It takes POST data in the form of dates[] or hours[] and fills in a table with it.Here's some of my code, it's not perfect but it might give you a start

$tasks = array("dates","descriptions","hours","minutes");

foreach($tasks as $name)
{
    $$name = explode("\n",$_POST[$name]);
}
for ($i=0;$i<count($descriptions);$i++)
{
     $data[]=array("dates"=>$dates[$i],"descriptions"=>$descriptions[$i],"hours"=>$hours[$i],"minutes"=>$minutes[$i]);
}


$p = &File_PDF::factory('P','mm','A4');

$p->open();

$p->setMargins(25, 25);
$p->addPage('P');

$p->setFont('arial', '', 24);
$p->cell(0, 9, "Invoice", 0, 1, 'C');

$p->setFont('arial', '', 14);
$p->write(6,date("F j, Y"));
$p->newLine();

$p->write(6,"Invoice #DIM-09-10-001");
$p->newLine();

$p->write(6,"Invoice for X");

$p->newLine();
$p->newLine();
$p->setFont('arial', '', 12);

$p->write(10, 'Work performed @ hourly rate of $20.00');
$p->newLine();
$p->newLine();

$widths = array(23,90,15,25);

$header = array("Date","Task","","Time");
foreach($header as $num=>$col)
        $p->Cell($widths[$num],7,$col,"B");
$p->newLine();
foreach($data as $row)
{
    $i=0;
    foreach($row as $name=>$col)
    {
        $p->Cell($widths[$i],10,$col,0);
        $i++;
    }
    $p->newLine();
}

$table_footer = array(array("","Total Time",'8 hours @ $20/hour'),array("","Total Fees Due",'$160'));
$widths = array(80,35,40);
$borders = array(array(0,"T","T"));

foreach($table_footer as $rownum=>$row)
{
    foreach($row as $num=>$col)
        $p->Cell($widths[$num],10,$col,$borders[$rownum][$num]);
    $p->newLine();
}

$p->write(10,"Please make check payable to ");
$p->setFontStyle("B");
$p->write(10,"David Mihal");

$p->newLine();
$p->newLine();

$p->setFontStyle("I");
$p->write(4,"All invoices are due and payable within 30 days. Thank you for your prompt attention to this invoice and for your continued business.");
$p->close();

$p->output('invoice.pdf',true);
David Mihal
  • 944
  • 6
  • 23