
<?php

  public function executeOrder(sfWebRequest $request)
  {
    // create the document
    $doc = new sfTinyDoc();
    $doc->createFrom(array('extension' => 'odt'));
    $doc->loadXml('content.xml');

    $doc->mergeXmlField('order',
      array(
        'id'         => '2009-123',
        'date'       => date('Y-m-d'),
        'total'      => 99.56,
        'vat'        => 5.48,
        'vat_rate'   => 5.5,
        'gtotal'     => 105.04,
        'lastname'   => 'Doe',
        'firstname'  => 'John',
        'company'    => '1solution',
        'adress1'    => '4 les jardins de Coucarel',
        'adress2'    => '',
        'adress3'    => '',
        'city'       => 'Clarensac',
        'zip'        => '30870',
        'country'    => 'France',
      )
    );
    $doc->mergeXmlBlock('row',
      array(
        array(
          'num'    => 1,
          'ref'    => 'the-book',
          'desc'   => 'The Definitive Guide to symfony',
          'price'  => 28.76,
          'tprice' => 28.76,
        ),
        array(
          'num'    => 1,
          'ref'    => 'propel-en',
          'desc'   => 'Practical symfony - Propel edition',
          'price'  => 23.60,
          'tprice' => 23.60,
        ),
        array(
          'num'    => 2,
          'ref'    => 'doctrine-en',
          'desc'   => 'Practical symfony - Doctrine edition',
          'price'  => 23.60,
          'tprice' => 47.20,
        ),
      )
    );
    $doc->saveXml();

    $doc->loadXml('styles.xml');
    $doc->mergeXmlField('header',
      array(
        'title' => 'made with tinyDoc and',
        'img'   => 'images/samples/openoffice-by-benjamin-bois.png',
      )
    );
    $doc->mergeXmlField('footer',
      array(
        'signature' => 'image credit : Benjamin Bois',
      )
    );
    $doc->saveXml();
    $doc->close();

    // send and remove the document
    $doc->sendResponse();
    $doc->remove();

    throw new sfStopException;
  }

?>
