<?php

namespace Mshop\Src;

use Dever;
use Mshop\Lib\Core;

# 库存清单
class Goods extends Core
{
    public function getList()
    {
        $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'),
        );
        $this->data['data'] = Dever::load('shop/lib/info')->getGoodsSku($this->shop_id);

        return $this->data;
    }


    # 下单pdf
    public function pdf()
    {
    	Dever::apply('fpdf/chinese', 'pdf');
        $pdf = new \PDF_Chinese('P','mm','A4');
        $pdf->AddGBFont();
        $pdf->Open();
        $pdf->AddPage();
        $pdf->SetFont('GB', '', 10);
        $pdf->Cell(180, 8, $this->convert('------------------------------------------------------------------厨人易料------------------------------------------------------------------'), 0, 0);
        $pdf->Ln(20);

        $pdf->SetFont('GB', '', 20);
        $pdf->Cell(0, 8,  $this->convert("库存清单"), 0, 0, 'C');
        $pdf->Ln();
        $pdf->Ln();
        $pdf->Ln();
        $pdf->SetFont('GB', '', 10);
        $pdf->Cell(0, 8,  $this->convert("门店名称:的发电机房就得开"), 0, 0);

        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("制单人:23213213"), 0, 0);

        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("制单时间:23213213"), 0, 0);

        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("----------------------------------------------------------------------------------------------------------------------------------------------"), 0, 0);

        $pdf->Ln();
        $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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        $pdf->Ln();
        $pdf->Cell(150, 8,  $this->convert("22221111111"), 0, 0);
        $pdf->Cell(40, 8,  $this->convert("X 2"), 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');

        

        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("----------------------------------------------------------------------------------------------------------------------------------------------"), 0, 0);

        //$pdf->SetY(-100);
        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("如遇任何问题请致电客服"), 0, 0, 'C');

        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("电话:400-123-1234"), 0, 0, 'C');

        $pdf->Ln();
        $pdf->Cell(0, 8,  $this->convert("周一~周五 9:00~18:00"), 0, 0, 'C');

        $manage_config = Dever::db('main/manage_config')->find();
        $sell_config = Dever::db('main/sell_config')->find();

        $pdf->Ln();
        $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();
    }

    public function convert($string, $to = 'GBK', $source = 'UTF-8')
    {
        return mb_convert_encoding($string, $to, $source);
    }
}