<?php
/**
 * 修车财务控制器
 */

namespace frontend\controllers;

use common\models\FixCarF;
use Yii;
use common\libs\MyLib;
use yii\data\Pagination;
use common\models\FixCarT;
use common\models\UserT;
use common\models\CarFinanceT;
use common\models\GiftTicketT;
use yii\web\Response;

class FixFinanceController extends BaseController{

    /**
    调取车信息
     */
    public function getList($acc_id=-1){

        $fixcar = FixCarT::findOne(['id'=>$acc_id]);
        return $fixcar;
    }


    /**
     ***********************************
     * 财务统计页面
     * 财务统计详细页面
     *********************************
     */
    public function actionCount(){

        $op = $this->requestType('get','op',1);
        $id = $this->requestType('get','fix_id',1);
        $page = $this->requestType('get','page',1);
        $car_no = $this->requestType('get','car_no');
        if($page < 1) $page = 1;
        $car_list = [];
        $page_info = '';
        if($op = 1){

            $model = FixCarF::find();
            $model = $model->where('');
            $model = $model->all();

            $finance_count = new FixCarF();
            $finance_count->attributes = $model;
          // var_dump($model);
           // $total = $model->count();
            $pagination = new Pagination();
            $pagination->setPage($page-1);
            $page_info = MyLib::getPageInfo($pagination);




            }
        return $this->render('count',[
            'car_list' => $car_list,
            'page_info' => $page_info,
            'car_no' => $car_no,
            'model'=>$model,
        ]);

    }

    public function actionCountForm(){

        $op = $this->requestType('get','op',1);
        $id = $this->requestType('get','fix_id',1);
        $page = $this->requestType('get','page',1);
        $car_no = $this->requestType('get','car_no');
        if($page < 1) $page = 1;
        $car_list = [];
        $page_info = '';
        if($op = 1){

            $model = FixCarF::find();
            $model = $model->where('');
            $model = $model->all();

            $finance_count = new FixCarF();
            $finance_count->attributes = $model;
            // var_dump($model);
            // $total = $model->count();
            $pagination = new Pagination();
            $pagination->setPage($page-1);
            $page_info = MyLib::getPageInfo($pagination);




        }
        return $this->render('count-form',[
            'car_list' => $car_list,
            'page_info' => $page_info,
            'car_no' => $car_no,
            'model'=>$model,
        ]);

    }



    public function actionSave()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $request = Yii::$app->request;
        $id = $request->get('id',0);
        var_dump($id);exit;
        $result = array();
        $result['success'] = false;
        $result['msg'] = '保存失败';

        if($request->isGet) {
            $id = $request->post('id',0);
            echo $id;
        }
        $demo = FixCarF::findOne(['id'=>$id]);
        var_dump($demo);
        $demo->save();
        }
}