<?php
class Custom_FtpMessageSendlogController extends Ec_Controller_Action
{
    public function preDispatch()
    {
        $this->tplDirectory = "custom/views/ftp/";
        $this->serviceClass = new Service_FtpMessageSendlog();
    }

    public function listAction()
    {
        if ($this->_request->isPost()) {
            //$fml_id = $this->_request->getParam('E1','');
            $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 = $this->serviceClass->getMatchFields($params);
            unset($params);
            $count = $this->serviceClass->getByCondition($condition, 'count(*)');
            $return['total'] = $count;

            if ($count) {
                $showFields=array(
                    
                'fml_id',
                'refercence_no',
                'add_time',
                'fmsl_comment',
                );
                $showFields = $this->serviceClass->getFieldsAlias($showFields);
                $rows = $this->serviceClass->getByCondition($condition,$showFields, $pageSize, $page, array('fmsl_id desc'));
                $return['data'] = $rows;
                $return['state'] = 1;
                $return['message'] = "";
            }
            die(Zend_Json::encode($return));
        }else{
            $fml_id = $this->_request->getParam('fml_id','');
            if(empty($fml_id)){
                 exit('参数为空');
            }
            $fmsl = new Service_FtpMessageSendlist();
            $ftpRow = $fmsl->getByField($fml_id);
            $this->view->ftpRow = $ftpRow;
        }
        $this->view->fml_id = $fml_id;
        echo Ec::renderTpl($this->tplDirectory . "ftp_message_sendlog_index.tpl", 'layout');
    }
}