PHP循环输出数据到表格显示数据窜列

请输入图片描述

  
//月初5号统计上月赠送课程
public static function MonthFifthSendEmail()
{
dailyJobLog::log('MonthFifthSendEmail begin');
// if(date('j')!='5')
// {
// return;
// }
$send = new faEmail ();
$time = date ( 'Y-m-d',strtotime('-32 day') );
$time1 = date('Y-m-d', strtotime('-4 day') );
//1. 获取上月赠送课程
$ruc = $send->selectGivLesson ( $time, $time1 );
$mailbody = '<html xmlns="http://www.w3.org/1999/xhtml"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><body>您好:<br/>这是上月所有的付款方式为“免费赠送”的订单汇总:<br/><table border="1"><tr><td>订单号</td><td>订购日期</td><td>总计</td><td>赠课类型</td><td>备注</td><td>客户姓名</td><td>省份</td><td>年级</td><td>负责人</td><td>提交人</td><td>是否付款 </td></tr>';
if ($ruc != null)
{
foreach ( $ruc as $value )
{
switch ($value['SOM_GiftType']) {
case 1:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>教师赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 2:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>教师子女赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 3:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>进步之星赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 4:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>讲座中奖赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 5:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>奖学金赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 6:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>简单大使赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 7:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>亲属赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 8:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>测试赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
case 9:
$mailbody .= '<tr><td>'.$value['SOM_OrderInfoID'].'</td><td>'.$value['SOM_OrderDate'].'</td><td>'.$value['SOM_OrderSum'].'</td><td>其他赠课</td><td>'.$value['SOM_GiftRemark'].'</td><td>'.$value['SOM_CustomerInfo'].'</td><td>'.$value['CRM_ProvinceName'].'</td><td>'.$value['CRM_GradeName'].'</td><td>'.$value['BDM_EmployeeName'].'</td><td>'.$value['BDM_SubmitEmployeeName'].'</td><td>'.($value['SOM_IsPay']==1?'已付款':'未付款').'</td></tr>';
break;
}
}
}
else
{
$mailbody .= '<tr style="color:red;font-weight:bold;"><td colspan="11">上月无赠送课程</td></tr>';
}
$mailbody .= '</table>';
$state = 1; // 0:已提交 1:已扣款 2:退回
//2.获取上一月批量授课
$end = $send->selectBatchLesson($state,$time,$time1);
$mailbody .= '<br/>这是上月已扣款的批量授课类型为“奖学金”、“教师赠课”、“教师孩子赠课”的订单汇总:<br/>
<table border="1" bordercolor = "bluesky">
<tr><td>编号</td><td>授课类型</td><td>名称</td><td>代理</td><td>备注</td><td>导入时间</td><td>提交人</td></tr>';
if ($end)
{
foreach ( $end as $value )
{
$mailbody .= '<tr><td>'.$value['ARM_BCIID'].'</td><td>'.$value['ARM_ClassType'].'</td><td>'.$value['ARM_ClassInfoName'].'</td><td>'.$value['ARM_AgentName'].'</td><td>'.$value['ARM_Remark'].'</td><td>'.$value['ARM_InsertTime'].'</td><td>'.$value['BDM_EmployeeName'].'</td></tr>';
}
}
else
{
$mailbody .= '<tr style="color:red;font-weight:bold;"><td colspan="7">已扣款的授课类型为“奖学金”、“教师赠课”、“教师孩子赠课”上月无订单</td></tr>';
}
$mailbody .= '</table>';
//3.赠课订单汇总
$result1 = $send->gather1($time,$time1);//已归档
$mailbody.='<br/>这是按赠课类型统计上月订单总额和(未)归档订单金额百分比:<br/>
<table border="1" bordercolor="pink">
<tr><td>赠课类型</td><td>课程总金额</td></tr>';
if ($result1!=null)
{
$mailbody .= '<tr><td bgcolor="#8E2323">已归档</td><td>'.$result1[0]['amounted'].'</td></tr>';//归档总金额
foreach ($result1 as $key => $value)
{
switch ($value['SOM_GiftType'])
{
case 1:
$mailbody.='<tr><td>教师赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 2:
$mailbody.='<tr><td>教师子女赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 3:
$mailbody.='<tr><td>进步之星赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 4:
$mailbody.='<tr><td>讲座中奖赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 5:
$mailbody.='<tr><td>奖学金赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 6:
$mailbody.='<tr><td>简单大使赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 7:
$mailbody.='<tr><td>亲属赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 8:
$mailbody.='<tr><td>测试赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 9:
$mailbody.='<tr><td>其他赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
}
}
$mailbody .= '<tr><td bgcolor="#8E2323">百分比</td><td>'.round($value['amountedPercent']*100).'%</td></tr>';
}
else
{
$mailbody.='<tr style="color:red;font-weight:bold;"><td colspan="2">没有归档订单数据</td></tr>';
}
$result=$send->gather0($time,$time1);//未归档订单
if ($result!=null)
{
$mailbody.='<tr><td bgcolor="#CCFF33">未归档</td><td>'.$result[0]['unamount'].'</td></tr>';
foreach ($result as $key => $value)
{
switch ($value['SOM_GiftType'])
{
case 1:
$mailbody.='<tr><td>教师赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 2:
$mailbody.='<tr><td>教师子女赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 3:
$mailbody.='<tr><td>进步之星赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 4:
$mailbody.='<tr><td>讲座中奖赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 5:
$mailbody.='<tr><td>奖学金赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 6:
$mailbody.='<tr><td>简单大使赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 7:
$mailbody.='<tr><td>亲属赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 8:
$mailbody.='<tr><td>测试赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
case 9:
$mailbody.='<tr><td>其他赠课</td><td>'.$value['subtotal'].'</td></tr>';
break;
}
}
$mailbody.='<tr><td bgcolor="#CCFF33">百分比</td><td>'.round($value['unamountPercent']*100).'%</td></tr>';
$mailbody .= '<tr><td bgcolor="#8FBC8F">总计</td><td colspan="2">'.$value['total'].'</td></tr>';
}
else
{
$mailbody.='<tr style="color:red;font-weight:bold;"><td colspan="2">没有未归档订单数据</td></tr>';
}
$mailbody .= '</table></body></html>';
$sMailSubject = date ( 'Y-m-d' ).'上月赠送课程汇总';
$sTo = BOSS;
$sCC = ShipServiceFee_TO;
$oETMailNotify = new ETMailNotify ( $sTo, $sMailSubject, $mailbody, $sCC );
$oETMailNotify->sendMail ();
echo $mailbody;
dailyJobLog::log('MonthFifthSendEmail end');
}
评论 (2)链接2015-11-02 
  • 0 支持
    很明显那个<td> 多了个空格(< td>
    而且就算你来纠错也该贴html吧=_=
    – yunzl 2015-11-09
  • 0 支持
    @yunzl 第几行<td>多了个空格? – 加百列 2016-04-14
德问是一个专业的编程问答社区,请 登录注册 后再提交答案