コード例 #1
0
ファイル: OrderController.php プロジェクト: usky105/baseshop1
 public function actionCreateExcel()
 {
     define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
     $objPHPExcel = new \PHPExcel();
     $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("PHPExcel Test Document")->setSubject("PHPExcel Test Document")->setDescription("Test document for PHPExcel, generated using PHP classes.")->setKeywords("office PHPExcel php")->setCategory("Test result file");
     //设置当前的sheet
     $objPHPExcel->setActiveSheetIndex(0);
     //设置工作簿默认的样式
     $objPHPExcel->getDefaultStyle()->getFont()->setName('宋体');
     //设置sheet的name
     $objPHPExcel->getActiveSheet()->setTitle('Nagoya');
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15.75);
     $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15.75);
     $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15.4);
     $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(13.75);
     $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(11.15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(14.13);
     $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(8.25);
     $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(8.5);
     $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(8.5);
     $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(8.5);
     $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(8.5);
     $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(8.5);
     $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(16.75);
     $objPHPExcel->getActiveSheet()->mergeCells('A1:B1');
     $objPHPExcel->getActiveSheet()->setCellValue('A1', 'IMPRESSION France');
     //$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(16);
     $objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('D1:F1');
     $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Chiffre d\'affaires en');
     //$objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->setSize(14);
     $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('G1:H1');
     $objPHPExcel->getActiveSheet()->setCellValue('G1', '10-2014');
     //$objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setSize(14);
     $objPHPExcel->getActiveSheet()->getStyle('G1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('A3:A4');
     $objPHPExcel->getActiveSheet()->setCellValue('A3', 'Date Facture');
     //$objPHPExcel->getActiveSheet()->getStyle('A3')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('A3')->getFont()->setSize(11);
     $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('A3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('B3:B4');
     $objPHPExcel->getActiveSheet()->setCellValue('B3', 'Nom de Client');
     //$objPHPExcel->getActiveSheet()->getStyle('B3')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('B3')->getFont()->setSize(11);
     $objPHPExcel->getActiveSheet()->getStyle('B3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('B3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('C3:C4');
     $objPHPExcel->getActiveSheet()->setCellValue('C3', 'Numéro Facture');
     //$objPHPExcel->getActiveSheet()->getStyle('C3')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('C3')->getFont()->setSize(9);
     $objPHPExcel->getActiveSheet()->getStyle('C3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('C3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('D3:F3');
     $objPHPExcel->getActiveSheet()->setCellValue('D3', 'HT €  ');
     $objPHPExcel->getActiveSheet()->getStyle('D3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('D3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->setCellValue('D4', 'Ventes hors UE');
     $objPHPExcel->getActiveSheet()->setCellValue('E4', 'Ventes UE');
     $objPHPExcel->getActiveSheet()->setCellValue('F4', 'Vente en Fr');
     //$objPHPExcel->getActiveSheet()->getStyle('D4')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('D4')->getFont()->setSize(8);
     //$objPHPExcel->getActiveSheet()->getStyle('E4')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('E4')->getFont()->setSize(8);
     //$objPHPExcel->getActiveSheet()->getStyle('F4')->getFont()->setName('宋体');
     $objPHPExcel->getActiveSheet()->getStyle('F4')->getFont()->setSize(8);
     $objPHPExcel->getActiveSheet()->getStyle('D4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('F4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('E4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('G3:G4');
     $objPHPExcel->getActiveSheet()->setCellValue('G3', 'TVA €');
     $objPHPExcel->getActiveSheet()->getStyle('G3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('G3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('H3:H4');
     $objPHPExcel->getActiveSheet()->setCellValue('H3', 'TTC €');
     $objPHPExcel->getActiveSheet()->getStyle('H3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('H3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('I3:L3');
     $objPHPExcel->getActiveSheet()->setCellValue('I3', 'Mode de règlement');
     $objPHPExcel->getActiveSheet()->getStyle('I3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('I3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->setCellValue('I4', 'CHQ');
     $objPHPExcel->getActiveSheet()->setCellValue('J4', 'VER');
     $objPHPExcel->getActiveSheet()->setCellValue('K4', 'TRAIT');
     $objPHPExcel->getActiveSheet()->setCellValue('L4', 'ESP');
     $objPHPExcel->getActiveSheet()->getStyle('I4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('J4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('K4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('L4')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells('M3:M4');
     $objPHPExcel->getActiveSheet()->setCellValue('M3', 'Date Règlement');
     $objPHPExcel->getActiveSheet()->getStyle('M3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('M3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     //数据库数据
     $data = Yii::$app->request->get();
     $firstday = isset($data['firstday']) ? $data['firstday'] : 0;
     $lastday = isset($data['lastday']) ? $data['lastday'] : 0;
     if ($firstday != 0 && $lastday != 0) {
         $orders = Orders::find()->where('created_at >= :start AND created_at < :end AND fac_no != 0 ', [':start' => $firstday, ':end' => $lastday])->all();
     } else {
         echo "参数错误";
         exit;
     }
     foreach ($orders as $i => $order) {
         $j = $i + 5;
         if ($order->remise > 0) {
             $remise_html = "(remise-" . $order->remise . "%)";
             $price = $order->sum_price * (100 - $order->remise) / 100;
         } else {
             $remise_html = "";
             $price = $order->sum_price;
         }
         $price = $order->type == 1 ? $price : '-' . $price;
         $objPHPExcel->getActiveSheet()->setCellValue('A' . $j, Date('Y/m/d', $order->created_at));
         $objPHPExcel->getActiveSheet()->setCellValue('B' . $j, $order->customer->username);
         $objPHPExcel->getActiveSheet()->setCellValue('C' . $j, $order->fac_no);
         $objPHPExcel->getActiveSheet()->setCellValue('D' . $j, '');
         $objPHPExcel->getActiveSheet()->setCellValue('F' . $j, $price . $remise_html);
         $objPHPExcel->getActiveSheet()->setCellValue('G' . $j, Helper::getTVA($price) . $remise_html);
         $objPHPExcel->getActiveSheet()->setCellValue('H' . $j, Helper::getTTC($price) . $remise_html);
         /*$objPHPExcel->getActiveSheet()->getStyle('A' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('B' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('C' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('D' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('E' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('F' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('G' . $j)->getFont()->setName('宋体');
           $objPHPExcel->getActiveSheet()->getStyle('H' . $j)->getFont()->setName('宋体');*/
     }
     /*$objWriteHTML = new \PHPExcel_Writer_HTML($objPHPExcel); //输出网页格式的对象
       $objWriteHTML->save("php://output");
       exit;*/
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save(str_replace('.php', Date("Y", $firstday) . "_" . Date("m", $firstday) . '.xlsx', __FILE__));
     echo "Success !<br>";
     echo "The EXCEL FILE is in :" . dirname(__FILE__);
     exit;
 }
コード例 #2
0
ファイル: mpdf_avoir.php プロジェクト: usky105/baseshop1
}
?>

			<?php 
if ($order['remise'] != 0) {
    $sumprice = $order['sum_price'] * (100 - $order['remise']) / 100;
    ?>
				<tr><td colspan="3"></td><td>Remise</td><td><?php 
    echo $order['remise'];
    ?>
</td></tr>
			<?php 
} else {
    $sumprice = $order['sum_price'];
}
?>
			<tr><td colspan="3"></td><td>MONTANT H.T</td><td><?php 
echo $sumprice;
?>
  </td></tr>
			<tr><td colspan="3"></td><td>T.V.A (20%)</td><td><?php 
echo Helper::getTVA($sumprice);
?>
</td></tr>
			<tr><td colspan="3"></td><td>PRIX TOTAL T.T.C</td><td><?php 
echo Helper::getTTC($sumprice);
?>
</td></tr>
		</table>
	</div>
</div>
コード例 #3
0
ファイル: user_orders.php プロジェクト: usky105/baseshop1
echo Html::a('月结总账管理', ['order/ledger'], ['class' => 'btn  btn-danger']);
?>
            </td>           
        </tr>
    </table>    
     
    <div class="jumbotron">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>  
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['label' => '订单编号', 'attribute' => 'order_id'], ['label' => '客户名', 'attribute' => 'action_user', 'format' => 'raw', 'value' => function ($data) {
    return Html::a($data->customer->username, ['order/user-orders', 'customer_id' => $data['action_user']]);
}], ['label' => '原始总价', 'attribute' => 'sum_price'], ['label' => 'Remise', 'value' => function ($data) {
    return $data['remise'] == 0 ? '-' : $data['remise'] . "%";
}], ['label' => 'H.T', 'value' => function ($data) {
    return number_format($data['sum_price'] * (1 - $data['remise'] / 100), 2, ",", ".");
}], ['label' => 'T.V.A', 'value' => function ($data) {
    return Helper::getTVA($data['sum_price'] * (1 - $data['remise'] / 100));
}], ['label' => 'T.T.C', 'value' => function ($data) {
    return Helper::getTTC($data['sum_price'] * (1 - $data['remise'] / 100));
}], ['label' => '发票编号', 'value' => function ($data) {
    return $data['fac_no'] == 0 ? '-' : $data['fac_no'];
}], ['attribute' => 'created_at', 'format' => ['date', 'php:Y/m/d H:i']], ['label' => '操作', 'format' => 'raw', 'value' => function ($data) {
    return Html::a('view', ['order/valider-order', 'order_id' => $data['order_id']], ['title' => '添加', 'target' => '_blank']);
}]]]);
?>
    </div>        
</div>