receipt.func.php 100 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019
  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. }elseif ($i == 13) {
  587. $html .= '<tr><th colspan="2" >纵横文库提现</th>';
  588. $sum = 0;
  589. for($month = 1; $month <= 12; $month ++) {
  590. $falg = true;
  591. foreach ( $statisticsPay as $key => $value ) {
  592. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  593. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  594. $sum += abs ( $value ['payPrice'] );
  595. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  596. $falg = false;
  597. break;
  598. }
  599. }
  600. if ($falg)
  601. $html .= '<td class="taR">-</td>';
  602. }
  603. if ($sum == 0){
  604. $html .= '<td class="taR">-</td>';
  605. }else{
  606. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  607. }
  608. $html .= '</tr>';
  609. }elseif ($i == 14) {
  610. $html .= '<tr><th colspan="2" >其他</th>';
  611. $sum = 0;
  612. for($month = 1; $month <= 12; $month ++) {
  613. $falg = true;
  614. foreach ( $statisticsPay as $key => $value ) {
  615. if ($value ['expenditureMsg'] == '' && $value ['month'] == $month && $value ['expenditureType'] == $i) {
  616. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  617. $sum += abs ( $value ['payPrice'] );
  618. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  619. $falg = false;
  620. break;
  621. }
  622. }
  623. if ($falg)
  624. $html .= '<td class="taR">-</td>';
  625. }
  626. if ($sum == 0){
  627. $html .= '<td class="taR">-</td>';
  628. }else{
  629. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  630. }
  631. $html .= '</tr>';
  632. }
  633. }
  634. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  635. $sum = 0;
  636. foreach ( $subtotalSum as $key => $value ) {
  637. $sum += $value;
  638. if (! empty ( $value ))
  639. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  640. else
  641. $html .= '<td class="taR">-</td>';
  642. }
  643. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  644. $html .= '</tr>';
  645. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  646. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  647. return array (
  648. 'html' => $html,
  649. 'sum' => $sum
  650. );
  651. }
  652. /**
  653. * 获得汇总 日常收支年
  654. * @param array $statisticsIncome
  655. * @return string
  656. */
  657. function _getPaymentsCollectByYearHtml($statisticsIncome = array()) {
  658. $html = '';
  659. $subtotalSum = array (
  660. 1 => 0,
  661. 2 => 0,
  662. 3 => 0,
  663. 4 => 0,
  664. 5 => 0,
  665. 6 => 0,
  666. 7 => 0,
  667. 8 => 0,
  668. 9 => 0,
  669. 10 => 0,
  670. 11 => 0,
  671. 12 => 0
  672. );
  673. for($i = 1; $i <= 15; $i ++) {
  674. if ($i == 1) {
  675. $subtotal = array (
  676. 1 => 0,
  677. 2 => 0,
  678. 3 => 0,
  679. 4 => 0,
  680. 5 => 0,
  681. 6 => 0,
  682. 7 => 0,
  683. 8 => 0,
  684. 9 => 0,
  685. 10 => 0,
  686. 11 => 0,
  687. 12 => 0
  688. );
  689. $html .= '<tr><th rowspan="5" width="90">利息收入</th>';
  690. $html .= '<th width="90">银行存款</th>';
  691. $sum = 0;
  692. for($month = 1; $month <= 12; $month ++) {
  693. $falg = true;
  694. foreach ( $statisticsIncome as $key => $value ) {
  695. if ($value ['accountMsg'] == '银行存款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  696. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  697. $sum += $value ['inComePrice'];
  698. $subtotal [$month] += $value ['inComePrice'];
  699. $falg = false;
  700. break;
  701. }
  702. }
  703. if ($falg)
  704. $html .= '<td class="taR">-</td>';
  705. }
  706. if ($sum == 0)
  707. $html .= '<td class="taR">-</td>';
  708. else
  709. $html .= '<td class="taR">¥' . $sum . '</td>';
  710. $html .= '</tr>';
  711. $html .= '<th width="90">活期理财收益</th>';
  712. $sum = 0;
  713. for($month = 1; $month <= 12; $month ++) {
  714. $falg = true;
  715. foreach ( $statisticsIncome as $key => $value ) {
  716. if ($value ['accountMsg'] == '活期理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) {
  717. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  718. $sum += $value ['inComePrice'];
  719. $subtotal [$month] += $value ['inComePrice'];
  720. $falg = false;
  721. break;
  722. }
  723. }
  724. if ($falg)
  725. $html .= '<td class="taR">-</td>';
  726. }
  727. if ($sum == 0)
  728. $html .= '<td class="taR">-</td>';
  729. else
  730. $html .= '<td class="taR">¥' . $sum . '</td>';
  731. $html .= '</tr>';
  732. $html .= '<th width="90">固定理财收益</th>';
  733. $sum = 0;
  734. for($month = 1; $month <= 12; $month ++) {
  735. $falg = true;
  736. foreach ( $statisticsIncome as $key => $value ) {
  737. if ($value ['accountMsg'] == '固定理财收益' && $value ['month'] == $month && $value ['accountType'] == $i) {
  738. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  739. $sum += $value ['inComePrice'];
  740. $subtotal [$month] += $value ['inComePrice'];
  741. $falg = false;
  742. break;
  743. }
  744. }
  745. if ($falg)
  746. $html .= '<td class="taR">-</td>';
  747. }
  748. if ($sum == 0)
  749. $html .= '<td class="taR">-</td>';
  750. else
  751. $html .= '<td class="taR">¥' . $sum . '</td>';
  752. $html .= '</tr>';
  753. $html .= '<th width="90">个人借款</th>';
  754. $sum = 0;
  755. for($month = 1; $month <= 12; $month ++) {
  756. $falg = true;
  757. foreach ( $statisticsIncome as $key => $value ) {
  758. if ($value ['accountMsg'] == '个人借款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  759. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  760. $sum += $value ['inComePrice'];
  761. $subtotal [$month] += $value ['inComePrice'];
  762. $falg = false;
  763. break;
  764. }
  765. }
  766. if ($falg)
  767. $html .= '<td class="taR">-</td>';
  768. }
  769. if ($sum == 0)
  770. $html .= '<td class="taR">-</td>';
  771. else
  772. $html .= '<td class="taR">¥' . $sum . '</td>';
  773. $html .= '</tr>';
  774. $html .= '<th width="90" class="colGreen">小计</th>';
  775. $sum = 0;
  776. for($month = 1; $month <= 12; $month ++) {
  777. $sum += $subtotal [$month];
  778. $subtotalSum [$month] += $subtotal [$month];
  779. if (! empty ( $subtotal [$month] ))
  780. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  781. else
  782. $html .= '<td class="taR">-</td>';
  783. }
  784. if ($sum == 0)
  785. $html .= '<td class="taR">-</td>';
  786. else
  787. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  788. $html .= '</tr>';
  789. } elseif ($i == 2) {
  790. $subtotal = array (
  791. 1 => 0,
  792. 2 => 0,
  793. 3 => 0,
  794. 4 => 0,
  795. 5 => 0,
  796. 6 => 0,
  797. 7 => 0,
  798. 8 => 0,
  799. 9 => 0,
  800. 10 => 0,
  801. 11 => 0,
  802. 12 => 0
  803. );
  804. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  805. $html .= '<th width="90">社保</th>';
  806. $sum = 0;
  807. for($month = 1; $month <= 12; $month ++) {
  808. $falg = true;
  809. foreach ( $statisticsIncome as $key => $value ) {
  810. if ($value ['accountMsg'] == '社保' && $value ['month'] == $month && $value ['accountType'] == $i) {
  811. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  812. $sum += $value ['inComePrice'];
  813. $subtotal [$month] += $value ['inComePrice'];
  814. $falg = false;
  815. break;
  816. }
  817. }
  818. if ($falg)
  819. $html .= '<td class="taR">-</td>';
  820. }
  821. if ($sum == 0)
  822. $html .= '<td class="taR">-</td>';
  823. else
  824. $html .= '<td class="taR">¥' . $sum . '</td>';
  825. $html .= '</tr>';
  826. $html .= '<th width="90">财政</th>';
  827. $sum = 0;
  828. for($month = 1; $month <= 12; $month ++) {
  829. $falg = true;
  830. foreach ( $statisticsIncome as $key => $value ) {
  831. if ($value ['accountMsg'] == '财政' && $value ['month'] == $month && $value ['accountType'] == $i) {
  832. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  833. $sum += $value ['inComePrice'];
  834. $subtotal [$month] += $value ['inComePrice'];
  835. $falg = false;
  836. break;
  837. }
  838. }
  839. if ($falg)
  840. $html .= '<td class="taR">-</td>';
  841. }
  842. if ($sum == 0)
  843. $html .= '<td class="taR">-</td>';
  844. else
  845. $html .= '<td class="taR">¥' . $sum . '</td>';
  846. $html .= '</tr>';
  847. $html .= '<th width="90" class="colGreen">小计</th>';
  848. $sum = 0;
  849. for($month = 1; $month <= 12; $month ++) {
  850. $sum += $subtotal [$month];
  851. $subtotalSum [$month] += $subtotal [$month];
  852. if (! empty ( $subtotal [$month] ))
  853. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  854. else
  855. $html .= '<td class="taR">-</td>';
  856. }
  857. if ($sum == 0)
  858. $html .= '<td class="taR">-</td>';
  859. else
  860. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  861. $html .= '</tr>';
  862. } elseif ($i == 3) {
  863. $html .= '<tr><th colspan="2" >纵横知道</th>';
  864. $sum = 0;
  865. for($month = 1; $month <= 12; $month ++) {
  866. $falg = true;
  867. foreach ( $statisticsIncome as $key => $value ) {
  868. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  869. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  870. $sum += $value ['inComePrice'];
  871. $subtotalSum [$month] += $value ['inComePrice'];
  872. $falg = false;
  873. break;
  874. }
  875. }
  876. if ($falg)
  877. $html .= '<td class="taR">-</td>';
  878. }
  879. if ($sum == 0)
  880. $html .= '<td class="taR">-</td>';
  881. else
  882. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  883. $html .= '</tr>';
  884. } elseif ($i == 4) {
  885. $subtotal = array (
  886. 1 => 0,
  887. 2 => 0,
  888. 3 => 0,
  889. 4 => 0,
  890. 5 => 0,
  891. 6 => 0,
  892. 7 => 0,
  893. 8 => 0,
  894. 9 => 0,
  895. 10 => 0,
  896. 11 => 0,
  897. 12 => 0
  898. );
  899. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  900. $html .= '<th width="90">备用金</th>';
  901. $sum = 0;
  902. for($month = 1; $month <= 12; $month ++) {
  903. $falg = true;
  904. foreach ( $statisticsIncome as $key => $value ) {
  905. if ($value ['accountMsg'] == '备用金' && $value ['month'] == $month && $value ['accountType'] == $i) {
  906. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  907. $sum += $value ['inComePrice'];
  908. $subtotal [$month] += $value ['inComePrice'];
  909. $falg = false;
  910. break;
  911. }
  912. }
  913. if ($falg)
  914. $html .= '<td class="taR">-</td>';
  915. }
  916. if ($sum == 0)
  917. $html .= '<td class="taR">-</td>';
  918. else
  919. $html .= '<td class="taR">¥' . $sum . '</td>';
  920. $html .= '</tr>';
  921. $html .= '<th width="90">私人借款</th>';
  922. $sum = 0;
  923. for($month = 1; $month <= 12; $month ++) {
  924. $falg = true;
  925. foreach ( $statisticsIncome as $key => $value ) {
  926. if ($value ['accountMsg'] == '私人借款' && $value ['month'] == $month && $value ['accountType'] == $i) {
  927. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  928. $sum += $value ['inComePrice'];
  929. $subtotal [$month] += $value ['inComePrice'];
  930. $falg = false;
  931. break;
  932. }
  933. }
  934. if ($falg)
  935. $html .= '<td class="taR">-</td>';
  936. }
  937. if ($sum == 0)
  938. $html .= '<td class="taR">-</td>';
  939. else
  940. $html .= '<td class="taR">¥' . $sum . '</td>';
  941. $html .= '</tr>';
  942. $html .= '<th width="90" class="colGreen">小计</th>';
  943. $sum = 0;
  944. for($month = 1; $month <= 12; $month ++) {
  945. $sum += $subtotal [$month];
  946. $subtotalSum [$month] += $subtotal [$month];
  947. if (! empty ( $subtotal [$month] ))
  948. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  949. else
  950. $html .= '<td class="taR">-</td>';
  951. }
  952. if ($sum == 0)
  953. $html .= '<td class="taR">-</td>';
  954. else
  955. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  956. $html .= '</tr>';
  957. } elseif ($i == 5) {
  958. $html .= '<tr><th colspan="2" >退汇</th>';
  959. $sum = 0;
  960. for($month = 1; $month <= 12; $month ++) {
  961. $falg = true;
  962. foreach ( $statisticsIncome as $key => $value ) {
  963. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  964. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  965. $sum += $value ['inComePrice'];
  966. $subtotalSum [$month] += $value ['inComePrice'];
  967. $falg = false;
  968. break;
  969. }
  970. }
  971. if ($falg)
  972. $html .= '<td class="taR">-</td>';
  973. }
  974. if ($sum == 0)
  975. $html .= '<td class="taR">-</td>';
  976. else
  977. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  978. $html .= '</tr>';
  979. } elseif ($i == 6) {
  980. $html .= '<tr><th colspan="2" >其他</th>';
  981. $sum = 0;
  982. for($month = 1; $month <= 12; $month ++) {
  983. $falg = true;
  984. foreach ( $statisticsIncome as $key => $value ) {
  985. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  986. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  987. $sum += $value ['inComePrice'];
  988. $subtotalSum [$month] += $value ['inComePrice'];
  989. $falg = false;
  990. break;
  991. }
  992. }
  993. if ($falg)
  994. $html .= '<td class="taR">-</td>';
  995. }
  996. if ($sum == 0)
  997. $html .= '<td class="taR">-</td>';
  998. else
  999. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1000. $html .= '</tr>';
  1001. } elseif ($i == 8) {
  1002. $html .= '<tr><th colspan="2" >保证金</th>';
  1003. $sum = 0;
  1004. for($month = 1; $month <= 12; $month ++) {
  1005. $falg = true;
  1006. foreach ( $statisticsIncome as $key => $value ) {
  1007. if ($value ['accountMsg'] == '' && $value ['month'] == $month && $value ['accountType'] == $i) {
  1008. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1009. $sum += $value ['inComePrice'];
  1010. $subtotalSum [$month] += $value ['inComePrice'];
  1011. $falg = false;
  1012. break;
  1013. }
  1014. }
  1015. if ($falg)
  1016. $html .= '<td class="taR">-</td>';
  1017. }
  1018. if ($sum == 0)
  1019. $html .= '<td class="taR">-</td>';
  1020. else
  1021. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1022. $html .= '</tr>';
  1023. }
  1024. }
  1025. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1026. $sum = 0;
  1027. foreach ( $subtotalSum as $key => $value ) {
  1028. $sum += $value;
  1029. if (! empty ( $value ))
  1030. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1031. else
  1032. $html .= '<td class="taR">-</td>';
  1033. }
  1034. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1035. $html .= '</tr>';
  1036. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全年合计</b></td>
  1037. <td class="colGreed taR" colspan="14"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1038. return array (
  1039. 'html' => $html,
  1040. 'sum' => $sum
  1041. );
  1042. }
  1043. /**
  1044. * 获得汇总 日常收支年
  1045. * @param array $statisticsIncome
  1046. * @return string
  1047. */
  1048. function _getPaymentsCollectByDayHtml($statisticsIncome = array(), $day = 0) {
  1049. $html = '<tr><th class="taC" colspan="2">日常收入</th>';
  1050. for($d = 1; $d <= $day; $d ++) {
  1051. $subtotalSum [$d] = 0;
  1052. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  1053. }
  1054. $html .= '<th class="taC" width="110">总计</th></tr>';
  1055. for($i = 1; $i <= 15; $i ++) {
  1056. if ($i == 1) {
  1057. for($d = 1; $d <= $day; $d ++) {
  1058. $subtotal [$d] = 0;
  1059. }
  1060. // $subtotal = array (
  1061. // 1 => 0,
  1062. // 2 => 0,
  1063. // 3 => 0,
  1064. // 4 => 0,
  1065. // 5 => 0,
  1066. // 6 => 0,
  1067. // 7 => 0,
  1068. // 8 => 0,
  1069. // 9 => 0,
  1070. // 10 => 0,
  1071. // 11 => 0,
  1072. // 12 => 0
  1073. // );
  1074. $html .= '<tr><th rowspan="4" width="90">利息收入</th>';
  1075. $html .= '<th width="90">银行存款</th>';
  1076. $sum = 0;
  1077. for($month = 1; $month <= $day; $month ++) {
  1078. $falg = true;
  1079. foreach ( $statisticsIncome as $key => $value ) {
  1080. if ($value ['accountMsg'] == '银行存款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1081. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1082. $sum += $value ['inComePrice'];
  1083. $subtotal [$month] += $value ['inComePrice'];
  1084. $falg = false;
  1085. break;
  1086. }
  1087. }
  1088. if ($falg)
  1089. $html .= '<td class="taR">-</td>';
  1090. }
  1091. if ($sum == 0)
  1092. $html .= '<td class="taR">-</td>';
  1093. else
  1094. $html .= '<td class="taR">¥' . $sum . '</td>';
  1095. $html .= '</tr>';
  1096. $html .= '<th width="90">理财收益</th>';
  1097. $sum = 0;
  1098. for($month = 1; $month <= $day; $month ++) {
  1099. $falg = true;
  1100. foreach ( $statisticsIncome as $key => $value ) {
  1101. if ($value ['accountMsg'] == '理财收益' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1102. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1103. $sum += $value ['inComePrice'];
  1104. $subtotal [$month] += $value ['inComePrice'];
  1105. $falg = false;
  1106. break;
  1107. }
  1108. }
  1109. if ($falg)
  1110. $html .= '<td class="taR">-</td>';
  1111. }
  1112. if ($sum == 0)
  1113. $html .= '<td class="taR">-</td>';
  1114. else
  1115. $html .= '<td class="taR">¥' . $sum . '</td>';
  1116. $html .= '</tr>';
  1117. $html .= '<th width="90">个人借款</th>';
  1118. $sum = 0;
  1119. for($month = 1; $month <= $day; $month ++) {
  1120. $falg = true;
  1121. foreach ( $statisticsIncome as $key => $value ) {
  1122. if ($value ['accountMsg'] == '个人借款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1123. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1124. $sum += $value ['inComePrice'];
  1125. $subtotal [$month] += $value ['inComePrice'];
  1126. $falg = false;
  1127. break;
  1128. }
  1129. }
  1130. if ($falg)
  1131. $html .= '<td class="taR">-</td>';
  1132. }
  1133. if ($sum == 0)
  1134. $html .= '<td class="taR">-</td>';
  1135. else
  1136. $html .= '<td class="taR">¥' . $sum . '</td>';
  1137. $html .= '</tr>';
  1138. $html .= '<th width="90" class="colGreen">小计</th>';
  1139. $sum = 0;
  1140. for($month = 1; $month <= $day; $month ++) {
  1141. $sum += $subtotal [$month];
  1142. $subtotalSum [$month] += $subtotal [$month];
  1143. if (! empty ( $subtotal [$month] ))
  1144. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  1145. else
  1146. $html .= '<td class="taR">-</td>';
  1147. }
  1148. if ($sum == 0)
  1149. $html .= '<td class="taR">-</td>';
  1150. else
  1151. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1152. $html .= '</tr>';
  1153. } elseif ($i == 2) {
  1154. for($d = 1; $d <= $day; $d ++) {
  1155. $subtotal [$d] = 0;
  1156. }
  1157. $html .= '<tr><th rowspan="3" width="90">补贴收入</th>';
  1158. $html .= '<th width="90">社保</th>';
  1159. $sum = 0;
  1160. for($month = 1; $month <= $day; $month ++) {
  1161. $falg = true;
  1162. foreach ( $statisticsIncome as $key => $value ) {
  1163. if ($value ['accountMsg'] == '社保' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1164. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1165. $sum += $value ['inComePrice'];
  1166. $subtotal [$month] += $value ['inComePrice'];
  1167. $falg = false;
  1168. break;
  1169. }
  1170. }
  1171. if ($falg)
  1172. $html .= '<td class="taR">-</td>';
  1173. }
  1174. if ($sum == 0)
  1175. $html .= '<td class="taR">-</td>';
  1176. else
  1177. $html .= '<td class="taR">¥' . $sum . '</td>';
  1178. $html .= '</tr>';
  1179. $html .= '<th width="90">财政</th>';
  1180. $sum = 0;
  1181. for($month = 1; $month <= $day; $month ++) {
  1182. $falg = true;
  1183. foreach ( $statisticsIncome as $key => $value ) {
  1184. if ($value ['accountMsg'] == '财政' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1185. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1186. $sum += $value ['inComePrice'];
  1187. $subtotal [$month] += $value ['inComePrice'];
  1188. $falg = false;
  1189. break;
  1190. }
  1191. }
  1192. if ($falg)
  1193. $html .= '<td class="taR">-</td>';
  1194. }
  1195. if ($sum == 0)
  1196. $html .= '<td class="taR">-</td>';
  1197. else
  1198. $html .= '<td class="taR">¥' . $sum . '</td>';
  1199. $html .= '</tr>';
  1200. $html .= '<th width="90" class="colGreen">小计</th>';
  1201. $sum = 0;
  1202. for($month = 1; $month <= $day; $month ++) {
  1203. $sum += $subtotal [$month];
  1204. $subtotalSum [$month] += $subtotal [$month];
  1205. if (! empty ( $subtotal [$month] ))
  1206. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  1207. else
  1208. $html .= '<td class="taR">-</td>';
  1209. }
  1210. if ($sum == 0)
  1211. $html .= '<td class="taR">-</td>';
  1212. else
  1213. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1214. $html .= '</tr>';
  1215. } elseif ($i == 3) {
  1216. $html .= '<tr><th colspan="2" >纵横知道</th>';
  1217. $sum = 0;
  1218. for($month = 1; $month <= $day; $month ++) {
  1219. $falg = true;
  1220. foreach ( $statisticsIncome as $key => $value ) {
  1221. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1222. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1223. $sum += $value ['inComePrice'];
  1224. $subtotalSum [$month] += $value ['inComePrice'];
  1225. $falg = false;
  1226. break;
  1227. }
  1228. }
  1229. if ($falg)
  1230. $html .= '<td class="taR">-</td>';
  1231. }
  1232. if ($sum == 0)
  1233. $html .= '<td class="taR">-</td>';
  1234. else
  1235. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1236. $html .= '</tr>';
  1237. } elseif ($i == 4) {
  1238. for($d = 1; $d <= $day; $d ++) {
  1239. $subtotal [$d] = 0;
  1240. }
  1241. $html .= '<tr><th rowspan="3" width="90">借款收回</th>';
  1242. $html .= '<th width="90">备用金</th>';
  1243. $sum = 0;
  1244. for($month = 1; $month <= $day; $month ++) {
  1245. $falg = true;
  1246. foreach ( $statisticsIncome as $key => $value ) {
  1247. if ($value ['accountMsg'] == '备用金' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1248. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1249. $sum += $value ['inComePrice'];
  1250. $subtotal [$month] += $value ['inComePrice'];
  1251. $falg = false;
  1252. break;
  1253. }
  1254. }
  1255. if ($falg)
  1256. $html .= '<td class="taR">-</td>';
  1257. }
  1258. if ($sum == 0)
  1259. $html .= '<td class="taR">-</td>';
  1260. else
  1261. $html .= '<td class="taR">¥' . $sum . '</td>';
  1262. $html .= '</tr>';
  1263. $html .= '<th width="90">私人借款</th>';
  1264. $sum = 0;
  1265. for($month = 1; $month <= $day; $month ++) {
  1266. $falg = true;
  1267. foreach ( $statisticsIncome as $key => $value ) {
  1268. if ($value ['accountMsg'] == '私人借款' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1269. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1270. $sum += $value ['inComePrice'];
  1271. $subtotal [$month] += $value ['inComePrice'];
  1272. $falg = false;
  1273. break;
  1274. }
  1275. }
  1276. if ($falg)
  1277. $html .= '<td class="taR">-</td>';
  1278. }
  1279. if ($sum == 0)
  1280. $html .= '<td class="taR">-</td>';
  1281. else
  1282. $html .= '<td class="taR">¥' . $sum . '</td>';
  1283. $html .= '</tr>';
  1284. $html .= '<th width="90" class="colGreen">小计</th>';
  1285. $sum = 0;
  1286. for($month = 1; $month <= $day; $month ++) {
  1287. $sum += $subtotal [$month];
  1288. $subtotalSum [$month] += $subtotal [$month];
  1289. if (! empty ( $subtotal [$month] ))
  1290. $html .= '<td class="taR colGreen">¥' . $subtotal [$month] . '</td>';
  1291. else
  1292. $html .= '<td class="taR">-</td>';
  1293. }
  1294. if ($sum == 0)
  1295. $html .= '<td class="taR">-</td>';
  1296. else
  1297. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1298. $html .= '</tr>';
  1299. } elseif ($i == 5) {
  1300. $html .= '<tr><th colspan="2" >退汇</th>';
  1301. $sum = 0;
  1302. for($month = 1; $month <= $day; $month ++) {
  1303. $falg = true;
  1304. foreach ( $statisticsIncome as $key => $value ) {
  1305. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1306. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1307. $sum += $value ['inComePrice'];
  1308. $subtotalSum [$month] += $value ['inComePrice'];
  1309. $falg = false;
  1310. break;
  1311. }
  1312. }
  1313. if ($falg)
  1314. $html .= '<td class="taR">-</td>';
  1315. }
  1316. if ($sum == 0)
  1317. $html .= '<td class="taR">-</td>';
  1318. else
  1319. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1320. $html .= '</tr>';
  1321. } elseif ($i == 6) {
  1322. $html .= '<tr><th colspan="2" >其他</th>';
  1323. $sum = 0;
  1324. for($month = 1; $month <= $day; $month ++) {
  1325. $falg = true;
  1326. foreach ( $statisticsIncome as $key => $value ) {
  1327. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1328. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1329. $sum += $value ['inComePrice'];
  1330. $subtotalSum [$month] += $value ['inComePrice'];
  1331. $falg = false;
  1332. break;
  1333. }
  1334. }
  1335. if ($falg)
  1336. $html .= '<td class="taR">-</td>';
  1337. }
  1338. if ($sum == 0)
  1339. $html .= '<td class="taR">-</td>';
  1340. else
  1341. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1342. $html .= '</tr>';
  1343. } elseif ($i == 8) {
  1344. $html .= '<tr><th colspan="2" >保证金</th>';
  1345. $sum = 0;
  1346. for($month = 1; $month <= $day; $month ++) {
  1347. $falg = true;
  1348. foreach ( $statisticsIncome as $key => $value ) {
  1349. if ($value ['accountMsg'] == '' && $value ['day'] == $month && $value ['accountType'] == $i) {
  1350. $html .= '<td class="taR">¥' . $value ['inComePrice'] . '</td>';
  1351. $sum += $value ['inComePrice'];
  1352. $subtotalSum [$month] += $value ['inComePrice'];
  1353. $falg = false;
  1354. break;
  1355. }
  1356. }
  1357. if ($falg)
  1358. $html .= '<td class="taR">-</td>';
  1359. }
  1360. if ($sum == 0)
  1361. $html .= '<td class="taR">-</td>';
  1362. else
  1363. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1364. $html .= '</tr>';
  1365. }
  1366. }
  1367. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1368. $sum = 0;
  1369. foreach ( $subtotalSum as $key => $value ) {
  1370. $sum += $value;
  1371. if (! empty ( $value ))
  1372. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1373. else
  1374. $html .= '<td class="taR">-</td>';
  1375. }
  1376. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1377. $html .= '</tr>';
  1378. $colspan = $day + 1;
  1379. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  1380. <td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1381. return array (
  1382. 'html' => $html,
  1383. 'sum' => $sum
  1384. );
  1385. }
  1386. function _getPaymentsCollectPayByDayHtml($statisticsPay = array(), $day = 0) {
  1387. $html = '<tr><th class="taC" colspan="2">日常支出</th>';
  1388. for($d = 1; $d <= $day; $d ++) {
  1389. $subtotalSum [$d] = 0;
  1390. $html .= '<th class="taC" width="80">' . $d . '日</th>';
  1391. }
  1392. $html .= '<th class="taC" width="110">总计</th></tr>';
  1393. for($i = 1; $i <= 15; $i ++) {
  1394. if ($i == 1) {
  1395. $html .= '<tr><th colspan="2" >银行手续费</th>';
  1396. $sum = 0;
  1397. for($month = 1; $month <= $day; $month ++) {
  1398. $falg = true;
  1399. foreach ( $statisticsPay as $key => $value ) {
  1400. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1401. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1402. $sum += $value ['payPrice'];
  1403. $subtotalSum [$month] += $value ['payPrice'];
  1404. $falg = false;
  1405. break;
  1406. }
  1407. }
  1408. if ($falg)
  1409. $html .= '<td class="taR">-</td>';
  1410. }
  1411. if ($sum == 0)
  1412. $html .= '<td class="taR">-</td>';
  1413. else
  1414. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1415. $html .= '</tr>';
  1416. } elseif ($i == 2) {
  1417. $html .= '<tr><th colspan="2" >总部电话费</th>';
  1418. $sum = 0;
  1419. for($month = 1; $month <= $day; $month ++) {
  1420. $falg = true;
  1421. foreach ( $statisticsPay as $key => $value ) {
  1422. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1423. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1424. $sum += $value ['payPrice'];
  1425. $subtotalSum [$month] += $value ['payPrice'];
  1426. $falg = false;
  1427. break;
  1428. }
  1429. }
  1430. if ($falg)
  1431. $html .= '<td class="taR">-</td>';
  1432. }
  1433. if ($sum == 0)
  1434. $html .= '<td class="taR">-</td>';
  1435. else
  1436. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1437. $html .= '</tr>';
  1438. } elseif ($i == 3) {
  1439. for($d = 1; $d <= $day; $d ++) {
  1440. $subtotal [$d] = 0;
  1441. }
  1442. $html .= '<tr><th rowspan="8" width="90">缴税</th>';
  1443. $html .= '<th width="90">增值税</th>';
  1444. $sum = 0;
  1445. for($month = 1; $month <= $day; $month ++) {
  1446. $falg = true;
  1447. foreach ( $statisticsPay as $key => $value ) {
  1448. if ($value ['expenditureMsg'] == '增值税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1449. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1450. $sum += $value ['payPrice'];
  1451. $subtotal [$month] += $value ['payPrice'];
  1452. $falg = false;
  1453. break;
  1454. }
  1455. }
  1456. if ($falg)
  1457. $html .= '<td class="taR">-</td>';
  1458. }
  1459. if ($sum == 0)
  1460. $html .= '<td class="taR">-</td>';
  1461. else
  1462. $html .= '<td class="taR">¥' . $sum . '</td>';
  1463. $html .= '</tr>';
  1464. $html .= '<th width="90">税金附加</th>';
  1465. $sum = 0;
  1466. for($month = 1; $month <= $day; $month ++) {
  1467. $falg = true;
  1468. foreach ( $statisticsPay as $key => $value ) {
  1469. if ($value ['expenditureMsg'] == '税金附加' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1470. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1471. $sum += $value ['payPrice'];
  1472. $subtotal [$month] += $value ['payPrice'];
  1473. $falg = false;
  1474. break;
  1475. }
  1476. }
  1477. if ($falg)
  1478. $html .= '<td class="taR">-</td>';
  1479. }
  1480. if ($sum == 0)
  1481. $html .= '<td class="taR">-</td>';
  1482. else
  1483. $html .= '<td class="taR">¥' . $sum . '</td>';
  1484. $html .= '</tr>';
  1485. $html .= '<th width="90">企业所得税</th>';
  1486. $sum = 0;
  1487. for($month = 1; $month <= $day; $month ++) {
  1488. $falg = true;
  1489. foreach ( $statisticsPay as $key => $value ) {
  1490. if ($value ['expenditureMsg'] == '企业所得税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1491. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1492. $sum += $value ['payPrice'];
  1493. $subtotal [$month] += $value ['payPrice'];
  1494. $falg = false;
  1495. break;
  1496. }
  1497. }
  1498. if ($falg)
  1499. $html .= '<td class="taR">-</td>';
  1500. }
  1501. if ($sum == 0)
  1502. $html .= '<td class="taR">-</td>';
  1503. else
  1504. $html .= '<td class="taR">¥' . $sum . '</td>';
  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">个税</th>';
  1554. $sum = 0;
  1555. for($month = 1; $month <= $day; $month ++) {
  1556. $falg = true;
  1557. foreach ( $statisticsPay as $key => $value ) {
  1558. if ($value ['expenditureMsg'] == '个税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1559. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1560. $sum += $value ['payPrice'];
  1561. $subtotal [$month] += $value ['payPrice'];
  1562. $falg = false;
  1563. break;
  1564. }
  1565. }
  1566. if ($falg)
  1567. $html .= '<td class="taR">-</td>';
  1568. }
  1569. if ($sum == 0){
  1570. $html .= '<td class="taR">-</td>';
  1571. }else{
  1572. $html .= '<td class="taR">¥' . $sum . '</td>';
  1573. }
  1574. $html .= '</tr>';
  1575. //----------------------------------------
  1576. $html .= '<th width="90">印花税</th>';
  1577. $sum = 0;
  1578. for($month = 1; $month <= $day; $month ++) {
  1579. $falg = true;
  1580. foreach ( $statisticsPay as $key => $value ) {
  1581. if ($value ['expenditureMsg'] == '印花税' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1582. $html .= '<td class="taR">¥' . $value ['payPrice'] . '</td>';
  1583. $sum += $value ['payPrice'];
  1584. $subtotal [$month] += $value ['payPrice'];
  1585. $falg = false;
  1586. break;
  1587. }
  1588. }
  1589. if ($falg)
  1590. $html .= '<td class="taR">-</td>';
  1591. }
  1592. if ($sum == 0){
  1593. $html .= '<td class="taR">-</td>';
  1594. }else{
  1595. $html .= '<td class="taR">¥' . $sum . '</td>';
  1596. }
  1597. $html .= '</tr>';
  1598. //----------------------------------------
  1599. $html .= '<th width="90" class="colRed">小计</th>';
  1600. $sum = 0;
  1601. for($month = 1; $month <= $day; $month ++) {
  1602. $sum += $subtotal [$month];
  1603. $subtotalSum [$month] += $subtotal [$month];
  1604. if (! empty ( $subtotal [$month] ))
  1605. $html .= '<td class="taR colRed">¥' . $subtotal [$month] . '</td>';
  1606. else
  1607. $html .= '<td class="taR">-</td>';
  1608. }
  1609. if ($sum == 0)
  1610. $html .= '<td class="taR">-</td>';
  1611. else
  1612. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1613. $html .= '</tr>';
  1614. } elseif ($i == 5) {
  1615. $html .= '<tr><th colspan="2" >保证金</th>';
  1616. $sum = 0;
  1617. for($month = 1; $month <= $day; $month ++) {
  1618. $falg = true;
  1619. foreach ( $statisticsPay as $key => $value ) {
  1620. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1621. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  1622. $sum += abs ( $value ['payPrice'] );
  1623. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  1624. $falg = false;
  1625. break;
  1626. }
  1627. }
  1628. if ($falg)
  1629. $html .= '<td class="taR">-</td>';
  1630. }
  1631. if ($sum == 0){
  1632. $html .= '<td class="taR">-</td>';
  1633. }else{
  1634. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1635. }
  1636. $html .= '</tr>';
  1637. }elseif ($i == 13) {
  1638. $html .= '<tr><th colspan="2" >纵横文库提现</th>';
  1639. $sum = 0;
  1640. for($month = 1; $month <= $day; $month ++) {
  1641. $falg = true;
  1642. foreach ( $statisticsPay as $key => $value ) {
  1643. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1644. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  1645. $sum += abs ( $value ['payPrice'] );
  1646. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  1647. $falg = false;
  1648. break;
  1649. }
  1650. }
  1651. if ($falg)
  1652. $html .= '<td class="taR">-</td>';
  1653. }
  1654. if ($sum == 0){
  1655. $html .= '<td class="taR">-</td>';
  1656. }else{
  1657. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1658. }
  1659. $html .= '</tr>';
  1660. }elseif ($i == 14) {
  1661. $html .= '<tr><th colspan="2" >其他</th>';
  1662. $sum = 0;
  1663. for($month = 1; $month <= $day; $month ++) {
  1664. $falg = true;
  1665. foreach ( $statisticsPay as $key => $value ) {
  1666. if ($value ['expenditureMsg'] == '' && $value ['day'] == $month && $value ['expenditureType'] == $i) {
  1667. $html .= '<td class="taR">¥' . abs ( $value ['payPrice'] ) . '</td>';
  1668. $sum += abs ( $value ['payPrice'] );
  1669. $subtotalSum [$month] += abs ( $value ['payPrice'] );
  1670. $falg = false;
  1671. break;
  1672. }
  1673. }
  1674. if ($falg)
  1675. $html .= '<td class="taR">-</td>';
  1676. }
  1677. if ($sum == 0){
  1678. $html .= '<td class="taR">-</td>';
  1679. }else{
  1680. $html .= '<td class="taR colRed">¥' . $sum . '</td>';
  1681. }
  1682. $html .= '</tr>';
  1683. }
  1684. }
  1685. $html .= '<tr><th class="taR" colspan="2">合计</th>';
  1686. $sum = 0;
  1687. foreach ( $subtotalSum as $key => $value ) {
  1688. $sum += $value;
  1689. if (! empty ( $value ))
  1690. $html .= '<td class="taR colGreen">¥' . $value . '</td>';
  1691. else
  1692. $html .= '<td class="taR">-</td>';
  1693. }
  1694. $html .= '<td class="taR colGreen">¥' . $sum . '</td>';
  1695. $html .= '</tr>';
  1696. $colspan = $day + 1;
  1697. $html .= '<tr class="warning"><td class="taR" colspan="2"><b>全月合计</b></td>
  1698. <td class="colGreed taR" colspan="' . $colspan . '"><b style="font-size:24px">¥' . $sum . '</b></td></tr>';
  1699. return array (
  1700. 'html' => $html,
  1701. 'sum' => $sum
  1702. );
  1703. }
  1704. function getExecuteStaff($receiptDetail) {
  1705. // 费用执行人相关数据
  1706. $executeCopy = json_decode ( $receiptDetail ['executeCopy'], true );
  1707. $executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );
  1708. foreach ( $executeCopy as $k => $v ) {
  1709. $executeCopy [$k] ['date'] = '';
  1710. $executeCopy [$k] ['opinion'] = '';
  1711. $executeCopy [$k] ['status'] = '';
  1712. if (! empty ( $executeStaff ))
  1713. foreach ( $executeStaff as $m => $u ) {
  1714. if ($v [0] == $m) {
  1715. $executeCopy [$k] ['date'] = $u ['date'];
  1716. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  1717. $executeCopy [$k] ['status'] = $u ['status'];
  1718. break;
  1719. }
  1720. }
  1721. }
  1722. $receiptDetail ['executeCopy'] = $executeCopy;
  1723. return $receiptDetail ['executeCopy'];
  1724. }
  1725. function num_to_rmb($num) {
  1726. $c1 = "零壹贰叁肆伍陆柒捌玖";
  1727. $c2 = "分角元拾佰仟万拾佰仟亿";
  1728. // 精确到分后面就不要了,所以只留两个小数位
  1729. $num = round ( $num, 2 );
  1730. // 将数字转化为整数
  1731. $num = $num * 100;
  1732. if (strlen ( $num ) > 10) {
  1733. return "金额太大,请检查";
  1734. }
  1735. $i = 0;
  1736. $c = "";
  1737. while ( 1 ) {
  1738. if ($i == 0) {
  1739. // 获取最后一位数字
  1740. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  1741. } else {
  1742. $n = $num % 10;
  1743. }
  1744. // 每次将最后一位数字转化为中文
  1745. $p1 = substr ( $c1, 3 * $n, 3 );
  1746. $p2 = substr ( $c2, 3 * $i, 3 );
  1747. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  1748. $c = $p1 . $p2 . $c;
  1749. } else {
  1750. $c = $p1 . $c;
  1751. }
  1752. $i = $i + 1;
  1753. // 去掉数字最后一位了
  1754. $num = $num / 10;
  1755. // echo $num.'</br>';
  1756. $num = ( int ) $num;
  1757. // $num =floor($num);
  1758. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  1759. // echo $num.'</br>';
  1760. // 结束循环
  1761. if ($num == 0) {
  1762. break;
  1763. }
  1764. }
  1765. // echo $c.'</br>';
  1766. $j = 0;
  1767. $slen = strlen ( $c );
  1768. while ( $j < $slen ) {
  1769. // utf8一个汉字相当3个字符
  1770. $m = substr ( $c, $j, 6 );
  1771. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  1772. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  1773. $left = substr ( $c, 0, $j );
  1774. $right = substr ( $c, $j + 3 );
  1775. $c = $left . $right;
  1776. $j = $j - 3;
  1777. $slen = $slen - 3;
  1778. }
  1779. $j = $j + 3;
  1780. }
  1781. // 这个是为了去掉类似23.0中最后一个“零”字
  1782. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  1783. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  1784. }
  1785. // 将处理的汉字加上“整”
  1786. if (empty ( $c )) {
  1787. return "零元整";
  1788. } else {
  1789. return $c . "整";
  1790. }
  1791. }
  1792. /**
  1793. * 数据导出
  1794. * @param array $title 标题行名称
  1795. * @param array $data 导出数据
  1796. * @param string $fileName 文件名
  1797. * @param string $savePath 保存路径
  1798. * @param $type 是否下载 false--保存 true--下载
  1799. * @return string 返回文件全路径
  1800. * @throws PHPExcel_Exception
  1801. * @throws PHPExcel_Reader_Exception @exportExcel(array('姓名','年龄'), array(array('a',21),array('b',23)), '档案', './', true);
  1802. */
  1803. function exportExcel($title = array(), $data = array(), $fileName = '', $savePath = './', $isDown = false) {
  1804. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  1805. $obj = new PHPExcel ();
  1806. // 横向单元格标识
  1807. $cellName = array (
  1808. 'A',
  1809. 'B',
  1810. 'C',
  1811. 'D',
  1812. 'E',
  1813. 'F',
  1814. 'G',
  1815. 'H',
  1816. 'I',
  1817. 'J',
  1818. 'K',
  1819. 'L',
  1820. 'M',
  1821. 'N',
  1822. 'O',
  1823. 'P',
  1824. 'Q',
  1825. 'R',
  1826. 'S',
  1827. 'T',
  1828. 'U',
  1829. 'V',
  1830. 'W',
  1831. 'X',
  1832. 'Y',
  1833. 'Z',
  1834. 'AA',
  1835. 'AB',
  1836. 'AC',
  1837. 'AD',
  1838. 'AE',
  1839. 'AF',
  1840. 'AG',
  1841. 'AH',
  1842. 'AI',
  1843. 'AJ',
  1844. 'AK',
  1845. 'AL',
  1846. 'AM',
  1847. 'AN',
  1848. 'AO',
  1849. 'AP',
  1850. 'AQ',
  1851. 'AR',
  1852. 'AS',
  1853. 'AT',
  1854. 'AU',
  1855. 'AV',
  1856. 'AW',
  1857. 'AX',
  1858. 'AY',
  1859. 'AZ'
  1860. );
  1861. $obj->getActiveSheet ( 0 )->setTitle ( 'sheet名称' ); // 设置sheet名称
  1862. $_row = 0; // 设置纵向单元格标识
  1863. if ($title) {
  1864. $_cnt = count ( $title );
  1865. // $obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //合并单元格
  1866. // $obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '数据导出:'.date('Y-m-d H:i:s')); //设置合并后的单元格内容
  1867. $_row ++;
  1868. $i = 0;
  1869. foreach ( $title as $v ) { // 设置列标题
  1870. $obj->setActiveSheetIndex ( 0 )->setCellValue ( $cellName [$i] . $_row, $v );
  1871. $i ++;
  1872. }
  1873. $_row ++;
  1874. }
  1875. ;
  1876. // html_entity_decode("&iuml;&raquo;&iquest;".$value['order_id']);
  1877. // 填写数据
  1878. if ($data) {
  1879. $i = 0;
  1880. foreach ( $data as $_v ) {
  1881. $j = 0;
  1882. foreach ( $_v as $_cell ) {
  1883. $obj->getActiveSheet ( 0 )->setCellValueExplicit ( $cellName [$j] . ($i + $_row), $_cell, PHPExcel_Cell_DataType::TYPE_STRING );
  1884. $j ++;
  1885. }
  1886. $i ++;
  1887. }
  1888. }
  1889. // 文件名处理
  1890. if (! $fileName) {
  1891. $fileName = uniqid ( time (), true );
  1892. }
  1893. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  1894. if ($isDown) { // 网页下载
  1895. header ( 'pragma:public' );
  1896. header ( "Content-Disposition:attachment;filename=$fileName.xls" );
  1897. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  1898. $objWrite->save ( 'php://output' );
  1899. exit ();
  1900. }
  1901. $_fileName = iconv ( "utf-8", "gb2312", $fileName ); // 转码
  1902. $_savePath = $savePath . $_fileName . '.xlsx';
  1903. $objWrite->save ( $_savePath );
  1904. return $savePath . $fileName . '.xlsx';
  1905. }
  1906. function cellColor($cells,$color,$obj){
  1907. $obj->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
  1908. 'type' => PHPExcel_Style_Fill::FILL_SOLID,
  1909. 'startcolor' => array(
  1910. 'rgb' => $color
  1911. )
  1912. ));
  1913. }
  1914. /**
  1915. * 导出办事处全年汇中明细execl
  1916. */
  1917. function excelRCData($summaryData,$aiAllList,$cglist,$year){
  1918. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  1919. $obj = new PHPExcel ();
  1920. //总行数计算
  1921. $onRow=4;
  1922. $maxRow=(count($cglist)*14)+1+$onRow;
  1923. //表头计算
  1924. $cellCount=0;$sectionCount=array();$last=8;
  1925. foreach ($aiAllList as $key=>$value){
  1926. //栏目细则个数
  1927. $cellCount+=count($value)+1;
  1928. $sectionCount[$key]=array($last,count($value)+1+$last-1);
  1929. $last=count($value)+1+$last;
  1930. }
  1931. $cellCount=$cellCount+7;
  1932. //print_r($sectionCount);
  1933. //设置宽高
  1934. $colNum=1;$maxCol='ZZ';
  1935. for ($col='A';$colNum<=$cellCount;$col++){
  1936. $obj->getActiveSheet()->getColumnDimension($col)->setWidth(18);
  1937. cellColor($col.'1', 'ddebf7',$obj);cellColor($col.'2', 'ddebf7',$obj);
  1938. cellColor($col.'3', 'ddebf7',$obj);
  1939. foreach ($sectionCount as $key=>$value){
  1940. $falg=false;
  1941. foreach ($value as $k=>$v){
  1942. if($v==$colNum){
  1943. $sectionCount[$key][$k]=$col;
  1944. $falg=true;
  1945. break;
  1946. }
  1947. }
  1948. if($falg){
  1949. break;
  1950. }
  1951. }
  1952. if($colNum==$cellCount){
  1953. $maxCol=$col;
  1954. }
  1955. $colNum++;
  1956. }
  1957. //print_r($sectionCount);DIE;
  1958. $obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
  1959. //设置字体居中
  1960. $obj->getActiveSheet()->getStyle('A1:'.$maxCol.'3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  1961. //设置边框
  1962. $styleThinBlackBorderOutline = array('borders' => array(
  1963. 'allborders' => array( //设置全部边框
  1964. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  1965. ),),);
  1966. $obj->getActiveSheet()->getStyle( 'A1:'.$maxCol.$maxRow)->applyFromArray($styleThinBlackBorderOutline);
  1967. //设置合并单元格
  1968. $obj->getActiveSheet()->mergeCells('A1:A3');
  1969. $obj->getActiveSheet()->mergeCells('B1:G2');
  1970. $obj->getActiveSheet()->mergeCells('H1:'.$maxCol.'1');
  1971. //表头内容
  1972. $obj->getactivesheet()->setCellValue ( 'A1','费用项' );
  1973. $obj->getactivesheet()->setCellValue ( 'B1','收入' );
  1974. $obj->getactivesheet()->setCellValue ( 'B3','利润' );
  1975. $obj->getactivesheet()->setCellValue ( 'C3','利润占比' );
  1976. $obj->getactivesheet()->setCellValue ( 'D3','收入合计' );
  1977. $obj->getactivesheet()->setCellValue ( 'E3','软件收入' );
  1978. $obj->getactivesheet()->setCellValue ( 'F3','培训及其他收入' );
  1979. $obj->getactivesheet()->setCellValue ( 'G3','费用合计' );
  1980. //表头细则
  1981. $obj->getactivesheet()->setCellValue ( 'H1','支出' );
  1982. //print_r($sectionCount);die;
  1983. foreach ($sectionCount as $key=>$value){
  1984. $obj->getactivesheet()->setCellValue ( $value['0'].'2',$key);
  1985. $obj->getActiveSheet()->getStyle($value['0'].'2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  1986. $obj->getActiveSheet()->mergeCells($value['0'].'2:'.$value['1'].'2');
  1987. $col=$value['0'];
  1988. $obj-> getActiveSheet() -> getStyle($col.'3') -> getFont()->getColor()->setRGB('f70000');
  1989. $obj->getactivesheet()->setCellValue ( $col.'3','合计');
  1990. $col++;
  1991. foreach ($aiAllList[$key] as $k=>$v){
  1992. if($col>$value['1']){
  1993. break;
  1994. }
  1995. $obj->getactivesheet()->setCellValue ( $col.'3',$v['name']);
  1996. $col++;
  1997. }
  1998. }
  1999. //数据填充
  2000. //全年全选中办事处 金额合计
  2001. $obj->getactivesheet()->setCellValue ( 'A'.$onRow,$year.'年合计' );
  2002. $col='H';
  2003. //合计行数计算
  2004. $cgRow=array();$LS=0;
  2005. foreach ($cglist as $cgk=>$value){
  2006. $row=5+$LS;
  2007. array_push($cgRow, $row);
  2008. $LS+=14;
  2009. }
  2010. foreach ($aiAllList as $aiak=>$aiav){
  2011. $sectionStart=$sectionCount[$aiak]['0'];
  2012. $sectionStart++;
  2013. $obj->getActiveSheet() -> getStyle($col.$onRow) -> getFont()->getColor()->setRGB('f70000');
  2014. $obj->getactivesheet()->setCellValue( $col.$onRow, '=SUM('.$sectionStart.$onRow.':'.$sectionCount[$aiak]['1'].$onRow.')' );
  2015. $col++;
  2016. foreach ($aiav as $k=>$v){//项目细则
  2017. $formula=array();
  2018. foreach ($cgRow as $cgrk=>$cgrv){
  2019. array_push($formula, $col.$cgrv);
  2020. }
  2021. $formula=implode(',', $formula);
  2022. $obj->getactivesheet()->setCellValue( $col.$onRow, '=SUM('.$formula.')' );
  2023. $col++;
  2024. }
  2025. }
  2026. $onRow++;//行数增加
  2027. foreach ($cglist as $cgk=>$value){
  2028. //办事处年合计详情
  2029. $obj->getactivesheet()->setCellValue ( 'A'.$onRow,$value['title'].'年合计' );
  2030. $col='H';
  2031. foreach ($aiAllList as $aiak=>$aiav){
  2032. $sectionStart=$sectionCount[$aiak]['0'];
  2033. $sectionStart++;
  2034. $obj-> getActiveSheet() -> getStyle($col.$onRow) -> getFont()->getColor()->setRGB('f70000');
  2035. $obj->getactivesheet()->setCellValue( $col.$onRow, '=SUM('.$sectionStart.$onRow.':'.$sectionCount[$aiak]['1'].$onRow.')' );
  2036. $col++;
  2037. foreach ($aiav as $k=>$v){//项目细则
  2038. $sumRowStart=$onRow+2;
  2039. $sumRowEnd=$sumRowStart+11;
  2040. $obj->getactivesheet()->setCellValue( $col.$onRow, '=SUM('.$col.$sumRowStart.':'.$col.$sumRowEnd.')' );
  2041. $col++;
  2042. }
  2043. }
  2044. $onRow++;//行数增加
  2045. //办事处年占比
  2046. $obj->getactivesheet()->setCellValue ( 'A'.$onRow,$value['title'].'费用占比' );
  2047. $col='H';
  2048. foreach ($aiAllList as $aiak=>$aiav){
  2049. $sectionStart=$sectionCount[$aiak]['0'];
  2050. $sectionStart++;
  2051. $sumRowStart=$onRow-1;
  2052. $obj->getActiveSheet()->getStyle($col.$onRow)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);//设置百分比
  2053. $obj-> getActiveSheet() -> getStyle($col.$onRow) -> getFont()->getColor()->setRGB('f70000');
  2054. $obj->getactivesheet()->setCellValue( $col.$onRow, '='.$col.$sumRowStart.'/'.$col.'4' );
  2055. $col++;
  2056. foreach ($aiav as $k=>$v){//项目细则
  2057. $obj->getActiveSheet()->getStyle($col.$onRow)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
  2058. $obj->getactivesheet()->setCellValue( $col.$onRow, '='.$col.$sumRowStart.'/'.$col.'4' );
  2059. $col++;
  2060. }
  2061. }
  2062. $onRow++;//行数增加
  2063. //办事处每月合计详情
  2064. for($month=1;$month<=12;$month++){
  2065. $obj->getactivesheet()->setCellValue ( 'A'.$onRow,$value['title'].$month.'月合计' );
  2066. $col='H';
  2067. if(isset($summaryData[$value['cid']])){
  2068. foreach ($aiAllList as $aiak=>$aiav){//总项目
  2069. $sectionStart=$sectionCount[$aiak]['0'];
  2070. $sectionStart++;
  2071. $obj-> getActiveSheet() -> getStyle($col.$onRow) -> getFont()->getColor()->setRGB('f70000');
  2072. $obj->getactivesheet()->setCellValue( $col.$onRow, '=SUM('.$sectionStart.$onRow.':'.$sectionCount[$aiak]['1'].$onRow.')' );//公式
  2073. $col++;
  2074. foreach ($aiav as $k=>$v){//项目细则
  2075. foreach ($summaryData[$value['cid']][$month][$aiak] as $dsk=>$dsv){//数据实体
  2076. if($dsv['item']==$v['name']){
  2077. $obj->getactivesheet()->setCellValue ( $col.$onRow,$dsv['price']);
  2078. break;
  2079. }
  2080. }
  2081. $col++;
  2082. }
  2083. }
  2084. }
  2085. $onRow++;
  2086. }
  2087. }
  2088. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  2089. header ( 'pragma:public' );
  2090. header ( "Content-Disposition:attachment;filename=".$year."办事处费用明细.xlsx" );
  2091. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  2092. $objWrite->save ( 'php://output' );
  2093. exit ();
  2094. }
  2095. /*
  2096. * 处理Excel导出
  2097. * @param $datas array
  2098. * 设置表格数据
  2099. * @param $titlename string
  2100. * 设置head @param $title string 设置表头
  2101. */
  2102. function excelData($trainData, $receiptDetail, $summary, $aiList,$receiptLoanDetail,$invoiceList,$RItemList,$lecturerList,$invoiceTrainingDetail) {
  2103. Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
  2104. $obj = new PHPExcel ();
  2105. //设置合并单元格
  2106. $obj->getActiveSheet()->mergeCells('A1:D1');
  2107. //设置居中--//字体加粗
  2108. $obj->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2109. $i=2;
  2110. for(;$i<=20;$i++){
  2111. $obj->getActiveSheet()->getStyle('A'.$i.':J'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2112. //$obj->getActiveSheet()->getStyle('A'.$i)->getFont()->setName('宋体')->setBold(true);
  2113. //$obj->getActiveSheet()->getStyle('C'.$i)->getFont()->setName('宋体')->setBold(true);
  2114. }
  2115. $styleThinBlackBorderOutline = array(
  2116. 'borders' => array(
  2117. 'allborders' => array( //设置全部边框
  2118. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2119. ),
  2120. ),
  2121. );
  2122. $obj->getActiveSheet()->getStyle( 'A1:D9')->applyFromArray($styleThinBlackBorderOutline);
  2123. for ($i=1;$i<=9;$i++){
  2124. cellColor('A'.$i, 'ddebf7',$obj);
  2125. }
  2126. cellColor('C2', 'ddebf7',$obj);cellColor('C3', 'ddebf7',$obj);
  2127. cellColor('C4', 'ddebf7',$obj);cellColor('C8', 'ddebf7',$obj);
  2128. cellColor('C6', 'ddebf7',$obj);cellColor('C7', 'ddebf7',$obj);
  2129. //设置单元格宽
  2130. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  2131. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  2132. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  2133. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  2134. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  2135. $obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
  2136. $obj->getActiveSheet()->getStyle('A1')->getFont()->setName('宋体')->setBold(true);
  2137. $obj->getactivesheet()->setCellValue ( 'A1','培训班信息' );
  2138. $obj->getactivesheet()->setCellValue ( 'A2','培训班名称' );
  2139. $obj->getactivesheet()->setCellValue ( 'B2',$trainData['trainName'] );
  2140. $obj->getactivesheet()->setCellValue ( 'C2','所在办事处' );
  2141. $obj->getactivesheet()->setCellValue ( 'D2',$trainData['categoryName'] );
  2142. $obj->getactivesheet()->setCellValue ( 'A3','开班时间' );
  2143. $obj->getactivesheet()->setCellValue ( 'B3',$trainData['trainStartDate'] );
  2144. $obj->getactivesheet()->setCellValue ( 'C3','结束时间' );
  2145. $obj->getactivesheet()->setCellValue ( 'D3',$trainData['trainEndDate'] );
  2146. $obj->getactivesheet()->setCellValue ( 'A4','参加人数' );
  2147. $obj->getactivesheet()->setCellValue ( 'B4',$trainData['participants'] );
  2148. $obj->getactivesheet()->setCellValue ( 'C4','培训班地址' );
  2149. autoCellsWidth($obj,'D',$trainData ['trainAddress']);
  2150. $obj->getactivesheet()->setCellValue ( 'D4',$trainData['trainAddress'] );
  2151. $obj->getactivesheet()->setCellValue ( 'A5','备注' );
  2152. $obj->getActiveSheet()->mergeCells('B5:D5');
  2153. $obj->getactivesheet()->setCellValue ( 'B5',$trainData['trainRemarks'] );
  2154. $obj->getActiveSheet()->mergeCells('A6:D6');
  2155. $obj->getActiveSheet()->getStyle('A6:D6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2156. $obj->getactivesheet()->setCellValue ( 'A6','汇款信息' );
  2157. $obj->getactivesheet()->setCellValue ( 'A7','汇款人户名' );
  2158. $obj->getactivesheet()->setCellValue ( 'B7',$receiptDetail['remittanceName'] );
  2159. $obj->getactivesheet()->setCellValue ( 'C7','汇款银行' );
  2160. if(0==$receiptDetail['remittanceBankType']){
  2161. $obj->getactivesheet()->setCellValue ( 'D7','广发银行' );
  2162. }else{
  2163. $obj->getactivesheet()->setCellValue ( 'D7',其他 );
  2164. }
  2165. $obj->getactivesheet()->setCellValue ( 'A8','汇款开户银行名称' );
  2166. autoCellsWidth($obj,'B',$receiptDetail ['bankName']);
  2167. $obj->getactivesheet()->setCellValue ( 'B8',$receiptDetail['bankName'] );
  2168. $obj->getactivesheet()->setCellValue ( 'C8','汇款帐号' );
  2169. $obj->getActiveSheet()->setCellValueExplicit('D8',$receiptDetail['bankNumber'],PHPExcel_Cell_DataType::TYPE_STRING);
  2170. //$obj->getactivesheet()->setCellValue ( 'D7',$receiptDetail['bankNumber'].'' );
  2171. if(0==$receiptDetail['remittanceBankType']){
  2172. $obj->getactivesheet()->setCellValue ( 'A9','联行号' );
  2173. $obj->getActiveSheet()->mergeCells('B9:D9');
  2174. $obj->getactivesheet()->setCellValue ( 'B9',$receiptDetail['coupletNumber'] );
  2175. }
  2176. $obj->setActiveSheetIndex(0);
  2177. $obj->getActiveSheet ()->setTitle ( '信息' );
  2178. //------------------------------------------------------------------------------------------
  2179. $obj->createSheet();
  2180. $obj->setActiveSheetIndex(1);
  2181. makeSummaryData($obj,$summary,$aiList);
  2182. //------------------------------------------------------------------------------------------
  2183. //绘制借款
  2184. $obj->createSheet();
  2185. $obj->setActiveSheetIndex(2);
  2186. makeReceiptLoanData($obj,$receiptLoanDetail);
  2187. //------------------------------------------------------------------------------------------
  2188. //绘制收入
  2189. $obj->createSheet();
  2190. $obj->setActiveSheetIndex(3);
  2191. makeInvoiceData($obj,$invoiceList,$invoiceTrainingDetail);
  2192. //------------------------------------------------------------------------------------------
  2193. //绘制支出
  2194. $obj->createSheet();
  2195. $obj->setActiveSheetIndex(4);
  2196. makeItemData($obj,$RItemList);
  2197. //------------------------------------------------------------------------------------------
  2198. //绘制讲师
  2199. $obj->createSheet();
  2200. $obj->setActiveSheetIndex(5);
  2201. makeLecturerData($obj,$lecturerList);
  2202. $objWrite = PHPExcel_IOFactory::createWriter ( $obj, 'Excel2007' );
  2203. header ( 'pragma:public' );
  2204. header ( "Content-Disposition:attachment;filename=".$trainData['trainName'].".xlsx" );
  2205. header ( 'Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  2206. $objWrite->save ( 'php://output' );
  2207. exit ();
  2208. }
  2209. function makeLecturerData($obj,$lecturerList){
  2210. //整体字体位置
  2211. $invoiceCount=count($lecturerList)+2;
  2212. for($i=1;$i<=$invoiceCount;$i++){
  2213. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  2214. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  2215. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
  2216. }
  2217. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  2218. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  2219. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  2220. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  2221. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  2222. //边框
  2223. $styleThinBlackBorderOutline = array(
  2224. 'borders' => array(
  2225. 'allborders' => array( //设置全部边框
  2226. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2227. ),
  2228. ),);
  2229. $obj->getActiveSheet()->getStyle( 'A1:E'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
  2230. cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
  2231. cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);cellColor('E1', 'ddebf7',$obj);
  2232. $obj->getactivesheet()->setCellValue ( 'A1','类型' );
  2233. $obj->getactivesheet()->setCellValue ( 'B1','讲师姓名' );
  2234. $obj->getactivesheet()->setCellValue ( 'C1','授课日数' );
  2235. $obj->getactivesheet()->setCellValue ( 'D1','日授课费' );
  2236. $obj->getactivesheet()->setCellValue ( 'E1','合计应发授课费' );
  2237. $i=2;$sumPrice=0;
  2238. foreach ($lecturerList as $key=>$value){
  2239. $lecturerName='';
  2240. if($value['ltype']=='OUTSIDE'){
  2241. $lecturerName.='外聘';
  2242. if($value['taxation']==0){
  2243. $lecturerName.='(不计税)';
  2244. }else{
  2245. $lecturerName.='(计税)';
  2246. }
  2247. }else{
  2248. $lecturerName.='员工';
  2249. }
  2250. $obj->getactivesheet()->setCellValue ( 'A'.$i,$lecturerName );
  2251. $obj->getactivesheet()->setCellValue ( 'B'.$i,$value['lecturerName'] );
  2252. $obj->getactivesheet()->setCellValue ( 'C'.$i,$value['schoolDay'] );
  2253. $obj->getactivesheet()->setCellValue ( 'D'.$i,$value['price'] );
  2254. $obj->getactivesheet()->setCellValue ( 'E'.$i,$value['fees'] );
  2255. $sumPrice+=$value['sum'];
  2256. $i++;
  2257. }
  2258. $obj->getactivesheet()->setCellValue ( 'C'.$i,'合计' );
  2259. $obj->getactivesheet()->setCellValue ( 'D'.$i,$sumPrice );
  2260. $obj->getActiveSheet ()->setTitle ( '讲师' );
  2261. }
  2262. function makeItemData($obj,$itemList){
  2263. //整体字体位置
  2264. $invoiceCount=count($itemList)+2;
  2265. for($i=1;$i<=$invoiceCount;$i++){
  2266. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  2267. $obj->getActiveSheet()->getStyle('A'.$i.':E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  2268. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
  2269. }
  2270. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  2271. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  2272. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  2273. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  2274. //边框
  2275. $styleThinBlackBorderOutline = array(
  2276. 'borders' => array(
  2277. 'allborders' => array( //设置全部边框
  2278. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2279. ),
  2280. ),);
  2281. $obj->getActiveSheet()->getStyle( 'A1:E'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
  2282. cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
  2283. cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);
  2284. cellColor('E1', 'ddebf7',$obj);
  2285. $obj->getactivesheet()->setCellValue ( 'A1','日期' );
  2286. $obj->getactivesheet()->setCellValue ( 'B1','类别' );
  2287. $obj->getactivesheet()->setCellValue ( 'C1','金额' );
  2288. $obj->getactivesheet()->setCellValue ( 'D1','经手人' );
  2289. $obj->getactivesheet()->setCellValue ( 'E1','支出描述' );
  2290. $i=2;$maxArray=array();$sumPrice=0;
  2291. foreach ($itemList as $key=>$value){
  2292. $obj->getactivesheet()->setCellValue ( 'A'.$i,$value['date'] );
  2293. $obj->getactivesheet()->setCellValue ( 'B'.$i,$value['item'] );
  2294. $obj->getactivesheet()->setCellValue ( 'C'.$i,$value['price'] );
  2295. $obj->getactivesheet()->setCellValue ( 'D'.$i,$value['inputer'] );
  2296. $obj->getactivesheet()->setCellValue ( 'E'.$i,$value['describe'] );
  2297. array_push($maxArray, strlen($value['describe']));
  2298. $sumPrice+=$value['price'];
  2299. $i++;
  2300. }
  2301. $obj->getactivesheet()->setCellValue ( 'B'.$i,'合计' );
  2302. $obj->getactivesheet()->setCellValue ( 'C'.$i,$sumPrice );
  2303. $ma=0;
  2304. if (!empty($maxArray)){
  2305. $ma=max($maxArray);
  2306. }
  2307. $max=$ma-10;$fontlenght=25;
  2308. if($max>25){
  2309. $fontlenght=$max;
  2310. }
  2311. $obj->getActiveSheet()->getColumnDimension('E')->setWidth($fontlenght);
  2312. $obj->getActiveSheet ()->setTitle ( '支出' );
  2313. }
  2314. function makeInvoiceData($obj,$invoiceList,$invoiceTrainingDetail){
  2315. //整体字体位置
  2316. $invoiceCount=count($invoiceList)+4;
  2317. for($i=1;$i<=$invoiceCount;$i++){
  2318. $obj->getActiveSheet()->getStyle('A'.$i.':I'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  2319. $obj->getActiveSheet()->getStyle('A'.$i.':I'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  2320. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18);
  2321. }
  2322. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  2323. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  2324. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  2325. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  2326. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  2327. $obj->getActiveSheet()->getColumnDimension('F')->setWidth(25);
  2328. $obj->getActiveSheet()->getColumnDimension('G')->setWidth(25);
  2329. $obj->getActiveSheet()->getColumnDimension('H')->setWidth(25);
  2330. $obj->getActiveSheet()->getColumnDimension('I')->setWidth(25);
  2331. //边框
  2332. $styleThinBlackBorderOutline = array(
  2333. 'borders' => array(
  2334. 'allborders' => array( //设置全部边框
  2335. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2336. ),
  2337. ),);
  2338. $obj->getActiveSheet()->getStyle( 'A1:I2')->applyFromArray($styleThinBlackBorderOutline);
  2339. cellColor('A1', 'ddebf7',$obj);cellColor('B1', 'ddebf7',$obj);
  2340. cellColor('C1', 'ddebf7',$obj);cellColor('D1', 'ddebf7',$obj);
  2341. cellColor('E1', 'ddebf7',$obj);cellColor('F1', 'ddebf7',$obj);
  2342. cellColor('H1', 'ddebf7',$obj);cellColor('G1', 'ddebf7',$obj);cellColor('I1', 'ddebf7',$obj);
  2343. $obj->getactivesheet()->setCellValue ( 'A1','培训班名称' );
  2344. $obj->getactivesheet()->setCellValue ( 'B1','办事处' );
  2345. $obj->getactivesheet()->setCellValue ( 'C1','创建' );
  2346. $obj->getactivesheet()->setCellValue ( 'D1','开班时间' );
  2347. $obj->getactivesheet()->setCellValue ( 'E1','包含发票' );
  2348. $obj->getactivesheet()->setCellValue ( 'F1','开票金额合计' );
  2349. $obj->getactivesheet()->setCellValue ( 'G1','入账金额合计' );
  2350. $obj->getactivesheet()->setCellValue ( 'H1','公司已收款' );
  2351. $obj->getactivesheet()->setCellValue ( 'I1','办事处已收款' );
  2352. if(!empty($invoiceTrainingDetail)){
  2353. $obj->getactivesheet()->setCellValue ( 'A2',$invoiceTrainingDetail['trainName'] );
  2354. $obj->getactivesheet()->setCellValue ( 'B2',$invoiceTrainingDetail['category'][0]['title'] );
  2355. $obj->getactivesheet()->setCellValue ( 'C2',$invoiceTrainingDetail['staff']['username'] );
  2356. $obj->getactivesheet()->setCellValue ( 'D2',$invoiceTrainingDetail['trainDate'] );
  2357. $obj->getactivesheet()->setCellValue ( 'E2',$invoiceTrainingDetail['invoiceTotal'] );
  2358. $obj->getactivesheet()->setCellValue ( 'F2',$invoiceTrainingDetail['invoiceTotalAmount'] );
  2359. $obj->getactivesheet()->setCellValue ( 'G2',$invoiceTrainingDetail['invoiceArriveAmount'] );
  2360. $obj->getactivesheet()->setCellValue ( 'H2',$invoiceTrainingDetail['invoiceCompanyAmount'] );
  2361. $obj->getactivesheet()->setCellValue ( 'I2',$invoiceTrainingDetail['RIAmount'] );
  2362. }
  2363. //边框
  2364. $styleThinBlackBorderOutline = array(
  2365. 'borders' => array(
  2366. 'allborders' => array( //设置全部边框
  2367. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2368. ),
  2369. ),);
  2370. $obj->getActiveSheet()->getStyle( 'A4:H'.$invoiceCount)->applyFromArray($styleThinBlackBorderOutline);
  2371. cellColor('A4', 'ddebf7',$obj);cellColor('B4', 'ddebf7',$obj);
  2372. cellColor('C4', 'ddebf7',$obj);cellColor('D4', 'ddebf7',$obj);
  2373. cellColor('E4', 'ddebf7',$obj);cellColor('F4', 'ddebf7',$obj);
  2374. cellColor('H4', 'ddebf7',$obj);cellColor('G4', 'ddebf7',$obj);
  2375. $obj->getactivesheet()->setCellValue ( 'A4','开票流水' );
  2376. $obj->getactivesheet()->setCellValue ( 'B4','开票单位(抬头)' );
  2377. $obj->getactivesheet()->setCellValue ( 'C4','发票号' );
  2378. $obj->getactivesheet()->setCellValue ( 'D4','总额' );
  2379. $obj->getactivesheet()->setCellValue ( 'E4','状态' );
  2380. $obj->getactivesheet()->setCellValue ( 'F4','办事处收款' );
  2381. $obj->getactivesheet()->setCellValue ( 'G4','收款流水号' );
  2382. $obj->getactivesheet()->setCellValue ( 'H4','收款银行到账' );
  2383. $i=5;$maxArray=array();
  2384. foreach ($invoiceList as $key=>$value){
  2385. $obj->getactivesheet()->setCellValue ( 'A'.$i,$value['invoiceSerial'] );
  2386. $title='';
  2387. if(!empty($value['invoiceType'])){
  2388. $title=$value['invoiceCompany'];
  2389. }else{
  2390. $title=$value['invoiceTitle'];
  2391. }
  2392. $obj->getactivesheet()->setCellValue ( 'B'.$i,$title );
  2393. $obj->getactivesheet()->setCellValue ( 'C'.$i,$value['invoiceNo'] );
  2394. if(!empty($value['invoiceType'])){
  2395. $obj->getactivesheet()->setCellValue ( 'D'.$i,'专'.$value['invoicePrice'] );
  2396. }else{
  2397. $obj->getactivesheet()->setCellValue ( 'D'.$i,$value['invoicePrice'] );
  2398. }
  2399. if($value['untreadStatus']==3){
  2400. $obj->getactivesheet()->setCellValue ( 'E'.$i,'已入账' );
  2401. }else{
  2402. $obj->getactivesheet()->setCellValue ( 'E'.$i,'已出票' );
  2403. }
  2404. if($value['untreadStatus']==3){
  2405. if($value['RIstatus']==1){
  2406. $obj->getactivesheet()->setCellValue ( 'F'.$i,'已收款' );
  2407. }
  2408. }else{
  2409. if($value['RIstatus']==1){
  2410. $obj->getactivesheet()->setCellValue ( 'F'.$i,'已收款' );
  2411. }
  2412. }
  2413. $receivablesSerial='';
  2414. $receivablesDate='';$hang=0;
  2415. if($value['untreadStatus']==3){
  2416. foreach ($value['irDetail'] as $k=>$v){
  2417. $receivablesSerial.=$v['receivablesSerial']."\r\n";
  2418. $receivablesDate.=$v['receivablesDate']."\r\n";
  2419. $hang+=8;
  2420. }
  2421. if($hang>8){
  2422. $obj->getActiveSheet()->getRowDimension($i)->setRowHeight(18+$hang);
  2423. }
  2424. }
  2425. $obj->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setWrapText(true);
  2426. $obj->getActiveSheet()->getStyle('G'.$i)->getAlignment()->setWrapText(true);
  2427. $obj->getactivesheet()->setCellValue ( 'G'.$i,$receivablesSerial );
  2428. $obj->getactivesheet()->setCellValue ( 'H'.$i,$receivablesDate );
  2429. //按字体多少自动拉长单元格
  2430. array_push($maxArray, strlen($title));
  2431. $i++;
  2432. }
  2433. $ma=0;
  2434. if (!empty($maxArray)){
  2435. $ma=max($maxArray);
  2436. }
  2437. $max=$ma-10;$fontlenght=25;
  2438. if($max>25){
  2439. $fontlenght=$max;
  2440. }
  2441. $obj->getActiveSheet()->getColumnDimension('B')->setWidth($fontlenght);
  2442. $obj->getActiveSheet ()->setTitle ( '收入' );
  2443. }
  2444. function makeReceiptLoanData($obj,$receiptLoanList){
  2445. if (empty($receiptLoanList)){
  2446. $obj->getActiveSheet ()->setTitle ( '借款' );
  2447. return ;
  2448. }
  2449. $base=$lnBase=0;$lnKey=1;$lnBase=14;
  2450. //定义行倍数
  2451. $lnKey2=2;$lnKey3=3;$lnKey4=4;$lnKey5=5;
  2452. $lnKey6=6;$lnKey7=7;$lnKey8=8;$lnKey9=9;
  2453. $lnKey10=10;$lnKey11=11;$lnKey12=12;$lnKey13=13;
  2454. $lnKey14=14;
  2455. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(35);
  2456. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(35);
  2457. foreach ($receiptLoanList as $key=>$receiptLoanDetail){
  2458. $lineNumber=1;
  2459. $lineNumber=$lineNumber+$base;
  2460. $maxBase=$base+16;
  2461. //echo $maxBase.'<br/>';
  2462. for (;$lineNumber<=$maxBase;$lineNumber++){
  2463. $lineNumberDynamic = 'ln'.$lineNumber;
  2464. $$lineNumberDynamic=$lineNumber;
  2465. $obj->getActiveSheet()->getStyle('A'.$lineNumber.':B'.$lineNumber)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  2466. $obj->getActiveSheet()->getStyle('A'.$lineNumber.':B'.$lineNumber)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  2467. $obj->getActiveSheet()->getRowDimension($lineNumber)->setRowHeight(18);
  2468. }
  2469. //正文
  2470. $receiptLoanDetail ['loanItem'] = json_decode ( $receiptLoanDetail ['loanItem'], true );
  2471. $receiptLoanDetail ['sumCN'] = num_to_rmb ( $receiptLoanDetail ['sum'] );
  2472. $receiptLoanDetail ['loanSumCN'] = num_to_rmb ( $receiptLoanDetail ['loanSum'] );
  2473. $receiptLoanDetail ['amountCN'] = num_to_rmb ( $receiptLoanDetail ['amount'] );
  2474. //echo $receiptLoanDetail ['sumCN'].'<br/>';
  2475. //边框
  2476. $styleThinBlackBorderOutline = array(
  2477. 'borders' => array(
  2478. 'allborders' => array( //设置全部边框
  2479. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2480. ),
  2481. ),);
  2482. $obj->getActiveSheet()->getStyle( 'A'.${'ln'.$lnKey}.':B'.${'ln'.$lnBase})->applyFromArray($styleThinBlackBorderOutline);
  2483. //绘制颜色
  2484. cellColor('A'.${'ln'.$lnKey}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey3}, 'ddebf7',$obj);
  2485. cellColor('A'.${'ln'.$lnKey2}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey6}, 'ddebf7',$obj);
  2486. cellColor('A'.${'ln'.$lnKey7}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey8}, 'ddebf7',$obj);
  2487. cellColor('A'.${'ln'.$lnKey9}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey10}, 'ddebf7',$obj);
  2488. cellColor('A'.${'ln'.$lnKey5}, 'ddebf7',$obj);cellColor('A'.${'ln'.$lnKey11}, 'ddebf7',$obj);
  2489. //正文内容
  2490. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey}.':B'.${'ln'.$lnKey});
  2491. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey},'借款费用' );
  2492. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2493. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey3}.':B'.${'ln'.$lnKey3});
  2494. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey3},'产生费用所在办事处' );
  2495. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey3})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2496. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey5}.':B'.${'ln'.$lnKey5});
  2497. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey5},'汇款信息' );
  2498. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey5})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2499. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey11}.':B'.${'ln'.$lnKey11});
  2500. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey11},'费用说明' );
  2501. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey11})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2502. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey2},'借款费用' );
  2503. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey2},$receiptLoanDetail ['loanItem'] ['借款费用'] [0] ['price'] );
  2504. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey4}.':B'.${'ln'.$lnKey4});
  2505. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey4},$receiptLoanDetail ['category'] [0] ['title'] );
  2506. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey6},'汇款人户名' );
  2507. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey7},'汇款银行' );
  2508. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey8},'汇款开户银行名称' );
  2509. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey9},'汇款帐号' );
  2510. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey10},'联行号' );
  2511. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey6},$receiptLoanDetail ['remittanceName'] );
  2512. if ($receiptLoanDetail ['remittanceBankType'] == 0){
  2513. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey7},'广发银行' );
  2514. }elseif ($receiptLoanDetail ['remittanceBankType'] == 1){
  2515. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey7},'其他' );
  2516. }
  2517. autoCellsWidth($obj,'B',$receiptLoanDetail ['bankName']);
  2518. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey8},$receiptLoanDetail ['bankName'] );
  2519. $obj->getActiveSheet()->setCellValueExplicit('B'.${'ln'.$lnKey9},$receiptLoanDetail ['bankNumber'],PHPExcel_Cell_DataType::TYPE_STRING);
  2520. //$obj->getactivesheet()->setCellValue ( 'B9',$receiptLoanDetail ['bankNumber'] );
  2521. if ($receiptLoanDetail ['remittanceBankType'] == 1){
  2522. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey10},$receiptLoanDetail ['coupletNumber'] );
  2523. }else{
  2524. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey10},'' );
  2525. }
  2526. $obj->getActiveSheet()->mergeCells('A'.${'ln'.$lnKey12}.':B'.${'ln'.$lnKey12});
  2527. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey12},$receiptLoanDetail ['explanation'] );
  2528. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey13}.':B'.${'ln'.$lnKey13})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2529. $obj->getActiveSheet()->getStyle('A'.${'ln'.$lnKey14}.':B'.${'ln'.$lnKey14})->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2530. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey13},'(' . $receiptLoanDetail ['receiptOrder'] . ')本次费用合计' );
  2531. $obj->getActiveSheet()->getStyle('B'.${'ln'.$lnKey13})->getAlignment()->setWrapText(true);
  2532. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey13},"¥" . $receiptLoanDetail ['sum'] . "\r\n" . $receiptLoanDetail ['sumCN'] );
  2533. $obj->getActiveSheet()->getRowDimension(${'ln'.$lnKey13})->setRowHeight(36);
  2534. $obj->getactivesheet()->setCellValue ( 'A'.${'ln'.$lnKey14},'汇款金额');
  2535. $obj->getActiveSheet()->getStyle('B'.${'ln'.$lnKey14})->getAlignment()->setWrapText(true);
  2536. $obj->getactivesheet()->setCellValue ( 'B'.${'ln'.$lnKey14},"¥" . $receiptLoanDetail ['amount'] . "\r\n" . $receiptLoanDetail ['amountCN'] );
  2537. $obj->getActiveSheet()->getRowDimension(${'ln'.$lnKey14})->setRowHeight(36);
  2538. //绘制计算
  2539. $lnKey=$lnBase+2;$lnKey2=$lnBase+3;$lnKey3=$lnBase+4;$lnKey4=$lnBase+5;
  2540. $lnKey5=$lnBase+6;$lnKey6=$lnBase+7;$lnKey8=$lnBase+9;$lnKey9=$lnBase+10;
  2541. $lnKey10=$lnBase+11;$lnKey11=$lnBase+12;$lnKey12=$lnBase+13;$lnKey14=$lnBase+15;
  2542. $lnKey7=$lnBase+8;$lnKey13=$lnBase+14;
  2543. $lnBase=$lnKey+14;
  2544. $base+=15;
  2545. }
  2546. //die;
  2547. $obj->getActiveSheet ()->setTitle ( '借款' );
  2548. }
  2549. //绘制汇总
  2550. function makeSummaryData($obj,$summary,$aiList){
  2551. //设置居中
  2552. //$obj->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2553. for($i=1;$i<=35;$i++){
  2554. $obj->getActiveSheet()->getStyle('A'.$i.':J'.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2555. if ($i>=19){
  2556. $obj->getActiveSheet()->getStyle('A'.$i.':B'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
  2557. }
  2558. }
  2559. //设置单元格宽
  2560. $obj->getActiveSheet()->getColumnDimension('A')->setWidth(25);
  2561. $obj->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  2562. $obj->getActiveSheet()->getColumnDimension('C')->setWidth(25);
  2563. $obj->getActiveSheet()->getColumnDimension('D')->setWidth(25);
  2564. $obj->getActiveSheet()->getColumnDimension('E')->setWidth(25);
  2565. $obj->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
  2566. $obj->getActiveSheet()->mergeCells('A1:A2');
  2567. $obj->getActiveSheet()->mergeCells('B1:C1');
  2568. $obj->getActiveSheet()->mergeCells('D1:E1');
  2569. $obj->getActiveSheet()->mergeCells('C2:C3');
  2570. $obj->getActiveSheet()->mergeCells('E2:E3');
  2571. $obj->getActiveSheet()->mergeCells('A6:E6');
  2572. $obj->getActiveSheet()->mergeCells('A10:E10');
  2573. $obj->getActiveSheet()->mergeCells('A15:E15');
  2574. $obj->getActiveSheet()->mergeCells('A16:E16');
  2575. //支出详情
  2576. $obj->getActiveSheet()->mergeCells('A18:C18');
  2577. $obj->getActiveSheet()->mergeCells('A19:A35');
  2578. cellColor('A1', 'ddebf7',$obj);cellColor('A2', 'ddebf7',$obj);
  2579. cellColor('B1', 'ddebf7',$obj);cellColor('B2', 'ddebf7',$obj);
  2580. cellColor('C2', 'ddebf7',$obj);cellColor('E2', 'ddebf7',$obj);
  2581. cellColor('D1', 'ddebf7',$obj);cellColor('D2', 'ddebf7',$obj);
  2582. cellColor('E3', 'ddebf7',$obj);cellColor('C3', 'ddebf7',$obj);
  2583. for ($i=3;$i<=15;$i++){
  2584. cellColor('A'.$i, 'ddebf7',$obj);
  2585. }
  2586. //支出详情
  2587. cellColor('A18', 'ddebf7',$obj);cellColor('D18', 'ddebf7',$obj);
  2588. cellColor('E18', 'ddebf7',$obj);cellColor('A19', 'ddebf7',$obj);
  2589. for ($i=19;$i<=35;$i++){
  2590. cellColor('B'.$i, 'ddebf7',$obj);
  2591. }
  2592. //边框
  2593. $styleThinBlackBorderOutline = array(
  2594. 'borders' => array(
  2595. 'allborders' => array( //设置全部边框
  2596. 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
  2597. ),
  2598. ),
  2599. );
  2600. $obj->getActiveSheet()->getStyle( 'A1:E16')->applyFromArray($styleThinBlackBorderOutline);
  2601. //支出详情
  2602. $obj->getActiveSheet()->getStyle( 'A18:E35')->applyFromArray($styleThinBlackBorderOutline);
  2603. $obj->getactivesheet()->setCellValue ( 'A1','汇总项目' );
  2604. $obj->getactivesheet()->setCellValue ( 'B1','收入按开票金额计算' );
  2605. $obj->getactivesheet()->setCellValue ( 'D1','收入按入账金额计算' );
  2606. $obj->getactivesheet()->setCellValue ( 'B2','金额' );
  2607. $obj->getactivesheet()->setCellValue ( 'C2','占比' );
  2608. $obj->getactivesheet()->setCellValue ( 'D2','金额' );
  2609. $obj->getactivesheet()->setCellValue ( 'E2','占比' );
  2610. $obj->getactivesheet()->setCellValue ( 'A3','收入' );
  2611. $obj->getactivesheet()->setCellValue ( 'A4','支出' );
  2612. $obj->getactivesheet()->setCellValue ( 'A5','利润' );
  2613. $obj->getactivesheet()->setCellValue ( 'A6','收入-支出=利润' );
  2614. $obj->getactivesheet()->setCellValue ( 'A7','公司利润' );
  2615. $obj->getactivesheet()->setCellValue ( 'A8','办事处利润' );
  2616. $obj->getactivesheet()->setCellValue ( 'A9','公司收款' );
  2617. $obj->getactivesheet()->setCellValue ( 'A10','收入×40%=办事处利润 收入×60%=公司利润' );
  2618. $obj->getactivesheet()->setCellValue ( 'A11','备用金(借款)' );
  2619. $obj->getactivesheet()->setCellValue ( 'A12','办事处收款' );
  2620. $obj->getactivesheet()->setCellValue ( 'A13','办事处实际支出' );
  2621. $obj->getactivesheet()->setCellValue ( 'A14','付总部款' );
  2622. $obj->getactivesheet()->setCellValue ( 'A15','备用金+办事处收款-办事处实际支出=付总部款' );
  2623. //支出详情
  2624. $obj->getactivesheet()->setCellValue ( 'A18','项目' );
  2625. $obj->getactivesheet()->setCellValue ( 'D18','金额' );
  2626. $obj->getactivesheet()->setCellValue ( 'E18','占入账金额比例' );
  2627. $obj->getactivesheet()->setCellValue ( 'A19','支出明细' );
  2628. $startKey=19;
  2629. foreach ($aiList as $key=>$value){
  2630. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2631. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2632. if($value['name']=='讲课费'){
  2633. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2634. $obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+2));
  2635. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2636. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2637. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'外聘' );
  2638. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['outsideTaxPrice'] );
  2639. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['outsideTaxProportion'].'%' );
  2640. $startKey+=1;
  2641. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2642. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2643. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'外聘(不计税)' );
  2644. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['outsideNoTaxPrice'] );
  2645. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['outsideNoTaxProportion'].'%' );
  2646. $startKey+=1;
  2647. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2648. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2649. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'员工' );
  2650. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['insidePrice'] );
  2651. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['insideProportion'].'%' );
  2652. }elseif($value['name']=='办公费'){
  2653. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2654. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2655. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2656. $obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+1));
  2657. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'办事处支出' );
  2658. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['categoryPrice'] );
  2659. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['categoryProportion'].'%' );
  2660. $startKey=$startKey+1;
  2661. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2662. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2663. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['companyPrice'] );
  2664. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['companyProportion'].'%' );
  2665. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'公司支出' );
  2666. }elseif($value['name']=='邮寄费'){
  2667. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  2668. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2669. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2670. $obj->getActiveSheet()->mergeCells('B'.$startKey.':B'.($startKey+1));
  2671. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'办事处支出' );
  2672. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['categoryPrice'] );
  2673. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['categoryProportion'].'%' );
  2674. $startKey=$startKey+1;
  2675. $obj->getActiveSheet()->getStyle('D'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2676. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2677. $obj->getactivesheet()->setCellValue ( 'D'.$startKey,$value['companyPrice'] );
  2678. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['companyProportion'].'%' );
  2679. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,'公司支出' );
  2680. }else{
  2681. $obj->getActiveSheet()->mergeCells('C'.$startKey.':D'.$startKey);
  2682. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,$value['name'] );
  2683. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,$value['priceFormat'] );
  2684. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$value['proportion'].'%' );
  2685. }
  2686. $startKey++;
  2687. }
  2688. //小计
  2689. $obj->getActiveSheet()->getStyle('C'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2690. $obj->getActiveSheet()->getStyle('E'.$startKey)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
  2691. $obj->getActiveSheet()->mergeCells('C'.$startKey.':D'.$startKey);
  2692. $obj->getactivesheet()->setCellValue ( 'B'.$startKey,'小计' );
  2693. $obj->getactivesheet()->setCellValue ( 'C'.$startKey,$summary[11]['total'] );
  2694. $obj->getactivesheet()->setCellValue ( 'E'.$startKey,$summary[11]['totalProportion'].'%' );
  2695. $startKey=3;
  2696. //内容
  2697. foreach ($summary as $key=>$value){
  2698. $k=$key+$startKey;
  2699. if($k==3){
  2700. $obj->getactivesheet()->setCellValue ( 'B'.$k,$value['invoiceTotalAmount'] );
  2701. $obj->getactivesheet()->setCellValue ( 'D'.$k,$value['invoiceArriveAmount'] );
  2702. }elseif($k==15){
  2703. $k+=1;
  2704. $obj->getactivesheet()->setCellValue ( 'A'.$k,'学员:'.$value['participants'].'人 讲师:'.$value['lectureCount'].' 人' );
  2705. }elseif($k==16){
  2706. }elseif($k==6||$k==10){
  2707. $k+=1;
  2708. $startKey+=1;
  2709. $obj->getactivesheet()->setCellValue ( 'B'.$k,$value[1] );
  2710. $obj->getactivesheet()->setCellValue ( 'C'.$k,$value[2] );
  2711. $obj->getactivesheet()->setCellValue ( 'D'.$k,$value[3] );
  2712. $obj->getactivesheet()->setCellValue ( 'E'.$k,$value[4] );
  2713. }else{
  2714. $obj->getactivesheet()->setCellValue ( 'B'.$k,$value[1] );
  2715. $obj->getactivesheet()->setCellValue ( 'C'.$k,$value[2] );
  2716. $obj->getactivesheet()->setCellValue ( 'D'.$k,$value[3] );
  2717. $obj->getactivesheet()->setCellValue ( 'E'.$k,$value[4] );
  2718. }
  2719. }
  2720. $obj->getActiveSheet ()->setTitle ( '汇总表' );
  2721. }
  2722. function autoCellsWidth($obj,$cellsNub,$str){
  2723. $max=strlen($str)-10;$fontlenght=35;
  2724. if($max>35){
  2725. $fontlenght=$max;
  2726. }
  2727. $obj->getActiveSheet()->getColumnDimension($cellsNub)->setWidth($fontlenght);
  2728. }
  2729. ?>