Printing

A place for users and developers of the Xataface to discuss and receive support.

Printing

Postby cookie720 » Sun Jun 24, 2012 7:37 am

Any quick/simple way to print?
I have played around with FPDF and read a few threads....kind of complicated, I managed to get to the stage where I have no errors but the page is completely blank? What part of the code actually prints fields/tables?

Code: Select all
<?php import('/fpdf/fpdf.php'); // Place your custom PDF class in another file and import it here
class dataface_actions_print_this_action {

function handle(&$params){
      $app =& Dataface_Application::getInstance();
      $query = $app->getQuery();
      $query['-limit'] = 9999999;
      $table =& Dataface_Table::loadTable($query['-table']);
      $record =& $app->getRecord();

      $pdfoutput = $record->val('orders');
      $pdf=new FPDF();
      $pdf->AliasNbPages();
      $pdf->AddPage();
      $pdf->SetFont('arial','',10);
      $pdf->SetLeftMargin(15);
      $pdf->MultiCell(0,5,$pdfoutput,0,1);
      $pdf->Output();

   }
}
?>
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm

Re: Printing

Postby shannah » Sun Jun 24, 2012 10:40 am

Hard to say from here. First thing is to make sure that $pdfoutput is not an empty string. I'm no expert on FPDF though. If you are having trouble with FPDF, you might want to try TCPDF (which is based on FPDF but has more features). Or to try a completely different approach and go to DOMPDF (it allows you to use HTML/CSS for building the PDF).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Printing

Postby cookie720 » Sun Jun 24, 2012 4:32 pm

I have got tcpdf to work, and I have my fields coming up. I read this thread
viewtopic.php?t=4066#20419
and im using this format
Code: Select all
function handle(&$params){
      $app =& Dataface_Application::getInstance();
      $query = $app->getQuery();
      $query['-limit'] = 9999999;
      $table =& Dataface_Table::loadTable($query['-table']);
      $record =& $app->getRecord();

          $ClientID = 'Client ID: '.$record->val('ClientID');
          $Photo = $record->val('Photo');
     $FirstName = 'First Name: '.$record->val('FirstName');
     $LastName = 'Last Name: '.$record->val('LastName');
     $PhoneNumber = 'Phone Number: '.$record->val('PhoneNumber');
    
     $OrderID= 'OrderID: '.$record->val('orders.OrderID');
    
    
     $pdf=new TCPDF();
      $pdf->AliasNbPages();
      $pdf->AddPage();
      $pdf->SetFont('helvetica','',10);
      $pdf->SetLeftMargin(15);
      $pdf->MultiCell(0,5,$ClientID,0,1);
        $pdf->MultiCell(0,5,$Photo,0,1);
     $pdf->MultiCell(0,5,$FirstName,0,1);
     $pdf->MultiCell(0,5,$LastName,0,1);
     $pdf->MultiCell(0,5,$PhoneNumber,0,1);
    
      $pdf->MultiCell(0,5,$OrderID,0,1);
      
     ob_end_clean();
      $pdf->Output();


Its working beautifully, is this an efficient way to do it?

NOTE: I cannot get photo to appear....

Another thing, a client has many "live" pending orders, and i would like to list them all, right now im doing this manually:

Code: Select all

$OrderID='Orders: '.$record->val('orders.OrderID');
$OrderID2=$record->val('orders.OrderID');
$OrderID2=$record->val('orders.OrderID');
$OrderID3=$record->val('orders.OrderID');
$OrderID4=$record->val('orders.OrderID');
.............
$pdf->MultiCell(0,5,$OrderID,0,1);
$pdf->MultiCell(0,5,$OrderID2,0,1);
$pdf->MultiCell(0,5,$OrderID3,0,1);
$pdf->MultiCell(0,5,$OrderID4,0,1);
$pdf->MultiCell(0,5,$OrderID5,0,1);
.......

this is crap cos i have to manually keep track each time. a very inefficient way especially for abig database, when some clients could have 50 orders, and others will have just 1

Is there a quick way to just loop it ?
(the thing is I dont how to create a loop within this function)
any help from the programmers out there?
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm

Re: Printing

Postby cookie720 » Tue Jun 26, 2012 5:26 pm

im trying to add a button for both my tables, but if i insert a new print button in actions.ini i get
Code: Select all
Warning: syntax error, unexpected END_OF_LINE, expecting '=' in C:/wamp/www/live_matters/xataface/actions.ini on line 22


Code: Select all
[print_this]
   label = Print
   description = Print This Report
   url = "{$this->url('-action=print_this_action')}"
   accessKey = "p"
   category = table_actions
   icon = "{$dataface_url}/images/print_icon.gif"
   mode = print
   permission = view
   order=5
   condition = "$query['-table'] == 'clients'"

   [print_this2]
   label = Print
   description = Print This Report
   url = "{$this->url('-action=print_this_action2')}"
   accessKey = "p"
   category = table_actions
   icon = "{$dataface_url}/images/print_icon.gif"
   mode = print
   permission = view
   order=5
   condition = "$query['-table'] == 'orders'"
is there a way to initiate the two tables in the one action?
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm

Re: Printing

Postby cookie720 » Tue Jun 26, 2012 6:32 pm

Incredible, it wasnt liking the space i had as a result of copying and pasting before [print_this2]

Anyway, 2 posts up! I would really appreciate some help anyone !
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved