receipt.func.php 91 KB

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