-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get a blank word document #434
Comments
Could you give the full example? "$$section" is wrong. |
order_header_id is $order_header_id "); $results = DB::query($q1,$order_header_id); foreach ($results as $row1) { ``` $order_header_id = ``` $row1['order_header_id']; ``` $order_header_name = ``` $row1['order_header_name']; $order_header_discount = $row1['order_header_discount']; $_SESSION['order_header_discount'] = $order_header_discount; ``` $state_tax_total = ``` $row1['order_header_tax']; ``` $_SESSION['state_tax_total'] = ``` $state_tax_total; ``` // print_r( $_SESSION ); ``` $order_header_organization_link_id = $row1['order_header_organization_link_id'] ; $order_header_organization_member_id = $row1['order_header_organization_member_id'] ; ``` $order_header_order_type_id = ``` $row1['order_header_order_type_id'] ; ``` $order_header_terms_id = ``` $row1['order_header_terms_id'] ; ``` $order_header_po_number = ``` $row1['order_header_po_number'] ; ``` if ``` (empty($order_header_terms_id)) { ``` $order_header_terms_id = ``` $row1['order_header_terms_id'] ; } ``` $order_header_due_date1 = ``` $row1['order_header_due_date'] ; ``` if ($order_header_due_date1 > ``` '0000-00-00') { ``` $phpdate = strtotime( ``` $order_header_due_date1 ); ``` $order_header_due_date = date( ``` 'm/d/Y', $phpdate ); ``` } $order_header_invoice_date1 = ``` $row1['order_header_invoice_date'] ; ``` if ($order_header_invoice_date1 ``` > '0000-00-00') { ``` $phpdate = strtotime( ``` $order_header_invoice_date1 ); ``` $order_header_invoice_date = ``` date( 'm/d/Y', $phpdate ); ``` $sqlt ='SELECT terms_id , ``` terms_percent , terms_day , terms_text ``` FROM terms WHERE terms_id = %s'; //print(" sqlt "); $results = ``` DB::query($sqlt,$order_header_terms_id); ``` foreach ($results as $rowt) { $terms_day = ``` $rowt['terms_day'] ; ``` $terms_percent = ``` $rowt['terms_percent'] ; ``` } list ($year,$month, $day) = ``` explode('-', $order_header_invoice_date1); ``` $dateto= ``` GregorianToJD($month,$day,$year) + $terms_day; ``` $order_header_due_date = ``` JDToGregorian($dateto); ``` // print(" terms_day is $terms_day "); } ``` } ``` //print(" order_header_terms_id is ``` $order_header_terms_id "); ``` if (!empty($order_header_terms_id)) { $sqlt ='SELECT terms_id , ``` terms_percent , terms_day , terms_text ``` FROM terms WHERE terms_id = %s'; $results = ``` DB::query($sqlt,$order_header_terms_id); ``` foreach ($results as $rowt) { $terms_day = ``` $rowt['terms_day'] ; ``` $terms_percent = ``` $rowt['terms_percent'] ; $_SESSION['terms_percent']=$terms_percent ; $_SESSION['order_header_terms_id']=$order_header_terms_id ; ``` } ``` //print("order_header_invoice_date1 is $order_header_invoice_date1 "); ``` $yesdis ``` =strpos($order_header_invoice_date1,'/') ; ``` if ( $yesdis >0){ list ($month, ``` $day,$year) = explode('/', $order_header_invoice_date1);} ``` $yesin ``` =strpos($order_header_invoice_date1,'-') ; ``` if ( $yesin >0){ list ($year ``` ,$month, $day) = explode('-', $order_header_invoice_date1);} ``` //print("month is $month day ``` is $day year is $year terms day is $terms_day "); ``` $dateto= ``` GregorianToJD($month,$day,$year) +$terms_day ; ``` //print("dateto is $dateto ``` "); ``` $order_header_due_date = ``` JDToGregorian($dateto); //print("order_header_invoice_date is $order_header_invoice_date order_header_due_date is $order_header_due_date "); ``` } ``` $organization_link_record = get_organization_link_record($order_header_organization_link_id); $organization_record = get_organization_record($organization_link_record['organization_link_organiz ation_id']); $_SESSION['state_tax'] =$organization_link_record['organization_link_state_tax'] ; $_SESSION['organization_taxable'] =$organization_record['organization_taxable'] ; $pathroot = '/home/vhosts/greatgrow.com/httpdocs/backoffice/invoice/'; $filedoc =$pathroot."invoice.doc"; //require_once 'PHPWord/PHPWord.php'; $invname =$organization_record['organization_firm_name'].' =>'; $invname.=$organization_link_record['organization_link_first_name']; $invname.=$organization_link_record['organization_link_flast_name']; $city =$organization_link_record['organization_link_city'] ; $city.= ', '.$organization_link_record['organization_link_state_name']; $city.= ' '.$organization_link_record['organization_link_zip']; $cnt =2; $invoicedoc ='invoice'.$cnt.'.docx'; // New Word Document $PHPWord = new PHPWord(); $document = $PHPWord->loadTemplate('./documents/invoice1.docx'); $section = $PHPWord->createSection(); $section->addText( $invname ); $section->addText( $organization_link_record['organization_link_address_1'] ); $section->addText($organization_link_record['organization_link_address_2'] ); if (!empty( $organization_link_record['organization_link_address_3'])) ``` {$section->addText( ``` $organization_link_record['organization_link_address_3'] );} if (!empty( $organization_link_record['organization_link_address_4'])) ``` {$section->addText( ``` $organization_link_record['organization_link_address_4'] );} $section->addText($city); $document->save('invoice/'.$invoicedoc); print (" $city "); print_r( $organization_link_record); die; the code works here is url staten island, NEW YORK 10305 Array ( [organization_link_id] => 3 [organization_link_organization_id] => 1 [organization_link_first_name] => Tom [organization_link_last_name] => Somebody [organization_link_full_name] => Tom Somebody [organization_link_title] => [organization_link_title_id] => 0 [organization_link_title_name] => [organization_link_address_1] => 489 Steuben Street [organization_link_address_2] => po box 1234 [organization_link_address_3] => [organization_link_address_4] => [organization_link_city] => staten island [organization_link_state_id] => 33 [organization_link_state_name] => NEW YORK [organization_link_state_tax] => 4.0000 [organization_link_country_id] => 8 [organization_link_country_name] => [organization_link_region_name] => [organization_link_zip] => 10305 [organization_link_phone] => 917-968-7093 [oorganization_link_fax] => [organization_link_cell] => [organization_link_notes] => [organization_link_member_id] => 0 [organization_link_type_id] => [organization_link_email] => smroczek@verizon.net [organization_link_email_opt_out] => 0 [organization_link_potential_id] => 0 [organization_link_modified_by] => 1 [organization_link_modified_by_time] => 2014-11-17 14:24:14 [organization_link_created_by] => 0 [organization_link_created_by_time] => 0000-00-00 00:00:00 ) I fixed $$section Thank you for your help The main url is http://greatgrow.com/ From: Franz Holzinger [mailto:notifications@github.com] Sent: Friday, November 21, 2014 2:57 PM To: PHPOffice/PHPWord Cc: smroczek Subject: Re: [PHPWord] Get a blank word document (#434) Could you give the full example? The array $organization_link_record has not been initialized. The same counts for the rest of variables: $invname, ... And you should give the file invoice1.docx for download. "$$section" is wrong. ## Reply to this email directly or view it on GitHub https://github.com//issues/434#issuecomment-64028564 . |
Some more info phpword From: Franz Holzinger [mailto:notifications@github.com] Could you give the full example? "$$section" is wrong. Reply to this email directly or view it on GitHub |
note error |
if you use $document = $PHPWord->loadTemplate('Template.docx'); $section->addText( $invname ); will not work |
how can i get a new table in a cell |
Late to the party... but here's the answer you probably didn't want. "It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform main document part of the template using XSLT" -- Source: http://phpword.readthedocs.org/en/latest/templates-processing.html |
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('./documents/invoice1.docx');
$section = $PHPWord->createSection();
$section->addText( $invname);
$section->addText( $organization_link_record['organization_link_address_1'] );
$section->addText( $organization_link_record['organization_link_address_2'] );
if (!empty( $organization_link_record['organization_link_address_3']))
{$section->addText( $organization_link_record['organization_link_address_3'] );}
if (!empty( $organization_link_record['organization_link_address_4']))
{$section->addText( $organization_link_record['organization_link_address_4'] );}
$$section->addText($city);
$document->save('invoice/'.$invoicedoc);
what am i doing wrong?
The text was updated successfully, but these errors were encountered: