receipt.func.php 96 KB

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