欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

自己写的shipingzhongcustom模块 第二部分 有大用

function _kefuchat_node_form_validation_two($form, &$form_state)
{


  if($form_state['values']['field_is_shangmen'][0]['value'] == '是' ){
     if(empty($form_state['values']['field_shangmeng_time'][0]['value'])){
        form_set_error('field_shangmeng_time','上门时间不能为空');
     }
//    if($form_state['values']['field_qq_property'][0]['value']!='400xinqu' &&
//       $form_state['values']['field_qq_property'][0]['value']!='400wuzhong' &&
//       $form_state['values']['field_qq_property'][0]['value']!='hd400'  ){

     if(empty($form_state['values']['field_genzong_time'][0]['value'])){
        form_set_error("field_genzong_time][0][value][date",'跟踪时间不能为空');
     }
     if(empty($form_state['values']['field_genzong_qingkuang'][0]['value'])){
        form_set_error("field_genzong_qingkuang][0][value",'跟踪情况不能为空');
     }
     if(empty($form_state['values']['field_genzong_fangshi'][0]['value'])){
        form_set_error("field_genzong_fangshi][0][value",'跟踪方式不能为空');
     }
//    }
  }

  if(!empty($form_state['values']['field_shangmeng_time'][0]['value']) && $form_state['values']['field_is_shangmen'][0]['value'] != '是'){
     form_set_error('field_is_shangmen','是否上门应该填\'\'');
  }
  if($form_state['values']['field_is_dingjing'][0]['value'] == '是' && empty($form_state['values']['field_dingjing_time'][0]['value'])){
     form_set_error('field_dingjing_time','订金时间不能为空');
  }
  if(!empty($form_state['values']['field_dingjing_time'][0]['value']) && $form_state['values']['field_is_dingjing'][0]['value'] != '是'){
     form_set_error('field_is_dingjing','是否订金应该填\'\'');
  }
  if($form_state['values']['field_is_dingjing'][0]['value'] == '是' && empty($form_state['values']['field_dingjingzuanye_select'][0]['value'])){
     form_set_error('field_dingjingzuanye_select','订金专业不能为空');
  }
  if($form_state['values']['field_is_dingjing'][0]['value'] == '是' && empty($form_state['values']['field_dingjingxuefei'][0]['value'])){
     form_set_error('field_dingjingxuefei','订金金额不能为空');
  }
  if(!empty($form_state['values']['field_dingjingxuefei'][0]['value']) && $form_state['values']['field_is_dingjing'][0]['value'] != '是'){
     form_set_error('field_is_dingjing','是否订金应该填\'\'');
  }

  if($form_state['values']['field_is_baoming'][0]['value'] == '是' && empty($form_state['values']['field_baoming_time'][0]['value'])){
     form_set_error('field_baoming_time','报名时间不能为空');
  }
  if(!empty($form_state['values']['field_baoming_time'][0]['value']) && $form_state['values']['field_is_baoming'][0]['value'] != '是'){
     form_set_error('field_is_baoming','是否报名应该填\'\'');
  }
  if($form_state['values']['field_is_baoming'][0]['value'] == '是' && empty($form_state['values']['field_baomingzuanye_select'][0]['value'])){
     form_set_error('field_baomingzuanye_select','报名专业不能为空');
  }
  if($form_state['values']['field_is_baoming'][0]['value'] == '是' && empty($form_state['values']['field_baomingxuefei'][0]['value'])){
     form_set_error('field_baomingxuefei','学费不能为空');
  }
  if(!empty($form_state['values']['field_baomingxuefei'][0]['value']) && $form_state['values']['field_is_baoming'][0]['value'] != '是'){
     form_set_error('field_is_baoming','是否报名应该填\'\'');
  }
  if($form_state['values']['field_is_zx_shangmen'][0]['value'] == '是' && empty($form_state['values']['field_zx_shangmeng_time'][0]['value'])){
     form_set_error('field_zx_shangmeng_time','转向上门时间不能为空');
  }
  /*if($form_state['values']['field_is_dingjing'][0]['value'] == '是' && empty($form_state['values']['field_id_card'][0]['value'])){
     form_set_error('field_id_card','身份证号不能为空');
  }*/
  if(_is_add_edit_xx() && $form_state['values']['field_is_baoming'][0]['value'] == '是' && empty($form_state['values']['field_id_card'][0]['value'])){
     form_set_error('field_id_card','身份证号不能为空');
  }
  /* if(_is_add_edit_xx() && $form_state['values']['field_is_dingjing'][0]['value'] == '是' && empty($form_state['values']['field_id_card'][0]['value'])){
           form_set_error('field_id_card','身份证号不能为空');
       }*/
  /*$export = kprint_r($form,TRUE);
  print $export;*/

  //这是学校
  foreach($form_state['values']['field_genzong_time'] as $key=>$value){
     if(!empty($value['value'])){
        if(empty($form_state['values']['field_genzong_qingkuang'][$key]['value'])){
           form_set_error("field_genzong_qingkuang][$key][value",'跟踪情况不能为空');
        }
        if(empty($form_state['values']['field_genzong_yxjb']) || empty($form_state['values']['field_genzong_yxjb'][0]['value'])){
           form_set_error("field_genzong_yxjb",'跟踪意向级别不能为空');
        }
        if(empty($form_state['values']['field_genzong_fangshi'][$key]['value'])){
           form_set_error("field_genzong_fangshi][$key][value",'跟踪方式不能为空');
        }
//       if(empty($form_state['values']['field_genzong_next_time'][$key]['value'])){
//          $form_state['values']['field_genzong_next_time'][$key]['value'] = Null;
//          $form_state['values']['field_genzong_next_time'][$key]['_weight'] = $key;
//          $form_state['values']['field_genzong_next_time'][$key]['value2'] = Null;
//          $form_state['values']['field_genzong_next_time'][$key]['timezone'] = 'Asia/Chongqing';
//          $form_state['values']['field_genzong_next_time'][$key]['offset'] = 28800;
//          $form_state['values']['field_genzong_next_time'][$key]['offset2'] = 28800;
//       }
     }
  }

  foreach($form_state['values']['field_genzong_qingkuang'] as $key=>$value){
     if(!empty($value['value'])){
        if(empty($form_state['values']['field_genzong_time'][$key]['value'])){
           form_set_error("field_genzong_time][$key][value][date",'跟踪时间不能为空');
        }
        if(empty($form_state['values']['field_genzong_yxjb']) || empty($form_state['values']['field_genzong_yxjb'][0]['value'])){
           form_set_error("field_genzong_yxjb",'跟踪意向级别不能为空');
        }
        if(empty($form_state['values']['field_genzong_fangshi'][$key]['value'])){
           form_set_error("field_genzong_fangshi][$key][value",'跟踪方式不能为空');
        }
     }
  }
  if(!empty($form_state['values']['field_genzong_yxjb']) && !empty($form_state['values']['field_genzong_yxjb'][0]['value'])){
     if(empty($form_state['values']['field_genzong_time'][0]['value'])){
        form_set_error("field_genzong_time][0][value][date",'跟踪时间不能为空');
     }
     if(empty($form_state['values']['field_genzong_qingkuang'][0]['value'])){
        form_set_error("field_genzong_qingkuang][0][value",'跟踪情况不能为空');
     }
     if(empty($form_state['values']['field_genzong_fangshi'][0]['value'])){
        form_set_error("field_genzong_fangshi][0][value",'跟踪方式不能为空');
     }

  }
  foreach($form_state['values']['field_genzong_fangshi'] as $key=>$value){

     if(!empty($value['value'])){
        if($value['value']!=='短信' && $value['value']!=='电话' && $value['value']!=='微信' && $value['value']!=='QQ' ){
           form_set_error("field_genzong_fangshi][$key][value","跟踪方式只能为'短信'、'电话'、'微信'、'QQ'中的一种");
        }
        if(empty($form_state['values']['field_genzong_time'][$key]['value'])){
           form_set_error("field_genzong_time][$key][value][date",'跟踪时间不能为空');
        }
        if(empty($form_state['values']['field_genzong_qingkuang'][$key]['value'])){
           form_set_error("field_genzong_qingkuang][$key][value",'跟踪情况不能为空');
        }
        if(empty($form_state['values']['field_genzong_yxjb']) || empty($form_state['values']['field_genzong_yxjb'][0]['value'])){
           form_set_error("field_genzong_yxjb",'跟踪意向级别不能为空');
        }
     }
  }
  foreach($form_state['values']['field_genzong_next_time'] as $key=>$value){
     if(!empty($value['value'])){
        if(empty($form_state['values']['field_genzong_time'][$key]['value'])){
           form_set_error("field_genzong_time][$key][value][date",'跟踪时间不能为空');
        }
        if(empty($form_state['values']['field_genzong_qingkuang'][$key]['value'])){
           form_set_error("field_genzong_qingkuang][$key][value",'跟踪情况不能为空');
        }
        if(empty($form_state['values']['field_genzong_yxjb']) || empty($form_state['values']['field_genzong_yxjb'][0]['value'])){
           form_set_error("field_genzong_yxjb",'跟踪意向级别不能为空');
        }
        if(empty($form_state['values']['field_genzong_fangshi'][$key]['value'])){
           form_set_error("field_genzong_fangshi][$key][value",'跟踪方式不能为空');
        }
     }
  }







  //form_set_error('current_posts_max', t('You must enter a number for the maximum number of posts to display.'));
}
function _kefuchat_node_form_validation($form, &$form_state) {

  $arg0=arg(0);
  $arg1=arg(1);
  $arg2=arg(2);
  //在有电话号码的时候
  if($form_state['values']['field_tel'][0]['value'])
  {


     //var_dump($form_state['values']['field_suozaixiaoqu']['value']);
     //var_dump($form_state['values']['field_tel'][0]['value']);
     //假如是编辑的情况下
     if( $form_state['values']['nid']){
        $sql = "select n.nid as nid from {node} as n inner join {content_type_kefuchat} as kefu on n.nid=kefu.nid
      inner join {content_field_tel} as tel on n.nid=tel.nid  where n.type='kefuchat' and tel.field_tel_value='%s' and n.nid!='%d' ";
        $result =  db_query($sql,trim($form_state['values']['field_tel'][0]['value']), $form_state['values']['nid']);
//       if(user_access('access administration pages')){
//          var_dump("AAA");
//          var_dump($sql);
//          var_dump(trim($form_state['values']['field_tel'][0]['value']));
//          var_dump($form_state['values']['nid']);
//          exit;
//       }
     }
     //假如增加的情况下
     else {
        $sql = "select n.nid as nid from {node} as n inner join {content_type_kefuchat} as kefu on n.nid=kefu.nid
      inner join {content_field_tel} as tel on n.nid=tel.nid  where n.type='kefuchat' and tel.field_tel_value='%s' ";
        $result =  db_query($sql,trim($form_state['values']['field_tel'][0]['value']));
//       if(user_access('access administration pages')){
//          var_dump("BBB");
//          var_dump($sql);
//          var_dump(trim($form_state['values']['field_tel'][0]['value']));exit;
//       }
     }


     $rowIds = array();
     while ($rowObject = db_fetch_object($result))
     {
        $rowIds[]= $rowObject->nid;
     }
     $rowObjs = array();
     foreach($rowIds as $id)
     {
        $rowObjs[] = node_load($id);
     }
     foreach($rowObjs as $key=>$obj)
     {

        drupal_set_message('以前存在过这个号码','error',false);
        $form_state['values']['field_tel'][0]['value'] = $form_state['values']['field_tel'][0]['value']."cf_tel";
//       empty($obj->field_suozaixiaoqu[0]['value']) && $obj->field_suozaixiaoqu[0]['value']='wz';
//      
//       if($obj->field_suozaixiaoqu[0]['value'] == $form_state['values']['field_suozaixiaoqu']['value']){
//          form_set_error('field_suozaixiaoqu', "对不起已存在这个电话号码,原来的电话号码<a href='/node/".$obj->nid."/edit'>在这里</a>!");
//       }
//       else if($obj->field_suozaixiaoqu[0]['value'] != $form_state['values']['field_suozaixiaoqu']['value']){
//          drupal_set_message('已在另一个校区存在这个号码','error',false);
//          $form_state['values']['field_tel'][0]['value'] = $form_state['values']['field_tel'][0]['value']."cf_tel";
//       }

     }
     // var_dump($form_state['values']['field_suozaixiaoqu']);
     // var_dump($rowObjs);
     // exit;
  }

  //在有微信号的时候
  if($form_state['values']['field_weixinhao'][0]['value'])
  {

     //var_dump($form_state['values']['field_suozaixiaoqu']['value']);
     //var_dump($form_state['values']['field_weixinhao'][0]['value']);exit;
     //假如是编辑的情况下
     if( $form_state['values']['nid']){
        $sql = "select nid from {content_type_kefuchat} where field_weixinhao_value='%s' and nid!='%d' ";
        $result =  db_query($sql,trim($form_state['values']['field_weixinhao'][0]['value']), $form_state['values']['nid']);
//       $str = sprintf($sql, trim($form_state['values']['field_weixinhao'][0]['value']), $form_state['values']['nid']);
//       var_dump($str);
     }
     //假如增加的情况下
     else {
        $sql = "select nid from {content_type_kefuchat} where field_weixinhao_value='%s' ";
        $result =  db_query($sql,trim($form_state['values']['field_weixinhao'][0]['value']));
//       $str = sprintf($sql, trim($form_state['values']['field_weixinhao'][0]['value']));
//       var_dump($str);
     }

     $rowIds = array();
     while ($rowObject = db_fetch_object($result))
     {
        $rowIds[]= $rowObject->nid;
     }
     $rowObjs = array();
     foreach($rowIds as $id)
     {
        $rowObjs[] = node_load($id);
     }

     foreach($rowObjs as $key=>$obj)
     {

        drupal_set_message('以前存在过这个微信号','error',false);
        $form_state['values']['field_weixinhao'][0]['value'] = $form_state['values']['field_weixinhao'][0]['value']."cf_weixinhao";
//       empty($obj->field_suozaixiaoqu[0]['value']) && $obj->field_suozaixiaoqu[0]['value']='wz';
//
//       if($obj->field_suozaixiaoqu[0]['value'] == $form_state['values']['field_suozaixiaoqu']['value']){
//          form_set_error('field_suozaixiaoqu', "对不起已存在这个电话号码,原来的电话号码<a href='/node/".$obj->nid."/edit'>在这里</a>!");
//       }
//       else if($obj->field_suozaixiaoqu[0]['value'] != $form_state['values']['field_suozaixiaoqu']['value']){
//          drupal_set_message('已在另一个校区存在这个号码','error',false);
//          $form_state['values']['field_tel'][0]['value'] = $form_state['values']['field_tel'][0]['value']."cf_tel";
//       }

     }
     // var_dump($form_state['values']['field_suozaixiaoqu']);
     // var_dump($rowObjs);
     // exit;
  }

  return $form;
}
//下面是百度的接口 两个作用 一个是保存node的手机归属地 第二个就是返回手机归属地
function _get_guishudi_from_baidu_interface($node,$tel)
{
  $ch = curl_init();
  $url = 'http://apis.baidu.com/apistore/mobilenumber/mobilenumber?phone='.$tel;
  $header = array(
     'apikey: cbba4c9bf1b8db573812e3c43a7b78fc',//这是apikey
  );
  // 添加apikey到header
  curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  // 执行HTTP请求
  curl_setopt($ch , CURLOPT_URL , $url);
  $res = curl_exec($ch);

  $obj = json_decode($res);
  if($obj->errNum==0){
     $outputstring = $obj->retData->province.'省'.$obj->retData->city.'市 '.$obj->retData->supplier;
     $node->field_shoujiguishudi[0]['value'] = $outputstring;
     node_save($node);
  }else{
     $outputstring = '';
  }

  return $outputstring;


}

//从 https://www.juhe.cn/docs/api/id/11 过来的接口
function _get_guishudi_from_juhe_interface($node,$tel){

  $json = file_get_contents('http://apis.juhe.cn/mobile/get?phone='.$tel.'&key=e878558862e7babf1a3cf6fb267ee125');
  $obj = json_decode($json);

  if(!empty($obj) && $obj->error_code == 0){
     $outputstring = $obj->result->province.'省'.$obj->result->city.'市 '.$obj->result->company;
     $node->field_shoujiguishudi[0]['value'] = $outputstring;
     node_save($node);

  }
  else{
     $outputstring = '';
  }
  return $outputstring;
}

//从 https://www.juhe.cn/docs/api/id/11 过来的接口
function _get_guishudi_from_jisuapi_interface($node,$tel){

  $json = file_get_contents('http://api.jisuapi.com/shouji/query?appkey=579d583411c7b99b&shouji='.$tel);
  $obj = json_decode($json);


  if(!empty($obj) && $obj->status == 0){
     $outputstring = $obj->result->province.'省'.$obj->result->city.'市 '.$obj->result->company;
     $node->field_shoujiguishudi[0]['value'] = $outputstring;
     node_save($node);

  }
  else{
     $outputstring = '';
  }
  return $outputstring;
}

//从http://api.showji.com/locating// 过来的接口
/*function _get_guishudi_from_guishu_showji_com_interface($node,$tel){

  $content = file_get_contents('http://guishu.showji.com/search.htm?m='.$tel);
  //var_dump("AAAAAA");
  //var_dump($content);
  //var_dump("BBBBBB");

  if(!empty($obj) && $obj->error_code == 0){
     $outputstring = $obj->result->province.'省'.$obj->result->city.'市 '.$obj->result->company;
     $node->field_shoujiguishudi[0]['value'] = $outputstring;
     node_save($node);

  }
  else{
     $outputstring = '';
  }
  return $outputstring;
}*/

function _getGuishude($nid,$tel)
{

  $node = node_load($nid);

  $tel = strval(trim($tel));
  //var_dump($tel);
  //$json = file_get_contents('http://apis.juhe.cn/mobile/get?phone='.$tel.'&key=e878558862e7babf1a3cf6fb267ee125');
  //var_dump(json_decode($json));
  if(empty($tel)){
     return '';
  }
  $tel = substr($tel,0,11);
  //下面是财付通
  /*$guishudi = @file_get_contents("http://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=".$tel);
  $guishudi = iconv('GBK','UTF-8',$guishudi);
  $guishudi =  str_replace('encoding="gb2312"','encoding="utf-8"',$guishudi);
  $dataObj = simplexml_load_string($guishudi);

  if(strval($dataObj->retmsg)=='OK'){
     $outputstring = trim(strval($dataObj->province)).'省'.trim(strval($dataObj->city)).'市  '.strval($dataObj->supplier).' ';
     $node->field_shoujiguishudi[0]['value'] = $outputstring;
     node_save($node);
  }
  else{
     $outputstring = '';
  }*/
  //下面是http://www.apidata.cn/ 的接口
// $guishudi = @file_get_contents('http://sj.apidata.cn/?mobile='.$tel);
// $guishudi_arr = json_decode($guishudi,true);
// if(!empty($guishudi_arr['status']) && ($guishudi_arr['message']=='success')){
//    $outputstring =  $guishudi_arr['data']['province'].'省'. $guishudi_arr['data']['city'].'市'.' '.$guishudi_arr['data']['isp'];
//    $node->field_shoujiguishudi[0]['value'] = $outputstring;
//    node_save($node);
// }
// else{
//    $outputstring = '';
// }
  //下面是百度的接口 两个作用 一个是保存node的手机归属地 第二个就是返回手机归属地
  //$outputstring = _get_guishudi_from_baidu_interface($node,$tel);

  //$outputstring = _get_guishudi_from_guishu_showji_com_interface($node,$tel);
  $outputstring = _get_guishudi_from_juhe_interface($node,$tel);
// $outputstring = _get_guishudi_from_jisuapi_interface($node,$tel);


  return $outputstring;
}
function _getGuishudeByIdTel($guishudi,$nid,$tel)
{
  if(!empty($guishudi)){
     return $guishudi;
  }
  return _getGuishude($nid,$tel);
}
////hook import postprocess
//function hook_node_import_postprocess($type, $values, $options, $preview) {
//
//
//
//}
////hook import task
//function  hook_node_import_task($task, $op){
//
//}
//hook import format options
//function hook_node_import_format_options_alter(&$formats, $op){
//
//
//}
//竞价总表时间验证
function _jingjiazongbiaotype_node_form_validation($form, &$form_state) {
  $arg0 = arg(0);
  $arg1 = arg(1);
  $arg2 = arg(2);
  global $user;
  //当华东角色的人进行编辑时 ,不能个修改日期
  //&& in_array('是且仅是华东角色',$user->roles)


  if($arg0=='node' && is_numeric($arg1) && $arg2=='edit' && in_array('是且仅是华东角色',$user->roles) && $form_state['submitted']){
     $node = node_load($arg1);
     $nodeDateStr =  date('Y-m-d',strtotime($node->field_zong_time[0]['value']));
     $strDate = $form_state['values']['field_zong_time'][0]['value']["date"];
     if($nodeDateStr != $strDate){
        form_set_error('field_zong_time', "日期不能修改,原来日期是 ".$nodeDateStr);
     }
  }
  else if($form_state['values']['field_zong_time'][0]['value']["date"])
  {
     $strDate = $form_state['values']['field_zong_time'][0]['value']["date"];
     $strDateYmdHis =  date('Y-m-d H:i:s',strtotime($strDate));
     $sql ="select n.nid from node as n inner join content_field_zong_time as zong_time on n.nid=zong_time.nid
      where n.type='jingjiazongbiaotype' and zong_time.field_zong_time_value='$strDateYmdHis'";
     $result =  db_result(db_query($sql));
     if(!empty($result) && $form_state['values']['nid']!=$result ){
        form_set_error('field_zong_time', $strDate."原来有竞价总表,<a href='/node/".$result."/edit'>在这里编辑</a>!");
     }
  }



  return $form;
}
//客服总表时间验证
function _kefuzongbiaotype_node_form_validation($form, &$form_state) {
  $arg0 = arg(0);
  $arg1 = arg(1);
  $arg2 = arg(2);
  global $user;
  //当华东角色的人进行编辑时 ,不能个修改日期
  //&& in_array('是且仅是华东角色',$user->roles)

  if($arg0=='node' && is_numeric($arg1) && $arg2=='edit' && in_array('是且仅是华东角色',$user->roles) && $form_state['submitted']){
     $node = node_load($arg1);
     $nodeDateStr =  date('Y-m-d',strtotime($node->field_zong_time[0]['value']));
     $strDate = $form_state['values']['field_zong_time'][0]['value']["date"];
     if($nodeDateStr != $strDate){
        form_set_error('field_zong_time', "日期不能修改,原来日期是 ".$nodeDateStr);
     }
  }
  else if($form_state['values']['field_zong_time'][0]['value']["date"])
  {
     $strDate = $form_state['values']['field_zong_time'][0]['value']["date"];
     $strDateYmdHis =  date('Y-m-d H:i:s',strtotime($strDate));
     $sql ="select n.nid from node as n inner join content_field_zong_time as zong_time on n.nid=zong_time.nid
      where n.type='kefuzongbiaotype' and zong_time.field_zong_time_value='$strDateYmdHis'";
     $result =  db_result(db_query($sql));
     if(!empty($result)  && $form_state['values']['nid']!=$result  ){
        form_set_error('field_zong_time', $strDate."原来有客服总表,<a href='/node/".$result."/edit'>在这里编辑</a>!");
     }
  }


  return $form;
}
function _seozongbiaotype_node_form_validation($form, &$form_state) {
  if($form_state['values']['field_zong_time'][0]['value']["date"])
  {
     $strDate = $form_state['values']['field_zong_time'][0]['value']["date"];
     $strDateYmdHis =  date('Y-m-d H:i:s',strtotime($strDate));
     $sql ="select n.nid from node as n inner join content_field_zong_time as zong_time on n.nid=zong_time.nid
      where n.type='seozongbiaotype' and zong_time.field_zong_time_value='$strDateYmdHis'";
     $result =  db_result(db_query($sql));
     if(!empty($result)  && $form_state['values']['nid']!=$result ){
        form_set_error('field_zong_time', $strDate."原来有seo总表,<a href='/node/".$result."/edit'>在这里编辑</a>!");
     }
  }

  return $form;
}
function _sijing2br($str)
{
  if(stripos($str,'####') !== false){
     return str_replace('####','<br />',$str);
  }
  return $str;
}
//返回要计算的年月日
//function _getCalcStartYMD()
//{
// $today = date('d');
// if($today>8){
//    return date('Y-m').'-08';
// }else{
//             //本月的上一天
//    return date('Y-m',(strtotime(date('Y-m-01'))-24*60*60)).'-08';
// }
//}
function _getCalcStartYMD()
{
  //返回上个月的25日
// return  date("Y-m-d", mktime(0, 0, 0, date("n", time())-1, 25, date("Y", time())));
  //返回的是本月1日
  return date('Y-m').'-01';
}



function _getCalcEndYMD(){
  return date('Y-m-d',strtotime(date('Y-m-d'))-24*60*60);
}
function _objectToArray($e){
  $e=(array)$e;
  foreach($e as $k=>$v){
     if( gettype($v)=='resource' ) return;
     if( gettype($v)=='object' || gettype($v)=='array' )
        $e[$k]=(array)_objectToArray($v);
  }
  return $e;
}






function _getTotalXiaoFei($matches){

  global $totalZongArr;
  $keyArray=array(63=>'totalXiaoFei',28=>'totalZongZiXun',29=>'totalYouXiaoZiXun'
  ,'30'=>'totalShangMenLiang','60'=>'totalBaoMingLiang','61'=>'totalDinjinLiang'
  ,'101'=>'wz_ZongXiaoFei','107'=>'xq_ZongXiaoFei','104'=>'hd_ZongXiaoFei'
     //,10=>'hd_ZongBaiduXiaoFei',9=>'hd_ZongSouGouXiaoFei',16=>'hd_Zong360XiaoFei'
  ,'wz-zzx'=>'wz_ZongZiXun','wz-yxzx'=>'wz_YouXiaoZiXun','wz-shanmenliang'=>'wz_ShangMenLiang','wz-baomingliang'=>'wz_BaoMingLiang','wz-dinjinliang'=>'wz_DinjinLiang'
  ,'xq-zzx'=>'xq_ZongZiXun','xq-yxzx'=>'xq_YouXiaoZiXun','xq-shanmenliang'=>'xq_ShangMenLiang','xq-baomingliang'=>'xq_BaoMingLiang','xq-dinjinliang'=>'xq_DinjinLiang'
  ,'hd-zzx'=>'hd_ZongZiXun','hd-yxzx'=>'hd_YouXiaoZiXun','hd-shanmenliang'=>'hd_ShangMenLiang','hd-baomingliang'=>'hd_BaoMingLiang','hd-dinjinliang'=>'hd_DinjinLiang');
  $totalZongArr[$keyArray[$matches[3]]]= floatval($totalZongArr[$keyArray[$matches[3]]])+floatval($matches[4]);
  return $matches[0];

}
function _getTotal($result)
{
  global $totalZongArr;
  //每次总是初始化给 $totalZongArr 置为空
  $totalZongArr = array();
  //$export = kprint_r($result, TRUE);
  //print $export;
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(63)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);//总消费
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(101)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);//吴中总消费
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(107)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);//爱丁堡总消费
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(104)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);//华东总消费
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(28)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(29)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(30)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(60)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(61)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);

  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(wz-zzx)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(wz-yxzx)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(wz-shanmenliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(wz-baomingliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(wz-dinjinliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);

  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(xq-zzx)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(xq-yxzx)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(xq-shanmenliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(xq-baomingliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(xq-dinjinliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);


  //preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(10)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  //preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(9)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  //preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-php-(16)">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(hd-zzx)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(hd-yxzx)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(hd-shanmenliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(hd-baomingliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);
  preg_replace_callback('/<td([\s]*)class="views-field([\s]*)views-field-field-kf-(hd-dinjinliang)-value">([^<]*)<\/td>/misU','_getTotalXiaoFei',$result);



}
//function _getOneMonthTongjiInfo($calcYMDStart,$calcYMDEnd='')
//{
////   var_dump($calcYMDStart);
////   var_dump($calcYMDEnd);
////   $calcYMDStart = '2014-08-08';
////   $calcYMDEnd  = '2014-08-26';
// // $result = views_get_view_result('allcontentview','page_14',array(1,2,3,4,5,6,7,8));
// $name = 'allcontentview';
//    $display_id = 'page_14';
// $view = views_get_view($name);
// $arguments = array();
//    $view->set_display($display_id);
// //下面几行是设过滤器
//    $item = $view->get_item($display_id, 'filter', 'field_zong_time_value');
//    $item['value']['value'] = $calcYMDStart;
//    $item['value']['default_date'] = $calcYMDStart;
//    $view->set_item($display_id, 'filter', 'field_zong_time_value', $item);
//    if(!empty($calcYMDEnd)){
//     $item = $view->get_item($display_id, 'filter', 'field_zong_time_value_1');
////        $export = kprint_r($item, TRUE);
////         print $export;
//        $item['value']['value'] = $calcYMDEnd;
//        $item['value']['default_date'] = $calcYMDEnd;
//        $item['default_date'] = $calcYMDEnd;
//        $view->set_item($display_id, 'filter', 'field_zong_time_value_1', $item);
////        $item = $view->get_item($display_id, 'filter', 'field_zong_time_value_1');
////                $export = kprint_r($item, TRUE);
//// print $export;
//
//    }
//
//    $view->pre_execute();
//    $view->execute();
//
////    $result = $view->result;
////            $export = kprint_r($result, TRUE);
//// print $export;
//    $result = $view->render();
//    _getTotal($result);
//
//
////        $export = kprint_r($result, TRUE);
//// print $export;
//
//   //var_dump($sumArray);
//    //下面是各项总
//    global $totalZongArr;
// $totalXiaoFei = $totalZongArr['totalXiaoFei'];
// $totalZongZiXun = $totalZongArr['totalZongZiXun'];
// $totalYouXiaoZiXun = $totalZongArr['totalYouXiaoZiXun'];
// $totalShangMenLiang = $totalZongArr['totalShangMenLiang'];
// $totalBaoMingLiang = $totalZongArr['totalBaoMingLiang'];
// $totalDinjinLiang = $totalZongArr['totalDinjinLiang'];
// //吴中加新区的七个数据  新区加吴中的消费就是拿总消费减去 华东的三个消费
// $wz_xq_ZongXiaoFei = $totalZongArr['wz_ZongXiaoFei']+$totalZongArr['xq_ZongXiaoFei'];
// $wz_xq_ZongZiXun = $totalZongArr['wz_ZongZiXun']+$totalZongArr['xq_ZongZiXun'];
// $wz_xq_YouXiaoZiXun = $totalZongArr['wz_YouXiaoZiXun']+$totalZongArr['xq_YouXiaoZiXun'];
// $wz_xq_ShangMenLiang = $totalZongArr['wz_ShangMenLiang']+$totalZongArr['xq_ShangMenLiang'];
// $wz_xq_BaoMingLiang = $totalZongArr['wz_BaoMingLiang']+$totalZongArr['xq_BaoMingLiang'];
// $wz_xq_DinjinLiang = $totalZongArr['wz_DinjinLiang']+$totalZongArr['xq_DinjinLiang'];
// $wz_xq_BaoMingLiangAndDinjinLiang = $wz_xq_BaoMingLiang+$wz_xq_DinjinLiang;
// //吴中的七个数据
// $wz_ZongXiaoFei = $totalZongArr['wz_ZongXiaoFei'];
// $wz_ZongZiXun = $totalZongArr['wz_ZongZiXun'];
// $wz_YouXiaoZiXun = $totalZongArr['wz_YouXiaoZiXun'];
// $wz_ShangMenLiang = $totalZongArr['wz_ShangMenLiang'];
// $wz_BaoMingLiang = $totalZongArr['wz_BaoMingLiang'];
// $wz_DinjinLiang = $totalZongArr['wz_DinjinLiang'];
// $wz_BaoMingLiangAndDinjinLiang = $wz_BaoMingLiang+$wz_DinjinLiang;
// //新区的七个数据
// $xq_ZongXiaoFei = $totalZongArr['xq_ZongXiaoFei'];
// $xq_ZongZiXun = $totalZongArr['xq_ZongZiXun'];
// $xq_YouXiaoZiXun = $totalZongArr['xq_YouXiaoZiXun'];
// $xq_ShangMenLiang = $totalZongArr['xq_ShangMenLiang'];
// $xq_BaoMingLiang = $totalZongArr['xq_BaoMingLiang'];
// $xq_DinjinLiang = $totalZongArr['xq_DinjinLiang'];
// $xq_BaoMingLiangAndDinjinLiang = $xq_BaoMingLiang+$xq_DinjinLiang;
//
// //华东咨询的七个数据
// $hd_ZongXiaoFei = $totalZongArr['hd_ZongXiaoFei'];
// $hd_ZongZiXun = $totalZongArr['hd_ZongZiXun'];
// $hd_YouXiaoZiXun = $totalZongArr['hd_YouXiaoZiXun'];
// $hd_ShangMenLiang = $totalZongArr['hd_ShangMenLiang'];
// $hd_BaoMingLiang = $totalZongArr['hd_BaoMingLiang'];
// $hd_DinjinLiang = $totalZongArr['hd_DinjinLiang'];
// $hd_BaoMingLiangAndDinjinLiang = $hd_BaoMingLiang+$hd_DinjinLiang;
//   //下面是各项成本
//   $chengBenZongZiXun = round($totalXiaoFei/$totalZongZiXun,3);
//   $chengBenYouXiaoZiXun = round($totalXiaoFei/$totalYouXiaoZiXun,3);
//   $chengBenShangMenLiang = round($totalXiaoFei/$totalShangMenLiang,3);
//   $chengBaoMingLiang = round($totalXiaoFei/$totalBaoMingLiang,3);
//   $chengBaoMingLiangJiaDinJingLiang = round($totalXiaoFei/($totalBaoMingLiang+$totalDinjinLiang),3);
//
//   $chengBen_wz_xq_ZongZiXun = round($wz_xq_ZongXiaoFei/$wz_xq_ZongZiXun,3);
//   $chengBen_wz_xq_YouXiaoZiXun = round($wz_xq_ZongXiaoFei/$wz_xq_YouXiaoZiXun,3);
//   $chengBen_wz_xq_ShangMenLiang = round($wz_xq_ZongXiaoFei/$wz_xq_ShangMenLiang,3);
//   $cheng_wz_xq_BaoMingLiang = round($wz_xq_ZongXiaoFei/$wz_xq_BaoMingLiang,3);
//   $cheng_wz_xq_BaoMingLiangJiaDinJingLiang = round($wz_xq_ZongXiaoFei/$wz_xq_BaoMingLiangAndDinjinLiang,3);
// $chengBen_wz_ZongZiXun = round($wz_ZongXiaoFei/$wz_ZongZiXun,3);
// $chengBen_wz_YouXiaoZiXun = round($wz_ZongXiaoFei/$wz_YouXiaoZiXun,3);
// $chengBen_wz_ShangMenLiang = round($wz_ZongXiaoFei/$wz_ShangMenLiang,3);
// $cheng_wz_BaoMingLiang = round($wz_ZongXiaoFei/$wz_BaoMingLiang,3);
// $cheng_wz_BaoMingLiangJiaDinJingLiang = round($wz_ZongXiaoFei/$wz_BaoMingLiangAndDinjinLiang,3);
// $chengBen_xq_ZongZiXun = round($xq_ZongXiaoFei/$xq_ZongZiXun,3);
// $chengBen_xq_YouXiaoZiXun = round($xq_ZongXiaoFei/$xq_YouXiaoZiXun,3);
// $chengBen_xq_ShangMenLiang = round($xq_ZongXiaoFei/$xq_ShangMenLiang,3);
// $cheng_xq_BaoMingLiang = round($xq_ZongXiaoFei/$xq_BaoMingLiang,3);
// $cheng_xq_BaoMingLiangJiaDinJingLiang = round($xq_ZongXiaoFei/$xq_BaoMingLiangAndDinjinLiang,3);
//
//   $chengBen_hd_ZongZiXun = round($hd_ZongXiaoFei/$hd_ZongZiXun,3);
//   $chengBen_hd_YouXiaoZiXun = round($hd_ZongXiaoFei/$hd_YouXiaoZiXun,3);
//   $chengBen_hd_ShangMenLiang = round($hd_ZongXiaoFei/$hd_ShangMenLiang,3);
//   $cheng_hd_BaoMingLiang = round($hd_ZongXiaoFei/$hd_BaoMingLiang,3);
//   $cheng_hd_BaoMingLiangJiaDinJingLiang = round($hd_ZongXiaoFei/$hd_BaoMingLiangAndDinjinLiang,3);
//
//
//   //下面是各项转化率
//   $zhuanHuaLiZongZiXunToYouXiaoZiXun = (round($totalYouXiaoZiXun/$totalZongZiXun,3)*100).'%';
//   $zhuanHuaLiYouXiaoZiXunToShangMenLiang = (round($totalShangMenLiang/$totalYouXiaoZiXun,3)*100).'%';
//   $zhuanHuaLiShangMenLiangToBaoMingLiang = (round($totalBaoMingLiang/$totalShangMenLiang,3)*100).'%';
//   $zhuanHuaLiShangMenLiangToBaoMingLiangJiaDinJingLiang = (round(($totalBaoMingLiang+$totalDinjinLiang)/$totalShangMenLiang,3)*100).'%';
//
//   $zhuanHuaLi_wz_xq_ZongZiXunToYouXiaoZiXun = (round($wz_xq_YouXiaoZiXun/$wz_xq_ZongZiXun,3)*100).'%';
//   $zhuanHuaLi_wz_xq_YouXiaoZiXunToShangMenLiang = (round($wz_xq_ShangMenLiang/$wz_xq_YouXiaoZiXun,3)*100).'%';
//   $zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiang = (round($wz_xq_BaoMingLiang/$wz_xq_ShangMenLiang,3)*100).'%';
//   $zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($wz_xq_BaoMingLiangAndDinjinLiang/$wz_xq_ShangMenLiang,3)*100).'%';
//
//   $zhuanHuaLi_hd_ZongZiXunToYouXiaoZiXun = (round($hd_YouXiaoZiXun/$hd_ZongZiXun,3)*100).'%';
//   $zhuanHuaLi_hd_YouXiaoZiXunToShangMenLiang = (round($hd_ShangMenLiang/$hd_YouXiaoZiXun,3)*100).'%';
//   $zhuanHuaLi_hd_ShangMenLiangToBaoMingLiang = (round($hd_BaoMingLiang/$hd_ShangMenLiang,3)*100).'%';
//   $zhuanHuaLi_hd_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($hd_BaoMingLiangAndDinjinLiang/$hd_ShangMenLiang,3)*100).'%';
// $zhuanHuaLi_wz_ZongZiXunToYouXiaoZiXun = (round($wz_YouXiaoZiXun/$wz_ZongZiXun,3)*100).'%';
// $zhuanHuaLi_wz_YouXiaoZiXunToShangMenLiang = (round($wz_ShangMenLiang/$wz_YouXiaoZiXun,3)*100).'%';
// $zhuanHuaLi_wz_ShangMenLiangToBaoMingLiang = (round($wz_BaoMingLiang/$wz_ShangMenLiang,3)*100).'%';
// $zhuanHuaLi_wz_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($wz_BaoMingLiangAndDinjinLiang/$wz_ShangMenLiang,3)*100).'%';
// $zhuanHuaLi_xq_ZongZiXunToYouXiaoZiXun = (round($xq_YouXiaoZiXun/$xq_ZongZiXun,3)*100).'%';
// $zhuanHuaLi_xq_YouXiaoZiXunToShangMenLiang = (round($xq_ShangMenLiang/$xq_YouXiaoZiXun,3)*100).'%';
// $zhuanHuaLi_xq_ShangMenLiangToBaoMingLiang = (round($xq_BaoMingLiang/$xq_ShangMenLiang,3)*100).'%';
// $zhuanHuaLi_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($xq_BaoMingLiangAndDinjinLiang/$xq_ShangMenLiang,3)*100).'%';
//
//
//   $resultArr=compact('totalXiaoFei','totalZongZiXun','totalYouXiaoZiXun','totalShangMenLiang','totalBaoMingLiang',
//                         'totalDinjinLiang','chengBenZongZiXun','chengBenYouXiaoZiXun','chengBenShangMenLiang',
//                         'chengBaoMingLiang','chengBaoMingLiangJiaDinJingLiang','zhuanHuaLiZongZiXunToYouXiaoZiXun',
//                         'zhuanHuaLiYouXiaoZiXunToShangMenLiang','zhuanHuaLiShangMenLiangToBaoMingLiang',
//                      'zhuanHuaLiShangMenLiangToBaoMingLiangJiaDinJingLiang',
//                   'wz_xq_ZongXiaoFei','wz_xq_ZongZiXun','wz_xq_YouXiaoZiXun','wz_xq_ShangMenLiang','wz_xq_BaoMingLiang',
//                         'wz_xq_DinjinLiang','chengBen_wz_xq_ZongZiXun','chengBen_wz_xq_YouXiaoZiXun','chengBen_wz_xq_ShangMenLiang',
//                         'cheng_wz_xq_BaoMingLiang','cheng_wz_xq_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_wz_xq_ZongZiXunToYouXiaoZiXun',
//                         'zhuanHuaLi_wz_xq_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiang',
//                         'zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang',
//                      'hd_ZongXiaoFei','hd_ZongZiXun','hd_YouXiaoZiXun','hd_ShangMenLiang','hd_BaoMingLiang',
//                         'hd_DinjinLiang','chengBen_hd_ZongZiXun','chengBen_hd_YouXiaoZiXun','chengBen_hd_ShangMenLiang',
//                         'cheng_hd_BaoMingLiang','cheng_hd_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_hd_ZongZiXunToYouXiaoZiXun',
//                         'zhuanHuaLi_hd_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_hd_ShangMenLiangToBaoMingLiang',
//                         'zhuanHuaLi_hd_ShangMenLiangToBaoMingLiangJiaDinJingLiang',
//                'wz_ZongXiaoFei','wz_ZongZiXun','wz_YouXiaoZiXun','wz_ShangMenLiang','wz_BaoMingLiang',
//                   'wz_DinjinLiang','chengBen_wz_ZongZiXun','chengBen_wz_YouXiaoZiXun','chengBen_wz_ShangMenLiang',
//                   'cheng_wz_BaoMingLiang','cheng_wz_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_wz_ZongZiXunToYouXiaoZiXun',
//                   'zhuanHuaLi_wz_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_wz_ShangMenLiangToBaoMingLiang',
//                   'zhuanHuaLi_wz_ShangMenLiangToBaoMingLiangJiaDinJingLiang',
//                'xq_ZongXiaoFei','xq_ZongZiXun','xq_YouXiaoZiXun','xq_ShangMenLiang','xq_BaoMingLiang',
//                   'xq_DinjinLiang','chengBen_xq_ZongZiXun','chengBen_xq_YouXiaoZiXun','chengBen_xq_ShangMenLiang',
//                   'cheng_xq_BaoMingLiang','cheng_xq_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_xq_ZongZiXunToYouXiaoZiXun',
//                   'zhuanHuaLi_xq_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_xq_ShangMenLiangToBaoMingLiang',
//                   'zhuanHuaLi_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang'
//   );
//   return $resultArr;
//}
function _getOneMonthTongjiInfo($calcYMDStart,$calcYMDEnd='')
{
  //框架户账面消费的计算方式 是  >=2016-03-01 时 比率是 1.3
  // < 2016-03-01 时 比率是 1.25
  $sql = "SELECT
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_szfzxx_xiaofei_value) as total_wz_baidu_szfzxx_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_400_xiaofei_value) as total_wz_baidu_400_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_szfzxx_jy_xiaofei_value) as total_wz_baidu_szfzxx_jy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_400_jy_xiaofei_value) as total_wz_baidu_400_jy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_wm_szfzxx_xiaofei_value) as total_wz_baidu_wm_szfzxx_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_wm_400_xiaofei_value) as total_wz_baidu_wm_400_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_400_kjh_sj_xiaofei_value )
as total_wz_baidu_400_kjh_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_400_kjh_wm_sj_xiaofei_value)
as total_wz_baidu_400_kjh_wm_xiaofei_value,

sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_sougou_wzfzxx_xiaofei_value) as total_wz_sougou_wzfzxx_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_sousou_szfzxx_xiaofei_value) as total_wz_sousou_szfzxx_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_sousou_400_xiaofei_value) as total_wz_sousou_400_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_360_szfzxx_xiaofei_value) as total_wz_360_szfzxx_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_360_400_xiaofei_value) as total_wz_360_400_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_wz_sm_sj_sj_xiaofei_value)
as total_wz_sm_sj_sj_xiaofei_value,

sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_ukart_xiaofei_value) as total_xq_baidu_ukart_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_adbxy_jy_xiaofei_value) as total_xq_baidu_adbxy_jy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_wm_adbxy_xiaofei_value) as total_xq_baidu_wm_adbxy_xiaofei_value,
sum( node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_adbxy_kjh_sj_xiaofei_value)
as total_xq_baidu_adbxy_kjh_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_adbxy_kjh_wm_sj_xiaofei_value)
as total_xq_baidu_adbxy_kjh_wm_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_sougou_adbxy_xiaofei_value) as total_xq_sougou_adbxy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_360_ukart_xiaofei_value) as total_xq_360_ukart_xiaofei_value,

sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_hdfzxy_xiaofei_value) as total_hd_baidu_hdfzxy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_baidu_hdfzxy_jy_xiaofei_value) as total_hd_baidu_hdfzxy_jy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_hdfzxy_kjh_sj_xiaofei_value )
as total_hd_baidu_hdfzxy_kjh_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_sougou_huadon_xiaofei_value) as total_hd_sougou_huadon_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_360_fzpxxy_xiaofei_value) as total_hd_360_fzpxxy_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_xq_sm_kjh_sj_sj_xiaofei_value)
as total_xq_sm_kjh_sj_sj_xiaofei_value,
sum(node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.field_hd_sm_kjh_sj_sj_xiaofei_value)
as total_hd_sm_kjh_sj_sj_xiaofei_value,

sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_wz_zzx_value) AS total_kf_wz_zzx_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_wz_yxzx_value) AS total_kf_wz_yxzx_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_xq_zzx.field_kf_xq_zzx_value) AS  total_kf_xq_zzx_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_xq_yxzx.field_kf_xq_yxzx_value) AS  total_kf_xq_yxzx_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_hd_zzx_value) AS total_kf_hd_zzx_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_hd_yxzx_value) AS total_kf_hd_yxzx_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_wz_shanmenliang_value) AS total_kf_wz_shanmenliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_wz_baomingliang_value) AS total_kf_wz_baomingliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_wz_dinjinliang_value) AS total_kf_wz_dinjinliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_xq_shanmenliang_value) AS total_kf_xq_shanmenliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_xq_baomingliang_value) AS total_kf_xq_baomingliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_xq_dinjinliang_value) AS total_kf_xq_dinjinliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_hd_shanmenliang_value) AS total_kf_hd_shanmenliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_hd_baomingliang_value) AS total_kf_hd_baomingliang_value,
sum(node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.field_kf_hd_dinjinliang_value) AS total_kf_hd_dinjinliang_value

FROM node node  LEFT JOIN content_type_timezongtype node_data_field_seozong ON node.vid = node_data_field_seozong.vid LEFT JOIN node node_node_data_field_seozong ON node_data_field_seozong.field_seozong_nid = node_node_data_field_seozong.nid LEFT JOIN content_type_timezongtype node_data_field_kfzhong ON node.vid = node_data_field_kfzhong.vid LEFT JOIN node node_node_data_field_kfzhong ON node_data_field_kfzhong.field_kfzhong_nid = node_node_data_field_kfzhong.nid LEFT JOIN content_type_timezongtype node_data_field_jingjiazong ON node.vid = node_data_field_jingjiazong.vid LEFT JOIN node node_node_data_field_jingjiazong ON node_data_field_jingjiazong.field_jingjiazong_nid = node_node_data_field_jingjiazong.nid LEFT JOIN content_field_zong_time node_data_field_zong_time ON node.vid = node_data_field_zong_time.vid LEFT JOIN content_type_jingjiazongbiaotype node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei ON node_node_data_field_jingjiazong.vid = node_node_data_field_jingjiazong_node_data_field_baidu_szfzxx_xiaofei.vid LEFT JOIN content_type_kefuzongbiaotype node_node_data_field_kfzhong_node_data_field_kf_wz_zzx ON node_node_data_field_kfzhong.vid = node_node_data_field_kfzhong_node_data_field_kf_wz_zzx.vid LEFT JOIN content_field_kf_xq_zzx node_node_data_field_kfzhong_node_data_field_kf_xq_zzx ON node_node_data_field_kfzhong.vid = node_node_data_field_kfzhong_node_data_field_kf_xq_zzx.vid LEFT JOIN content_field_kf_xq_yxzx node_node_data_field_kfzhong_node_data_field_kf_xq_yxzx ON node_node_data_field_kfzhong.vid = node_node_data_field_kfzhong_node_data_field_kf_xq_yxzx.vid WHERE (node.type in ('timezongtype')) AND (node_data_field_zong_time.field_zong_time_value >= '".$calcYMDStart."')  AND (node_data_field_zong_time.field_zong_time_value <= '".$calcYMDEnd."')";
  $result = db_query($sql);
  $arrFormResult = db_fetch_array($result);

  $wz_ZongXiaoFei = $arrFormResult['total_wz_baidu_szfzxx_xiaofei_value']
     +$arrFormResult['total_wz_baidu_400_xiaofei_value']
     +$arrFormResult['total_wz_baidu_szfzxx_jy_xiaofei_value']
     +$arrFormResult['total_wz_baidu_400_jy_xiaofei_value']
     +$arrFormResult['total_wz_baidu_wm_szfzxx_xiaofei_value']
     +$arrFormResult['total_wz_baidu_szfzxx_xiaofei_value']
     +$arrFormResult['total_wz_baidu_wm_400_xiaofei_value']
     +$arrFormResult['total_wz_baidu_400_kjh_xiaofei_value']
     +$arrFormResult['total_wz_baidu_400_kjh_wm_xiaofei_value']

     +$arrFormResult['total_wz_sougou_wzfzxx_xiaofei_value']
     +$arrFormResult['total_wz_sousou_szfzxx_xiaofei_value']
     +$arrFormResult['total_wz_sousou_400_xiaofei_value']

     +$arrFormResult['total_wz_360_szfzxx_xiaofei_value']
     +$arrFormResult['total_wz_360_400_xiaofei_value']

     +$arrFormResult['total_wz_sm_sj_sj_xiaofei_value'];

  $xq_ZongXiaoFei =  $arrFormResult['total_xq_baidu_ukart_xiaofei_value']
     +$arrFormResult['total_xq_baidu_wm_adbxy_xiaofei_value']
     +$arrFormResult['total_xq_baidu_adbxy_jy_xiaofei_value']
     +$arrFormResult['total_xq_baidu_adbxy_kjh_xiaofei_value']
     +$arrFormResult['total_xq_baidu_adbxy_kjh_wm_xiaofei_value']

     +$arrFormResult['total_xq_sougou_adbxy_xiaofei_value']

     +$arrFormResult['total_xq_360_ukart_xiaofei_value']
     +$arrFormResult['total_xq_sm_kjh_sj_sj_xiaofei_value'];;

  $hd_ZongXiaoFei =  $arrFormResult['total_hd_baidu_hdfzxy_xiaofei_value']
     +$arrFormResult['total_hd_baidu_hdfzxy_jy_xiaofei_value']
     +$arrFormResult['total_hd_baidu_hdfzxy_kjh_xiaofei_value']

     +$arrFormResult['total_hd_sougou_huadon_xiaofei_value']

     +$arrFormResult['total_hd_360_fzpxxy_xiaofei_value']

     +$arrFormResult['total_hd_sm_kjh_sj_sj_xiaofei_value'];

  //吴中的七个数据
  //第一个是吴中总消费 上面已经取到了
  $wz_ZongXiaoFei = round($wz_ZongXiaoFei,3);
  $wz_ZongZiXun = $arrFormResult['total_kf_wz_zzx_value'];
  $wz_YouXiaoZiXun = $arrFormResult['total_kf_wz_yxzx_value'];
  $wz_ShangMenLiang = $arrFormResult['total_kf_wz_shanmenliang_value'];
  $wz_BaoMingLiang = $arrFormResult['total_kf_wz_baomingliang_value'];
  $wz_DinjinLiang = $arrFormResult['total_kf_wz_dinjinliang_value'];
  $wz_BaoMingLiangAndDinjinLiang = $wz_BaoMingLiang+$wz_DinjinLiang;

  //新区的七个数据
  //第一个是新区总消费 上面已经取到了
  $xq_ZongXiaoFei = round($xq_ZongXiaoFei,3);

  $xq_ZongZiXun = $arrFormResult['total_kf_xq_zzx_value'];
  $xq_YouXiaoZiXun = $arrFormResult['total_kf_xq_yxzx_value'];
  $xq_ShangMenLiang = $arrFormResult['total_kf_xq_shanmenliang_value'];
  $xq_BaoMingLiang = $arrFormResult['total_kf_xq_baomingliang_value'];
  $xq_DinjinLiang = $arrFormResult['total_kf_xq_dinjinliang_value'];
  $xq_BaoMingLiangAndDinjinLiang = $xq_BaoMingLiang+$xq_DinjinLiang;


  //吴中加新区的七个数据  新区加吴中的消费就是拿总消费减去 华东的三个消费
  $wz_xq_ZongXiaoFei = $wz_ZongXiaoFei+$xq_ZongXiaoFei;
  $wz_xq_ZongZiXun = $wz_ZongZiXun+$xq_ZongZiXun;
  $wz_xq_YouXiaoZiXun = $wz_YouXiaoZiXun+$xq_YouXiaoZiXun;
  $wz_xq_ShangMenLiang = $wz_ShangMenLiang+$xq_ShangMenLiang;
  $wz_xq_BaoMingLiang = $wz_BaoMingLiang+$xq_BaoMingLiang;
  $wz_xq_DinjinLiang = $wz_DinjinLiang+$xq_DinjinLiang;
  $wz_xq_BaoMingLiangAndDinjinLiang = $wz_BaoMingLiangAndDinjinLiang+$xq_BaoMingLiangAndDinjinLiang;

  //华东咨询的七个数据
  //第一个是华东总消费 上面已经取到了
  $hd_ZongXiaoFei = round($hd_ZongXiaoFei,3);
  $hd_ZongZiXun = $arrFormResult['total_kf_hd_zzx_value'];
  $hd_YouXiaoZiXun = $arrFormResult['total_kf_hd_yxzx_value'];
  $hd_ShangMenLiang = $arrFormResult['total_kf_hd_shanmenliang_value'];
  $hd_BaoMingLiang = $arrFormResult['total_kf_hd_baomingliang_value'];
  $hd_DinjinLiang = $arrFormResult['total_kf_hd_dinjinliang_value'];
  $hd_BaoMingLiangAndDinjinLiang = $hd_BaoMingLiang+$hd_DinjinLiang;

//  var_dump($wz_ZongXiaoFei);
//  var_dump($xq_ZongXiaoFei);
//  var_dump($hd_ZongXiaoFei);
  //吴中  + 华东 + 新区
  $totalXiaoFei = $wz_ZongXiaoFei+$xq_ZongXiaoFei+$hd_ZongXiaoFei;
  $totalZongZiXun = $wz_ZongZiXun+$xq_ZongZiXun+$hd_ZongZiXun;
  $totalYouXiaoZiXun =$wz_YouXiaoZiXun+$xq_YouXiaoZiXun+$hd_YouXiaoZiXun;
  $totalShangMenLiang = $wz_ShangMenLiang+$xq_ShangMenLiang+$hd_ShangMenLiang;
  $totalBaoMingLiang = $wz_BaoMingLiang+$xq_BaoMingLiang+$hd_BaoMingLiang;
  $totalDinjinLiang =$wz_DinjinLiang+$xq_DinjinLiang+$hd_DinjinLiang;
  $totalBaoMingLiangAndDinjinLiang = $totalBaoMingLiang+$totalDinjinLiang;

  //下面是各项成本
  $chengBenZongZiXun = round($totalXiaoFei/$totalZongZiXun,3);
  $chengBenYouXiaoZiXun = round($totalXiaoFei/$totalYouXiaoZiXun,3);
  $chengBenShangMenLiang = round($totalXiaoFei/$totalShangMenLiang,3);
  $chengBaoMingLiang = round($totalXiaoFei/$totalBaoMingLiang,3);
  $chengBaoMingLiangJiaDinJingLiang = round($totalXiaoFei/($totalBaoMingLiangAndDinjinLiang),3);

  $chengBen_wz_xq_ZongZiXun = round($wz_xq_ZongXiaoFei/$wz_xq_ZongZiXun,3);
  $chengBen_wz_xq_YouXiaoZiXun = round($wz_xq_ZongXiaoFei/$wz_xq_YouXiaoZiXun,3);
  $chengBen_wz_xq_ShangMenLiang = round($wz_xq_ZongXiaoFei/$wz_xq_ShangMenLiang,3);
  $cheng_wz_xq_BaoMingLiang = round($wz_xq_ZongXiaoFei/$wz_xq_BaoMingLiang,3);
  $cheng_wz_xq_BaoMingLiangJiaDinJingLiang = round($wz_xq_ZongXiaoFei/$wz_xq_BaoMingLiangAndDinjinLiang,3);
  $chengBen_wz_ZongZiXun = round($wz_ZongXiaoFei/$wz_ZongZiXun,3);
  $chengBen_wz_YouXiaoZiXun = round($wz_ZongXiaoFei/$wz_YouXiaoZiXun,3);
  $chengBen_wz_ShangMenLiang = round($wz_ZongXiaoFei/$wz_ShangMenLiang,3);
  $cheng_wz_BaoMingLiang = round($wz_ZongXiaoFei/$wz_BaoMingLiang,3);
  $cheng_wz_BaoMingLiangJiaDinJingLiang = round($wz_ZongXiaoFei/$wz_BaoMingLiangAndDinjinLiang,3);
  $chengBen_xq_ZongZiXun = round($xq_ZongXiaoFei/$xq_ZongZiXun,3);
  $chengBen_xq_YouXiaoZiXun = round($xq_ZongXiaoFei/$xq_YouXiaoZiXun,3);
  $chengBen_xq_ShangMenLiang = round($xq_ZongXiaoFei/$xq_ShangMenLiang,3);
  $cheng_xq_BaoMingLiang = round($xq_ZongXiaoFei/$xq_BaoMingLiang,3);
  $cheng_xq_BaoMingLiangJiaDinJingLiang = round($xq_ZongXiaoFei/$xq_BaoMingLiangAndDinjinLiang,3);

  $chengBen_hd_ZongZiXun = round($hd_ZongXiaoFei/$hd_ZongZiXun,3);
  $chengBen_hd_YouXiaoZiXun = round($hd_ZongXiaoFei/$hd_YouXiaoZiXun,3);
  $chengBen_hd_ShangMenLiang = round($hd_ZongXiaoFei/$hd_ShangMenLiang,3);
  $cheng_hd_BaoMingLiang = round($hd_ZongXiaoFei/$hd_BaoMingLiang,3);
  $cheng_hd_BaoMingLiangJiaDinJingLiang = round($hd_ZongXiaoFei/$hd_BaoMingLiangAndDinjinLiang,3);


  //下面是各项转化率
  $zhuanHuaLiZongZiXunToYouXiaoZiXun = (round($totalYouXiaoZiXun/$totalZongZiXun,3)*100).'%';
  $zhuanHuaLiYouXiaoZiXunToShangMenLiang = (round($totalShangMenLiang/$totalYouXiaoZiXun,3)*100).'%';
  $zhuanHuaLiShangMenLiangToBaoMingLiang = (round($totalBaoMingLiang/$totalShangMenLiang,3)*100).'%';
  $zhuanHuaLiShangMenLiangToBaoMingLiangJiaDinJingLiang = (round(($totalBaoMingLiangAndDinjinLiang)/$totalShangMenLiang,3)*100).'%';

  $zhuanHuaLi_wz_xq_ZongZiXunToYouXiaoZiXun = (round($wz_xq_YouXiaoZiXun/$wz_xq_ZongZiXun,3)*100).'%';
  $zhuanHuaLi_wz_xq_YouXiaoZiXunToShangMenLiang = (round($wz_xq_ShangMenLiang/$wz_xq_YouXiaoZiXun,3)*100).'%';
  $zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiang = (round($wz_xq_BaoMingLiang/$wz_xq_ShangMenLiang,3)*100).'%';
  $zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($wz_xq_BaoMingLiangAndDinjinLiang/$wz_xq_ShangMenLiang,3)*100).'%';

  $zhuanHuaLi_hd_ZongZiXunToYouXiaoZiXun = (round($hd_YouXiaoZiXun/$hd_ZongZiXun,3)*100).'%';
  $zhuanHuaLi_hd_YouXiaoZiXunToShangMenLiang = (round($hd_ShangMenLiang/$hd_YouXiaoZiXun,3)*100).'%';
  $zhuanHuaLi_hd_ShangMenLiangToBaoMingLiang = (round($hd_BaoMingLiang/$hd_ShangMenLiang,3)*100).'%';
  $zhuanHuaLi_hd_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($hd_BaoMingLiangAndDinjinLiang/$hd_ShangMenLiang,3)*100).'%';
  $zhuanHuaLi_wz_ZongZiXunToYouXiaoZiXun = (round($wz_YouXiaoZiXun/$wz_ZongZiXun,3)*100).'%';
  $zhuanHuaLi_wz_YouXiaoZiXunToShangMenLiang = (round($wz_ShangMenLiang/$wz_YouXiaoZiXun,3)*100).'%';
  $zhuanHuaLi_wz_ShangMenLiangToBaoMingLiang = (round($wz_BaoMingLiang/$wz_ShangMenLiang,3)*100).'%';
  $zhuanHuaLi_wz_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($wz_BaoMingLiangAndDinjinLiang/$wz_ShangMenLiang,3)*100).'%';
  $zhuanHuaLi_xq_ZongZiXunToYouXiaoZiXun = (round($xq_YouXiaoZiXun/$xq_ZongZiXun,3)*100).'%';
  $zhuanHuaLi_xq_YouXiaoZiXunToShangMenLiang = (round($xq_ShangMenLiang/$xq_YouXiaoZiXun,3)*100).'%';
  $zhuanHuaLi_xq_ShangMenLiangToBaoMingLiang = (round($xq_BaoMingLiang/$xq_ShangMenLiang,3)*100).'%';
  $zhuanHuaLi_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang = (round($xq_BaoMingLiangAndDinjinLiang/$xq_ShangMenLiang,3)*100).'%';


  $resultArr=compact('totalXiaoFei','totalZongZiXun','totalYouXiaoZiXun','totalShangMenLiang','totalBaoMingLiang',
     'totalDinjinLiang','chengBenZongZiXun','chengBenYouXiaoZiXun','chengBenShangMenLiang',
     'chengBaoMingLiang','chengBaoMingLiangJiaDinJingLiang','zhuanHuaLiZongZiXunToYouXiaoZiXun',
     'zhuanHuaLiYouXiaoZiXunToShangMenLiang','zhuanHuaLiShangMenLiangToBaoMingLiang',
     'zhuanHuaLiShangMenLiangToBaoMingLiangJiaDinJingLiang',
     'wz_xq_ZongXiaoFei','wz_xq_ZongZiXun','wz_xq_YouXiaoZiXun','wz_xq_ShangMenLiang','wz_xq_BaoMingLiang',
     'wz_xq_DinjinLiang','chengBen_wz_xq_ZongZiXun','chengBen_wz_xq_YouXiaoZiXun','chengBen_wz_xq_ShangMenLiang',
     'cheng_wz_xq_BaoMingLiang','cheng_wz_xq_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_wz_xq_ZongZiXunToYouXiaoZiXun',
     'zhuanHuaLi_wz_xq_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiang',
     'zhuanHuaLi_wz_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang',
     'hd_ZongXiaoFei','hd_ZongZiXun','hd_YouXiaoZiXun','hd_ShangMenLiang','hd_BaoMingLiang',
     'hd_DinjinLiang','chengBen_hd_ZongZiXun','chengBen_hd_YouXiaoZiXun','chengBen_hd_ShangMenLiang',
     'cheng_hd_BaoMingLiang','cheng_hd_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_hd_ZongZiXunToYouXiaoZiXun',
     'zhuanHuaLi_hd_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_hd_ShangMenLiangToBaoMingLiang',
     'zhuanHuaLi_hd_ShangMenLiangToBaoMingLiangJiaDinJingLiang',
     'wz_ZongXiaoFei','wz_ZongZiXun','wz_YouXiaoZiXun','wz_ShangMenLiang','wz_BaoMingLiang',
     'wz_DinjinLiang','chengBen_wz_ZongZiXun','chengBen_wz_YouXiaoZiXun','chengBen_wz_ShangMenLiang',
     'cheng_wz_BaoMingLiang','cheng_wz_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_wz_ZongZiXunToYouXiaoZiXun',
     'zhuanHuaLi_wz_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_wz_ShangMenLiangToBaoMingLiang',
     'zhuanHuaLi_wz_ShangMenLiangToBaoMingLiangJiaDinJingLiang',
     'xq_ZongXiaoFei','xq_ZongZiXun','xq_YouXiaoZiXun','xq_ShangMenLiang','xq_BaoMingLiang',
     'xq_DinjinLiang','chengBen_xq_ZongZiXun','chengBen_xq_YouXiaoZiXun','chengBen_xq_ShangMenLiang',
     'cheng_xq_BaoMingLiang','cheng_xq_BaoMingLiangJiaDinJingLiang','zhuanHuaLi_xq_ZongZiXunToYouXiaoZiXun',
     'zhuanHuaLi_xq_YouXiaoZiXunToShangMenLiang','zhuanHuaLi_xq_ShangMenLiangToBaoMingLiang',
     'zhuanHuaLi_xq_ShangMenLiangToBaoMingLiangJiaDinJingLiang'
  );
  return $resultArr;


}
function _calcLastMonth($calcYMDStart)
{
  return date("Y-m-d", mktime(0, 0, 0, date("n", strtotime($calcYMDStart)) - 1, date("j", strtotime($calcYMDStart)), date("Y", strtotime($calcYMDStart))));
}
//近7天
function _calcJingOneWeek($calcYMDStart){
  return  date("Y-m-d",(strtotime($calcYMDStart)-6*24*60*60));
}
//近一个月
function _calcJingOneMonth($calcYMDStart){
  return  date("Y-m-d",(strtotime($calcYMDStart)-30*24*60*60));
}
//上一年的这一天
function _calcLastYear($calcYMDStart)
{
  //这个是上一年的这一天
  $lastCalcYMD =  date("Y-m-d", mktime(0, 0, 0, date("n", strtotime($calcYMDStart)), date("j", strtotime($calcYMDStart)), date("Y", strtotime($calcYMDStart))-1));
  return $lastCalcYMD;
// //这里再加11天 +11*24*60*60
// return date('Y-m-d',strtotime($lastCalcYMD)+11*24*60*60);

  //这是上一年的下一个月 再减去10天
// $lastCalcYMD =  date("Y-m-d", mktime(0, 0, 0, date("n", strtotime($calcYMDStart))+1, date("j", strtotime($calcYMDStart))-10, date("Y", strtotime($calcYMDStart))-1));
//
// return $lastCalcYMD;
}
function _getKeFuInfo($username,$calcYMDStart,$calcYMDEnd,$zixundiqu='')
{

  //先减8小时 以期与默认时区的时间吻合
  $calcYMDStartTime = strtotime($calcYMDStart)-8*60*60;
  $calcYMDStart = date('Y-m-d H:i:s',$calcYMDStartTime);

  $calcYMDEndTime = strtotime($calcYMDEnd)-8*60*60;
  $calcYMDEnd = date('Y-m-d H:i:s',$calcYMDEndTime);
  if(!empty($zixundiqu)){
     $zixundiqu_part_fisrt =" LEFT JOIN content_type_kefuchat node_data_field_suozaixiaoqu_value ON node.vid = node_data_field_suozaixiaoqu_value.vid AND node_data_field_suozaixiaoqu_value.field_suozaixiaoqu_value = '".$zixundiqu."' ";
     $zixundiqu_part_second = "  AND (node_data_field_suozaixiaoqu_value.field_suozaixiaoqu_value = '".$zixundiqu."') ";
  }else{
     $zixundiqu_part_fisrt = "";
     $zixundiqu_part_second = "";
  }

  //总咨询
  $sql = "SELECT count(node.nid) as cou FROM node node  LEFT JOIN content_field_time
   node_data_field_time ON node.vid = node_data_field_time.vid LEFT JOIN content_type_kefuchat
   node_data_field_xueshenname ON node.vid = node_data_field_xueshenname.vid LEFT JOIN
   content_field_xueyuan_qq node_data_field_xueyuan_qq ON node.vid = node_data_field_xueyuan_qq.vid
   LEFT JOIN content_field_tel node_data_field_tel ON node.vid = node_data_field_tel.vid INNER JOIN users
   users ON node.uid = users.uid LEFT JOIN content_field_yixiangzhuanye node_data_field_yixiangzhuanye
   ON node.vid = node_data_field_yixiangzhuanye.vid LEFT JOIN node_revisions node_revisions
   ON node.vid = node_revisions.vid ".$zixundiqu_part_fisrt." WHERE
  (node_data_field_time.field_time_value >='".$calcYMDStart."') and (node_data_field_time.field_time_value <='".$calcYMDEnd."') and
  (((users.name) = ('".$username."')) AND (node.type in ('kefuchat'))) ".$zixundiqu_part_second;
  $zongZiXunLiang = db_result(db_query($sql));
  empty($zongZiXunLiang) && $zongZiXunLiang = 0;



//有效咨询
  $sql = " SELECT  count(node.nid) as cou  FROM node node  LEFT JOIN content_field_time
   node_data_field_time ON node.vid = node_data_field_time.vid LEFT JOIN content_type_kefuchat
   node_data_field_xueshenname ON node.vid = node_data_field_xueshenname.vid LEFT JOIN
   content_field_xueyuan_qq node_data_field_xueyuan_qq ON node.vid = node_data_field_xueyuan_qq.vid
   LEFT JOIN content_field_tel node_data_field_tel ON node.vid = node_data_field_tel.vid INNER JOIN
   users users ON node.uid = users.uid INNER JOIN content_type_kefuchat node_data_field_chat_status ON
   node.vid = node_data_field_chat_status.vid LEFT JOIN content_field_yixiangzhuanye
   node_data_field_yixiangzhuanye ON node.vid = node_data_field_yixiangzhuanye.vid LEFT JOIN
   node_revisions node_revisions ON node.vid = node_revisions.vid ".$zixundiqu_part_fisrt." WHERE
  (node_data_field_time.field_time_value >='".$calcYMDStart."') and (node_data_field_time.field_time_value <='".$calcYMDEnd."')
   AND (((users.name) LIKE ('".$username."')) AND (node_data_field_chat_status.field_chat_status_value = 'complete')
   AND (node.type in ('kefuchat'))) ".$zixundiqu_part_second;
  $youXiaoZiXunLiang = db_result(db_query($sql));
  empty($youXiaoZiXunLiang) && $youXiaoZiXunLiang = 0;

  //上门量
  $sql = "SELECT count(node.nid) as cou  FROM node node  LEFT JOIN content_field_shangmeng_time
   node_data_field_shangmeng_time ON node.vid = node_data_field_shangmeng_time.vid LEFT JOIN content_type_kefuchat
   node_data_field_xueshenname ON node.vid = node_data_field_xueshenname.vid LEFT JOIN
   content_field_xueyuan_qq node_data_field_xueyuan_qq ON node.vid = node_data_field_xueyuan_qq.vid LEFT
   JOIN content_field_tel node_data_field_tel ON node.vid = node_data_field_tel.vid INNER JOIN users users
   ON node.uid = users.uid INNER JOIN content_field_is_shangmen node_data_field_is_shangmen ON
   node.vid = node_data_field_is_shangmen.vid LEFT JOIN content_field_yixiangzhuanye node_data_field_yixiangzhuanye ON
   node.vid = node_data_field_yixiangzhuanye.vid LEFT JOIN node_revisions
   node_revisions ON node.vid = node_revisions.vid INNER JOIN content_type_kefuchat node_data_field_chat_status ON
   node.vid = node_data_field_chat_status.vid ".$zixundiqu_part_fisrt." WHERE
   (node_data_field_shangmeng_time.field_shangmeng_time_value >='".$calcYMDStart."') and (node_data_field_shangmeng_time.field_shangmeng_time_value <='".$calcYMDEnd."')
   AND (((users.name) LIKE ('".$username."')))
   AND (node_data_field_is_shangmen.field_is_shangmen_value = '是')  AND (node.type in ('kefuchat')) ".$zixundiqu_part_second;
  // AND (node_data_field_chat_status.field_chat_status_value = 'complete') 把这个是否有效去掉
  $shangMenLiang = db_result(db_query($sql));
  empty($shangMenLiang) && $shangMenLiang=0;
  $zongZiXunToYouXiaoZiXun = !empty($zongZiXunLiang)? (round($youXiaoZiXunLiang/$zongZiXunLiang,3)*100).'%':'0%';
  $youXiaoZiXunToShangMenLiang = !empty($youXiaoZiXunLiang)? (round($shangMenLiang/$youXiaoZiXunLiang,3)*100).'%':'0%';
  return compact('zongZiXunLiang','youXiaoZiXunLiang','shangMenLiang','zongZiXunToYouXiaoZiXun','youXiaoZiXunToShangMenLiang');

}






function _getJieDaiInfo($username,$calcYMDStart,$calcYMDEnd)
{

  //先减8小时 以期与默认时区的时间吻合
  $calcYMDStartTime = strtotime($calcYMDStart)-8*60*60;
  $calcYMDStart = date('Y-m-d H:i:s',$calcYMDStartTime);

  $calcYMDEndTime = strtotime($calcYMDEnd)-8*60*60;
  $calcYMDEnd = date('Y-m-d H:i:s',$calcYMDEndTime);


  //下面三个$sql条件 没有加上 有效的 其实  可以加上 ( 不过即然上门了 肯定是有效了)  
  $sql ="SELECT  count(node.nid) as cou FROM node node  LEFT JOIN content_type_kefuchat
   node_data_field_shangmeng_time ON
   node.vid = node_data_field_shangmeng_time.vid LEFT JOIN content_field_xueyuan_qq
   node_data_field_xueyuan_qq
   ON node.vid = node_data_field_xueyuan_qq.vid LEFT JOIN content_field_tel node_data_field_tel
   ON node.vid = node_data_field_tel.vid INNER JOIN users users ON node.uid = users.uid INNER JOIN
   content_type_kefuchat node_data_field_is_shangmen ON
   node.vid = node_data_field_is_shangmen.vid LEFT JOIN
   content_field_time node_data_field_time ON node.vid = node_data_field_time.vid LEFT JOIN
   content_field_yixiangzhuanye node_data_field_yixiangzhuanye ON
   node.vid = node_data_field_yixiangzhuanye.vid
   LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid WHERE
   (node_data_field_shangmeng_time.field_shangmeng_time_value >='".$calcYMDStart."')
   and (node_data_field_shangmeng_time.field_shangmeng_time_value <='".$calcYMDEnd."')    AND
   (((node_data_field_shangmeng_time.field_shangmeng_writer_value) LIKE ('".$username."'))) AND
   (node_data_field_is_shangmen.field_chat_status_value = 'complete') AND
   (node_data_field_is_shangmen.field_is_shangmen_value = '是')  AND (node.type in
   ('kefuchat'))";
  $shangMenLiang = db_result(db_query($sql));
  //下面三个$sql条件 没有加上 有效的 其实  可以加上 ( 不过即然上门并且报名了 肯定是有效了)  
  $sql = "SELECT count(node.nid) as cou FROM node node  LEFT JOIN content_type_kefuchat
   node_data_field_shangmeng_time ON node.vid = node_data_field_shangmeng_time.vid LEFT JOIN
   content_field_xueyuan_qq node_data_field_xueyuan_qq ON
   node.vid = node_data_field_xueyuan_qq.vid LEFT JOIN content_field_tel node_data_field_tel ON
   node.vid = node_data_field_tel.vid INNER JOIN users users ON node.uid = users.uid INNER JOIN
   content_type_kefuchat node_data_field_is_shangmen ON
   node.vid = node_data_field_is_shangmen.vid LEFT JOIN content_field_time node_data_field_time ON
   node.vid = node_data_field_time.vid LEFT JOIN content_field_yixiangzhuanye
   node_data_field_yixiangzhuanye ON node.vid = node_data_field_yixiangzhuanye.vid LEFT JOIN
   node_revisions node_revisions ON node.vid = node_revisions.vid WHERE
   (node_data_field_shangmeng_time.field_shangmeng_time_value >='".$calcYMDStart."')
   and (node_data_field_shangmeng_time.field_shangmeng_time_value <='".$calcYMDEnd."')        AND
   (((node_data_field_shangmeng_time.field_shangmeng_writer_value) LIKE ('".$username."'))) AND
   (node_data_field_is_shangmen.field_chat_status_value = 'complete') AND
   (node_data_field_is_shangmen.field_is_shangmen_value = '是') AND
   (node_data_field_is_shangmen.field_is_baoming_value = '是')   AND
   (node.type in ('kefuchat'))";
  $baoMingLiang = db_result(db_query($sql));
  //下面三个$sql条件 没有加上 有效的 其实  可以加上 ( 不过即然上门并且报名且交定金了 肯定是有效了)
  $sql = "SELECT count(node.nid) as cou FROM node node  LEFT JOIN content_type_kefuchat node_data_field_shangmeng_time ON
   node.vid = node_data_field_shangmeng_time.vid LEFT JOIN content_field_xueyuan_qq node_data_field_xueyuan_qq ON
   node.vid = node_data_field_xueyuan_qq.vid LEFT JOIN content_field_tel node_data_field_tel ON
   node.vid = node_data_field_tel.vid INNER JOIN users users ON node.uid = users.uid INNER JOIN
   content_type_kefuchat node_data_field_is_shangmen ON node.vid = node_data_field_is_shangmen.vid LEFT JOIN
   content_field_time node_data_field_time ON node.vid = node_data_field_time.vid LEFT JOIN
   content_field_yixiangzhuanye node_data_field_yixiangzhuanye ON node.vid = node_data_field_yixiangzhuanye.vid LEFT JOIN
   node_revisions node_revisions ON node.vid = node_revisions.vid WHERE
   (node_data_field_shangmeng_time.field_shangmeng_time_value >='".$calcYMDStart."')
    and (node_data_field_shangmeng_time.field_shangmeng_time_value <='".$calcYMDEnd."')   AND
   (((node_data_field_shangmeng_time.field_shangmeng_writer_value) LIKE ('".$username."'))) AND
   (node_data_field_is_shangmen.field_chat_status_value = 'complete') AND
   (node_data_field_is_shangmen.field_is_shangmen_value = '是')
   AND (node_data_field_is_shangmen.field_is_dingjing_value = '是')  AND
   (node.type in ('kefuchat'))";
  $dingJingLiang = db_result(db_query($sql));
  $baoMingLiangJiaDingJingLiang = floatval($baoMingLiang)+floatval($dingJingLiang);
  $shangMenLiangToBaoMingLiang = !empty($shangMenLiang)? (round($baoMingLiang/$shangMenLiang,3)*100).'%':'0%';
  $shangMenLiangToBaoMingLiangJiaDingJingLiang = !empty($shangMenLiang)? (round($baoMingLiangJiaDingJingLiang/$shangMenLiang,3)*100).'%':'0%';
  return compact('shangMenLiang','baoMingLiang','baoMingLiangJiaDingJingLiang','shangMenLiangToBaoMingLiang','shangMenLiangToBaoMingLiangJiaDingJingLiang');

}
function _setSameValue(&$value, $key, $sameValue)
{
  $value = $sameValue;
}
//由数字公历转换成文字农历
function _getNongli($yearMontDay)
{
  $arrYearMontDay = explode('-',$yearMontDay);
  include_once 'Lunar.class.php';
  $lunar = new Lunar();
  $nongliYearMonthDayArr  = $lunar->convertSolarToLunar($arrYearMontDay[0],$arrYearMontDay[1],$arrYearMontDay[2]); //公历转农历
  return $nongliYearMonthDayArr[0].'年-'.$nongliYearMonthDayArr[1].'-'.$nongliYearMonthDayArr[2];
}
function _get_num_Nongli($yearMontDay)
{
  $arrYearMontDay = explode('-',$yearMontDay);
  include_once 'Lunar.class.php';
  $lunar = new Lunar();
  $nongliYearMonthDayArr  = $lunar->convertSolarToLunar($arrYearMontDay[0],$arrYearMontDay[1],$arrYearMontDay[2]); //公历转农历
  return $nongliYearMonthDayArr[0].'年-'.$nongliYearMonthDayArr[1].'-'.$nongliYearMonthDayArr[2];
}
//由数字农历转换成数字公历
function _get_num_Gongli($yearMontDay)
{
  $arrYearMontDay = explode('-',$yearMontDay);
  include_once 'Lunar.class.php';
  $lunar = new Lunar();
  $gongliYearMonthDayArr  = $lunar->convertLunarToSolar($arrYearMontDay[0],$arrYearMontDay[1],$arrYearMontDay[2]); //公历转农历
  return $gongliYearMonthDayArr[0].'-'.$gongliYearMonthDayArr[1].'-'.$gongliYearMonthDayArr[2];
}
function _xiangjia($value1,$value2){
  return intval($value1)+intval($value2);
}
function _getMonthTongjiInfo()
{
  global $onlyIndexTonjingFilter;
  $onlyIndexTonjingFilter = true;

  if(!($_GET['form_id']=='select_date_query_tongji_nl_form' && (!empty($_GET['date_start']['date'])) && (!empty($_GET['date_end']['date'])))) {
     //开始就是8日
     $calcYMDStart = _getCalcStartYMD();
     //结束就是前一天
     $calcYMDEnd = _getCalcEndYMD();

     $postYMDStart = $_GET['date_start']['date'];
     $postYMDEnd = $_GET['date_end']['date'];

     if (!empty($postYMDStart)) {
        $calcYMDStart = $postYMDStart;
     }

     if (!empty($postYMDEnd)) {
        $calcYMDEnd = $postYMDEnd;
     }
  }else{
     $postYMDStart_nl = $_GET['date_start']['date'];
     $calcYMDEnd_nl =  $_GET['date_end']['date'];
     $calcYMDStart = _get_num_Gongli($postYMDStart_nl);
     $calcYMDEnd = _get_num_Gongli($calcYMDEnd_nl);

  }


  $thisMonthArr = _getOneMonthTongjiInfo($calcYMDStart,$calcYMDEnd);
  if(!($_GET['form_id']=='select_date_query_tongji_nl_form' && (!empty($_GET['date_start']['date'])) && (!empty($_GET['date_end']['date'])))) {
     $calcYMDLastMonthStart = _calcLastMonth($calcYMDStart);
     //结束应该是前一天
     $calcYMDLastMonthEnd = _calcLastMonth($calcYMDEnd);
  }else{
     $calcYMDLastMonthStart_nl = _calcLastMonth($postYMDStart_nl);
     //结束应该是前一天
     $calcYMDLastMonthEnd_nl = _calcLastMonth($calcYMDEnd_nl);


     $calcYMDLastMonthStart = _get_num_Gongli($calcYMDLastMonthStart_nl);
     //结束应该是前一天
     $calcYMDLastMonthEnd = _get_num_Gongli($calcYMDLastMonthEnd_nl);

  }

  $lastMonthArr = _getOneMonthTongjiInfo($calcYMDLastMonthStart,$calcYMDLastMonthEnd);


  if(!($_GET['form_id']=='select_date_query_tongji_nl_form' && (!empty($_GET['date_start']['date'])) && (!empty($_GET['date_end']['date'])))) {
     //开始应该是前一年的这一天 再加四天 现在是加11天 +11*24*60*60
     //$calcYMDLastYearStart = _calcLastYear(date('Y-m-d',strtotime($calcYMDStart)+11*24*60*60));
     //开始应该是前一年的这一天
     $calcYMDLastYearStart = _calcLastYear(date('Y-m-d',strtotime($calcYMDStart)));
     //结束应该是前一年的这一天  再加四天  现在是加11天 +11*24*60*60
     //$calcYMDLastYearEnd = _calcLastYear(date('Y-m-d',strtotime($calcYMDEnd)+11*24*60*60));
     $calcYMDLastYearEnd = _calcLastYear(date('Y-m-d',strtotime($calcYMDEnd)));
  }else{
     $calcYMDLastYearStart_nl =_calcLastYear(date('Y-m-d',strtotime($postYMDStart_nl)));
     $calcYMDLastYearEnd_nl = _calcLastYear(date('Y-m-d',strtotime($calcYMDEnd_nl)));
     $calcYMDLastYearStart = _get_num_Gongli($calcYMDLastYearStart_nl);
     $calcYMDLastYearEnd = _get_num_Gongli($calcYMDLastYearEnd_nl);
  }


  $lastYearArr = _getOneMonthTongjiInfo($calcYMDLastYearStart,$calcYMDLastYearEnd);
  $yearMonthDay = $calcYMDStart.' 至 '.$calcYMDEnd;
  $lastYearYearMonthDay = $calcYMDLastYearStart.' 至 '.$calcYMDLastYearEnd;

  //得到昨天的年月日
  $yesterDayYmd =_getCalcEndYMD();
  //昨天明细日期
  $mingxiCalcYMDEnd  = $mingxiCalcYMDStart = $yesterDayYmd;
  $postYMDStartMx = $_GET['date_start_mx']['date'];
  $postYMDEndMx = $_GET['date_end_mx']['date'];
  if(!empty($postYMDStartMx)){
     $mingxiCalcYMDStart = $postYMDStartMx;
  }
  if(!empty($postYMDEndMx)){
     $mingxiCalcYMDEnd = $postYMDEndMx;
  }

//  $zhuYunMeiYesterDayArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
//  $zhuYunMeiYesterDayWzArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
//  $zhuYunMeiYesterDayXqArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
//  $zhuYunMeiYesterDayHdArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


// $jiangTingYesterDayArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
// $jiangTingYesterDayWzArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
// $jiangTingYesterDayXqArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
// $jiangTingYesterDayHdArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $yangYangYesterDayArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $yangYangYesterDayWzArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $yangYangYesterDayXqArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $yangYangYesterDayHdArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $xiaoQiangYesterDayArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $xiaoQiangYesterDayWzArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $xiaoQiangYesterDayXqArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $xiaoQiangYesterDayHdArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $wenXiaoLanYesterDayArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $wenXiaoLanYesterDayWzArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $wenXiaoLanYesterDayXqArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $wenXiaoLanYesterDayHdArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $zhangSuDiYesterDayArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $zhangSuDiYesterDayWzArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $zhangSuDiYesterDayXqArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $zhangSuDiYesterDayHdArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $zhaoJingYesterDayArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $zhaoJingYesterDayWzArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $zhaoJingYesterDayXqArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $zhaoJingYesterDayHdArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $wuJingYanYesterDayArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $wuJingYanYesterDayWzArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $wuJingYanYesterDayXqArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $wuJingYanYesterDayHdArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $jianZhiYesterDayArr    = array_map('_xiangjia',$zhaoJingYesterDayArr,$wuJingYanYesterDayArr);
  $jianZhiYesterDayArr = array_combine(array_keys($zhaoJingYesterDayArr), $jianZhiYesterDayArr);
  $jianZhiYesterDayWzArr    = array_map('_xiangjia',$zhaoJingYesterDayWzArr,$wuJingYanYesterDayWzArr);
  $jianZhiYesterDayWzArr = array_combine(array_keys($zhaoJingYesterDayWzArr), $jianZhiYesterDayWzArr);
  $jianZhiYesterDayXqArr    = array_map('_xiangjia',$zhaoJingYesterDayXqArr,$wuJingYanYesterDayXqArr);
  $jianZhiYesterDayXqArr = array_combine(array_keys($zhaoJingYesterDayXqArr), $jianZhiYesterDayXqArr);
  $jianZhiYesterDayHdArr    = array_map('_xiangjia',$zhaoJingYesterDayHdArr,$wuJingYanYesterDayHdArr);
  $jianZhiYesterDayHdArr = array_combine(array_keys($zhaoJingYesterDayHdArr), $jianZhiYesterDayHdArr);




  //兼职的转化率
  $jianZhiYesterDayArr['zongZiXunToYouXiaoZiXun'] =  !empty($jianZhiYesterDayArr['zongZiXunLiang']) ? (round($jianZhiYesterDayArr['youXiaoZiXunLiang']/$jianZhiYesterDayArr['zongZiXunLiang'],3)*100).'%':'0%';
  $jianZhiYesterDayArr['youXiaoZiXunToShangMenLiang'] =  !empty($jianZhiYesterDayArr['youXiaoZiXunLiang']) ? (round($jianZhiYesterDayArr['shangMenLiang']/$jianZhiYesterDayArr['youXiaoZiXunLiang'],3)*100).'%':'0%';


  //近1个月明细日期
  $mingxiCalcYMDStart = _calcJingOneWeek($yesterDayYmd);
  $mingxiCalcYMDEnd   = $yesterDayYmd;

//  $zhuYunMeiJingWeekArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
//  $zhuYunMeiJingWeekWzArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
//  $zhuYunMeiJingWeekXqArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
//  $zhuYunMeiJingWeekHdArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


// $jiangTingJingWeekArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
// $jiangTingJingWeekWzArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
// $jiangTingJingWeekXqArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
// $jiangTingJingWeekHdArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $yangYangJingWeekArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $yangYangJingWeekWzArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $yangYangJingWeekXqArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $yangYangJingWeekHdArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');

  $xiaoQiangJingWeekArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $xiaoQiangJingWeekWzArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $xiaoQiangJingWeekXqArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $xiaoQiangJingWeekHdArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $wenXiaoLanJingWeekArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $wenXiaoLanJingWeekWzArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $wenXiaoLanJingWeekXqArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $wenXiaoLanJingWeekHdArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');

  $zhangSuDiJingWeekArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $zhangSuDiJingWeekWzArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $zhangSuDiJingWeekXqArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $zhangSuDiJingWeekHdArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $zhaoJingJingWeekArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $zhaoJingJingWeekWzArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $zhaoJingJingWeekXqArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $zhaoJingJingWeekHdArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $wuJingYanJingWeekArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $wuJingYanJingWeekWzArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $wuJingYanJingWeekXqArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $wuJingYanJingWeekHdArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $jianZhiJingWeekArr    = array_map('_xiangjia',$zhaoJingJingWeekArr,$wuJingYanJingWeekArr);
  $jianZhiJingWeekArr = array_combine(array_keys($zhaoJingJingWeekArr), $jianZhiJingWeekArr);
  $jianZhiJingWeekWzArr    = array_map('_xiangjia',$zhaoJingJingWeekWzArr,$wuJingYanJingWeekWzArr);
  $jianZhiJingWeekWzArr = array_combine(array_keys($zhaoJingJingWeekWzArr), $jianZhiJingWeekWzArr);
  $jianZhiJingWeekXqArr    = array_map('_xiangjia',$zhaoJingJingWeekXqArr,$wuJingYanJingWeekXqArr);
  $jianZhiJingWeekXqArr = array_combine(array_keys($zhaoJingJingWeekXqArr), $jianZhiJingWeekXqArr);
  $jianZhiJingWeekHdArr    = array_map('_xiangjia',$zhaoJingJingWeekHdArr,$wuJingYanJingWeekHdArr);
  $jianZhiJingWeekHdArr = array_combine(array_keys($zhaoJingJingWeekHdArr), $jianZhiJingWeekHdArr);



  //兼职的转化率
  $jianZhiJingWeekArr['zongZiXunToYouXiaoZiXun'] =  !empty($jianZhiJingWeekArr['zongZiXunLiang']) ? (round($jianZhiJingWeekArr['youXiaoZiXunLiang']/$jianZhiJingWeekArr['zongZiXunLiang'],3)*100).'%':'0%';
  $jianZhiJingWeekArr['youXiaoZiXunToShangMenLiang'] =  !empty($jianZhiJingWeekArr['youXiaoZiXunLiang']) ? (round($jianZhiJingWeekArr['shangMenLiang']/$jianZhiJingWeekArr['youXiaoZiXunLiang'],3)*100).'%':'0%';

  //近1个月明细日期
  $mingxiCalcYMDStart = _calcJingOneMonth($yesterDayYmd);
  $mingxiCalcYMDEnd   = $yesterDayYmd;

//  $zhuYunMeiJingMonthArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
//
//
//  $zhuYunMeiJingMonthWzArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
//
//  $zhuYunMeiJingMonthXqArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
//  $zhuYunMeiJingMonthHdArr  = _getKeFuInfo('朱运美',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


// $jiangTingJingMonthArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
// $jiangTingJingMonthWzArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
// $jiangTingJingMonthXqArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
// $jiangTingJingMonthHdArr  = _getKeFuInfo('姜霆',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $yangYangJingMonthArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $yangYangJingMonthWzArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $yangYangJingMonthXqArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $yangYangJingMonthHdArr  = _getKeFuInfo('杨洋',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');

  $xiaoQiangJingMonthArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $xiaoQiangJingMonthWzArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $xiaoQiangJingMonthXqArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $xiaoQiangJingMonthHdArr  = _getKeFuInfo('肖强',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $wenXiaoLanJingMonthArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $wenXiaoLanJingMonthWzArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $wenXiaoLanJingMonthXqArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $wenXiaoLanJingMonthHdArr  = _getKeFuInfo('翁晓兰',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');

  $zhangSuDiJingMonthArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $zhangSuDiJingMonthWzArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $zhangSuDiJingMonthXqArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $zhangSuDiJingMonthHdArr  = _getKeFuInfo('张素娣',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');



  $zhaoJingJingMonthArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $zhaoJingJingMonthWzArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $zhaoJingJingMonthXqArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $zhaoJingJingMonthHdArr  = _getKeFuInfo('赵静',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $wuJingYanJingMonthArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd);
  $wuJingYanJingMonthWzArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'wz');
  $wuJingYanJingMonthXqArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'xq');
  $wuJingYanJingMonthHdArr  = _getKeFuInfo('吴金燕',$mingxiCalcYMDStart,$mingxiCalcYMDEnd,'hd');


  $jianZhiJingMonthArr    = array_map('_xiangjia',$zhaoJingJingMonthArr,$wuJingYanJingMonthArr);
  $jianZhiJingMonthArr = array_combine(array_keys($zhaoJingJingMonthArr), $jianZhiJingMonthArr);
  $jianZhiJingMonthWzArr    = array_map('_xiangjia',$zhaoJingJingMonthWzArr,$wuJingYanJingMonthWzArr);
  $jianZhiJingMonthWzArr = array_combine(array_keys($zhaoJingJingMonthWzArr), $jianZhiJingMonthWzArr);
  $jianZhiJingMonthXqArr    = array_map('_xiangjia',$zhaoJingJingMonthXqArr,$wuJingYanJingMonthXqArr);
  $jianZhiJingMonthXqArr = array_combine(array_keys($zhaoJingJingMonthXqArr), $jianZhiJingMonthXqArr);
  $jianZhiJingMonthHdArr    = array_map('_xiangjia',$zhaoJingJingMonthHdArr,$wuJingYanJingMonthHdArr);
  $jianZhiJingMonthHdArr = array_combine(array_keys($zhaoJingJingMonthHdArr), $jianZhiJingMonthHdArr);



  //兼职的转化率
  $jianZhiJingMonthArr['zongZiXunToYouXiaoZiXun'] =  !empty($jianZhiJingMonthArr['zongZiXunLiang']) ? (round($jianZhiJingMonthArr['youXiaoZiXunLiang']/$jianZhiJingMonthArr['zongZiXunLiang'],3)*100).'%':'0%';
  $jianZhiJingMonthArr['youXiaoZiXunToShangMenLiang'] =  !empty($jianZhiJingMonthArr['youXiaoZiXunLiang']) ? (round($jianZhiJingMonthArr['shangMenLiang']/$jianZhiJingMonthArr['youXiaoZiXunLiang'],3)*100).'%':'0%';

  drupal_add_js(drupal_get_path('theme', 'myminnellizhutwo') . "/js/mingxi.js", '', 'footer');

  //$resultArrs = compact('yearMonthDay','thisMonthArr','lastMonthArr','lastYearArr','zhouYanJunArr','zhuYunMeiArr','wangJinJinArr','zhaoJingMeiArr');
  //下面 是根据公历求农历
  $nongliCalcYMDStart = _getNongli($calcYMDStart);
  $nongliCalcYMDEnd = _getNongli($calcYMDEnd);
  $nongliCalcYMDLastYearStart = _getNongli($calcYMDLastYearStart);
  $nongliCalcYMDLastYearEnd = _getNongli($calcYMDLastYearEnd);
  $nongliYearMonthDay = $nongliCalcYMDStart.' 至 '.$nongliCalcYMDEnd;
  $nongliLastYearYearMonthDay = $nongliCalcYMDLastYearStart.' 至 '.$nongliCalcYMDLastYearEnd;
  $resultArrs = compact('yearMonthDay','nongliYearMonthDay','lastYearYearMonthDay','nongliLastYearYearMonthDay','thisMonthArr','lastMonthArr','lastYearArr',
     'zhuYunMeiYesterDayArr','jiangTingYesterDayArr','jianZhiYesterDayArr',
     'zhuYunMeiJingWeekArr','jiangTingJingWeekArr','yangYangJingWeekArr','jianZhiJingWeekArr',
     'zhuYunMeiJingMonthArr','jiangTingJingMonthArr','yangYangJingMonthArr','jianZhiJingMonthArr',
     'zhuYunMeiYesterDayWzArr','zhuYunMeiYesterDayXqArr','zhuYunMeiYesterDayHdArr',
     'jiangTingYesterDayWzArr','jiangTingYesterDayXqArr','jiangTingYesterDayHdArr',
     'yangYangYesterDayArr','yangYangYesterDayWzArr','yangYangYesterDayXqArr','yangYangYesterDayHdArr',

     'xiaoQiangYesterDayArr','xiaoQiangYesterDayWzArr','xiaoQiangYesterDayXqArr','xiaoQiangYesterDayHdArr',
     'wenXiaoLanYesterDayArr','wenXiaoLanYesterDayWzArr','wenXiaoLanYesterDayXqArr','wenXiaoLanYesterDayHdArr',
     'zhangSuDiYesterDayArr','zhangSuDiYesterDayWzArr','zhangSuDiYesterDayXqArr','zhangSuDiYesterDayHdArr',

     'jianZhiYesterDayWzArr','jianZhiYesterDayXqArr','jianZhiYesterDayHdArr',
     'zhuYunMeiJingWeekWzArr','zhuYunMeiJingWeekXqArr','zhuYunMeiJingWeekHdArr',
     'jiangTingJingWeekWzArr','jiangTingJingWeekXqArr','jiangTingJingWeekHdArr','yangYangJingWeekWzArr','yangYangJingWeekXqArr',
     'yangYangJingWeekHdArr',

     'xiaoQiangJingWeekArr','xiaoQiangJingWeekWzArr','xiaoQiangJingWeekXqArr','xiaoQiangJingWeekHdArr',
     'wenXiaoLanJingWeekArr','wenXiaoLanJingWeekWzArr','wenXiaoLanJingWeekXqArr','wenXiaoLanJingWeekHdArr',
     'zhangSuDiJingWeekArr','zhangSuDiJingWeekWzArr','zhangSuDiJingWeekXqArr','zhangSuDiJingWeekHdArr',

     'jianZhiJingWeekWzArr',
     'jianZhiJingWeekXqArr','jianZhiJingWeekHdArr',


     'zhuYunMeiJingMonthWzArr','zhuYunMeiJingMonthXqArr','zhuYunMeiJingMonthHdArr',
     'jiangTingJingMonthWzArr','jiangTingJingMonthXqArr','jiangTingJingMonthHdArr',
     'yangYangJingMonthWzArr','yangYangJingMonthXqArr','yangYangJingMonthHdArr',

     'xiaoQiangJingMonthArr','xiaoQiangJingMonthWzArr','xiaoQiangJingMonthXqArr','xiaoQiangJingMonthHdArr',
     'wenXiaoLanJingMonthArr','wenXiaoLanJingMonthWzArr','wenXiaoLanJingMonthXqArr','wenXiaoLanJingMonthHdArr',
     'zhangSuDiJingMonthArr','zhangSuDiJingMonthWzArr','zhangSuDiJingMonthXqArr','zhangSuDiJingMonthHdArr',

     'jianZhiJingMonthWzArr','jianZhiJingMonthXqArr','jianZhiJingMonthHdArr');
  return $resultArrs;
}
function _toDMD($strDate)
{
  if($strDate=='now'){
     return date('Y-m-d');
  }
  return $strDate;
}



普通分类: