yellowstore.inc.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $where=" where a.uniacid=:uniacid ";
  5. if(!empty($_GPC['keywords'])){
  6. $where.=" and a.company_name LIKE concat('%', :name,'%') ";
  7. $data[':name']=$_GPC['keywords'];
  8. }
  9. if(!empty($_GPC['time'])){
  10. $start=strtotime($_GPC['time']['start']);
  11. $end=strtotime($_GPC['time']['end']);
  12. $where.=" and a.sh_time >={$start} and a.sh_time<={$end} ";
  13. }
  14. if(!empty($_GPC['state'])){
  15. $start=strtotime($_GPC['time']['start']);
  16. $end=strtotime($_GPC['time']['end']);
  17. $where.=" and a.state ={$_GPC['state']}";
  18. }
  19. $data[':uniacid']=$_W['uniacid'];
  20. $pageindex = max(1, intval($_GPC['page']));
  21. $pagesize=10;
  22. $type=isset($_GPC['type'])?$_GPC['type']:'all';
  23. $sql="SELECT a.*,b.days as typename,c.type_name FROM ".tablename('zhtc_yellowstore'). " a" . " left join " . tablename("zhtc_yellowset") . " b on b.id=a.rz_type left join " . tablename("zhtc_yellowtype") . " c on c.id=a.type_id ".$where. " ORDER BY a.sort ASC,a.id DESC";
  24. $total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zhtc_yellowstore'). " a" ." left join " . tablename("zhtc_yellowset") . " b on b.id=a.rz_type left join " . tablename("zhtc_yellowtype") . " c on c.id=a.type_id ".$where,$data);
  25. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  26. $list=pdo_fetchall($select_sql,$data);
  27. $pager = pagination($total, $pageindex, $pagesize);
  28. if($_GPC['op']=='delete'){
  29. $res=pdo_delete('zhtc_yellowstore',array('id'=>$_GPC['id']));
  30. if($res){
  31. message('删除成功!', $this->createWebUrl('yellowstore'), 'success');
  32. }else{
  33. message('删除失败!','','error');
  34. }
  35. }
  36. if($_GPC['op']=='tg'){
  37. $rst=pdo_get('zhtc_yellowstore',array('id'=>$_GPC['id']));
  38. $time=pdo_get('zhtc_yellowset',array('id'=>$rst['rz_type']));
  39. $newtime=$time['days']*24*60*60;
  40. $res=pdo_update('zhtc_yellowstore',array('state'=>2,'sh_time'=>time(),'dq_time'=>time()+$newtime),array('id'=>$_GPC['id']));
  41. if($res){
  42. message('通过成功!', $this->createWebUrl('yellowstore'), '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('yellowstore'), '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}");
  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} 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/yellowstore');