receipt.func.php 81 KB

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