当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpWord\Autoloader类代码示例

本文整理汇总了PHP中PhpOffice\PhpWord\Autoloader的典型用法代码示例。如果您正苦于以下问题:PHP Autoloader类的具体用法?PHP Autoloader怎么用?PHP Autoloader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Autoloader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mergeDOCX

 function mergeDOCX($source_file, $merged_file)
 {
     // Important: we get the merge data first, because the phpWord
     // autoloader included below stuffs up the Jethro autoloader
     // and causes errors.
     $data = array_values($this->getMergeData());
     // NB THIS FILE HAS BEEN CHANGED!
     require_once 'include/phpword/src/PhpWord/Autoloader.php';
     \PhpOffice\PhpWord\Autoloader::register();
     \PhpOffice\PhpWord\Settings::setTempDir(dirname($source_file));
     $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($source_file);
     if (!$templateProcessor->cloneBlock('MERGEBLOCK', count($data))) {
         $vars = $templateProcessor->getVariables();
         if (empty($vars)) {
             trigger_error("You don't seem to have included any \${keywords} in your file; cannot merge");
             return;
         }
         $templateProcessor->cloneRow(reset($vars), count($data));
     }
     foreach ($data as $num => $row) {
         foreach ($row as $k => $v) {
             $templateProcessor->setValue(strtoupper($k) . '#' . ($num + 1), $this->xmlEntities($v));
         }
     }
     $templateProcessor->saveAs($merged_file);
 }
开发者ID:vanoudt,项目名称:jethro-pmm,代码行数:26,代码来源:call_odf_merge.class.php

示例2: PhpWord

 function __construct($testResultsHandler)
 {
     Autoloader::register();
     Settings::loadConfig();
     $this->testResultsHandler = $testResultsHandler;
     $this->phpWord = new PhpWord();
 }
开发者ID:KDRS-TEST,项目名称:noark5-validator,代码行数:7,代码来源:ReportBuilder.php

示例3: actionExport

 public function actionExport($id)
 {
     $filepath = dirname(__FILE__) . '/../runtime/result.docx';
     $template_filepath = dirname(__FILE__) . '/../runtime/templates/Template.docx';
     if (file_exists($template_filepath)) {
         $resource = Resource::findOne($id);
         $filename = $resource->name . '.docx';
         $coordinates = json_decode($resource->coordinates);
         $owner = PersonalData::findOne($resource->owner_data_id);
         $owner_name = $owner->last_name . ' ' . $owner->first_name . ' ' . $owner->middle_name;
         $resource_class = ResourceClass::findOne($resource->class_id)->name;
         $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;
         }
         $linear_size = $attributes['length'];
         if ($attributes['width']) {
             $linear_size .= ':' . $attributes['width'];
         }
         if ($attributes['height']) {
             $linear_size .= ':' . $attributes['height'];
         }
         \PhpOffice\PhpWord\Autoloader::register();
         $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template_filepath);
         // Template processing
         $templateProcessor->setValue('name', htmlspecialchars($resource->name, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('class', htmlspecialchars($resource_class, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('subclass', htmlspecialchars($subclass, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('owner', htmlspecialchars($owner_name, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('linear_size', htmlspecialchars($linear_size, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('area', htmlspecialchars($attributes['square'], ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('weight', htmlspecialchars($attributes['weight'], ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('perimeter', htmlspecialchars($attributes['perimeter'], ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('volume', htmlspecialchars($attributes['volume'], ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('reason', htmlspecialchars($reason, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('registrar', htmlspecialchars($registrar, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('registrar_address', htmlspecialchars($registrar, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('registration_number', htmlspecialchars($registration_number, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('registration_date', htmlspecialchars($creation_date, ENT_COMPAT, 'UTF-8'));
         $templateProcessor->setValue('registrar_shortname', htmlspecialchars($registrar_short_name, ENT_COMPAT, 'UTF-8'));
         for ($i = 1; $i <= 20; $i++) {
             $lat = "";
             $lng = "";
             if (count($coordinates) >= $i) {
                 $lat = $coordinates[$i - 1][0];
                 $lng = $coordinates[$i - 1][1];
             }
             $templateProcessor->setValue('lat#' . $i, htmlspecialchars($lat, ENT_COMPAT, 'UTF-8'));
             $templateProcessor->setValue('lng#' . $i, htmlspecialchars($lng, ENT_COMPAT, 'UTF-8'));
         }
         // Saving the document as OOXML file...
         $templateProcessor->saveAs($filepath);
         if (file_exists($filepath)) {
             return \Yii::$app->response->sendFile($filepath, $filename, ['inline' => false])->send();
         }
     }
 }
开发者ID:Vitashev,项目名称:resource-app,代码行数:59,代码来源:ResourceController.php

示例4: testAutoload

 /**
  * Autoload
  */
 public function testAutoload()
 {
     $declaredCount = count(get_declared_classes());
     Autoloader::autoload('Foo');
     $this->assertCount($declaredCount, get_declared_classes(), 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' . 'classes outside of the PhpOffice\\PhpWord namespace');
     // TODO change this class to the main PhpWord class when it is namespaced
     Autoloader::autoload('PhpOffice\\PhpWord\\Exception\\InvalidStyleException');
     $this->assertTrue(in_array('PhpOffice\\PhpWord\\Exception\\InvalidStyleException', get_declared_classes()), 'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' . 'PhpOffice\\PhpWord\\Exception\\InvalidStyleException class');
 }
开发者ID:Senasum,项目名称:PHPWord,代码行数:12,代码来源:AutoloaderTest.php

示例5: array

 function __construct()
 {
     parent::__construct();
     Autoloader::register();
     Settings::loadConfig();
     Settings::setTempDir(getcwd() . TMPDIR_WORD);
     // Set writers
     $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
     // Set PDF renderer
     if (Settings::getPdfRendererPath() === null) {
         $writers['PDF'] = null;
     }
     // Return to the caller script when runs by CLI
     if (PHP_SAPI == 'cli') {
         return;
     }
 }
开发者ID:nhatlang19,项目名称:elearningONL,代码行数:17,代码来源:Word.php

示例6: session_start

<?php

include "../core/autoload.php";
include "../core/app/model/ReservationData.php";
include "../core/app/model/PacientData.php";
include "../core/app/model/MedicData.php";
include "../core/app/model/StatusData.php";
include "../core/app/model/PaymentData.php";
session_start();
require_once '../PhpWord/Autoloader.php';
use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings;
Autoloader::register();
$word = new PhpOffice\PhpWord\PhpWord();
$alumns = $_SESSION["report_data"];
$section1 = $word->AddSection();
$section1->addText("REPORTE DE CITAS", array("size" => 22, "bold" => true, "align" => "right"));
$styleTable = array('borderSize' => 6, 'borderColor' => '888888', 'cellMargin' => 40);
$styleFirstRow = array('borderBottomColor' => '0000FF', 'bgColor' => 'AAAAAA');
$table1 = $section1->addTable("table1");
$table1->addRow();
$table1->addCell()->addText("Asunto");
$table1->addCell()->addText("Paciente");
$table1->addCell()->addText("Medico");
$table1->addCell()->addText("Fecha");
$table1->addCell()->addText("Estado");
$table1->addCell()->addText("Pago");
$table1->addCell()->addText("Costo");
$total = 0;
foreach ($alumns as $al) {
    $medic = $al->getMedic();
开发者ID:evilnapsis,项目名称:bookmedik,代码行数:31,代码来源:report-word.php

示例7: dirname

<?php

include_once dirname(__FILE__) . '/../../lib/PHPWord/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
class RTipoDocumento
{
    private $dataSource;
    private $plantilla;
    //Ruta relativa para incluir la plantilla
    public function __construct($PlantillaReporte)
    {
        $this->plantilla = $PlantillaReporte;
    }
    public function setDataSource(DataSource $dataSource)
    {
        $this->dataSource = $dataSource;
    }
    public function getDataSource()
    {
        return $this->dataSource;
    }
    function write($fileName)
    {
        $phpWord = new \PhpOffice\PhpWord\PhpWord();
        //echo dirname(__FILE__).'/'.$this->plantilla;exit;
        $document = $phpWord->loadTemplate(dirname(__FILE__) . '/' . $this->plantilla);
        setlocale(LC_ALL, "es_ES@euro", "es_ES", "esp");
        //var_dump($this->dataSource);
        foreach ($this->dataSource->getParameters() as $col => $val) {
            //echo 'kkk:'. $col .' '.$val;
            $document->setValue($col, $val);
开发者ID:hcvcastro,项目名称:pxp,代码行数:31,代码来源:RTipoDocumento.php

示例8: ciniki_conferences_conferenceScheduleDownload

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
//.........这里部分代码省略.........
开发者ID:ciniki,项目名称:conferences,代码行数:101,代码来源:conferenceScheduleDownload.php

示例9: readDocument

	function readDocument($path){
	
		$conf =& JFactory::getConfig();
		$tmp_path = $conf->getValue('config.tmp_path');
	
		$acceptableFiles = array( 'application/msword' => "doc",//doc
				'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => "docx",//docx,
				'application/pdf' => "pdf" //pdf
		);
	
		$finfo 		    = finfo_open(FILEINFO_MIME_TYPE);
		$file_extension = finfo_file($finfo, $path);
		finfo_close($finfo);
	
		if(array_key_exists($file_extension, $acceptableFiles)){
	
			if($acceptableFiles[$file_extension] == "doc" || $acceptableFiles[$file_extension] == "docx"){
					
				require_once 'libraries/PHPWord-master/src/PhpWord/Autoloader.php';
				\PhpOffice\PhpWord\Autoloader::register();
					
				$phpWord = \PhpOffice\PhpWord\IOFactory::load($path);
				$result = $this->write($phpWord, "temp", array('HTML' => 'html'),$tmp_path);
					
				$contents = file_get_contents($tmp_path.'/temp.html', true);
					
			}else if($acceptableFiles[$file_extension] == "pdf"){
				include 'libraries/pdfparser/vendor/autoload.php';
					
				$parser = new \Smalot\PdfParser\Parser();
				$pdf    = $parser->parseFile($path);
					
				$contents = $pdf->getText();
					
			}
		}
		return $contents;
	}
开发者ID:kaantunc,项目名称:myk_git,代码行数:38,代码来源:basvuru_kaydet.php

示例10: _genExport

 /**
  * Generate  export file of current result
  */
 protected function _genExport($po_result, $ps_output_type, $ps_output_filename, $ps_title = null)
 {
     $this->view->setVar('criteria_summary', $vs_criteria_summary = $this->getCriteriaForDisplay());
     // add displayable description of current search/browse parameters
     $this->view->setVar('criteria_summary_truncated', mb_substr($vs_criteria_summary, 0, 60) . (mb_strlen($vs_criteria_summary) > 60 ? '...' : ''));
     $this->opo_result_context->setParameter('last_export_type', $ps_output_type);
     $this->opo_result_context->saveContext();
     if (substr($ps_output_type, 0, 4) !== '_pdf') {
         switch ($ps_output_type) {
             case '_xlsx':
                 require_once __CA_LIB_DIR__ . "/core/Parsers/PHPExcel/PHPExcel.php";
                 require_once __CA_LIB_DIR__ . "/core/Parsers/PHPExcel/PHPExcel/Writer/Excel2007.php";
                 $vs_content = $this->render('Results/xlsx_results.php');
                 return;
             case '_docx':
                 require_once __CA_LIB_DIR__ . "/core/Parsers/PHPWord/Autoloader.php";
                 \PhpOffice\PhpWord\Autoloader::register();
                 $vs_content = $this->render('Results/docx_results.php');
                 return;
             case '_csv':
                 $vs_delimiter = ",";
                 $vs_output_file_name = mb_substr(preg_replace("/[^A-Za-z0-9\\-]+/", '_', $ps_output_filename . '_csv'), 0, 30);
                 $vs_file_extension = 'txt';
                 $vs_mimetype = "text/plain";
                 break;
             case '_tab':
                 $vs_delimiter = "\t";
                 $vs_output_file_name = mb_substr(preg_replace("/[^A-Za-z0-9\\-]+/", '_', $ps_output_filename . '_tab'), 0, 30);
                 $vs_file_extension = 'txt';
                 $vs_mimetype = "text/plain";
             default:
                 break;
         }
         header("Content-Disposition: attachment; filename=export_" . $vs_output_file_name . "." . $vs_file_extension);
         header("Content-type: " . $vs_mimetype);
         // get display list
         self::Index(null, null);
         $va_display_list = $this->view->getVar('display_list');
         $va_rows = array();
         // output header
         $va_row = array();
         foreach ($va_display_list as $va_display_item) {
             $va_row[] = $va_display_item['display'];
         }
         $va_rows[] = join($vs_delimiter, $va_row);
         $po_result->seek(0);
         $t_display = $this->view->getVar('t_display');
         while ($po_result->nextHit()) {
             $va_row = array();
             foreach ($va_display_list as $vn_placement_id => $va_display_item) {
                 $vs_value = html_entity_decode($t_display->getDisplayValue($po_result, $vn_placement_id, array('convert_codes_to_display_text' => true, 'convertLineBreaks' => false)), ENT_QUOTES, 'UTF-8');
                 // quote values as required
                 if (preg_match("![^A-Za-z0-9 .;]+!", $vs_value)) {
                     $vs_value = '"' . str_replace('"', '""', $vs_value) . '"';
                 }
                 $va_row[] = $vs_value;
             }
             $va_rows[] = join($vs_delimiter, $va_row);
         }
         $this->opo_response->addContent(join("\n", $va_rows), 'view');
     } else {
         //
         // PDF output
         //
         $va_template_info = caGetPrintTemplateDetails('results', substr($ps_output_type, 5));
         if (!is_array($va_template_info)) {
             $this->postError(3110, _t("Could not find view for PDF"), "BaseFindController->PrintSummary()");
             return;
         }
         try {
             $this->view->setVar('base_path', $vs_base_path = pathinfo($va_template_info['path'], PATHINFO_DIRNAME));
             $this->view->addViewPath(array($vs_base_path, "{$vs_base_path}/local"));
             $vs_content = $this->render($va_template_info['path']);
             $o_dompdf = new DOMPDF();
             $o_dompdf->load_html($vs_content);
             $o_dompdf->set_paper(caGetOption('pageSize', $va_template_info, 'letter'), caGetOption('pageOrientation', $va_template_info, 'portrait'));
             $o_dompdf->set_base_path(caGetPrintTemplateDirectoryPath('results'));
             $o_dompdf->render();
             $o_dompdf->stream(caGetOption('filename', $va_template_info, 'export_results.pdf'));
         } catch (Exception $e) {
             $this->postError(3100, _t("Could not generate PDF"), "BaseFindController->PrintSummary()");
         }
         return;
     }
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:88,代码来源:BaseFindController.php

示例11: downloadWord

 public function downloadWord()
 {
     // echo COMMON_PATH . 'Org/PhpWord/Autoloader.php';exit;
     require_once COMMON_PATH . 'Org/PhpWord/Autoloader.php';
     \PhpOffice\PhpWord\Autoloader::register();
     \PhpOffice\PhpWord\Settings::loadConfig();
     echo date('H:i:s'), ' Create new PhpWord object', EOL;
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $section = $phpWord->addSection();
     $header = array('size' => 16, 'bold' => true);
     $styleTable = array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'width' => '100%');
     $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
     $styleCell = array('align' => 'center');
     $fontStyle = array('bold' => true, 'align' => 'center');
     $section->addText("用户相关", $header);
     $phpWord->addTableStyle('Table', $styleTable);
     $table = $section->addTable('Table');
     $table->addRow(30);
     $table->addCell(2000, $styleCell)->addText("字段", $fontStyle);
     $table->addCell(1000, $styleCell)->addText("类型", $fontStyle);
     $table->addCell(800, $styleCell)->addText("必选", $fontStyle);
     $table->addCell()->addText("说明", $fontStyle);
     for ($i = 1; $i <= 8; $i++) {
         $table->addRow();
         $table->addCell(2000)->addText("userTel");
         $table->addCell(1000)->addText("字符串");
         $table->addCell(800)->addText("是");
         $table->addCell()->addText(htmlspecialchars("手机号码"));
     }
     $section->addPageBreak();
     $fileName = "word报表" . date("YmdHis") . ".docx";
     // header("Content-type: application/vnd.ms-word");
     // header("Content-Disposition:attachment;filename=".$fileName.".docx");
     // header('Cache-Control: max-age=0');
     $phpWord->save($fileName, 'Word2007');
 }
开发者ID:Orchild,项目名称:mt,代码行数:36,代码来源:IndexController.class.php

示例12: systemReport

 /**
  * @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';
//.........这里部分代码省略.........
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:101,代码来源:CompetencyExport.php

示例13: report

 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();
//.........这里部分代码省略.........
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:101,代码来源:IndividualComExport.php

示例14: actionExport

 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);
//.........这里部分代码省略.........
开发者ID:romangrb,项目名称:resource-registry,代码行数:101,代码来源:ResourceController.php

示例15: report

 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);
//.........这里部分代码省略.........
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:101,代码来源:ProjectComExport.php


注:本文中的PhpOffice\PhpWord\Autoloader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。