receipt.func.php 100 KB

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