| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 | 
							- <?php 
 
- /**
 
-  * 订单分组
 
-  */
 
- require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
 
- require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
 
- class Blacklist_adminAction extends Action{
 
- 	
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		if(empty($_SESSION['mds_user'])){
 
- 			header("Location:/?a=index&m=admin_login");
 
- 			exit();
 
- 		}
 
- //		$this->checkAdministratorRight('5');
 
- 		
 
- 	}
 
- 	
 
- 	function index(){
 
- 		
 
- 		$admin = new AdvertAdminAction();
 
- 		$where = "where uid='{$_SESSION['user_infos']['id']}'";
 
- 		$uname = $_SESSION['user_infos']['uname'];
 
- 		
 
- 		$info           = $_REQUEST['info'];
 
- 		$error			= $_REQUEST['error'];
 
- 		
 
- //		$isexcel    = $_POST['isexcel'];
 
- //
 
- //		//导入数据
 
- //
 
- //		if($_POST['leadExcel'] == "true")
 
- //		{
 
- //			$filename = $_FILES['inputExcel']['name'];
 
- //			$tmp_name = $_FILES['inputExcel']['tmp_name'];
 
- //
 
- //			$excel_array = $this->uploadFile($filename,$tmp_name);
 
- //
 
- //			if(!empty($excel_array['error'])){
 
- //				//导入失败
 
- //				$error = $excel_array['error'];
 
- //
 
- //			}else{
 
- //
 
- //				unset($excel_array[0]);//若第一排的数据是字段名的话,删除
 
- //				header("Content-type: text/html; charset=utf-8");
 
- //
 
- //				foreach($excel_array as $array){
 
- //
 
- //					$insert = $admin->add_black_content($array[0], $array[1], $array[2], $array[3], $array[4], $array[5], $array[6], strtotime($array[7]), time());
 
- //
 
- //				}
 
- //
 
- //				$info = '导入数据成功';
 
- //
 
- //				header("Location:/?a=blacklist_admin&m=index&info=$info");
 
- //				exit();
 
- //
 
- //			}
 
- //
 
- //
 
- //		}
 
- //		//end
 
- 		
 
- 		
 
- 		$list  = $admin->select_black_list($where);
 
- 		foreach($list as &$ls){
 
- 			$ls['add_time'] = date('Y-m-d H:i:s',$ls['add_time']);
 
- 			$ls['update_time'] = date('Y-m-d H:i:s',$ls['update_time']);
 
- 		}
 
- 		
 
- //		//导出数据
 
- //		if($isexcel=='yes'){
 
- //
 
- //			$this->generateEXCEL('blacklist',$list);
 
- //
 
- //			exit;
 
- //		}
 
- 		$this->assign('info',$info);
 
- 		$this->assign('error',$error);
 
- 		$this->assign('list',$list);
 
- 		$this->assign('uname',$uname);
 
- 		$this->display('index.html');
 
- 	}
 
- 	//导出excel
 
- 	function generateEXCEL($filename = 'report',$data = ''){
 
- 		
 
- 		//引入PHPExcel相关文件
 
- 		require_once( ONU_ROOT . 'phpexcel/PHPExcel.php');
 
- 		require_once( ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php');
 
- 		require_once( ONU_ROOT . 'phpexcel/PHPExcel/Writer/Excel5.php');
 
- 		
 
- 		//新建
 
- 		
 
- 		$resultPHPExcel = new PHPExcel();
 
- 		//设置参数
 
- 		
 
- 		//设值
 
- 		
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('A1', '订单来源');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('B1', '负责人姓名 ');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('C1', '用户名');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('D1', '用户uid');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('E1', '国家 ');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('F1', '订单金额');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('G1', '备注说明 ');
 
- 		$resultPHPExcel->getActiveSheet()->setCellValue('H1', '上次购买日期');
 
- 		
 
- 		
 
- 		$i = 2;
 
- 		foreach($data as $item){
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('A' . $i, $item['order_from']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('B' . $i, $item['fz_name']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('C' . $i, $item['uname']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('D' . $i, $item['uid']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('E' . $i, $item['country']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('F' . $i, $item['money']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('G' . $i, $item['remark']);
 
- 			$resultPHPExcel->getActiveSheet()->setCellValue('H' . $i, date('Y-m-d',$item['pre_time']));
 
- 			
 
- 			$i ++;
 
- 		}
 
- 		
 
- 	
 
- 		
 
- 		//设置导出文件名
 
- 		
 
- 		$outputFileName = "$filename.xls";
 
- 		
 
- 		$xlsWriter = new PHPExcel_Writer_Excel5($resultPHPExcel);
 
- 		
 
- 		ob_end_clean();//清除缓冲区,避免乱码
 
- 		
 
- 		
 
- 		//ob_start(); ob_flush();
 
- 		header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
 
- 		
 
- 		header("Content-Type: application/force-download");
 
- 		
 
- 		header("Content-Type: application/octet-stream");
 
- 		
 
- 		header("Content-Type: application/download");
 
- 		
 
- 		header('Content-Disposition:inline;filename="'.$outputFileName.'"');
 
- 		
 
- 		header("Content-Transfer-Encoding: binary");
 
- 		
 
- 		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 
- 		
 
- 		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");
 
- 		
 
- 		
 
- 		
 
- 		$finalFileName = $outputFileName; 
 
- 		$xlsWriter->save($finalFileName); 
 
- 		
 
- 		echo file_get_contents($finalFileName); 
 
- 		exit;
 
- 		
 
- 		
 
- 		
 
- 	}
 
- 	
 
- 	
 
- 	
 
- 	//导入Excel文件
 
- 	function uploadFile($file,$filetempname)
 
- 	{
 
- 		//自己设置的上传文件存放路径
 
- 		$filePath = 'static/upload/';
 
- 		$str = "";
 
- 		//下面的路径按照你PHPExcel的路径来修改
 
- 		require_once ONU_ROOT . 'phpexcel/PHPExcel.php';
 
- 		require_once ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php';
 
- 		require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/Excel5.php';
 
- 	
 
- 		//注意设置时区
 
- 		$time=date("y-m-d-H-i-s");//去当前上传的时间
 
- 		//获取上传文件的扩展名
 
- 		$extend=strrchr ($file,'.');
 
- 		//上传后的文件名
 
- 		$name=$time.$extend;
 
- 		$uploadfile=$filePath.$name;//上传后的文件名地址
 
- 		//move_uploaded_file() 函数将上传的文件移动到新位置。若成功,则返回 true,否则返回 false。
 
- 		$result=move_uploaded_file($filetempname,$uploadfile);//假如上传到当前目录下
 
- 		
 
- 		
 
- 		//echo $result;
 
- 		if($result) //如果上传文件成功,就执行导入excel操作
 
- 		{
 
- 			
 
- 			$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
 
- 			$objPHPExcel = $objReader->load($uploadfile);
 
- 			$sheet = $objPHPExcel->getSheet(0);
 
- 			$highestRow = $sheet->getHighestRow();           //取得总行数
 
- 			$highestColumn = $sheet->getHighestColumn(); //取得总列数
 
- 	
 
- 			/* 第二种方法*/
 
- 			$objWorksheet = $objPHPExcel->getActiveSheet();
 
- 			$highestRow = $objWorksheet->getHighestRow();
 
- 			echo 'highestRow='.$highestRow;
 
- 			echo "<br>";
 
- 			$highestColumn = $objWorksheet->getHighestColumn();
 
- 			$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);//总列数
 
- 			echo 'highestColumnIndex='.$highestColumnIndex;
 
- 			echo "<br>";
 
- 			$headtitle=array();
 
- 			
 
- 			
 
- 			//获取到的excel数据
 
- 			$excel_array = array();
 
- 			
 
- 			
 
- 			for ($row = 1;$row <= $highestRow;$row++)
 
- 			{
 
- 				$strs=array();
 
- 				//注意highestColumnIndex的列数索引从0开始
 
- 				for ($col = 0;$col < $highestColumnIndex;$col++)
 
- 				{
 
- 					$strs[$col] =$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
 
- 					
 
- 					if($strs[$col] instanceof PHPExcel_RichText){     //富文本转换字符串
 
- 						$strs[$col] = $strs[$col]->__toString();
 
- 					}
 
- 					
 
- 					//第七个数字是日期型的
 
- //					if($col==7){
 
- //						$strs[$col]=gmdate("Y-m-d", PHPExcel_Shared_Date::ExcelToPHP($strs[$col]));
 
- //					}
 
- 				}
 
- 				
 
- 				
 
- 				array_push($excel_array, $strs);
 
- 				
 
- 			}
 
- 			
 
- 		}
 
- 		else
 
- 		{
 
- 				$excel_array['error'] = "导入失败!";
 
- 		}
 
- 		return $excel_array;
 
- 		
 
- 	}
 
- 	
 
- 	
 
- 	
 
- 	//end
 
- 	
 
- 	
 
- }
 
- ?>
 
 
  |