Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: pdf invoice date

  1. #1
    Join Date
    Feb 2007
    Posts
    378

    Default pdf invoice date

    I'm trying to add the invoice creation date to my pdf invoice using:

    Code:
    $pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'L','1');
    I see the text but it doesn't input the creation date so i have:

    Invoice Date:

    Any advice greatly appreciated - as ever it will be something stupid that I am doing!

    Ad

  2. #2
    Join Date
    Mar 2007
    Posts
    15

    Default

    Heya.
    I have made it so:
    includes/pdfconfig.php
    after <?php
    add:
    Code:
    $a1=mysql_query("SELECT SQL_CACHE date FROM tblinvoices WHERE id='".$invoiceid."' LIMIT 1") or die(mysql_error());
    $a=mysql_fetch_array($a1);
    $ajakesekene=explode('-', $a['date']);
    $ajake=$ajakesekene[2].'/'.$ajakesekene[1].'/'.$ajakesekene[0];
    Then add this next lines where you want show your creating date:
    Code:
    $pdf->SetFont('Arial','',10);
    $pdf->Cell(0,6,$_LANG["invoicesdatecreated"].':   '.$ajake,0,1,'R','0');

    I hope its helping you.

  3. #3
    Join Date
    Mar 2007
    Location
    NY
    Posts
    129

    Default

    This was good worked for me. Thanks, I was also interested in trying to add the payment portion like the invoice itself on the bottom showing in PDF the transaction portion when paid or blank if not paid. Can this be done?
    Joe

  4. #4
    Join Date
    Mar 2007
    Posts
    15

    Default

    You think in this file? viewinvoice.php?id=InvoiceNumber
    That in pdf file end it showing same transactions and so...?
    I think this is possible...
    I write something and copy here then

  5. #5
    Join Date
    Mar 2007
    Location
    NY
    Posts
    129

    Default

    Thanks that will be great this way clients can view when and maybe how it was paid when they save for thier records.

    Again thanks in advance.

  6. #6
    Join Date
    Mar 2007
    Posts
    15

    Default

    Hey,
    Im now back
    so... here is what you use:
    Added "status" to:
    Code:
    $a1=mysql_query("SELECT SQL_CACHE id,date,status FROM tblinvoices WHERE id='".$invoiceid."' LIMIT 1") or die(mysql_error());
    $a=mysql_fetch_array($a1);
    Then bottom before ?>
    add:

    Code:
    if($a['status']=='Paid'){
    
    $pdf->Ln(10);
    
    $pdf->SetFont('Arial','b',9);
    $pdf->Cell(0,4,$_LANG['invoicestransactions'],0,1,'L','0');
    $pdf->Ln(5);
    
    
    $pdf->Cell(40,4,$_LANG['invoicestransdate'],1,0,'C','1');
    $pdf->Cell(58,4,$_LANG['invoicestransgateway'],1,0,'C','1');
    $pdf->Cell(50,4,$_LANG['invoicestransid'],1,0,'C','1');
    $pdf->Cell(40,4,$_LANG['invoicestransamount'],1,0,'C','1');
    $pdf->Ln();
    
    
    $trans1=mysql_query("SELECT SQL_CACHE userid,gateway,date,amountin,transid,invoiceid FROM tblaccounts WHERE invoiceid='".$invoiceid."'")
     or die(mysql_error());
    while($trans = mysql_fetch_assoc($trans1))
    {
    $trans2=mysql_query("SELECT SQL_CACHE gateway,setting,value FROM tblpaymentgateways WHERE gateway='".$trans['gateway']."' AND setting='name' LIMIT 1")
     or die(mysql_error());
    $tra=mysql_fetch_array($trans2);
    
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(40,4,$trans['date'],1);
    $pdf->Cell(58,4,$tra['value'],1,0,'C');
    $pdf->Cell(50,4,$trans['transid'],1,0,'C');
    $pdf->Cell(40,4,$trans['amountin'],1,0,'C');
    $pdf->Ln();
    }
    
    }
    If you want more down this then
    1st line change this:
    if($a['status']=='Paid'){
    $pdf->Ln(10); <<<--- 10 to 20 like :P
    And finish..
    I hope its helping you....

  7. #7
    Join Date
    Mar 2007
    Posts
    15

    Default

    I have used this system now.. i think 5 days and i like this .
    but yes...too much is crypted...but if you can little think and know php you can make anything
    WHMCS RULZ

  8. #8
    Join Date
    Mar 2007
    Posts
    15

    Default

    I found one good code more :P
    If you dont like this bottom Page 1/1 and your web address..
    then add to bottom before ?>
    this:
    Code:
    $pdf->Open(0,7,'');

  9. #9
    Join Date
    Mar 2007
    Location
    NY
    Posts
    129

    Default

    Thanks will try tonight and get back to you

  10. #10
    Join Date
    Mar 2007
    Location
    NY
    Posts
    129

    Default

    koivumagi

    I understand what to do with the second part of the code.
    But where do I put the first code ---Added "status" to ?

    I tryed it a couple of ways but I cant see anything only the original pdf.
    Joe

  11. #11
    Join Date
    Mar 2007
    Posts
    15

    Default

    Ok..
    if you added this date function then u know that top you have added this :
    after <?php
    Code:
    $a1=mysql_query("SELECT SQL_CACHE id,dateFROM tblinvoices WHERE id='".$invoiceid."' LIMIT 1") or die(mysql_error()); 
    $a=mysql_fetch_array($a1);

    now remove this and add:
    or you only add status to here: SELECT SQL_CACHE id,date,status <<< here

    Code:
    $a1=mysql_query("SELECT SQL_CACHE id,date,status FROM tblinvoices WHERE id='".$invoiceid."' LIMIT 1") or die(mysql_error()); 
    $a=mysql_fetch_array($a1);

  12. #12
    Join Date
    Mar 2007
    Location
    NY
    Posts
    129

    Default

    Here is what it looks like I dont see any added feature when I download it.

    <?php
    //Logo
    $a1=mysql_query("SELECT SQL_CACHE id,date,status FROM tblinvoices WHERE id='".$invoiceid."' LIMIT 1") or die(mysql_error());
    $a=mysql_fetch_array($a1);
    $ajakesekene=explode('-', $a['date']);
    $ajake=$ajakesekene[2].'/'.$ajakesekene[1].'/'.$ajakesekene[0];
    $pdf->Ln(5);
    //Status
    if ($status=="") {
    $status="paid";
    }
    $pdf->Image(dirname(__FILE__).'/../images/invoices/'.strtolower($status).'.png',120,65,50);
    //Arial bold 15
    $pdf->SetFont('Arial','B',15);
    //Move to the right
    $pdf->SetFillColor(239);
    $pdf->Cell(0,8,$_LANG["invoicestitle"].$invoiceid,0,1,'L','1');
    $pdf->SetFont('Arial','',10);
    $pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$ajake,0,1,'L','1');
    $pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'R','2');

    //Line break
    $pdf->Ln(1);
    # Company Details
    $pdf->SetFont('Arial','',13);
    $pdf->Cell(0,6,$companyname,0,1,'L');
    $pdf->SetFont('Arial','',;
    foreach ($companyaddress AS $addressline) {
    $pdf->Cell(0,4,$addressline,0,1,'L');
    }
    $pdf->Ln(10);
    # Clients Details
    $pdf->SetFont('Arial','',11);
    if ($clientsdetails["companyname"]) {
    $pdf->Cell(0,4,$clientsdetails["companyname"],0,1,'L');
    $pdf->Cell(0,5,"ATTN: ".$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
    } else {
    $pdf->Cell(0,5,$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
    }
    $pdf->SetFont('Arial','',;
    $pdf->Cell(0,4,$clientsdetails["address1"],0,1,'L');
    if ($clientsdetails["address2"]) {
    $pdf->Cell(0,4,$clientsdetails["address2"],0,1,'L');
    }
    $pdf->Cell(0,4,$clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L');
    $pdf->Cell(0,4,$clientsdetails["country"],0,1,'L');
    $pdf->Ln(10);

    $pdf->SetFont('Arial','B',10);
    $pdf->SetFillColor(239);
    $pdf->Cell(148,7,$_LANG["invoicesdescription"],1,0,'C','1');
    $pdf->Cell(40,7,$_LANG["invoicesamount"],1,0,'C','1');
    $pdf->Ln();

    $pdf->SetFont('Arial','',10);

    foreach ($invoiceitems AS $item) {
    if (strlen($item["description"])>85) {
    #$pdf->MultiCell(148,6,$item["description"],1);
    $pdf->Cell(148,6,substr($item["description"],0,85),1);
    $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
    $pdf->Ln();
    $pdf->Cell(148,6,substr($item["description"],85),1);
    $pdf->Cell(40,6,"",1,0,'C');
    } else {
    $pdf->Cell(148,6,$item["description"],1);
    $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
    }
    $pdf->Ln();
    }

    $pdf->SetFont('Arial','B',10);

    $pdf->Cell(148,7,$_LANG["invoicessubtotal"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$subtotal,1,0,'C','1' );
    $pdf->Ln();

    $pdf->Cell(148,7,$_LANG["invoicescredit"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$credit,1,0,'C','1');
    $pdf->Ln();

    if ($CONFIG["TaxEnabled"]) {
    $pdf->Cell(148,7,$taxrate."% ".$_LANG["invoicestax"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$tax,1,0,'C','1');
    $pdf->Ln();
    }

    $pdf->Cell(148,7,$_LANG["invoicestotal"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$total,1,0,'C','1');
    $pdf->Ln();

    $pdf->Ln();

    if($a['status']=='Paid'){

    $pdf->Ln(10);

    $pdf->SetFont('Arial','b',9);
    $pdf->Cell(0,4,$_LANG['invoicestransactions'],0,1,'L','0');
    $pdf->Ln(5);


    $pdf->Cell(40,4,$_LANG['invoicestransdate'],1,0,'C','1');
    $pdf->Cell(58,4,$_LANG['invoicestransgateway'],1,0,'C','1');
    $pdf->Cell(50,4,$_LANG['invoicestransid'],1,0,'C','1');
    $pdf->Cell(40,4,$_LANG['invoicestransamount'],1,0,'C','1');
    $pdf->Ln();


    $trans1=mysql_query("SELECT SQL_CACHE userid,gateway,date,amountin,transid,invoiceid FROM tblaccounts WHERE invoiceid='".$invoiceid."'")
    or die(mysql_error());
    while($trans = mysql_fetch_assoc($trans1))
    {
    $trans2=mysql_query("SELECT SQL_CACHE gateway,setting,value FROM tblpaymentgateways WHERE gateway='".$trans['gateway']."' AND setting='name' LIMIT 1")
    or die(mysql_error());
    $tra=mysql_fetch_array($trans2);

    $pdf->SetFont('Arial','',9);
    $pdf->Cell(40,4,$trans['date'],1);
    $pdf->Cell(58,4,$tra['value'],1,0,'C');
    $pdf->Cell(50,4,$trans['transid'],1,0,'C');
    $pdf->Cell(40,4,$trans['amountin'],1,0,'C');
    $pdf->Ln();
    }

    }
    ?>
    Joe

  13. #13
    Join Date
    Mar 2007
    Posts
    15

    Default

    Ok here is my full file:
    It has invoice created date, reference number and transaction in pdf.

    Code:
    <?php
    
    $a1=mysql_query("SELECT SQL_CACHE id,date,status FROM tblinvoices WHERE id='".$invoiceid."' LIMIT 1") or die(mysql_error());
    $a=mysql_fetch_array($a1);
    
    
    $ajakesekene=explode('-', $a['date']);
    
    $ajake=$ajakesekene[2].'/'.$ajakesekene[1].'/'.$ajakesekene[0];
    
    $number = $invoiceid;
    if (!isset($number)) $number = "1234567890";
    
    $kordaja = 7;
    $algarv = $number;
    do {
                    $kontrolljark = $kontrolljark + (($number % 10) * $kordaja);
    
                    if ($kordaja == 7) $kordaja = 3;
                    else if ($kordaja == 3) $kordaja = 1;
                    else if ($kordaja == 1) $kordaja = 7;
    
    } while ((int)$number /= 10);
    
    $kontrolljark = 10 - ($kontrolljark % 10);
    
    if ($kontrolljark == 10){$kontrolljark = 0;}
    
    $viitenumber = $algarv.$kontrolljark;
    
    
    
    # Company Details
    $pdf->SetFont('Arial','',13);
    $pdf->Cell(0,6,$companyname,0,1,'L');
    $pdf->SetFont('Arial','',8);
    foreach ($companyaddress AS $addressline) {
            $pdf->Cell(0,4,$addressline,0,1,'L');
    }
    //Line break
    //Logo
    $pdf->Image(dirname(__FILE__).'/../images/logo.jpg',140,8,50);
    $pdf->Ln(10);
    //Line break
    //Arial bold 15
    $pdf->SetFont('Arial','B',12);
    //Move to the right
    $pdf->SetFillColor(239);
    $pdf->Cell(0,6,$_LANG["invoicestitle"].'     '.$invoiceid,0,1,'R','0');
    $pdf->SetFont('Arial','',10);
    $pdf->Cell(0,6,$_LANG["invoicesdatecreated"].':   '.$ajake,0,1,'R','0');
    $pdf->SetFont('Arial','',10);
    $pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate,0,1,'R','0');
    $pdf->SetFont('Arial','',10);
    $pdf->Cell(0,6,'Viitenumber:    '.$viitenumber,0,1,'R','0');
    //Line break
    $pdf->Ln(10)
    ;
    # Clients Details
    $pdf->SetFont('Arial','',11);
    if ($clientsdetails["companyname"]) {
            $pdf->Cell(0,4,$clientsdetails["companyname"],0,1,'L');
            $pdf->Cell(0,5,"Kontakt: ".$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
    } else {
            $pdf->Cell(0,5,$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
    }
    $pdf->SetFont('Arial','',8);
    $pdf->Cell(0,4,$clientsdetails["address1"],0,1,'L');
    if ($clientsdetails["address2"]) {
            $pdf->Cell(0,4,$clientsdetails["address2"],0,1,'L');
    }
    $pdf->Cell(0,4,$clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L');
    $pdf->Cell(0,4,$clientsdetails["country"],0,1,'L');
    $pdf->Ln(10);
    
    $pdf->SetFont('Arial','B',10);
    $pdf->SetFillColor(239);
    $pdf->Cell(148,7,$_LANG["invoicesdescription"],1,0,'C','1');
    $pdf->Cell(40,7,$_LANG["invoicesamount"],1,0,'C','1');
    $pdf->Ln();
    
    $pdf->SetFont('Arial','',10);
    foreach ($invoiceitems AS $item) {
            if (strlen($item["description"])>85) {
                    $pdf->MultiCell(148,6,$item["description"],1);
                    $pdf->Cell(148,6,"",1);
                    $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
            } else {
                    $pdf->Cell(148,6,$item["description"],1);
                    $pdf->Cell(40,6,$currencysymbol.$item["amount"],1,0,'C');
            }
            $pdf->Ln();
    }
    
    $pdf->SetFont('Arial','B',10);
    
    $pdf->Cell(148,7,$_LANG["invoicessubtotal"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$subtotal,1,0,'C','1');
    $pdf->Ln();
    
    $pdf->Cell(148,7,$_LANG["invoicescredit"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$credit,1,0,'C','1');
    $pdf->Ln();
    
    if ($CONFIG["TaxEnabled"]) {
            $pdf->Cell(148,7,$taxrate."% ".$_LANG["invoicestax"].":",1,0,'R','1');
            $pdf->Cell(40,7,$currencysymbol.$tax,1,0,'C','1');
            $pdf->Ln();
    }
    $pdf->Cell(148,7,$_LANG["invoicestotal"].":",1,0,'R','1');
    $pdf->Cell(40,7,$currencysymbol.$total,1,0,'C','1');
    $pdf->Ln();
    
    $pdf->Ln();
    
    
    if($a['status']=='Paid'){
    
    $pdf->Ln(10);
    
    $pdf->SetFont('Arial','b',9);
    $pdf->Cell(0,4,$_LANG['invoicestransactions'],0,1,'L','0');
    $pdf->Ln(5);
    
    
    $pdf->Cell(40,4,$_LANG['invoicestransdate'],1,0,'C','1');
    $pdf->Cell(58,4,$_LANG['invoicestransgateway'],1,0,'C','1');
    $pdf->Cell(50,4,$_LANG['invoicestransid'],1,0,'C','1');
    $pdf->Cell(40,4,$_LANG['invoicestransamount'],1,0,'C','1');
    $pdf->Ln();
    $trans1=mysql_query("SELECT SQL_CACHE userid,gateway,date,amountin,transid,invoiceid FROM tblaccounts WHERE invoiceid='".$invoiceid."'")
     or die(mysql_error());
    while($trans = mysql_fetch_assoc($trans1))
    {
    $trans2=mysql_query("SELECT SQL_CACHE gateway,setting,value FROM tblpaymentgateways WHERE gateway='".$trans['gateway']."' AND setting='name' LIMIT 1")
     or die(mysql_error());
    $tra=mysql_fetch_array($trans2);
    
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(40,4,$trans['date'],1);
    $pdf->Cell(58,4,$tra['value'],1,0,'C');
    $pdf->Cell(50,4,$trans['transid'],1,0,'C');
    $pdf->Cell(40,4,$trans['amountin'],1,0,'C');
    $pdf->Ln();
    }
    
    }
    ?>

  14. #14
    Join Date
    Feb 2007
    Posts
    378

    Default

    koivumagi,

    This is GREAT thanks. Have got it working nicely!

    One thing you might be able to help with - may date is backwards. Instead of 15/3/2007 it is 2007-03-15. Is there anyway of changing this?

    Thanks,

    Ad

  15. #15
    Join Date
    Feb 2007
    Posts
    378

    Default

    This has also helped me to change my messages on the invoice depending on whether it is paid or unpaid. Excellent!

Page 1 of 2 12 LastLast

Similar Threads

  1. PDF invoice: how can I change the filename invoice-<nr>.pdf?
    By Paderman in forum Customisation & Integration Questions
    Replies: 1
    Last Post: 11-13-12, 04:42 PM
  2. Replies: 2
    Last Post: 06-19-09, 04:22 PM
  3. Add transaction date to email confirmation and pdf invoice
    By wildorchid in forum Feature Requests
    Replies: 9
    Last Post: 01-17-09, 02:06 PM
  4. Manual Creation - Invoice #, Invoice Date, Date Due
    By mstorman in forum Feature Requests
    Replies: 7
    Last Post: 11-24-06, 06:58 AM