<?php
class flow_account_detailClassModel extends flowModel
{
	
	
  public function flowrsreplace($rs)
    {
          $uid=$this->adminid;
          $sql="account in ( select a.name from oa_c_fund_account as a where uid like concat({$uid},',%') or uid like concat('%,',{$uid}) or uid like concat('%,',{$uid},',%') )";
          $account_detail = m('c_account_detail')->getall($sql,'account');
          foreach ($account_detail as $key => $value){
              $allaccount[]=$value['account'];
          }
         foreach ($rs as $k => &$v) {
            switch ($k) {
                case 'opt_type':
                    if($v == 1) {
                        $v = '收入';
                      
                    } else if($v == 2) {
                        $v = '支出';
                    } else {
                        $v = '';
                    }
                    break;
                case 'trans_numb':
                   
                    $arr=$this->getnums($v);
                    if($arr){
                      $num=$arr['num'];
                      $id=$arr['id'];
                      $name=$arr['name'];
                      $v= "<a href='javascript:;' onclick=openxiangs('$name','$num',$id)>$v</a>";
                    }else{
                      $v=$v;
                    }
                    break;
                 case 'account':
                    if(!in_array($v,$allaccount)){
                        $rs['account_balance']='***';
                    }else{
                        $rs['account_balance']=$rs['account_balance'];
                    }
                   break;
               }  
        }
        return $rs;
    }

	 public function getnums($num){

        if(strpos($num, 'OA-FK') !==false){
              $ids = m('c_fininfom_oafk')->getone('docnum = "'.$num.'"','id');
              $ids['num']='oafk';
              $ids['name']='付款申请单';
              // $ids['id']=$ids['id'];
        }
        if(strpos($num, 'OA-YFK') !==false){
              $ids = m('c_fininfom_oayfk')->getone('docnum = "'.$num.'"','id');
              $ids['num']='oayfk';
              $ids['name']='预付款申请单';
        }
        if(strpos($num, 'OA-BX') !==false){
              $ids = m('fininfom')->getone('docnum = "'.$num.'"','id'); 
              $ids['num']='finfybx';
              $ids['name']='费用报销';
        }
        if(strpos($num, 'FT') !==false){
              $ids = m('c_fund_detail')->getone('trans_numb = "'.$num.'"','id'); 
              $ids['num']='fund_transfer';
              $ids['name']='资金划拨';
        }
        if(strpos($num, 'FS') !==false){
              $ids = m('c_fund_detail')->getone('trans_numb = "'.$num.'"','id'); 
              $ids['num']='fund_deposit';
              $ids['name']='资金入账';
        }
        return $ids;
    }
}

