receipt.func.php 84 KB

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