receipt.func.php 97 KB

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