<?php
/**
 * Created by 姚
 * User: user
 * Date: 2015-10-21
 * Time: 上午10:19
 * To change this template use File | Settings | File Templates.
 */
class Order_TrackingErrorController extends Ec_Controller_Action
{
    public function preDispatch()
    {
        $this->tplDirectory = "order/views/default/";
        $this->serviceClass = new Service_TrackingErrorLog();
        $userAuth = new Zend_Session_Namespace('userAuthorization');
        $this->user_id = $userAuth->userId;
    }

    public function listAction(){
        if ($this->_request->isPost()){
            $page = $this->_request->getParam('page', 1);
            $pageSize = $this->_request->getParam('pageSize', 20);

            $page = $page ? $page : 1;
            $pageSize = $pageSize ? $pageSize : 20;

            $return = array(
                "state" => 0,
                "message" => "No Data"
            );
            //$params = $this->_request->getParams();
            $condition = array(
                'order_code'=>$this->_request->getParam("order_code","*"),
                'sm_code'=>$this->_request->getParam("E2",""),
                'dateFor'=>$this->_request->getParam("dateFor",""),
                'dateTo'=>$this->_request->getParam("dateTo",""),
            );
            $count = Service_TrackingErrorLog::getByCondition($condition,"count(*)");
            $return['total'] = $count;
            if($count){
                 $showFields = array(
                    'te_id',
                    'order_code',
                    'sm_code',
                    'update_time',
                    'content',
                );
                //$showFields = $this->serviceClass->getFieldsAlias($showFields);
                $errorList = Service_TrackingErrorLog::getByCondition($condition,$showFields,$pageSize,$page,"update_time desc");
                $return['data'] = $errorList;
                $return['state'] = 1;
            }
            die(Zend_Json::encode($return));
        }
        $this->view->SM=Common_DataCache::getShippingMethodSimple();
        echo Ec::renderTpl($this->tplDirectory . "tracking-error-list.tpl", 'layout');
    }
}
