<?php
/**
 * 
 * Class 
 */
class openfkinfoClassAction extends openapiAction
{
    public function __call($name, $arguments)
    {
        $msg = $name.' action not found';
        return $this->showreturn([],$msg,'201');
    }


    public function listAction(){

        $post = $_POST;
        if($post){
            $arr=$post['docnum'];
            $arr=explode(',', $arr);

            $str = " ' " . join("','", array_values($arr) ) . " ' ";  // 使用需要的符号拼接
            $str = " ' ".str_replace( ",","','", implode(',',$arr));  //使用需要的符号替换
            $str = join( ', ',array_map(function( $v ){  return "'".$v."'";},$arr) );


            $sql='select a.id,a.docnum,a.status,b.nowcheckname from oa_c_fininfom_oafk  as a INNER JOIN oa_flow_bill as b on a.docnum=b.sericnum  where a.docnum  in '."(".$str.")";
            $data = $this->db->getall($sql);
            foreach ($data as $key => $value) {
                $info ='select * from [Q]c_fund_details_fk   where mid='.$value['id'];
                $info = $this->db->getall($info);
                $data[$key]['info']=$info;
                $data[$key]['url']="http://chengye-dev.gonn.tech/task.php?a=p&num=oafk&mid=".$value['id'];
            }
        }else{
            $data = $this->db->getall('select  * from oa_c_fininfom_oafk  as a INNER JOIN oa_flow_bill as b on a.docnum=b.sericnum ');
            foreach ($data as $key => $value) {


                $info ='select * from [Q]c_fund_details_fk   where mid='.$value['id'];
                $info = $this->db->getall($info);
                $data[$key]['info']=$info;
                $data[$key]['url']="http://chengye-dev.gonn.tech/task.php?a=p&num=oafk&mid=".$value['id'];
            }
        }
        return $this->showreturn($data,'SUCCESS','200');

    }



    public function fkinforAction(){

        $post = $_POST;
        switch ($post['type']) {
            case '1':
                $sql='select o.name,o.num from oa_option  as o  where o.pid=516';
                $data = $this->db->getall($sql);
                break;
            case '2':
                $sql='select o.name,o.num from oa_option  as o  where o.pid=933';
                $data = $this->db->getall($sql);
                break;
            case '3':
                $sql='select o.name,o.num from oa_option  as o  where o.pid=678';
                $data = $this->db->getall($sql);
                break;
            default:
                return $this->showreturn([],'error','201');
                break;
        }

        return $this->showreturn($data,'SUCCESS','200');

    }
}