示例#1
0
 public function createConsoleYiiApp()
 {
     require dirname(__FILE__) . '/../../vendor/autoload.php';
     $config = (require dirname(__FILE__) . '/../../protected/config/console-test.php');
     \Yii::$enableIncludePath = false;
     if (!\Yii::app()) {
         \Yii::createConsoleApplication($config);
     }
 }
 /**
  * Serve files.
  */
 public function actionServe()
 {
     Yii::$enableIncludePath = false;
     // preload CFileHelper before disabling Yii autoload
     $tmp = CFileHelper::getExtension('');
     $tmp = CLogger::LEVEL_ERROR;
     //@YiiBase::autoload('CHttpException');
     //@YiiBase::autoload('CExceptionEvent');
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require dirname(dirname(__FILE__)) . '/vendors/minify/min/index.php';
 }
示例#3
0
 /**
  * 
  * 导出订单数据服务费报表
  * 
  */
 public function actionExportServiceCharge()
 {
     header("Content-Type:text/html;charset=GB2312");
     Yii::$enableIncludePath = false;
     Yii::import('application.extensions.PHPExcel.PHPExcel', 1);
     $obj_phpexcel = new PHPExcel();
     $dataserviceModel = new DataServiceFeeModel();
     $getData = $this->_get();
     $time = date('F/d', time());
     //echo $getData['start-time'];
     $whereSql = '';
     if ($getData['platform_type'] != '0') {
         $whereSql .= "AND ORDERTYPE = '" . $getData['platform_type'] . "'";
     }
     if (strlen($getData['gbillno']) > 0) {
         $whereSql .= "AND GENERALBILLNO LIKE '%" . $getData['gbillno'] . "%'";
     }
     if (strlen($getData['start-time']) > 0) {
         $whereSql .= " AND TO_CHAR(REALARRIVALDATE, 'YYYY-MM-DD HH24:MI:SS') > '" . $getData['start-time'] . " 00:00:00'";
     }
     if (strlen($getData['end-time']) > 0) {
         $whereSql .= " AND TO_CHAR(REALARRIVALDATE, 'YYYY-MM-DD HH24:MI:SS') < '" . $getData['end-time'] . " 24:00:00'";
     }
     $data = $dataserviceModel->getNowhereList($whereSql);
     foreach ($data as &$val) {
         $val['price'] = $getData['charge'];
         $val['charge'] = $val['NUM'] * $getData['charge'];
     }
     $opexcel = new OperateExcel();
     $opexcel = PHPExcel_IOFactory::load(Yii::app()->basePath . '\\tmp\\temp\\ServiceFeeTemplate.xlsx');
     $writer = PHPExcel_IOFactory::createWriter($opexcel, 'Excel5');
     $this->actionDoExport('OK', $opexcel->getSheet(1));
     $sheet1 = $opexcel->getSheet(0);
     //设置sheet标题
     $sheet1->setTitle("Debit note");
     //设置客户资料
     $sheet1->getCell('A10')->setValue($getData['platform_type']);
     //设置日期
     $sheet1->getCell('F7')->setValue($time);
     $roll = 14;
     $styleThinBlackBorderOutline = array('borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))));
     //金额
     $price = 0;
     //总数
     $countnum = 0;
     foreach ($data as $res) {
         $price += intval($res['charge']);
         $countnum += intval($res['NUM']);
     }
     //设置数量
     $sheet1->getCell('D15')->setValue($countnum);
     //设置单价
     $sheet1->getCell('E15')->setValue($getData['charge']);
     //设置总价
     $sheet1->getCell('F15')->setValue($countnum * $getData['charge']);
     /*  foreach($data as $key=>$res){
             $roll++;
             //合并单元格
             $sheet1->mergeCells("B{$roll}:C{$roll}");
             //设置字体
             $sheet1->getStyle("A{$roll}:F{$roll}")->getFont()->setName('宋体');
             $sheet1->getStyle("A{$roll}:F{$roll}")->getFont()->setSize(8);
             $sheet1->getStyle("A{$roll}:F{$roll}")->getFont()->setBold(true);
             $sheet1->getStyle("A{$roll}:F{$roll}")->getFont()->getColor()->setRGB('0000');
             //序号
             $sheet1->setCellValueByColumnAndRow(0,$roll,$key+1);
             //收费项目
             $sheet1->setCellValueByColumnAndRow(1,$roll,'数据处理费');
             //数量
             $sheet1->setCellValueByColumnAndRow(3,$roll,$res['NUM']);
             //单价
             $sheet1->setCellValueByColumnAndRow(4,$roll,'¥'.number_format($res['price'],2));
             //金额
             $sheet1->setCellValueByColumnAndRow(5,$roll,'¥'.number_format($res['charge'],2));
             $price += intval($res['charge']);
             $sheet1->setCellValueByColumnAndRow(5,$roll+1,$price);
             //设置边框
             $sheet1->getStyle("A{$roll}")->applyFromArray($styleThinBlackBorderOutline);
             $sheet1->getStyle("B{$roll}:C{$roll}")->applyFromArray($styleThinBlackBorderOutline);
             $sheet1->getStyle("D{$roll}")->applyFromArray($styleThinBlackBorderOutline);
             $sheet1->getStyle("E{$roll}")->applyFromArray($styleThinBlackBorderOutline);
             $sheet1->getStyle("F{$roll}")->applyFromArray($styleThinBlackBorderOutline);
             //生成一行
             $sheet1->insertNewRowBefore($roll+1,1);
         }
             
             //删除一行
             $sheet1->removeRow($roll+1,1); */
     $filename = uniqid() . '.xls';
     $file_name = "顺益订单服务费(" . $getData['platform_type'] . "_" . $getData['start-time'] . "_" . $getData['end-time'] . ")";
     $show_name = "{$file_name}.xls";
     $write1 = PHPExcel_IOFactory::createWriter($opexcel, 'Excel5');
     $write1->save($filename);
     //解决乱码
     ob_end_clean();
     //弹出下载对话框
     header('Content-Disposition: attachment; filename=' . $show_name);
     header('Content-Length: ' . filesize($filename));
     //生成缓存文件
     readfile($filename);
     //删除缓存文件
     unlink($filename);
 }
示例#4
0
<?php

//include('compressor.php');
date_default_timezone_set('Asia/Ho_Chi_Minh');
error_reporting(E_ALL);
//ini_set('display_errors', '1');
// change the following paths if necessary
// error_reporting(E_ALL);
$yii = dirname(__FILE__) . '/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $yii;
Yii::$enableIncludePath = false;
Yii::createWebApplication($config)->run();
    public function actionAlertaFinalizaPresubasta()
    {
        Yii::$enableIncludePath = false;
        //
        //list($MailController) = Yii::app()->createController('Mail');
        //$MailController->mailsend();
        $arreglo = array();
        $criteria = new CDbCriteria();
        // Verificar
        // Existe una subasta silenciosa activa?
        $criteria = new CDbCriteria();
        $criteria->condition = 'silenciosa=:silenciosa';
        $criteria->params = array(':silenciosa' => 1);
        $subas = Subastas::model()->find($criteria);
        if ($subas == null) {
            //Tomo ultima silenciosa
            $criteria->condition = 'fuesilenciosa=:fuesilenciosa';
            $criteria->params = array(':fuesilenciosa' => 1);
            $criteria->order = 'id DESC';
            $silenciosa = Subastas::model()->find($criteria);
            // Ya fue enviado los correos masivos.
            if ($silenciosa->envio_correos_pre) {
                return;
            }
            // Pre Subasta
            $actualTime = new DateTime("now");
            $intervaloPresubasta = $actualTime->getTimestamp() - $silenciosa->fechaPresubasta()->getTimestamp();
            // Verificando que se encuentra en los proximos 10 minutos al finalizar la subasta.
            if (!($intervaloPresubasta >= 0 && $intervaloPresubasta <= 600)) {
                return;
            }
        } else {
            return;
        }
        $footer = Correos::model()->find('id=:id', array('id' => 1));
        //construyo el titulo del mensaje
        $subject = $silenciosa['nombre'] . ' ' . $silenciosa['nombrec'] . ' en vivo inicia en una hora';
        //obtengo los resultados de las obras en la subasta finalizada.
        //$imagenes = ImagenS::model()->findAll('ids=:ids', array(':ids' => $silenciosa['id']));
        $criteria = new CDbCriteria();
        $criteria->distinct = true;
        $criteria->condition = "ids=" . $silenciosa->id;
        $criteria->select = 'id_usuario, ids';
        $imagenes = ImagenS::model()->findAll($criteria);
        $message = "";
        //echo $silenciosa['nombre'];
        //echo "Hola";
        foreach ($imagenes as $key => $value) {
            //valido que la obra la tenga un usuario y q no vuelva a entrar ese mismo usuario
            /*
                                    if($value->id_usuario and !in_array($value->id_usuario, $arreglo))
                                    {*/
            $usuario = Usuarios::model()->find('id=:id', array(':id' => $value->id_usuario));
            $usuariospuja = Usuariospujas::model()->find('idusuario=:idusuario and idsubasta=:idsubasta', array(':idusuario' => $usuario['id'], ':idsubasta' => $silenciosa['id']));
            if (!$usuariospuja) {
                continue;
            }
            $correo = $usuario['email'];
            $nombre = $usuario['nombre'];
            $apellido = $usuario['apellido'];
            $paleta = $usuariospuja['paleta'];
            $to = $correo;
            $message .= '<h2> Las obras a las que no dejo puja quedan hasta ahí. Haga click aquí para ir a <a href="' . Yii::app()->request->baseUrl . '">Subastas Odalys </a></h2>';
            $message = '
               <h2 style="padding-bottom:5px !important; font-size:14px !important;">Estimado(a) ' . strtoupper($nombre) . ' ' . strtoupper($apellido) . ', la Pre-' . $silenciosa['nombre'] . ' ' . $silenciosa['nombrec'] . ' ha finalizado a las 5:00 p.m. del día de hoy.</h2>
               <h2 style="padding-bottom:10px !important; font-size:14px !important;">Hasta el momento Ud. tiene la última puja de los siguientes lotes:</h2><br/>
                <table width="100%">
                  <thead>
                    <tr>

                      <th align="left" style="width: 200px;">LOTE</th>
                      <th align="left">ÚLTIMA PUJA</th>

                    </tr>
                  </thead>
                  <tbody>';
            //$arreglo[] = $value->id_usuario;
            $usuarios = ImagenS::model()->findAll('id_usuario=:id_usuario and ids=:idsubasta', array(':id_usuario' => $value->id_usuario, ':idsubasta' => $silenciosa['id']));
            // Lista de imágenes del usuario.
            foreach ($usuarios as $ky => $valor) {
                $message .= '<tr>
					 <td align="left" style="width: 200px;">
					  <!--<img src="http://www.odalys.com/odalys/' . $valor->imagen . '" style="float:left;padding-right:20px;"/>-->
					  ' . $valor->descri . '
					</td>';
                $message .= '
					 <td align="center">' . $silenciosa['moneda'] . ' ' . number_format($valor->actual) . '</td>
					</tr>';
            }
            $message .= '</tbody>
				</table>
				<hr>';
            $message .= '<h2 style="padding-bottom:10px !important; font-size:14px !important;">
                Le recordamos que si no seleccioó alguna de las opciones para los lotes mencionados anteriormente, asumiremos que
                desea quedarse con su puja actual, en este caso su última puja de la presubasta va a ser tomada como su última oferta en el lote, es decir, el lote será subastado en la sala desde ese monto.
                <br><br>
                Recuerde que la Subasta 237 Maestros Venezolanos, se realizará hoy domingo 29 de noviembre a las 11:00 a.m. en el Hotel JW Marriott Caracas. Salón Armando Reverón. Av. Venezuela con calle Mohedano. El Rosal. Caracas.
                <br><br>
                Ante cualquier duda, por favor póngase en contacto con nosotros.


                ';
            $message .= '

                    <br>
                    Atentamente,
                    <br><br>
                    Casa de Subastas Odalys<br>
                    C. Comercial Concresa, Nivel PB. Local <br>
                    115 y 116, Prados del Este, Baruta 1080,<br>
                    Estado Miranda, Venezuela<br>
                    Telfs: +58 2129795942, +58 2129761773<br>
                    Fax: +58 212 9794068<br>
                    odalys@odalys.com<br>


                </div>';
            //echo $message;
            //echo "Fin de mensaje";
            //echo "----------------------------------";
            //echo "<br>";
            echo 'Enviando correo a: ' . $to . ' con asunto: ' . $subject;
            echo PHP_EOL;
            $this->mailsend($to, $subject, $message);
            //$MailController->mailsend($to,$subject,$message);
            //var_dump(($value));
            //die;
            $message = "";
            $to = "";
            //$subject = "";
            //	$this->render('compradores', array('valor'=>$message));
            //}
            $message = "";
            $to = "";
            //$subject = "";
        }
        // Se marca la subasta que fue silenciosa como  enviada los correos.
        $silenciosa->envio_correos_pre = 1;
        if ($silenciosa->save()) {
            return;
        }
    }
	/**
	 * 生成多个sheet的excel
	 */
	public function exportSheetExcel($listArr1 , $listArr2 , $headArr1 , $headArr2){
		//if(!$listArr || !$headArr) return false;
		set_time_limit(0);
		// 关闭YII的自动加载功能,改用手动加载,否则会出错,PHPExcel有自己的自动加载功能
		Yii::$enableIncludePath=false;
		/*引入PHPExcel.php文件*/
		Yii::import('application.extensions.PHPExcel.PHPExcel', 1);
	
		$obj_phpexcel = new PHPExcel();
		$obj_phpexcel->setActiveSheetIndex(0); //设置第一个工作表为活动工作表
		$obj_phpexcel->getActiveSheet()->setTitle('orderhead'); //设置工作表名称
		$objActSheet = $obj_phpexcel->getActiveSheet();
		//设置字体
		$objActSheet->getDefaultStyle()->getFont()->setName('微软雅黑');
		//设置字体大小
		$objActSheet->getDefaultStyle()->getFont()->setSize(9);
		//设置自动行高
		$objActSheet->getDefaultRowDimension()->setRowHeight(15);
		$key = 0;
		$keyArr = array();
		foreach($headArr1 as $v){
			$index = PHPExcel_Cell::stringFromColumnIndex($key);
			$keyArr[] = $index;
			//设置页头填充色
			$objStyle = $objActSheet ->getStyle($index.'1');
			$objFill = $objStyle->getFill();
			$objFill->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
			$objFill->getStartColor()->setARGB('#FFFF00');
			//设置页头边框色
			$objBorder = $objStyle->getBorders();
			$objBorder->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objBorder->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objBorder->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objBorder->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			//设置自动列宽
			$objActSheet->getColumnDimension($index)->setAutoSize(true);
			//设置对其方式
			$objAlign = $objStyle->getAlignment();
			$objAlign->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objAlign->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
			$obj_phpexcel->setActiveSheetIndex(0)->setCellValue($index.'1' , $v);
			$key++;
		}
		$keyWordArr = CDict::$title_key_word;
		$keyWordArr2 = CDict::$title_hscode_word;
		$key2 = 2;
		foreach($listArr1 as $l_key =>$info){ //行写入
			$key3 = 0;
			foreach($info as $c_key=>$value){// 列写入
				$span = $keyArr[$key3];
				// 				$objStyle = $objActSheet ->getStyle($span.$key2);
				// 				$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
				//设置单元格避免大数字科学计数显示
// 				if(in_array($c_key, array('ORDERCOMMITTIME','PAY_TIME','USER_ID','IDENTIFY_CODE'))){
// 					$objStyle = $objActSheet ->getStyle($span.$key2);
// 	 				$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
// 				}
				//$objActSheet->setCellValue($span.$key2, $value);
				if(is_numeric($value) && $c_key != 'TRX_SERIAL_NO' && $c_key!='IDENTIFY_CODE' && $c_key!='USER_ID' && $c_key != 'GOODNO' && $c_key != 'HSCODE' && $c_key != 'RECEIVEZIPCODE' && $c_key != 'RECZIP' && $c_key != 'MERCHANTORDERID'){
					$objStyle = $objActSheet ->getStyle($span.$key2);
					if(strpos($value,'.')){
						$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
					}else{
						$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
					}
					$objActSheet->setCellValue($span.$key2,$value);
				}else{
					$objActSheet->setCellValueExplicit($span.$key2,$value,PHPExcel_Cell_DataType::TYPE_STRING);
				}
				//$objActSheet->setCellValueExplicit($span.$key2,$value,PHPExcel_Cell_DataType::TYPE_STRING);
				$key3++;
			}
			$key2++;
		}
		
		//创建第二个工作表
		$newWorkSheet = new PHPExcel_Worksheet($obj_phpexcel, 'orderlist'); //创建一个工作表
		$obj_phpexcel->addSheet($newWorkSheet); //插入工作表
		$obj_phpexcel->setActiveSheetIndex(1); //切换到新创建的工作表
		
		$objActSheet1 = $obj_phpexcel->getActiveSheet();
		//设置字体
		$objActSheet1->getDefaultStyle()->getFont()->setName('微软雅黑');
		//设置字体大小
		$objActSheet1->getDefaultStyle()->getFont()->setSize(9);
		//设置自动行高
		$objActSheet1->getDefaultRowDimension()->setRowHeight(15);
		$key = 0;
		$keyArr = array();
		foreach($headArr2 as $v){
			$index = PHPExcel_Cell::stringFromColumnIndex($key);
			$keyArr[] = $index;
			//设置页头填充色
			$objStyle = $objActSheet1 ->getStyle($index.'1');
			$objFill = $objStyle->getFill();
			$objFill->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
			$objFill->getStartColor()->setARGB('#FFFF00');
			//设置页头边框色
			$objBorder = $objStyle->getBorders();
			$objBorder->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objBorder->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objBorder->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objBorder->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			//设置自动列宽
			$objActSheet1->getColumnDimension($index)->setAutoSize(true);
			//设置对其方式
			$objAlign = $objStyle->getAlignment();
			$objAlign->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objAlign->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
			$obj_phpexcel->setActiveSheetIndex(1)->setCellValue($index.'1' , $v);
			$key++;
		}
		$key2 = 2;
		foreach($listArr2 as $l_key =>$info){ //行写入
			$key3 = 0;
			foreach($info as $c_key=>$value){// 列写入
				$span = $keyArr[$key3];
				//设置关键字高亮
				if($c_key == 'NAMEZH'){
					foreach ($keyWordArr as $word){
						if(strpos($value, $word)!==false){
							$objStyle = $objActSheet1 ->getStyle($span.$key2);
							$objStyle->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
							$objStyle->getFont()->setSize(10);
						}
					}
				}
				if($c_key == 'HSCODE'){
				    //设置关键字高亮
				    foreach ($keyWordArr2 as $word2){
				        if(strpos($value, $word2)!==false){
				            $objStyle = $objActSheet1 ->getStyle($span.$key2);
							$objStyle->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
							$objStyle->getFont()->setSize(10);
				        }
				    }
				}
				// 				$objStyle = $objActSheet ->getStyle($span.$key2);
				// 				$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
				//设置单元格避免大数字科学计数显示
// 				$objStyle = $objActSheet1 ->getStyle($span.$key2);
// 				$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
				//$objActSheet1->setCellValue($span.$key2, $value);
				if(is_numeric($value) && $c_key != 'GOODNO' && $c_key != 'HSCODE' && $c_key != 'RECEIVEZIPCODE' && $c_key != 'RECZIP'){
					$objStyle = $objActSheet1 ->getStyle($span.$key2);
					if(strpos($value,'.')){
						$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
					}else{
						$objStyle->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
					}
					$objActSheet1->setCellValue($span.$key2,$value);
				}else{
					$objActSheet1->setCellValueExplicit($span.$key2,$value,PHPExcel_Cell_DataType::TYPE_STRING);
				}
				//$objActSheet1->setCellValueExplicit($span.$key2,$value,PHPExcel_Cell_DataType::TYPE_STRING);
				$key3++;
			}
			$key2++;
		}
		$obj_phpexcel->setActiveSheetIndex(0); //设置第一个工作表为活动工作表
		
		$obj_Writer=new PHPExcel_Writer_Excel5($obj_phpexcel);//用于其他版本格式
		$date = date("YmdHis");
		$filename = "export_".$date.".xls";
		ob_end_clean();//清除缓冲区,避免乱码
		header("Content-Type: application/force-download");
		header("Content-Type: application/octet-stream");
		header("Content-Type: application/download");
		header('Content-Disposition:inline;filename="'.$filename.'"');
		header("Content-Transfer-Encoding: binary");
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Pragma: no-cache");
		$obj_Writer->save('php://output');
	}
示例#7
0
文件: yii.php 项目: keyeMyria/CRM
 /**
  * Imports a class or a directory.
  * Overrides {@link YiiBase::import()} to check in /custom for all imported classes
  *
  * @param string $alias path alias to be imported
  * @param boolean $forceInclude whether to include the class file immediately. If false, the class file
  * will be included only when the class is being used. This parameter is used only when
  * the path alias refers to a class.
  * @return string the class name or the directory that this alias refers to
  * @throws CException if the alias is invalid
  */
 public static function import($alias, $forceInclude = false)
 {
     if (isset(self::$_imports[$alias])) {
         // previously imported
         return self::$_imports[$alias];
     }
     if (class_exists($alias, false) || interface_exists($alias, false)) {
         return self::$_imports[$alias] = $alias;
     }
     if (($pos = strrpos($alias, '\\')) !== false) {
         $namespace = str_replace('\\', '.', ltrim(substr($alias, 0, $pos), '\\'));
         if (($path = self::getPathOfAlias($namespace)) !== false) {
             $classFile = $path . DIRECTORY_SEPARATOR . substr($alias, $pos + 1) . '.php';
             if ($forceInclude) {
                 if (is_file($classFile)) {
                     require self::getCustomPath($classFile);
                 } else {
                     throw new CException(Yii::t('yii', 'Alias "{alias}" is invalid. Make sure it points to an existing PHP file.', array('{alias}' => $alias)));
                 }
                 self::$_imports[$alias] = $alias;
             } else {
                 self::$classMap[$alias] = $classFile;
             }
             return $alias;
         } else {
             throw new CException(Yii::t('yii', 'Alias "{alias}" is invalid. Make sure it points to an existing directory.', array('{alias}' => $namespace)));
         }
     }
     if (($pos = strrpos($alias, '.')) === false) {
         if ($forceInclude && self::x2_autoload($alias)) {
             self::$_imports[$alias] = $alias;
         }
         return $alias;
     }
     $className = (string) substr($alias, $pos + 1);
     $isClass = $className !== '*';
     if ($isClass && (class_exists($className, false) || interface_exists($className, false))) {
         return self::$_imports[$alias] = $className;
     }
     if (($path = self::getPathOfAlias($alias)) !== false) {
         if ($isClass) {
             if ($forceInclude) {
                 if (is_file($path . '.php')) {
                     require self::getCustomPath($path . '.php');
                 } else {
                     throw new CException(Yii::t('yii', 'Alias "{alias}" is invalid. Make sure it points to an existing PHP file.', array('{alias}' => $alias)));
                 }
                 self::$_imports[$alias] = $className;
             } else {
                 self::$classMap[$className] = $path . '.php';
             }
             return $className;
         } else {
             if (self::$_includePaths === null) {
                 self::$_includePaths = array_unique(explode(PATH_SEPARATOR, get_include_path()));
                 if (($pos = array_search('.', self::$_includePaths, true)) !== false) {
                     unset(self::$_includePaths[$pos]);
                 }
             }
             array_unshift(self::$_includePaths, $path);
             if (self::$enableIncludePath && set_include_path('.' . PATH_SEPARATOR . implode(PATH_SEPARATOR, self::$_includePaths)) === false) {
                 self::$enableIncludePath = false;
             }
             return self::$_imports[$alias] = $path;
         }
     } else {
         throw new CException(Yii::t('yii', 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.', array('{alias}' => $alias)));
     }
 }
 /**
  * Serve files.
  */
 public function actionServe()
 {
     Yii::$enableIncludePath = false;
     require dirname(dirname(__FILE__)) . '/vendors/minify/min/index.php';
 }
示例#9
0
文件: Yii.php 项目: fufudao/yii2-base
 /**
  * Registers a new class autoloader.
  * The new autoloader will be placed before {@link autoload} and after
  * any other existing autoloaders.
  * @param callback $callback a valid PHP callback (function name or array($className,$methodName)).
  * @param boolean $append whether to append the new autoloader after the default Yii autoloader.
  * Be careful using this option as it will disable {@link enableIncludePath autoloading via include path}
  * when set to true. After this the Yii autoloader can not rely on loading classes via simple include anymore
  * and you have to {@link import} all classes explicitly.
  */
 public static function registerAutoloader($callback, $append = false)
 {
     if ($append) {
         self::$enableIncludePath = false;
         spl_autoload_register($callback);
     } else {
         spl_autoload_unregister(array('Yii', 'autoload_1'));
         spl_autoload_register($callback);
         spl_autoload_register(array('Yii', 'autoload_1'));
     }
 }
示例#10
0
 public function actionPollRating()
 {
     $orderIds = trim(Yii::app()->request->getParam('orderIds'));
     //获取数据
     $data = PollRating::model()->getExportData($orderIds);
     //获取附件
     $attachments = FileUpload::model()->getFiles($orderIds);
     $pics = array();
     foreach ($attachments as $value) {
         $pics[$value['orderid']][] = $value['file_path'];
     }
     Yii::$enableIncludePath = false;
     //Yii::import('application.extension.PHPExcel', 1);
     $objPHPExcel = new PHPExcel();
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '处理日期')->setCellValue('B1', '产品类型')->setCellValue('C1', '开始时间')->setCellValue('D1', '结束时间')->setCellValue('E1', '处理时间')->setCellValue('F1', '账号')->setCellValue('G1', '订单号')->setCellValue('H1', '申请服务')->setCellValue('I1', '具体内容')->setCellValue('J1', '问题描述')->setCellValue('K1', '处理情况')->setCellValue('L1', '备注')->setCellValue('M1', '处理人员')->setCellValue('N1', '附件');
     //最多支持5张附件图片
     $picColumn = array('N', 'O', 'P', 'Q', 'R');
     $i = 2;
     foreach ($data as $value) {
         $endTime = empty($value["updatetime"]) ? time() : strtotime($value["updatetime"]);
         $startTime = empty($value["intitime"]) ? 0 : strtotime($value["intitime"]);
         $subTime = $endTime - $startTime;
         $remark = "";
         $res = unserialize(base64_decode($value['content']));
         $remarkKey = mb_convert_encoding('备注_', 'GBK', 'UTF8');
         if (isset($res[$remarkKey])) {
             $remark = mb_convert_encoding($res[$remarkKey], 'UTF8', 'GBK');
         }
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, strstr($value["intitime"], ' ', true))->setCellValueExplicit('B' . $i, mb_convert_encoding($value['game_name'], 'UTF8', 'GBK'), PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('C' . $i, trim(strstr($value["intitime"], ' ')))->setCellValueExplicit('D' . $i, $value['updatetime'], PHPExcel_Cell_DataType::TYPE_STRING)->setCellValueExplicit('E' . $i, $subTime, PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('F' . $i, $value['consumeraccount'])->setCellValueExplicit('G' . $i, $value['ordernum'], PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('H' . $i, $value['typename'])->setCellValue('I' . $i, $value['typedetail'])->setCellValueExplicit('J' . $i, $remark, PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue('K' . $i, mb_convert_encoding($value['status'], 'UTF8', 'GBK'))->setCellValue('L' . $i, mb_convert_encoding($value['remark'], 'UTF-8', 'GBK'))->setCellValue('M' . $i, mb_convert_encoding($value['username'], 'UTF8', 'GBK'));
         //图片
         if (isset($pics[$value['orderid']])) {
             foreach ($pics[$value['orderid']] as $key => $pic) {
                 $objDrawing = new PHPExcel_Worksheet_Drawing();
                 $objDrawing->setPath(_PATH_UPLOAD . DIRECTORY_SEPARATOR . $pic);
                 $objDrawing->setCoordinates($picColumn[$key] . $i);
                 $objDrawing->setName($pic);
                 $objDrawing->setHeight(60);
                 $objDrawing->setWidth(60);
                 $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
             }
         }
         //设置行高
         $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(30);
         $i++;
     }
     $filename = mb_convert_encoding('所有接待日志', 'GBK', 'UTF8') . date('YmdHis');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
     header('Cache-Control: max-age=0');
     // If you're serving to IE 9, then the following may be needed
     header('Cache-Control: max-age=1');
     // 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
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save('php://output');
     exit;
 }