コード例 #1
0
ファイル: RDocumento.php プロジェクト: hcvcastro/pxp
 function write($fileName)
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $document = $phpWord->loadTemplate(dirname(__FILE__) . '/template_carta_adj.docx');
     setlocale(LC_ALL, "es_ES@euro", "es_ES", "esp");
     $document->setValue('NUMOC', $this->getDataSource()->getParameter('num_tramite'));
     // On section/content
     $document->setValue('PROVEEDOR', $this->getDataSource()->getParameter('desc_proveedor'));
     // On section/content
     $document->setValue('OBJETIVO', $this->getDataSource()->getParameter('objeto'));
     // On section/content
     $document->setValue('FECHAOC', strftime("%d de %B de %Y", strtotime($this->getDataSource()->getParameter('fecha_oc'))));
     // On section/content
     $document->saveAs($fileName);
 }
コード例 #2
0
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx');
// Variables on different parts of document
$document->setValue('weekday', date('l'));
// On section/content
$document->setValue('time', date('H:i'));
// On footer
$document->setValue('serverName', realpath(__DIR__));
// On header
// Simple table
$document->cloneRow('rowValue', 10);
$document->setValue('rowValue#1', 'Sun');
$document->setValue('rowValue#2', 'Mercury');
$document->setValue('rowValue#3', 'Venus');
$document->setValue('rowValue#4', 'Earth');
$document->setValue('rowValue#5', 'Mars');
$document->setValue('rowValue#6', 'Jupiter');
$document->setValue('rowValue#7', 'Saturn');
$document->setValue('rowValue#8', 'Uranus');
$document->setValue('rowValue#9', 'Neptun');
$document->setValue('rowValue#10', 'Pluto');
$document->setValue('rowNumber#1', '1');
$document->setValue('rowNumber#2', '2');
$document->setValue('rowNumber#3', '3');
$document->setValue('rowNumber#4', '4');
$document->setValue('rowNumber#5', '5');
コード例 #3
0
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$document = $phpWord->loadTemplate('resources/Sample_23_TemplateBlock.docx');
/*
$section->addText('Hello world!');
$section->addText('Hello world!');
$section->addText('Hello world!');
$section->addText('Hello world!');*/
// Will clone everything between ${tag} and ${/tag}, the number of times. By default, 1.
$document->cloneBlock('CLONEME', 3);
// Everything between ${tag} and ${/tag}, will be deleted/erased.
$document->deleteBlock('DELETEME');
$name = 'Sample_23_TemplateBlock.docx';
echo date('H:i:s'), " Write to Word2007 format", EOL;
$document->saveAs($name);
rename($name, "results/{$name}");
echo getEndingNotes(array('Word2007' => 'docx'));
if (!CLI) {
    include_once 'Sample_Footer.php';
}
コード例 #4
0
    <body>
        <h1>Ejemplo Certificado y CAPTCHA</h1>
    <?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $securimage = new Securimage();
    if ($securimage->check($_POST['captcha_code']) == false) {
        echo "El CAPTCHA ingresado es incorrecto.<br /><br />";
        echo "Por favor <a href='javascript:history.go(-1)'>vuelve</a> a intentarlo.";
        exit;
    }
    ob_end_clean();
    header("Content-Encoding: None", true);
    \PhpOffice\PhpWord\Autoloader::register();
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $filenameModelo = "modelo2.docx";
    $template = $phpWord->loadTemplate($filenameModelo);
    $template->setValue('proveedor', $_POST['prestador']);
    $template->setValue('chofer', $_POST['chofer']);
    $template->setValue('matricula', $_POST['matricula']);
    $template->setValue('dni', $_POST['dni']);
    $template->setValue('curso', $_POST['curso']);
    $template->setValue('sede', $_POST['sede']);
    $template->setValue('fechacurso', $_POST['fecha_curso']);
    $template->setValue('numero', $_POST['transaccion']);
    $template->setValue('fechatrans', $_POST['fecha_transaccion']);
    // QR
    $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" . "status_chofer.php";
    $qrFile = generarQR($url);
    $template->setImageValue("image1.png", $qrFile);
    $filename = 'output.docx';
    $filenamePdf = 'output.pdf';
コード例 #5
0
ファイル: Pdf.php プロジェクト: nagiro/Entrades
 /**
  * Funció que em retorna el document de tancament
  **/
 public static function generaDocumentTancament($idSessio)
 {
     \PhpOffice\PhpWord\Settings::setTempDir(BASEURL . 'tmp/');
     $phpword = new \PhpOffice\PhpWord\PhpWord();
     $T = $phpword->loadTemplate(BASEURL . '/Data/Documents/InformeTancamentLaGorga.docx');
     $EM = new EspectaclesModel();
     $LlistatLocalitats = $EM->getLocalitatsForDocument($idSessio);
     if (sizeof($LlistatLocalitats) == 0) {
         throw new MyException('No he trobat cap seient ocupat.');
     }
     $RECAPTAT = array('TOTALS' => array('M' => array('PERSONES' => 0, 'PREU' => 0), 'T' => array('PERSONES' => 0, 'PREU' => 0), 'D' => array('PERSONES' => 0, 'PREU' => 0), 'TOTAL' => 0, 'PERSONES' => 0), 'TIPUS_ENTRADA' => array());
     $LC = $LlistatLocalitats['COMANDES'];
     $LS = $LlistatLocalitats['SESSIO'];
     $LE = $LlistatLocalitats['ESPECTACLE'];
     foreach ($LlistatLocalitats['LOCALITATS'] as $K => $LTO) {
         $OP = $LTO->getPreu();
         $idComanda = $LTO->localitat['l_idComanda'];
         $TipusPagament = $LC[$idComanda]->comanda['co_TipusPagament'];
         $NomPreu = $OP->preu['nom'];
         $Import = $OP->preu['import'];
         if ($LTO->localitat['l_estat'] == 'O') {
             if (!isset($RECAPTAT['TOTALS'][$TipusPagament])) {
                 $RECAPTAT['TOTALS'][$TipusPagament] = array('PERSONES' => 0, 'PREU' => 0);
             }
             //Sumem import al recaptat per tipus pagament
             $RECAPTAT['TOTALS'][$TipusPagament]['PREU'] += $Import;
             $RECAPTAT['TOTALS'][$TipusPagament]['PERSONES'] += 1;
             //Sumem import al total recaptat
             $RECAPTAT['TOTALS']['TOTAL'] += $Import;
             //Sumem l'import a la persona
             $RECAPTAT['TOTALS']['PERSONES'] += 1;
             //Sumem import al tipus de preu
             if (!isset($RECAPTAT['TIPUS_ENTRADA'][$NomPreu])) {
                 $RECAPTAT['TIPUS_ENTRADA'][$NomPreu] = array('TOTAL' => 0, 'PERSONES' => 0, 'PREU' => $Import);
             }
             //Sumem import al total per tipus de preu
             $RECAPTAT['TIPUS_ENTRADA'][$NomPreu]['TOTAL'] += $Import;
             //Sumem persona al tipus de preu
             $RECAPTAT['TIPUS_ENTRADA'][$NomPreu]['PERSONES'] += 1;
         } else {
             //Sumem import al tipus de preu
             if (!isset($RECAPTAT['TIPUS_ENTRADA']['Reserves'])) {
                 $RECAPTAT['TIPUS_ENTRADA']['Reserves'] = array('TOTAL' => 0, 'PERSONES' => 0, 'PREU' => 0);
             }
             //Sumem import al total per tipus de preu
             $RECAPTAT['TIPUS_ENTRADA']['Reserves']['TOTAL'] = 0;
             //Sumem persona al tipus de preu
             $RECAPTAT['TIPUS_ENTRADA']['Reserves']['PERSONES'] += 1;
         }
     }
     $T->setValue('Espectacle', htmlspecialchars($LE->espectacle['e_Titol']));
     $T->setValue('Dia', htmlspecialchars($LS->sessio['tmp_Dia']));
     $T->setValue('Hora', htmlspecialchars($LS->sessio['tmp_Hora']));
     $T->setValue('Organitzador', htmlspecialchars($LE->espectacle['e_OrganitzadorNom']));
     $T->setValue('Cif', htmlspecialchars($LE->espectacle['e_OrganitzadorCif']));
     $T->setValue('Recaptat', $RECAPTAT['TOTALS']['TOTAL']);
     $T->setValue('Online', $RECAPTAT['TOTALS']['T']['PREU']);
     $T->setValue('Datafon', $RECAPTAT['TOTALS']['D']['PREU']);
     $T->setValue('Metalic', $RECAPTAT['TOTALS']['M']['PREU']);
     $T->setValue('NOnline', $RECAPTAT['TOTALS']['T']['PERSONES']);
     $T->setValue('NDatafon', $RECAPTAT['TOTALS']['D']['PERSONES']);
     $T->setValue('NMetalic', $RECAPTAT['TOTALS']['M']['PERSONES']);
     $T->setValue('Persones', $RECAPTAT['TOTALS']['PERSONES']);
     $T->cloneRow('rowValue', sizeof($RECAPTAT['TIPUS_ENTRADA']));
     $i = 1;
     foreach ($RECAPTAT['TIPUS_ENTRADA'] as $K => $V) {
         $T->setValue('rowValue#' . strval($i), htmlspecialchars($K));
         $T->setValue('rowQuantitat#' . strval($i), $V['PERSONES']);
         $T->setValue('rowPreu#' . strval($i), $V['PREU']);
         $T->setValue('rowImport#' . strval($i), $V['TOTAL']);
         $i++;
     }
     $T->setValue('Total', $RECAPTAT['TOTALS']['TOTAL']);
     $config = J::loadJsonConfigFile("config.json");
     $importTaxa1Dia = floatval($config['TAXA_OCUPACIO']);
     $importTaxa = $RECAPTAT['TOTALS']['TOTAL'] * 25 / 100;
     if ($importTaxa > $importTaxa1Dia) {
         $importTaxa = $importTaxa1Dia * 0.3;
     }
     $T->setValue('ImportTaxa', $importTaxa);
     $T->saveAs(BASEURL . 'Data/Documents/S' . $idSessio . '.docx');
     return true;
 }
コード例 #6
0
ファイル: Word.php プロジェクト: nhatlang19/elearningONL
 function importFromDocx($filename)
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $document = $phpWord->loadTemplate($filename);
     // check valid
     $rows = $document->getContentTable();
     if (count($rows) % NUMBER_LINE_A_QUESTION == 0) {
         return $rows;
     }
     return null;
 }
コード例 #7
-1
ファイル: RTipoDocumento.php プロジェクト: hcvcastro/pxp
 function write($fileName)
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     //echo dirname(__FILE__).'/'.$this->plantilla;exit;
     $document = $phpWord->loadTemplate(dirname(__FILE__) . '/' . $this->plantilla);
     setlocale(LC_ALL, "es_ES@euro", "es_ES", "esp");
     //var_dump($this->dataSource);
     foreach ($this->dataSource->getParameters() as $col => $val) {
         //echo 'kkk:'. $col .' '.$val;
         $document->setValue($col, $val);
         // On section/content
     }
     //echo 'iiiiiooooooo: '.$fileName;exit;
     $document->saveAs($fileName);
 }