dever 3 years ago
parent
commit
f62ecefa4e

+ 54 - 27
app/mshop/src/Goods.php

@@ -10,15 +10,15 @@ class Goods extends Core
 {
     public function getList()
     {
-    	$this->data['search'] = array();
-    	$this->data['search']['total'] = array
-    	(
-    		array('name' => '全部', 'value' => ''),
+        $this->data['search'] = array();
+        $this->data['search']['total'] = array
+        (
+            array('name' => '全部', 'value' => ''),
             array('name' => '无库存', 'value' => '1'),
-    		array('name' => '库存<3件', 'value' => '3'),
-    		array('name' => '库存<5件', 'value' => '5'),
-    		array('name' => '库存<10件', 'value' => '10'),
-    	);
+            array('name' => '库存<3件', 'value' => '3'),
+            array('name' => '库存<5件', 'value' => '5'),
+            array('name' => '库存<10件', 'value' => '10'),
+        );
         $this->data['data'] = Dever::load('shop/lib/info')->getGoodsSku($this->shop_id);
 
         return $this->data;
@@ -29,29 +29,27 @@ class Goods extends Core
     public function pdf()
     {
         Dever::apply('fpdf/chinese', 'pdf');
-
-        $pdf=new \PDF_Chinese();
+        $pdf = new \PDF_Chinese('P','mm','A4');
         $pdf->AddGBFont();
         $pdf->Open();
         $pdf->AddPage();
-        $pdf->SetFont('GB', 'B', 10);
-        $pdf->Cell(0, 8,  $this->convert("------------------------------------------------------------------厨人易料------------------------------------------------------------------"), 0, 0, 'C');
-        $pdf->Ln();
-        $pdf->Ln();
+        $pdf->SetFont('GB', '', 10);
+        $pdf->Cell(180, 8, $this->convert('------------------------------------------------------------------厨人易料------------------------------------------------------------------'), 0, 0);
+        $pdf->Ln(20);
 
-        $pdf->SetFont('GB', 'B', 20);
-        $pdf->Cell(180, 8,  $this->convert("库存清单"), 0, 0, 'C');
+        $pdf->SetFont('GB', '', 20);
+        $pdf->Cell(0, 8,  $this->convert("库存清单"), 0, 0, 'C');
         $pdf->Ln();
         $pdf->Ln();
         $pdf->Ln();
-        $pdf->SetFont('GB', 'B', 10);
-        $pdf->Cell(180, 8,  $this->convert("门店名称:的发电机房就得开"), 0, 0);
+        $pdf->SetFont('GB', '', 10);
+        $pdf->Cell(0, 8,  $this->convert("门店名称:" . $this->shop['name']), 0, 0);
 
         $pdf->Ln();
-        $pdf->Cell(180, 8,  $this->convert("制单人:23213213"), 0, 0);
+        $pdf->Cell(0, 8,  $this->convert("制单人:" . $this->user['name']), 0, 0);
 
         $pdf->Ln();
-        $pdf->Cell(180, 8,  $this->convert("制单时间:23213213"), 0, 0);
+        $pdf->Cell(0, 8,  $this->convert("制单时间:" . date('Y-m-d H:i:s')), 0, 0);
 
         $pdf->Ln();
         $pdf->Cell(0, 8,  $this->convert("----------------------------------------------------------------------------------------------------------------------------------------------"), 0, 0);
@@ -60,27 +58,56 @@ class Goods extends Core
         $pdf->Cell(150, 8,  $this->convert("商品名称"), 0, 0);
         $pdf->Cell(40, 8,  $this->convert("数量"), 0, 0, 'R');
 
-        $pdf->Ln();
-        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
-        $pdf->Cell(40, 8,  $this->convert("X 2"), 0, 0, 'R');
+        $data = Dever::load('shop/lib/info')->getGoodsSku($this->shop_id);
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                if (isset($v['price_array'])) {
+                    $pdf->Ln();
+                    $pdf->Cell(150, 8,  $this->convert($v['name']), 0, 0);
+                    foreach ($v['price_array'] as $k1 => $v1) {
+                        $pdf->Ln();
+                        $pdf->Cell(150, 8,  $this->convert('----' . $v1['name']), 0, 0);
+                        $pdf->Cell(40, 8,  $this->convert('X' . $v1['total']), 0, 0, 'R');
+                    }
+                } else {
+                    $pdf->Ln();
+                    $pdf->Cell(150, 8,  $this->convert($v['name']), 0, 0);
+                    $pdf->Cell(40, 8,  $this->convert('X' . $v['total']), 0, 0, 'R');
+                }
+            }
+        }
 
         $pdf->Ln();
         $pdf->Cell(0, 8,  $this->convert("----------------------------------------------------------------------------------------------------------------------------------------------"), 0, 0);
 
+        //$pdf->SetY(-100);
+        $manage_config = Dever::db('main/manage_config')->find();
+        $sell_config = Dever::db('main/sell_config')->find();
+        $config = Dever::db('main/config')->find();
+
         $pdf->Ln();
+        $pdf->Cell(0, 8,  $this->convert("如遇任何问题请致电客服"), 0, 0, 'C');
+
         $pdf->Ln();
-        $pdf->Cell(180, 8,  $this->convert("如遇任何问题请至电客服"), 0, 0, 'C');
+        $pdf->Cell(0, 8,  $this->convert("电话:" . $manage_config['phone']), 0, 0, 'C');
 
         $pdf->Ln();
-        $pdf->Cell(180, 8,  $this->convert("电话:400-123-1234"), 0, 0, 'C');
+        $pdf->Cell(0, 8,  $this->convert($config['worktime']), 0, 0, 'C');
 
         $pdf->Ln();
-        $pdf->Cell(180, 8,  $this->convert("周一~周五 9:00~18:00"), 0, 0, 'C');
+        $pdf->Ln();
+        $y = $pdf->GetY();
+        $pdf->Image($sell_config['applet'], 70, $y, 30, 30);
+        $pdf->Image($manage_config['applet'], 110, $y, 30, 30);
+
+        $pdf->Ln(30);
+        $pdf->Cell(0, 8,  $this->convert("门店零售小程序                 门店管理小程序"), 0, 0, 'C');
 
         $pdf->Output();
     }
 
-    private function convert($string, $to = 'GBK', $source = 'UTF-8')
+    public function convert($string, $to = 'GBK', $source = 'UTF-8')
     {
         return mb_convert_encoding($string, $to, $source);
     }

+ 1 - 1
app/mshop/src/My.php

@@ -334,7 +334,7 @@ class My extends Core
     # 销售对账单管理
     public function stat_month()
     {
-        $this->data['config'] = Dever::db('main/sell_config')->find();
+        $this->data['config'] = Dever::db('main/manage_config')->find();
         $where['shop_id'] = $this->shop_id;
         $shop = Dever::db('shop/info')->find($this->shop_id);
         $month = Dever::input('month');

+ 10 - 0
main/database/manage_config.php

@@ -79,6 +79,16 @@ return array
             'update'    => 'text',
         ),
 
+        'dz_phone'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '对账专员电话',
+            'default'   => '',
+            'desc'      => '请输入对账专员电话',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
         'km'      => array
         (
             'type'      => 'varchar-32',

+ 0 - 10
main/database/sell_config.php

@@ -79,16 +79,6 @@ return array
             'update'    => 'text',
         ),
 
-        'dz_phone'      => array
-        (
-            'type'      => 'varchar-100',
-            'name'      => '对账专员电话',
-            'default'   => '',
-            'desc'      => '请输入对账专员电话',
-            'match'     => 'option',
-            'update'    => 'text',
-        ),
-
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 4 - 0
package/pdf/index.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_PACKAGE',  'pdf');
+define('DEVER_APP_SETUP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');