Exemplo n.º 1
0
 /**
  * Render the invoice.
  *
  * @return mixed
  */
 public function render()
 {
     // libs TinyButStrong
     include_once 'TinyButStrong/tinyButStrong.class.php';
     include_once 'TinyButStrong/tinyDoc.class.php';
     $doc = new tinyDoc();
     // use zip extension if available
     if (class_exists('ZipArchive')) {
         $doc->setZipMethod('ziparchive');
     } else {
         $doc->setZipMethod('shell');
         try {
             $doc->setZipBinary('zip');
             $doc->setUnzipBinary('unzip');
         } catch (tinyDocException $e) {
             $doc->setZipMethod('pclzip');
         }
     }
     $doc->setProcessDir($this->getTemporaryDirectory());
     //This is where the template is selected
     $templateform = $this->getTemplateDir() . $this->getTemplateFile();
     $doc->createFrom($templateform);
     $doc->loadXml('content.xml');
     // fetch variables from model to get values
     $customer = $this->getModel()->getCustomer();
     $projects = $this->getModel()->getProjects();
     $entries = $this->getModel()->getEntries();
     // assign all available variables (which are not arrays as they do not work in tinyButStrong)
     foreach ($this->getModel()->toArray() as $k => $v) {
         if (is_array($v)) {
             continue;
         }
         $GLOBALS[$k] = $v;
     }
     // ugly but neccessary for tinyButStrong
     // set globals variables, so they can be used in invoice templates
     $allCustomer = $this->prepareCustomerArray($customer);
     foreach ($allCustomer as $k => $v) {
         $GLOBALS[$k] = $v;
     }
     $GLOBALS['projects'] = $projects;
     $GLOBALS['project'] = implode(', ', array_map(function ($project) {
         return $project['name'];
     }, $projects));
     $doc->mergeXmlBlock('row', $entries);
     $doc->saveXml();
     $doc->close();
     // send and remove the document
     $doc->sendResponse();
     $doc->remove();
 }
Exemplo n.º 2
0
		$msg="Mode \$fb_dezip_ooo=$fb_dezip_ooo non traité pour le moment... désolé.<br />";
	}
	else {
		$tempdirOOo="../temp/".$tempdir;

		$nom_dossier_temporaire = $tempdirOOo;
		//par defaut content.xml
		$nom_fichier_xml_a_traiter ='content.xml';

		// Création d'une classe tinyDoc
		$OOo = new tinyDoc();
		
		// Choix du module de dézippage
		$dezippeur=getSettingValue("fb_dezip_ooo");
		if ($dezippeur==1){
			$OOo->setZipMethod('shell');
			$OOo->setZipBinary('zip');
			$OOo->setUnzipBinary('unzip');
		}
		else{
			$OOo->setZipMethod('ziparchive');
		}

		$prefixe_generation_hors_dossier_mod_ooo="../mod_ooo/";
		$nom_fichier_modele_ooo="avertissement_fin_periode.odt";

		//Procédure du traitement à effectuer
		//les chemins contenant les données
		include_once("../mod_ooo/lib/chemin.inc.php");

		//echo "\$nom_dossier_modele_a_utiliser=$nom_dossier_modele_a_utiliser<br />";
Exemplo n.º 3
0
$ttltime = 0;
$gtotal = 0;
while (list($id, $fd) = each($invoiceArray)) {
    $gtotal += $invoiceArray[$id]['amount'];
    $ttltime += $invoiceArray[$id]['hour'];
}
$vat_rate = $kndArray['knd_vat'];
if (!is_numeric($vat_rate)) {
    $vat_rate = $kga['conf']['defaultVat'];
}
$vat = $vat_rate * $gtotal / 100;
$total = $gtotal - $vat;
$doc = new tinyDoc();
// use zip extension if available
if (class_exists('ZipArchive')) {
    $doc->setZipMethod('ziparchive');
} else {
    $doc->setZipMethod('shell');
    try {
        $doc->setZipBinary('zip');
        $doc->setUnzipBinary('unzip');
    } catch (tinyDocException $e) {
        $doc->setZipMethod('pclzip');
    }
}
$doc->setProcessDir('../../temporary');
//This is where the template is selected
$templateform = "templates/" . $_REQUEST['ivform_file'];
$doc->createFrom($templateform);
$doc->loadXml('content.xml');
$doc->mergeXmlBlock('row', $invoiceArray);