receipt.func.php 83 KB

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