StatBookController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\stat\classes\StatBookClass;
  4. use common\components\dateUtil;
  5. use Yii;
  6. use common\components\util;
  7. class StatBookController extends BaseController
  8. {
  9. //花材销量 ssh 20211021
  10. public function actionProfile()
  11. {
  12. $get = Yii::$app->request->get();
  13. $where = [];
  14. $where['mainId'] = $this->mainId;
  15. $searchTime = $get['searchTime'] ?? 'today';
  16. if (!empty($searchTime)) {
  17. $startTime = $get['startTime'] ?? '';
  18. $endTime = $get['endTime'] ?? '';
  19. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  20. $where['time'] = ['between', [$period['startTime'], $period['endTime']]];
  21. }
  22. $list = StatBookClass::getAllByCondition($where, 'time DESC', '*');
  23. util::success(['list' => $list]);
  24. }
  25. public function actionPrintOrder()
  26. {
  27. $get = Yii::$app->request->get();
  28. $where = [];
  29. $where['mainId'] = $this->mainId;
  30. $searchTime = $get['searchTime'] ?? 'today';
  31. if (!empty($searchTime)) {
  32. $startTime = $get['startTime'] ?? '';
  33. $endTime = $get['endTime'] ?? '';
  34. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  35. $where['time'] = ['between', [$period['startTime'], $period['endTime']]];
  36. }
  37. $list = StatBookClass::getAllByCondition($where, 'time DESC', '*');
  38. if (empty($list)) {
  39. util::fail('没有花材需要打印');
  40. }
  41. $num = count($list);
  42. $pageSize = 16;
  43. $ratio = ceil($num / $pageSize);
  44. echo $num;
  45. $content = "<CB>预订汇总</CB><BR><BR>";
  46. if ($ratio > 1) {
  47. for ($i = 1; $i <= $ratio; $i++) {
  48. $offset = ($i - 1) * $pageSize;
  49. $current = array_slice($list, $offset, $pageSize);
  50. print_r($current);
  51. }
  52. } else {
  53. }
  54. }
  55. }