index-report.php 47.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
<?php
require_once('./admin.php');
if ( ! current_user_can( 'manage_options' ) )
	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
$title = __('General Settings');
$parent_file = 'options-general.php';
/* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
/**
 * Display JavaScript on the page.
 *
 * @since 3.5.0
 */
function options_general_add_js() {
?>
<script type="text/javascript">
//<![CDATA[
	jQuery(document).ready(function($){
		$("input[name='date_format']").click(function(){
			if ( "date_format_custom_radio" != $(this).attr("id") )
				$("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
		});
		$("input[name='date_format_custom']").focus(function(){
			$("#date_format_custom_radio").attr("checked", "checked");
		});
		$("input[name='time_format']").click(function(){
			if ( "time_format_custom_radio" != $(this).attr("id") )
				$("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
		});
		$("input[name='time_format_custom']").focus(function(){
			$("#time_format_custom_radio").attr("checked", "checked");
		});
		$("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
			var format = $(this);
			format.siblings('.spinner').css('display', 'inline-block'); // show(); can't be used here
			$.post(ajaxurl, {
					action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
					date : format.val()
				}, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
		});
	});
//]]>
</script>
<?php
}
add_action('admin_head', 'options_general_add_js');
include('./admin-header.php');
?>
 
<link rel="stylesheet" href="//www.quanqiusou.cn/admin40/base.css">
<!-- <link rel="stylesheet" href="//www.quanqiusou.cn/admin40/global.css"> -->
<link rel="stylesheet" href="//www.quanqiusou.cn/admin40/global.css?t=20180510"> 
<link rel="stylesheet" href="//www.quanqiusou.cn/admin40/skin.css">
<!--[if lt IE 9]>
<script src="//www.quanqiusou.cn/admin40/js/html5.js"></script>
<script src="//www.quanqiusou.cn/admin40/js/respond.js"></script>
<![endif]-->
 
<style type="text/css">
html,body{background-color: #fff;}
</style>
 
<div class="gd-wrap">
<?php 
	function google_api_to_array($apino) {
		$nowdate = date("Y-m-d"); 
		$startDate = date("Y-m-d",strtotime("-2 day"));
		$endDate = date("Y-m-d",strtotime("-1 day"));  //昨天
		$url = "http://www.quanqiusou.cn/google-rank/data_json/".$nowdate."/".$apino."_".$startDate."_".$endDate.".json";
		$json_data = @file_get_contents($url);
		$datas = json_decode($json_data, true);
		$k=A;
		$list_arr=array();
		if(is_array($datas)){	
			foreach($datas as $val){
				foreach($val as $key=>$v){
					if(is_array($v)){
						$s[$key][$k]['change']=intval($v['change']);
						$s[$key][$k]['class']=$v['class'];
						$s[$key][$k]['position']=intval($v['position']);
					}				
				}
				$k++;
				$list_arr=$s;
			}
		}
		return $list_arr;
	}
	function server_time_array($apino){
		$url = "http://www.quanqiusou.cn/jsonapi/?apino=".$apino;
		$json_data = @file_get_contents($url);
		$datas = json_decode($json_data, true);
		return $datas;
	}
	$info_api = get_post_meta(32,'api_id');
	
	$apino = $info_api[0]; 
	//$apino = '3676604';
	$endDate = date("Y-m-d",strtotime("-1 day"));  //昨天
	$rank_home_num = $rank_all_num = $rank_third_num = 0;
	$list_arr_d = google_api_to_array($apino);
	if($list_arr_d){
		foreach($list_arr_d[$endDate] as $value){
			if(($value['position']<10||$value['position']==10)&&$value['position']>0){
				$rank_home_num++;
			}
          	if($value['position'] <= 30 && $value['position']>0){
            	$rank_third_num++;
            }
			$rank_all_num++;	
		}
	}
	$company_name = get_post_meta(32,'公司名',true);
	$stats_setting = get_option('stats_settings');
	$StartMonth = $stats_setting['month_start']."-01";
	$EndMonth = date('Y-m-01');
	$ToStartMonth = strtotime( $StartMonth ); //转换一下
	$ToEndMonth   = strtotime( $EndMonth ); //一样转换一下
	$i = false;
	$month_arr = array();
	while( $ToEndMonth >  $ToStartMonth) {
		$NewMonth = !$i ? date('Y-m', strtotime('+0 Month', $ToEndMonth)) : date('Y-m', strtotime('-1 Month', $ToEndMonth));
		$ToEndMonth = strtotime( $NewMonth );
		$i = true;
		$month_arr[] = $NewMonth;
	}
?>
<?php if(!isset($_POST['month'])){?>
  <!-- 设置 -->
  <section class="report-layer report-layer-set">
      <div class="layer-bd">
          <h1 class="layer-title">全球搜·账户报表</h1>
          <div class="report-set">
			<form action="" method='post'>
              <span class="report-set-select">
                  <select name="month" id="">
					<?php if($month_arr){ foreach($month_arr as $month){?>
						<option value="<?php echo $month;?>" <?php if(isset($_POST['month']) && $_POST['month']== $month){ echo 'selected="selected"';}?>><?php echo $month;?></option>
					<?php }}?>
                  </select>
              </span>
              <input class="report-set-btn" type="submit" value='生成报表'>
			 </form>
          </div>
      </div>
	  <?php if(isset($_POST['month'])){?>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo date('Y年m月',strtotime($_POST['month']));?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
	  <?php }?>
  </section>
<?php }?>
	
<?php if(isset($_POST['month'])){ $cur_month = $_POST['month'];$cur_month_ym = date('Y年m月',strtotime($cur_month));?>
<?php
	$res = $wpdb->get_row("select count(id) as ip from wp_stats_day_ip where is_spider=1",ARRAY_A);
	$total_ip = $res['ip'];
	$fuwu_info = server_time_array($apino);
?>
  <input type="hidden" id="month_str" value="<?php echo $cur_month;?>">
<div id="pdf-pages" class="pdf-pages">
  <!-- 封面 -->
  <section class="report-layer report-layer-1">
  <div class="report-layer-in">
      <div class="layer-bd">
          <a class="btn-download-report" id="renderPdf" href="javascript:">下载<em>PDF报表</em></a>
          <h1 class="layer-title">全球搜·账户报表</h1>
          <div class="layer-desc">
              <p><?php echo $company_name;?></p>
              <p><?php echo $cur_month_ym;?></p>
          </div>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
  <!-- 前言 -->
  <section class="report-layer report-layer-2">
  <div class="report-layer-in">
      <div class="layer-bd">
          <h1 class="layer-title">前言</h1>
          <div class="report-cont">
              <dl>
              <dt>尊敬的用户:</dt>
              <dd>您好!首先,感谢贵公司对全球搜的信任和关注,贵公司的网站上线以来,获得了一定的排名和流量,我们此次的账户服务,是在网站积累数据的基础上,对数据进行分析,给出进一步的优化意见,同时基于我们对贵公司产品的搜索引擎相关数据,给出我们下一步的优化策略,因为贵公司对产品非常了解,所以希望贵公司领导能够对此报告进行修改指正,并提出宝贵意见;全球搜本着严谨科学的态度,充分考虑实际要求,倾听客户的需求,提供合理的方案和优质的服务,为贵公司寻找更多的海外客户,是全球搜的目标,我们希望能借助此报告,进一步优化贵公司的网站,提升搜索引擎展示效果,获得更多的询盘。</dd>
              <dd class="align-r">
                  <p>全 球 搜</p>
                  <p><?php echo $cur_month_ym;?></p>
              </dd>
              </dl>
          </div>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
  <!-- 概况 -->
  <section class="report-layer report-layer-3">
  <div class="report-layer-in">
      <div class="layer-bd">
          <h1 class="layer-title">概况</h1>
          <div class="report-cont">
              <dl>
              <dt>尊敬的用户:</dt>
              <dd>您好!<?php echo $company_name;?>的网站上线至今,网站访客量、Google搜索引擎关键词排名已不断提升,目前共计访问量<span class="txt-impt" id='total_ip'><?php echo $total_ip;?></span>IP,本月访问量<span class="txt-impt" id='month_ip'></span>IP,主要来自于<span class="txt-impt" id='ip_from_country'></span>等国家,搜索引擎流量主要来自<span class="txt-impt" id='ll_from'></span>,目前Google首页关键词排名数量为<span class="txt-impt" id='keywords_rank_num_home'><?php echo $rank_home_num;?></span>个,<?php if($fuwu_info['dabiaosj']>0){?>前三页关键词数量为<span class="txt-impt" id='keywords_rank_num'><?php echo $rank_third_num;?></span>个,关键词首页数量已达标,首次达标时间为<span class="txt-impt" id="dabiao_date"><?php echo $fuwu_info['dabiaosj'];?></span><?php }?>累计服务时间<span class="txt-impt" id="server_date"><?php echo $fuwu_info['fwsj'];?></span>天,剩余服务时间<span class="txt-impt" id="server_date_sy"><?php echo $fuwu_info['syfwsj'];?></span>天;网站优化推广至今已经收到<span class="txt-impt" id="xunpan_num"></span>封精准询盘,本月收到精准询盘<span class="txt-impt" id="xunpan_num_month"></span>封,直接发Email到邮箱的询盘应有<span class="txt-impt" id="send_email_xunpan"></span>封,本月询盘转化率约为<span class="txt-impt" id="month_cf"></span>%,询盘主要来自于<span class="txt-impt" id="xunp_from_country"></span>等国家,具体的数据详情请浏览以下图表内容。
              </dd>
              </dl>
          </div>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
  <!-- 访问来源 -->
  <section class="report-layer report-layer-4 report-layer-chart">
  <div class="report-layer-in">
      <div class="layer-bd">
        <h4 class="layer-bd-tit">访问来源</h4>
        <section class="view-report-item referrals-report-item">
          <aside class="report-item-side">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="ly_moth_<?php echo $cur_month;?>_moth"id><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="view-count-info view-count-page">
                  <ul>
                    <li>
                      <div class="count-label">共计浏览量</div>
                      <div class="count-num"><span class="num-value" id="ly_moth_<?php echo $cur_month;?>_pv">0</span><i>PV</i></div>
                    </li>
                    <li>
                      <div class="count-label">共计访客量</div>
                      <div class="count-num"><span class="num-value" id="ly_moth_<?php echo $cur_month;?>_ip">0</span><i>IP</i></div>
                    </li>
                  </ul>
                </div>
                <div class="state-count-txt">
                  <h4>访问来源TOP10</h4>
				  <ul class="referrals-list" id="ly_country_top10_<?php echo $cur_month;?>" ></ul>
                </div>
              </div>  
            </div>
          </aside>
          <div class="report-item-main">
          <div class="item-main-in">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="moth_2018-04_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="chart-box">
                  <div class="referrals-report-chart" id="referrals-report-chart_ly_<?php echo $cur_month;?>"></div>
                </div>
              </div>
            </div>
          </div>
          </div>
        </section>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
  
   <!-- 流量转化 -->
  <section class="report-layer report-layer-5 report-layer-chart">
  <div class="report-layer-in">
      <div class="layer-bd">
        <h4 class="layer-bd-tit">流量转化</h4>
        <section class="view-report-item referrals-report-item">
          <aside class="report-item-side">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="ll_moth_<?php echo $cur_month;?>_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="view-count-info view-count-page">
                  <ul>
                    <li>
                      <div class="count-label">共计浏览量</div>
                      <div class="count-num"><span class="num-value" id="ll_moth_<?php echo $cur_month;?>_pv">0</span><i>PV</i></div>
                    </li>
                    <li>
                      <div class="count-label">共计访客量</div>
                      <div class="count-num"><span class="num-value" id="ll_moth_<?php echo $cur_month;?>_ip">0</span><i>IP</i></div>
                    </li>
                  </ul>
                </div>
                <div class="state-count-txt">
                  <h4>访问国家TOP10</h4>
                  <ul class="referrals-list" id="ll_country_top10_<?php echo $cur_month;?>"></ul>
                </div>
              </div>  
            </div>
          </aside>
          <div class="report-item-main">
          <div class="item-main-in">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="moth_2018-04_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="chart-box">
                  <div class="referrals-report-chart" id="referrals-report-chart_ll_<?php echo $cur_month;?>"></div>
                </div>
              </div>
            </div>
          </div>
          </div>
        </section>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
   <!-- 受访页面 -->
  <section class="report-layer report-layer-6 report-layer-chart">
  <div class="report-layer-in">
      <div class="layer-bd">
        <h4 class="layer-bd-tit">受访页面</h4>
        <section class="view-report-item referrals-report-item">
          <aside class="report-item-side">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="ym_moth_<?php echo $cur_month;?>_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="view-count-info view-count-page">
                  <ul>
                    <li>
                      <div class="count-label">共计浏览量</div>
                      <div class="count-num"><span class="num-value" id="ym_moth_<?php echo $cur_month;?>_pv">0</span><i>PV</i></div>
                    </li>
                    <li>
                      <div class="count-label">共计访客量</div>
                      <div class="count-num"><span class="num-value" id="ym_moth_<?php echo $cur_month;?>_ip">0</span><i>IP</i></div>
                    </li>
                  </ul>
                </div>
                <div class="state-count-txt">
                  <h4>受访页面TOP10</h4>
                  <ul class="referrals-list" id="ym_country_top10_<?php echo $cur_month;?>"></ul>
                </div>
              </div>  
            </div>
          </aside>
          <div class="report-item-main">
          <div class="item-main-in">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="moth_2018-04_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="chart-box">
                  <div class="referrals-report-chart" id="referrals-report-chart_ym_<?php echo $cur_month;?>"></div>
                </div>
              </div>
            </div>
          </div>
          </div>
        </section>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
   <!-- 访问终端 -->
  <section class="report-layer report-layer-7 report-layer-chart">
  <div class="report-layer-in">
      <div class="layer-bd">
        <h4 class="layer-bd-tit">访问终端</h4>
        <section class="view-report-item referrals-report-item">
          <aside class="report-item-side">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="zd_moth_<?php echo $cur_month;?>_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="view-count-info view-count-page">
                  <ul>
                    <li>
                      <div class="count-label">共计浏览量</div>
                      <div class="count-num"><span class="num-value" id="zd_moth_<?php echo $cur_month;?>_pv">0</span><i>PV</i></div>
                    </li>
                    <li>
                      <div class="count-label">共计访客量</div>
                      <div class="count-num"><span class="num-value" id="zd_moth_<?php echo $cur_month;?>_ip">0</span><i>IP</i></div>
                    </li>
                  </ul>
                </div>
                <div class="state-count-txt">
                  <h4>访问国家TOP10</h4>
                  <ul class="referrals-list" id="zd_country_top10_<?php echo $cur_month;?>"></ul>
                </div>
              </div>  
            </div>
          </aside>
          <div class="report-item-main">
          <div class="item-main-in">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="moth_2018-04_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="chart-box">
                  <div class="referrals-report-chart" id="referrals-report-chart_zd_<?php echo $cur_month;?>"></div>
                </div>
              </div>
            </div>
          </div>
          </div>
        </section>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
  <!-- 地域分布 -->
  <section class="report-layer report-layer-8 report-layer-chart">
  <div class="report-layer-in">
      <div class="layer-bd">
        <h4 class="layer-bd-tit">地域分布</h4>
        <section class="view-report-item referrals-report-item">
          <aside class="report-item-side">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="gj_moth_<?php echo $cur_month;?>_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="view-count-info view-count-page">
                  <ul>
                    <li>
                      <div class="count-label">共计浏览量</div>
                      <div class="count-num"><span class="num-value" id="gj_moth_<?php echo $cur_month;?>_pv">0</span><i>PV</i></div>
                    </li>
                    <li>
                      <div class="count-label">共计访客量</div>
                      <div class="count-num"><span class="num-value" id="gj_moth_<?php echo $cur_month;?>_ip">0</span><i>IP</i></div>
                    </li>
                  </ul>
                </div>
                <div class="state-count-txt">
                  <h4>访问国家TOP10</h4>
                  <ul class="referrals-list" id="gj_country_top10_<?php echo $cur_month;?>"></ul>
                </div>
              </div>  
            </div>
          </aside>
          <div class="report-item-main">
          <div class="item-main-in">
            <div class="gd-panel">
              <header class="gd-panel-hd">
                <h2 class="panel-hd-tit"><span class="moth_2018-04_moth"><?php echo $cur_month_ym;?></span>份数据统计</h2>
              </header>
              <div class="gd-panel-bd">
                <div class="chart-box">
                  <div class="referrals-report-chart" id="referrals-report-chart_gj_<?php echo $cur_month;?>"></div>
                </div>
              </div>
            </div>
          </div>
          </div>
        </section>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
  <!-- 检测及建议 -->
  <?php 
	$res = $wpdb->get_row("select count(term_taxonomy_id) as num from `wp_term_taxonomy` where `taxonomy`='category' and `term_id`!=623",ARRAY_A);
	//$count_posts = wp_count_posts();
	$category_num = $res['num'];
	$products_num = 0;                      
    query_posts(array('cat'=>490,'post_type'=>'post','showposts'=>10000));while ( have_posts() ) : the_post();
        $products_num++;                 
    endwhile; wp_reset_query(); 
	$news_num = count(query_posts(array( 'post_type' => 'news','posts_per_page'=>-1)));;
	$before_7day = date('Y-m-d',time()-7*3600*24);
	$month_before = date('Y-m-d',time()-30*3600*24);
	$res2 = $wpdb->get_row("select count(ID) as num from `wp_posts` where `post_type`='news' and `post_status`='publish' and `post_date` >= '$before_7day 00:00:00'",ARRAY_A);
	$res3 = $wpdb->get_row("select count(ID) as num from `wp_posts` where `post_type`='post' and `post_status`='publish' and `post_date` >= '$month_before 00:00:00'",ARRAY_A);
	$news_num_7day = $res2['num'];
	$products_num_month = $res3['num'];
  ?>
  <section class="report-layer report-layer-9 report-yhjc">
  <div class="report-layer-in">
      <div class="layer-bd">
          <h4 class="layer-bd-tit">检测及建议</h4>
          <div class="yhjc-list">
              <div class="list-item">
                  <dl>
                  <dt>检测网站打开速度</dt>
                  <dd>
                    <i class="ico-success" style="background-image: url(./img/yhjc-ico-success.png);"></i>
                    <div class="txt-tips">网站页面平均打开速度为<?php echo round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2);?></div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测网站结构</dt>
                  <dd>
                    <i class="ico-success" style="background-image: url(./img/yhjc-ico-success.png);"></i>
                    <div class="txt-tips">网站结构符合SEO优化标准</div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测标签优化</dt>
                  <dd>
                    <i class="ico-success" style="background-image: url(./img/yhjc-ico-success.png);"></i>
                    <div class="txt-tips">检测到关键词标签页面</div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测关键词优化</dt>
                  <dd>
                    <i class="ico-success" style="background-image: url(./img/yhjc-ico-success.png);"></i>
                    <div class="txt-tips">关键词已经录入到相关产品页面</div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测网站图片优化</dt>
                  <dd>
                    <i class="ico-success" style="background-image: url(./img/yhjc-ico-success.png);"></i>
                    <div class="txt-tips">网站图片已经进行了优化处理</div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测Sitemap及Robot优化</dt>
                  <dd>
                    <i class="ico-success" style="background-image: url(./img/yhjc-ico-success.png);"></i>
                    <div class="txt-tips">已检测到Sitemap.xml、Robots.txt文件</div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测所有已录入产品分类的数量(<?php echo $category_num;?>)</dt>
                  <dd>
                    <i class="ico-fail" style="background-image: url(./img/yhjc-ico-<?php echo $category_num<20?'fail':'success';?>.png);"></i>
                    <div class="txt-tips"><?php if($category_num < 20) echo '已录入产品分类数量较少,建议再挖掘扩展';else echo '已检测到录入产品分类'.$category_num.'个';?></div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测所有已录入产品的数量(<?php echo $products_num;?>)</dt>
                  <dd>
                    <i class="ico-fail" style="background-image: url(./img/yhjc-ico-<?php echo $products_num<100?'fail':'success';?>.png);"></i>
                    <div class="txt-tips"><?php if($products_num < 100) echo '已录入产品数量较少,建议每日新发布1-3个新产品,配合不同长尾关键词进行发布';else echo '已检测到录入产品'.$products_num.'个,建议保持更新!';?></div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测所有已录入新闻的数量(<?php echo $news_num;?>)</dt>
                  <dd>
                    <i class="ico-fail" style="background-image: url(./img/yhjc-ico-<?php echo $news_num<10?'fail':'success';?>.png);"></i>
                    <div class="txt-tips"><?php if($news_num < 10) echo '已发布的新闻数量较少,建议每周发布1-2篇新闻,可以包含:行业新闻、企业新闻等内容';else echo '已检测到录入新闻'.$news_num.'篇,建议保持更新!';?></div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测近30天产品更新的数量(<?php echo $products_num_month;?>)</dt>
                  <dd>
                    <i class="ico-fail" style="background-image: url(./img/yhjc-ico-<?php echo $products_num_month==0?'fail':'success';?>.png);"></i>
                    <div class="txt-tips"><?php if($products_num_month == 0) echo '<font color="red">警告:30天内未发布新的产品,建议每日新发布1-3个新产品,配合不同长尾关键词进行发布</font>';else echo '已检测到30天内发布了'.$products_num_month.'个新产品,继续保持!'?></div>
                  </dd>
                  </dl>
              </div>
              <div class="list-item">
                  <dl>
                  <dt>检测近7天新闻更新的数量(<?php echo $news_num_7day;?>)</dt>
                  <dd>
                    <i class="ico-fail" style="background-image: url(./img/yhjc-ico-<?php echo $news_num_7day==0?'fail':'success';?>.png);"></i>
                    <div class="txt-tips"><?php if($news_num_7day == 0) echo '<font color="red">警告:7天内未发布新闻,建议每周发布1-2篇新闻</font>';else echo '已检测到7天内发布了'.$news_num_7day.'篇新闻,继续保持!'?></div>
                  </dd>
                  </dl>
              </div>
          </div>
      </div>
      <div class="layer-hd">
          <h3 class="hd-tit"><?php echo $company_name;?> <?php echo $cur_month_ym;?> 账户报表</h3>
          <div class="hd-r"><span class="txt-1">Global</span><span class="txt-2">So</span><span class="txt-3">.com</span></div>
      </div>
  </div>
  </section>
<?php }?>
</div>
</div>
<script src="//www.quanqiusou.cn/admin40/js/jquery.min.js"></script>
<script src="//www.quanqiusou.cn/admin40/js/fastclick.js"></script>
<script src="//www.quanqiusou.cn/admin40/js/base.js"></script>
<?php if(isset($_POST['month'])){?>
<?php
$data['moth_begin'] = $BeginDate = date('Y-m-01', strtotime($_POST['month']));
$data['moth_end']= date('Y-m-d', strtotime("$BeginDate +1 month -1 day"));
$res_zd = $wpdb->get_row("select count(id) as pc from wp_stats_day_ip where is_moblie=0 and date(`day`) between '".$data['moth_begin']."' and '".$data['moth_end']."'",ARRAY_A);
$count_pc = $res_zd['pc'];
$res_zd = $wpdb->get_row("select count(id) as mo from wp_stats_day_ip where is_moblie=1 and date(`day`) between '".$data['moth_begin']."' and '".$data['moth_end']."'",ARRAY_A);
$count_mo = $res_zd['mo'];
?>
<!-- 生成图表 -->
<script src="//www.quanqiusou.cn/admin40/js/highcharts.js"></script>
<script type="text/javascript">
function getMonthfirstDay(iDate){  
    var dateArr=iDate.split('-');
     return iDate+'-'+1;  
}
// 当月最后一天
function getMonthLastDay(iDate){  
    var dateArr=iDate.split('-');
    var year =dateArr[0];
    var month=dateArr[1];
    var d= new Date(year, month, 0); 
    return iDate+''+d.getDate();  
}
$(function () {
	var cur_month = $('#month_str').val();
	//访问来源
	var arr_ly = new Array();
    $.get("/wp-admin/admin-ajax.php", { "action": "stats_data_uvly", month :cur_month},
	   function(data){
		   $('.ly_moth_'+cur_month+'_moth').html(data.moth_moth);	   
		   $('#ly_moth_'+cur_month+'_pv').html(data.moth_pv);
		   $('#ly_moth_'+cur_month+'_ip').html(data.moth_ip);
		   $('#month_ip').html(data.moth_ip);
		   month_ip
		   var country_top10_html = '';
		   var ll_from = '';
		   $.each(data.referrer_top15_area, function(i,item){
			   if(i<10){
				country_top10_html +="<li>"+item['referrer']+"</li>";
				arr_ly[i] = new Array(i);
				arr_ly[i][0] = item['referrer'];
				arr_ly[i][1] = parseInt(item['num_referrer']);
				ll_from += item['referrer']+'、';
			   }
			});
			ll_from=ll_from.substring(0,ll_from.length -1);
		   $('#ly_country_top10_'+cur_month).html(country_top10_html);
			$('#ll_from').html(ll_from);
			$('#referrals-report-chart_ly_'+cur_month).highcharts({
				chart: {
					plotBackgroundColor: null,
					plotBorderWidth: null,
					plotShadow: false
				},
				colors: ['#188ae2', '#3ab74c', '#ff7373', '#DDDF00',
						 '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4','#82a6f5',
						 '#9ff048','#f1aaa6','#c09eff','#82d0f5']
				,
				title: {
					text: ''
				},
				tooltip: {
					headerFormat: '',
					pointFormat: '{point.name}: <span class="point-value">{point.percentage:.1f}%</span>'
				},
				plotOptions: {
					pie: {
						allowPointSelect: true,
						cursor: 'pointer',
						dataLabels: {
							enabled: true,
							format: '<span class="point-label">{point.name}</span>, {point.percentage:.1f} %',
							style: {
								color: '#666',
								fontSize: "12px",
								fontWeight: "normal"
							}
						}
					}
				},
				series: [{
					type: 'pie',
					name: '',
					// 数据
					data: arr_ly
				}]
			});
		}, "json");
		//终端
		$.get("/wp-admin/admin-ajax.php", { "action": "stats_data_uvzd", month :cur_month},
		   function(data){
			   $('.zd_moth_'+cur_month+'_moth').html(data.moth_moth);	   
			   $('#zd_moth_'+cur_month+'_pv').html(data.moth_pv);
			   $('#zd_moth_'+cur_month+'_ip').html(data.moth_ip);
			   
			   var pc = data.count_pc;
			   var mo = data.count_mo;
			   var country_top10_html = '';
			   $.each(data.country_top10, function(i,item){
					country_top10_html +="<li>"+item['show_area']+"</li>"
				});
			   $('#zd_country_top10_'+cur_month).html(country_top10_html);
			   $('#referrals-report-chart_zd_'+cur_month).highcharts({
					chart: {
						plotBackgroundColor: null,
						plotBorderWidth: null,
						plotShadow: false
					},
					colors: ['#188ae2', '#3ab74c', '#ff7373', '#DDDF00',
							 '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4','#82a6f5',
							 '#9ff048','#f1aaa6','#c09eff','#82d0f5']
					,
					title: {
						text: ''
					},
					tooltip: {
						headerFormat: '',
						pointFormat: '{point.name}: <span class="point-value">{point.percentage:.1f}%</span>'
					},
					plotOptions: {
						pie: {
							allowPointSelect: true,
							cursor: 'pointer',
							dataLabels: {
								enabled: true,
								format: '<span class="point-label">{point.name}</span>, {point.percentage:.1f} %',
								style: {
									color: '#666',
									fontSize: "12px",
									fontWeight: "normal"
								}
							}
						}
					},
					series: [{
						type: 'pie',
						name: '',
						// 数据
						data: [
							['PC',  parseInt("<?php echo $count_pc;?>")],
							['MOBILE', parseInt("<?php echo $count_mo;?>")],
						]
					}]
				});
		}, "json");
		//流量转化
		$.get("/wp-admin/admin-ajax.php", { "action": "stats_data_uvhz", month :cur_month},
	   function(data){
		   $('.ll_moth_'+cur_month+'_moth').html(data.moth_moth);	   
		   $('#ll_moth_'+cur_month+'_pv').html(data.moth_pv);
		   $('#ll_moth_'+cur_month+'_ip').html(data.moth_ip);
		   $('#month_cf').html(data.cf_f_count);
		   var country_top10_html = '';
		   var ip_from_country = '';
		   $.each(data.country_top10, function(i,item){
			   if(i<10){
				country_top10_html +="<li>"+item['show_area']+"</li>"
				ip_from_country += item['show_area']+"、";
			   }
			});
			ip_from_country=ip_from_country.substring(0,ip_from_country.length -1);
		   $('#ll_country_top10_'+cur_month).html(country_top10_html);
		   $('#ip_from_country').html(ip_from_country);
		   var data_pv = new Array();
		   var data_ip = new Array();
		   var k=0;
		   $.each(data.moth['data'], function(i,item){
				data_pv[k] = parseInt(item.pv);
				data_ip[k] = parseInt(item.ip);
				k++;
			});
			// 各月份数据
			Highcharts.chart('referrals-report-chart_ll_'+cur_month,
				{
				xAxis: {
					type: 'datetime',
					dateTimeLabelFormats: {
						day: '%m-%d'
					},
					tickWidth:0,
					lineWidth: 0,
					labels:{
						style:{
							color:'#999'
						}
					}
				},
				tooltip: {
					xDateFormat: '%Y年%m月%d日',
					shared:true,
					shadow: false,
					backgroundColor: '#ffffff',
					style:{
						color: '#666666',
						fontSize: '12px',
						padding: '8px',
						lineHeight:'20px'
					}
				},
				colors: ['#ececec','#7cb0d8'],
				chart:{type:'areaspline'},
				plotOptions: {
					series: {
						lineWidth:1,
						marker: {
							enabled: true
						},
						pointStart: Date.parse(getMonthfirstDay(cur_month)), // 开始时间
						pointEnd: Date.parse(getMonthLastDay(cur_month)), // 结束时间
						pointInterval: 24 * 3600 * 1000
					}
				},
				series:[
					{
						name:'访客次数(PV)',lineColor:'#aaaaaa',marker: {symbol: 'circle',lineWidth: 1,lineColor: '#ffffff',fillColor: '#cccccc'},
						data:eval(data_pv) // PV数据
					},
					{
						name:'独立访客(IP)',lineColor:'#3292e0',marker: {symbol: 'circle',lineWidth: 1,lineColor: '#ffffff',fillColor: '#3292e0'},
						data:eval(data_ip) // UV数据
					}
					]
			});
	}, "json");
	//受访页面
	var arr_ym = new Array();
	$.get("/wp-admin/admin-ajax.php", { "action": "stats_data_uvym", month :cur_month},
		   function(data){
			   $('.ym_moth_'+cur_month+'_moth').html(data.moth_moth);	   
			   $('#ym_moth_'+cur_month+'_pv').html(data.moth_pv);
			   $('#ym_moth_'+cur_month+'_ip').html(data.moth_ip);
			   
			   var country_top10_html = '';
			   
			   $.each(data.referrer_top15_area, function(i,item){
				   if(i<10){
					country_top10_html +="<li><a target='_blank' href='"+item['request']+"'>"+item['request']+"</a></li>";
					arr_ym[i] = new Array(i);
					arr_ym[i][0] = item['request'];
					arr_ym[i][1] = parseInt(item['num_request']);
				   }
				});
			   $('#ym_country_top10_'+cur_month).html(country_top10_html);
				
				$('#referrals-report-chart_ym_'+cur_month).highcharts({
					chart: {
						plotBackgroundColor: null,
						plotBorderWidth: null,
						plotShadow: false
					},
					colors: ['#188ae2', '#3ab74c', '#ff7373', '#DDDF00',
							 '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4','#82a6f5',
							 '#9ff048','#f1aaa6','#c09eff','#82d0f5']
					,
					title: {
						text: ''
					},
					tooltip: {
						headerFormat: '',
						pointFormat: '{point.name}: <span class="point-value">{point.percentage:.1f}%</span>'
					},
					plotOptions: {
						pie: {
							allowPointSelect: true,
							cursor: 'pointer',
							dataLabels: {
								enabled: true,
                useHTML: true,
                format: '<div class="label-item"><span class="point-label">{point.name}</span><span class="point-percent">, {point.percentage:.1f} %</span></div>',
								style: {
									color: '#666',
									fontSize: "12px",
									fontWeight: "normal"
								}
							}
						}
					},
					series: [{
						type: 'pie',
						name: '',
						// 数据
						data: arr_ym
					}]
				});
		}, "json");
		//地域分布
		var arr_gj = new Array();
		$.get("/wp-admin/admin-ajax.php", { "action": "stats_data_uvgj", month :cur_month},
			   function(data){
				   $('.gj_moth_'+cur_month+'_moth').html(data.moth_moth);	   
				   $('#gj_moth_'+cur_month+'_pv').html(data.moth_pv);
				   $('#gj_moth_'+cur_month+'_ip').html(data.moth_ip);
				   
				   var country_top10_html = '';
				   
				   $.each(data.country_top15, function(i,item){
					   if(i<10){
						country_top10_html +="<li>"+item['show_area']+"</li>";
						arr_gj[i] = new Array(i);
						arr_gj[i][0] = item['show_area'];
						arr_gj[i][1] = parseInt(item['ip_area']);
					   }
					});
				   $('#gj_country_top10_'+cur_month).html(country_top10_html);
					
					$('#referrals-report-chart_gj_'+cur_month).highcharts({
						chart: {
							plotBackgroundColor: null,
							plotBorderWidth: null,
							plotShadow: false
						},
						colors: ['#188ae2', '#3ab74c', '#ff7373', '#DDDF00',
								 '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4','#82a6f5',
								 '#9ff048','#f1aaa6','#c09eff','#82d0f5']
						,
						title: {
							text: ''
						},
						tooltip: {
							headerFormat: '',
							pointFormat: '{point.name}: <span class="point-value">{point.percentage:.1f}%</span>'
						},
						plotOptions: {
							pie: {
								allowPointSelect: true,
								cursor: 'pointer',
								dataLabels: {
									enabled: true,
									format: '<span class="point-label">{point.name}</span>, {point.percentage:.1f} %',
									style: {
										color: '#666',
										fontSize: "12px",
										fontWeight: "normal"
									}
								}
							}
						},
						series: [{
							type: 'pie',
							name: '',
							// 数据
							data: arr_gj
						}]
					});
			}, "json");
		//询盘数据
		$.get("/wp-admin/admin-ajax.php", { "action": "stats_data_xptj", month :cur_month},
		   function(data){  
			   $('#xunpan_num').html(data.cf_count);
			   $('#xunpan_num_month').html(data.cf_count_month);
			   var start_num = data.cf_count_month-3;
			   if(start_num < 0){
					start_num = 0;
			   }
			   var end_num = data.cf_count_month+3;
			   $('#send_email_xunpan').html(start_num+"-"+end_num);
			   
			   var country_top10_html = '';
			   $.each(data.country_top20, function(i,item){
					country_top10_html += item['show_area']+"、";
				});
				country_top10_html=country_top10_html.substring(0,country_top10_html.length -1);
			   $('#xunp_from_country').html(country_top10_html);
		}, "json");
});
</script>
<?php }?>
<!-- PDF 文档下载 (2018-05-10) -->
<script type="text/javascript" src="//www.quanqiusou.cn/admin40/js/canvg2.js"></script>
<script type="text/javascript" src="//www.quanqiusou.cn/admin40/js/html2canvas.js"></script>
<script type="text/javascript" src="//www.quanqiusou.cn/admin40/js/jsPdf.debug.js"></script>
<script type="text/javascript">
$(function(){
  $(window).on('load',function(){
    $('.report-layer .btn-download-report').fadeIn(300);
  })
})
var downPdf = document.getElementById("renderPdf");
var layHeightArr=[];
$('.report-layer').each(function(){
  var layH=parseInt($(this).height());
  layHeightArr.push(layH);
})
var pdfLayH=Math.max.apply(null,layHeightArr);
var pdfLayW=$('.pdf-pages').width();
var actualWidth = 595.28;
var actualHeight =pdfLayH/pdfLayW*595.28;
var formatSize=[actualWidth,actualHeight];
var layScale=actualHeight/actualWidth;
if(layScale<1){
var dfPdf=new jsPDF('l', 'mm',formatSize);
}
else{
var dfPdf=new jsPDF('p', 'pt',formatSize);
}
downPdf.onclick = function() {
      if($('.pdf-create-pop').length<1){
        $('.pdf-pages').append('<div class="pdf-create-pop"><div class="pdf-pop-msg"><div class="pop-msg-txt"></div></div></div>');
      }
      $('body').addClass('pdf-create');
      $('.btn-download-report').hide();
      $('.pdf-create-pop').fadeIn(300);
      var lableDiv = document.getElementById('pdf-pages').getElementsByClassName("report-layer");
      createCanvas(dfPdf,lableDiv[i],0);
      svg2canvas($('.pdf-pages .report-layer'));
}
function createCanvas(pdf,lableDiv,index){
   var lableDiv = document.getElementById('pdf-pages').getElementsByClassName("report-layer");
   var ele=lableDiv[index];
    var date=new Date();
    //var pdfYear=date.getFullYear().toString();
    //var pdfMonth=parseInt(date.getMonth()+1).toString();
    var pdfMonth = "<?php echo $cur_month_ym;?>";
    
    var main = {
        init:function(){
            main.html2Canvas();
        },
        //获取像素密度
        getPixelRatio:function(context){
            var backingStore = context.backingStorePixelRatio ||
                    context.webkitBackingStorePixelRatio ||
                    context.mozBackingStorePixelRatio ||
                    context.msBackingStorePixelRatio ||
                    context.oBackingStorePixelRatio ||
                    context.backingStorePixelRatio || 1;
            return (window.devicePixelRatio || 1) / backingStore;
        },
        //绘制dom 元素,生成截图canvas
        html2Canvas: function () {
            // svg2canvas(ele);
            $('.pdf-create-pop .pop-msg-txt').html('正在生成PDF文档第'+'<b>'+(parseInt(index)+1)+'</b>页');
            var shareContent = $('.report-layer-'+(index+1));// 需要绘制的部分的 dom 对象 ,注意容器的宽度不要使用百分比,使用固定宽度,避免缩放问题
            var width = shareContent.width();  // 获取(原生)dom 宽度
            var height = shareContent.height(); // 获取(原生)dom 高
            var offsetTop = shareContent.offset().top;  //元素距离顶部的偏移量
            var canvas = document.createElement('canvas');  //创建canvas 对象
            canvas.setAttribute('class','pdf-canvas canvas'+index);
            var context = canvas.getContext('2d');
            var scaleBy = main.getPixelRatio(context);  //获取像素密度的方法 (也可以采用自定义缩放比例)
            canvas.width = (width+shareContent.offset().left*2) * scaleBy;   
            canvas.height = (height + offsetTop) * scaleBy;  // 注意高度问题,由于顶部有个距离所以要加上顶部的距离,解决图像高度偏移问题
            context.scale(scaleBy, scaleBy);
            var opts = {
                allowTaint:false,//允许加载跨域的图片
                tainttest:true, //检测每张图片都已经加载完成
                scale:scaleBy, // 添加的scale 参数
                canvas:canvas, //自定义 canvas
                logging: false, //日志开关,发布的时候记得改成false
                width:width, //dom 原始宽度
                height:height, //dom 原始高度
                background: "#fff"
            };
            html2canvas(shareContent, opts).then(function (canvas) {
                var body = document.getElementsByTagName("body");
                body[0].appendChild(canvas);
                if(index==0){
                  var pageData;
                }
                var pageData = canvas.toDataURL('image/jpeg', 1.0);
                var contentWidth = canvas.width;
                var contentHeight = canvas.height;
				var company_name = "<?php echo $company_name;?>";
                var imgWidth = 595.28;
                var imgHeight = 595.28/contentWidth * contentHeight;
                pageWidth=595.28;
                pageHeight=contentHeight/contentWidth*pageWidth;
                pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
              if(index==lableDiv.length-1){
                pdf.save('全球搜月度报表_'+company_name+'_'+pdfMonth+'.pdf');
                $('body').removeClass('pdf-create').addClass('pdf-exited');
                $('.pdf-create-pop').fadeOut(200,function(){
                  $('.btn-download-report').fadeIn(200);
                });
                dfPdf=new jsPDF('l', 'mm',formatSize); //避免数据重复
              }
              if(index<lableDiv.length){
                pdf.addPage();
                pageData='';
              }
              index++;
              if(index < lableDiv.length){
                 window.setTimeout(createCanvas(pdf,lableDiv,index),200);
              }
            });
        }
    };
    //最后运行代码
    main.init();
}
function svg2canvas(targetElem) {
    var svgElem = targetElem.find('svg');
    svgElem.each(function (index, node) {
        var parentNode = node.parentNode;
        //由于现在的IE不支持直接对svg标签node取内容,所以需要在当前标签外面套一层div,通过外层div的innerHTML属性来获取
        var tempNode = document.createElement('div');
        tempNode.appendChild(node);
        var svg = tempNode.innerHTML;
        var canvas = document.createElement('canvas');
        //转换
        canvg(canvas, svg);
        parentNode.appendChild(canvas);
    });
}
</script>
<script src = "https://cdn.polyfill.io/v2/polyfill.min.js"></script>
</body>
</html>