dlinyellowstore.inc.php 5.0 KB

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