receipt.func.php 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408
  1. <?php
  2. /*
  3. * 办事处汇总明细
  4. */
  5. function _getReceiptSummaryHtml($cglist,$aiAllList,$dataSummary){
  6. $html='';
  7. foreach ($cglist as $cgk=>$value){
  8. //初始化年合计数组
  9. foreach ($aiAllList as $yptempk=>$yptempv){
  10. $yearPriceArray[$yptempk]=0;
  11. //栏目细则
  12. foreach ($yptempv as $k=>$v){
  13. $yearPriceArray[$yptempk][$v['name']]=0;
  14. }
  15. }
  16. //办事处每月数据展示
  17. $summaryDateHtml='';
  18. for($month=1;$month<=12;$month++){
  19. $summaryDateHtml.='<tr>';
  20. $summaryDateHtml.='<th>'.$value['title'].$month.'月合计</th>
  21. <td class="taR"></td>
  22. <td class="taR"></td>
  23. <td class="taR"></td>
  24. <td class="taR"></td>
  25. <td class="taR"></td>
  26. <td class="taR colGreen"></td>';
  27. $itemHtml='';
  28. if(isset($dataSummary[$value['cid']])){
  29. foreach ($aiAllList as $aiak=>$aiav){//总项目
  30. $tempHtml='';$tempPrice=0;
  31. foreach ($aiav as $k=>$v){//项目细则
  32. $falg=true;
  33. foreach ($dataSummary[$value['cid']][$month][$aiak] as $dsk=>$dsv){//数据实体
  34. if($dsv['item']==$v['name']){
  35. $tempHtml.='<td class="taR">'.$dsv['price'].'</td>';
  36. $tempPrice+=$dsv['price'];
  37. $yearPriceArray[$aiak][$v['name']]+=$dsv['price'];//该办事处项目细则金额合计
  38. $falg=false;
  39. break;
  40. }
  41. }
  42. if($falg){
  43. $tempHtml.='<td class="taR"></td>';
  44. }
  45. }
  46. $yearPriceArray[$aiak]+=$tempPrice;
  47. $itemHtml.='<td class="taR colRed">'.$tempPrice.'</td>';//每个月份 项目金额合计
  48. $itemHtml.=$tempHtml;//每个月份项目细则金额
  49. }
  50. }else{
  51. foreach ($aiAllList as $aiak=>$aiav){
  52. $itemHtml.='<td class="taR colRed"></td>';
  53. foreach ($aiav as $k=>$v){
  54. $itemHtml.='<td class="taR"></td>';
  55. }
  56. }
  57. }
  58. $summaryDateHtml.=$itemHtml;
  59. $summaryDateHtml.='</tr>';
  60. }
  61. //办事处全年合计
  62. $summaryYearHtml='<tr><th>'.$value['title'].'年合计</th>
  63. <td class="taR"></td>
  64. <td class="taR"></td>
  65. <td class="taR"></td>
  66. <td class="taR"></td>
  67. <td class="taR"></td>
  68. <td class="taR colGreen"></td>';
  69. foreach ($aiAllList as $aalk=>$aalv){
  70. //栏目
  71. $summaryYearHtml.='<td class="taR colRed">'.$yearPriceArray[$aalk].'</td>';
  72. //栏目细则
  73. foreach ($aalv as $k=>$v){
  74. $summaryYearHtml.='<th>'.$yearPriceArray[$aalk][$v['name']].'</th>';
  75. }
  76. }
  77. $summaryYearHtml.='</tr>';
  78. $html.=$summaryYearHtml;
  79. $html.=$summaryDateHtml;
  80. }
  81. return $html;
  82. }
  83. /**
  84. * 获得借款单详情
  85. */
  86. function _getReceiptLoanHtml($receiptDetail, $verifylist, $extendHtml = '') {
  87. $receiptDetail ['loanItem'] = json_decode ( $receiptDetail ['loanItem'], true );
  88. $receiptDetail ['sumCN'] = num_to_rmb ( $receiptDetail ['sum'] );
  89. $receiptDetail ['loanSumCN'] = num_to_rmb ( $receiptDetail ['loanSum'] );
  90. $receiptDetail ['amountCN'] = num_to_rmb ( $receiptDetail ['amount'] );
  91. $executeCopy = getExecuteStaff ( $receiptDetail );
  92. // print_r ( $executeCopy );
  93. $html = '<div class="saeaList">
  94. <div class="entry loan-list" style="margin-bottom: 50px">
  95. <div class="seal"></div>
  96. <div class="seTable">
  97. <table class="table table-bordered table-condensed table-hover">
  98. <tbody>
  99. <tr>
  100. <th colspan="2" class="taC">借款费用</th>
  101. </tr>
  102. <tr>
  103. <th>借款费用</th>
  104. <td class="taR" width="140">¥' . $receiptDetail ['loanItem'] ['借款费用'] [0] ['price'] . '</td>
  105. </tr>
  106. <tr>
  107. <th class="taC" colspan="2">产生费用所在办事处</th>
  108. </tr>
  109. <tr>
  110. <th style="text-align: center" colspan="2">' . $receiptDetail ['category'] [0] ['title'] . '</th>
  111. </tr>
  112. <tr>
  113. <th colspan="2" class="taC">汇款信息</th>
  114. </tr>
  115. <tr>
  116. <th>汇款人户名</th>
  117. <td>' . $receiptDetail ['remittanceName'] . '</td>
  118. </tr>
  119. <tr>
  120. <th>汇款银行</th>';
  121. if ($receiptDetail ['remittanceBankType'] == 0)
  122. $html .= '<td>广发银行</td>';
  123. elseif ($receiptDetail ['remittanceBankType'] == 1)
  124. $html .= '<td>其他</td>';
  125. $html .= '</tr>
  126. <tr>
  127. <th>汇款开户银行名称</th>
  128. <td>' . $receiptDetail ['bankName'] . '</td>
  129. </tr>
  130. <tr>
  131. <th>汇款帐号</th>
  132. <td>' . $receiptDetail ['bankNumber'] . '</td>
  133. </tr>';
  134. if ($receiptDetail ['remittanceBankType'] == 1)
  135. $html .= '<tr>
  136. <th>联行号</th>
  137. <td>' . $receiptDetail ['coupletNumber'] . '</td>
  138. </tr>';
  139. $html .= '<tr>
  140. <th class="taC" colspan="2">费用说明</th>
  141. </tr>
  142. <tr>
  143. <td colspan="2">' . $receiptDetail ['explanation'] . '</td>
  144. </tr>
  145. <tr class="warning">
  146. <td class="taR"><b>(' . $receiptDetail ['receiptOrder'] . ')本次费用合计</b></td>
  147. <td class="taR"><b style="font-size: 24px">¥' . $receiptDetail ['sum'] . '</b><br>' . $receiptDetail ['sumCN'] . '</td>
  148. </tr>
  149. <tr class="warning">
  150. <td class="taR"><b>汇款金额</b></td>
  151. <td class="taR" width="140"><b style="font-size: 24px">¥' . $receiptDetail ['amount'] . '</b><br>' . $receiptDetail ['amountCN'] . '</td>
  152. </tr>
  153. </tbody>
  154. </table>
  155. </div>
  156. <div class="seCensor loan-censor">
  157. <div class="title">' . $receiptDetail ['receiptOrder'] . '</div>
  158. <div class="censorList clearfix censorHeight" style="height: 548px;">
  159. <ul>
  160. <li class="post">
  161. <div class="avtra">
  162. <img src="' . $receiptDetail ['staffDetail'] ['avatar'] . '_2.jpg" width="32">
  163. </div>
  164. <div class="comment">
  165. <p>
  166. <span class="fR">' . $receiptDetail ['date'] . '</span>' . $receiptDetail ['staffDetail'] ['username'] . '
  167. </p>
  168. <p>提交审批</p>
  169. </div>
  170. </li>';
  171. foreach ( $verifylist as $key => $value ) {
  172. $html .= '<li ';
  173. if ($value ['status'] == 1) {
  174. $html .= 'class="done"';
  175. } elseif ($value ['status'] == 3) {
  176. $html .= 'class="undone"';
  177. }
  178. $html .= '>
  179. <div class="avtra">
  180. <img src="' . $value [2] . '_2.jpg" width="32">
  181. </div>
  182. <div class="comment">
  183. <p class="colGray">
  184. <span class="fR">' . $value ['date'] . '</span>' . $value [1] . '';
  185. if (isset ( $value ['rolename'] )) {
  186. $html .= '(' . $value ['rolename'] . ')';
  187. }
  188. $html .= '</p>
  189. <p>' . $value ['opinion'] . '</p>
  190. </div>
  191. </li>';
  192. }
  193. foreach ( $executeCopy as $key => $value ) {
  194. $html .= '<li ';
  195. if ($value ['status'] == 1) {
  196. $html .= 'class="done"';
  197. } elseif ($value ['status'] == 3) {
  198. $html .= 'class="undone"';
  199. }
  200. $html .= '>
  201. <div class="avtra">
  202. <img src="' . $value [2] . '_2.jpg" width="32">
  203. </div>
  204. <div class="comment">
  205. <p class="colGray">
  206. <span class="fR">' . $value ['date'] . '</span>' . $value [1] . '(费用执行)
  207. </p>
  208. <p>' . $value ['opinion'] . '</p>
  209. </div>
  210. </li>';
  211. }
  212. $html .= '
  213. </ul>
  214. </div>
  215. </div>
  216. </div>
  217. ' . $extendHtml . '
  218. </div>';
  219. return $html;
  220. }
  221. function _getPaymentsCollectPayByYearHtml($statisticsPay = array()) {
  222. $html = '';
  223. $subtotalSum = array (
  224. 1 => 0,
  225. 2 => 0,
  226. 3 => 0,
  227. 4 => 0,
  228. 5 => 0,
  229. 6 => 0,
  230. 7 => 0,
  231. 8 => 0,
  232. 9 => 0,
  233. 10 => 0,
  234. 11 => 0,
  235. 12 => 0
  236. );
  237. for($i = 1; $i <= 15; $i ++) {
  238. if ($i == 1) {
  239. $html = '<tr><th colspan="2" >银行手续费</th>';
  240. $sum = 0;
  241. for($month = 1; $month <= 12; $month ++) {
  242. $falg = true;
  243. foreach ( $statisticsPay as $key => $value ) {
  244. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  245. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  246. $sum += $value ['payPrice'];
  247. $subtotalSum [$month] += $value ['payPrice'];
  248. $falg = false;
  249. break;
  250. }
  251. }
  252. if ($falg)
  253. $html .= '<td class="taR">-</td>';
  254. }
  255. if ($sum == 0)
  256. $html .= '<td class="taR">-</td>';
  257. else
  258. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  259. $html .= '</tr>';
  260. } elseif ($i == 2) {
  261. $html .= '<tr><th colspan="2" >总部电话费</th>';
  262. $sum = 0;
  263. for($month = 1; $month <= 12; $month ++) {
  264. $falg = true;
  265. foreach ( $statisticsPay as $key => $value ) {
  266. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  267. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  268. $sum += $value ['payPrice'];
  269. $subtotalSum [$month] += $value ['payPrice'];
  270. $falg = false;
  271. break;
  272. }
  273. }
  274. if ($falg)
  275. $html .= '<td class="taR">-</td>';
  276. }
  277. if ($sum == 0)
  278. $html .= '<td class="taR">-</td>';
  279. else
  280. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  281. $html .= '</tr>';
  282. } elseif ($i == 3) {
  283. $subtotal = array (
  284. 1 => 0,
  285. 2 => 0,
  286. 3 => 0,
  287. 4 => 0,
  288. 5 => 0,
  289. 6 => 0,
  290. 7 => 0,
  291. 8 => 0,
  292. 9 => 0,
  293. 10 => 0,
  294. 11 => 0,
  295. 12 => 0
  296. );
  297. $html .= '<tr><th rowspan="4" width="90">缴税</th>';
  298. $html .= '<th width="90">增值税</th>';
  299. $sum = 0;
  300. for($month = 1; $month <= 12; $month ++) {
  301. $falg = true;
  302. foreach ( $statisticsPay as $key => $value ) {
  303. if ($value ['expenditureMsg'] == '增值税' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  304. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  305. $sum += $value ['payPrice'];
  306. $subtotal [$month] += $value ['payPrice'];
  307. $falg = false;
  308. break;
  309. }
  310. }
  311. if ($falg)
  312. $html .= '<td class="taR">-</td>';
  313. }
  314. if ($sum == 0)
  315. $html .= '<td class="taR">-</td>';
  316. else
  317. $html .= '<td class="taR">¥' . $sum . '</td>';
  318. $html .= '</tr>';
  319. $html .= '<th width="90">税金附加</th>';
  320. $sum = 0;
  321. for($month = 1; $month <= 12; $month ++) {
  322. $falg = true;
  323. foreach ( $statisticsPay as $key => $value ) {
  324. if ($value ['expenditureMsg'] == '税金附加' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  325. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  326. $sum += $value ['payPrice'];
  327. $subtotal [$month] += $value ['payPrice'];
  328. $falg = false;
  329. break;
  330. }
  331. }
  332. if ($falg)
  333. $html .= '<td class="taR">-</td>';
  334. }
  335. if ($sum == 0)
  336. $html .= '<td class="taR">-</td>';
  337. else
  338. $html .= '<td class="taR">¥' . $sum . '</td>';
  339. $html .= '</tr>';
  340. $html .= '<th width="90">企业所得税</th>';
  341. $sum = 0;
  342. for($month = 1; $month <= 12; $month ++) {
  343. $falg = true;
  344. foreach ( $statisticsPay as $key => $value ) {
  345. if ($value ['expenditureMsg'] == '企业所得税' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  346. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  347. $sum += $value ['payPrice'];
  348. $subtotal [$month] += $value ['payPrice'];
  349. $falg = false;
  350. break;
  351. }
  352. }
  353. if ($falg)
  354. $html .= '<td class="taR">-</td>';
  355. }
  356. if ($sum == 0)
  357. $html .= '<td class="taR">-</td>';
  358. else
  359. $html .= '<td class="taR">¥' . $sum . '</td>';
  360. $html .= '</tr>';
  361. $html .= '<th width="90" class="colRed">小计</th>';
  362. $sum = 0;
  363. for($month = 1; $month <= 12; $month ++) {
  364. $sum += $subtotal [$month];
  365. $subtotalSum [$month] += $subtotal [$month];
  366. if (! empty ( $subtotal [$month] ))
  367. $html .= '<td class="taR colRed">¥' . $subtotal [$month] . '</td>';
  368. else
  369. $html .= '<td class="taR">-</td>';
  370. }
  371. if ($sum == 0)
  372. $html .= '<td class="taR">-</td>';
  373. else
  374. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  375. $html .= '</tr>';
  376. } elseif ($i == 5) {
  377. $html .= '<tr><th colspan="2" >保证金</th>';
  378. $sum = 0;
  379. for($month = 1; $month <= 12; $month ++) {
  380. $falg = true;
  381. foreach ( $statisticsPay as $key => $value ) {
  382. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  383. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  384. $sum += abs ( $value ['payPrice'] );
  385. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  386. $falg = false;
  387. break;
  388. }
  389. }
  390. if ($falg)
  391. $html .= '<td class="taR">-</td>';
  392. }
  393. if ($sum == 0)
  394. $html .= '<td class="taR">-</td>';
  395. else
  396. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  397. $html .= '</tr>';
  398. }
  399. }
  400. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  401. $sum = 0;
  402. foreach ( $subtotalSum as $key => $value ) {
  403. $sum += $value;
  404. if (! empty ( $value ))
  405. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  406. else
  407. $html .= '<td class="taR">-</td>';
  408. }
  409. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  410. $html .= '</tr>';
  411. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  412. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  413. return array (
  414. 'html' => $html,
  415. 'sum' => $sum
  416. );
  417. }
  418. /**
  419. * 获得汇总 日常收支年
  420. * @param array $statisticsIncome
  421. * @return string
  422. */
  423. function _getPaymentsCollectByYearHtml($statisticsIncome = array()) {
  424. $html = '';
  425. $subtotalSum = array (
  426. 1 => 0,
  427. 2 => 0,
  428. 3 => 0,
  429. 4 => 0,
  430. 5 => 0,
  431. 6 => 0,
  432. 7 => 0,
  433. 8 => 0,
  434. 9 => 0,
  435. 10 => 0,
  436. 11 => 0,
  437. 12 => 0
  438. );
  439. for($i = 1; $i <= 15; $i ++) {
  440. if ($i == 1) {
  441. $subtotal = array (
  442. 1 => 0,
  443. 2 => 0,
  444. 3 => 0,
  445. 4 => 0,
  446. 5 => 0,
  447. 6 => 0,
  448. 7 => 0,
  449. 8 => 0,
  450. 9 => 0,
  451. 10 => 0,
  452. 11 => 0,
  453. 12 => 0
  454. );
  455. $html .= '<tr><th rowspan="4" width="90">利息收入</th>';
  456. $html .= '<th width="90">银行存款</th>';
  457. $sum = 0;
  458. for($month = 1; $month <= 12; $month ++) {
  459. $falg = true;
  460. foreach ( $statisticsIncome as $key => $value ) {
  461. if ($value ['accountMsg'] == '银行存款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  462. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  463. $sum += $value ['inComePrice'];
  464. $subtotal [$month] += $value ['inComePrice'];
  465. $falg = false;
  466. break;
  467. }
  468. }
  469. if ($falg)
  470. $html .= '<td class="taR">-</td>';
  471. }
  472. if ($sum == 0)
  473. $html .= '<td class="taR">-</td>';
  474. else
  475. $html .= '<td class="taR">¥' . $sum . '</td>';
  476. $html .= '</tr>';
  477. $html .= '<th width="90">活期理财收益</th>';
  478. $sum = 0;
  479. for($month = 1; $month <= 12; $month ++) {
  480. $falg = true;
  481. foreach ( $statisticsIncome as $key => $value ) {
  482. if ($value ['accountMsg'] == '活期理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) {
  483. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  484. $sum += $value ['inComePrice'];
  485. $subtotal [$month] += $value ['inComePrice'];
  486. $falg = false;
  487. break;
  488. }
  489. }
  490. if ($falg)
  491. $html .= '<td class="taR">-</td>';
  492. }
  493. if ($sum == 0)
  494. $html .= '<td class="taR">-</td>';
  495. else
  496. $html .= '<td class="taR">¥' . $sum . '</td>';
  497. $html .= '</tr>';
  498. $html .= '<th width="90">固定理财收益</th>';
  499. $sum = 0;
  500. for($month = 1; $month <= 12; $month ++) {
  501. $falg = true;
  502. foreach ( $statisticsIncome as $key => $value ) {
  503. if ($value ['accountMsg'] == '固定理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) {
  504. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  505. $sum += $value ['inComePrice'];
  506. $subtotal [$month] += $value ['inComePrice'];
  507. $falg = false;
  508. break;
  509. }
  510. }
  511. if ($falg)
  512. $html .= '<td class="taR">-</td>';
  513. }
  514. if ($sum == 0)
  515. $html .= '<td class="taR">-</td>';
  516. else
  517. $html .= '<td class="taR">¥' . $sum . '</td>';
  518. $html .= '</tr>';
  519. $html .= '<th width="90">个人借款</th>';
  520. $sum = 0;
  521. for($month = 1; $month <= 12; $month ++) {
  522. $falg = true;
  523. foreach ( $statisticsIncome as $key => $value ) {
  524. if ($value ['accountMsg'] == '个人借款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  525. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  526. $sum += $value ['inComePrice'];
  527. $subtotal [$month] += $value ['inComePrice'];
  528. $falg = false;
  529. break;
  530. }
  531. }
  532. if ($falg)
  533. $html .= '<td class="taR">-</td>';
  534. }
  535. if ($sum == 0)
  536. $html .= '<td class="taR">-</td>';
  537. else
  538. $html .= '<td class="taR">¥' . $sum . '</td>';
  539. $html .= '</tr>';
  540. $html .= '<th width="90" class="colGreen">小计</th>';
  541. $sum = 0;
  542. for($month = 1; $month <= 12; $month ++) {
  543. $sum += $subtotal [$month];
  544. $subtotalSum [$month] += $subtotal [$month];
  545. if (! empty ( $subtotal [$month] ))
  546. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  547. else
  548. $html .= '<td class="taR">-</td>';
  549. }
  550. if ($sum == 0)
  551. $html .= '<td class="taR">-</td>';
  552. else
  553. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  554. $html .= '</tr>';
  555. } elseif ($i == 2) {
  556. $subtotal = array (
  557. 1 => 0,
  558. 2 => 0,
  559. 3 => 0,
  560. 4 => 0,
  561. 5 => 0,
  562. 6 => 0,
  563. 7 => 0,
  564. 8 => 0,
  565. 9 => 0,
  566. 10 => 0,
  567. 11 => 0,
  568. 12 => 0
  569. );
  570. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  571. $html .= '<th width="90">社保</th>';
  572. $sum = 0;
  573. for($month = 1; $month <= 12; $month ++) {
  574. $falg = true;
  575. foreach ( $statisticsIncome as $key => $value ) {
  576. if ($value ['accountMsg'] == '社保' && $value ['month'] == $month && $value ['accountType'] == $i) {
  577. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  578. $sum += $value ['inComePrice'];
  579. $subtotal [$month] += $value ['inComePrice'];
  580. $falg = false;
  581. break;
  582. }
  583. }
  584. if ($falg)
  585. $html .= '<td class="taR">-</td>';
  586. }
  587. if ($sum == 0)
  588. $html .= '<td class="taR">-</td>';
  589. else
  590. $html .= '<td class="taR">¥' . $sum . '</td>';
  591. $html .= '</tr>';
  592. $html .= '<th width="90">财政</th>';
  593. $sum = 0;
  594. for($month = 1; $month <= 12; $month ++) {
  595. $falg = true;
  596. foreach ( $statisticsIncome as $key => $value ) {
  597. if ($value ['accountMsg'] == '财政' && $value ['month'] == $month && $value ['accountType'] == $i) {
  598. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  599. $sum += $value ['inComePrice'];
  600. $subtotal [$month] += $value ['inComePrice'];
  601. $falg = false;
  602. break;
  603. }
  604. }
  605. if ($falg)
  606. $html .= '<td class="taR">-</td>';
  607. }
  608. if ($sum == 0)
  609. $html .= '<td class="taR">-</td>';
  610. else
  611. $html .= '<td class="taR">¥' . $sum . '</td>';
  612. $html .= '</tr>';
  613. $html .= '<th width="90" class="colGreen">小计</th>';
  614. $sum = 0;
  615. for($month = 1; $month <= 12; $month ++) {
  616. $sum += $subtotal [$month];
  617. $subtotalSum [$month] += $subtotal [$month];
  618. if (! empty ( $subtotal [$month] ))
  619. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  620. else
  621. $html .= '<td class="taR">-</td>';
  622. }
  623. if ($sum == 0)
  624. $html .= '<td class="taR">-</td>';
  625. else
  626. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  627. $html .= '</tr>';
  628. } elseif ($i == 3) {
  629. $html .= '<tr><th colspan="2" >纵横知道</th>';
  630. $sum = 0;
  631. for($month = 1; $month <= 12; $month ++) {
  632. $falg = true;
  633. foreach ( $statisticsIncome as $key => $value ) {
  634. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  635. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  636. $sum += $value ['inComePrice'];
  637. $subtotalSum [$month] += $value ['inComePrice'];
  638. $falg = false;
  639. break;
  640. }
  641. }
  642. if ($falg)
  643. $html .= '<td class="taR">-</td>';
  644. }
  645. if ($sum == 0)
  646. $html .= '<td class="taR">-</td>';
  647. else
  648. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  649. $html .= '</tr>';
  650. } elseif ($i == 4) {
  651. $subtotal = array (
  652. 1 => 0,
  653. 2 => 0,
  654. 3 => 0,
  655. 4 => 0,
  656. 5 => 0,
  657. 6 => 0,
  658. 7 => 0,
  659. 8 => 0,
  660. 9 => 0,
  661. 10 => 0,
  662. 11 => 0,
  663. 12 => 0
  664. );
  665. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  666. $html .= '<th width="90">备用金</th>';
  667. $sum = 0;
  668. for($month = 1; $month <= 12; $month ++) {
  669. $falg = true;
  670. foreach ( $statisticsIncome as $key => $value ) {
  671. if ($value ['accountMsg'] == '备用金' && $value ['month'] == $month && $value ['accountType'] == $i) {
  672. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  673. $sum += $value ['inComePrice'];
  674. $subtotal [$month] += $value ['inComePrice'];
  675. $falg = false;
  676. break;
  677. }
  678. }
  679. if ($falg)
  680. $html .= '<td class="taR">-</td>';
  681. }
  682. if ($sum == 0)
  683. $html .= '<td class="taR">-</td>';
  684. else
  685. $html .= '<td class="taR">¥' . $sum . '</td>';
  686. $html .= '</tr>';
  687. $html .= '<th width="90">私人借款</th>';
  688. $sum = 0;
  689. for($month = 1; $month <= 12; $month ++) {
  690. $falg = true;
  691. foreach ( $statisticsIncome as $key => $value ) {
  692. if ($value ['accountMsg'] == '私人借款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  693. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  694. $sum += $value ['inComePrice'];
  695. $subtotal [$month] += $value ['inComePrice'];
  696. $falg = false;
  697. break;
  698. }
  699. }
  700. if ($falg)
  701. $html .= '<td class="taR">-</td>';
  702. }
  703. if ($sum == 0)
  704. $html .= '<td class="taR">-</td>';
  705. else
  706. $html .= '<td class="taR">¥' . $sum . '</td>';
  707. $html .= '</tr>';
  708. $html .= '<th width="90" class="colGreen">小计</th>';
  709. $sum = 0;
  710. for($month = 1; $month <= 12; $month ++) {
  711. $sum += $subtotal [$month];
  712. $subtotalSum [$month] += $subtotal [$month];
  713. if (! empty ( $subtotal [$month] ))
  714. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  715. else
  716. $html .= '<td class="taR">-</td>';
  717. }
  718. if ($sum == 0)
  719. $html .= '<td class="taR">-</td>';
  720. else
  721. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  722. $html .= '</tr>';
  723. } elseif ($i == 5) {
  724. $html .= '<tr><th colspan="2" >退汇</th>';
  725. $sum = 0;
  726. for($month = 1; $month <= 12; $month ++) {
  727. $falg = true;
  728. foreach ( $statisticsIncome as $key => $value ) {
  729. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  730. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  731. $sum += $value ['inComePrice'];
  732. $subtotalSum [$month] += $value ['inComePrice'];
  733. $falg = false;
  734. break;
  735. }
  736. }
  737. if ($falg)
  738. $html .= '<td class="taR">-</td>';
  739. }
  740. if ($sum == 0)
  741. $html .= '<td class="taR">-</td>';
  742. else
  743. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  744. $html .= '</tr>';
  745. } elseif ($i == 6) {
  746. $html .= '<tr><th colspan="2" >其他</th>';
  747. $sum = 0;
  748. for($month = 1; $month <= 12; $month ++) {
  749. $falg = true;
  750. foreach ( $statisticsIncome as $key => $value ) {
  751. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  752. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  753. $sum += $value ['inComePrice'];
  754. $subtotalSum [$month] += $value ['inComePrice'];
  755. $falg = false;
  756. break;
  757. }
  758. }
  759. if ($falg)
  760. $html .= '<td class="taR">-</td>';
  761. }
  762. if ($sum == 0)
  763. $html .= '<td class="taR">-</td>';
  764. else
  765. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  766. $html .= '</tr>';
  767. } elseif ($i == 8) {
  768. $html .= '<tr><th colspan="2" >保证金</th>';
  769. $sum = 0;
  770. for($month = 1; $month <= 12; $month ++) {
  771. $falg = true;
  772. foreach ( $statisticsIncome as $key => $value ) {
  773. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  774. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  775. $sum += $value ['inComePrice'];
  776. $subtotalSum [$month] += $value ['inComePrice'];
  777. $falg = false;
  778. break;
  779. }
  780. }
  781. if ($falg)
  782. $html .= '<td class="taR">-</td>';
  783. }
  784. if ($sum == 0)
  785. $html .= '<td class="taR">-</td>';
  786. else
  787. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  788. $html .= '</tr>';
  789. }
  790. }
  791. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  792. $sum = 0;
  793. foreach ( $subtotalSum as $key => $value ) {
  794. $sum += $value;
  795. if (! empty ( $value ))
  796. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  797. else
  798. $html .= '<td class="taR">-</td>';
  799. }
  800. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  801. $html .= '</tr>';
  802. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  803. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  804. return array (
  805. 'html' => $html,
  806. 'sum' => $sum
  807. );
  808. }
  809. /**
  810. * 获得汇总 日常收支年
  811. * @param array $statisticsIncome
  812. * @return string
  813. */
  814. function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
  815. $html = '<tr><th class="taC" colspan="2">日常收入</th>';
  816. for($d = 1; $d <= $day; $d ++) {
  817. $subtotalSum [$d] = 0;
  818. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  819. }
  820. $html .= '<th class="taC" width="110">总计</th></tr>';
  821. for($i = 1; $i <= 15; $i ++) {
  822. if ($i == 1) {
  823. for($d = 1; $d <= $day; $d ++) {
  824. $subtotal [$d] = 0;
  825. }
  826. // $subtotal = array (
  827. // 1 => 0,
  828. // 2 => 0,
  829. // 3 => 0,
  830. // 4 => 0,
  831. // 5 => 0,
  832. // 6 => 0,
  833. // 7 => 0,
  834. // 8 => 0,
  835. // 9 => 0,
  836. // 10 => 0,
  837. // 11 => 0,
  838. // 12 => 0
  839. // );
  840. $html .= '<tr><th rowspan="4" width="90">利息收入</th>';
  841. $html .= '<th width="90">银行存款</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. $subtotal [$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">¥' . $sum . '</td>';
  861. $html .= '</tr>';
  862. $html .= '<th width="90">理财收益</th>';
  863. $sum = 0;
  864. for($month = 1; $month <= $day; $month ++) {
  865. $falg = true;
  866. foreach ( $statisticsIncome as $key => $value ) {
  867. if ($value ['accountMsg'] == '理财收益' && $value ['day'] == $month && $value ['accountType'] == $i) {
  868. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  869. $sum += $value ['inComePrice'];
  870. $subtotal [$month] += $value ['inComePrice'];
  871. $falg = false;
  872. break;
  873. }
  874. }
  875. if ($falg)
  876. $html .= '<td class="taR">-</td>';
  877. }
  878. if ($sum == 0)
  879. $html .= '<td class="taR">-</td>';
  880. else
  881. $html .= '<td class="taR">¥' . $sum . '</td>';
  882. $html .= '</tr>';
  883. $html .= '<th width="90">个人借款</th>';
  884. $sum = 0;
  885. for($month = 1; $month <= $day; $month ++) {
  886. $falg = true;
  887. foreach ( $statisticsIncome as $key => $value ) {
  888. if ($value ['accountMsg'] == '个人借款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  889. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  890. $sum += $value ['inComePrice'];
  891. $subtotal [$month] += $value ['inComePrice'];
  892. $falg = false;
  893. break;
  894. }
  895. }
  896. if ($falg)
  897. $html .= '<td class="taR">-</td>';
  898. }
  899. if ($sum == 0)
  900. $html .= '<td class="taR">-</td>';
  901. else
  902. $html .= '<td class="taR">¥' . $sum . '</td>';
  903. $html .= '</tr>';
  904. $html .= '<th width="90" class="colGreen">小计</th>';
  905. $sum = 0;
  906. for($month = 1; $month <= $day; $month ++) {
  907. $sum += $subtotal [$month];
  908. $subtotalSum [$month] += $subtotal [$month];
  909. if (! empty ( $subtotal [$month] ))
  910. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  911. else
  912. $html .= '<td class="taR">-</td>';
  913. }
  914. if ($sum == 0)
  915. $html .= '<td class="taR">-</td>';
  916. else
  917. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  918. $html .= '</tr>';
  919. } elseif ($i == 2) {
  920. for($d = 1; $d <= $day; $d ++) {
  921. $subtotal [$d] = 0;
  922. }
  923. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  924. $html .= '<th width="90">社保</th>';
  925. $sum = 0;
  926. for($month = 1; $month <= $day; $month ++) {
  927. $falg = true;
  928. foreach ( $statisticsIncome as $key => $value ) {
  929. if ($value ['accountMsg'] == '社保' && $value ['day'] == $month && $value ['accountType'] == $i) {
  930. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  931. $sum += $value ['inComePrice'];
  932. $subtotal [$month] += $value ['inComePrice'];
  933. $falg = false;
  934. break;
  935. }
  936. }
  937. if ($falg)
  938. $html .= '<td class="taR">-</td>';
  939. }
  940. if ($sum == 0)
  941. $html .= '<td class="taR">-</td>';
  942. else
  943. $html .= '<td class="taR">¥' . $sum . '</td>';
  944. $html .= '</tr>';
  945. $html .= '<th width="90">财政</th>';
  946. $sum = 0;
  947. for($month = 1; $month <= $day; $month ++) {
  948. $falg = true;
  949. foreach ( $statisticsIncome as $key => $value ) {
  950. if ($value ['accountMsg'] == '财政' && $value ['day'] == $month && $value ['accountType'] == $i) {
  951. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  952. $sum += $value ['inComePrice'];
  953. $subtotal [$month] += $value ['inComePrice'];
  954. $falg = false;
  955. break;
  956. }
  957. }
  958. if ($falg)
  959. $html .= '<td class="taR">-</td>';
  960. }
  961. if ($sum == 0)
  962. $html .= '<td class="taR">-</td>';
  963. else
  964. $html .= '<td class="taR">¥' . $sum . '</td>';
  965. $html .= '</tr>';
  966. $html .= '<th width="90" class="colGreen">小计</th>';
  967. $sum = 0;
  968. for($month = 1; $month <= $day; $month ++) {
  969. $sum += $subtotal [$month];
  970. $subtotalSum [$month] += $subtotal [$month];
  971. if (! empty ( $subtotal [$month] ))
  972. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  973. else
  974. $html .= '<td class="taR">-</td>';
  975. }
  976. if ($sum == 0)
  977. $html .= '<td class="taR">-</td>';
  978. else
  979. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  980. $html .= '</tr>';
  981. } elseif ($i == 3) {
  982. $html .= '<tr><th colspan="2" >纵横知道</th>';
  983. $sum = 0;
  984. for($month = 1; $month <= $day; $month ++) {
  985. $falg = true;
  986. foreach ( $statisticsIncome as $key => $value ) {
  987. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  988. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  989. $sum += $value ['inComePrice'];
  990. $subtotalSum [$month] += $value ['inComePrice'];
  991. $falg = false;
  992. break;
  993. }
  994. }
  995. if ($falg)
  996. $html .= '<td class="taR">-</td>';
  997. }
  998. if ($sum == 0)
  999. $html .= '<td class="taR">-</td>';
  1000. else
  1001. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1002. $html .= '</tr>';
  1003. } elseif ($i == 4) {
  1004. for($d = 1; $d <= $day; $d ++) {
  1005. $subtotal [$d] = 0;
  1006. }
  1007. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  1008. $html .= '<th width="90">备用金</th>';
  1009. $sum = 0;
  1010. for($month = 1; $month <= $day; $month ++) {
  1011. $falg = true;
  1012. foreach ( $statisticsIncome as $key => $value ) {
  1013. if ($value ['accountMsg'] == '备用金' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1014. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1015. $sum += $value ['inComePrice'];
  1016. $subtotal [$month] += $value ['inComePrice'];
  1017. $falg = false;
  1018. break;
  1019. }
  1020. }
  1021. if ($falg)
  1022. $html .= '<td class="taR">-</td>';
  1023. }
  1024. if ($sum == 0)
  1025. $html .= '<td class="taR">-</td>';
  1026. else
  1027. $html .= '<td class="taR">¥' . $sum . '</td>';
  1028. $html .= '</tr>';
  1029. $html .= '<th width="90">私人借款</th>';
  1030. $sum = 0;
  1031. for($month = 1; $month <= $day; $month ++) {
  1032. $falg = true;
  1033. foreach ( $statisticsIncome as $key => $value ) {
  1034. if ($value ['accountMsg'] == '私人借款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1035. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1036. $sum += $value ['inComePrice'];
  1037. $subtotal [$month] += $value ['inComePrice'];
  1038. $falg = false;
  1039. break;
  1040. }
  1041. }
  1042. if ($falg)
  1043. $html .= '<td class="taR">-</td>';
  1044. }
  1045. if ($sum == 0)
  1046. $html .= '<td class="taR">-</td>';
  1047. else
  1048. $html .= '<td class="taR">¥' . $sum . '</td>';
  1049. $html .= '</tr>';
  1050. $html .= '<th width="90" class="colGreen">小计</th>';
  1051. $sum = 0;
  1052. for($month = 1; $month <= $day; $month ++) {
  1053. $sum += $subtotal [$month];
  1054. $subtotalSum [$month] += $subtotal [$month];
  1055. if (! empty ( $subtotal [$month] ))
  1056. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  1057. else
  1058. $html .= '<td class="taR">-</td>';
  1059. }
  1060. if ($sum == 0)
  1061. $html .= '<td class="taR">-</td>';
  1062. else
  1063. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1064. $html .= '</tr>';
  1065. } elseif ($i == 5) {
  1066. $html .= '<tr><th colspan="2" >退汇</th>';
  1067. $sum = 0;
  1068. for($month = 1; $month <= $day; $month ++) {
  1069. $falg = true;
  1070. foreach ( $statisticsIncome as $key => $value ) {
  1071. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1072. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1073. $sum += $value ['inComePrice'];
  1074. $subtotalSum [$month] += $value ['inComePrice'];
  1075. $falg = false;
  1076. break;
  1077. }
  1078. }
  1079. if ($falg)
  1080. $html .= '<td class="taR">-</td>';
  1081. }
  1082. if ($sum == 0)
  1083. $html .= '<td class="taR">-</td>';
  1084. else
  1085. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1086. $html .= '</tr>';
  1087. } elseif ($i == 6) {
  1088. $html .= '<tr><th colspan="2" >其他</th>';
  1089. $sum = 0;
  1090. for($month = 1; $month <= $day; $month ++) {
  1091. $falg = true;
  1092. foreach ( $statisticsIncome as $key => $value ) {
  1093. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1094. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1095. $sum += $value ['inComePrice'];
  1096. $subtotalSum [$month] += $value ['inComePrice'];
  1097. $falg = false;
  1098. break;
  1099. }
  1100. }
  1101. if ($falg)
  1102. $html .= '<td class="taR">-</td>';
  1103. }
  1104. if ($sum == 0)
  1105. $html .= '<td class="taR">-</td>';
  1106. else
  1107. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1108. $html .= '</tr>';
  1109. } elseif ($i == 8) {
  1110. $html .= '<tr><th colspan="2" >保证金</th>';
  1111. $sum = 0;
  1112. for($month = 1; $month <= $day; $month ++) {
  1113. $falg = true;
  1114. foreach ( $statisticsIncome as $key => $value ) {
  1115. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1116. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1117. $sum += $value ['inComePrice'];
  1118. $subtotalSum [$month] += $value ['inComePrice'];
  1119. $falg = false;
  1120. break;
  1121. }
  1122. }
  1123. if ($falg)
  1124. $html .= '<td class="taR">-</td>';
  1125. }
  1126. if ($sum == 0)
  1127. $html .= '<td class="taR">-</td>';
  1128. else
  1129. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1130. $html .= '</tr>';
  1131. }
  1132. }
  1133. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1134. $sum = 0;
  1135. foreach ( $subtotalSum as $key => $value ) {
  1136. $sum += $value;
  1137. if (! empty ( $value ))
  1138. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1139. else
  1140. $html .= '<td class="taR">-</td>';
  1141. }
  1142. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1143. $html .= '</tr>';
  1144. $colspan = $day + 1;
  1145. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  1146. <td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1147. return array (
  1148. 'html' => $html,
  1149. 'sum' => $sum
  1150. );
  1151. }
  1152. function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
  1153. $html = '<tr><th class="taC" colspan="2">日常支出</th>';
  1154. for($d = 1; $d <= $day; $d ++) {
  1155. $subtotalSum [$d] = 0;
  1156. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  1157. }
  1158. $html .= '<th class="taC" width="110">总计</th></tr>';
  1159. for($i = 1; $i <= 15; $i ++) {
  1160. if ($i == 1) {
  1161. $html .= '<tr><th colspan="2" >银行手续费</th>';
  1162. $sum = 0;
  1163. for($month = 1; $month <= $day; $month ++) {
  1164. $falg = true;
  1165. foreach ( $statisticsPay as $key => $value ) {
  1166. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1167. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1168. $sum += $value ['payPrice'];
  1169. $subtotalSum [$month] += $value ['payPrice'];
  1170. $falg = false;
  1171. break;
  1172. }
  1173. }
  1174. if ($falg)
  1175. $html .= '<td class="taR">-</td>';
  1176. }
  1177. if ($sum == 0)
  1178. $html .= '<td class="taR">-</td>';
  1179. else
  1180. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1181. $html .= '</tr>';
  1182. } elseif ($i == 2) {
  1183. $html .= '<tr><th colspan="2" >总部电话费</th>';
  1184. $sum = 0;
  1185. for($month = 1; $month <= $day; $month ++) {
  1186. $falg = true;
  1187. foreach ( $statisticsPay as $key => $value ) {
  1188. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1189. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1190. $sum += $value ['payPrice'];
  1191. $subtotalSum [$month] += $value ['payPrice'];
  1192. $falg = false;
  1193. break;
  1194. }
  1195. }
  1196. if ($falg)
  1197. $html .= '<td class="taR">-</td>';
  1198. }
  1199. if ($sum == 0)
  1200. $html .= '<td class="taR">-</td>';
  1201. else
  1202. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1203. $html .= '</tr>';
  1204. } elseif ($i == 3) {
  1205. for($d = 1; $d <= $day; $d ++) {
  1206. $subtotal [$d] = 0;
  1207. }
  1208. $html .= '<tr><th rowspan="4" width="90">缴税</th>';
  1209. $html .= '<th width="90">增值税</th>';
  1210. $sum = 0;
  1211. for($month = 1; $month <= $day; $month ++) {
  1212. $falg = true;
  1213. foreach ( $statisticsPay as $key => $value ) {
  1214. if ($value ['expenditureMsg'] == '增值税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1215. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1216. $sum += $value ['payPrice'];
  1217. $subtotal [$month] += $value ['payPrice'];
  1218. $falg = false;
  1219. break;
  1220. }
  1221. }
  1222. if ($falg)
  1223. $html .= '<td class="taR">-</td>';
  1224. }
  1225. if ($sum == 0)
  1226. $html .= '<td class="taR">-</td>';
  1227. else
  1228. $html .= '<td class="taR">¥' . $sum . '</td>';
  1229. $html .= '</tr>';
  1230. $html .= '<th width="90">税金附加</th>';
  1231. $sum = 0;
  1232. for($month = 1; $month <= $day; $month ++) {
  1233. $falg = true;
  1234. foreach ( $statisticsPay as $key => $value ) {
  1235. if ($value ['expenditureMsg'] == '税金附加' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1236. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1237. $sum += $value ['payPrice'];
  1238. $subtotal [$month] += $value ['payPrice'];
  1239. $falg = false;
  1240. break;
  1241. }
  1242. }
  1243. if ($falg)
  1244. $html .= '<td class="taR">-</td>';
  1245. }
  1246. if ($sum == 0)
  1247. $html .= '<td class="taR">-</td>';
  1248. else
  1249. $html .= '<td class="taR">¥' . $sum . '</td>';
  1250. $html .= '</tr>';
  1251. $html .= '<th width="90">企业所得税</th>';
  1252. $sum = 0;
  1253. for($month = 1; $month <= $day; $month ++) {
  1254. $falg = true;
  1255. foreach ( $statisticsPay as $key => $value ) {
  1256. if ($value ['expenditureMsg'] == '企业所得税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1257. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1258. $sum += $value ['payPrice'];
  1259. $subtotal [$month] += $value ['payPrice'];
  1260. $falg = false;
  1261. break;
  1262. }
  1263. }
  1264. if ($falg)
  1265. $html .= '<td class="taR">-</td>';
  1266. }
  1267. if ($sum == 0)
  1268. $html .= '<td class="taR">-</td>';
  1269. else
  1270. $html .= '<td class="taR">¥' . $sum . '</td>';
  1271. $html .= '</tr>';
  1272. $html .= '<th width="90" class="colRed">小计</th>';
  1273. $sum = 0;
  1274. for($month = 1; $month <= $day; $month ++) {
  1275. $sum += $subtotal [$month];
  1276. $subtotalSum [$month] += $subtotal [$month];
  1277. if (! empty ( $subtotal [$month] ))
  1278. $html .= '<td class="taR colRed">¥' . $subtotal [$month] . '</td>';
  1279. else
  1280. $html .= '<td class="taR">-</td>';
  1281. }
  1282. if ($sum == 0)
  1283. $html .= '<td class="taR">-</td>';
  1284. else
  1285. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1286. $html .= '</tr>';
  1287. } elseif ($i == 5) {
  1288. $html .= '<tr><th colspan="2" >保证金</th>';
  1289. $sum = 0;
  1290. for($month = 1; $month <= $day; $month ++) {
  1291. $falg = true;
  1292. foreach ( $statisticsPay as $key => $value ) {
  1293. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1294. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  1295. $sum += abs ( $value ['payPrice'] );
  1296. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  1297. $falg = false;
  1298. break;
  1299. }
  1300. }
  1301. if ($falg)
  1302. $html .= '<td class="taR">-</td>';
  1303. }
  1304. if ($sum == 0)
  1305. $html .= '<td class="taR">-</td>';
  1306. else
  1307. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1308. $html .= '</tr>';
  1309. }
  1310. }
  1311. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1312. $sum = 0;
  1313. foreach ( $subtotalSum as $key => $value ) {
  1314. $sum += $value;
  1315. if (! empty ( $value ))
  1316. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1317. else
  1318. $html .= '<td class="taR">-</td>';
  1319. }
  1320. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1321. $html .= '</tr>';
  1322. $colspan = $day + 1;
  1323. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  1324. <td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1325. return array (
  1326. 'html' => $html,
  1327. 'sum' => $sum
  1328. );
  1329. }
  1330. function getExecuteStaff($receiptDetail) {
  1331. // 费用执行人相关数据
  1332. $executeCopy = json_decode ( $receiptDetail ['executeCopy'], true );
  1333. $executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );
  1334. foreach ( $executeCopy as $k => $v ) {
  1335. $executeCopy [$k] ['date'] = '';
  1336. $executeCopy [$k] ['opinion'] = '';
  1337. $executeCopy [$k] ['status'] = '';
  1338. if (! empty ( $executeStaff ))
  1339. foreach ( $executeStaff as $m => $u ) {
  1340. if ($v [0] == $m) {
  1341. $executeCopy [$k] ['date'] = $u ['date'];
  1342. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  1343. $executeCopy [$k] ['status'] = $u ['status'];
  1344. break;
  1345. }
  1346. }
  1347. }
  1348. $receiptDetail ['executeCopy'] = $executeCopy;
  1349. return $receiptDetail ['executeCopy'];
  1350. }
  1351. function num_to_rmb($num) {
  1352. $c1 = "零壹贰叁肆伍陆柒捌玖";
  1353. $c2 = "分角元拾佰仟万拾佰仟亿";
  1354. // 精确到分后面就不要了,所以只留两个小数位
  1355. $num = round ( $num, 2 );
  1356. // 将数字转化为整数
  1357. $num = $num * 100;
  1358. if (strlen ( $num ) > 10) {
  1359. return "金额太大,请检查";
  1360. }
  1361. $i = 0;
  1362. $c = "";
  1363. while ( 1 ) {
  1364. if ($i == 0) {
  1365. // 获取最后一位数字
  1366. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  1367. } else {
  1368. $n = $num % 10;
  1369. }
  1370. // 每次将最后一位数字转化为中文
  1371. $p1 = substr ( $c1, 3 * $n, 3 );
  1372. $p2 = substr ( $c2, 3 * $i, 3 );
  1373. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  1374. $c = $p1 . $p2 . $c;
  1375. } else {
  1376. $c = $p1 . $c;
  1377. }
  1378. $i = $i + 1;
  1379. // 去掉数字最后一位了
  1380. $num = $num / 10;
  1381. // echo $num.'</br>';
  1382. $num = ( int ) $num;
  1383. // $num =floor($num);
  1384. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  1385. // echo $num.'</br>';
  1386. // 结束循环
  1387. if ($num == 0) {
  1388. break;
  1389. }
  1390. }
  1391. // echo $c.'</br>';
  1392. $j = 0;
  1393. $slen = strlen ( $c );
  1394. while ( $j < $slen ) {
  1395. // utf8一个汉字相当3个字符
  1396. $m = substr ( $c, $j, 6 );
  1397. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  1398. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  1399. $left = substr ( $c, 0, $j );
  1400. $right = substr ( $c, $j + 3 );
  1401. $c = $left . $right;
  1402. $j = $j - 3;
  1403. $slen = $slen - 3;
  1404. }
  1405. $j = $j + 3;
  1406. }
  1407. // 这个是为了去掉类似23.0中最后一个“零”字
  1408. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  1409. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  1410. }
  1411. // 将处理的汉字加上“整”
  1412. if (empty ( $c )) {
  1413. return "零元整";
  1414. } else {
  1415. return $c . "整";
  1416. }
  1417. }
  1418. /**
  1419. * 数据导出
  1420. * @param array $title 标题行名称
  1421. * @param array $data 导出数据
  1422. * @param string $fileName 文件名
  1423. * @param string $savePath 保存路径
  1424. * @param $type 是否下载 false--保存 true--下载
  1425. * @return string 返回文件全路径
  1426. * @throws PHPExcel_Exception
  1427. * @throws PHPExcel_Reader_Exception @exportExcel(array('姓名','年龄'), array(array('a',21),array('b',23)), '档案', './', true);
  1428. */
  1429. function exportExcel($title = array(), $data = array(), $fileName = '', $savePath = './', $isDown = false) {
  1430. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  1431. $obj = new PHPExcel ();
  1432. // 横向单元格标识
  1433. $cellName = array (
  1434. 'A',
  1435. 'B',
  1436. 'C',
  1437. 'D',
  1438. 'E',
  1439. 'F',
  1440. 'G',
  1441. 'H',
  1442. 'I',
  1443. 'J',
  1444. 'K',
  1445. 'L',
  1446. 'M',
  1447. 'N',
  1448. 'O',
  1449. 'P',
  1450. 'Q',
  1451. 'R',
  1452. 'S',
  1453. 'T',
  1454. 'U',
  1455. 'V',
  1456. 'W',
  1457. 'X',
  1458. 'Y',
  1459. 'Z',
  1460. 'AA',
  1461. 'AB',
  1462. 'AC',
  1463. 'AD',
  1464. 'AE',
  1465. 'AF',
  1466. 'AG',
  1467. 'AH',
  1468. 'AI',
  1469. 'AJ',
  1470. 'AK',
  1471. 'AL',
  1472. 'AM',
  1473. 'AN',
  1474. 'AO',
  1475. 'AP',
  1476. 'AQ',
  1477. 'AR',
  1478. 'AS',
  1479. 'AT',
  1480. 'AU',
  1481. 'AV',
  1482. 'AW',
  1483. 'AX',
  1484. 'AY',
  1485. 'AZ'
  1486. );
  1487. $obj->getActiveSheet ( 0 )->setTitle ( 'sheet名称' ); // 设置sheet名称
  1488. $_row = 0; // 设置纵向单元格标识
  1489. if ($title) {
  1490. $_cnt = count ( $title );
  1491. // $obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //合并单元格
  1492. // $obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '数据导出:'.date('Y-m-d H:i:s')); //设置合并后的单元格内容
  1493. $_row ++;
  1494. $i = 0;
  1495. foreach ( $title as $v ) { // 设置列标题
  1496. $obj->setActiveSheetIndex ( 0 )->setCellValue ( $cellName [$i] . $_row, $v );
  1497. $i ++;
  1498. }
  1499. $_row ++;
  1500. }
  1501. ;
  1502. // html_entity_decode("&iuml;&raquo;&iquest;".$value['order_id']);
  1503. // 填写数据
  1504. if ($data) {
  1505. $i = 0;
  1506. foreach ( $data as $_v ) {
  1507. $j = 0;
  1508. foreach ( $_v as $_cell ) {
  1509. $obj->getActiveSheet ( 0 )->setCellValueExplicit ( $cellName [$j] . ($i + $_row), $_cell, PHPExcel_Cell_DataType::TYPE_STRING );
  1510. $j ++;
  1511. }
  1512. $i ++;
  1513. }
  1514. }
  1515. // 文件名处理
  1516. if (! $fileName) {
  1517. $fileName = uniqid ( time (), true );
  1518. }
  1519. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  1520. if ($isDown) { // 网页下载
  1521. header ( 'pragma:public' );
  1522. header ( "Content-Disposition:attachment;filename=$fileName.xls" );
  1523. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  1524. $objWrite->save ( 'php://output' );
  1525. exit ();
  1526. }
  1527. $_fileName = iconv ( "utf-8", "gb2312", $fileName ); // 转码
  1528. $_savePath = $savePath . $_fileName . '.xlsx';
  1529. $objWrite->save ( $_savePath );
  1530. return $savePath . $fileName . '.xlsx';
  1531. }
  1532. function cellColor($cells,$color,$obj){
  1533. $obj->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
  1534. 'type' => PHPExcel_Style_Fill::FILL_SOLID,
  1535. 'startcolor' => array(
  1536. 'rgb' => $color
  1537. )
  1538. ));
  1539. }
  1540. /*
  1541. * 处理Excel导出
  1542. * @param $datas array
  1543. * 设置表格数据
  1544. * @param $titlename string
  1545. * 设置head @param $title string 设置表头
  1546. */
  1547. function excelData($trainData, $receiptDetail, $summary, $aiList,$receiptLoanDetail,$invoiceList,$RItemList,$lecturerList,$invoiceTrainingDetail) {
  1548. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  1549. $obj = new PHPExcel ();
  1550. //设置合并单元格
  1551. $obj->getActiveSheet()->mergeCells('A1:D1');
  1552. //设置居中--//字体加粗
  1553. $obj->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1554. $i=2;
  1555. for(;$i<=20;$i++){
  1556. $obj->getActiveSheet()->getStyle('A'.$i.':J'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1557. //$obj->getActiveSheet()->getStyle('A'.$i)->getFont()->setName('宋体')->setBold(true);
  1558. //$obj->getActiveSheet()->getStyle('C'.$i)->getFont()->setName('宋体')->setBold(true);
  1559. }
  1560. $styleThinBlackBorderOutline = array(
  1561. 'borders' => array(
  1562. 'allborders' => array( //设置全部边框
  1563. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1564. ),
  1565. ),
  1566. );
  1567. $obj->getActiveSheet()->getStyle( 'A1:D9')->applyFromArray($styleThinBlackBorderOutline);
  1568. for ($i=1;$i<=9;$i++){
  1569. cellColor('A'.$i, 'ddebf7',$obj);
  1570. }
  1571. cellColor('C2', 'ddebf7',$obj);cellColor('C3', 'ddebf7',$obj);
  1572. cellColor('C4', 'ddebf7',$obj);cellColor('C8', 'ddebf7',$obj);
  1573. cellColor('C6', 'ddebf7',$obj);cellColor('C7', 'ddebf7',$obj);
  1574. //设置单元格宽
  1575. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  1576. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  1577. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  1578. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  1579. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  1580. $obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
  1581. $obj->getActiveSheet()->getStyle('A1')->getFont()->setName('宋体')->setBold(true);
  1582. $obj->getactivesheet()->setCellValue ( 'A1','培训班信息' );
  1583. $obj->getactivesheet()->setCellValue ( 'A2','培训班名称' );
  1584. $obj->getactivesheet()->setCellValue ( 'B2',$trainData['trainName'] );
  1585. $obj->getactivesheet()->setCellValue ( 'C2','所在办事处' );
  1586. $obj->getactivesheet()->setCellValue ( 'D2',$trainData['categoryName'] );
  1587. $obj->getactivesheet()->setCellValue ( 'A3','开班时间' );
  1588. $obj->getactivesheet()->setCellValue ( 'B3',$trainData['trainStartDate'] );
  1589. $obj->getactivesheet()->setCellValue ( 'C3','结束时间' );
  1590. $obj->getactivesheet()->setCellValue ( 'D3',$trainData['trainEndDate'] );
  1591. $obj->getactivesheet()->setCellValue ( 'A4','参加人数' );
  1592. $obj->getactivesheet()->setCellValue ( 'B4',$trainData['participants'] );
  1593. $obj->getactivesheet()->setCellValue ( 'C4','培训班地址' );
  1594. autoCellsWidth($obj,'D',$trainData ['trainAddress']);
  1595. $obj->getactivesheet()->setCellValue ( 'D4',$trainData['trainAddress'] );
  1596. $obj->getactivesheet()->setCellValue ( 'A5','备注' );
  1597. $obj->getActiveSheet()->mergeCells('B5:D5');
  1598. $obj->getactivesheet()->setCellValue ( 'B5',$trainData['trainRemarks'] );
  1599. $obj->getActiveSheet()->mergeCells('A6:D6');
  1600. $obj->getActiveSheet()->getStyle('A6:D6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1601. $obj->getactivesheet()->setCellValue ( 'A6','汇款信息' );
  1602. $obj->getactivesheet()->setCellValue ( 'A7','汇款人户名' );
  1603. $obj->getactivesheet()->setCellValue ( 'B7',$receiptDetail['remittanceName'] );
  1604. $obj->getactivesheet()->setCellValue ( 'C7','汇款银行' );
  1605. if(0==$receiptDetail['remittanceBankType']){
  1606. $obj->getactivesheet()->setCellValue ( 'D7','广发银行' );
  1607. }else{
  1608. $obj->getactivesheet()->setCellValue ( 'D7',其他 );
  1609. }
  1610. $obj->getactivesheet()->setCellValue ( 'A8','汇款开户银行名称' );
  1611. autoCellsWidth($obj,'B',$receiptDetail ['bankName']);
  1612. $obj->getactivesheet()->setCellValue ( 'B8',$receiptDetail['bankName'] );
  1613. $obj->getactivesheet()->setCellValue ( 'C8','汇款帐号' );
  1614. $obj->getActiveSheet()->setCellValueExplicit('D8',$receiptDetail['bankNumber'],PHPExcel_Cell_DataType::TYPE_STRING);
  1615. //$obj->getactivesheet()->setCellValue ( 'D7',$receiptDetail['bankNumber'].'' );
  1616. if(0==$receiptDetail['remittanceBankType']){
  1617. $obj->getactivesheet()->setCellValue ( 'A9','联行号' );
  1618. $obj->getActiveSheet()->mergeCells('B9:D9');
  1619. $obj->getactivesheet()->setCellValue ( 'B9',$receiptDetail['coupletNumber'] );
  1620. }
  1621. $obj->setActiveSheetIndex(0);
  1622. $obj->getActiveSheet ()->setTitle ( '信息' );
  1623. //------------------------------------------------------------------------------------------
  1624. $obj->createSheet();
  1625. $obj->setActiveSheetIndex(1);
  1626. makeSummaryData($obj,$summary,$aiList);
  1627. //------------------------------------------------------------------------------------------
  1628. //绘制借款
  1629. $obj->createSheet();
  1630. $obj->setActiveSheetIndex(2);
  1631. makeReceiptLoanData($obj,$receiptLoanDetail);
  1632. //------------------------------------------------------------------------------------------
  1633. //绘制收入
  1634. $obj->createSheet();
  1635. $obj->setActiveSheetIndex(3);
  1636. makeInvoiceData($obj,$invoiceList,$invoiceTrainingDetail);
  1637. //------------------------------------------------------------------------------------------
  1638. //绘制支出
  1639. $obj->createSheet();
  1640. $obj->setActiveSheetIndex(4);
  1641. makeItemData($obj,$RItemList);
  1642. //------------------------------------------------------------------------------------------
  1643. //绘制讲师
  1644. $obj->createSheet();
  1645. $obj->setActiveSheetIndex(5);
  1646. makeLecturerData($obj,$lecturerList);
  1647. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  1648. header ( 'pragma:public' );
  1649. header ( "Content-Disposition:attachment;filename=".$trainData['trainName'].".xlsx" );
  1650. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  1651. $objWrite->save ( 'php://output' );
  1652. exit ();
  1653. }
  1654. function makeLecturerData($obj,$lecturerList){
  1655. //整体字体位置
  1656. $invoiceCount=count($lecturerList)+2;
  1657. for($i=1;$i<=$invoiceCount;$i++){
  1658. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  1659. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  1660. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
  1661. }
  1662. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  1663. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  1664. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  1665. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  1666. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  1667. //边框
  1668. $styleThinBlackBorderOutline = array(
  1669. 'borders' => array(
  1670. 'allborders' => array( //设置全部边框
  1671. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1672. ),
  1673. ),);
  1674. $obj->getActiveSheet()->getStyle( 'A1:E'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
  1675. cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
  1676. cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);cellColor('E1', 'ddebf7',$obj);
  1677. $obj->getactivesheet()->setCellValue ( 'A1','类型' );
  1678. $obj->getactivesheet()->setCellValue ( 'B1','讲师姓名' );
  1679. $obj->getactivesheet()->setCellValue ( 'C1','授课日数' );
  1680. $obj->getactivesheet()->setCellValue ( 'D1','日授课费' );
  1681. $obj->getactivesheet()->setCellValue ( 'E1','合计应发授课费' );
  1682. $i=2;$sumPrice=0;
  1683. foreach ($lecturerList as $key=>$value){
  1684. $lecturerName='';
  1685. if($value['ltype']=='OUTSIDE'){
  1686. $lecturerName.='外聘';
  1687. if($value['taxation']==0){
  1688. $lecturerName.='(不计税)';
  1689. }else{
  1690. $lecturerName.='(计税)';
  1691. }
  1692. }else{
  1693. $lecturerName.='员工';
  1694. }
  1695. $obj->getactivesheet()->setCellValue ( 'A'.$i,$lecturerName );
  1696. $obj->getactivesheet()->setCellValue ( 'B'.$i,$value['lecturerName'] );
  1697. $obj->getactivesheet()->setCellValue ( 'C'.$i,$value['schoolDay'] );
  1698. $obj->getactivesheet()->setCellValue ( 'D'.$i,$value['price'] );
  1699. $obj->getactivesheet()->setCellValue ( 'E'.$i,$value['fees'] );
  1700. $sumPrice+=$value['sum'];
  1701. $i++;
  1702. }
  1703. $obj->getactivesheet()->setCellValue ( 'C'.$i,'合计' );
  1704. $obj->getactivesheet()->setCellValue ( 'D'.$i,$sumPrice );
  1705. $obj->getActiveSheet ()->setTitle ( '讲师' );
  1706. }
  1707. function makeItemData($obj,$itemList){
  1708. //整体字体位置
  1709. $invoiceCount=count($itemList)+2;
  1710. for($i=1;$i<=$invoiceCount;$i++){
  1711. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  1712. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  1713. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
  1714. }
  1715. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  1716. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  1717. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  1718. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  1719. //边框
  1720. $styleThinBlackBorderOutline = array(
  1721. 'borders' => array(
  1722. 'allborders' => array( //设置全部边框
  1723. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1724. ),
  1725. ),);
  1726. $obj->getActiveSheet()->getStyle( 'A1:E'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
  1727. cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
  1728. cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);
  1729. cellColor('E1', 'ddebf7',$obj);
  1730. $obj->getactivesheet()->setCellValue ( 'A1','日期' );
  1731. $obj->getactivesheet()->setCellValue ( 'B1','类别' );
  1732. $obj->getactivesheet()->setCellValue ( 'C1','金额' );
  1733. $obj->getactivesheet()->setCellValue ( 'D1','经手人' );
  1734. $obj->getactivesheet()->setCellValue ( 'E1','支出描述' );
  1735. $i=2;$maxArray=array();$sumPrice=0;
  1736. foreach ($itemList as $key=>$value){
  1737. $obj->getactivesheet()->setCellValue ( 'A'.$i,$value['date'] );
  1738. $obj->getactivesheet()->setCellValue ( 'B'.$i,$value['item'] );
  1739. $obj->getactivesheet()->setCellValue ( 'C'.$i,$value['price'] );
  1740. $obj->getactivesheet()->setCellValue ( 'D'.$i,$value['inputer'] );
  1741. $obj->getactivesheet()->setCellValue ( 'E'.$i,$value['describe'] );
  1742. array_push($maxArray, strlen($value['describe']));
  1743. $sumPrice+=$value['price'];
  1744. $i++;
  1745. }
  1746. $obj->getactivesheet()->setCellValue ( 'B'.$i,'合计' );
  1747. $obj->getactivesheet()->setCellValue ( 'C'.$i,$sumPrice );
  1748. $ma=0;
  1749. if (!empty($maxArray)){
  1750. $ma=max($maxArray);
  1751. }
  1752. $max=$ma-10;$fontlenght=25;
  1753. if($max>25){
  1754. $fontlenght=$max;
  1755. }
  1756. $obj->getActiveSheet()->getColumnDimension('E')->setWidth($fontlenght);
  1757. $obj->getActiveSheet ()->setTitle ( '支出' );
  1758. }
  1759. function makeInvoiceData($obj,$invoiceList,$invoiceTrainingDetail){
  1760. //整体字体位置
  1761. $invoiceCount=count($invoiceList)+4;
  1762. for($i=1;$i<=$invoiceCount;$i++){
  1763. $obj->getActiveSheet()->getStyle('A'.$i.':I'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  1764. $obj->getActiveSheet()->getStyle('A'.$i.':I'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  1765. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
  1766. }
  1767. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  1768. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  1769. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  1770. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  1771. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  1772. $obj->getActiveSheet()->getColumnDimension('F')->setWidth(25);
  1773. $obj->getActiveSheet()->getColumnDimension('G')->setWidth(25);
  1774. $obj->getActiveSheet()->getColumnDimension('H')->setWidth(25);
  1775. $obj->getActiveSheet()->getColumnDimension('I')->setWidth(25);
  1776. //边框
  1777. $styleThinBlackBorderOutline = array(
  1778. 'borders' => array(
  1779. 'allborders' => array( //设置全部边框
  1780. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1781. ),
  1782. ),);
  1783. $obj->getActiveSheet()->getStyle( 'A1:I2')->applyFromArray($styleThinBlackBorderOutline);
  1784. cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
  1785. cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);
  1786. cellColor('E1', 'ddebf7',$obj);cellColor('F1', 'ddebf7',$obj);
  1787. cellColor('H1', 'ddebf7',$obj);cellColor('G1', 'ddebf7',$obj);cellColor('I1', 'ddebf7',$obj);
  1788. $obj->getactivesheet()->setCellValue ( 'A1','培训班名称' );
  1789. $obj->getactivesheet()->setCellValue ( 'B1','办事处' );
  1790. $obj->getactivesheet()->setCellValue ( 'C1','创建' );
  1791. $obj->getactivesheet()->setCellValue ( 'D1','开班时间' );
  1792. $obj->getactivesheet()->setCellValue ( 'E1','包含发票' );
  1793. $obj->getactivesheet()->setCellValue ( 'F1','开票金额合计' );
  1794. $obj->getactivesheet()->setCellValue ( 'G1','入账金额合计' );
  1795. $obj->getactivesheet()->setCellValue ( 'H1','公司已收款' );
  1796. $obj->getactivesheet()->setCellValue ( 'I1','办事处已收款' );
  1797. if(!empty($invoiceTrainingDetail)){
  1798. $obj->getactivesheet()->setCellValue ( 'A2',$invoiceTrainingDetail['trainName'] );
  1799. $obj->getactivesheet()->setCellValue ( 'B2',$invoiceTrainingDetail['category'][0]['title'] );
  1800. $obj->getactivesheet()->setCellValue ( 'C2',$invoiceTrainingDetail['staff']['username'] );
  1801. $obj->getactivesheet()->setCellValue ( 'D2',$invoiceTrainingDetail['trainDate'] );
  1802. $obj->getactivesheet()->setCellValue ( 'E2',$invoiceTrainingDetail['invoiceTotal'] );
  1803. $obj->getactivesheet()->setCellValue ( 'F2',$invoiceTrainingDetail['invoiceTotalAmount'] );
  1804. $obj->getactivesheet()->setCellValue ( 'G2',$invoiceTrainingDetail['invoiceArriveAmount'] );
  1805. $obj->getactivesheet()->setCellValue ( 'H2',$invoiceTrainingDetail['invoiceCompanyAmount'] );
  1806. $obj->getactivesheet()->setCellValue ( 'I2',$invoiceTrainingDetail['RIAmount'] );
  1807. }
  1808. //边框
  1809. $styleThinBlackBorderOutline = array(
  1810. 'borders' => array(
  1811. 'allborders' => array( //设置全部边框
  1812. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1813. ),
  1814. ),);
  1815. $obj->getActiveSheet()->getStyle( 'A4:H'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
  1816. cellColor('A4', 'ddebf7',$obj);cellColor('B4', 'ddebf7',$obj);
  1817. cellColor('C4', 'ddebf7',$obj);cellColor('D4', 'ddebf7',$obj);
  1818. cellColor('E4', 'ddebf7',$obj);cellColor('F4', 'ddebf7',$obj);
  1819. cellColor('H4', 'ddebf7',$obj);cellColor('G4', 'ddebf7',$obj);
  1820. $obj->getactivesheet()->setCellValue ( 'A4','开票流水' );
  1821. $obj->getactivesheet()->setCellValue ( 'B4','开票单位(抬头)' );
  1822. $obj->getactivesheet()->setCellValue ( 'C4','发票号' );
  1823. $obj->getactivesheet()->setCellValue ( 'D4','总额' );
  1824. $obj->getactivesheet()->setCellValue ( 'E4','状态' );
  1825. $obj->getactivesheet()->setCellValue ( 'F4','办事处收款' );
  1826. $obj->getactivesheet()->setCellValue ( 'G4','收款流水号' );
  1827. $obj->getactivesheet()->setCellValue ( 'H4','收款银行到账' );
  1828. $i=5;$maxArray=array();
  1829. foreach ($invoiceList as $key=>$value){
  1830. $obj->getactivesheet()->setCellValue ( 'A'.$i,$value['invoiceSerial'] );
  1831. $title='';
  1832. if(!empty($value['invoiceType'])){
  1833. $title=$value['invoiceCompany'];
  1834. }else{
  1835. $title=$value['invoiceTitle'];
  1836. }
  1837. $obj->getactivesheet()->setCellValue ( 'B'.$i,$title );
  1838. $obj->getactivesheet()->setCellValue ( 'C'.$i,$value['invoiceNo'] );
  1839. if(!empty($value['invoiceType'])){
  1840. $obj->getactivesheet()->setCellValue ( 'D'.$i,'专'.$value['invoicePrice'] );
  1841. }else{
  1842. $obj->getactivesheet()->setCellValue ( 'D'.$i,$value['invoicePrice'] );
  1843. }
  1844. if($value['untreadStatus']==3){
  1845. $obj->getactivesheet()->setCellValue ( 'E'.$i,'已入账' );
  1846. }else{
  1847. $obj->getactivesheet()->setCellValue ( 'E'.$i,'已出票' );
  1848. }
  1849. if($value['untreadStatus']==3){
  1850. if($value['RIstatus']==1){
  1851. $obj->getactivesheet()->setCellValue ( 'F'.$i,'已收款' );
  1852. }
  1853. }else{
  1854. if($value['RIstatus']==1){
  1855. $obj->getactivesheet()->setCellValue ( 'F'.$i,'已收款' );
  1856. }
  1857. }
  1858. $receivablesSerial='';
  1859. $receivablesDate='';$hang=0;
  1860. if($value['untreadStatus']==3){
  1861. foreach ($value['irDetail'] as $k=>$v){
  1862. $receivablesSerial.=$v['receivablesSerial']."\r\n";
  1863. $receivablesDate.=$v['receivablesDate']."\r\n";
  1864. $hang+=8;
  1865. }
  1866. if($hang>8){
  1867. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18+$hang);
  1868. }
  1869. }
  1870. $obj->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setWrapText(true);
  1871. $obj->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setWrapText(true);
  1872. $obj->getactivesheet()->setCellValue ( 'G'.$i,$receivablesSerial );
  1873. $obj->getactivesheet()->setCellValue ( 'H'.$i,$receivablesDate );
  1874. //按字体多少自动拉长单元格
  1875. array_push($maxArray, strlen($title));
  1876. $i++;
  1877. }
  1878. $ma=0;
  1879. if (!empty($maxArray)){
  1880. $ma=max($maxArray);
  1881. }
  1882. $max=$ma-10;$fontlenght=25;
  1883. if($max>25){
  1884. $fontlenght=$max;
  1885. }
  1886. $obj->getActiveSheet()->getColumnDimension('B')->setWidth($fontlenght);
  1887. $obj->getActiveSheet ()->setTitle ( '收入' );
  1888. }
  1889. function makeReceiptLoanData($obj,$receiptLoanList){
  1890. if (empty($receiptLoanList)){
  1891. $obj->getActiveSheet ()->setTitle ( '借款' );
  1892. return ;
  1893. }
  1894. $base=$lnBase=0;$lnKey=1;$lnBase=14;
  1895. //定义行倍数
  1896. $lnKey2=2;$lnKey3=3;$lnKey4=4;$lnKey5=5;
  1897. $lnKey6=6;$lnKey7=7;$lnKey8=8;$lnKey9=9;
  1898. $lnKey10=10;$lnKey11=11;$lnKey12=12;$lnKey13=13;
  1899. $lnKey14=14;
  1900. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(35);
  1901. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(35);
  1902. foreach ($receiptLoanList as $key=>$receiptLoanDetail){
  1903. $lineNumber=1;
  1904. $lineNumber=$lineNumber+$base;
  1905. $maxBase=$base+16;
  1906. //echo $maxBase.'<br/>';
  1907. for (;$lineNumber<=$maxBase;$lineNumber++){
  1908. $lineNumberDynamic = 'ln'.$lineNumber;
  1909. $$lineNumberDynamic=$lineNumber;
  1910. $obj->getActiveSheet()->getStyle('A'.$lineNumber.':B'.$lineNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  1911. $obj->getActiveSheet()->getStyle('A'.$lineNumber.':B'.$lineNumber)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  1912. $obj->getActiveSheet()->getRowDimension($lineNumber)->setRowHeight(18);
  1913. }
  1914. //正文
  1915. $receiptLoanDetail ['loanItem'] = json_decode ( $receiptLoanDetail ['loanItem'], true );
  1916. $receiptLoanDetail ['sumCN'] = num_to_rmb ( $receiptLoanDetail ['sum'] );
  1917. $receiptLoanDetail ['loanSumCN'] = num_to_rmb ( $receiptLoanDetail ['loanSum'] );
  1918. $receiptLoanDetail ['amountCN'] = num_to_rmb ( $receiptLoanDetail ['amount'] );
  1919. //echo $receiptLoanDetail ['sumCN'].'<br/>';
  1920. //边框
  1921. $styleThinBlackBorderOutline = array(
  1922. 'borders' => array(
  1923. 'allborders' => array( //设置全部边框
  1924. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1925. ),
  1926. ),);
  1927. $obj->getActiveSheet()->getStyle( 'A'.${'ln'.$lnKey}.':B'.${'ln'.$lnBase})->applyFromArray($styleThinBlackBorderOutline);
  1928. //绘制颜色
  1929. cellColor('A'.${'ln'.$lnKey}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey3}, 'ddebf7',$obj);
  1930. cellColor('A'.${'ln'.$lnKey2}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey6}, 'ddebf7',$obj);
  1931. cellColor('A'.${'ln'.$lnKey7}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey8}, 'ddebf7',$obj);
  1932. cellColor('A'.${'ln'.$lnKey9}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey10}, 'ddebf7',$obj);
  1933. cellColor('A'.${'ln'.$lnKey5}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey11}, 'ddebf7',$obj);
  1934. //正文内容
  1935. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey}.':B'.${'ln'.$lnKey});
  1936. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey},'借款费用' );
  1937. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1938. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey3}.':B'.${'ln'.$lnKey3});
  1939. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey3},'产生费用所在办事处' );
  1940. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey3})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1941. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey5}.':B'.${'ln'.$lnKey5});
  1942. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey5},'汇款信息' );
  1943. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey5})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1944. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey11}.':B'.${'ln'.$lnKey11});
  1945. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey11},'费用说明' );
  1946. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey11})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1947. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey2},'借款费用' );
  1948. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey2},$receiptLoanDetail ['loanItem'] ['借款费用'] [0] ['price'] );
  1949. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey4}.':B'.${'ln'.$lnKey4});
  1950. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey4},$receiptLoanDetail ['category'] [0] ['title'] );
  1951. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey6},'汇款人户名' );
  1952. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey7},'汇款银行' );
  1953. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey8},'汇款开户银行名称' );
  1954. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey9},'汇款帐号' );
  1955. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey10},'联行号' );
  1956. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey6},$receiptLoanDetail ['remittanceName'] );
  1957. if ($receiptLoanDetail ['remittanceBankType'] == 0){
  1958. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey7},'广发银行' );
  1959. }elseif ($receiptLoanDetail ['remittanceBankType'] == 1){
  1960. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey7},'其他' );
  1961. }
  1962. autoCellsWidth($obj,'B',$receiptLoanDetail ['bankName']);
  1963. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey8},$receiptLoanDetail ['bankName'] );
  1964. $obj->getActiveSheet()->setCellValueExplicit('B'.${'ln'.$lnKey9},$receiptLoanDetail ['bankNumber'],PHPExcel_Cell_DataType::TYPE_STRING);
  1965. //$obj->getactivesheet()->setCellValue ( 'B9',$receiptLoanDetail ['bankNumber'] );
  1966. if ($receiptLoanDetail ['remittanceBankType'] == 1){
  1967. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey10},$receiptLoanDetail ['coupletNumber'] );
  1968. }else{
  1969. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey10},'' );
  1970. }
  1971. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey12}.':B'.${'ln'.$lnKey12});
  1972. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey12},$receiptLoanDetail ['explanation'] );
  1973. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey13}.':B'.${'ln'.$lnKey13})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  1974. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey14}.':B'.${'ln'.$lnKey14})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  1975. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey13},'(' . $receiptLoanDetail ['receiptOrder'] . ')本次费用合计' );
  1976. $obj->getActiveSheet()->getStyle('B'.${'ln'.$lnKey13})->getAlignment()->setWrapText(true);
  1977. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey13},"¥" . $receiptLoanDetail ['sum'] . "\r\n" . $receiptLoanDetail ['sumCN'] );
  1978. $obj->getActiveSheet()->getRowDimension(${'ln'.$lnKey13})->setRowHeight(36);
  1979. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey14},'汇款金额');
  1980. $obj->getActiveSheet()->getStyle('B'.${'ln'.$lnKey14})->getAlignment()->setWrapText(true);
  1981. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey14},"¥" . $receiptLoanDetail ['amount'] . "\r\n" . $receiptLoanDetail ['amountCN'] );
  1982. $obj->getActiveSheet()->getRowDimension(${'ln'.$lnKey14})->setRowHeight(36);
  1983. //绘制计算
  1984. $lnKey=$lnBase+2;$lnKey2=$lnBase+3;$lnKey3=$lnBase+4;$lnKey4=$lnBase+5;
  1985. $lnKey5=$lnBase+6;$lnKey6=$lnBase+7;$lnKey8=$lnBase+9;$lnKey9=$lnBase+10;
  1986. $lnKey10=$lnBase+11;$lnKey11=$lnBase+12;$lnKey12=$lnBase+13;$lnKey14=$lnBase+15;
  1987. $lnKey7=$lnBase+8;$lnKey13=$lnBase+14;
  1988. $lnBase=$lnKey+14;
  1989. $base+=15;
  1990. }
  1991. //die;
  1992. $obj->getActiveSheet ()->setTitle ( '借款' );
  1993. }
  1994. //绘制汇总
  1995. function makeSummaryData($obj,$summary,$aiList){
  1996. //设置居中
  1997. //$obj->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1998. for($i=1;$i<=35;$i++){
  1999. $obj->getActiveSheet()->getStyle('A'.$i.':J'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2000. if ($i>=19){
  2001. $obj->getActiveSheet()->getStyle('A'.$i.':B'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  2002. }
  2003. }
  2004. //设置单元格宽
  2005. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  2006. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  2007. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  2008. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  2009. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  2010. $obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
  2011. $obj->getActiveSheet()->mergeCells('A1:A2');
  2012. $obj->getActiveSheet()->mergeCells('B1:C1');
  2013. $obj->getActiveSheet()->mergeCells('D1:E1');
  2014. $obj->getActiveSheet()->mergeCells('C2:C3');
  2015. $obj->getActiveSheet()->mergeCells('E2:E3');
  2016. $obj->getActiveSheet()->mergeCells('A6:E6');
  2017. $obj->getActiveSheet()->mergeCells('A10:E10');
  2018. $obj->getActiveSheet()->mergeCells('A15:E15');
  2019. $obj->getActiveSheet()->mergeCells('A16:E16');
  2020. //支出详情
  2021. $obj->getActiveSheet()->mergeCells('A18:C18');
  2022. $obj->getActiveSheet()->mergeCells('A19:A35');
  2023. cellColor('A1', 'ddebf7',$obj);cellColor('A2', 'ddebf7',$obj);
  2024. cellColor('B1', 'ddebf7',$obj);cellColor('B2', 'ddebf7',$obj);
  2025. cellColor('C2', 'ddebf7',$obj);cellColor('E2', 'ddebf7',$obj);
  2026. cellColor('D1', 'ddebf7',$obj);cellColor('D2', 'ddebf7',$obj);
  2027. cellColor('E3', 'ddebf7',$obj);cellColor('C3', 'ddebf7',$obj);
  2028. for ($i=3;$i<=15;$i++){
  2029. cellColor('A'.$i, 'ddebf7',$obj);
  2030. }
  2031. //支出详情
  2032. cellColor('A18', 'ddebf7',$obj);cellColor('D18', 'ddebf7',$obj);
  2033. cellColor('E18', 'ddebf7',$obj);cellColor('A19', 'ddebf7',$obj);
  2034. for ($i=19;$i<=35;$i++){
  2035. cellColor('B'.$i, 'ddebf7',$obj);
  2036. }
  2037. //边框
  2038. $styleThinBlackBorderOutline = array(
  2039. 'borders' => array(
  2040. 'allborders' => array( //设置全部边框
  2041. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2042. ),
  2043. ),
  2044. );
  2045. $obj->getActiveSheet()->getStyle( 'A1:E16')->applyFromArray($styleThinBlackBorderOutline);
  2046. //支出详情
  2047. $obj->getActiveSheet()->getStyle( 'A18:E35')->applyFromArray($styleThinBlackBorderOutline);
  2048. $obj->getactivesheet()->setCellValue ( 'A1','汇总项目' );
  2049. $obj->getactivesheet()->setCellValue ( 'B1','收入按开票金额计算' );
  2050. $obj->getactivesheet()->setCellValue ( 'D1','收入按入账金额计算' );
  2051. $obj->getactivesheet()->setCellValue ( 'B2','金额' );
  2052. $obj->getactivesheet()->setCellValue ( 'C2','占比' );
  2053. $obj->getactivesheet()->setCellValue ( 'D2','金额' );
  2054. $obj->getactivesheet()->setCellValue ( 'E2','占比' );
  2055. $obj->getactivesheet()->setCellValue ( 'A3','收入' );
  2056. $obj->getactivesheet()->setCellValue ( 'A4','支出' );
  2057. $obj->getactivesheet()->setCellValue ( 'A5','利润' );
  2058. $obj->getactivesheet()->setCellValue ( 'A6','收入-支出=利润' );
  2059. $obj->getactivesheet()->setCellValue ( 'A7','公司利润' );
  2060. $obj->getactivesheet()->setCellValue ( 'A8','办事处利润' );
  2061. $obj->getactivesheet()->setCellValue ( 'A9','公司收款' );
  2062. $obj->getactivesheet()->setCellValue ( 'A10','收入×40%=办事处利润 收入×60%=公司利润' );
  2063. $obj->getactivesheet()->setCellValue ( 'A11','备用金(借款)' );
  2064. $obj->getactivesheet()->setCellValue ( 'A12','办事处收款' );
  2065. $obj->getactivesheet()->setCellValue ( 'A13','办事处实际支出' );
  2066. $obj->getactivesheet()->setCellValue ( 'A14','付总部款' );
  2067. $obj->getactivesheet()->setCellValue ( 'A15','备用金+办事处收款-办事处实际支出=付总部款' );
  2068. //支出详情
  2069. $obj->getactivesheet()->setCellValue ( 'A18','项目' );
  2070. $obj->getactivesheet()->setCellValue ( 'D18','金额' );
  2071. $obj->getactivesheet()->setCellValue ( 'E18','占入账金额比例' );
  2072. $obj->getactivesheet()->setCellValue ( 'A19','支出明细' );
  2073. $startKey=19;
  2074. foreach ($aiList as $key=>$value){
  2075. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2076. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2077. if($value['name']=='讲课费'){
  2078. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2079. $obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+2));
  2080. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2081. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2082. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'外聘' );
  2083. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['outsideTaxPrice'] );
  2084. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['outsideTaxProportion'].'%' );
  2085. $startKey+=1;
  2086. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2087. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2088. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'外聘(不计税)' );
  2089. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['outsideNoTaxPrice'] );
  2090. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['outsideNoTaxProportion'].'%' );
  2091. $startKey+=1;
  2092. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2093. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2094. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'员工' );
  2095. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['insidePrice'] );
  2096. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['insideProportion'].'%' );
  2097. }elseif($value['name']=='办公费'){
  2098. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2099. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2100. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2101. $obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+1));
  2102. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'办事处支出' );
  2103. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['categoryPrice'] );
  2104. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['categoryProportion'].'%' );
  2105. $startKey=$startKey+1;
  2106. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2107. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2108. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['companyPrice'] );
  2109. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['companyProportion'].'%' );
  2110. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'公司支出' );
  2111. }elseif($value['name']=='邮寄费'){
  2112. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2113. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2114. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2115. $obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+1));
  2116. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'办事处支出' );
  2117. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['categoryPrice'] );
  2118. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['categoryProportion'].'%' );
  2119. $startKey=$startKey+1;
  2120. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2121. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2122. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['companyPrice'] );
  2123. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['companyProportion'].'%' );
  2124. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'公司支出' );
  2125. }else{
  2126. $obj->getActiveSheet()->mergeCells('C'.$startKey.':D'.$startKey);
  2127. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2128. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,$value['priceFormat'] );
  2129. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['proportion'].'%' );
  2130. }
  2131. $startKey++;
  2132. }
  2133. //小计
  2134. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2135. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2136. $obj->getActiveSheet()->mergeCells('C'.$startKey.':D'.$startKey);
  2137. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,'小计' );
  2138. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,$summary[11]['total'] );
  2139. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$summary[11]['totalProportion'].'%' );
  2140. $startKey=3;
  2141. //内容
  2142. foreach ($summary as $key=>$value){
  2143. $k=$key+$startKey;
  2144. if($k==3){
  2145. $obj->getactivesheet()->setCellValue ( 'B'.$k,$value['invoiceTotalAmount'] );
  2146. $obj->getactivesheet()->setCellValue ( 'D'.$k,$value['invoiceArriveAmount'] );
  2147. }elseif($k==15){
  2148. $k+=1;
  2149. $obj->getactivesheet()->setCellValue ( 'A'.$k,'学员:'.$value['participants'].'人 讲师:'.$value['lectureCount'].' 人' );
  2150. }elseif($k==16){
  2151. }elseif($k==6||$k==10){
  2152. $k+=1;
  2153. $startKey+=1;
  2154. $obj->getactivesheet()->setCellValue ( 'B'.$k,$value[1] );
  2155. $obj->getactivesheet()->setCellValue ( 'C'.$k,$value[2] );
  2156. $obj->getactivesheet()->setCellValue ( 'D'.$k,$value[3] );
  2157. $obj->getactivesheet()->setCellValue ( 'E'.$k,$value[4] );
  2158. }else{
  2159. $obj->getactivesheet()->setCellValue ( 'B'.$k,$value[1] );
  2160. $obj->getactivesheet()->setCellValue ( 'C'.$k,$value[2] );
  2161. $obj->getactivesheet()->setCellValue ( 'D'.$k,$value[3] );
  2162. $obj->getactivesheet()->setCellValue ( 'E'.$k,$value[4] );
  2163. }
  2164. }
  2165. $obj->getActiveSheet ()->setTitle ( '汇总表' );
  2166. }
  2167. function autoCellsWidth($obj,$cellsNub,$str){
  2168. $max=strlen($str)-10;$fontlenght=35;
  2169. if($max>35){
  2170. $fontlenght=$max;
  2171. }
  2172. $obj->getActiveSheet()->getColumnDimension($cellsNub)->setWidth($fontlenght);
  2173. }
  2174. ?>