Goods.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace store\Admin;
  3. use Dever;
  4. class Goods extends Core
  5. {
  6. # 订单列表
  7. public function getList()
  8. {
  9. $data = Dever::load('store/lib/goods')->getGoodsSku($this->id);
  10. $html = '';
  11. if ($data) {
  12. foreach ($data as $k => $v) {
  13. $v['cover'] = '<img src="'.$v['cover'].'" width="50" />';
  14. $v['sku_name'] = isset($v['sku_name']) ? $v['sku_name'] : '无';
  15. $html .= '<tr><td>'.$v['cover'].'</td><td>'.$v['name'].'</td><td>'.$v['sku_name'].'</td><td>'.$v['total'].'</td></tr>';
  16. }
  17. }
  18. return $html;
  19. }
  20. # 获取列表页搜索信息
  21. public function getSearch()
  22. {
  23. $config = array
  24. (
  25. array('name' => '全部', 'value' => ''),
  26. array('name' => '库存<3件', 'value' => '3'),
  27. array('name' => '库存<5件', 'value' => '5'),
  28. array('name' => '库存<10件', 'value' => '10'),
  29. array('name' => '无库存', 'value' => '1'),
  30. );
  31. $total = Dever::input('total');
  32. $html = '';
  33. foreach ($config as $k => $v) {
  34. $selected = '';
  35. if ((!$total && $k == 0) || $total == $v['value']) {
  36. $selected = 'selected=""';
  37. }
  38. $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
  39. }
  40. return $html;
  41. }
  42. # 获取基本信息
  43. public function getConfig()
  44. {
  45. $data['search'] = Dever::url('goods', 'store');
  46. $data['print'] = Dever::url('admin/goods.print', 'store');
  47. return $data;
  48. }
  49. # 打印订单单
  50. public function print_api()
  51. {
  52. $factory_config = Dever::db('main/factory_config')->find();
  53. $main_config = Dever::db('main/config')->find();
  54. $config = Dever::db('main/config')->find();
  55. $data = Dever::load('store/lib/goods')->getGoodsSku($this->id);
  56. $store = Dever::db('store/info')->find($this->id);
  57. $pdf = Dever::load('pdf/lib/base')->init();
  58. $pdf->hr('-', $config['name']);
  59. $pdf->br()->font(20)->center('库存清单');
  60. $pdf->font(10);
  61. $pdf->br(2);
  62. $pdf->br()->left('仓库名称:' . $store['name'], 80)->left('制单人:' . $this->user['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
  63. $pdf->hr();
  64. $head = array(array('商品编号', 40), array('商品名称', 70), array('商品属性', 60), array('数量', 20));
  65. if ($data) {
  66. $body = array();
  67. $body_total = array();
  68. $body_total['num'] = 0;
  69. foreach ($data as $k => $v) {
  70. $v['sku_name'] = isset($v['sku_name']) ? $v['sku_name'] : '无';
  71. $body[] = array
  72. (
  73. $v['id'],
  74. $v['name'],
  75. $v['sku_name'],
  76. 'x ' . $v['total'],
  77. );
  78. $body_total['num'] += $v['total'];
  79. }
  80. $pdf->br();
  81. foreach ($head as $k => $v) {
  82. $pdf->left($v[0], $v[1]);
  83. }
  84. foreach ($body as $k => $v) {
  85. $pdf->br();
  86. foreach ($head as $k1 => $v1) {
  87. $pdf->left($v[$k1], $v1[1]);
  88. }
  89. }
  90. $pdf->br();
  91. $pdf->right('共'.$body_total['num'].'件商品');
  92. $pdf->hr();
  93. }
  94. $pdf->br(1);
  95. $pdf->right('如遇任何问题请致电客服');
  96. $pdf->br();
  97. $pdf->font(20);
  98. $pdf->left($main_config['name'], 160);
  99. $pdf->font(10);
  100. $pdf->right('电话:' . $factory_config['phone'], 30);
  101. $pdf->br();
  102. $pdf->left($main_config['site'], 160);
  103. $pdf->font(10);
  104. $pdf->right($main_config['worktime'], 30);
  105. $pdf->out('库存清单');
  106. }
  107. }