receipt.func.php 87 KB

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