receipt.func.php 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  1. <?php
  2. function _getPaymentsCollectPayByYearHtml($statisticsPay = array()) {
  3. $html = '';
  4. $subtotalSum = array (
  5. 1 => 0,
  6. 2 => 0,
  7. 3 => 0,
  8. 4 => 0,
  9. 5 => 0,
  10. 6 => 0,
  11. 7 => 0,
  12. 8 => 0,
  13. 9 => 0,
  14. 10 => 0,
  15. 11 => 0,
  16. 12 => 0
  17. );
  18. for($i = 1; $i <= 15; $i ++) {
  19. if ($i == 1) {
  20. $html = '<tr><th colspan="2" >银行手续费</th>';
  21. $sum = 0;
  22. for($month = 1; $month <= 12; $month ++) {
  23. $falg = true;
  24. foreach ( $statisticsPay as $key => $value ) {
  25. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  26. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  27. $sum += $value ['payPrice'];
  28. $subtotalSum [$month] += $value ['payPrice'];
  29. $falg = false;
  30. break;
  31. }
  32. }
  33. if ($falg)
  34. $html .= '<td class="taR">-</td>';
  35. }
  36. if ($sum == 0)
  37. $html .= '<td class="taR">-</td>';
  38. else
  39. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  40. $html .= '</tr>';
  41. } elseif ($i == 2) {
  42. $html .= '<tr><th colspan="2" >总部电话费</th>';
  43. $sum = 0;
  44. for($month = 1; $month <= 12; $month ++) {
  45. $falg = true;
  46. foreach ( $statisticsPay as $key => $value ) {
  47. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  48. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  49. $sum += $value ['payPrice'];
  50. $subtotalSum [$month] += $value ['payPrice'];
  51. $falg = false;
  52. break;
  53. }
  54. }
  55. if ($falg)
  56. $html .= '<td class="taR">-</td>';
  57. }
  58. if ($sum == 0)
  59. $html .= '<td class="taR">-</td>';
  60. else
  61. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  62. $html .= '</tr>';
  63. } elseif ($i == 3) {
  64. $subtotal = array (
  65. 1 => 0,
  66. 2 => 0,
  67. 3 => 0,
  68. 4 => 0,
  69. 5 => 0,
  70. 6 => 0,
  71. 7 => 0,
  72. 8 => 0,
  73. 9 => 0,
  74. 10 => 0,
  75. 11 => 0,
  76. 12 => 0
  77. );
  78. $html .= '<tr><th rowspan="4" width="90">缴税</th>';
  79. $html .= '<th width="90">增值税</th>';
  80. $sum = 0;
  81. for($month = 1; $month <= 12; $month ++) {
  82. $falg = true;
  83. foreach ( $statisticsPay as $key => $value ) {
  84. if ($value ['expenditureMsg'] == '增值税' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  85. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  86. $sum += $value ['payPrice'];
  87. $subtotal [$month] += $value ['payPrice'];
  88. $falg = false;
  89. break;
  90. }
  91. }
  92. if ($falg)
  93. $html .= '<td class="taR">-</td>';
  94. }
  95. if ($sum == 0)
  96. $html .= '<td class="taR">-</td>';
  97. else
  98. $html .= '<td class="taR">¥' . $sum . '</td>';
  99. $html .= '</tr>';
  100. $html .= '<th width="90">税金附加</th>';
  101. $sum = 0;
  102. for($month = 1; $month <= 12; $month ++) {
  103. $falg = true;
  104. foreach ( $statisticsPay as $key => $value ) {
  105. if ($value ['expenditureMsg'] == '税金附加' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  106. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  107. $sum += $value ['payPrice'];
  108. $subtotal [$month] += $value ['payPrice'];
  109. $falg = false;
  110. break;
  111. }
  112. }
  113. if ($falg)
  114. $html .= '<td class="taR">-</td>';
  115. }
  116. if ($sum == 0)
  117. $html .= '<td class="taR">-</td>';
  118. else
  119. $html .= '<td class="taR">¥' . $sum . '</td>';
  120. $html .= '</tr>';
  121. $html .= '<th width="90">企业所得税</th>';
  122. $sum = 0;
  123. for($month = 1; $month <= 12; $month ++) {
  124. $falg = true;
  125. foreach ( $statisticsPay as $key => $value ) {
  126. if ($value ['expenditureMsg'] == '企业所得税' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  127. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  128. $sum += $value ['payPrice'];
  129. $subtotal [$month] += $value ['payPrice'];
  130. $falg = false;
  131. break;
  132. }
  133. }
  134. if ($falg)
  135. $html .= '<td class="taR">-</td>';
  136. }
  137. if ($sum == 0)
  138. $html .= '<td class="taR">-</td>';
  139. else
  140. $html .= '<td class="taR">¥' . $sum . '</td>';
  141. $html .= '</tr>';
  142. $html .= '<th width="90" class="colRed">小计</th>';
  143. $sum = 0;
  144. for($month = 1; $month <= 12; $month ++) {
  145. $sum += $subtotal [$month];
  146. $subtotalSum [$month] += $subtotal [$month];
  147. if (! empty ( $subtotal [$month] ))
  148. $html .= '<td class="taR colRed">¥' . $subtotal [$month] . '</td>';
  149. else
  150. $html .= '<td class="taR">-</td>';
  151. }
  152. if ($sum == 0)
  153. $html .= '<td class="taR">-</td>';
  154. else
  155. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  156. $html .= '</tr>';
  157. }elseif ($i == 5) {
  158. $html .= '<tr><th colspan="2" >保证金</th>';
  159. $sum = 0;
  160. for($month = 1; $month <= 12; $month ++) {
  161. $falg = true;
  162. foreach ( $statisticsPay as $key => $value ) {
  163. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  164. $html .= '<td class="taR">¥' . abs($value ['payPrice']) . '</td>';
  165. $sum += abs($value ['payPrice']);
  166. $subtotalSum [$month] += abs($value ['payPrice']);
  167. $falg = false;
  168. break;
  169. }
  170. }
  171. if ($falg)
  172. $html .= '<td class="taR">-</td>';
  173. }
  174. if ($sum == 0)
  175. $html .= '<td class="taR">-</td>';
  176. else
  177. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  178. $html .= '</tr>';
  179. }
  180. }
  181. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  182. $sum = 0;
  183. foreach ( $subtotalSum as $key => $value ) {
  184. $sum += $value;
  185. if (! empty ( $value ))
  186. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  187. else
  188. $html .= '<td class="taR">-</td>';
  189. }
  190. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  191. $html .= '</tr>';
  192. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  193. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  194. return array('html'=>$html,'sum'=>$sum);
  195. }
  196. /**
  197. * 获得汇总 日常收支年
  198. * @param array $statisticsIncome
  199. * @return string
  200. */
  201. function _getPaymentsCollectByYearHtml($statisticsIncome = array()) {
  202. $html = '';
  203. $subtotalSum = array (
  204. 1 => 0,
  205. 2 => 0,
  206. 3 => 0,
  207. 4 => 0,
  208. 5 => 0,
  209. 6 => 0,
  210. 7 => 0,
  211. 8 => 0,
  212. 9 => 0,
  213. 10 => 0,
  214. 11 => 0,
  215. 12 => 0
  216. );
  217. for($i = 1; $i <= 15; $i ++) {
  218. if ($i == 1) {
  219. $subtotal = array (
  220. 1 => 0,
  221. 2 => 0,
  222. 3 => 0,
  223. 4 => 0,
  224. 5 => 0,
  225. 6 => 0,
  226. 7 => 0,
  227. 8 => 0,
  228. 9 => 0,
  229. 10 => 0,
  230. 11 => 0,
  231. 12 => 0
  232. );
  233. $html .= '<tr><th rowspan="4" width="90">利息收入</th>';
  234. $html .= '<th width="90">银行存款</th>';
  235. $sum = 0;
  236. for($month = 1; $month <= 12; $month ++) {
  237. $falg = true;
  238. foreach ( $statisticsIncome as $key => $value ) {
  239. if ($value ['accountMsg'] == '银行存款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  240. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  241. $sum += $value ['inComePrice'];
  242. $subtotal [$month] += $value ['inComePrice'];
  243. $falg = false;
  244. break;
  245. }
  246. }
  247. if ($falg)
  248. $html .= '<td class="taR">-</td>';
  249. }
  250. if ($sum == 0)
  251. $html .= '<td class="taR">-</td>';
  252. else
  253. $html .= '<td class="taR">¥' . $sum . '</td>';
  254. $html .= '</tr>';
  255. $html .= '<th width="90">活期理财收益</th>';
  256. $sum = 0;
  257. for($month = 1; $month <= 12; $month ++) {
  258. $falg = true;
  259. foreach ( $statisticsIncome as $key => $value ) {
  260. if ($value ['accountMsg'] == '活期理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) {
  261. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  262. $sum += $value ['inComePrice'];
  263. $subtotal [$month] += $value ['inComePrice'];
  264. $falg = false;
  265. break;
  266. }
  267. }
  268. if ($falg)
  269. $html .= '<td class="taR">-</td>';
  270. }
  271. if ($sum == 0)
  272. $html .= '<td class="taR">-</td>';
  273. else
  274. $html .= '<td class="taR">¥' . $sum . '</td>';
  275. $html .= '</tr>';
  276. $html .= '<th width="90">固定理财收益</th>';
  277. $sum = 0;
  278. for($month = 1; $month <= 12; $month ++) {
  279. $falg = true;
  280. foreach ( $statisticsIncome as $key => $value ) {
  281. if ($value ['accountMsg'] == '固定理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) {
  282. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  283. $sum += $value ['inComePrice'];
  284. $subtotal [$month] += $value ['inComePrice'];
  285. $falg = false;
  286. break;
  287. }
  288. }
  289. if ($falg)
  290. $html .= '<td class="taR">-</td>';
  291. }
  292. if ($sum == 0)
  293. $html .= '<td class="taR">-</td>';
  294. else
  295. $html .= '<td class="taR">¥' . $sum . '</td>';
  296. $html .= '</tr>';
  297. $html .= '<th width="90">个人借款</th>';
  298. $sum = 0;
  299. for($month = 1; $month <= 12; $month ++) {
  300. $falg = true;
  301. foreach ( $statisticsIncome as $key => $value ) {
  302. if ($value ['accountMsg'] == '个人借款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  303. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  304. $sum += $value ['inComePrice'];
  305. $subtotal [$month] += $value ['inComePrice'];
  306. $falg = false;
  307. break;
  308. }
  309. }
  310. if ($falg)
  311. $html .= '<td class="taR">-</td>';
  312. }
  313. if ($sum == 0)
  314. $html .= '<td class="taR">-</td>';
  315. else
  316. $html .= '<td class="taR">¥' . $sum . '</td>';
  317. $html .= '</tr>';
  318. $html .= '<th width="90" class="colGreen">小计</th>';
  319. $sum = 0;
  320. for($month = 1; $month <= 12; $month ++) {
  321. $sum += $subtotal [$month];
  322. $subtotalSum [$month] += $subtotal [$month];
  323. if (! empty ( $subtotal [$month] ))
  324. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  325. else
  326. $html .= '<td class="taR">-</td>';
  327. }
  328. if ($sum == 0)
  329. $html .= '<td class="taR">-</td>';
  330. else
  331. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  332. $html .= '</tr>';
  333. } elseif ($i == 2) {
  334. $subtotal = array (
  335. 1 => 0,
  336. 2 => 0,
  337. 3 => 0,
  338. 4 => 0,
  339. 5 => 0,
  340. 6 => 0,
  341. 7 => 0,
  342. 8 => 0,
  343. 9 => 0,
  344. 10 => 0,
  345. 11 => 0,
  346. 12 => 0
  347. );
  348. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  349. $html .= '<th width="90">社保</th>';
  350. $sum = 0;
  351. for($month = 1; $month <= 12; $month ++) {
  352. $falg = true;
  353. foreach ( $statisticsIncome as $key => $value ) {
  354. if ($value ['accountMsg'] == '社保' && $value ['month'] == $month && $value ['accountType'] == $i) {
  355. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  356. $sum += $value ['inComePrice'];
  357. $subtotal [$month] += $value ['inComePrice'];
  358. $falg = false;
  359. break;
  360. }
  361. }
  362. if ($falg)
  363. $html .= '<td class="taR">-</td>';
  364. }
  365. if ($sum == 0)
  366. $html .= '<td class="taR">-</td>';
  367. else
  368. $html .= '<td class="taR">¥' . $sum . '</td>';
  369. $html .= '</tr>';
  370. $html .= '<th width="90">财政</th>';
  371. $sum = 0;
  372. for($month = 1; $month <= 12; $month ++) {
  373. $falg = true;
  374. foreach ( $statisticsIncome as $key => $value ) {
  375. if ($value ['accountMsg'] == '财政' && $value ['month'] == $month && $value ['accountType'] == $i) {
  376. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  377. $sum += $value ['inComePrice'];
  378. $subtotal [$month] += $value ['inComePrice'];
  379. $falg = false;
  380. break;
  381. }
  382. }
  383. if ($falg)
  384. $html .= '<td class="taR">-</td>';
  385. }
  386. if ($sum == 0)
  387. $html .= '<td class="taR">-</td>';
  388. else
  389. $html .= '<td class="taR">¥' . $sum . '</td>';
  390. $html .= '</tr>';
  391. $html .= '<th width="90" class="colGreen">小计</th>';
  392. $sum = 0;
  393. for($month = 1; $month <= 12; $month ++) {
  394. $sum += $subtotal [$month];
  395. $subtotalSum [$month] += $subtotal [$month];
  396. if (! empty ( $subtotal [$month] ))
  397. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  398. else
  399. $html .= '<td class="taR">-</td>';
  400. }
  401. if ($sum == 0)
  402. $html .= '<td class="taR">-</td>';
  403. else
  404. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  405. $html .= '</tr>';
  406. } elseif ($i == 3) {
  407. $html .= '<tr><th colspan="2" >纵横知道</th>';
  408. $sum = 0;
  409. for($month = 1; $month <= 12; $month ++) {
  410. $falg = true;
  411. foreach ( $statisticsIncome as $key => $value ) {
  412. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  413. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  414. $sum += $value ['inComePrice'];
  415. $subtotalSum [$month] += $value ['inComePrice'];
  416. $falg = false;
  417. break;
  418. }
  419. }
  420. if ($falg)
  421. $html .= '<td class="taR">-</td>';
  422. }
  423. if ($sum == 0)
  424. $html .= '<td class="taR">-</td>';
  425. else
  426. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  427. $html .= '</tr>';
  428. } elseif ($i == 4) {
  429. $subtotal = array (
  430. 1 => 0,
  431. 2 => 0,
  432. 3 => 0,
  433. 4 => 0,
  434. 5 => 0,
  435. 6 => 0,
  436. 7 => 0,
  437. 8 => 0,
  438. 9 => 0,
  439. 10 => 0,
  440. 11 => 0,
  441. 12 => 0
  442. );
  443. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  444. $html .= '<th width="90">备用金</th>';
  445. $sum = 0;
  446. for($month = 1; $month <= 12; $month ++) {
  447. $falg = true;
  448. foreach ( $statisticsIncome as $key => $value ) {
  449. if ($value ['accountMsg'] == '备用金' && $value ['month'] == $month && $value ['accountType'] == $i) {
  450. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  451. $sum += $value ['inComePrice'];
  452. $subtotal [$month] += $value ['inComePrice'];
  453. $falg = false;
  454. break;
  455. }
  456. }
  457. if ($falg)
  458. $html .= '<td class="taR">-</td>';
  459. }
  460. if ($sum == 0)
  461. $html .= '<td class="taR">-</td>';
  462. else
  463. $html .= '<td class="taR">¥' . $sum . '</td>';
  464. $html .= '</tr>';
  465. $html .= '<th width="90">私人借款</th>';
  466. $sum = 0;
  467. for($month = 1; $month <= 12; $month ++) {
  468. $falg = true;
  469. foreach ( $statisticsIncome as $key => $value ) {
  470. if ($value ['accountMsg'] == '私人借款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  471. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  472. $sum += $value ['inComePrice'];
  473. $subtotal [$month] += $value ['inComePrice'];
  474. $falg = false;
  475. break;
  476. }
  477. }
  478. if ($falg)
  479. $html .= '<td class="taR">-</td>';
  480. }
  481. if ($sum == 0)
  482. $html .= '<td class="taR">-</td>';
  483. else
  484. $html .= '<td class="taR">¥' . $sum . '</td>';
  485. $html .= '</tr>';
  486. $html .= '<th width="90" class="colGreen">小计</th>';
  487. $sum = 0;
  488. for($month = 1; $month <= 12; $month ++) {
  489. $sum += $subtotal [$month];
  490. $subtotalSum [$month] += $subtotal [$month];
  491. if (! empty ( $subtotal [$month] ))
  492. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  493. else
  494. $html .= '<td class="taR">-</td>';
  495. }
  496. if ($sum == 0)
  497. $html .= '<td class="taR">-</td>';
  498. else
  499. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  500. $html .= '</tr>';
  501. } elseif ($i == 5) {
  502. $html .= '<tr><th colspan="2" >退汇</th>';
  503. $sum = 0;
  504. for($month = 1; $month <= 12; $month ++) {
  505. $falg = true;
  506. foreach ( $statisticsIncome as $key => $value ) {
  507. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  508. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  509. $sum += $value ['inComePrice'];
  510. $subtotalSum [$month] += $value ['inComePrice'];
  511. $falg = false;
  512. break;
  513. }
  514. }
  515. if ($falg)
  516. $html .= '<td class="taR">-</td>';
  517. }
  518. if ($sum == 0)
  519. $html .= '<td class="taR">-</td>';
  520. else
  521. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  522. $html .= '</tr>';
  523. } elseif ($i == 6) {
  524. $html .= '<tr><th colspan="2" >其他</th>';
  525. $sum = 0;
  526. for($month = 1; $month <= 12; $month ++) {
  527. $falg = true;
  528. foreach ( $statisticsIncome as $key => $value ) {
  529. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  530. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  531. $sum += $value ['inComePrice'];
  532. $subtotalSum [$month] += $value ['inComePrice'];
  533. $falg = false;
  534. break;
  535. }
  536. }
  537. if ($falg)
  538. $html .= '<td class="taR">-</td>';
  539. }
  540. if ($sum == 0)
  541. $html .= '<td class="taR">-</td>';
  542. else
  543. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  544. $html .= '</tr>';
  545. } elseif ($i == 8) {
  546. $html .= '<tr><th colspan="2" >保证金</th>';
  547. $sum = 0;
  548. for($month = 1; $month <= 12; $month ++) {
  549. $falg = true;
  550. foreach ( $statisticsIncome as $key => $value ) {
  551. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  552. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  553. $sum += $value ['inComePrice'];
  554. $subtotalSum [$month] += $value ['inComePrice'];
  555. $falg = false;
  556. break;
  557. }
  558. }
  559. if ($falg)
  560. $html .= '<td class="taR">-</td>';
  561. }
  562. if ($sum == 0)
  563. $html .= '<td class="taR">-</td>';
  564. else
  565. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  566. $html .= '</tr>';
  567. }
  568. }
  569. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  570. $sum = 0;
  571. foreach ( $subtotalSum as $key => $value ) {
  572. $sum += $value;
  573. if (! empty ( $value ))
  574. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  575. else
  576. $html .= '<td class="taR">-</td>';
  577. }
  578. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  579. $html .= '</tr>';
  580. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  581. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  582. return array('html'=>$html,'sum'=>$sum);
  583. }
  584. /**
  585. * 获得汇总 日常收支年
  586. * @param array $statisticsIncome
  587. * @return string
  588. */
  589. function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
  590. $html = '<tr><th class="taC" colspan="2">日常收入</th>';
  591. for($d = 1; $d <= $day; $d ++) {
  592. $subtotalSum [$d] = 0;
  593. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  594. }
  595. $html .= '<th class="taC" width="110">总计</th></tr>';
  596. for($i = 1; $i <= 15; $i ++) {
  597. if ($i == 1) {
  598. for($d = 1; $d <= $day; $d ++) {
  599. $subtotal [$d] = 0;
  600. }
  601. // $subtotal = array (
  602. // 1 => 0,
  603. // 2 => 0,
  604. // 3 => 0,
  605. // 4 => 0,
  606. // 5 => 0,
  607. // 6 => 0,
  608. // 7 => 0,
  609. // 8 => 0,
  610. // 9 => 0,
  611. // 10 => 0,
  612. // 11 => 0,
  613. // 12 => 0
  614. // );
  615. $html .= '<tr><th rowspan="4" width="90">利息收入</th>';
  616. $html .= '<th width="90">银行存款</th>';
  617. $sum = 0;
  618. for($month = 1; $month <= $day; $month ++) {
  619. $falg = true;
  620. foreach ( $statisticsIncome as $key => $value ) {
  621. if ($value ['accountMsg'] == '银行存款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  622. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  623. $sum += $value ['inComePrice'];
  624. $subtotal [$month] += $value ['inComePrice'];
  625. $falg = false;
  626. break;
  627. }
  628. }
  629. if ($falg)
  630. $html .= '<td class="taR">-</td>';
  631. }
  632. if ($sum == 0)
  633. $html .= '<td class="taR">-</td>';
  634. else
  635. $html .= '<td class="taR">¥' . $sum . '</td>';
  636. $html .= '</tr>';
  637. $html .= '<th width="90">理财收益</th>';
  638. $sum = 0;
  639. for($month = 1; $month <= $day; $month ++) {
  640. $falg = true;
  641. foreach ( $statisticsIncome as $key => $value ) {
  642. if ($value ['accountMsg'] == '理财收益' && $value ['day'] == $month && $value ['accountType'] == $i) {
  643. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  644. $sum += $value ['inComePrice'];
  645. $subtotal [$month] += $value ['inComePrice'];
  646. $falg = false;
  647. break;
  648. }
  649. }
  650. if ($falg)
  651. $html .= '<td class="taR">-</td>';
  652. }
  653. if ($sum == 0)
  654. $html .= '<td class="taR">-</td>';
  655. else
  656. $html .= '<td class="taR">¥' . $sum . '</td>';
  657. $html .= '</tr>';
  658. $html .= '<th width="90">个人借款</th>';
  659. $sum = 0;
  660. for($month = 1; $month <= $day; $month ++) {
  661. $falg = true;
  662. foreach ( $statisticsIncome as $key => $value ) {
  663. if ($value ['accountMsg'] == '个人借款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  664. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  665. $sum += $value ['inComePrice'];
  666. $subtotal [$month] += $value ['inComePrice'];
  667. $falg = false;
  668. break;
  669. }
  670. }
  671. if ($falg)
  672. $html .= '<td class="taR">-</td>';
  673. }
  674. if ($sum == 0)
  675. $html .= '<td class="taR">-</td>';
  676. else
  677. $html .= '<td class="taR">¥' . $sum . '</td>';
  678. $html .= '</tr>';
  679. $html .= '<th width="90" class="colGreen">小计</th>';
  680. $sum = 0;
  681. for($month = 1; $month <= $day; $month ++) {
  682. $sum += $subtotal [$month];
  683. $subtotalSum [$month] += $subtotal [$month];
  684. if (! empty ( $subtotal [$month] ))
  685. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  686. else
  687. $html .= '<td class="taR">-</td>';
  688. }
  689. if ($sum == 0)
  690. $html .= '<td class="taR">-</td>';
  691. else
  692. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  693. $html .= '</tr>';
  694. } elseif ($i == 2) {
  695. for($d = 1; $d <= $day; $d ++) {
  696. $subtotal [$d] = 0;
  697. }
  698. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  699. $html .= '<th width="90">社保</th>';
  700. $sum = 0;
  701. for($month = 1; $month <= $day; $month ++) {
  702. $falg = true;
  703. foreach ( $statisticsIncome as $key => $value ) {
  704. if ($value ['accountMsg'] == '社保' && $value ['day'] == $month && $value ['accountType'] == $i) {
  705. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  706. $sum += $value ['inComePrice'];
  707. $subtotal [$month] += $value ['inComePrice'];
  708. $falg = false;
  709. break;
  710. }
  711. }
  712. if ($falg)
  713. $html .= '<td class="taR">-</td>';
  714. }
  715. if ($sum == 0)
  716. $html .= '<td class="taR">-</td>';
  717. else
  718. $html .= '<td class="taR">¥' . $sum . '</td>';
  719. $html .= '</tr>';
  720. $html .= '<th width="90">财政</th>';
  721. $sum = 0;
  722. for($month = 1; $month <= $day; $month ++) {
  723. $falg = true;
  724. foreach ( $statisticsIncome as $key => $value ) {
  725. if ($value ['accountMsg'] == '财政' && $value ['day'] == $month && $value ['accountType'] == $i) {
  726. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  727. $sum += $value ['inComePrice'];
  728. $subtotal [$month] += $value ['inComePrice'];
  729. $falg = false;
  730. break;
  731. }
  732. }
  733. if ($falg)
  734. $html .= '<td class="taR">-</td>';
  735. }
  736. if ($sum == 0)
  737. $html .= '<td class="taR">-</td>';
  738. else
  739. $html .= '<td class="taR">¥' . $sum . '</td>';
  740. $html .= '</tr>';
  741. $html .= '<th width="90" class="colGreen">小计</th>';
  742. $sum = 0;
  743. for($month = 1; $month <= $day; $month ++) {
  744. $sum += $subtotal [$month];
  745. $subtotalSum [$month] += $subtotal [$month];
  746. if (! empty ( $subtotal [$month] ))
  747. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  748. else
  749. $html .= '<td class="taR">-</td>';
  750. }
  751. if ($sum == 0)
  752. $html .= '<td class="taR">-</td>';
  753. else
  754. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  755. $html .= '</tr>';
  756. } elseif ($i == 3) {
  757. $html .= '<tr><th colspan="2" >纵横知道</th>';
  758. $sum = 0;
  759. for($month = 1; $month <= $day; $month ++) {
  760. $falg = true;
  761. foreach ( $statisticsIncome as $key => $value ) {
  762. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  763. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  764. $sum += $value ['inComePrice'];
  765. $subtotalSum [$month] += $value ['inComePrice'];
  766. $falg = false;
  767. break;
  768. }
  769. }
  770. if ($falg)
  771. $html .= '<td class="taR">-</td>';
  772. }
  773. if ($sum == 0)
  774. $html .= '<td class="taR">-</td>';
  775. else
  776. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  777. $html .= '</tr>';
  778. } elseif ($i == 4) {
  779. for($d = 1; $d <= $day; $d ++) {
  780. $subtotal [$d] = 0;
  781. }
  782. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  783. $html .= '<th width="90">备用金</th>';
  784. $sum = 0;
  785. for($month = 1; $month <= $day; $month ++) {
  786. $falg = true;
  787. foreach ( $statisticsIncome as $key => $value ) {
  788. if ($value ['accountMsg'] == '备用金' && $value ['day'] == $month && $value ['accountType'] == $i) {
  789. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  790. $sum += $value ['inComePrice'];
  791. $subtotal [$month] += $value ['inComePrice'];
  792. $falg = false;
  793. break;
  794. }
  795. }
  796. if ($falg)
  797. $html .= '<td class="taR">-</td>';
  798. }
  799. if ($sum == 0)
  800. $html .= '<td class="taR">-</td>';
  801. else
  802. $html .= '<td class="taR">¥' . $sum . '</td>';
  803. $html .= '</tr>';
  804. $html .= '<th width="90">私人借款</th>';
  805. $sum = 0;
  806. for($month = 1; $month <= $day; $month ++) {
  807. $falg = true;
  808. foreach ( $statisticsIncome as $key => $value ) {
  809. if ($value ['accountMsg'] == '私人借款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  810. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  811. $sum += $value ['inComePrice'];
  812. $subtotal [$month] += $value ['inComePrice'];
  813. $falg = false;
  814. break;
  815. }
  816. }
  817. if ($falg)
  818. $html .= '<td class="taR">-</td>';
  819. }
  820. if ($sum == 0)
  821. $html .= '<td class="taR">-</td>';
  822. else
  823. $html .= '<td class="taR">¥' . $sum . '</td>';
  824. $html .= '</tr>';
  825. $html .= '<th width="90" class="colGreen">小计</th>';
  826. $sum = 0;
  827. for($month = 1; $month <= $day; $month ++) {
  828. $sum += $subtotal [$month];
  829. $subtotalSum [$month] += $subtotal [$month];
  830. if (! empty ( $subtotal [$month] ))
  831. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  832. else
  833. $html .= '<td class="taR">-</td>';
  834. }
  835. if ($sum == 0)
  836. $html .= '<td class="taR">-</td>';
  837. else
  838. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  839. $html .= '</tr>';
  840. } elseif ($i == 5) {
  841. $html .= '<tr><th colspan="2" >退汇</th>';
  842. $sum = 0;
  843. for($month = 1; $month <= $day; $month ++) {
  844. $falg = true;
  845. foreach ( $statisticsIncome as $key => $value ) {
  846. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  847. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  848. $sum += $value ['inComePrice'];
  849. $subtotalSum [$month] += $value ['inComePrice'];
  850. $falg = false;
  851. break;
  852. }
  853. }
  854. if ($falg)
  855. $html .= '<td class="taR">-</td>';
  856. }
  857. if ($sum == 0)
  858. $html .= '<td class="taR">-</td>';
  859. else
  860. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  861. $html .= '</tr>';
  862. } elseif ($i == 6) {
  863. $html .= '<tr><th colspan="2" >其他</th>';
  864. $sum = 0;
  865. for($month = 1; $month <= $day; $month ++) {
  866. $falg = true;
  867. foreach ( $statisticsIncome as $key => $value ) {
  868. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  869. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  870. $sum += $value ['inComePrice'];
  871. $subtotalSum [$month] += $value ['inComePrice'];
  872. $falg = false;
  873. break;
  874. }
  875. }
  876. if ($falg)
  877. $html .= '<td class="taR">-</td>';
  878. }
  879. if ($sum == 0)
  880. $html .= '<td class="taR">-</td>';
  881. else
  882. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  883. $html .= '</tr>';
  884. }elseif ($i == 8) {
  885. $html .= '<tr><th colspan="2" >保证金</th>';
  886. $sum = 0;
  887. for($month = 1; $month <= $day; $month ++) {
  888. $falg = true;
  889. foreach ( $statisticsIncome as $key => $value ) {
  890. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  891. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  892. $sum += $value ['inComePrice'];
  893. $subtotalSum [$month] += $value ['inComePrice'];
  894. $falg = false;
  895. break;
  896. }
  897. }
  898. if ($falg)
  899. $html .= '<td class="taR">-</td>';
  900. }
  901. if ($sum == 0)
  902. $html .= '<td class="taR">-</td>';
  903. else
  904. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  905. $html .= '</tr>';
  906. }
  907. }
  908. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  909. $sum = 0;
  910. foreach ( $subtotalSum as $key => $value ) {
  911. $sum += $value;
  912. if (! empty ( $value ))
  913. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  914. else
  915. $html .= '<td class="taR">-</td>';
  916. }
  917. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  918. $html .= '</tr>';
  919. $colspan = $day + 1;
  920. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  921. <td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  922. return array('html'=>$html,'sum'=>$sum);
  923. }
  924. function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
  925. $html = '<tr><th class="taC" colspan="2">日常支出</th>';
  926. for($d = 1; $d <= $day; $d ++) {
  927. $subtotalSum [$d] = 0;
  928. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  929. }
  930. $html .= '<th class="taC" width="110">总计</th></tr>';
  931. for($i = 1; $i <= 15; $i ++) {
  932. if ($i == 1) {
  933. $html .= '<tr><th colspan="2" >银行手续费</th>';
  934. $sum = 0;
  935. for($month = 1; $month <= $day; $month ++) {
  936. $falg = true;
  937. foreach ( $statisticsPay as $key => $value ) {
  938. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  939. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  940. $sum += $value ['payPrice'];
  941. $subtotalSum [$month] += $value ['payPrice'];
  942. $falg = false;
  943. break;
  944. }
  945. }
  946. if ($falg)
  947. $html .= '<td class="taR">-</td>';
  948. }
  949. if ($sum == 0)
  950. $html .= '<td class="taR">-</td>';
  951. else
  952. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  953. $html .= '</tr>';
  954. } elseif ($i == 2) {
  955. $html .= '<tr><th colspan="2" >总部电话费</th>';
  956. $sum = 0;
  957. for($month = 1; $month <= $day; $month ++) {
  958. $falg = true;
  959. foreach ( $statisticsPay as $key => $value ) {
  960. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  961. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  962. $sum += $value ['payPrice'];
  963. $subtotalSum [$month] += $value ['payPrice'];
  964. $falg = false;
  965. break;
  966. }
  967. }
  968. if ($falg)
  969. $html .= '<td class="taR">-</td>';
  970. }
  971. if ($sum == 0)
  972. $html .= '<td class="taR">-</td>';
  973. else
  974. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  975. $html .= '</tr>';
  976. } elseif ($i == 3) {
  977. for($d = 1; $d <= $day; $d ++) {
  978. $subtotal [$d] = 0;
  979. }
  980. $html .= '<tr><th rowspan="4" width="90">缴税</th>';
  981. $html .= '<th width="90">增值税</th>';
  982. $sum = 0;
  983. for($month = 1; $month <= $day; $month ++) {
  984. $falg = true;
  985. foreach ( $statisticsPay as $key => $value ) {
  986. if ($value ['expenditureMsg'] == '增值税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  987. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  988. $sum += $value ['payPrice'];
  989. $subtotal [$month] += $value ['payPrice'];
  990. $falg = false;
  991. break;
  992. }
  993. }
  994. if ($falg)
  995. $html .= '<td class="taR">-</td>';
  996. }
  997. if ($sum == 0)
  998. $html .= '<td class="taR">-</td>';
  999. else
  1000. $html .= '<td class="taR">¥' . $sum . '</td>';
  1001. $html .= '</tr>';
  1002. $html .= '<th width="90">税金附加</th>';
  1003. $sum = 0;
  1004. for($month = 1; $month <= $day; $month ++) {
  1005. $falg = true;
  1006. foreach ( $statisticsPay as $key => $value ) {
  1007. if ($value ['expenditureMsg'] == '税金附加' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1008. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1009. $sum += $value ['payPrice'];
  1010. $subtotal [$month] += $value ['payPrice'];
  1011. $falg = false;
  1012. break;
  1013. }
  1014. }
  1015. if ($falg)
  1016. $html .= '<td class="taR">-</td>';
  1017. }
  1018. if ($sum == 0)
  1019. $html .= '<td class="taR">-</td>';
  1020. else
  1021. $html .= '<td class="taR">¥' . $sum . '</td>';
  1022. $html .= '</tr>';
  1023. $html .= '<th width="90">企业所得税</th>';
  1024. $sum = 0;
  1025. for($month = 1; $month <= $day; $month ++) {
  1026. $falg = true;
  1027. foreach ( $statisticsPay as $key => $value ) {
  1028. if ($value ['expenditureMsg'] == '企业所得税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1029. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1030. $sum += $value ['payPrice'];
  1031. $subtotal [$month] += $value ['payPrice'];
  1032. $falg = false;
  1033. break;
  1034. }
  1035. }
  1036. if ($falg)
  1037. $html .= '<td class="taR">-</td>';
  1038. }
  1039. if ($sum == 0)
  1040. $html .= '<td class="taR">-</td>';
  1041. else
  1042. $html .= '<td class="taR">¥' . $sum . '</td>';
  1043. $html .= '</tr>';
  1044. $html .= '<th width="90" class="colRed">小计</th>';
  1045. $sum = 0;
  1046. for($month = 1; $month <= $day; $month ++) {
  1047. $sum += $subtotal [$month];
  1048. $subtotalSum [$month] += $subtotal [$month];
  1049. if (! empty ( $subtotal [$month] ))
  1050. $html .= '<td class="taR colRed">¥' . $subtotal [$month] . '</td>';
  1051. else
  1052. $html .= '<td class="taR">-</td>';
  1053. }
  1054. if ($sum == 0)
  1055. $html .= '<td class="taR">-</td>';
  1056. else
  1057. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1058. $html .= '</tr>';
  1059. }elseif ($i == 5) {
  1060. $html .= '<tr><th colspan="2" >保证金</th>';
  1061. $sum = 0;
  1062. for($month = 1; $month <= $day; $month ++) {
  1063. $falg = true;
  1064. foreach ( $statisticsPay as $key => $value ) {
  1065. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1066. $html .= '<td class="taR">¥' . abs($value ['payPrice']) . '</td>';
  1067. $sum += abs($value ['payPrice']);
  1068. $subtotalSum [$month] += abs($value ['payPrice']);
  1069. $falg = false;
  1070. break;
  1071. }
  1072. }
  1073. if ($falg)
  1074. $html .= '<td class="taR">-</td>';
  1075. }
  1076. if ($sum == 0)
  1077. $html .= '<td class="taR">-</td>';
  1078. else
  1079. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1080. $html .= '</tr>';
  1081. }
  1082. }
  1083. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1084. $sum = 0;
  1085. foreach ( $subtotalSum as $key => $value ) {
  1086. $sum += $value;
  1087. if (! empty ( $value ))
  1088. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1089. else
  1090. $html .= '<td class="taR">-</td>';
  1091. }
  1092. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1093. $html .= '</tr>';
  1094. $colspan = $day + 1;
  1095. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  1096. <td class="colGreed taR" colspan="'.$colspan.'"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1097. return array('html'=>$html,'sum'=>$sum);
  1098. }
  1099. /**
  1100. * 数据导出
  1101. * @param array $title 标题行名称
  1102. * @param array $data 导出数据
  1103. * @param string $fileName 文件名
  1104. * @param string $savePath 保存路径
  1105. * @param $type 是否下载 false--保存 true--下载
  1106. * @return string 返回文件全路径
  1107. * @throws PHPExcel_Exception
  1108. * @throws PHPExcel_Reader_Exception @exportExcel(array('姓名','年龄'), array(array('a',21),array('b',23)), '档案', './', true);
  1109. */
  1110. function exportExcel($title = array(), $data = array(), $fileName = '', $savePath = './', $isDown = false) {
  1111. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  1112. $obj = new PHPExcel ();
  1113. // 横向单元格标识
  1114. $cellName = array (
  1115. 'A',
  1116. 'B',
  1117. 'C',
  1118. 'D',
  1119. 'E',
  1120. 'F',
  1121. 'G',
  1122. 'H',
  1123. 'I',
  1124. 'J',
  1125. 'K',
  1126. 'L',
  1127. 'M',
  1128. 'N',
  1129. 'O',
  1130. 'P',
  1131. 'Q',
  1132. 'R',
  1133. 'S',
  1134. 'T',
  1135. 'U',
  1136. 'V',
  1137. 'W',
  1138. 'X',
  1139. 'Y',
  1140. 'Z',
  1141. 'AA',
  1142. 'AB',
  1143. 'AC',
  1144. 'AD',
  1145. 'AE',
  1146. 'AF',
  1147. 'AG',
  1148. 'AH',
  1149. 'AI',
  1150. 'AJ',
  1151. 'AK',
  1152. 'AL',
  1153. 'AM',
  1154. 'AN',
  1155. 'AO',
  1156. 'AP',
  1157. 'AQ',
  1158. 'AR',
  1159. 'AS',
  1160. 'AT',
  1161. 'AU',
  1162. 'AV',
  1163. 'AW',
  1164. 'AX',
  1165. 'AY',
  1166. 'AZ'
  1167. );
  1168. $obj->getActiveSheet ( 0 )->setTitle ( 'sheet名称' ); // 设置sheet名称
  1169. $_row = 0; // 设置纵向单元格标识
  1170. if ($title) {
  1171. $_cnt = count ( $title );
  1172. // $obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //合并单元格
  1173. // $obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '数据导出:'.date('Y-m-d H:i:s')); //设置合并后的单元格内容
  1174. $_row ++;
  1175. $i = 0;
  1176. foreach ( $title as $v ) { // 设置列标题
  1177. $obj->setActiveSheetIndex ( 0 )->setCellValue ( $cellName [$i] . $_row, $v );
  1178. $i ++;
  1179. }
  1180. $_row ++;
  1181. }
  1182. ;
  1183. // html_entity_decode("&iuml;&raquo;&iquest;".$value['order_id']);
  1184. // 填写数据
  1185. if ($data) {
  1186. $i = 0;
  1187. foreach ( $data as $_v ) {
  1188. $j = 0;
  1189. foreach ( $_v as $_cell ) {
  1190. $obj->getActiveSheet ( 0 )->setCellValueExplicit ( $cellName [$j] . ($i + $_row), $_cell, PHPExcel_Cell_DataType::TYPE_STRING );
  1191. $j ++;
  1192. }
  1193. $i ++;
  1194. }
  1195. }
  1196. // 文件名处理
  1197. if (! $fileName) {
  1198. $fileName = uniqid ( time (), true );
  1199. }
  1200. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  1201. if ($isDown) { // 网页下载
  1202. header ( 'pragma:public' );
  1203. header ( "Content-Disposition:attachment;filename=$fileName.xls" );
  1204. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  1205. $objWrite->save ( 'php://output' );
  1206. exit ();
  1207. }
  1208. $_fileName = iconv ( "utf-8", "gb2312", $fileName ); // 转码
  1209. $_savePath = $savePath . $_fileName . '.xlsx';
  1210. $objWrite->save ( $_savePath );
  1211. return $savePath . $fileName . '.xlsx';
  1212. }
  1213. ?>