reportdata.html.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /**
  3. * The reportData view file of report module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2014 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
  6. * @license LGPL (http://www.gnu.org/licenses/lgpl.html)
  7. * @author Yidong Wang <yidong@cnezsoft.com>
  8. * @package report
  9. * @version $Id$
  10. * @link http://www.zentao.net
  11. */
  12. ?>
  13. <?php if($step == 1):?>
  14. <table class='reportData table table-condensed table-striped table-bordered table-fixed datatable' style='width: auto; min-width: 100%'>
  15. <thead>
  16. <tr>
  17. <?php $i = 0;?>
  18. <?php foreach($fields as $field):?>
  19. <?php $attr = $i == 0 ? "data-flex='false' data-width='auto'" : "data-flex='true' data-width='90' class='text-center'";?>
  20. <th <?php echo $attr?>><?php echo $field;?></th>
  21. <?php $i++;?>
  22. <?php endforeach;?>
  23. </tr>
  24. </thead>
  25. <tbody>
  26. <?php foreach($dataList as $data):?>
  27. <tr>
  28. <?php foreach($data as $field => $value):?>
  29. <td title='<?php echo strip_tags($value);?>'><?php echo $value?></td>
  30. <?php endforeach;?>
  31. </tr>
  32. <?php endforeach;?>
  33. <tbody>
  34. </table>
  35. <?php else:?>
  36. <?php
  37. $sqlLangs = json_decode($this->session->sqlLangs, true);
  38. $clientLang = $this->app->getClientLang();
  39. $width = common::checkNotCN() ? 140 : 80;
  40. ?>
  41. <table class='reportData table table-condensed table-striped table-bordered table-fixed datatable' style='width: auto; min-width: 100%' data-fixed-left-width="<?php echo strpos($report->module, 'product') !== false ? 200 : 400;?>">
  42. <thead>
  43. <tr>
  44. <?php $textAlign = (!empty($report->module) and strpos($report->module, 'product') !== false) ? 'text-left' : 'text-center';?>
  45. <?php $params = !empty($report->params) ? json_decode($report->params) : array();?>
  46. <th data-flex='false' data-width='auto' class="<?php echo $textAlign;?>"><?php echo $fields[$condition['group1']]?></th>
  47. <?php if($condition['group2']):?>
  48. <th data-flex='false' data-width='auto' class="<?php echo $textAlign;?>"><?php echo $fields[$condition['group2']]?></th>
  49. <?php endif;?>
  50. <?php
  51. /* Set dataCols. */
  52. $dataCols = array();
  53. foreach($headers as $i => $reportFields)
  54. {
  55. $showed[$i] = false;
  56. foreach($reportFields as $reportField)
  57. {
  58. if(isset($headerNames[$i]))
  59. {
  60. foreach ($headerNames[$i] as $key => $headerName)
  61. {
  62. if(!in_array($key, $reportFields)) unset($headerNames[$i][$key]); // If the header name does not have a header, remove.
  63. }
  64. foreach ($reportFields as $key => $reportFid)
  65. {
  66. if(!isset($headerNames[$i][$reportFid])) $headerNames[$i][$key]=$reportFid; // If the header cannot find header name,add head.
  67. }
  68. foreach($headerNames[$i] as $key => $headerName)
  69. {
  70. echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>" . (empty($headerName) ? $lang->report->null : $headerName) . '</th>';
  71. $percentKey = (empty($key) ? 'null' : $key) . 'Percent';
  72. if(isset($condition['percent'][$i]) and isset($condition['showAlone'][$i]) and $condition['contrast'][$i] != 'crystalTotal') echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>" . (isset($sqlLangs[$percentKey][$clientLang]) ? $sqlLangs[$percentKey][$clientLang] : $lang->crystal->percentAB) . "</th>";
  73. $dataCols[$i][] = $key;
  74. }
  75. $showed[$i] = true;
  76. }
  77. elseif(isset($condition['isUser']['reportField'][$i]))
  78. {
  79. $user = zget($users, $reportField, $reportField);
  80. echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>" . (empty($user) ? $lang->report->null : $user) . '</th>';
  81. $dataCols[$i][] = $reportField;
  82. }
  83. else
  84. {
  85. echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>" . zget($fields, $reportField, $reportField) . '</th>';
  86. $dataCols[$i][] = $reportField;
  87. }
  88. if($showed[$i]) break;
  89. $percentKey = $reportField . 'Percent';
  90. if(isset($condition['percent'][$i]) and isset($condition['showAlone'][$i]) and $condition['contrast'][$i] != 'crystalTotal') echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>" . (isset($sqlLangs[$percentKey][$clientLang]) ? $sqlLangs[$percentKey][$clientLang] : $lang->crystal->percentAB) . "</th>";
  91. }
  92. if(isset($condition['reportTotal'][$i])) echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>{$lang->crystal->total}</th>";
  93. $percentKey = $reportField . 'Percent';
  94. if(isset($condition['percent'][$i]) and isset($condition['showAlone'][$i]) and $condition['contrast'][$i] == 'crystalTotal') echo "<th data-flex='true' data-type='number' data-width=$width class='text-center'>" . (isset($sqlLangs[$percentKey][$clientLang]) ? $sqlLangs[$percentKey][$clientLang] : $lang->crystal->percentAB) . "</th>";
  95. }
  96. ?>
  97. </tr>
  98. </thead>
  99. <tbody>
  100. <?php $initStaticData = true;//Report data may be used in doc. When the doc has more than one report, there will be wrong in getCellData method. Because this method use static variable, if has more than one report, the result will be wrong. So init the static variable according to this variable.?>
  101. <?php $methodName = $this->app->getMethodName();?>
  102. <?php if($condition['group2']):?>
  103. <?php foreach($reportData as $group1 => $group1Data):?>
  104. <?php $group2Num = 0;?>
  105. <?php foreach($group1Data as $group2 => $data):?>
  106. <?php $group2Num++;?>
  107. <tr class='text-center'>
  108. <?php if($group2Num == 1 or $methodName == 'show'):?>
  109. <?php
  110. $group1Name = $group1;
  111. if(!empty($condition['isUser']['group1']))
  112. {
  113. $group1Name = zget($users, $group1, $group1);
  114. }
  115. elseif($groupLang['group1'])
  116. {
  117. $group1Name = zget($groupLang['group1'], $group1, $group1);
  118. }
  119. ?>
  120. <td <?php if(count($group1Data) > 1 and $methodName != 'show') echo 'rowspan=' . count($group1Data)?> title='<?php echo $group1Name?>'>
  121. <?php echo empty($group1Name) ? $lang->report->null : $group1Name;?>
  122. </td>
  123. <?php endif;?>
  124. <?php
  125. $group2Name = $group2;
  126. if(!empty($condition['isUser']['group2']))
  127. {
  128. $group2Name = zget($users, $group2, $group2);
  129. }
  130. elseif($groupLang['group2'])
  131. {
  132. $group2Name = zget($groupLang['group2'], $group2, $group2);
  133. }
  134. ?>
  135. <td title='<?php echo $group2Name?>'><?php echo empty($group2Name) ? $lang->report->null : $group2Name;?></td>
  136. <?php
  137. $data = $this->report->getCellData($data, $dataCols, $condition, $initStaticData);
  138. $allTotal = $data['allTotal'];
  139. $cellDataList = $data['cellData'];
  140. foreach($cellDataList as $i => $cellData) echo '<td>' . (empty($cellData) ? 0 : $cellData) . '</td>';
  141. ?>
  142. </tr>
  143. <?php $initStaticData = false;?>
  144. <?php endforeach;?>
  145. <?php endforeach;?>
  146. <?php else:?>
  147. <?php foreach($reportData as $group1 => $data):?>
  148. <tr>
  149. <?php
  150. $group1Name = $group1;
  151. if(!empty($condition['isUser']['group1']))
  152. {
  153. $group1Name = zget($users, $group1, $group1);
  154. }
  155. elseif($groupLang['group1'])
  156. {
  157. $group1Name = zget($groupLang['group1'], $group1, $group1);
  158. }
  159. ?>
  160. <td class="<?php echo $textAlign;?> "title='<?php echo $group1Name?>'><?php echo empty($group1Name) ? $lang->report->null : $group1Name;?></td>
  161. <?php
  162. $data = $this->report->getCellData($data, $dataCols, $condition, $initStaticData);
  163. $allTotal = $data['allTotal'];
  164. $cellDataList = $data['cellData'];
  165. foreach($cellDataList as $i => $cellData) echo '<td class="text-center">' . (empty($cellData) ? 0 : $cellData) . '</td>';
  166. ?>
  167. </tr>
  168. <?php $initStaticData = false;?>
  169. <?php endforeach;?>
  170. <?php endif;?>
  171. <tr>
  172. <td class="<?php echo $textAlign;?>" <?php if($condition['group2']) echo 'colspan=2'?>><?php echo $lang->crystal->total?></td>
  173. <?php ksort($allTotal);?>
  174. <?php foreach($allTotal as $total):?>
  175. <td class='text-center'><?php echo $total?></td>
  176. <?php endforeach;?>
  177. </tr>
  178. </tbody>
  179. </table>
  180. <?php endif;?>