Sms_customer_list_adminAction.class.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <?php
  2. /**
  3. * 导入客户信息,导出客户信息
  4. */
  5. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  6. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  7. class Sms_customer_list_adminAction extends Action{
  8. public function __construct(){
  9. parent::__construct();
  10. if(empty($_SESSION['mds_user'])){
  11. header("Location:/?a=index&m=admin_login");
  12. exit();
  13. }
  14. }
  15. //客户列表
  16. public function index(){
  17. require_once (ONU_ROOT . "frame/Page.class.php");
  18. $admin = new AdvertAdminAction();
  19. $uid = $_SESSION['user_infos']['id'];
  20. $info = $_REQUEST['info'];
  21. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  22. $pageSize = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
  23. $n = ($page-1)*$pageSize;
  24. $pa = "";//查询参数
  25. $pa='&pagesize='.$pageSize;
  26. $limit = " $n,$pageSize";
  27. $where = " where uid='$uid' ";
  28. $group_list = $admin->select_sms_user_group($where);
  29. $tel = trim($_REQUEST['tel']);
  30. $group_name = $_REQUEST['group_name'];
  31. if(!empty($tel)) {
  32. $where.=" and tel='$tel'";
  33. }
  34. if(!empty($group_name)){
  35. $where.=" and group_name='$group_name'";
  36. $pa .= "&group_name=$group_name";
  37. }
  38. $where.=" and is_block=0";
  39. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  40. $all_total = $admin->selectSmsCustomerCount($where);
  41. $p = new Page($all_total,$pageSize,$pa);
  42. $pp = $p->fpage();
  43. $this->assign('tel',$tel);
  44. $this->assign('list',$customer_list);
  45. $this->assign('group_list',$group_list);
  46. $this->assign('group_name',$group_name);
  47. $this->assign('info',$info);
  48. $this->assign('page',$page);
  49. $this->assign('pagesize',$pageSize);
  50. $this->assign("show",$pp);
  51. $this->display("index.html");
  52. }
  53. public function blackList(){
  54. require_once (ONU_ROOT . "frame/Page.class.php");
  55. $admin = new AdvertAdminAction();
  56. $info = $_REQUEST['info'];
  57. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  58. $pageSize = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
  59. $n = ($page-1)*$pageSize;
  60. $pa = "";//查询参数
  61. $pa='&pagesize='.$pageSize;
  62. $limit = " $n,$pageSize";
  63. $where = " where 1=1 ";
  64. $tel = trim($_REQUEST['tel']);
  65. if(!empty($tel)) {
  66. $where.=" and tel='$tel'";
  67. }
  68. $where.=" and is_block=1";
  69. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  70. $all_total = $admin->selectSmsCustomerCount($where);
  71. $p = new Page($all_total,$pageSize,$pa);
  72. $pp = $p->fpage();
  73. $this->assign('tel',$tel);
  74. $this->assign('list',$customer_list);
  75. $this->assign('info',$info);
  76. $this->assign('page',$page);
  77. $this->assign('pagesize',$pageSize);
  78. $this->assign("show",$pp);
  79. $this->display("blacklist.html");
  80. }
  81. public function nosendList(){
  82. require_once (ONU_ROOT . "frame/Page.class.php");
  83. $admin = new AdvertAdminAction();
  84. $info = $_REQUEST['info'];
  85. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  86. $pageSize = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
  87. $n = ($page-1)*$pageSize;
  88. $pa = "";//查询参数
  89. $pa='&pagesize='.$pageSize;
  90. $limit = " $n,$pageSize";
  91. $where = " where 1=1 ";
  92. $tel = trim($_REQUEST['tel']);
  93. if(!empty($tel)) {
  94. $where.=" and tel='$tel'";
  95. }
  96. $where.=" and is_send=2";
  97. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  98. $all_total = $admin->selectSmsCustomerCount($where);
  99. $p = new Page($all_total,$pageSize,$pa);
  100. $pp = $p->fpage();
  101. $this->assign('tel',$tel);
  102. $this->assign('list',$customer_list);
  103. $this->assign('info',$info);
  104. $this->assign('page',$page);
  105. $this->assign('pagesize',$pageSize);
  106. $this->assign("show",$pp);
  107. $this->display("nosendList.html");
  108. }
  109. public function remove(){
  110. $admin = new AdvertAdminAction();
  111. $uid = $_SESSION['user_infos']['id'];
  112. $info = $_REQUEST['info'];
  113. $where = " where uid='$uid' ";
  114. $group_list = $admin->select_sms_user_group($where);
  115. $this->assign('group_list',$group_list);
  116. $this->assign('info',$info);
  117. $this->display("remove.html");
  118. }
  119. //添加客户
  120. public function add(){
  121. $admin = new AdvertAdminAction();
  122. $uid = $_SESSION['user_infos']['id'];
  123. $where = "where uid='$uid' ";
  124. $group_list = $admin->select_sms_user_group($where);
  125. if($_POST['tel']){
  126. $data['uname'] = $_POST['username'];
  127. $data['tel'] = trim($_POST['tel']);
  128. $data['group_name'] = trim($_POST['group_name']);
  129. $data['country'] = trim($_POST['country']);
  130. $data['uid'] = $uid;
  131. $is_exist = $admin->selectCustomerByTel($data['tel'], $data['uid']);
  132. if(empty($is_exist)){
  133. $add = $admin->add_sms_customer($data);
  134. if($add){
  135. $info = "添加手机号成功";
  136. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  137. exit();
  138. }else{
  139. $info = "添加手机号失败";
  140. $this->assign('info',$info);
  141. }
  142. }else{
  143. $info = "您之前已经添加过此用户";
  144. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  145. exit();
  146. }
  147. }
  148. $this->assign('group_list',$group_list);
  149. $this->display('add.html');
  150. }
  151. //添加黑名单
  152. public function addBlack(){
  153. $admin = new AdvertAdminAction();
  154. if($_POST['tel']){
  155. $info = '添加失败';
  156. $uname = $_POST['username'];
  157. $tel = trim($_POST['tel']);
  158. $country = trim($_POST['country']);
  159. $group_name ='黑名单';
  160. $user = $admin->selectOneCustomerBymobile($tel);//查询手机号是否存在
  161. if($user){
  162. $add =$admin->updateSmsCustomerBlcak($user);
  163. }else{
  164. $uid =99;
  165. $values = "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$group_name}', 1, 2)";
  166. $add =$admin->import_sms_customer($values);
  167. }
  168. if($add){
  169. $info = "添加成功";
  170. header("Location:/?a=sms_customer_list_admin&m=blacklist&info=$info");
  171. exit();
  172. }else{
  173. $this->assign('info',$info);
  174. }
  175. }
  176. $this->display('addBlack.html');
  177. }
  178. //编辑客户
  179. public function edit(){
  180. $admin = new AdvertAdminAction();
  181. $uid = $_SESSION['user_infos']['id'];
  182. $where = "where uid='$uid' ";
  183. $group_list = $admin->select_sms_user_group($where);
  184. $id = $_REQUEST['id'];
  185. $one_info = $admin->selectOneSmsCustomer($id);
  186. if($_POST['tel']){
  187. $id = $_POST['id'];
  188. $data['uname'] = $_POST['username'];
  189. $data['group_name'] = trim($_POST['group_name']);
  190. $data['country'] = trim($_POST['country']);
  191. $data['tel'] = trim($_POST['tel']);
  192. $update = $admin->updateSmsCustomer($data,$id);
  193. if($update){
  194. $info = "编辑客户资料成功";
  195. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  196. exit();
  197. }else{
  198. $info = "编辑客户资料失败";
  199. $this->assign('info',$info);
  200. }
  201. }
  202. $this->assign('id',$id);
  203. $this->assign('one_info',$one_info);
  204. $this->assign('group_list',$group_list);
  205. $this->display('edit.html');
  206. }
  207. //删除客户
  208. public function delete(){
  209. $admin = new AdvertAdminAction();
  210. $uid = $_SESSION['user_infos']['id'];
  211. $id = $_REQUEST['id'];
  212. if($_REQUEST['id']){
  213. $delete = $admin->deleteSmsCustomer($id,$uid);
  214. $info = "删除成功";
  215. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  216. exit();
  217. }
  218. }
  219. //批量删除客户
  220. public function batch_delete(){
  221. $admin = new AdvertAdminAction();
  222. $uid = $_SESSION['user_infos']['id'];
  223. $id_array = $_POST['id_array'];
  224. $count = count($id_array);
  225. if($count==1){
  226. $id = $id_array[0];
  227. $delete = $admin->deleteSmsCustomer($id,$uid);
  228. $info = "删除成功";
  229. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  230. exit();
  231. }else if($count>1){
  232. $in_array = implode(',',$id_array);
  233. $delete = $admin->deleteBatchSmsCustomer($in_array,$uid);
  234. $info = "删除成功";
  235. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  236. exit();
  237. }
  238. }
  239. public function import(){
  240. $admin = new AdvertAdminAction();
  241. $city_code =$admin->selectCityCode();
  242. $new=array();
  243. foreach ($city_code as $v){
  244. $new[]=$v['code'];
  245. }
  246. $is_send=1;
  247. $uid = $_SESSION['user_infos']['id'];
  248. if($_POST['to_import_user']=='yes'){
  249. $filename = $_FILES['inputExcel']['name'];
  250. $tmp_name = $_FILES['inputExcel']['tmp_name'];
  251. $excel_array = $this->uploadFile($filename,$tmp_name);
  252. if(!empty($excel_array['error'])){
  253. $info = $excel_array['error'];
  254. }else{
  255. unset($excel_array[0]);//若第一排的数据是字段名的话,删除
  256. header("Content-type: text/html; charset=utf-8");
  257. $blackList = $admin->selectSmsBlackList();
  258. $blackListArr = array_column($blackList, 'tel');
  259. $values = '';
  260. foreach($excel_array as $array){
  261. if(!empty($array[2])){
  262. $uname = str_replace("’", '', $array[0]);
  263. $tel = trim($array[1]);
  264. $country = trim($array[2]);
  265. $groupName = trim($array[3]);
  266. if(in_array($tel, $blackListArr)) {
  267. continue;
  268. }
  269. if($country=='United States'||$country=='Canada'){
  270. $code = substr($tel , 0 , 3);
  271. if (in_array($code, $new)) {
  272. $is_send=1;
  273. }else{
  274. $is_send=2;
  275. }
  276. }
  277. $values .= "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$groupName}', 0, '{$is_send}'),";
  278. }
  279. }
  280. if($values) {
  281. $values = trim($values, ",");
  282. $insert = $admin->import_sms_customer($values);
  283. $info = '导入数据成功';
  284. }
  285. }
  286. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  287. exit();
  288. }
  289. }
  290. public function importBlackList(){
  291. $admin = new AdvertAdminAction();
  292. $uid = $_SESSION['user_infos']['id'];
  293. if($_POST['to_import_user']=='yes'){
  294. $filename = $_FILES['inputExcel']['name'];
  295. $tmp_name = $_FILES['inputExcel']['tmp_name'];
  296. $excel_array = $this->uploadFile($filename,$tmp_name);
  297. if(!empty($excel_array['error'])){
  298. $info = $excel_array['error'];
  299. }else{
  300. unset($excel_array[0]);//若第一排的数据是字段名的话,删除
  301. header("Content-type: text/html; charset=utf-8");
  302. $blackList = $admin->selectSmsBlackList($uid);
  303. $blackListArr = array_column($blackList, 'tel');
  304. $values = '';
  305. foreach($excel_array as $array){
  306. if(!empty($array[1])){
  307. $uname = str_replace("'", '', $array[0]);
  308. $tel = trim($array[1]);
  309. $country = trim($array[2]);
  310. $groupName = trim($array[3]);
  311. if(in_array($tel, $blackListArr)) {
  312. continue;
  313. }
  314. $telsArr[] = $tel;
  315. $values .= "('{$uname}', '{$country}', '{$tel}', 99, '{$groupName}', 1, 2),";
  316. }
  317. }
  318. if($telsArr) {
  319. $telsStr = implode(',', $telsArr);
  320. $result = $admin->deleteSmsCustomerByTel($telsStr);
  321. $values = trim($values, ",");
  322. $insert = $admin->import_sms_customer($values);
  323. $info = '导入数据成功';
  324. }
  325. }
  326. header("Location:/?a=sms_customer_list_admin&m=blacklist&info=$info");
  327. exit();
  328. }
  329. }
  330. public function deleteByExcel(){
  331. $admin = new AdvertAdminAction();
  332. $uid = $_SESSION['user_infos']['id'];
  333. if($_POST['to_import_user']=='yes'){
  334. $filename = $_FILES['inputExcel']['name'];
  335. $tmp_name = $_FILES['inputExcel']['tmp_name'];
  336. $excel_array = $this->uploadFile($filename,$tmp_name);
  337. if(!empty($excel_array['error'])){
  338. $info = $excel_array['error'];
  339. }else{
  340. unset($excel_array[0]);//若第一排的数据是字段名的话,删除
  341. header("Content-type: text/html; charset=utf-8");
  342. $telsArr = array();
  343. foreach($excel_array as $array){
  344. if(!empty($array[0])){
  345. $tel = trim($array[0]);
  346. $telsArr[] = $tel;
  347. }
  348. }
  349. if($telsArr) {
  350. $telsStr = "'" . implode("','", $telsArr) . "'";
  351. $result = $admin->deleteSmsCustomerByTel($telsStr);
  352. $info = '删除数据成功';
  353. }
  354. }
  355. header("Location:/?a=sms_customer_list_admin&m=remove&info=$info");
  356. exit();
  357. }
  358. }
  359. public function deleteByGroup() {
  360. $admin = new AdvertAdminAction();
  361. $uid = $_SESSION['user_infos']['id'];
  362. $groupName = $_POST['group_name'];
  363. if($groupName) {
  364. $delete_c = $admin->deleteSmsCustomerByGroup($groupName, $uid);
  365. $info = '删除 ' . $groupName . ' 客户分组成功';
  366. } else {
  367. $error = "删除失败";
  368. }
  369. header("Location:/?a=sms_customer_list_admin&m=remove&info=$info&error=$error");
  370. exit();
  371. }
  372. public function export(){
  373. $admin = new AdvertAdminAction();
  374. $uid = $_SESSION['user_infos']['id'];
  375. $group_name = $_REQUEST['group_name'];
  376. $where = " where uid='$uid' ";
  377. if(!empty($group_name)){
  378. $where.=" and group_name='$group_name'";
  379. }
  380. $where.=" and is_block=0";
  381. $list = $admin->selesctSmsCustomer($where);
  382. $d = date('Y-m-d',time());
  383. $this->generateEXCEL($d."导出客户数据",$list);
  384. }
  385. function generateEXCEL($filename = 'report',$data = ''){
  386. //引入PHPExcel相关文件
  387. require_once( ONU_ROOT . 'phpexcel/PHPExcel.php');
  388. require_once( ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php');
  389. require_once( ONU_ROOT . 'phpexcel/PHPExcel/Writer/Excel5.php');
  390. //新建
  391. $resultPHPExcel = new PHPExcel();
  392. //设置参数
  393. //设值
  394. $resultPHPExcel->getActiveSheet()->setCellValue('A1', 'Name');
  395. $resultPHPExcel->getActiveSheet()->setCellValue('B1', 'Tel');
  396. $resultPHPExcel->getActiveSheet()->setCellValue('C1', 'Country');
  397. $resultPHPExcel->getActiveSheet()->setCellValue('D1', 'Group');
  398. //设置水平居中
  399. $resultPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  400. $resultPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  401. $resultPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  402. $resultPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  403. //设置水平居中
  404. $resultPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  405. $resultPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  406. $resultPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  407. $resultPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  408. $i = 2;
  409. foreach($data as $item){
  410. $resultPHPExcel->getActiveSheet()->setCellValue('A' . $i, $item['uname']);
  411. $resultPHPExcel->getActiveSheet()->setCellValue('B' . $i, $item['tel']);
  412. $resultPHPExcel->getActiveSheet()->setCellValue('C' . $i, $item['country']);
  413. $resultPHPExcel->getActiveSheet()->setCellValue('D' . $i, $item['group_name']);
  414. //设置单元格宽度
  415. $resultPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(40);
  416. $resultPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
  417. $resultPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
  418. $resultPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
  419. //设置水平居中
  420. $resultPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  421. $resultPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  422. $resultPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  423. $resultPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  424. //设置行高度
  425. $resultPHPExcel->getActiveSheet()->getRowDimension("1")->setRowHeight(20);
  426. $resultPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(20);
  427. $i ++;
  428. }
  429. //设置导出文件名
  430. $xlsWriter = new PHPExcel_Writer_Excel5($resultPHPExcel);
  431. ob_end_clean();//清除缓冲区,避免乱码
  432. //ob_start(); ob_flush();
  433. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  434. header("Content-Type: application/force-download");
  435. header("Content-Type: application/octet-stream");
  436. header("Content-Type: application/download");
  437. //header('Content-Disposition:inline;filename="'.$outputFileName.'"');
  438. header('Content-Disposition:attachment;filename='.'"'.$filename.'.xls"'); //可以对文件名进行处理
  439. header("Content-Transfer-Encoding: binary");
  440. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  441. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  442. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  443. header("Pragma: no-cache");
  444. $xlsWriter->save('php://output');
  445. exit;
  446. }
  447. //导入Excel文件
  448. function uploadFile($file,$filetempname)
  449. {
  450. //自己设置的上传文件存放路径
  451. $filePath = 'static/upload/';
  452. $str = "";
  453. //下面的路径按照你PHPExcel的路径来修改
  454. require_once ONU_ROOT . 'phpexcel/PHPExcel.php';
  455. require_once ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php';
  456. require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/Excel5.php';
  457. require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/Excel2007.php';
  458. //require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/CSV.php';
  459. //注意设置时区
  460. $time=date("y-m-d-H-i-s");//去当前上传的时间
  461. //获取上传文件的扩展名
  462. $extend=strrchr ($file,'.');
  463. //上传后的文件名
  464. $name=$time.$extend;
  465. $uploadfile=$filePath.$name;//上传后的文件名地址
  466. //move_uploaded_file() 函数将上传的文件移动到新位置。若成功,则返回 true,否则返回 false。
  467. $result=move_uploaded_file($filetempname,$uploadfile);//假如上传到当前目录下
  468. //echo $result;
  469. if($result) { //如果上传文件成功,就执行导入excel操作
  470. $objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
  471. $objPHPExcel = $objReader->load($uploadfile);
  472. $sheet = $objPHPExcel->getSheet(0);
  473. $highestRow = $sheet->getHighestRow(); //取得总行数
  474. $highestColumn = $sheet->getHighestColumn(); //取得总列数
  475. /* 第二种方法*/
  476. $objWorksheet = $objPHPExcel->getActiveSheet();
  477. $highestRow = $objWorksheet->getHighestRow();
  478. echo 'highestRow='.$highestRow;
  479. echo "<br>";
  480. $highestColumn = $objWorksheet->getHighestColumn();
  481. $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);//总列数
  482. echo 'highestColumnIndex='.$highestColumnIndex;
  483. echo "<br>";
  484. $headtitle=array();
  485. //获取到的excel数据
  486. $excel_array = array();
  487. for ($row = 1;$row <= $highestRow;$row++)
  488. {
  489. $strs=array();
  490. //注意highestColumnIndex的列数索引从0开始
  491. for ($col = 0;$col < $highestColumnIndex;$col++)
  492. {
  493. $strs[$col] =$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
  494. if($strs[$col] instanceof PHPExcel_RichText){ //富文本转换字符串
  495. $strs[$col] = $strs[$col]->__toString();
  496. }
  497. }
  498. array_push($excel_array, $strs);
  499. }
  500. } else {
  501. $excel_array['error'] = "导入失败!";
  502. }
  503. return $excel_array;
  504. }
  505. public function exportBlackList(){
  506. $admin = new AdvertAdminAction();
  507. $list = $admin->getAllSmsBlacklist();
  508. $d = date('Y-m-d',time());
  509. $this->generateEXCEL($d . "导出短信黑名单客户数据", $list);
  510. }
  511. }