receipt.func.php 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  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">¥' . $value ['payPrice'] . '</td>';
  165. $sum += $value ['payPrice'];
  166. $subtotalSum [$month] += $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" class="colGreen">小计</th>';
  298. $sum = 0;
  299. for($month = 1; $month <= 12; $month ++) {
  300. $sum += $subtotal [$month];
  301. $subtotalSum [$month] += $subtotal [$month];
  302. if (! empty ( $subtotal [$month] ))
  303. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  304. else
  305. $html .= '<td class="taR">-</td>';
  306. }
  307. if ($sum == 0)
  308. $html .= '<td class="taR">-</td>';
  309. else
  310. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  311. $html .= '</tr>';
  312. } elseif ($i == 2) {
  313. $subtotal = array (
  314. 1 => 0,
  315. 2 => 0,
  316. 3 => 0,
  317. 4 => 0,
  318. 5 => 0,
  319. 6 => 0,
  320. 7 => 0,
  321. 8 => 0,
  322. 9 => 0,
  323. 10 => 0,
  324. 11 => 0,
  325. 12 => 0
  326. );
  327. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  328. $html .= '<th width="90">社保</th>';
  329. $sum = 0;
  330. for($month = 1; $month <= 12; $month ++) {
  331. $falg = true;
  332. foreach ( $statisticsIncome as $key => $value ) {
  333. if ($value ['accountMsg'] == '社保' && $value ['month'] == $month && $value ['accountType'] == $i) {
  334. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  335. $sum += $value ['inComePrice'];
  336. $subtotal [$month] += $value ['inComePrice'];
  337. $falg = false;
  338. break;
  339. }
  340. }
  341. if ($falg)
  342. $html .= '<td class="taR">-</td>';
  343. }
  344. if ($sum == 0)
  345. $html .= '<td class="taR">-</td>';
  346. else
  347. $html .= '<td class="taR">¥' . $sum . '</td>';
  348. $html .= '</tr>';
  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" class="colGreen">小计</th>';
  371. $sum = 0;
  372. for($month = 1; $month <= 12; $month ++) {
  373. $sum += $subtotal [$month];
  374. $subtotalSum [$month] += $subtotal [$month];
  375. if (! empty ( $subtotal [$month] ))
  376. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  377. else
  378. $html .= '<td class="taR">-</td>';
  379. }
  380. if ($sum == 0)
  381. $html .= '<td class="taR">-</td>';
  382. else
  383. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  384. $html .= '</tr>';
  385. } elseif ($i == 3) {
  386. $html .= '<tr><th colspan="2" >纵横知道</th>';
  387. $sum = 0;
  388. for($month = 1; $month <= 12; $month ++) {
  389. $falg = true;
  390. foreach ( $statisticsIncome as $key => $value ) {
  391. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  392. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  393. $sum += $value ['inComePrice'];
  394. $subtotalSum [$month] += $value ['inComePrice'];
  395. $falg = false;
  396. break;
  397. }
  398. }
  399. if ($falg)
  400. $html .= '<td class="taR">-</td>';
  401. }
  402. if ($sum == 0)
  403. $html .= '<td class="taR">-</td>';
  404. else
  405. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  406. $html .= '</tr>';
  407. } elseif ($i == 4) {
  408. $subtotal = array (
  409. 1 => 0,
  410. 2 => 0,
  411. 3 => 0,
  412. 4 => 0,
  413. 5 => 0,
  414. 6 => 0,
  415. 7 => 0,
  416. 8 => 0,
  417. 9 => 0,
  418. 10 => 0,
  419. 11 => 0,
  420. 12 => 0
  421. );
  422. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  423. $html .= '<th width="90">备用金</th>';
  424. $sum = 0;
  425. for($month = 1; $month <= 12; $month ++) {
  426. $falg = true;
  427. foreach ( $statisticsIncome as $key => $value ) {
  428. if ($value ['accountMsg'] == '备用金' && $value ['month'] == $month && $value ['accountType'] == $i) {
  429. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  430. $sum += $value ['inComePrice'];
  431. $subtotal [$month] += $value ['inComePrice'];
  432. $falg = false;
  433. break;
  434. }
  435. }
  436. if ($falg)
  437. $html .= '<td class="taR">-</td>';
  438. }
  439. if ($sum == 0)
  440. $html .= '<td class="taR">-</td>';
  441. else
  442. $html .= '<td class="taR">¥' . $sum . '</td>';
  443. $html .= '</tr>';
  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" class="colGreen">小计</th>';
  466. $sum = 0;
  467. for($month = 1; $month <= 12; $month ++) {
  468. $sum += $subtotal [$month];
  469. $subtotalSum [$month] += $subtotal [$month];
  470. if (! empty ( $subtotal [$month] ))
  471. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  472. else
  473. $html .= '<td class="taR">-</td>';
  474. }
  475. if ($sum == 0)
  476. $html .= '<td class="taR">-</td>';
  477. else
  478. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  479. $html .= '</tr>';
  480. } elseif ($i == 5) {
  481. $html .= '<tr><th colspan="2" >退汇</th>';
  482. $sum = 0;
  483. for($month = 1; $month <= 12; $month ++) {
  484. $falg = true;
  485. foreach ( $statisticsIncome as $key => $value ) {
  486. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  487. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  488. $sum += $value ['inComePrice'];
  489. $subtotalSum [$month] += $value ['inComePrice'];
  490. $falg = false;
  491. break;
  492. }
  493. }
  494. if ($falg)
  495. $html .= '<td class="taR">-</td>';
  496. }
  497. if ($sum == 0)
  498. $html .= '<td class="taR">-</td>';
  499. else
  500. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  501. $html .= '</tr>';
  502. } elseif ($i == 6) {
  503. $html .= '<tr><th colspan="2" >其他</th>';
  504. $sum = 0;
  505. for($month = 1; $month <= 12; $month ++) {
  506. $falg = true;
  507. foreach ( $statisticsIncome as $key => $value ) {
  508. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  509. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  510. $sum += $value ['inComePrice'];
  511. $subtotalSum [$month] += $value ['inComePrice'];
  512. $falg = false;
  513. break;
  514. }
  515. }
  516. if ($falg)
  517. $html .= '<td class="taR">-</td>';
  518. }
  519. if ($sum == 0)
  520. $html .= '<td class="taR">-</td>';
  521. else
  522. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  523. $html .= '</tr>';
  524. } elseif ($i == 8) {
  525. $html .= '<tr><th colspan="2" >保证金</th>';
  526. $sum = 0;
  527. for($month = 1; $month <= 12; $month ++) {
  528. $falg = true;
  529. foreach ( $statisticsIncome as $key => $value ) {
  530. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  531. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  532. $sum += $value ['inComePrice'];
  533. $subtotalSum [$month] += $value ['inComePrice'];
  534. $falg = false;
  535. break;
  536. }
  537. }
  538. if ($falg)
  539. $html .= '<td class="taR">-</td>';
  540. }
  541. if ($sum == 0)
  542. $html .= '<td class="taR">-</td>';
  543. else
  544. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  545. $html .= '</tr>';
  546. }
  547. }
  548. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  549. $sum = 0;
  550. foreach ( $subtotalSum as $key => $value ) {
  551. $sum += $value;
  552. if (! empty ( $value ))
  553. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  554. else
  555. $html .= '<td class="taR">-</td>';
  556. }
  557. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  558. $html .= '</tr>';
  559. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  560. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  561. return array('html'=>$html,'sum'=>$sum);
  562. }
  563. /**
  564. * 获得汇总 日常收支年
  565. * @param array $statisticsIncome
  566. * @return string
  567. */
  568. function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
  569. $html = '<tr><th class="taC" colspan="2">日常收入</th>';
  570. for($d = 1; $d <= $day; $d ++) {
  571. $subtotalSum [$d] = 0;
  572. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  573. }
  574. $html .= '<th class="taC" width="110">总计</th></tr>';
  575. for($i = 1; $i <= 15; $i ++) {
  576. if ($i == 1) {
  577. for($d = 1; $d <= $day; $d ++) {
  578. $subtotal [$d] = 0;
  579. }
  580. // $subtotal = array (
  581. // 1 => 0,
  582. // 2 => 0,
  583. // 3 => 0,
  584. // 4 => 0,
  585. // 5 => 0,
  586. // 6 => 0,
  587. // 7 => 0,
  588. // 8 => 0,
  589. // 9 => 0,
  590. // 10 => 0,
  591. // 11 => 0,
  592. // 12 => 0
  593. // );
  594. $html .= '<tr><th rowspan="4" width="90">利息收入</th>';
  595. $html .= '<th width="90">银行存款</th>';
  596. $sum = 0;
  597. for($month = 1; $month <= $day; $month ++) {
  598. $falg = true;
  599. foreach ( $statisticsIncome as $key => $value ) {
  600. if ($value ['accountMsg'] == '银行存款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  601. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  602. $sum += $value ['inComePrice'];
  603. $subtotal [$month] += $value ['inComePrice'];
  604. $falg = false;
  605. break;
  606. }
  607. }
  608. if ($falg)
  609. $html .= '<td class="taR">-</td>';
  610. }
  611. if ($sum == 0)
  612. $html .= '<td class="taR">-</td>';
  613. else
  614. $html .= '<td class="taR">¥' . $sum . '</td>';
  615. $html .= '</tr>';
  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" class="colGreen">小计</th>';
  659. $sum = 0;
  660. for($month = 1; $month <= $day; $month ++) {
  661. $sum += $subtotal [$month];
  662. $subtotalSum [$month] += $subtotal [$month];
  663. if (! empty ( $subtotal [$month] ))
  664. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  665. else
  666. $html .= '<td class="taR">-</td>';
  667. }
  668. if ($sum == 0)
  669. $html .= '<td class="taR">-</td>';
  670. else
  671. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  672. $html .= '</tr>';
  673. } elseif ($i == 2) {
  674. for($d = 1; $d <= $day; $d ++) {
  675. $subtotal [$d] = 0;
  676. }
  677. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  678. $html .= '<th width="90">社保</th>';
  679. $sum = 0;
  680. for($month = 1; $month <= $day; $month ++) {
  681. $falg = true;
  682. foreach ( $statisticsIncome as $key => $value ) {
  683. if ($value ['accountMsg'] == '社保' && $value ['day'] == $month && $value ['accountType'] == $i) {
  684. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  685. $sum += $value ['inComePrice'];
  686. $subtotal [$month] += $value ['inComePrice'];
  687. $falg = false;
  688. break;
  689. }
  690. }
  691. if ($falg)
  692. $html .= '<td class="taR">-</td>';
  693. }
  694. if ($sum == 0)
  695. $html .= '<td class="taR">-</td>';
  696. else
  697. $html .= '<td class="taR">¥' . $sum . '</td>';
  698. $html .= '</tr>';
  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" class="colGreen">小计</th>';
  721. $sum = 0;
  722. for($month = 1; $month <= $day; $month ++) {
  723. $sum += $subtotal [$month];
  724. $subtotalSum [$month] += $subtotal [$month];
  725. if (! empty ( $subtotal [$month] ))
  726. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  727. else
  728. $html .= '<td class="taR">-</td>';
  729. }
  730. if ($sum == 0)
  731. $html .= '<td class="taR">-</td>';
  732. else
  733. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  734. $html .= '</tr>';
  735. } elseif ($i == 3) {
  736. $html .= '<tr><th colspan="2" >纵横知道</th>';
  737. $sum = 0;
  738. for($month = 1; $month <= $day; $month ++) {
  739. $falg = true;
  740. foreach ( $statisticsIncome as $key => $value ) {
  741. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  742. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  743. $sum += $value ['inComePrice'];
  744. $subtotalSum [$month] += $value ['inComePrice'];
  745. $falg = false;
  746. break;
  747. }
  748. }
  749. if ($falg)
  750. $html .= '<td class="taR">-</td>';
  751. }
  752. if ($sum == 0)
  753. $html .= '<td class="taR">-</td>';
  754. else
  755. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  756. $html .= '</tr>';
  757. } elseif ($i == 4) {
  758. for($d = 1; $d <= $day; $d ++) {
  759. $subtotal [$d] = 0;
  760. }
  761. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  762. $html .= '<th width="90">备用金</th>';
  763. $sum = 0;
  764. for($month = 1; $month <= $day; $month ++) {
  765. $falg = true;
  766. foreach ( $statisticsIncome as $key => $value ) {
  767. if ($value ['accountMsg'] == '备用金' && $value ['day'] == $month && $value ['accountType'] == $i) {
  768. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  769. $sum += $value ['inComePrice'];
  770. $subtotal [$month] += $value ['inComePrice'];
  771. $falg = false;
  772. break;
  773. }
  774. }
  775. if ($falg)
  776. $html .= '<td class="taR">-</td>';
  777. }
  778. if ($sum == 0)
  779. $html .= '<td class="taR">-</td>';
  780. else
  781. $html .= '<td class="taR">¥' . $sum . '</td>';
  782. $html .= '</tr>';
  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" class="colGreen">小计</th>';
  805. $sum = 0;
  806. for($month = 1; $month <= $day; $month ++) {
  807. $sum += $subtotal [$month];
  808. $subtotalSum [$month] += $subtotal [$month];
  809. if (! empty ( $subtotal [$month] ))
  810. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  811. else
  812. $html .= '<td class="taR">-</td>';
  813. }
  814. if ($sum == 0)
  815. $html .= '<td class="taR">-</td>';
  816. else
  817. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  818. $html .= '</tr>';
  819. } elseif ($i == 5) {
  820. $html .= '<tr><th colspan="2" >退汇</th>';
  821. $sum = 0;
  822. for($month = 1; $month <= $day; $month ++) {
  823. $falg = true;
  824. foreach ( $statisticsIncome as $key => $value ) {
  825. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  826. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  827. $sum += $value ['inComePrice'];
  828. $subtotalSum [$month] += $value ['inComePrice'];
  829. $falg = false;
  830. break;
  831. }
  832. }
  833. if ($falg)
  834. $html .= '<td class="taR">-</td>';
  835. }
  836. if ($sum == 0)
  837. $html .= '<td class="taR">-</td>';
  838. else
  839. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  840. $html .= '</tr>';
  841. } elseif ($i == 6) {
  842. $html .= '<tr><th colspan="2" >其他</th>';
  843. $sum = 0;
  844. for($month = 1; $month <= $day; $month ++) {
  845. $falg = true;
  846. foreach ( $statisticsIncome as $key => $value ) {
  847. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  848. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  849. $sum += $value ['inComePrice'];
  850. $subtotalSum [$month] += $value ['inComePrice'];
  851. $falg = false;
  852. break;
  853. }
  854. }
  855. if ($falg)
  856. $html .= '<td class="taR">-</td>';
  857. }
  858. if ($sum == 0)
  859. $html .= '<td class="taR">-</td>';
  860. else
  861. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  862. $html .= '</tr>';
  863. }elseif ($i == 8) {
  864. $html .= '<tr><th colspan="2" >保证金</th>';
  865. $sum = 0;
  866. for($month = 1; $month <= $day; $month ++) {
  867. $falg = true;
  868. foreach ( $statisticsIncome as $key => $value ) {
  869. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  870. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  871. $sum += $value ['inComePrice'];
  872. $subtotalSum [$month] += $value ['inComePrice'];
  873. $falg = false;
  874. break;
  875. }
  876. }
  877. if ($falg)
  878. $html .= '<td class="taR">-</td>';
  879. }
  880. if ($sum == 0)
  881. $html .= '<td class="taR">-</td>';
  882. else
  883. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  884. $html .= '</tr>';
  885. }
  886. }
  887. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  888. $sum = 0;
  889. foreach ( $subtotalSum as $key => $value ) {
  890. $sum += $value;
  891. if (! empty ( $value ))
  892. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  893. else
  894. $html .= '<td class="taR">-</td>';
  895. }
  896. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  897. $html .= '</tr>';
  898. $colspan = $day + 1;
  899. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  900. <td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  901. return array('html'=>$html,'sum'=>$sum);
  902. }
  903. function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
  904. $html = '<tr><th class="taC" colspan="2">日常支出</th>';
  905. for($d = 1; $d <= $day; $d ++) {
  906. $subtotalSum [$d] = 0;
  907. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  908. }
  909. $html .= '<th class="taC" width="110">总计</th></tr>';
  910. for($i = 1; $i <= 15; $i ++) {
  911. if ($i == 1) {
  912. $html .= '<tr><th colspan="2" >银行手续费</th>';
  913. $sum = 0;
  914. for($month = 1; $month <= $day; $month ++) {
  915. $falg = true;
  916. foreach ( $statisticsPay as $key => $value ) {
  917. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  918. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  919. $sum += $value ['payPrice'];
  920. $subtotalSum [$month] += $value ['payPrice'];
  921. $falg = false;
  922. break;
  923. }
  924. }
  925. if ($falg)
  926. $html .= '<td class="taR">-</td>';
  927. }
  928. if ($sum == 0)
  929. $html .= '<td class="taR">-</td>';
  930. else
  931. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  932. $html .= '</tr>';
  933. } elseif ($i == 2) {
  934. $html .= '<tr><th colspan="2" >总部电话费</th>';
  935. $sum = 0;
  936. for($month = 1; $month <= $day; $month ++) {
  937. $falg = true;
  938. foreach ( $statisticsPay as $key => $value ) {
  939. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  940. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  941. $sum += $value ['payPrice'];
  942. $subtotalSum [$month] += $value ['payPrice'];
  943. $falg = false;
  944. break;
  945. }
  946. }
  947. if ($falg)
  948. $html .= '<td class="taR">-</td>';
  949. }
  950. if ($sum == 0)
  951. $html .= '<td class="taR">-</td>';
  952. else
  953. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  954. $html .= '</tr>';
  955. } elseif ($i == 3) {
  956. for($d = 1; $d <= $day; $d ++) {
  957. $subtotal [$d] = 0;
  958. }
  959. $html .= '<tr><th rowspan="4" width="90">缴税</th>';
  960. $html .= '<th width="90">增值税</th>';
  961. $sum = 0;
  962. for($month = 1; $month <= $day; $month ++) {
  963. $falg = true;
  964. foreach ( $statisticsPay as $key => $value ) {
  965. if ($value ['expenditureMsg'] == '增值税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  966. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  967. $sum += $value ['payPrice'];
  968. $subtotal [$month] += $value ['payPrice'];
  969. $falg = false;
  970. break;
  971. }
  972. }
  973. if ($falg)
  974. $html .= '<td class="taR">-</td>';
  975. }
  976. if ($sum == 0)
  977. $html .= '<td class="taR">-</td>';
  978. else
  979. $html .= '<td class="taR">¥' . $sum . '</td>';
  980. $html .= '</tr>';
  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" class="colRed">小计</th>';
  1024. $sum = 0;
  1025. for($month = 1; $month <= $day; $month ++) {
  1026. $sum += $subtotal [$month];
  1027. $subtotalSum [$month] += $subtotal [$month];
  1028. if (! empty ( $subtotal [$month] ))
  1029. $html .= '<td class="taR colRed">¥' . $subtotal [$month] . '</td>';
  1030. else
  1031. $html .= '<td class="taR">-</td>';
  1032. }
  1033. if ($sum == 0)
  1034. $html .= '<td class="taR">-</td>';
  1035. else
  1036. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1037. $html .= '</tr>';
  1038. }elseif ($i == 5) {
  1039. $html .= '<tr><th colspan="2" >保证金</th>';
  1040. $sum = 0;
  1041. for($month = 1; $month <= $day; $month ++) {
  1042. $falg = true;
  1043. foreach ( $statisticsPay as $key => $value ) {
  1044. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1045. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1046. $sum += $value ['payPrice'];
  1047. $subtotalSum [$month] += $value ['payPrice'];
  1048. $falg = false;
  1049. break;
  1050. }
  1051. }
  1052. if ($falg)
  1053. $html .= '<td class="taR">-</td>';
  1054. }
  1055. if ($sum == 0)
  1056. $html .= '<td class="taR">-</td>';
  1057. else
  1058. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1059. $html .= '</tr>';
  1060. }
  1061. }
  1062. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1063. $sum = 0;
  1064. foreach ( $subtotalSum as $key => $value ) {
  1065. $sum += $value;
  1066. if (! empty ( $value ))
  1067. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1068. else
  1069. $html .= '<td class="taR">-</td>';
  1070. }
  1071. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1072. $html .= '</tr>';
  1073. $colspan = $day + 1;
  1074. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  1075. <td class="colGreed taR" colspan="'.$colspan.'"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1076. return array('html'=>$html,'sum'=>$sum);
  1077. }
  1078. /**
  1079. * 数据导出
  1080. * @param array $title 标题行名称
  1081. * @param array $data 导出数据
  1082. * @param string $fileName 文件名
  1083. * @param string $savePath 保存路径
  1084. * @param $type 是否下载 false--保存 true--下载
  1085. * @return string 返回文件全路径
  1086. * @throws PHPExcel_Exception
  1087. * @throws PHPExcel_Reader_Exception @exportExcel(array('姓名','年龄'), array(array('a',21),array('b',23)), '档案', './', true);
  1088. */
  1089. function exportExcel($title = array(), $data = array(), $fileName = '', $savePath = './', $isDown = false) {
  1090. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  1091. $obj = new PHPExcel ();
  1092. // 横向单元格标识
  1093. $cellName = array (
  1094. 'A',
  1095. 'B',
  1096. 'C',
  1097. 'D',
  1098. 'E',
  1099. 'F',
  1100. 'G',
  1101. 'H',
  1102. 'I',
  1103. 'J',
  1104. 'K',
  1105. 'L',
  1106. 'M',
  1107. 'N',
  1108. 'O',
  1109. 'P',
  1110. 'Q',
  1111. 'R',
  1112. 'S',
  1113. 'T',
  1114. 'U',
  1115. 'V',
  1116. 'W',
  1117. 'X',
  1118. 'Y',
  1119. 'Z',
  1120. 'AA',
  1121. 'AB',
  1122. 'AC',
  1123. 'AD',
  1124. 'AE',
  1125. 'AF',
  1126. 'AG',
  1127. 'AH',
  1128. 'AI',
  1129. 'AJ',
  1130. 'AK',
  1131. 'AL',
  1132. 'AM',
  1133. 'AN',
  1134. 'AO',
  1135. 'AP',
  1136. 'AQ',
  1137. 'AR',
  1138. 'AS',
  1139. 'AT',
  1140. 'AU',
  1141. 'AV',
  1142. 'AW',
  1143. 'AX',
  1144. 'AY',
  1145. 'AZ'
  1146. );
  1147. $obj->getActiveSheet ( 0 )->setTitle ( 'sheet名称' ); // 设置sheet名称
  1148. $_row = 0; // 设置纵向单元格标识
  1149. if ($title) {
  1150. $_cnt = count ( $title );
  1151. // $obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //合并单元格
  1152. // $obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '数据导出:'.date('Y-m-d H:i:s')); //设置合并后的单元格内容
  1153. $_row ++;
  1154. $i = 0;
  1155. foreach ( $title as $v ) { // 设置列标题
  1156. $obj->setActiveSheetIndex ( 0 )->setCellValue ( $cellName [$i] . $_row, $v );
  1157. $i ++;
  1158. }
  1159. $_row ++;
  1160. }
  1161. ;
  1162. // html_entity_decode("&iuml;&raquo;&iquest;".$value['order_id']);
  1163. // 填写数据
  1164. if ($data) {
  1165. $i = 0;
  1166. foreach ( $data as $_v ) {
  1167. $j = 0;
  1168. foreach ( $_v as $_cell ) {
  1169. $obj->getActiveSheet ( 0 )->setCellValueExplicit ( $cellName [$j] . ($i + $_row), $_cell, PHPExcel_Cell_DataType::TYPE_STRING );
  1170. $j ++;
  1171. }
  1172. $i ++;
  1173. }
  1174. }
  1175. // 文件名处理
  1176. if (! $fileName) {
  1177. $fileName = uniqid ( time (), true );
  1178. }
  1179. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  1180. if ($isDown) { // 网页下载
  1181. header ( 'pragma:public' );
  1182. header ( "Content-Disposition:attachment;filename=$fileName.xls" );
  1183. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  1184. $objWrite->save ( 'php://output' );
  1185. exit ();
  1186. }
  1187. $_fileName = iconv ( "utf-8", "gb2312", $fileName ); // 转码
  1188. $_savePath = $savePath . $_fileName . '.xlsx';
  1189. $objWrite->save ( $_savePath );
  1190. return $savePath . $fileName . '.xlsx';
  1191. }
  1192. ?>