receipt.func.php 81 KB

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