Пример #1
5
 public function generateDOC($html)
 {
     $objPHPWord = new PhpWord();
     // Create new PHPWord object
     $section = $objPHPWord->addSection();
     Html::addHtml($section, $html, true);
     $objWriter = IOFactory::createWriter($objPHPWord, 'Word2007');
     ob_start();
     $objWriter->save('php://output');
     $contents = ob_get_clean();
     return $contents;
 }
 /**
  * Create word file using phpWord library
  *
  * @param array $text
  * @param       $file
  * @return string
  * @throws \PhpOffice\PhpWord\Exception\Exception
  */
 public function createDocx(array $text, $file)
 {
     $file_path = public_path($file);
     $phpWord = new PhpWord();
     foreach ($text as $page) {
         $section = $phpWord->addSection();
         $page = $this->escape($page);
         Html::addHtml($section, $page);
     }
     $objWriter = IOFactory::createWriter($phpWord, 'Word2007');
     $objWriter->save($file_path);
     return $file_path;
 }
Пример #3
1
function exportWord($text, $font, $size, $bold)
{
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->addSection();
    //
    //    $section->addText($text);
    //
    //    $section->addText('Hello world! I am formatted.',
    //        array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
    //    $phpWord->addFontStyle('myOwnStyle',
    //        array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
    //    $section->addText('Hello world! I am formatted by a user defined style',
    //        'myOwnStyle');
    $fontStyle = new \PhpOffice\PhpWord\Style\Font();
    $fontStyle->setBold($bold);
    $fontStyle->setName($font);
    $fontStyle->setSize($size);
    $myTextElement = $section->addText($text);
    $myTextElement->setFontStyle($fontStyle);
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    $objWriter->save('helloWorld.docx');
}
Пример #4
0
 /**
  * @param object|string $phpWord
  * @param string $ext
  * @param string $fileName
  */
 public static function printDoc($phpWord, $ext, $fileName)
 {
     $formats = array('docx' => 'Word2007', 'odt' => 'ODText', 'html' => 'HTML', 'pdf' => 'PDF');
     if (realpath($phpWord)) {
         $phpWord = \PhpOffice\PhpWord\IOFactory::load($phpWord, $formats[$ext]);
     }
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $formats[$ext]);
     CRM_Utils_System::setHttpHeader('Content-Type', "application/{$ext}");
     CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"');
     $objWriter->save("php://output");
 }
Пример #5
0
 /**
  * Get document content
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @param string $writerName
  * @return \PhpOffice\PhpWord\Tests\XmlDocument
  */
 public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')
 {
     self::$file = tempnam(sys_get_temp_dir(), 'PhpWord');
     if (!is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) {
         mkdir(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
     }
     $xmlWriter = IOFactory::createWriter($phpWord, $writerName);
     $xmlWriter->save(self::$file);
     $zip = new \ZipArchive();
     $res = $zip->open(self::$file);
     if ($res === true) {
         $zip->extractTo(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
         $zip->close();
     }
     return new XmlDocument(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
 }
Пример #6
0
/**
 * Write documents
 *
 * @param \PhpOffice\PhpWord\PhpWord $phpWord
 * @param string $filename
 * @param array $writers
 */
function write($phpWord, $filename, $writers)
{
    $result = '';
    // Write documents
    foreach ($writers as $writer => $extension) {
        $result .= date('H:i:s') . " Write to {$writer} format";
        if (!is_null($extension)) {
            $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
            $xmlWriter->save("{$filename}.{$extension}");
            rename("{$filename}.{$extension}", "results/{$filename}.{$extension}");
        } else {
            $result .= ' ... NOT DONE!';
        }
        $result .= EOL;
    }
    $result .= getEndingNotes($writers);
    return $result;
}
Пример #7
0
 /**
  * Get document content
  *
  * @since 0.12.0 Throws CreateTemporaryFileException.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @param string $writerName
  *
  * @return \PhpOffice\PhpWord\Tests\XmlDocument
  *
  * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
  */
 public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')
 {
     self::$file = tempnam(Settings::getTempDir(), 'PhpWord');
     if (false === self::$file) {
         throw new CreateTemporaryFileException();
     }
     if (!is_dir(Settings::getTempDir() . '/PhpWord_Unit_Test/')) {
         mkdir(Settings::getTempDir() . '/PhpWord_Unit_Test/');
     }
     $xmlWriter = IOFactory::createWriter($phpWord, $writerName);
     $xmlWriter->save(self::$file);
     $zip = new \ZipArchive();
     $res = $zip->open(self::$file);
     if (true === $res) {
         $zip->extractTo(Settings::getTempDir() . '/PhpWord_Unit_Test/');
         $zip->close();
     }
     return new XmlDocument(Settings::getTempDir() . '/PhpWord_Unit_Test/');
 }
Пример #8
0
 public function prepare()
 {
     $file = path('tmp') . sha1(microtime());
     $lines = $this->getData();
     $phpWord = new PhpWord();
     $section = $phpWord->addSection(['orientation' => 'landscape']);
     /**
      * Make header
      */
     $table = $section->addTable(['width' => 100 * 50]);
     $i = 0;
     $j = 0;
     $table->addRow();
     foreach ($lines[0] as $key => $val) {
         $table->addCell(1750)->addText($key);
         $j++;
     }
     /**
      * Make data
      */
     foreach ($lines as $line) {
         $i++;
         $j = 0;
         $table->addRow();
         foreach ($line as $val) {
             $table->addCell(1750)->addText($val);
             $j++;
         }
     }
     /**
      * Save file.
      */
     $objWriter = IOFactory::createWriter($phpWord, 'Word2007');
     $objWriter->save($file);
     /**
      * Implement strategy.
      */
     $this->setFileContent(file_get_contents($file));
     unlink($file);
 }
Пример #9
0
 /**
  * 生成简历文件字符串
  * @param $sp_id 快照主键
  * @param string $type 类型 doc/doc_no_contact(隐藏了联系方式)
  */
 public function getDocFileStr($id, $type = 'doc_no_contact')
 {
     $sp_model = new ResumeSnapshot();
     $sp_info = $sp_model->getResumeSnapshotInfoById($id);
     //根据简历快照生成word
     $phpWord = new PhpWord();
     // New portrait section
     $section = $phpWord->addSection();
     // Add header for all other pages //todo logo图片需传到线上
     $subsequent = $section->addHeader();
     $subsequent->addText(htmlspecialchars('51CTO高招-中高端IT人才的招聘平台'));
     $subsequent->addImage('http://job.51cto.com/pic/logo_s.jpg', array('width' => 80, 'height' => 80, 'align' => 'right'));
     ////        $section = $phpWord->addSection();
     //        $html = '<h1>Adding element via HTML</h1>';
     //        $html .= '<p>Some well formed HTML snippet needs to be used</p>';
     //        $html .= '<p>With for example <strong>some<sup>1</sup> <em>inline</em> formatting</strong><sub>1</sub></p>';
     //        $html .= '<p>Unordered (bulleted) list:</p>';
     //        $html .= '<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>';
     //        $html .= '<p>Ordered (numbered) list:</p>';
     //        $html .= '<ol><li>Item 1</li><li>Item 2</li></ol>';
     //
     //        \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
     $section = $phpWord->addSection();
     $header = array('size' => 16, 'bold' => true);
     //1.Use EastAisa FontStyle
     $section->addText(htmlspecialchars('邵燕'), array('name' => '微软雅黑', 'size' => '二号', 'color' => '1B2232'));
     $section->addText(htmlspecialchars('邵燕'), array('name' => '微软雅黑', 'size' => '二号', 'color' => '1B2232'));
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
     $rand = time() . rand(10000, 99999);
     $file = WEB_ROOT . "/runtime/{$rand}.docx";
     //临时文件
     $file = WEB_ROOT . "/runtime/test.docx";
     //临时文件
     $objWriter->save($file, 'Word2007', true);
     //        $file_str = file_get_contents($file);
     //        unlink($file);//删除文件
     //
     //        return $file_str;
 }
Пример #10
0
 /**
  * Download file from PHPWord instance
  * @param PHPWord $phpWord reference to phpWord
  * @param string $fileName file name
  * @param string $format file save format
  */
 public function download(PHPWord &$phpWord, $fileName, $format = 'Word2007')
 {
     if (!in_array($format, array_keys(static::$map))) {
         $format = $this->defaultFormat;
     }
     $fileName .= '.' . static::$map[$format];
     header('Content-Type: ' . FileHelper::getMimeTypeByExtension($fileName));
     header('Content-Disposition: attachment;filename="' . $fileName . '"');
     header('Cache-Control: max-age=0');
     header('Cache-Control: max-age=1');
     // If you're serving to IE 9, then the following may be needed
     // If you're serving to IE over SSL, then the following may be needed
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     // always modified
     header('Cache-Control: cache, must-revalidate');
     // HTTP/1.1
     header('Pragma: public');
     // HTTP/1.0
     $writer = IOFactory::createWriter($phpWord, $format);
     $writer->save('php://output');
     Yii::$app->end();
 }
 /**
  * Save to file or download
  *
  * All exceptions should already been handled by the writers
  *
  * @param string $filename
  * @param string $format
  * @param bool $download
  * @return bool
  */
 public function save($filename, $format = 'Word2007', $download = false)
 {
     $mime = array('Word2007' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'ODText' => 'application/vnd.oasis.opendocument.text', 'RTF' => 'application/rtf', 'HTML' => 'text/html', 'PDF' => 'application/pdf');
     $writer = IOFactory::createWriter($this, $format);
     if ($download === true) {
         header("Content-Description: File Transfer");
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Content-Type: ' . $mime[$format]);
         header('Content-Transfer-Encoding: binary');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Expires: 0');
         $filename = 'php://output';
         // Change filename to force download
     }
     $writer->save($filename);
     return true;
 }
Пример #12
0
        $string = gmdate('Y-m-d H:i:s') . " item.create webhook received. ";
        $string .= "Post params: " . print_r($_POST, true) . "\n";
        $item_id = (int) $_POST['item_id'];
        // get item
        $item = PodioItem::get($item_id);
        $item_file = $item->files[0];
        $file = PodioFile::get($item_file->file_id);
        $mimetype = $file->mimetype;
        // validate mime and get reader
        $reader_name = $controller->getReaderByMime($mimetype);
        if ($reader_name) {
            file_put_contents(__DIR__ . '/temp/' . $item_file->name, $file->get_raw());
            $file_name_exploded = explode('.', $item_file->name);
            $file_name_no_ext = $file_name_exploded[0];
            $controller->init_pdf_renderer();
            \PhpOffice\PhpWord\Autoloader::register();
            // Creating the new document...
            $phpWord = new \PhpOffice\PhpWord\PhpWord();
            // Read contents
            $source = __DIR__ . '/temp/' . $item_file->name;
            $phpWord = \PhpOffice\PhpWord\IOFactory::load($source, $reader_name);
            //Save pdf file
            $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');
            $xmlWriter->save(__DIR__ . '/temp/' . $file_name_no_ext . '.pdf');
            $uploadedFile = PodioFile::upload(__DIR__ . '/temp/' . $file_name_no_ext . '.pdf', $file_name_no_ext . '.pdf');
            PodioFile::attach($uploadedFile->file_id, array('ref_type' => 'item', 'ref_id' => $item_id));
        }
        // log request
        file_put_contents($file, $string, FILE_APPEND | LOCK_EX);
        break;
}
Пример #13
0
 $resultado = move_uploaded_file($tmp_name, $ruta);
 if ($resultado) {
     //$insertar = llamada  a la bd
     echo date('H:i:s'), "Silabus guardado correctamente<br>";
     $uploadOk = true;
     if ($extension == "docx") {
         echo date('H:i:s'), " Leyendo archivo de `{$ruta}`";
         $phpWord = \PhpOffice\PhpWord\IOFactory::load($ruta);
         $writers = array('HTML' => 'html');
         //'Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf',
         foreach ($writers as $writer => $extension) {
             echo date('H:i:s'), " Convirtiendo a formato {$writer} <br>";
             if (file_exists($carpeta . "/{$id_curso}.{$extension}")) {
                 echo "El archivo ya existe.<br>";
             } else {
                 $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
                 $xmlWriter->save("temporal.{$extension}");
                 rename("{$id_curso}.{$extension}", "{$carpeta}/{$id_curso}.{$extension}");
             }
         }
     }
     echo date('H:i:s'), " Leyendo archivo html <br><br>";
     //Agregar codigo de captura de datos
     $url = $carpeta . "/" . $_REQUEST['idcurso'] . ".html";
     $html = file_get_contents($url);
     $dom = new domDocument();
     $dom->loadHTML($html);
     /*** eliminar espacios en blanco ***/
     $dom->preserveWhiteSpace = false;
     $ps = $dom->getElementsByTagName('p');
     /*** obteniendo todas las tablas ***/
Пример #14
0
function make_word_doc($doc, $dir)
{
    /**
    * uses the $doc object to create a new word doc whose name is sent back to hte client where an <iframe> downloads it
    *
    * @since 1.0
    *
    * @caller user action
    * @ingroup editor
    *
    * @param object $doc created in js - a big object w all the info needed
    * @param string $dir the directory name to add the .doc
    * @return echos the word doc's name
    */
    // make the a new instance of a phpword
    // you will add all the info to this
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $i = 0;
    $l = count($doc) - 1;
    // loop through each page in the doc
    // each page is a 'section'
    for ($i; $i < $l; $i = $i + 1) {
        $Paragraphs = $doc['Page' . $i];
        $ii = 0;
        $ll = count($Paragraphs) - 1;
        ${"page_" . $i} = $phpWord->addSection();
        $Page = ${"page_" . $i};
        // in each page loop through each paragraph
        // style the the paragraph's alignment
        for ($ii; $ii < $ll; $ii = $ii + 1) {
            $Spans = $Paragraphs['Paragraph' . $ii];
            $iii = 0;
            $lll = count($Spans) - 1;
            ${"paragraph_" . $i . '_' . $ii} = $Page->addTextRun(array('align' => $Spans['align']));
            $Paragraph = ${"paragraph_" . $i . '_' . $ii};
            // loop through each text span
            for ($iii; $iii < $lll; $iii = $iii + 1) {
                $Span = $Spans['Span' . $iii];
                // create the style info for the text span
                $Style = array('name' => $Span['Styles']['name'], 'size' => intval($Span['Styles']['size']), 'bold' => filter_var($Span['Styles']['bold'], FILTER_VALIDATE_BOOLEAN), 'italic' => filter_var($Span['Styles']['italic'], FILTER_VALIDATE_BOOLEAN), 'color' => $Span['Styles']['color'], 'fgColor' => $Span['Styles']['fgColor']);
                // add the text span with it's style to the paragraph
                $Paragraph->addText($Span['text'], $Style);
            }
        }
    }
    // assign it as a word doc
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    // create an empty word doc file w. the new file name
    $pathAndFile = $dir . '/' . $doc['title'] . '.docx';
    // save the file with content included
    $objWriter->save($pathAndFile);
    // return the .doc's title so it can be downloaded
    echo $doc['title'] . '.docx';
    die;
}
Пример #15
0
 /**
  * @Security("has_role('ROLE_USER')")
  */
 private function downloadQRCodeFile(Rucher $rucher, $ruches)
 {
     //Création de l'objet phpWord pour le fichier word
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     //Création du path pour gérer les fichiers temporaires
     $path = $this->get('kernel')->getRootDir() . "/../web/generate/";
     //Ajout d'une section
     $section = $phpWord->addSection();
     //Ajout d'un en-tête
     $phpWord->addFontStyle('eStyle', array('bold' => true, 'size' => 16));
     $phpWord->addFontStyle('rStyle', array('size' => 14));
     $header = $section->addHeader();
     $headerTable = $header->addTable();
     $headerTable->addRow();
     $headerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5))->addImage('logo.png', array('height' => 80));
     $cellText = $headerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(11));
     $cellText->addText(htmlspecialchars($rucher->getExploitation()->getNom()), 'eStyle', array('align' => 'right'));
     $cellText->addText(htmlspecialchars($rucher->getNom()), 'rStyle', array('align' => 'right'));
     //Ajout d'un pied de page
     $footer = $section->addFooter();
     $footer->addPreserveText(htmlspecialchars('{PAGE}/{NUMPAGES}'), null, array('align' => 'right'));
     //Création du style des cellules
     $cellStyle = array('valign' => 'center');
     $phpWord->addFontStyle('qStyle', array('size' => 12));
     //Ajout de la table contenant les qr codes
     $table = $section->addTable();
     //Nombre de ruches dans le fichier, utile pour créer une nouvelle ligne
     $nbRuches = 0;
     foreach ($ruches as $ruche) {
         //3 QRCodes par ligne
         if ($nbRuches % 3 === 0) {
             $table->addRow(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5.5));
         }
         $nbRuches++;
         //Construction de l'url pour accéder à la ruche
         $url = $this->generateUrl('kg_beekeeping_management_view_ruche', array('ruche_id' => $ruche->getId()), true);
         //Construction du QRCode pointant sur l'url de la ruche
         $options = array('code' => $url, 'type' => 'qrcode', 'format' => 'png');
         $barcode = $this->get('sgk_barcode.generator')->generate($options);
         //Path du fichier avec le QRCode
         $filename = 'qrcode' . $ruche->getId() . '.png';
         //Sauvegarde du fichier
         file_put_contents($path . $filename, base64_decode($barcode));
         //Ajout du QRCode dans le fichier ODT
         $cell = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5.33), $cellStyle);
         $cell->addText(htmlspecialchars($ruche->getNom()), 'qStyle', array('align' => 'center'));
         $cell->addImage('generate/' . $filename, array('width' => 151.18, 'height' => 151.18, 'wrappingStyle' => 'behind', 'align' => 'center'));
     }
     //Ajout de cellules vides si ligne incomplète
     $reste = 3 - $nbRuches % 3;
     if ($reste < 3) {
         while ($reste > 0) {
             $cell = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5.33), $cellStyle);
             $reste--;
         }
     }
     //Sauvegarde du fichier ODT
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
     $filename = $rucher->getId() . '_qr_codes_rucher_' . $rucher->getNom() . '.docx';
     $objWriter->save($path . $filename, 'Word2007', true);
     //Récupération du contenu du fichier
     $content = file_get_contents($path . $filename);
     //Création de la réponse avec le contentu du fichier (pour le download)
     $response = new Response();
     $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
     $response->headers->set('Content-Disposition', 'attachment;filename="' . $filename);
     $response->setContent($content);
     //Suppression des fichiers créés durant la création du fichier word
     unlink($path . $filename);
     foreach ($ruches as $ruche) {
         $filename = 'qrcode' . $ruche->getId() . '.png';
         unlink($path . $filename);
     }
     //Retour de la réponse
     return $response;
 }
Пример #16
0
 /**
  * @Then it should be the same as :document
  */
 public function itShouldBeTheSameAs($document)
 {
     $writer = \PhpOffice\PhpWord\IOFactory::createWriter($this->phpword, 'Word2007');
     $writer->save($this->getFilename($document));
     throw new PendingException();
 }
function ciniki_conferences_conferenceScheduleDownload($ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.conferenceScheduleDownload');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree');
    //
    // Load business settings
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings');
    $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $intl_timezone = $rc['settings']['intl-default-timezone'];
    $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY);
    $intl_currency = $rc['settings']['intl-default-currency'];
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'timeFormat');
    $date_format = ciniki_users_dateFormat($ciniki, 'php');
    $time_format = ciniki_users_timeFormat($ciniki, 'php');
    $mysql_date_format = ciniki_users_dateFormat($ciniki, 'mysql');
    //
    // Load conference maps
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'maps');
    $rc = ciniki_conferences_maps($ciniki);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $maps = $rc['maps'];
    $strsql = "SELECT ciniki_conferences.id, " . "ciniki_conferences.name, " . "ciniki_conferences.permalink, " . "ciniki_conferences.status, " . "ciniki_conferences.status AS status_text, " . "ciniki_conferences.flags, " . "DATE_FORMAT(ciniki_conferences.start_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS start_date, " . "DATE_FORMAT(ciniki_conferences.end_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS end_date, " . "ciniki_conferences.synopsis, " . "ciniki_conferences.description, " . "ciniki_conferences.imap_mailbox, " . "ciniki_conferences.imap_username, " . "ciniki_conferences.imap_password, " . "ciniki_conferences.imap_subject " . "FROM ciniki_conferences " . "WHERE ciniki_conferences.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences.id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference');
    if ($rc['stat'] != 'ok') {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3631', 'msg' => 'Conference not found', 'err' => $rc['err']));
    }
    if (!isset($rc['conference'])) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3632', 'msg' => 'Unable to find Conference'));
    }
    $conference = $rc['conference'];
    if (isset($maps['conference']['status'][$conference['status_text']])) {
        $conference['status_text'] = $maps['conference']['status'][$conference['status_text']];
    }
    $strsql = "SELECT ciniki_conferences_sessions.id, " . "CONCAT_WS('-', ciniki_conferences_sessions.id, ciniki_conferences_presentations.id) AS rowid, " . "ciniki_conferences_sessions.conference_id, " . "ciniki_conferences_sessions.room_id, " . "ciniki_conferences_rooms.name AS room, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_sessions.name, " . "ciniki_conferences_sessions.session_start AS start_time, " . "ciniki_conferences_sessions.session_start AS start_date, " . "ciniki_conferences_sessions.session_end AS end_time, " . "IFNULL(ciniki_conferences_presentations.id, 0) AS presentation_id, " . "IFNULL(ciniki_conferences_presentations.customer_id, 0) AS customer_id, " . "IFNULL(ciniki_conferences_presentations.presentation_number, '') AS presentation_number, " . "IFNULL(ciniki_conferences_presentations.title, '') AS presentation_title, " . "IFNULL(ciniki_conferences_presentations.description, '') AS presentation_description, " . "IFNULL(ciniki_customers.display_name, '') AS display_name, " . "IFNULL(ciniki_conferences_presentations.status, 0) AS status, " . "IFNULL(ciniki_conferences_presentations.status, '') AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text " . "FROM ciniki_conferences_sessions " . "INNER JOIN ciniki_conferences_rooms ON (" . "ciniki_conferences_sessions.room_id = ciniki_conferences_rooms.id " . "AND ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_presentations ON (" . "ciniki_conferences_sessions.id = ciniki_conferences_presentations.session_id " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY ciniki_conferences_sessions.session_start, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_presentations.title " . "";
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree');
    $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'times', 'fname' => 'start_time', 'fields' => array('start_time', 'start_date', 'end_time'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone))), array('container' => 'rooms', 'fname' => 'room_id', 'fields' => array('id' => 'room_id', 'name' => 'room', 'session_name' => 'name', 'presentation_id')), array('container' => 'presentations', 'fname' => 'presentation_id', 'fields' => array('id', 'conference_id', 'room_id', 'room', 'sequence', 'name', 'start_time', 'start_date', 'end_time', 'presentation_id', 'customer_id', 'presentation_number', 'presentation_title', 'presentation_description', 'display_name', 'status', 'status_text', 'registration', 'registration_text'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone)), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status']))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (isset($rc['times'])) {
        $timeslots = $rc['times'];
    } else {
        $timeslots = array();
    }
    //
    // Generate the word file
    //
    require_once $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/Autoloader.php';
    \PhpOffice\PhpWord\Autoloader::register();
    require $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/PhpWord.php';
    $PHPWord = new \PhpOffice\PhpWord\PhpWord();
    $PHPWord->addTitleStyle(1, array('bold' => true, 'size' => 18), array('spaceBefore' => 240, 'spaceAfter' => 120));
    $PHPWord->addTitleStyle(2, array('bold' => true, 'size' => 16), array('spaceBefore' => 120, 'spaceAfter' => 120));
    $PHPWord->addTitleStyle(3, array('bold' => false, 'size' => 14), array('spaceBefore' => 120, 'spaceAfter' => 120));
    $style_table = array('cellMargin' => 80, 'borderColor' => 'aaaaaa', 'borderSize' => 6);
    $style_header = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'bgColor' => 'dddddd', 'valign' => 'center');
    $style_cell = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'valign' => 'center', 'bgcolor' => 'ffffff');
    $style_header_font = array('bold' => true, 'spaceAfter' => 20);
    $style_cell_font = array();
    $style_header_pleft = array('align' => 'left');
    $style_header_pright = array('align' => 'right');
    $style_cell_pleft = array('align' => 'left');
    $style_cell_pright = array('align' => 'right');
    $section = $PHPWord->addSection();
    $header = $section->addHeader();
    $table = $header->addTable();
    $table->addRow();
    $cell = $table->addCell(9600);
    $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center'));
    //print "<pre>" . print_r($timeslots, true) . "</pre>";
    //exit;
    //
    // Create a table with a row for each time slot
    //
    $cur_date = '';
    $table = $section->addTable($style_table);
    $session_number = 1;
    foreach ($timeslots as $timeslot) {
        //
        // Add the date as a header
        //
        if ($timeslot['start_date'] != $cur_date) {
            $table->addRow();
            $cell = $table->addCell(1500, $style_cell);
            $cell->addText($timeslot['start_date']);
            $cell->setGridSpan(2);
            $cur_date = $timeslot['start_date'];
            //            $session_number = 1;
        }
        //
        // Add the time slot
        //
        $table->addRow();
        $cell = $table->addCell(1500, $style_cell);
        $cell->addText($timeslot['start_time'] . ' - ' . $timeslot['end_time'], $style_cell_font);
        $nonsession_info = array();
        $session_info = array();
        if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) {
            foreach ($timeslot['rooms'] as $room) {
                if (!isset($room['presentations']) || $room['presentation_id'] == 0) {
                    if (isset($room['presentations'][0])) {
                        $session = $room['presentations'][0];
                        if ($session['name'] != '') {
                            $nonsession_info[] = $session['name'];
                        }
                    }
                    $nonsession_info[] = "Location: " . $room['name'];
                } else {
                    $session_info[] = $session_number . ". " . $room['session_name'] . ": ";
                    $presentation_number = 1;
                    $presentation_info = '';
                    foreach ($room['presentations'] as $presentation) {
                        if ($presentation_number > 1) {
                            $presentation_info .= "; ";
                        }
                        $presentation_info .= $presentation_number . ") " . $presentation['display_name'];
                        $presentation_number++;
                    }
                    $session_info[] = $presentation_info;
                    $session_info[] = "Location: " . $room['name'];
                    $session_info[] = "";
                    $session_number++;
                }
            }
        }
        $cell = $table->addCell(2500, $style_cell);
        foreach ($nonsession_info as $line) {
            $cell->addText($line, $style_cell_font);
        }
        $cell = $table->addCell(5500, $style_cell);
        foreach ($session_info as $line) {
            $cell->addText($line, $style_cell_font);
        }
    }
    $section = $PHPWord->addSection();
    $header = $section->addHeader();
    $table = $header->addTable();
    $table->addRow();
    $cell = $table->addCell(9600);
    $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center'));
    $session_number = 1;
    foreach ($timeslots as $timeslot) {
        if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) {
            foreach ($timeslot['rooms'] as $room) {
                if (!isset($room['presentations']) || $room['presentation_id'] == 0) {
                    continue;
                }
                $section->addTitle($session_number . ". " . $room['session_name'], 1);
                if (isset($room['presentations']) && $room['presentation_id'] != 0) {
                    foreach ($room['presentations'] as $pid => $presentation) {
                        $section->addTitle($presentation['display_name'], 2);
                        $section->addTitle(htmlspecialchars($presentation['presentation_title']), 3);
                        $lines = explode("\n", $presentation['presentation_description']);
                        foreach ($lines as $line) {
                            $section->addText(htmlspecialchars($line), array());
                        }
                        $section->addText('');
                    }
                }
                $session_number++;
            }
        }
    }
    //
    // Output the word file
    //
    header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
    header('Content-Disposition: attachment;filename="' . preg_replace("/[^A-Za-z0-9]/", '', $conference['name']) . '.docx"');
    header('Cache-Control: max-age=0');
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007');
    $objWriter->save('php://output');
    return array('stat' => 'exit');
}
Пример #18
0
	function write($phpWord, $filename, $writers,$target_path)
	{
		$result = '';
		foreach ($writers as $writer => $extension) {
			$result .= date('H:i:s') . " Write to {$writer} format";
			if (!is_null($extension)) {
				$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
				$xmlWriter->save($tmp_path . "/{$filename}.{$extension}");
				$result = true;
			} else {
				$result = false;
			}
		}
		return $result;
	}
Пример #19
0
    protected function convertImpl($text)
    {
        $descr['book_title'] = $this->nameru;
        $descr['author'] = "";
        foreach ([$this->author, $this->illustrator] as $aut) {
            if ($aut) {
                foreach (explode(',', $aut) as $au) {
                    $a = explode(' ', trim($au));
                    $descr['author'] = (isset($descr['author']) ? $descr['author'] : '') . "<h1>";
                    $descr['author'] .= $this->escapexml(trim($au));
                    $descr['author'] .= "</h1>";
                }
            }
        }
        $descr['annotation'] = '';
        if ($this->annotation) {
            $this->annotation = preg_replace('@\\n@', '</p><p>', $this->annotation);
            $this->annotation = preg_replace("@'''(.*?)'''@", '<b>\\1</b>', $this->annotation);
            $this->annotation = preg_replace("@''(.*?)''@", '<i>\\1</i>', $this->annotation);
            $this->annotation = preg_replace('@<p></p>@', '<br/>', $this->annotation);
            $descr['annotation'] = "<h2>Аннотация</h2><p>{$this->annotation}</p>";
        }
        $descr['coverpage'] = '';
        $images = [];
        if ($this->covers) {
            $innerHeight = $this->height;
            $cover = $this->covers[0];
            $image = $this->images[$cover];
            /* Width and height are unimportant. Actual resizing is done not in this class. We must save aspect ratio though. */
            $descr['coverpage'] = "<img src=\"" . $image['thumbnail'] . "\" width=\"" . $image['convert_width'] . "\" height=\"" . $image['convert_height'] . "\" />";
            $images[] = $cover;
            $descr['coverpage_n'] = $cover;
        }
        //	echo $descr['coverpage'];
        //		exit;
        if ($this->translators) {
            foreach ($this->translators as $translator) {
                if (!array_key_exists('translator', $descr)) {
                    $descr['translator'] = '';
                }
                $descr['translator'] .= "<p name=\"translator\">" . $this->escapexml($translator) . "</p>";
            }
        }
        if ($this->seriestitle) {
            $descr['sequence'] = "<h1>" . $this->escapexml($this->seriestitle) . ($this->seriesnum ? " {$this->seriesnum}" : '') . " </h1>";
        }
        $descr['date2'] = date('j F Y, H:i', $this->touched);
        $descr['id'] = 'RuRa_' . str_replace('/', '_', $this->nameurl);
        if ($this->isbn) {
            $descr['isbn'] = ";isbn:{$this->isbn}";
        }
        if ($this->command == 'RuRa-team') {
            $credit = "<h2>Реквизиты переводчиков</h2>\n \t\t\t\t         <p>Над переводом работала команда <b>RuRa-team</b></p>\n";
            foreach ($this->workers as $activity => $workers) {
                $credit .= '<p>' . $activity . ': <b>' . implode('</b>, <b>', $workers) . "</b></p>\n";
            }
            $credit .= '<p>Самый свежий перевод всегда можно найти на сайте нашего проекта:</p>
				          <p><a href="http://ruranobe.ru">http://ruranobe.ru</a></p>
 				          <p>Чтобы оставаться в курсе всех новостей, вступайте в нашу группу в Контакте:</p>
				          <p><a href="http://vk.com/ru.ranobe">http://vk.com/ru.ranobe</a></p>
						  <p>Для желающих отблагодарить переводчика материально имеются webmoney-кошельки команды:</p>
						  <p><b>R125820793397</b></p>
						  <p><b>U911921912420</b></p>
						  <p><b>Z608138208963</b></p>
						  <p>QIWI-кошелек:</p>
						  <p><b>+79116857099</b></p>
						  <p>Яндекс-деньги:</p>
						  <p><b>410012692832515</b></p>
                          <p>PayPal:</p>
                          <p><b>paypal@ruranobe.ru</b></p>
						  <p>А так же счет для перевода с кредитных карт:</p>
						  <p><b>4890 4941 5384 9302</b></p>
						  <p>Версия от ' . date('d.m.Y', $this->touched) . '</p>
						  <p></p>
						  <p></p>
						  <p></p>
						  <p><b>Любое распространение перевода за пределами нашего сайта запрещено. Если вы скачали файл на другом сайте - вы поддержали воров</b></p>
						  <p></p>
						  <p></p>
						  <p></p>';
        } elseif (strpos($this->command, 'RuRa-team') !== false) {
            $credit = "<h2>Реквизиты переводчиков</h2>\n\t\t\t\t\t\t <p>Над релизом работали {$this->command}</p>\n";
            foreach ($this->workers as $activity => $workers) {
                $credit .= '<p>' . $activity . ': <b>' . implode('</b>, <b>', $workers) . "</b></p>\n";
            }
            $credit .= '<p>Самый свежий перевод всегда можно найти на сайте нашего проекта:</p>
						  <p><a l:href="http://ruranobe.ru">http://ruranobe.ru</a></p>
						  <p>Чтобы оставаться в курсе всех новостей, вступайте в нашу группу в Контакте:</p>
						  <p><a l:href="http://vk.com/ru.ranobe">http://vk.com/ru.ranobe</a></p>
						  <p>Версия от ' . date('d.m.Y', $this->touched) . '</p>
						  <p><b>Любое коммерческое использование данного текста или его фрагментов запрещено</b></p>';
        } else {
            $credit = "<h2>Реквизиты переводчиков</h2>";
            if ($this->command) {
                $credit .= "<p>Перевод команды {$this->command}</p>";
            }
            foreach ($this->workers as $activity => $workers) {
                $credit .= '<p>' . $activity . ': <b>' . implode('</b>, <b>', $workers) . "</b></p>\n";
            }
            $credit .= '<p>Версия от ' . date('d.m.Y', $this->touched) . '</p>
						  <p><b>Любое коммерческое использование данного текста или его фрагментов запрещено</b></p>';
        }
        if ($this->height == 0) {
            $text = preg_replace('/(<p[^>]*>)?<img[^>]*>(<\\/p>)?/u', '', $text);
        } else {
            for ($i = 1; $i < count($this->covers); ++$i) {
                $image = $this->images[$this->covers[$i]];
                $text = "<img src=\"" . $image['thumbnail'] . "\" width=\"" . $image['convert_width'] . "\" height=\"" . $image['convert_height'] . "\" />" . $text;
            }
            $text = preg_replace_callback('/(<a[^>]*>)?<img[^>]*data-resource-id="(-?\\d*)"[^>]*>(<\\/a>)?/u', function ($match) use(&$images) {
                if ($match[2] < 0) {
                    return '';
                }
                $image = $this->images[$match[2]];
                /* Width and height are unimportant. Actual resizing is done not in this class. We must save aspect ratio though. */
                return "<img src=\"" . $image['thumbnail'] . "\" width=\"" . $image['convert_width'] . "\" height=\"" . $image['convert_height'] . "\" />";
            }, $text);
        }
        $footnotes = array();
        $footnotes_temp = explode(',;,', $this->footnotes);
        for ($i = 0; $i < sizeof($footnotes_temp); $i++) {
            if (is_numeric($footnotes_temp[$i])) {
                $footnotes[$footnotes_temp[$i]] = $footnotes_temp[$i + 1];
                $i++;
            }
        }
        $text = trim($text);
        $epubText = "<html>\n\t<body>\n\t\t{$descr['coverpage']}\n\t\t{$descr['author']}\n\t\t{$descr['sequence']}\n\t    {$descr['annotation']}\n\t\t{$credit}\n\t\t{$text}\n\t</body>\n\t</html>";
        $epubText = preg_replace_callback('@(<span[^>]*><a href="#cite_note-(\\d*)"[^>]*>.{0,15}</span>)@', function ($match) use(&$footnotes) {
            $footnote = $footnotes[$match[2]];
            $footnote = preg_replace('@</p>\\s*<p[^>]*>@', '<br/>', $footnote);
            if ($footnote) {
                return '<footnote>' . $footnote . '</footnote>';
            } else {
                return $match[1];
            }
        }, $epubText);
        //preg_replace('@cite_note-(\d*)@',"<footnote></footnote>", $epubText);
        //echo '<xmp>'.$epubText;
        //echo $footnotes[137603266];
        //exit;
        //echo '<xmp>'.$epubText;
        //exit;
        $epubText = preg_replace('@section@', "div", $epubText);
        /* Delete extra <br/> tag before images */
        $epubText = preg_replace('@<div>(.){0,20}<br\\/>(.){0,20}<img src@', '<div><img src', $epubText);
        /* Eliminate caret return before <h1> (Each div starts with caret return in h2d_htmlconverter.php) */
        $epubText = preg_replace('@\\s*<div>(.{0,40})(<h1>.*?<\\/h1>)@', '\\1\\2<div>', $epubText);
        /* NGNL Specific names */
        //$text=str_replace('<span style="position: relative; text-indent: 0;"><span style="display: inline-block; font-style: normal">&#12302;&#12288;&#12288;&#12288;&#12303;</span><span style="position: absolute; font-size: .7em; top: -11px; left: 50%"><span style="position: relative; left: -50%;">','&#12302;<sup>',$text);
        //$text=str_replace('</span></span></span>','</sup>&#12303;',$text);
        // Styles of elements in which footnote is nested should not count. Thus close them
        $epubText = preg_replace('@pb@', "br", $epubText);
        //echo '<xmp>'.$epubText;
        //exit;
        //PHPWord doesn't support tags nested in link element. Unnest images from them
        $epubText = preg_replace('@<a[^>]*>(<img[^>]*>)<\\/a>@', "\\1", $epubText);
        // Delete extra page breaks related to images.
        $epubText = preg_replace('@<div[^>]*>(.){0,20}(<img[^>]*>)(.){0,20}<\\/div>@', "\\1\\2\\3", $epubText);
        $epubText = preg_replace('@<p[^>]*>(.){0,20}(<img[^>]*>)(.){0,20}<\\/p>@', "\\1\\2\\3", $epubText);
        /* Swap h2 and img tags if img follows h2. (It gave a bad look in docx). */
        $epubText = preg_replace('@(<h2>.{0,100}<\\/h2>)(<img[^>]*>)@', '\\2\\1', $epubText);
        /* After swap we often needs to further lift img tag in previous <div> or <p> tag */
        $epubText = preg_replace('@<\\/div>(<img[^>]*>)<h2@', '\\1</div><h2', $epubText);
        $epubText = preg_replace('@<\\/p>(<img[^>]*>)<h2@', '\\1</p><h2', $epubText);
        //echo '<xmp>'.$epubText;
        //exit;
        $phpword_object = new \PhpOffice\PhpWord\PhpWord();
        \PhpOffice\PhpWord\Settings::setCompatibility(false);
        $html_dom = new \simple_html_dom();
        $html_dom->load($epubText);
        $html_dom_array = $html_dom->find('html', 0)->children();
        $paths = htmltodocx_paths();
        $initial_state = ['phpword_object' => &$phpword_object, 'base_root' => $paths['base_root'], 'base_path' => $paths['base_path'], 'current_style' => ['size' => '11'], 'parents' => [0 => 'body'], 'list_depth' => 0, 'context' => 'section', 'pseudo_list' => true, 'pseudo_list_indicator_font_name' => 'Wingdings', 'pseudo_list_indicator_font_size' => '7', 'pseudo_list_indicator_character' => 'l ', 'table_allowed' => true, 'treat_div_as_paragraph' => true, 'structure_headings' => true, 'structure_document' => true, 'style_sheet' => htmltodocx_styles_example()];
        htmltodocx_insert_html($phpword_object, $html_dom_array[0]->nodes, $initial_state);
        //var_dump($html_dom_array[0]->nodes);
        //		exit;
        $html_dom->clear();
        unset($html_dom);
        $h2d_file_uri = tempnam(sys_get_temp_dir(), 'htd');
        /*if ($h2d_file_uri === false) {
              var_dump(sys_get_temp_dir());
          }*/
        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpword_object, 'Word2007');
        $objWriter->save($h2d_file_uri);
        $bin = file_get_contents($h2d_file_uri);
        unlink($h2d_file_uri);
        //echo 'sdfjnsdlkvjn';
        //exit;
        return $bin;
    }
 public function report($examinee_id)
 {
     \PhpOffice\PhpWord\Autoloader::register();
     $this->wordHandle = new \PhpOffice\PhpWord\PhpWord();
     $data = $this->getBasic($examinee_id);
     $chart = new WordChart();
     //----------------------------------------------------
     // layout
     $sectionStyle = array('borderColor' => '000000', 'borderSize' => 1, 'orientation' => 'portrait', 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.59), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.25), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.25), 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.25), 'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(21), 'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(29.7), 'headerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.5), 'footerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.75));
     //add section
     $section = $this->wordHandle->addSection($sectionStyle);
     $section->getStyle()->setPageNumberingStart(1);
     $header = $section->addHeader();
     $footer = $section->addFooter();
     $footer->addPreserveText('{PAGE}/{NUMPAGES}', array('size' => 10, 'color' => '000000'), array('alignment' => 'center', 'lineHeight' => 1));
     //set first logo pic
     $section->addImage('reportimage/logo.png', array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(6.88), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3.06), 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_LEFT, 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_OMARGIN, 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_OMARGIN));
     $section->addTextBreak(4, array('size' => 12), array('lineHeight' => 1.5));
     // set caption block
     $caption = $section->createTextrun();
     $caption->addImage('reportimage/fengmian.png', array('marginTop' => -1, 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToInch(1), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4.86), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4.06), 'wrappingStyle' => 'square'));
     $caption->addText('综合素质测评报告', array('color' => 'red', 'size' => 36));
     $section->addTextBreak(1, array('size' => '22'), array('lineHeight' => 1.5));
     //set examinee textrun
     $examineeinfotextrun = $section->addTextRun(array('borderTopSize' => 1, 'borderTopColor' => '000000', 'lineHeight' => 1.5, 'valign' => 'center'));
     $basicInfoFontStyle = array('size' => 14, 'bold' => true);
     $examineeinfotextrun->addTextBreak();
     $examineeinfotextrun->addText('测评对象: ' . $data['name'], $basicInfoFontStyle);
     $examineeinfotextrun->addTextBreak();
     $examineeinfotextrun->addText('性    别: ' . $data['sex'], $basicInfoFontStyle);
     $examineeinfotextrun->addTextBreak();
     $examineeinfotextrun->addText('出生年月: ' . $data['birth'], $basicInfoFontStyle);
     $examineeinfotextrun->addTextBreak();
     $examineeinfotextrun->addText('测试单位: 北京国合点金管理咨询有限公司', $basicInfoFontStyle);
     $examineeinfotextrun->addTextBreak();
     $examineeinfotextrun->addText('测试时间: ' . $data['test_date'], $basicInfoFontStyle);
     $section->addPageBreak();
     // Define the TOC font style
     $section->addText("目录", array('size' => 18, 'color' => 'red'), array('alignment' => 'center', 'lineHeight' => 1.5));
     $section->addTOC(array('size' => 14), \PhpOffice\PhpWord\Style\TOC::TABLEADER_LINE, 1, 3);
     $section->addPageBreak();
     // Add title styles
     $this->wordHandle->addTitleStyle(1, array('size' => 14, 'color' => 'red', 'bold' => true), array('lineHeight' => 1.5));
     $this->wordHandle->addTitleStyle(2, array('size' => 14, 'color' => 'blue', 'bold' => true), array('lineHeight' => 1.5));
     $this->wordHandle->addTitleStyle(3, array('size' => 14, 'color' => 'blue', 'bold' => true), array('lineHeight' => 1.5));
     $section->addTitle('一、个人情况综述', 1);
     $section->addTitle('个人信息', 2);
     $section->addListItem("姓名: " . $data['name'] . "(" . $data['sex'] . ")", 0, array('size' => 14), \PhpOffice\PhpWord\Style\ListItem::TYPE_SQUARE_FILLED, array('lineHeight' => 1.5));
     $section->addListItem("毕业院校: " . $data['school'] . $data['degree'], 0, array('size' => 14), \PhpOffice\PhpWord\Style\ListItem::TYPE_ALPHANUM, array('lineHeight' => 1.5));
     $section->addListItem("规定测试时间: 3小时", 0, array('size' => 14), \PhpOffice\PhpWord\Style\ListItem::TYPE_ALPHANUM, array('lineHeight' => 1.5));
     $section->addListItem("实际完成时间:" . $data['exam_time'], 0, array('size' => 14), \PhpOffice\PhpWord\Style\ListItem::TYPE_ALPHANUM, array('lineHeight' => 1.5));
     $section->addTitle('工作经历', 2);
     $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000', 'align' => 'center'));
     //判断工作经历是否为空
     if (empty($data['works'])) {
         $section->addText('空');
     } else {
         $row = $table->addRow(600);
         $row->addCell(2500, array('valign' => 'center'))->addText("工作单位", array('size' => 14), array('alignment' => 'center'));
         $row->addCell(2500, array('valign' => 'center'))->addText('部门', array('size' => 14), array('alignment' => 'center'));
         $row->addCell(2500, array('valign' => 'center'))->addText('职位', array('size' => 14), array('alignment' => 'center'));
         $row->addCell(2500, array('valign' => 'center'))->addText('工作时间', array('size' => 14), array('alignment' => 'center'));
         foreach ($data['works'] as $value) {
             $table->addRow(600);
             $table->addCell(2500, array('valign' => 'center'))->addText($value['employer'], array('size' => 14), array('alignment' => 'center'));
             $table->addCell(2500, array('valign' => 'center'))->addText($value['unit'], array('size' => 14), array('alignment' => 'center'));
             $table->addCell(2500, array('valign' => 'center'))->addText($value['duty'], array('size' => 14), array('alignment' => 'center'));
             $table->addCell(2500, array('valign' => 'center'))->addText($value['date'], array('size' => 14), array('alignment' => 'center'));
         }
     }
     $section->addTextBreak(1, array('size' => 14), array('lineHeight' => 1.5));
     $text = '    测试要求3小时,以' . $data['exam_time'] . '完成,' . $data['name'] . $data['exam_time_flag']['value'] . ',且回答' . $data['exam_auth_flag']['value'] . ',说明其阅读' . $data['exam_evalute'] . '。 ';
     $section->addText($text, array('size' => 14), array('lineHeight' => 1.5));
     $section->addTextBreak(1, array('size' => 14), array('lineHeight' => 1.5));
     $table = $section->addTable();
     $row = $table->addRow();
     $text = '    根据测试结果和综合统计分析,分别从职业心理、职业素质、职业心智、职业能力等做出系统评价,按优、良、中、差四个等级评分。综合得分:优秀率为' . $data['excellent_rate'][0] . '%,良好率为' . $data['excellent_rate'][1] . '%,中为' . $data['excellent_rate'][2] . '%,差为' . $data['excellent_rate'][3] . '%,综合发展潜质为' . $data['excellent_evaluate'] . ',如右图所示。 ';
     $row->addCell(7000)->addText($text, array('size' => 14), array('lineHeight' => 1.5));
     //add chart
     $fileName = $chart->barGraph_1($data['excellent_rate'], $examinee_id);
     if (file_exists($fileName)) {
         $row->addCell(3000)->addImage($fileName, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.77), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.48), 'wrappingStyle' => 'square'));
     }
     $section->addPageBreak();
     $section->addTitle('二、测评结果', 1);
     $section->addTitle('1、突出优势', 2);
     foreach ($data['advantage'] as $value) {
         $section->addTitle($value['chs_name'], 3);
         $children = explode(",", $value['children']);
         $count = count($children);
         $j = 0;
         $comments = array();
         foreach ($value['detail'] as $svalue) {
             $advantages = ChildIndexComment::findFirst(array('child_chs_name=?1 AND index_chs_name=?2', 'bind' => array(1 => $svalue['chs_name'], 2 => $value['chs_name'])))->advantage;
             $advantage = json_decode($advantages, true);
             $rand_key = array_rand($advantage);
             $convert_array = array('一', '二', '三');
             $comments[] = $convert_array[$j++] . $advantage[$rand_key];
         }
         $table = $section->addTable();
         $row = $table->addRow();
         $text_1 = "    本项内容共由" . $count . "项指标构成,满分10分。根据得分的高低排序,分析" . $data['name'] . "得分排在前三项具体特点为:";
         $text_2 = "。具体分布如右图所示: ";
         $textrun = $row->addCell(7000)->addTextRun(array('lineHeight' => 1.5));
         $textrun->addText($text_1, array('size' => 14));
         $textrun->addText(implode(';', $comments), array('size' => 14, 'bold' => true));
         $textrun->addText($text_2, array('size' => 14));
         //add chart
         $fileName = $chart->barGraph_2($value['detail'], $examinee_id, 'Cyan');
         if (file_exists($fileName)) {
             $row->addCell(3000)->addImage($fileName, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.77), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.48), 'wrappingStyle' => 'square'));
         }
         $section->addTextBreak();
     }
     $section->addTitle('2、需要改进方面', 2);
     foreach ($data['disadvantage'] as $value) {
         $section->addTitle($value['chs_name'], 3);
         $children = explode(",", $value['children']);
         $count = count($children);
         $j = 0;
         $comments = array();
         foreach ($value['detail'] as $svalue) {
             $advantages = ChildIndexComment::findFirst(array('child_chs_name=?1 AND index_chs_name=?2', 'bind' => array(1 => $svalue['chs_name'], 2 => $value['chs_name'])))->disadvantage;
             $advantage = json_decode($advantages, true);
             $rand_key = array_rand($advantage);
             $convert_array = array('一', '二', '三');
             $comments[] = $convert_array[$j++] . $advantage[$rand_key];
         }
         $table = $section->addTable();
         $row = $table->addRow();
         $text_1 = "    本项内容共由" . $count . "项指标构成,满分10分。根据得分的由低到高排序,分析" . $data['name'] . "得分偏低的原因为:";
         $text_2 = "。具体分布如右图所示: ";
         $textrun = $row->addCell(7000)->addTextRun(array('lineHeight' => 1.5));
         $textrun->addText($text_1, array('size' => 14));
         $textrun->addText(implode(';', $comments), array('size' => 14, 'bold' => true));
         $textrun->addText($text_2, array('size' => 14));
         //add chart
         $fileName = $chart->barGraph_2($value['detail'], $examinee_id, 'darkgreen');
         if (file_exists($fileName)) {
             $row->addCell(3000)->addImage($fileName, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.77), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.48), 'wrappingStyle' => 'square'));
         }
         $section->addTextBreak();
     }
     $section->addTextBreak();
     $section->addTitle('三、综合评价', 1);
     if (empty($data['com'])) {
         $section->addText('素质测评模块没有被选中', array('size' => 14, 'bold' => true), array('lineHeight' => 1.5));
         $section->addTextBreak();
     } else {
         $table = $section->addTable();
         $row = $table->addRow();
         $key_array = array();
         //图表名称数组
         $value_array = array();
         // 图表值数组   一位小数
         $new_key_array = array();
         // 文本名称数组
         $des_array = array();
         //描述数组
         $index_array = array();
         foreach ($data['com'] as $key => $value) {
             $key_array[] = $key;
             $value_array[] = $value[0];
             $new_key_array[] = $value['name'];
             $des_array[] = $value['des'];
             $tmp = array();
             $tmp[] = $value[1][0]['name'];
             $tmp[] = $value[1][1]['name'];
             $tmp[] = $value[1][2]['name'];
             $index_array[] = $tmp;
         }
         $text_1 = "    综合评价分析包括对";
         $text_2 = "的分析。其中";
         $text_3 = "。由各指标的得分平均值得出";
         $text_4 = "的综合分。 ";
         $textrun = $row->addCell(7000)->addTextRun(array('lineHeight' => 1.5));
         $textrun->addText($text_1, array('size' => 14));
         $textrun->addText(implode('、', $new_key_array), array('size' => 14, 'bold' => true));
         $textrun->addText($text_2, array('size' => 14));
         $textrun->addText(implode(',', $des_array), array('size' => 14));
         $textrun->addText($text_3, array('size' => 14));
         $textrun->addText(implode('、', $new_key_array), array('size' => 14));
         $textrun->addText($text_4, array('size' => 14));
         //add chart
         $fileName = $chart->radarGraph_1($value_array, $key_array, $examinee_id);
         if (file_exists($fileName)) {
             $row->addCell(3000)->addImage($fileName, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.77), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4.92), 'wrappingStyle' => 'square'));
         }
         $i = 0;
         foreach ($new_key_array as $value) {
             $section->addTitle($value, 2);
             $textrun = $section->addTextRun(array('lineHeight' => 1.5));
             $textrun->addText($data['name'], array('size' => 14, 'color' => 'blue'));
             //综合项指标评语  ComprehensiveComment
             $comment = array();
             foreach ($index_array[$i++] as $value) {
                 $comment[] = ComprehensiveComment::findFirst(array('index_chs_name = ?1', 'bind' => array(1 => $value)))->comment;
             }
             $textrun->addText(implode(';', $comment), array('size' => 14));
             $textrun->addText('。', array('size' => 14));
         }
         $section->addTextBreak();
     }
     $section->addTitle('四、结论与建议', 1);
     $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000', 'align' => 'center'));
     $row = $table->addRow(600);
     $firstCell = $row->addCell(2000, array('valign' => 'center'))->addText('优势', array('size' => 14, 'color' => 'blue'), array('alignment' => 'center', 'lineHeight' => 1.5));
     $secondCell = $row->addCell(2000);
     $secondCell->getStyle()->setGridSpan(4);
     $i = 1;
     foreach ($data['advantages'] as $value) {
         $secondCell->addText($i++ . '.' . $value, array('size' => 14), array('alignment' => 'left', 'lineHeight' => 1.5));
     }
     $row = $table->addRow(600);
     $firstCell = $row->addCell(2000, array('valign' => 'center'))->addText('改进', array('size' => 14, 'color' => 'blue'), array('alignment' => 'center', 'lineHeight' => 1.5));
     $secondCell = $row->addCell(2000);
     $secondCell->getStyle()->setGridSpan(4);
     $i = 1;
     foreach ($data['disadvantages'] as $value) {
         $secondCell->addText($i++ . '.' . $value, array('size' => 14), array('alignment' => 'left', 'lineHeight' => 1.5));
     }
     $row = $table->addRow(600);
     $row->addCell(2000, array('valign' => 'center', 'vMerge' => 'restart'))->addText('潜质', array('size' => 14, 'color' => 'blue'), array('alignment' => 'center', 'lineHeight' => 1.5));
     $row->addCell(2000, array('valign' => 'center'))->addText("优", array('size' => 14), array('alignment' => 'center', 'lineHeight' => 1.5));
     $row->addCell(2000, array('valign' => 'center'))->addText("良", array('size' => 14), array('alignment' => 'center', 'lineHeight' => 1.5));
     $row->addCell(2000, array('valign' => 'center'))->addText("中", array('size' => 14), array('alignment' => 'center', 'lineHeight' => 1.5));
     $row->addCell(2000, array('valign' => 'center'))->addText("差", array('size' => 14), array('alignment' => 'center', 'lineHeight' => 1.5));
     $row = $table->addRow(600);
     $row->addCell(2000, array('vMerge' => 'continue'));
     for ($i = 0; $i < 4; $i++) {
         if ($data['excellent_evaluate_key'] == $i + 1) {
             $table->addCell(2000)->addText('√', array('size' => 14, 'color' => 'red'), array('alignment' => 'center', 'lineHeight' => 1.5));
         } else {
             $table->addCell(2000);
         }
     }
     $row = $table->addRow(600);
     $firstCell = $row->addCell(2000, array('valign' => 'center'))->addText('评价', array('size' => 14, 'color' => 'blue'), array('alignment' => 'center', 'lineHeight' => 1.5));
     $secondCell = $row->addCell(2000);
     $secondCell->getStyle()->setGridSpan(4);
     $secondCell->addText($data['remark'], array('size' => 14), array('lineHeight' => 1.5));
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($this->wordHandle, 'Word2007');
     //临时文件命名规范    $examinee_id_$date_rand(100,900)
     $date = date('H_i_s');
     $stamp = rand(100, 900);
     $fileName = './tmp/' . $examinee_id . '_' . $date . '_' . $stamp . '.docx';
     $objWriter->save($fileName);
     return $fileName;
 }
 public function actionExport($id)
 {
     $templateFilepath = dirname(__FILE__) . '/../runtime/templates/Template2.docx';
     $source = dirname(__FILE__) . '/../runtime/temp.docx';
     \PhpOffice\PhpWord\Autoloader::register();
     $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($templateFilepath);
     $months = ['Січня', 'Лютого', 'Березня', 'Квітня', 'Травня', 'Червня', 'Липня', 'Серпня', 'Вересня', 'Жовтня', 'Листопада', 'Грудня'];
     $date = getdate();
     $currentDate = $date['mday'] . ' ' . $months[$date['mon'] - 1] . ' ' . $date['year'] . ' року';
     $extractNumber = '№' . $date['mday'] . ($date['mon'] - 1) . substr($date['year'], -2);
     $templateProcessor->setValue('date', $currentDate);
     $templateProcessor->setValue('number', $extractNumber);
     $templateProcessor->saveAs($source);
     $phpWord = \PhpOffice\PhpWord\IOFactory::load($source);
     //$phpWord = new \PhpOffice\PhpWord\PhpWord();
     $phpWord->setDefaultFontName('Times New Roman');
     $phpWord->setDefaultFontSize(11);
     $sectionStyle = ['marginTop' => 1000];
     $tableStyle = ['borderSize' => 6, 'borderColor' => '000', 'cellMargin' => 0];
     $innerTableStyle = ['cellMargin' => 20];
     $boldFontStyle = ['bold' => true];
     $italicFontStyle = ['italic' => true];
     $styleCell = ['valign' => 'center'];
     $styleCellBTLR = ['valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR];
     $innerTableCellStyle = ['borderRightSize' => 6, 'borderRightColor' => '000', 'borderLeftSize' => 6, 'borderLeftColor' => '000', 'borderBottomSize' => 6, 'borderBottomColor' => '000'];
     $innerTableRightCellStyle = ['borderLeftSize' => 6, 'borderLeftColor' => '000', 'borderBottomSize' => 6, 'borderBottomColor' => '000'];
     $innerTableFontStyle = ['size' => 9];
     $innerTableParagraphStyle = ['align' => 'center'];
     // Get resource data
     $resource = Resource::findOne($id);
     $filename = $resource->name . '.docx';
     $coordinates = json_decode($resource->coordinates);
     $owner_name = 'народ України (Український народ)';
     $resource_class = 'природний ресурс';
     $resource_subclass = ResourceClass::findOne($resource->class_id)->name;
     $creation_date = $resource->date;
     $registrar = PersonalData::findOne($resource->registrar_data_id);
     $registrar_info = $registrar->last_name . ' ' . $registrar->first_name . ' ' . $registrar->middle_name . ' ' . $registrar->address;
     $registrar_shortname = $registrar->last_name . $registrar->first_name[0] . '. ' . $registrar->middle_name[0] . '.';
     $parameters = Parameter::find()->where(['resource_id' => $id])->all();
     $attributes = [];
     foreach ($parameters as $parameter) {
         $parameter_name = ResourceAttribute::findOne($parameter->attribute_id);
         $attributes[$parameter_name->name] = $parameter->value;
     }
     $length = $attributes['length'];
     $width = $attributes['width'];
     $height = $attributes['height'];
     if ($length || $width || $height) {
         if (!$length) {
             $length = '0';
         }
         if (!$width) {
             $width = '0';
         }
         if (!$height) {
             $height = '0';
         }
         $attributes['linear_size'] = $length . ':' . $width . ':' . $height;
     }
     $reason = $resource->reason;
     function formatCoords($num)
     {
         $num = round($num, 4, PHP_ROUND_HALF_DOWN);
         $degrees = floor($num);
         $minfloat = ($num - $degrees) * 60;
         $minutes = floor($minfloat);
         $secfloat = ($minfloat - $minutes) * 60;
         $seconds = round($secfloat);
         if ($seconds == 60) {
             $minutes++;
             $seconds = 0;
         }
         if ($minutes == 60) {
             $degrees++;
             $minutes = 0;
         }
         return (string) $degrees . '°' . (string) $minutes . '\'' . (string) $seconds . '"';
     }
     $tableFields = ['Найменування об’єкту' => $resource->name, 'Клас об’єкту' => $resource_class, 'Підклас об’єкту' => $resource_subclass, 'Власник об’єкту' => $owner_name, 'Географічні координати кутів (вершин) об’єкту у форматі ГГ°ММ\'СС,СС". ' => $coordinates, 'Лінійні розміри об’єкту, Д:Ш:В, м' => $attributes['linear_size'], 'Загальна площа об’єкту, га' => $attributes['square'] / 10000, 'Маса (вага) об’єкту, кг' => $attributes['weight'], 'Периметр об’єкту, м' => $attributes['perimeter'], 'Об’єм об’єкту, м3' => $attributes['volume'], 'Підстава для внесення відомостей до Реєстру' => $reason, 'ПІБ та поштова адреса народного реєстратора' => $registrar_info, 'Реєстраційний номер об’єкту' => $registration_number, 'Дата створення запису' => $creation_date];
     $tableUnitalicFields = ['Клас об’єкту', 'Власник об’єкту'];
     $sections = $phpWord->getSections();
     $section = $sections[0];
     $phpWord->addTableStyle('Resource Table', $tableStyle);
     $table = $section->addTable('Resource Table');
     foreach ($tableFields as $key => $value) {
         if ($value) {
             if (!is_array($value)) {
                 $valueFontStyle = [];
                 if (in_array($key, $tableUnitalicFields)) {
                     $valueFontStyle = $italicFontStyle;
                 }
                 $table->addRow(200);
                 $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(8))->addText(htmlspecialchars($key, ENT_COMPAT, 'UTF-8'), $boldFontStyle);
                 $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(15))->addText(htmlspecialchars($value, ENT_COMPAT, 'UTF-8'), $valueFontStyle);
             } else {
                 $row = $table->addRow();
                 $row->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(8))->addText(htmlspecialchars($key, ENT_COMPAT, 'UTF-8'), $boldFontStyle);
                 $cell = $row->addCell();
                 $innerTable = $cell->addTable($innerTableStyle);
                 $innerTable->addRow(10);
                 $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars('Північна широта', ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle);
                 $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars('Східна довгота', ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle);
                 $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars("Північна широта \n(продовження)", ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle);
                 $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableRightCellStyle)->addText(htmlspecialchars("Східна довгота \n(продовження)", ENT_COMPAT, 'UTF-8'), $innerTableFontStyle, $innerTableParagraphStyle);
                 $coordinatesNumber = count($coordinates);
                 for ($i = 1; $i <= round($coordinatesNumber / 2); $i++) {
                     $lat = '';
                     $lng = '';
                     $latCont = '';
                     $lngCont = '';
                     if ($coordinatesNumber >= $i) {
                         $lat = formatCoords($coordinates[$i - 1][0]);
                         $lng = formatCoords($coordinates[$i - 1][1]);
                     }
                     if ($coordinatesNumber >= round($coordinatesNumber / 2) + $i) {
                         $latCont = formatCoords($coordinates[$i + round($coordinatesNumber / 2) - 1][0]);
                         $lngCont = formatCoords($coordinates[$i + round($coordinatesNumber / 2) - 1][1]);
                     }
                     $innerTable->addRow(10);
                     $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars($lat, ENT_COMPAT, 'UTF-8'), $italicFontStyle);
                     $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars($lng, ENT_COMPAT, 'UTF-8'), $italicFontStyle);
                     $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableCellStyle)->addText(htmlspecialchars($latCont, ENT_COMPAT, 'UTF-8'), $italicFontStyle);
                     $innerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $innerTableRightCellStyle)->addText(htmlspecialchars($lngCont, ENT_COMPAT, 'UTF-8'), $italicFontStyle);
                 }
             }
         }
     }
     $section->addTextBreak(2);
     $section->addText('Народний реєстратор', $boldFontStyle);
     $section->addText(htmlspecialchars($registrar_shortname, ENT_COMPAT, 'UTF-8'));
     header("Content-Description: File Transfer");
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
     header('Content-Transfer-Encoding: binary');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Expires: 0');
     $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
     $xmlWriter->save("php://output");
 }
Пример #22
0
 public function posliSubor($phpWord)
 {
     if (URLParser::v("type") == "1") {
         $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
         $objWriter->save($name = '../docs/' . md5(uniqid()) . '.docx');
         $pripona = ".docx";
     } elseif (URLParser::v("type") == "2") {
         $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
         $objWriter->save($name = '../docs/' . md5(uniqid()) . '.odt');
         $pripona = ".odt";
     } elseif (URLParser::v("type") == "3") {
         $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF');
         $objWriter->save($name = '../docs/' . md5(uniqid()) . '.rtf');
         $pripona = ".rtf";
     }
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=NaPodpis' . $pripona);
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . filesize($name));
     flush();
     readfile($name);
     unlink($name);
     exit;
 }
Пример #23
0
 /**
  * generate doc
  * @var array $params
  */
 public function generateDoc($params)
 {
     Yii::$app->user->identity = \app\models\User::findIdentityByAccessToken($params['template']['key']);
     header("Content-Description: File Transfer");
     header('Content-Transfer-Encoding: binary');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Expires: 0');
     switch ($params['template']['format']) {
         case 'PDF':
             $file = Yii::$app->user->id . '_temp.pdf';
             $writeFormat = 'PDF';
             PhpWordSettings::setPdfRendererPath(dirname(__DIR__) . '/../../../vendor/tecnickcom/tcpdf');
             PhpWordSettings::setPdfRendererName('TCPDF');
             header('Content-Type: application/pdf');
             break;
         case 'Word2013':
             $file = Yii::$app->user->id . '_temp.docx';
             $writeFormat = 'Word2013';
             header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
             break;
         default:
             $file = Yii::$app->user->id . '_temp.doc';
             $writeFormat = 'Word2007';
             header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
             break;
     }
     header('Content-Disposition: attachment; filename="' . $file . '"');
     $document = new TemplateProcessor(dirname(__DIR__) . '/../../../files/' . $this->id . '/' . $this->template_file);
     /**
      * process the fields, that have been send through the rest interface
      */
     foreach ($params['template']['fields'] as $field) {
         foreach ($field as $key => $value) {
             $document->setValue($key, UTF8encoding::fixUTF8($value));
         }
     }
     /**
      * process the tables, that have been send through the rest interface
      */
     foreach ($params['template']['tables'] as $tables) {
         foreach ($tables as $name => $rows) {
             //first we create a clone for the master row
             $document->cloneRow($name, count($rows));
             //our walking variable for the table
             $ii = 1;
             foreach ($rows as $row) {
                 foreach ($row as $cell) {
                     $document->setValue(key($cell) . '#' . $ii, current($cell));
                 }
                 $ii++;
             }
         }
     }
     // save as a random file in temp file
     $temp_file = tempnam(sys_get_temp_dir(), $file);
     $document->saveAs($temp_file);
     switch ($params['template']['format']) {
         case 'PDF':
             $phpWord = IOFactory::load($temp_file);
             $xmlWriter = IOFactory::createWriter($phpWord, $writeFormat);
             $xmlWriter->save("php://output");
             break;
         case 'Word2007':
             $phpWord = IOFactory::load($temp_file);
             $xmlWriter = IOFactory::createWriter($phpWord, $writeFormat);
             $xmlWriter->save("php://output");
             break;
         default:
             readfile($temp_file);
             break;
     }
     unlink($temp_file);
     $LogEvent = new TemplateEvent();
     $LogEvent->aTemplateCreated(Yii::$app->user->identity->username, $this->id);
     \Yii::$app->end();
 }
Пример #24
0
 /**
  *
  */
 public function exportMemberProfile($id)
 {
     $user = User::find($id);
     if (!$user) {
         return Redirect::route('members')->with('mError', 'Cet utilisateur est introuvable !');
     }
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $phpWord->addTitleStyle(1, array('name' => 'Tahoma', 'size' => 30, 'bold' => true), array('align' => 'center', 'spaceBefore' => true, 'spaceAfter' => true));
     $phpWord->addTitleStyle(2, array('name' => 'Tahoma', 'size' => 14, 'color' => '666666', 'bold' => true), array('align' => 'center', 'spaceBefore' => true, 'spaceAfter' => true));
     $phpWord->addFontStyle('defaultText', array('name' => 'Tahoma', 'size' => 12, 'spaceBefore' => true, 'spaceAfter' => true));
     $section = $phpWord->addSection(array('marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1)));
     $textrun = $section->addTextRun('Heading1');
     $textrun->addText($user->fullname);
     $section->addTextBreak();
     $textrun = $section->addTextRun('Heading2');
     $textrun->addText(htmlspecialchars($user->bio_short));
     $section->addTextBreak();
     $table = $section->addTable();
     $table->addRow();
     $cell1 = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(14));
     foreach (explode("\n", htmlspecialchars($user->bio_long)) as $line) {
         $cell1->addText($line, 'defaultText');
     }
     $cell1->addTextBreak();
     if ($user->phone) {
         $cell1->addText(htmlspecialchars(sprintf('Tél: %s', $user->phoneFmt)), 'defaultText', array('align' => 'right'));
     }
     $cell1->addText(htmlspecialchars(sprintf('Email: %s', $user->email)), 'defaultText', array('align' => 'right'));
     if ($user->website) {
         $cell1->addText(htmlspecialchars($user->website), 'defaultText', array('align' => 'right'));
     }
     $cell2 = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5));
     $image_url = $user->largeAvatarUrl;
     $image_url = preg_replace('!^(.+)\\?.+$!', '$1', $image_url);
     if (false === strpos($image_url, 'http')) {
         $image_url = public_path() . $image_url;
     }
     $cell2->addImage($image_url, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5)));
     $filename = sprintf('%s.docx', Str::slug($user->fullname));
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
     $objWriter->save($filename);
     $content = file_get_contents($filename);
     unlink($filename);
     $headers = array("Content-Description" => "File Transfer", "Content-Transfer-Encoding" => "binary", "Content-type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Disposition" => "attachment; filename=" . $filename);
     return Response::make($content, 200, $headers);
 }
Пример #25
0
$section->addText(htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. ' . 'The important thing is not to stop questioning." ' . '(Albert Einstein)'));
/*
 * Note: it's possible to customize font style of the Text element you add in three ways:
 * - inline;
 * - using named font style (new font style object will be implicitly created);
 * - using explicitly created font style object.
 */
// Adding Text element with font customized inline...
$section->addText(htmlspecialchars('"Great achievement is usually born of great sacrifice, ' . 'and is never the result of selfishness." ' . '(Napoleon Hill)'), array('name' => 'Tahoma', 'size' => 10));
// Adding Text element with font customized using named font style...
$fontStyleName = 'oneUserDefinedStyle';
$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true));
$section->addText(htmlspecialchars('"The greatest accomplishment is not in never falling, ' . 'but in rising again after you fall." ' . '(Vince Lombardi)'), $fontStyleName);
// Adding Text element with font customized using explicitly created font style object...
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
$fontStyle->setBold(true);
$fontStyle->setName('Tahoma');
$fontStyle->setSize(13);
$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)'));
$myTextElement->setFontStyle($fontStyle);
// Saving the document as OOXML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('helloWorld.docx');
// Saving the document as ODF file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
$objWriter->save('helloWorld.odt');
// Saving the document as HTML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
$objWriter->save('helloWorld.html');
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
Пример #26
0
 /**
  * @usage 系统胜任力报告生成
  * @param
  */
 public function systemReport($project_id)
 {
     //get basic info
     $systemCompetency = new CompetencyData();
     $data = $systemCompetency->getSystemData($project_id);
     $data_pro = $systemCompetency->getProjectAvgIndex($project_id);
     \PhpOffice\PhpWord\Autoloader::register();
     $this->wordHandle = new \PhpOffice\PhpWord\PhpWord();
     //cell style
     $CellNum = $data['count'] + 1;
     $CellLength = \PhpOffice\PhpWord\Shared\Converter::cmToTwip(18.76) / $CellNum;
     //set section style
     $sectionStyle = array('orientation' => 'portrait', 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(3.17), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(3.17), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.54), 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.54), 'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(21), 'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(29.7), 'headerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.5), 'footerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.75));
     $section = $this->wordHandle->addSection($sectionStyle);
     //set default style
     $this->wordHandle->setDefaultFontName("Microsoft YaHei");
     $captionFontStyle = array('color' => 'red', 'size' => 18, 'bold' => true);
     $titleFontStyle = array('color' => 'blue', 'size' => 14, 'bold' => true);
     $fontStyle1 = array('bold' => true, 'size' => 14);
     $fontStyle2 = array('color' => 'blue', 'size' => 14, 'bold' => true);
     $paragraphStyle1 = array('lineHeight' => 1.5);
     $paragraphStyle2 = array('alignment' => 'center', 'lineHeight' => 1.5);
     $paragraphStyle3 = array('alignment' => 'center');
     //set table style
     $styleTable = array('borderSize' => 6, 'borderColor' => 'black', 'cellMargin' => 80);
     //report part
     $table = $section->addTable($styleTable);
     $table->addRow();
     $cell1_19 = $table->addCell($CellLength);
     $cell1_19->getStyle()->setGridSpan($CellNum);
     $cell1_19->addText("系统胜任力测评结果", $captionFontStyle, $paragraphStyle3);
     $table->addRow();
     $cell2_13 = $table->addCell($CellLength);
     $hebing = floor($CellNum / 3);
     $cell2_13->getStyle()->setGridSpan($hebing);
     $cell2_13->addText("系统名称", $fontStyle1, $paragraphStyle3);
     $cell2_49 = $table->addCell($CellLength);
     $cell2_49->getStyle()->setGridSpan($CellNum - $hebing);
     $cell2_49->addText("XX系统", $fontStyle1, $paragraphStyle3);
     $table->addRow();
     $cell3_19 = $table->addCell($CellLength);
     $cell3_19->getStyle()->setGridSpan($CellNum);
     $cell3_19->addText("胜任素质评分", $titleFontStyle, $paragraphStyle2);
     $table->addRow();
     foreach ($data['advantage']['value'] as $key => $value) {
         $table->addCell($CellLength)->addText($value['chs_name'], $fontStyle1, $paragraphStyle3);
     }
     foreach ($data['disadvantage']['value'] as $key => $value) {
         $table->addCell($CellLength)->addText($value['chs_name'], $fontStyle1, $paragraphStyle3);
     }
     $table->addCell($CellLength)->addText('总分', $fontStyle1, $paragraphStyle3);
     $table->addRow();
     foreach ($data['advantage']['value'] as $key => $value) {
         $table->addCell($CellLength)->addText($value['score'], $fontStyle1, $paragraphStyle3);
     }
     foreach ($data['disadvantage']['value'] as $key => $value) {
         $table->addCell($CellLength)->addText($value['score'], $fontStyle1, $paragraphStyle3);
     }
     $table->addCell($CellLength)->addText($data['value'], $fontStyle1, $paragraphStyle3);
     $table->addRow();
     $cell6_19 = $table->addCell($CellLength);
     $cell6_19->getStyle()->setGridSpan($CellNum);
     //add chart
     $chart = new WordChart();
     $fileName = $chart->radarGraph_2($data, $data_pro, $project_id);
     if (file_exists($fileName)) {
         $cell6_19->addImage($fileName, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(13.76), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(7.09), 'wrappingStyle' => 'square'));
     }
     $table->addRow();
     $cell7_19 = $table->addCell($CellLength);
     $cell7_19->getStyle()->setGridSpan($CellNum);
     $cell7_19->addText("胜任力评价 ", $titleFontStyle, $paragraphStyle3);
     $table->addRow();
     $cell8_19 = $table->addCell($CellLength);
     $cell8_19->getStyle()->setGridSpan($CellNum);
     $cell8_19->addText("主要优势有:", array('color' => 'blue', 'size' => 12, 'bold' => true), $paragraphStyle1);
     $array1 = array('一', '二', '三', '四', '五');
     $i = 0;
     foreach ($data['advantage']['value'] as $key => $value) {
         $cell8_19->addText($array1[$i++] . "是" . $value['comment'], array('size' => 12));
     }
     $table->addRow();
     $cell9_19 = $table->addCell($CellLength);
     $cell9_19->getStyle()->setGridSpan($CellNum);
     $cell9_19->addText("有待改进有:", array('color' => 'blue', 'size' => 12, 'bold' => true), $paragraphStyle1);
     $array2 = array('一', '二', '三');
     $i = 0;
     foreach ($data['disadvantage']['value'] as $key => $value) {
         $cell9_19->addText($array2[$i++] . "是" . $value['comment'], array('size' => 12));
     }
     //命名
     //临时文件命名规范    $project_id_$date_rand(100,900)
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($this->wordHandle, 'Word2007');
     $date = date('H_i_s');
     $stamp = rand(100, 900);
     $fileName = './tmp/' . $project_id . '_' . $date . '_' . $stamp . '.docx';
     $objWriter->save($fileName);
     return $fileName;
 }
Пример #27
0
 /**
  * Create non-existing writer
  *
  * @expectedException \PhpOffice\PhpWord\Exception\Exception
  */
 public function testNonexistentWriterCanNotBeCreated()
 {
     IOFactory::createWriter(new PhpWord(), 'Word2006');
 }
Пример #28
0
 public function report($project_id)
 {
     $data = new ProjectComData();
     $data->project_check($project_id);
     $chart = new WordChart();
     $project = Project::findFirst($project_id);
     //-----------------------------------
     \PhpOffice\PhpWord\Autoloader::register();
     $this->wordHandle = new \PhpOffice\PhpWord\PhpWord();
     // layout
     $sectionStyle = array('orientation' => 'portrait', 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.9), 'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(21), 'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(29.7), 'headerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'footerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(0.8));
     //add section
     $section = $this->wordHandle->addSection($sectionStyle);
     $section->getStyle()->setPageNumberingStart(1);
     $header = $section->addHeader();
     $header = $header->createTextrun();
     $header->addImage('reportimage/logo_2.jpg', array('marginTop' => -1, 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToInch(1), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.98), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.54), 'wrappingStyle' => 'square'));
     $header->addText($project->name . "总体分析报告", array('color' => 'red', 'size' => 11), array('lineHeight' => 1, 'alignment' => 'right'));
     $footer = $section->addFooter();
     $footer->addPreserveText('{PAGE}', array('size' => 10, 'color' => '000000'), array('alignment' => 'center', 'lineHeight' => 1));
     //cover part
     $paragraphStyle = array('alignment' => 'center', 'lineHeight' => 1.5);
     $defaultParagraphStyle = array('lineHeight' => 1.5);
     $captionFontStyle = array('name' => 'Microsoft YaHei', 'size' => 22, 'color' => 'red', 'bold' => true);
     $section->addTextBreak(6);
     $section->addText($project->name . "总体分析报告", $captionFontStyle, $paragraphStyle);
     $section->addPageBreak();
     //set title style---TOC
     $this->wordHandle->addTitleStyle(1, array('size' => 16, 'bold' => true), array('lineHeight' => 1.5));
     $this->wordHandle->addTitleStyle(2, array('size' => 15, 'bold' => true), array('lineHeight' => 1.5));
     $this->wordHandle->addTitleStyle(3, array('size' => 12, 'bold' => true), array('lineHeight' => 1.5));
     //catalog part
     $section->addText("目录", array('color' => 'blue', 'size' => 12), $paragraphStyle);
     $section->addTOC(array('size' => 12), \PhpOffice\PhpWord\Style\TOC::TABLEADER_LINE, 1, 3);
     $section->addPageBreak();
     $captionFontStyle2 = array('name' => 'Microsoft YaHei', 'size' => 18, 'color' => 'red', 'bold' => true);
     $section->addText($project->name . "总体分析报告", $captionFontStyle2, $paragraphStyle);
     //part1  项目背景
     $section->addTitle("一、项目背景", 1);
     //-------------------------------------------------------------------------
     $examinee = Examinee::find(array('project_id=?1 AND type = 0 ', 'bind' => array(1 => $project_id)));
     $examinee = $examinee->toArray();
     $examinee_num = count($examinee);
     //总人数
     $exam_date_start = explode(' ', $project->begintime)[0];
     //开始时间
     $exam_date_end = explode(' ', $project->endtime)[0];
     //结束时间
     $min_time = 0;
     $total_time = 0;
     $level_array = array(1 => 0, 2 => 0, 3 => 0, 4 => 0);
     foreach ($examinee as $examinee_record) {
         if ($min_time == 0 || $min_time > $examinee_record['exam_time']) {
             $min_time = $examinee_record['exam_time'];
         }
         $total_time += $examinee_record['exam_time'];
         $level = ReportData::getLevel($examinee_record['id']);
         $level_array[$level]++;
     }
     $min_time_str = null;
     foreach (array(3600 => '小时', 60 => '分', 1 => '秒') as $key => $value) {
         if ($min_time >= $key) {
             $min_time_str .= floor($min_time / $key) . $value;
             $min_time %= $key;
         }
     }
     //最短答题时间
     $average_time = $total_time / $examinee_num;
     $average_time_str = null;
     foreach (array(3600 => '小时', 60 => '分', 1 => '秒') as $key => $value) {
         if ($average_time >= $key) {
             $average_time_str .= floor($average_time / $key) . $value;
             $average_time %= $key;
         }
     }
     //平均答题时间
     $rate_1 = sprintf('%.2f', $level_array[1] / $examinee_num) * 100 . '%';
     //优秀率
     $rate_2 = sprintf('%.2f', $level_array[2] / $examinee_num) * 100 . '%';
     //良好率
     $rate_3 = sprintf('%.2f', $level_array[3] / $examinee_num) * 100 . '%';
     //中等率
     //	---------------------------------------------------------
     $section->addText("    为了充分开发中青年人才资源,了解中青年人才水平、培养有潜力人才及科技骨干、选拔一批经验丰富,德才兼备的中青年高技能人才,北京XXX集团(后简称“集团”),采用第三方北京技术交流培训中心(以下简称“中心”)自主研发26年,通过上下、左右、前后六维(简称“6+1”)测评技术,对集团" . $examinee_num . "名中青年人才进行了一次有针对性的测评。从" . $exam_date_start . "到" . $exam_date_end . ",在集团培训中心进行上机测试。规定测评时间为3小时,最短完成时间为" . $min_time_str . ",一般为" . $average_time_str . "左右。 ", $defaultParagraphStyle);
     $section->addText("    测评后进行专家(四位局级以上领导干部)与中青年人才一对一人均半小时的沟通(简称“面询”), 这是区别国内所有综合测评机构的独有特色。面询内容有三:一是根据测评结果按优劣势分析归纳与评价;二是双方互动理解与确认测评结果;三是现场解答每位人才提出的问题,并给予针对性、个性化的解决方案与建议。", $defaultParagraphStyle);
     $section->addText("    通过对" . $examinee_num . "位中青年人才综合统计分析,按优良中差排序结果为:全体优秀率达" . $rate_1 . ",良好" . $rate_2 . "。在测评和专家面询后,对全部人才进行了无记名的满意度调查,参加调查83人,回收有效问卷83份,有效率100%,满意度100%。(满意度调查报告详见附件1) ", $defaultParagraphStyle);
     $section->addTitle("1、测评目的", 2);
     $section->addTitle("第一、为中青年人才培训提供科学参考依据", 3);
     $section->addText("    在传统的人事管理信息系统中,人与人之间的差别只体现在性别、年龄、职务、工种、学历、职称、工作经历上,而却忽略了内隐素质能力上的差异。综合测评可以帮助集团领导了解中青年人才更多重要的信息,为个性化培养与培训提供科学、准确的依据。在对人才进行精准识别后,还进行了人岗匹配,针对岗位胜任程度和潜质提出了使用与培养的建议。通过本次测评,清晰了集团中青年人才职业心理、职业素质、智体结构、职业能力和发展潜质,为集团下一步的培训工作提供了科学、客观、准确的依据。", $defaultParagraphStyle);
     $section->addTitle("第二、为中青年人才提供自我认知和自我提升的工具", 3);
     $section->addText("    通过综合测评,帮助了这些人才全面、系统、客观、准确了解自我;通过结合岗位职责一对一面询,让这些人才更加明确自身优势与劣势;清晰哪些技能和素质需要进一步培训,在实际工作中扬长避短,促进自我职业生涯与集团战略的有机结合。", $defaultParagraphStyle);
     $section->addTitle("2、测评流程", 2);
     $section->addText("    综合测评分为五个阶段:", $defaultParagraphStyle);
     $section->addText("    一是测评前准备。这一阶段确定测试人才的人数、测评时间、测评内容、测评群体的总体情况;收集测评人才简历;编制测评总体需求量表。", $defaultParagraphStyle);
     $section->addText("    二是人机对话测评。通过“6+1”系统综合测评,人均获取近1000个定性与定量数据,经过数据处理与统计分析,为专家面询提供科学、准确、客观、真实的测评结果。", $defaultParagraphStyle);
     $section->addText("    三是专家面询。这一过程人均半小时,目的是让有较高领导岗位经历和复合学科背景的专家依据测评结果,与中青年人才一对一的互动沟通:首先,帮他们清晰自己的优劣势;其次,为他们排忧解惑;最后,为每位中青年人才梳理出与集团发展匹配的对策。", $defaultParagraphStyle);
     $section->addText("    四是撰写总体与个体报告。依据对“6+1”大数据分析结果撰写总体综合素质分析报告;整合个人测评结果和专家面询评价,撰写每位人才的综合测评分析报告。", $defaultParagraphStyle);
     $section->addText("    五是汇报与反馈。向集团领导汇报总体与个体测评结果,反馈无记名满意度调查报告等,针对集团发展战略和现代人力资源管理提出针对性的建议与对策。", $defaultParagraphStyle);
     $section->addTitle("3、技术路径", 2);
     $section->addText("    “中心”的综合测评系统始于1988年博士研究成果,经历了26年实践检验,其过程(1)测评地域:北京、上海、天津、广东、山西、湖南、湖北、陕西、内蒙、海南、浙江、山东、辽宁、河南等省市;(2)年龄:20~68岁;(3)学历:大专~博士后;(4)职称:初级~两院士;(5)职务:初、中级~政府副部长、部队中将(陆海空);(6)类型:跨国公司高管、各类企业高管与技术人才;(7)测评人数:3万多人;(8)测评数据:每人925个;(9)获得荣誉:7次获国家自然科学基金资助,2次获航空科学基金资助,4次获省部级科学技术进步二等奖和管理成果一等奖;在国内外核心刊物发表论文30多篇,专著一本;测评软件50多套;培养出3名博士、9名硕士;经调查,客户反映测评准确率高、效果明显,平均满意度达97.8%,受到被测评人才和用人单位的普遍欢迎和认可。", $defaultParagraphStyle);
     //part2  基本情况分析
     $section->addTitle("二、综合测评基本情况分析", 1);
     $inquery_data = $data->getInqueryAnsComDetail($project_id);
     //--------------------------------------------------------------------
     #获取inquery_data 第一个数据项 以及 总体人数
     $section->addText("    参加本次测评对象是集团的中青年人才(或简称“人才”),有" . (count($inquery_data[0]['options']) + 1) . "个重要定义:", $defaultParagraphStyle);
     $textrun = $section->addTextRun(array('lineHeight' => 1.5));
     $textrun->addText('第一,');
     $textrun->addText('总体', array('color' => 'red'));
     $textrun->addText(':' . $examinee_num . '人');
     $time_array = array('第二', '第三', '第四', '第五', '第六', '第七', '第八', '第九', '第十', '第十一', '第十二', '第十三', '第十四', '第十五');
     $i = 0;
     foreach ($inquery_data[0]['options'] as $value) {
         $textrun = $section->addTextRun(array('lineHeight' => 1.5));
         $textrun->addText($time_array[$i] . ',');
         $textrun->addText($value, array('color' => 'red'));
         $textrun->addText(':' . array_sum($inquery_data[0]['value'][$i++]) . '人');
     }
     $section->addTitle("(一)基本信息分析", 2);
     //先分析简单项-----按照题目需求量表来 n项
     $i = 1;
     foreach ($inquery_data as $value) {
         $section->addTitle($i . '-逐项分析', 3);
         $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000'));
         $row = $table->addRow(500);
         $row->addCell(1000, array('valign' => 'center'))->addText('分类', array('size' => 10.5), array('alignment' => 'center'));
         $row->addCell(1000, array('valign' => 'center'))->addText('人数', array('size' => 10.5), array('alignment' => 'center'));
         $row->addCell(1000, array('valign' => 'center'))->addText('比例', array('size' => 10.5), array('alignment' => 'center'));
         $j = 0;
         foreach ($value['options'] as $option_value) {
             $row = $table->addRow(500);
             $row->addCell(1000, array('valign' => 'center'))->addText($option_value, array('size' => 10.5), array('alignment' => 'center'));
             $row->addCell(1000, array('valign' => 'center'))->addText(array_sum($inquery_data[$i - 1]['value'][$j]), array('size' => 10.5), array('alignment' => 'center'));
             $row->addCell(1000, array('valign' => 'center'))->addText(sprintf('%.2f', array_sum($inquery_data[$i - 1]['value'][$j]) / $examinee_num) * 100 . '%', array('size' => 10.5), array('alignment' => 'center'));
             $j++;
         }
         $i++;
         //add chart -- 饼图 -- 加不了 无法湖区到图表名称
         //add text
         $section->addTextBreak();
         $section->addText('    相关分析:', array('color' => 'blue', 'bold' => true), array('lineHeight' => 1.5));
         $section->addTextBreak();
     }
     //交叉项分析----从第二道题开始 与第一项进行比较 综合分析 n-1项
     $i = 1;
     foreach ($inquery_data as $value) {
         $section->addTitle($i . '-交叉项分析', 3);
         $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000'));
         $row = $table->addRow(500);
         $row->addCell(1000, array('valign' => 'center'))->addText('分类', array('size' => 10.5), array('alignment' => 'center'));
         foreach ($inquery_data[0]['options'] as $level_name) {
             $row->addCell(1000, array('valign' => 'center'))->addText($level_name, array('size' => 10.5), array('alignment' => 'center'));
         }
         $j = 0;
         foreach ($value['options'] as $option_value) {
             $row = $table->addRow(500);
             $row->addCell(1000, array('valign' => 'center'))->addText($option_value, array('size' => 10.5), array('alignment' => 'center'));
             foreach ($inquery_data[$i - 1]['value'][$j] as $value_level_number) {
                 $row->addCell(1000, array('valign' => 'center'))->addText($value_level_number, array('size' => 10.5), array('alignment' => 'center'));
             }
             $j++;
         }
         $i++;
         $section->addTextBreak();
         $section->addText('    相关分析:', array('color' => 'blue', 'bold' => true), array('lineHeight' => 1.5));
         $section->addTextBreak();
     }
     $level_examinees = $data->getBaseLevels($project_id);
     // 		//测评结果
     $section->addTitle("三、测评结果及特点分析", 1);
     $section->addTitle("1、突出优势的特征", 2);
     $advantage_data = $data->getProjectAdvantages($project_id);
     $number = 1;
     $existed_factors = array();
     //遍历优势结果集
     foreach ($advantage_data as $advantage_record) {
         $section->addTitle($number++ . $advantage_record['chs_name'], 3);
         $children_str = $advantage_record['children'];
         $children_array = explode(',', $children_str);
         //图表数据  storage
         $storage = array();
         foreach ($level_examinees as $level_record) {
             $storage[] = array();
         }
         //遍历优势指标的下属
         $factor = 'A';
         //保证每个指标的下属因子少于26
         foreach ($children_array as $children_name) {
             $factor_value_by_level = $data->getFactorGrideByLevel(null, $children_name, $level_examinees, $project_id);
             for ($i = 0, $len = count($storage); $i < $len; $i++) {
                 $storage[$i][$factor] = $factor_value_by_level[$i];
             }
             $factor++;
         }
         //各层人员各种因子的数据获取完成         $storage ;
         $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000'));
         $row = $table->addRow(500);
         $row->addCell(1000, array('valign' => 'center'))->addText('分类', array('size' => 10.5), array('alignment' => 'center'));
         foreach ($storage[0] as $stor_key => $stor_value) {
             $row->addCell(1000, array('valign' => 'center'))->addText($stor_key, array('size' => 10.5), array('alignment' => 'center'));
         }
         $j = 0;
         foreach ($storage as $storage_record) {
             $row = $table->addRow(500);
             $row->addCell(1000, array('valign' => 'center'))->addText($inquery_data[0]['options'][$j], array('size' => 10.5), array('alignment' => 'center'));
             foreach ($storage_record as $storage_record_value) {
                 $row->addCell(1000, array('valign' => 'center'))->addText($storage_record_value, array('size' => 10.5), array('alignment' => 'center'));
             }
             $j++;
         }
         $section->addTextBreak();
         //优势3项下属
         $advantage_three = array();
         $advantage_count = 0;
         foreach ($advantage_record['detail'] as $factor_info) {
             //优势指标中选取前三
             if ($advantage_count >= 3) {
                 break;
             }
             if (in_array($factor_info['chs_name'], $existed_factors)) {
                 continue;
             } else {
                 $existed_factors[] = $factor_info['chs_name'];
             }
             //获取前三因子 factor_info['chs_name']
             $advantage_three[$factor_info['chs_name']] = array();
             $advantage_count++;
             //优势因子获取优势评语
             //取 28项指标的下属
             // 				$advantage_comment = ReportComment::findFirst(array(
             // 						'name=?1',
             // 						'bind'=>array(1=>$factor_info['chs_name'])))->advantage;
             // 				$advantage_comment_array = explode("|", $advantage_comment);
             $advantage_comment = ChildIndexComment::findFirst(array('index_chs_name = ?1 AND child_chs_name =?2', 'bind' => array(1 => $advantage_record['chs_name'], 2 => $factor_info['chs_name'])))->advantage;
             $advantage_comment_array = json_decode($advantage_comment, true);
             $rand_key = array_rand($advantage_comment_array);
             $comment = $advantage_comment_array[$rand_key];
             //优势因子评语
             $advantage_three[$factor_info['chs_name']]['comment'] = $comment;
             $factor_by_level = $data->getFactorGrideByLevel($factor_info['chs_name'], null, $level_examinees, $project_id);
             arsort($factor_by_level);
             //逆序排列
             $level_arsort_array = array();
             foreach ($factor_by_level as $arsort_key => $arsort_value) {
                 $level_arsort_array[] = $inquery_data[0]['options'][$arsort_key];
             }
             $advantage_three[$factor_info['chs_name']]['level_arsort'] = $level_arsort_array;
         }
         //优势3项获取完毕   ----- $advantage_three
         $section->addText('特征描述', array('color' => 'blue', 'size' => 11, 'bold' => true));
         $number_array = array('一', '二', '三');
         $i = 0;
         foreach ($advantage_three as $value) {
             $section->addText($number_array[$i++] . $value['comment'], $defaultParagraphStyle);
         }
         $section->addTextBreak();
         foreach ($advantage_three as $key => $value) {
             $section->addText($key . ':' . implode(',', $value['level_arsort']), $defaultParagraphStyle);
         }
         $section->addTextBreak();
     }
     $section->addTitle('2、需要完善和提升的方面', 2);
     //$level_examinees =$data->getBaseLevels($project_id);
     $disadvantage_data = $data->getProjectDisadvantages($project_id);
     $number = 1;
     $existed_factors = array();
     //遍历劣势结果集
     foreach ($disadvantage_data as $disadvantage_record) {
         $section->addTitle($number++ . $disadvantage_record['chs_name'], 3);
         $children_str = $disadvantage_record['children'];
         $children_array = explode(',', $children_str);
         //图表数据  storage
         $storage = array();
         foreach ($level_examinees as $level_record) {
             $storage[] = array();
         }
         //遍历优势指标的下属
         $factor = 'A';
         //保证每个指标的下属因子少于26
         foreach ($children_array as $children_name) {
             $factor_value_by_level = $data->getFactorGrideByLevel(null, $children_name, $level_examinees, $project_id);
             for ($i = 0, $len = count($storage); $i < $len; $i++) {
                 $storage[$i][$factor] = $factor_value_by_level[$i];
             }
             $factor++;
         }
         //各层人员各种因子的数据获取完成         $storage ;
         $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000'));
         $row = $table->addRow(500);
         $row->addCell(1000, array('valign' => 'center'))->addText('分类', array('size' => 10.5), array('alignment' => 'center'));
         foreach ($storage[0] as $stor_key => $stor_value) {
             $row->addCell(1000, array('valign' => 'center'))->addText($stor_key, array('size' => 10.5), array('alignment' => 'center'));
         }
         $j = 0;
         foreach ($storage as $storage_record) {
             $row = $table->addRow(500);
             $row->addCell(1000, array('valign' => 'center'))->addText($inquery_data[0]['options'][$j], array('size' => 10.5), array('alignment' => 'center'));
             foreach ($storage_record as $storage_record_value) {
                 $row->addCell(1000, array('valign' => 'center'))->addText($storage_record_value, array('size' => 10.5), array('alignment' => 'center'));
             }
             $j++;
         }
         $section->addTextBreak();
         //劣势3项下属
         $disadvantage_three = array();
         $disadvantage_count = 0;
         foreach ($disadvantage_record['detail'] as $factor_info) {
             //劣势指标中选取前三
             if ($disadvantage_count >= 3) {
                 break;
             }
             if (in_array($factor_info['chs_name'], $existed_factors)) {
                 continue;
             } else {
                 $existed_factors[] = $factor_info['chs_name'];
             }
             //获取前三因子 factor_info['chs_name']
             $disadvantage_three[$factor_info['chs_name']] = array();
             $disadvantage_count++;
             //劣势因子获取劣势因子
             // 				$disadvantage_comment = ReportComment::findFirst(array(
             // 						'name=?1',
             // 						'bind'=>array(1=>$factor_info['chs_name'])))->disadvantage;
             // 				$disadvantage_comment_array = explode("|", $disadvantage_comment);
             $disadvantage_comment = ChildIndexComment::findFirst(array('index_chs_name = ?1 AND child_chs_name =?2', 'bind' => array(1 => $disadvantage_record['chs_name'], 2 => $factor_info['chs_name'])))->disadvantage;
             $disadvantage_comment_array = json_decode($disadvantage_comment, true);
             $rand_key = array_rand($disadvantage_comment_array);
             $comment = $disadvantage_comment_array[$rand_key];
             //优势因子评语
             $disadvantage_three[$factor_info['chs_name']]['comment'] = $comment;
             $factor_by_level = $data->getFactorGrideByLevel($factor_info['chs_name'], null, $level_examinees, $project_id);
             arsort($factor_by_level);
             //逆序排列
             $level_arsort_array = array();
             foreach ($factor_by_level as $arsort_key => $arsort_value) {
                 $level_arsort_array[] = $inquery_data[0]['options'][$arsort_key];
             }
             $disadvantage_three[$factor_info['chs_name']]['level_arsort'] = $level_arsort_array;
         }
         //劣势3项获取完毕   ----- $disadvantage_three
         $section->addText('特征描述', array('color' => 'blue', 'size' => 11, 'bold' => true));
         $number_array = array('一', '二', '三');
         $i = 0;
         foreach ($disadvantage_three as $value) {
             $section->addText($number_array[$i++] . $value['comment'], $defaultParagraphStyle);
         }
         $section->addTextBreak();
         foreach ($disadvantage_three as $key => $value) {
             $section->addText($key . ':' . implode(',', $value['level_arsort']), $defaultParagraphStyle);
         }
         $section->addTextBreak();
     }
     $section->addTitle("四、职业素质综合评价", 1);
     $comprehensive_data = $data->getComprehensiveData($project_id);
     if (empty($comprehensive_data)) {
         $section->addText('素质测评模块没有被选中', array('size' => 14, 'bold' => true), array('lineHeight' => 1.5));
         $section->addTextBreak();
     } else {
         //chart data
         $chart_labels = array();
         $chart_values = array();
         foreach ($comprehensive_data as $comprehensive_record) {
             $chart_labels[] = $comprehensive_record['name'];
             //图表中的标签名称
             $chart_values[] = $comprehensive_record['value'];
             //图表中对应项的得分数据
         }
         //add data chart
         $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000'));
         $row = $table->addRow(500);
         foreach ($chart_labels as $chart_label_value) {
             $row->addCell(1000, array('valign' => 'center'))->addText($chart_label_value, array('size' => 10.5), array('alignment' => 'center'));
         }
         $row = $table->addRow(500);
         foreach ($chart_values as $chart_label_value) {
             $row->addCell(1000, array('valign' => 'center'))->addText($chart_label_value, array('size' => 10.5), array('alignment' => 'center'));
         }
         $number_tk = 1;
         foreach ($comprehensive_data as $comprehensive_record) {
             $module_record = Module::findFirst(array("name = ?1", 'bind' => array(1 => $comprehensive_record['name_in_table'])));
             //MemoryCache::getModuleDetail($comprehensive_record['name_in_table']); //根据数据库中存储的模块名称获取模块的下属children ,之后按照原有的children顺序来排列指标得分
             $children = explode(',', $module_record->children);
             $search_array = array();
             foreach ($comprehensive_record['children'] as $com_value) {
                 $search_array[$com_value['id']] = sprintf('%.2f', $com_value['score']);
             }
             foreach ($children as &$value) {
                 $index_info = Index::findFirst(array('name=?1', 'bind' => array(1 => $value)));
                 $value = $search_array[$index_info->id];
             }
             //$children 按顺序排列的指标得分
             $section->addTitle($number_tk++ . $comprehensive_record['name'], 2);
             $table = $section->addTable(array('borderSize' => 1, 'borderColor' => '000000'));
             $row = $table->addRow(500);
             $number = count($children);
             $start = 'A';
             for ($i = 0; $i < $number; $i++) {
                 $row->addCell(1000, array('valign' => 'center'))->addText($start++, array('size' => 10.5), array('alignment' => 'center'));
             }
             $row = $table->addRow(500);
             foreach ($children as $chart_label_value) {
                 $row->addCell(1000, array('valign' => 'center'))->addText($chart_label_value, array('size' => 10.5), array('alignment' => 'center'));
             }
             //前三指标评语
             $three_index = array_slice($comprehensive_record['children'], 0, 3);
             $comment = array();
             foreach ($three_index as $three_value) {
                 $comment[] = ComprehensiveComment::findFirst(array('index_chs_name = ?1', 'bind' => array(1 => $three_value['chs_name'])))->comment;
             }
             $section->addTextBreak();
             $section->addText(implode(';', $comment) . '。', $defaultParagraphStyle);
             $section->addTextBreak();
         }
     }
     // 		//结论与建议
     $section->addTitle("五、结论与建议", 1);
     $section->addTitle("(一)本次综合测评的基本评价", 2);
     $section->addTitle("1、印证了集团对中青年人才培养前瞻性、系统性和实效性", 3);
     $section->addText("    通过本次综合测评与统计分析,得到了具有优秀发展潜质的中青年人才占" . $rate_1 . "、有良好发展潜质占" . $rate_2 . "、中等潜质为" . $rate_3 . "的测评结果,进一步证明了集团在中青年人才培养体系的系统性、科学性、精准性、可行性及实操性。", $defaultParagraphStyle);
     $section->addTitle("2、量化了集团中青年人才的发展潜质和培养与培训路径", 3);
     $section->addText("    以人均1000多个数据为基础,有复合的理论体系和系统的方法体系为支撑,对所有参加测评的中青年人才量化的内容有四:一是进行了发展潜质的量化排序;二是精确了能否胜任现有岗位的五级评分;三是明确了今后的培养方向;四是清晰了下一步培训的重点。", $defaultParagraphStyle);
     $section->addTitle("3、形成了具有XXX集团特色的中青年人才队伍", 3);
     $section->addText("    集团有一支性别结构均衡、有行业特点,人才梯队结构年龄分布合理,专业门类较齐全、理工科配备合适,学历结构适当,对集团发展前景高度认可的中青年人才队伍。", $defaultParagraphStyle);
     $section->addTitle("4、突显了集团中青年人才特质", 3);
     $section->addText("    形成了外向开朗、身心健康、阳光向上、精力充沛的人格;思路清晰,有追求和不断总结的归纳提炼能力;具有后天勤奋和先天聪明,勇于实践,训练有素的分析能力;还具有自律谨严,心胸开阔,持之以恒的纪律性;能很好胜任现有岗位的中青年人才特质。", $defaultParagraphStyle);
     $section->addTitle("5、彰显了集团对人才培养与培训合理性", 3);
     $section->addText("    以XXX类专业技术人才为主体的中青年人才结构,能够与承担的集团工作任务特点相适应;通过培训需求和学历调查得知,中青年人才均受过高等教育,有较高的工作能力和职业素质,有丰富的工作经验,是一支总体素质较高的人才队伍。", $defaultParagraphStyle);
     $section->addTitle("6、突出了中青年人才较高的自知之明,普遍比较低调", 3);
     $section->addText("    总体对自身发展有较明确定位,对个人能力的特长、胜任岗位的优势,以及能力素质的短板有比较客观的认识与评价,对职业生涯发展规划有迫切的需求。如:在在专家面询中,他们与专家互动最多的是如何改进自己的不足。而在“6+1”调查中,统计自认为非常胜任现有工作岗位是25%,但实际测评结果却是50%。", $defaultParagraphStyle);
     $section->addTitle("7、达成了个人与集团发展较一致的职业目标", 3);
     $section->addText("    对自身建设的努力方向、存在的问题和面临的任务,有比较一致的认识,并与集团促进人才发展目标较相吻合。因为100%的人对集团发展有信心,这些人才以在XXX工作为荣,把个人目标与集团目标匹配期望度非常高。", $defaultParagraphStyle);
     $section->addTitle("8、锻炼了一支经过基层磨练、综合素质高的集团总部中青年人才队伍", 3);
     $section->addText("    集团总部中青年人才在心理健康、归纳能力、分析能力、聪慧性及对自我约束等均高于其他测评人才,而且他们大都经过基层历练,为集团机关发展与改革储备了优质与可靠的人才基础。", $defaultParagraphStyle);
     $section->addTitle("(二)本次测评出现的主要问题", 2);
     $section->addTitle("1、集团在引进中青年人才来源还需要进一步优化", 3);
     $section->addText("    中青年人才的专业结构较全面,学历水平比较高,职称层次较多。但来自名牌高校的优秀人才并不多,这也为什么在相应专业领域没有形成领军人才的直接原因。", $defaultParagraphStyle);
     $section->addTitle("2、集团总部人才优势与实际工作相矛盾的影响要引起重视", 3);
     $section->addText("    测评结果显示,集团总部人才在工作的执著性、人际关系调节和独立工作能力均得分不高,但他们的实际潜质证明对应这三方面的短板是恰恰是他们的优势。为什么会出现这样矛盾呢?原因为:一是在集团总部有些部门存在管理传统和领导强势或无序;二是某些重要岗位出现人岗不匹配,理论上是出现了“彼德原理”现象,实际上是影响到下级或整个部门综合素质水平;三是集团总部“官本位”与现代管理相互交织产生的“蝴蝶效应”,不仅影响到这些人才,更重要的是已波及到总部管理层和下属企业。", $defaultParagraphStyle);
     $section->addTitle("3、危机感、局限性、依赖性较高比例不容忽视", 3);
     $section->addText("    特别要强调的是:本次测评中68%的中青年人才工作求稳怕乱,除与本岗位有关的内容外,对其他的事情关心或关注很少,长此以往就会出现眼界不开阔、洞察力不强的局面;有79%的人才做事依靠上级布置,缺乏自主意识,不考虑工作为什么做,怎么样做;有75%的人才工作的执着性不强,自己有正确意见也不愿意或不敢发表,不太关心集团期望目标,只关注自己是否能完成局部的任务。长此下去,出了问题很难找到责任人,岗位责任与集团的绩效管理和绩效考核会形同虚设。", $defaultParagraphStyle);
     $section->addTitle("4、集团需要系统化的培训体系", 3);
     $section->addText("    从综合测评看到:集团的培训年年都在不断创新,不断改进,不断提升。但随着外部环境不断变化,应对式的培训已经满足不了集团各层级人才的需求,这就需要从集团战略顶层面系统思考的培训规划与体系。如:中青年人才非常需要职业技能、管理方法、沟通技巧等系统的综合素质与能力方面的培训,也期望集团在这些方面加大对他们训练的力度,尽快提升他们的综合素质。", $defaultParagraphStyle);
     $section->addTitle("5、岗位稳定性过高,晋升困难,“天花板”和“温水煮青蛙”并存", 3);
     $section->addText("    大部分中青年人才在当前职位上长久得不到调整或者提升,有些人才在基层助理职位上工作已有8年或更长。虽然岗位稳定能让人才在现有职务上游刃有余的完成工作,但思维模式和工作方法容易禁锢于固有的模式之中,“温水煮青蛙”的现象在这些人才中比较这普遍,长此下去,他们对职业前景的期待成为了“天花板”,随之带来就是理想逐渐倦怠,工作缺乏激情。", $defaultParagraphStyle);
     $section->addTitle("6、薪酬福利急待提升", 3);
     $section->addText("    调查结果显示,大量中青年人才选择在集团工作的原因只有很少是因为薪资福利优厚;在希望集团能够改善的问题,更多人的期望能提高收入,增加福利。这说明集团在吸引优秀人才上,薪资福利的吸引力较弱,这也是吸引不到国内外优秀人才的重要原因所在。", $defaultParagraphStyle);
     $section->addTitle("(三)建议与对策", 2);
     $section->addTitle("1、建立与集团战略匹配的现代化人力资源管理体系", 3);
     $section->addText("    综合考虑本次测评结果,建议集团尽快建立与集团战略匹配的现代化人力资源管理体系。以中青年人才综合素质测评作为切入点,制定科学、规范、合理的人才发展规划;以培养高层次、复合型人才为重点,打造有目标、有重点、有计划、有针对性的现代化人力资源管理体系。", $defaultParagraphStyle);
     $section->addTitle("2、建立完善的薪酬福利体系,加大激励与吸引优秀人才的力度", 3);
     $section->addText("    通过本次测评,中青年人才普遍希望集团的薪酬福利能够进一步得到提升,希望能引起集团领导的关注并提出匹配的解决对策。尽管XXX属于城市公共服务类,但其服务水平、所承担的职责和忠诚度远远高于一般的企业,而这一切取决于人才综合素质。", $defaultParagraphStyle);
     $section->addTitle("3、建立基于集团战略的现代人力资源管理的培训体系", 3);
     $section->addText("    以集团人才规划为出发点,根据不同层次的人才,建立健全适合集团发展战略的培训体系已迫在眉睫。并在此基础上开展针对各层次人才的短板、个性化的培训,提升集团人才队伍的整体综合素质能力;注重中青年人才结合岗位需求有针对性培训,加大对这些人才培养与培训力度,重点就专业技能、管理方法、团队合作、人际沟通等进行全方位、多形式的培训。", $defaultParagraphStyle);
     $section->addTitle("4、建立合理的调岗及晋升制度,搭建中青年人才成长平台", 3);
     $section->addText("    中青年人才在集团工作的稳定性普遍很高,但同时存在的问题就是没有多余的岗位吸引新的优秀人才加入。集团建立合理的调岗及晋升制度之后,不仅能促进现有人才的工作积极行,明确他们的职业发展道路,激发其工作热情,避免“天花板”现象;调岗和人才晋升之后,空余的岗位可以吸纳更多优秀的人才,给集团人才梯队注入新鲜血液,带来新思想、新技能。", $defaultParagraphStyle);
     $section->addTitle("5、对不同层次后备人才进行职业生涯规划", 3);
     $section->addText("    结合集团战略与人才发展规划,以各层次后备人才综合测评作为切入点,以培养高层次、复合型人才为重点,打造有目标、有重点、有计划、有针对性的人才职业生涯规划和针对性、使用与培养相结合的体系。", $defaultParagraphStyle);
     $section->addTitle("6、建立不同层次人才综合素质体系,让优秀人才脱颖而出", 3);
     $section->addText("    针对集团管理层和领导方法等有待提升的空间,以本次中青年人才综合测评结果为契机,在不同层次、不同群体人才综合素质与需求动机进行对比分析基础上,建立与集团发展战略需求相匹配胜任力标准,让德才兼备,想干事、能干事、干成事的人才在集团平台上施展自己的才华,使XXX集团成为行业的标杆!", $defaultParagraphStyle);
     //命名
     //临时文件命名规范    $project_id_$date_rand(100,900)
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($this->wordHandle, 'Word2007');
     $date = date('H_i_s');
     $stamp = rand(100, 900);
     $fileName = './tmp/' . $project_id . '_' . $date . '_' . $stamp . '.docx';
     $objWriter->save($fileName);
     return $fileName;
 }
        foreach ($projects as $project) {
            $textRunObj = $section->createTextRun();
            if ($this->action === 'em-cartaz-preview') {
                $textRunObj->addText('PROJETO ' . $project['project']->name . ' ', $eventTitleFont);
                $textRunObj->addText('(');
                $textRunObj->addLink($project['project']->singleUrl, 'link', $eventTitleFont, $eventTitleFont);
                $textRunObj->addText(')');
            } else {
                $section->addText('PROJETO ' . $project['project']->name, $eventTitleFont);
            }
            foreach ($project['events'] as $event) {
                if ($this->action === 'em-cartaz-preview') {
                    $addEventBlockHtml($event);
                } else {
                    $addEventBlockDoc($event);
                }
            }
        }
    }
    if ($this->action === 'em-cartaz-preview') {
        //$content = '<a href="'.$app->createUrl('panel', 'em-cartaz-download').'">Salvar Documento Em Formato Microsoft Word</a>';
        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
        $this->render('em-cartaz', array('content' => $objWriter->getWriterPart('Body')->write(), 'from' => $from, 'to' => $to));
    } else {
        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
        $objWriter->save("php://output");
        $app->response()->header('Content-Type', 'application/vnd.ms-word');
        $app->response()->header('Content-Disposition', 'attachment;filename="Em Cartaz de ' . $from->format('d-m-Y') . ' a ' . $to->format('d-m-Y') . '.docx"');
        $app->response()->header('Cache-Control', 'max-age=0');
    }
});
Пример #30
0
 public function actionHtml()
 {
     $data = $this->getData();
     $searchModel = $data['searchModel'];
     $dataProvider = $data['dataProvider'];
     $title = $data['title'];
     $modelName = $data['modelName'];
     $fields = $this->getFieldsKeys($searchModel->exportFields());
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $section = $phpWord->addSection();
     $section->addTitle($title ? $title : $modelName);
     $table = $section->addTable(['name' => 'Tahoma', 'size' => 10, 'align' => 'center']);
     $table->addRow(300, ['exactHeight' => true]);
     foreach ($fields as $one) {
         $table->addCell(1500, ['bgColor' => 'eeeeee', 'valign' => 'center', 'borderTopSize' => 5, 'borderRightSize' => 5, 'borderBottomSize' => 5, 'borderLeftSize' => 5])->addText($searchModel->getAttributeLabel($one), ['bold' => true, 'size' => 10], ['align' => 'center']);
     }
     foreach ($dataProvider->getModels() as $model) {
         $table->addRow(300, ['exactHeight' => true]);
         foreach ($searchModel->exportFields() as $one) {
             if (is_string($one)) {
                 $table->addCell(1500, ['valign' => 'center', 'borderTopSize' => 1, 'borderRightSize' => 1, 'borderBottomSize' => 1, 'borderLeftSize' => 1])->addText('<p style="margin-left: 10px;">' . $model[$one] . '</p>', ['bold' => false, 'size' => 10], ['align' => 'right']);
             } else {
                 $table->addCell(1500, ['valign' => 'center', 'borderTopSize' => 1, 'borderRightSize' => 1, 'borderBottomSize' => 1, 'borderLeftSize' => 1])->addText('<p style="margin-left: 10px;">' . $one($model) . '</p>', ['bold' => false, 'size' => 10], ['align' => 'right']);
             }
         }
     }
     header('Content-Type: application/html');
     $filename = $modelName . '_' . time() . ".html";
     header('Content-Disposition: attachment;filename=' . $filename . ' ');
     header('Cache-Control: max-age=0');
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
     $objWriter->save('php://output');
 }