예제 #1
0
} else {
    if ($count_direta > $count_indireta) {
        $maximo = $count_direta;
    } else {
        $maximo = $count_indireta;
    }
}
// New Word Document
// echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$header = array('bold' => true, 'name' => 'Arial', 'align' => 'center');
$phpWord->addFontStyle('rStyle', array('name' => 'Arial', 'bold' => true));
$phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceBefore' => 10, 'spaceAfter' => 10));
$phpWord->addParagraphStyle('l2Style', array('align' => 'left', 'spaceBefore' => 10, 'spaceAfter' => 10));
$phpWord->addParagraphStyle('lStyle', array('align' => 'left', 'spaceBefore' => 10, 'spaceAfter' => 10));
$phpWord->setDefaultFontSize(8);
//Tamanho da fonte por default
$section = $phpWord->addSection();
/*Style da tabela*/
$styleTable = array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 10);
$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => 'FFFFFF');
$styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fontStyle = array('bold' => true, 'align' => 'center');
$localStyle = array('bold' => true, 'underline' => 'single');
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
$cellColSpan3 = array('gridSpan' => 3, 'valign' => 'center');
$cellColSpan4 = array('gridSpan' => 4, 'valign' => 'center');
$cellColSpan3Cinza = array('gridSpan' => 3, 'valign' => 'center', 'bgColor' => 'CCCCCC');
$cellColSpanCorpo = array('gridSpan' => 3);
$corTitulo = array('valign' => 'center', 'bgColor' => 'CCCCCC');
예제 #2
0
파일: Tools.php 프로젝트: djspys1/baoku
 /**
  * just an example
  * */
 public static function Report($cid)
 {
     $m = InvoicePallet::model()->findByAttributes(array('id' => $cid));
     $n = Supplier::model()->findByAttributes(array('number' => $m->supplier_no));
     $i = Pallet::model()->findByAttributes(array('id' => $m->pid));
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require_once Yii::getPathOfAlias('webroot') . '/assets/phpword/samples/Sample_Header.php';
     spl_autoload_register(array('YiiBase', 'autoload'));
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $phpWord->setDefaultFontName('新宋体');
     $phpWord->setDefaultFontSize(12);
     $phpWord->setDefaultParagraphStyle(array('align' => 'both', 'lineHeight' => '2'));
     $section = $phpWord->addSection();
     $section->addText('开票通知', array('bold' => true, 'size' => 24), array('align' => 'center', 'space' => array('before' => 200, 'after' => 100)));
     $section->addText('注意:请收到立即开票!谢谢!', array('bold' => true, 'size' => 20), array('align' => 'center', 'space' => array('before' => 200, 'after' => 200)));
     $section->addText('TO:' . ' ' . $n->name . '        传真:', null, array('align' => 'left'));
     $section->addText('公司名称:拓泓贸易(上海)有限公司', null, array('align' => 'left'));
     $section->addText('纳税人识别号:310112690186868', null, array('align' => 'left'));
     $section->addText('开票地址电话:上海市闵行区元江路5500号D1幢869室(021-54846073)', null, array('align' => 'left'));
     $section->addText('开户行及账号:上海浦东发展银行闵行支行 98280154740006293', null, array('align' => 'left'));
     $section->addTextBreak(1);
     $section->addText('开票资料如下:', array('bold' => true, 'size' => 16), array('align' => 'left'));
     $styleTable = array('borderSize' => 2, 'borderColor' => '686868', 'align' => 'center');
     $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
     $styleCell = array('valign' => 'center', 'halign' => 'center');
     $fontStyle = array('bold' => false, 'size' => 11, 'borderSize' => 2);
     $center = array('spaceBefore' => 10, 'spaceAfter' => 0, 'align' => 'center', 'valign' => 'center');
     $phpWord->addTableStyle('table1', $styleTable, array('align' => 'center'));
     $table = $section->addTable('table1');
     $table->addRow();
     $table->addCell(1800)->addText('开票品名', $fontStyle, $center);
     $table->addCell(1000)->addText('型号', $fontStyle, $center);
     $table->addCell(800)->addText('数量', $fontStyle, $center);
     $table->addCell(800)->addText('单位', $fontStyle, $center);
     $table->addCell(1000)->addText('单价', $fontStyle, $center);
     $table->addCell(1800)->addText('总价', $fontStyle, $center);
     $table->addCell(2500)->addText('合同号', $fontStyle, $center);
     $table->addRow();
     $table->addCell(1800)->addText($m->type, $fontStyle, $center);
     $table->addCell(1000)->addText($m->model, $fontStyle, $center);
     $table->addCell(800)->addText($m->num, $fontStyle, $center);
     $table->addCell(800)->addText($m->unit, $fontStyle, $center);
     $table->addCell(800)->addText($m->unit_price, $fontStyle, $center);
     $table->addCell(1800)->addText($m->unit_price * $m->num, $fontStyle, $center);
     $table->addCell(2500)->addText($i->purchase_contract_no, $fontStyle, $center);
     $table->addRow();
     $table->addCell(1800)->addText('合计', $fontStyle, $center);
     $table->addCell(1000)->addText('', $fontStyle, $center);
     $table->addCell(800)->addText('', $fontStyle, $center);
     $table->addCell(800)->addText('', $fontStyle, $center);
     $table->addCell(800)->addText('', $fontStyle, $center);
     $table->addCell(1800)->addText('¥' . $m->unit_price * $m->num, $fontStyle, $center);
     $table->addCell(2500)->addText($i->purchase_contract_no, $fontStyle, $center);
     $section->addText('请开票后,全套发票寄至以下地址:', array('bold' => true, 'size' => 12), array('align' => 'left'));
     $section->addText('上海市闵行区曲吴路589号9号楼205', null, array('align' => 'left'));
     $section->addText('拓泓贸易(上海)有限公司', null, array('align' => 'left'));
     $section->addText('电话:021-54846073 	13661561440', null, array('align' => 'left'));
     $section->addText('联系人:叶建伟', null, array('align' => 'left'));
     $section->addText('如有疑问,请今日联系!', null, array('align' => 'left'));
     $section->addText('日期:' . date('Y-m-d'), null, array('align' => 'left'));
     $fileName = "{$n->name}.doc";
     //         $fileName = iconv ( "utf-8", "gb2312", $fileName);
     //         $fileName = mb_convert_encoding($fileName, "utf-8", "auto");
     $absPath = Yii::getPathOfAlias('webroot');
     $relPath = '/uploads/files/';
     $file = $absPath . $relPath . $fileName;
     $fPath = $relPath . $fileName;
     $fName = '开票通知 - ' . date("Ymd");
     $res = array('name' => $fName, 'url' => $fPath);
     write($phpWord, $file, $writers);
     return $res;
 }