jonsecu Posted November 24, 2012 Share Posted November 24, 2012 Hi, I am looking for a way to create a pdf to print the results of some queries done in prestashop, the query is like this one: $zeroQuantity = 'SELECT id_product FROM ps_stock_available WHERE ps_stock_available.quantity = 0'; $results = Db::getInstance()->ExecuteS($zeroQuantity); $data_to_pdf = $results; The array to show is stored in $data_to_pdf variable, I would like to print this array as a table and add some header and footer to the pdf file. Can anyone give an insight on how to achieve this? Thanks you very much. Link to comment Share on other sites More sharing options...
bellini13 Posted November 25, 2012 Share Posted November 25, 2012 the query only returns the product id, what other information would you be displaying in this table? Link to comment Share on other sites More sharing options...
jonsecu Posted November 25, 2012 Author Share Posted November 25, 2012 Hi, thanks for anwering. Indeed, it only shows the id. I posted this just as an example of how I am going to have stored the query data. The data that I want to present as a pdf file will be on php variables generated by prestashop sql queries (using Db:: methods). In general I´d like to have a custom pdf file which includes the results of a query showing the orders that sold certain products between a period of time and that are now out of stock (ps_stock_available.quantity = 0). Example: Product 1 Name: sold between date 1 and date 2 id_order date_sold The query would show the id_order and the time when it was sold. I would like to add to the pdf a header with the store name, the product being reported, the supplier name and date generated. I am looking for a method or way to convert this query results into a pdf... formatted using html tables??? I would like to trigger the generation of this report either by clicking a button on the backoffice or automatically at certain time of the day... but actually my main concern is the transformation of php data to a pdf file. Thanks again and have a good weekend. Link to comment Share on other sites More sharing options...
bellini13 Posted November 25, 2012 Share Posted November 25, 2012 Prestashop uses the fpdf or tcpdf library to create PDF documents. tcpdf is new with v1.5 and I am not familiar with it. fpdf API is here http://www.fpdf.org/ tcpdf API is here http://www.tcpdf.org/ You could follow the PDF class in Prestashop as a guide to create a new PDF document, or add a new function to the PDF class so that it would create this specialized PDF document. Using fpdf you would likely want to use the Multicell function to create the table data. Refer to the API documents for examples. With tcpdf it looks like it supports html formatting, refer to this example http://www.tcpdf.org/examples/example_006.phps Link to comment Share on other sites More sharing options...
jonsecu Posted November 26, 2012 Author Share Posted November 26, 2012 Thank you very much. I am checking on this one and I am pretty sure it will do the job. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now