0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0 ); for($i = 1; $i <= 15; $i ++) { if ($i == 1) { $html = '银行手续费'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotalSum [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 2) { $html .= '总部电话费'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotalSum [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 3) { $subtotal = array ( 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0 ); $html .= '缴税'; $html .= '增值税'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '增值税' && $value ['month'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotal [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '税金附加'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '税金附加' && $value ['month'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotal [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '企业所得税'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '企业所得税' && $value ['month'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotal [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; }elseif ($i == 5) { $html .= '保证金'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotalSum [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } } $html .= '合计'; $sum = 0; foreach ( $subtotalSum as $key => $value ) { $sum += $value; if (! empty ( $value )) $html .= '¥' . $value . ''; else $html .= '-'; } $html .= '¥' . $sum . ''; $html .= ''; $html .= '全年合计 ¥' . $sum . ''; return array('html'=>$html,'sum'=>$sum); } /** * 获得汇总 日常收支年 * @param array $statisticsIncome * @return string */ function _getPaymentsCollectByYearHtml($statisticsIncome = array()) { $html = ''; $subtotalSum = array ( 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0 ); for($i = 1; $i <= 15; $i ++) { if ($i == 1) { $subtotal = array ( 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0 ); $html .= '利息收入'; $html .= '银行存款'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '银行存款' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '理财收益'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '个人借款'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '个人借款' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 2) { $subtotal = array ( 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0 ); $html .= '补贴收入'; $html .= '社保'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '社保' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '财政'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '财政' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 3) { $html .= '纵横知道'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 4) { $subtotal = array ( 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0 ); $html .= '借款收回'; $html .= '备用金'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '备用金' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '私人借款'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '私人借款' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 5) { $html .= '退汇'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 6) { $html .= '其他'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 8) { $html .= '保证金'; $sum = 0; for($month = 1; $month <= 12; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } } $html .= '合计'; $sum = 0; foreach ( $subtotalSum as $key => $value ) { $sum += $value; if (! empty ( $value )) $html .= '¥' . $value . ''; else $html .= '-'; } $html .= '¥' . $sum . ''; $html .= ''; $html .= '全年合计 ¥' . $sum . ''; return array('html'=>$html,'sum'=>$sum); } /** * 获得汇总 日常收支年 * @param array $statisticsIncome * @return string */ function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) { $html = '日常收入'; for($d = 1; $d <= $day; $d ++) { $subtotalSum [$d] = 0; $html .= '' . $d . '日'; } $html .= '总计'; for($i = 1; $i <= 15; $i ++) { if ($i == 1) { for($d = 1; $d <= $day; $d ++) { $subtotal [$d] = 0; } // $subtotal = array ( // 1 => 0, // 2 => 0, // 3 => 0, // 4 => 0, // 5 => 0, // 6 => 0, // 7 => 0, // 8 => 0, // 9 => 0, // 10 => 0, // 11 => 0, // 12 => 0 // ); $html .= '利息收入'; $html .= '银行存款'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '银行存款' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '理财收益'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '理财收益' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '个人借款'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '个人借款' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 2) { for($d = 1; $d <= $day; $d ++) { $subtotal [$d] = 0; } $html .= '补贴收入'; $html .= '社保'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '社保' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '财政'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '财政' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 3) { $html .= '纵横知道'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 4) { for($d = 1; $d <= $day; $d ++) { $subtotal [$d] = 0; } $html .= '借款收回'; $html .= '备用金'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '备用金' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '私人借款'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '私人借款' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotal [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 5) { $html .= '退汇'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 6) { $html .= '其他'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; }elseif ($i == 8) { $html .= '保证金'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsIncome as $key => $value ) { if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) { $html .= '¥' . $value ['inComePrice'] . ''; $sum += $value ['inComePrice']; $subtotalSum [$month] += $value ['inComePrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } } $html .= '合计'; $sum = 0; foreach ( $subtotalSum as $key => $value ) { $sum += $value; if (! empty ( $value )) $html .= '¥' . $value . ''; else $html .= '-'; } $html .= '¥' . $sum . ''; $html .= ''; $colspan = $day + 1; $html .= '全月合计 ¥' . $sum . ''; return array('html'=>$html,'sum'=>$sum); } function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) { $html = '日常支出'; for($d = 1; $d <= $day; $d ++) { $subtotalSum [$d] = 0; $html .= '' . $d . '日'; } $html .= '总计'; for($i = 1; $i <= 15; $i ++) { if ($i == 1) { $html .= '银行手续费'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotalSum [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 2) { $html .= '总部电话费'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotalSum [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } elseif ($i == 3) { for($d = 1; $d <= $day; $d ++) { $subtotal [$d] = 0; } $html .= '缴税'; $html .= '增值税'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '增值税' && $value ['day'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotal [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '税金附加'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '税金附加' && $value ['day'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotal [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '企业所得税'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '企业所得税' && $value ['day'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotal [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; $html .= '小计'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $sum += $subtotal [$month]; $subtotalSum [$month] += $subtotal [$month]; if (! empty ( $subtotal [$month] )) $html .= '¥' . $subtotal [$month] . ''; else $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; }elseif ($i == 5) { $html .= '保证金'; $sum = 0; for($month = 1; $month <= $day; $month ++) { $falg = true; foreach ( $statisticsPay as $key => $value ) { if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) { $html .= '¥' . $value ['payPrice'] . ''; $sum += $value ['payPrice']; $subtotalSum [$month] += $value ['payPrice']; $falg = false; break; } } if ($falg) $html .= '-'; } if ($sum == 0) $html .= '-'; else $html .= '¥' . $sum . ''; $html .= ''; } } $html .= '合计'; $sum = 0; foreach ( $subtotalSum as $key => $value ) { $sum += $value; if (! empty ( $value )) $html .= '¥' . $value . ''; else $html .= '-'; } $html .= '¥' . $sum . ''; $html .= ''; $colspan = $day + 1; $html .= '全年合计 ¥' . $sum . ''; return array('html'=>$html,'sum'=>$sum); } /** * 数据导出 * @param array $title 标题行名称 * @param array $data 导出数据 * @param string $fileName 文件名 * @param string $savePath 保存路径 * @param $type 是否下载 false--保存 true--下载 * @return string 返回文件全路径 * @throws PHPExcel_Exception * @throws PHPExcel_Reader_Exception @exportExcel(array('姓名','年龄'), array(array('a',21),array('b',23)), '档案', './', true); */ function exportExcel($title = array(), $data = array(), $fileName = '', $savePath = './', $isDown = false) { Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' ); $obj = new PHPExcel (); // 横向单元格标识 $cellName = array ( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ' ); $obj->getActiveSheet ( 0 )->setTitle ( 'sheet名称' ); // 设置sheet名称 $_row = 0; // 设置纵向单元格标识 if ($title) { $_cnt = count ( $title ); // $obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //合并单元格 // $obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '数据导出:'.date('Y-m-d H:i:s')); //设置合并后的单元格内容 $_row ++; $i = 0; foreach ( $title as $v ) { // 设置列标题 $obj->setActiveSheetIndex ( 0 )->setCellValue ( $cellName [$i] . $_row, $v ); $i ++; } $_row ++; } ; // html_entity_decode("".$value['order_id']); // 填写数据 if ($data) { $i = 0; foreach ( $data as $_v ) { $j = 0; foreach ( $_v as $_cell ) { $obj->getActiveSheet ( 0 )->setCellValueExplicit ( $cellName [$j] . ($i + $_row), $_cell, PHPExcel_Cell_DataType::TYPE_STRING ); $j ++; } $i ++; } } // 文件名处理 if (! $fileName) { $fileName = uniqid ( time (), true ); } $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' ); if ($isDown) { // 网页下载 header ( 'pragma:public' ); header ( "Content-Disposition:attachment;filename=$fileName.xls" ); header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ); $objWrite->save ( 'php://output' ); exit (); } $_fileName = iconv ( "utf-8", "gb2312", $fileName ); // 转码 $_savePath = $savePath . $_fileName . '.xlsx'; $objWrite->save ( $_savePath ); return $savePath . $fileName . '.xlsx'; } ?>