inyellowstore.inc.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu2();
  4. $where=" where a.uniacid=:uniacid and a.cityname=:cityname ";
  5. $type=isset($_GPC['type'])?$_GPC['type']:'wait';
  6. if(isset($_GPC['keywords'])){
  7. $where.=" and a.company_name LIKE concat('%', :name,'%') ";
  8. $data[':name']=$_GPC['keywords'];
  9. $type='all';
  10. }
  11. if(!empty($_GPC['time'])){
  12. $start=strtotime($_GPC['time']['start']);
  13. $end=strtotime($_GPC['time']['end']);
  14. $where.=" and a.sh_time >={$start} and a.sh_time<={$end} ";
  15. }
  16. $data[':uniacid']=$_W['uniacid'];
  17. $data[':cityname']=$_COOKIE["cityname"];
  18. $pageindex = max(1, intval($_GPC['page']));
  19. $pagesize=10;
  20. if($type=='wait'){
  21. $_GPC['state']=1;
  22. }
  23. if(!empty($_GPC['state'])){
  24. $where.=" and a.state ={$_GPC['state']}";
  25. }
  26. $sql="SELECT a.*,b.days as typename FROM ".tablename('zhtc_yellowstore'). " a" . " left join " . tablename("zhtc_yellowset") . " b on b.id=a.rz_type".$where. " ORDER BY a.sort ASC";
  27. $total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zhtc_yellowstore'). " a" ." left join " . tablename("zhtc_yellowset") . " b on b.id=a.rz_type".$where,$data);
  28. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  29. $list=pdo_fetchall($select_sql,$data);
  30. $pager = pagination($total, $pageindex, $pagesize);
  31. if($_GPC['op']=='delete'){
  32. $res=pdo_delete('zhtc_yellowstore',array('id'=>$_GPC['id']));
  33. if($res){
  34. message('删除成功!', $this->createWebUrl('inyellowstore'), 'success');
  35. }else{
  36. message('删除失败!','','error');
  37. }
  38. }
  39. if($_GPC['op']=='tg'){
  40. $res=pdo_update('zhtc_yellowstore',array('state'=>2,'sh_time'=>time()),array('id'=>$_GPC['id']));
  41. if($res){
  42. message('通过成功!', $this->createWebUrl('inyellowstore'), 'success');
  43. }else{
  44. message('通过失败!','','error');
  45. }
  46. }
  47. if($_GPC['op']=='jj'){
  48. $res=pdo_update('zhtc_yellowstore',array('state'=>3,'sh_time'=>time()),array('id'=>$_GPC['id']));
  49. if($res){
  50. message('拒绝成功!', $this->createWebUrl('inyellowstore'), 'success');
  51. }else{
  52. message('拒绝失败!','','error');
  53. }
  54. }
  55. if(checksubmit('export_submit', true)) {
  56. if($_GPC['time']['start']==$_GPC['time']['end']){
  57. $dcstart=strtotime(date('Y-m-d 00:00:00'));
  58. $dcend=strtotime(date('Y-m-d 23:59:59'));
  59. $note=$_GPC['time']['start']."黄页数据";
  60. }else{
  61. $dcstart=strtotime($_GPC['time']['start']." 00:00:00");
  62. $dcend=strtotime($_GPC['time']['end']." 23:59:59");
  63. $note=$_GPC['time']['start']."至".$_GPC['time']['end']."黄页数据";
  64. }
  65. $count = pdo_fetchcolumn("SELECT COUNT(*) FROM". tablename("zhtc_yellowstore")." WHERE uniacid={$_W['uniacid']} and state=2 and sh_time>={$dcstart} and sh_time<={$dcend} and cityname='{$_COOKIE["cityname"]}' ");
  66. $pagesize = ceil($count/5000);
  67. //array_unshift( $names, '活动名称');
  68. $header = array(
  69. 'id'=>'帖子id',
  70. 'logo' => 'logo图片',
  71. 'company_name' => '公司名称',
  72. 'company_address' => '公司地址',
  73. 'coordinates' => '公司坐标',
  74. 'link_tel' => '联系电话',
  75. 'dq_time' => '到期时间',
  76. 'typeName' => '一级分类',
  77. 'nTypeName' => '二级分类',
  78. 'cityname' => '所属城市',
  79. 'sh_time' => '入驻时间'
  80. );
  81. $keys = array_keys($header);
  82. $html = "\xEF\xBB\xBF";
  83. foreach ($header as $li) {
  84. $html .= $li . "\t ,";
  85. }
  86. $html .= "\n";
  87. for ($j = 1; $j <= $pagesize; $j++) {
  88. $sql = "select a.*,b.type_name as typeName,c.name as nTypeName from " . tablename("zhtc_yellowstore")." a" . " left join " . tablename("zhtc_yellowtype")." b on a.type_id=b.id left join " . tablename("zhtc_yellowtype2")." c on a.type2_id=c.id WHERE a.uniacid={$_W['uniacid']} and a.state=2 and a.sh_time>={$dcstart} and a.sh_time<={$dcend} and a.cityname='{$_COOKIE["cityname"]}' limit " . ($j - 1) * 5000 . ",5000 ";
  89. $list = pdo_fetchall($sql);
  90. if (!empty($list)) {
  91. $size = ceil(count($list) / 500);
  92. for ($i = 0; $i < $size; $i++) {
  93. $buffer = array_slice($list, $i * 500, 500);
  94. $user = array();
  95. foreach ($buffer as $k =>$row) {
  96. $row['logo']=str_replace(',','#',$row['logo']);
  97. $row['coordinates']=str_replace(',','#',$row['coordinates']);
  98. $row['dq_time']=date('Y-m-d H:i:s',$row['dq_time']);
  99. $row['sh_time']=date('Y-m-d H:i:s',$row['sh_time']);
  100. $row['cityname']=$row['cityname']?:'全国';
  101. foreach ($keys as $key) {
  102. $data5[] = $row[$key];
  103. }
  104. $user[] = implode("\t ,", $data5) . "\t ,";
  105. unset($data5);
  106. }
  107. $html .= implode("\n", $user) . "\n";
  108. }
  109. }
  110. }
  111. header("Content-type:text/csv");
  112. header("Content-Disposition:attachment; filename=".$note.".csv");
  113. echo $html;
  114. exit();
  115. }
  116. include $this->template('web/inyellowstore');