receipt.func.php 84 KB

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