Lindsayanng Posted July 20, 2011 Share Posted July 20, 2011 I am i guess "intermediate" when it comes to using php building libraries - I definitely understand them and how to work with them. However, I have not done much in the realm of building a pdf from something as complex as a shopping cart, that paired with my somewhat lack of knowledge of prestashop has me stuck. I have gotten RELATIVELY far - I have created an additional form in the "invoices" tab in admin that looks through all orders by date and then returns only the orders for those dates. Right now I have it hooked to the function that builds the invoices.. The goal here is to almost duplicate the invoices output but change it just a little bit. So where a normal invoice output looks like a nice normal invoice table with addresses up top and the store address underneath, the new output will have the store address in a newly defined place for use with a new RMA (return murchandise authorization) form that has a label on it that the customer peels away. Basically two entirely different classes for the normal invoice.pdf and my new rma.pdfSo the issue is I can not seem to make a second class for my new style pdf because it gets hung up. I have the forum submission routing to a file called pdf2.php which as this information: define('PS_ADMIN_DIR', getcwd()); include(PS_ADMIN_DIR.'/../config/config.inc.php'); /* Header can't be included, so cookie must be created here */ $cookie = new Cookie('psAdmin'); if (!$cookie->id_employee) Tools::redirectAdmin('login.php'); $functionArray = array( 'labels' => 'generateLabelsPDF', ); foreach ($functionArray as $var => $function) if (isset($_GET[$var])) { call_user_func($function); die; } function generateLabelsPDF() { $orders = Order::getOrdersIdInvoiceByDate($_GET['date_from'], $_GET['date_to'], NULL, 'invoice'); if (!is_array($orders)) die (Tools::displayError('No invoices found')); PDF::multipleLabels($orders); } I maintained the 'invoice' reference there because for now I just want to test the output. With this setup my pdf that I download should look exactly like all of the other pdfs but will have a new class name. When I actually get it hooked to the pdf classes page then I will start building the second pdf design. Then in the pdf.php classes file I added this: //added for labels public static function multipleLabels($labels) { $pdf = new PDF('P', 'mm', 'A4'); foreach ($labels AS $id_order) { $orderObj = new Order((int)$id_order); if (Validate::isLoadedObject($orderObj)) PDF::invoice($orderObj, 'D', true, $pdf); } return $pdf->Output('cust_labels.pdf', 'D'); } //added for labels So the things I have done to test are as follows: First I simply put the default invoices function into admin/pdf2.php and removed it from the pdf.php just to make sure that my form was submitting to proper page and it was. Doing that generated the proper invoices that would have occured had I used the original invoice print button. The next step was the change the function from 'invoices' => generateInvoicesPDF to 'labels' => generateLabelsPDF and any references of the previous mention throughout that code. Doing that breaks it.. It seems that the part that breaks it is changing 'invoices' => to 'labels' I found that I could change all references to generateLabelsPDF as well as create a new duplicate function of invoices called multipleLables and it all works IF and only IF i change the initial 'labels' => generateLabelsPDF back to simply 'invoices' => generateLabelsPDF I did some digging through the spaghetti code in the classes/pdf.php file but I think I am a little confused as to what calls what. It's hard to see where the different pdf's that are generated are coming from. It seems to be one giant "template" with a bunch of if/else statements in there.. Not sure though as it seems the returns slip might be it's own design as well. Anyways - any help is ALWAYS appreciated.. This isn't necessarily a pdf generation issue but more of an issue combining a function with a class. thanks for your help in advance/ Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 26, 2011 Author Share Posted July 26, 2011 making SOME progress on this but still having issues. Is there anyone out there? Link to comment Share on other sites More sharing options...
Recommended Posts