| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183 | <?php/** * @author darkredz */class ReceiptExtendController extends DooController {	public $staff;	public $verifyId;	public $executeId;		// public static $NEW2 = 0;	public $AGENCY = "日常相关费用";	public $TRAVEL = "差旅相关费用";	public $TRAIN = "培训班费用";	public $OTHER = "其他";	private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";	private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";	private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";	private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";	private function showCache($path) {		if (file_exists ( $path )) {			echo "<!DOCTYPE html>";			include $path;			die ();		}	}	private function cacheFile($path) {		$content = ob_get_contents ();		$fp = fopen ( $path, "w" );		fwrite ( $fp, $content );		fclose ( $fp );	}	private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {		$collectHtml = "";		$sumPrice = 0.00;		for($i = 1; $i <= 12; $i ++) {			$falg = true;			foreach ( $receiptCollectList as $key => $value ) {				if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {					$sumPrice += $value ['price'];					if ($classType == "b") {						$collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';						$falg = false;						break;					} else {						$collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';						$falg = false;						break;					}				}			}			if ($falg)				$collectHtml .= '<td class="taR">-</td>';		}		$collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';		return $collectHtml;	}	public function beforeRun($resource, $action) {		Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$sid = $XDeode->decode ( $_COOKIE ["staff"] );		// 单独判断公司汇总的访问权限		if ($action == 'companyCategoryCollect'||$action='receiptSummaryStatisticsByAgency') {			Doo::loadModel ( "receiptAuthorityManage" );			$invoiceCompanyManage = new receiptAuthorityManage ();						$icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );			if (empty ( $icm ))				die ( 'illegal request' );		}				Doo::loadModel ( 'staff' );		$staff = new staff ();		$detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );				$accessModular = 'RECEIPTSEXTEND'; // 是否已经开放的方法		$accessAuthority = 'RECEIPTS';		if (empty ( $detail ['cldAccessArray'] ))			die ( 'illegal request' );		else {			if (in_array ( $accessAuthority, $detail ['cldAccessArray'] )) {				if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {					$flag = true;				} else {					$flag = false;				}			} else {				die ( 'illegal request' );			}		}		if (! $flag)			die ( 'illegal request' );	}	function __construct() {		if (isset ( $_COOKIE ["staff"] )) {						if (! empty ( $_COOKIE ["staff"] )) {								Doo::loadModel ( 'staff' );				Doo::loadModel ( 'verify' );				$verify = new verify ();				$staff = new staff ();				Doo::loadModel ( "execute" );				$execute = new execute ();								$verifyList = $verify->find ( array (						'select' => 'staff',						'asArray' => true 				) );				$list = array ();								// 判断角色的审批权限				foreach ( $verifyList as $key => $value ) {					$ver = json_decode ( $value ['staff'] );										foreach ( $ver as $k => $v ) {						if ($v [1] == 'ROLE') {							$roleList = json_decode ( $v [3] );							foreach ( $roleList as $t => $g ) {								$gList = explode ( "_", $g );								array_push ( $list, $gList [0] );								// print_r($list);							}						} else							array_push ( $list, $v [0] );					}				}								// 判断执行人的审批权限				$executeList = $execute->find ( array (						'where'=>'mold !="日常收支"',						'select' => 'staff',						'asArray' => true 				) );				$list2 = array ();				foreach ( $executeList as $key => $value ) {					$ver = json_decode ( $value ['staff'] );										foreach ( $ver as $k => $v ) {						array_push ( $list2, $v [0] );					}				}				//print_r($executeList);				$eidList = file_get_contents ( "protected/config/execute/execute.ini" );				$eidList = array_filter ( explode ( ",", $eidList ) );								$this->executeId = array_merge ( $list2, $eidList );								$this->verifyId = $list;				$this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );								// 检测用户信息完成				$this->data ['isStaffCompleteMsg'] = false;				$detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );				if (! empty ( $detail ))					$this->data ['isStaffCompleteMsg'] = true;								return "/";			}		}				Doo::loadCore ( 'uri/DooUriRouter' );		$router = new DooUriRouter ();		$routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );				if ($routeRs ['1'] != "login") {			header ( 'Content-Type:text/html;charset=utf-8' );			@header ( "Location: /login" );		}	}		/**	 * 查看审批培训班结算	 */	function receiptTrain() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';				$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';		$trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );				// 如有已入账已收款的发票,自动取消办事处已收款		// Doo::loadModel ( 'RIExtend' );		// $RIExtend = new RIExtend ();		// $RIExtendList=$RIExtend->getRIExtendByRid($rid);		// if (!empty($RIExtendList)){		// foreach ($RIExtenreceiptTrainRevenuedList as $key=>$value){		// $RIExtend = new RIExtend ();		// $RIExtend->delete(array (		// 'where' => 'iid=' . $value['iid'],		// 'limit' => 1		// ));		// }		// }				$data ['receiptMemu'] = 'expenses';		if ($showType == 'approval') {			$data ['receiptMemu'] = 'approvalExpenses';			// if ($receiptDetail ['status'] != 2)			// die ();		} elseif ($showType == 'implement') {			$data ['receiptMemu'] = 'implement';			// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))			// die ();		}		$data ['showType'] = $showType;				$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				// 汇总表合计		// 收入合计		Doo::loadModel ( 'invoiceTraining' );		$invoiceTraining = new invoiceTraining ();		$invoiceTrainingDetail = array (				'invoiceArriveAmount' => '0.00',				'RIAmount' => '0.00',				'invoiceTotalAmount' => '0.00',				'invoiceCompanyAmount' => '0.00',				'invoiceArriveAmountM'=>'0.00',				'invoiceCompanyAmountM'=>'0.00'		);		if ($receiptDetail ['invoiceTrainId'] != 0) {			$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );		}		// print_r($invoiceTrainingDetail);		$invoiceArriveAmount = $RIAmount = 0;		if (! empty ( $invoiceTrainingDetail )) {			$invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];			$RIAmount = $invoiceTrainingDetail ['RIAmount'];		}		$data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;		// 支出项目		Doo::loadModel ( 'accountItem' );		$accountItem = new accountItem ();				// 项目金额合计		Doo::loadModel ( 'RItem' );		$RItem = new RItem ();		// 讲师获得		Doo::loadModel ( 'RILecturer' );		$RILecturer = new RILecturer ();		$RItemList = $RItem->getRItemByRid ( $rid );		$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );		// 支出项金额详情		$aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );				// 利润		$profit = $invoiceArriveAmount - $aiData ['total'];		$companyProfit = $profit * 0.6;		$categoryProfit = $profit * 0.4;				$data ['profit'] = sprintf ( "%.2f", $profit );		$data ['companyProfit'] = sprintf ( "%.2f", $companyProfit );		$data ['categoryProfit'] = sprintf ( "%.2f", $categoryProfit );		// 发票利润		$data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];				// 发票公司利润		$invoiceCompanyProfit = $data ['invoiceProfit'] * 0.6;		$data ['invoiceCompanyProfit'] = sprintf ( "%.2f", $invoiceCompanyProfit );		// 办事处利润		$invoiceCategoryProfit = $data ['invoiceProfit'] * 0.4;		$data ['invoiceCategoryProfit'] = sprintf ( "%.2f", $invoiceCategoryProfit );				// print_r($aiData['dataList']);		$categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];		$data ['categoryActualExpenditure'] = sprintf ( "%.2f", $categoryActualExpenditure );		// 备用金		$sum = 0;		$data ['receiptLoanDetail'] = array (				'sum' => '0.00' 		);		if (! empty ( $receiptDetail ['trainLoanRid'] )) {						$receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );			foreach ($receiptLoanList as $key=>$value){				$sum+=$value['sum'];			}			$data ['receiptLoanDetail'] = array (					'sum' => $sum			);			//$data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );			//$sum = $data ['receiptLoanDetail'] ['sum'];		}				$payment = $sum + $RIAmount - $categoryActualExpenditure;		$data ['payment'] = sprintf ( "%.2f", $payment );		$data ['paymentAbs']=sprintf ( "%.2f",abs($payment));        Doo::loadClass ( 'authcode.func' );        $data ['paymentAuthCode'] = authcode($payment,'');		$data ['total'] = sprintf ( "%.2f", $aiData ['total'] );		$data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;		$data ['aiList'] = $aiData ['dataList'];				// 占比计算		if ($invoiceArriveAmount != 0) {			$data ['totalProportion'] = sprintf ( "%.2f", $aiData ['total'] / $invoiceArriveAmount * 100 );			$data ['profitProportion'] = sprintf ( "%.2f", $profit / $invoiceArriveAmount * 100 ); // number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;			$data ['sumProportion'] = sprintf ( "%.2f", $sum / $invoiceArriveAmount * 100 ); // number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;			$data ['invoiceTotalAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount * 100 );			$data ['RIAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount * 100 );			$data ['companyProfitProportion'] = sprintf ( "%.2f", $companyProfit / $invoiceArriveAmount * 100 );			$data ['categoryProportion'] = sprintf ( "%.2f", $categoryProfit / $invoiceArriveAmount * 100 );			$data ['categoryActualExpenditureProportion'] = sprintf ( "%.2f", $categoryActualExpenditure / $invoiceArriveAmount * 100 );			$data ['paymentProportion'] = sprintf ( "%.2f", $payment / $invoiceArriveAmount * 100 );		} else {			$data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;		}		// 发票金额占比计算		if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {			// 支出			$data ['invoicetotalProportion'] = sprintf ( "%.2f", $aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 利润			$data ['invoiceprofitProportion'] = sprintf ( "%.2f", $data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 公司利润			$data ['invoicecompanyProfitProportion'] = sprintf ( "%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 办事处利润			$data ['invoicecategoryProportion'] = sprintf ( "%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 公司收款			$data ['invoiceTotalAmountProportionB'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 备用金			$data ['invoicesumProportion'] = sprintf ( "%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 办事处收款			$data ['invoiceRIAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 办事处实际支出			$data ['ICAEP'] = sprintf ( "%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );			// 付总部款			$data ['invoicepaymentProportion'] = sprintf ( "%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount'] * 100 );		} else {			$data ['invoiceprofitProportion'] = $data ['invoiceRIAmountProportion'] = $data ['invoicetotalProportion'] = $data ['invoiceTotalAmountProportionB'] = $data ['invoicesumProportion'] = $data ['ICAEP'] = $data ['invoicepaymentProportion'] = $data ['invoicecompanyProfitProportion'] = $data ['invoicecategoryProportion'] = 0;		}				// 是否写入过流水		$accountType = 0;		if ($receiptDetail ['Rtype'] == 0) {			$accountType = 3;		} elseif ($receiptDetail ['Rtype'] == 1) {			if ($receiptDetail ['Rtype'] == 0) {				$accountType = 1;			} elseif ($receiptDetail ['Rtype'] == 1) {				$accountType = 2;			}		} elseif ($receiptDetail ['Rtype'] == 2) {			$accountType = 4;		} elseif ($receiptDetail ['Rtype'] == 3) {			$accountType = 12;		}		Doo::loadModel ( 'wasteBook' );		$wasteBook = new wasteBook ();		$wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptDetail ['rid'] );		$data ['wbDetail'] = $wbDetail;				// 讲师人数		Doo::loadModel ( 'RILecturer' );		$RILecturer = new RILecturer ();		$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );		$data ['lectureCount'] = count ( $RILecturerList );				// 审批组		Doo::loadModel ( 'verify' );		$verify = new verify ();		$veList = $verify->getVerifyByAll ();				// 办事处		Doo::loadModel ( 'L_category' );		$lCategory = new L_category ();		$data ['category'] = $lCategory->getCategory ();				$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['veList'] = $veList;		$data ['trainEdiType'] = $trainEdiType;		$data ['ridKey'] = $ridKey;				$summaryJson = array (				0 => array (						'invoiceTotalAmount' => $data ['invoiceTrainingDetail'] ['invoiceTotalAmount'],						'invoiceArriveAmount' => $data ['invoiceTrainingDetail'] ['invoiceArriveAmount']				),				1 => array (						'1' => $data ['total'],						'2' => $data ['invoicetotalProportion'] . '%',						'3' => $data ['total'],						'4' => $data ['totalProportion'] . '%'				),				2 => array (						'1' => $data ['invoiceProfit'],						'2' => $data ['invoiceprofitProportion'] . '%',						'3' => $data ['profit'],						'4' => $data ['profitProportion'] . '%'				),						3 => array (						'1' => $data ['invoiceCompanyProfit'],						'2' => $data ['invoicecompanyProfitProportion'] . '%',						'3' => $data ['companyProfit'],						'4' => $data ['companyProfitProportion'] . '%'				),				4 => array (						'1' => $data ['invoiceCategoryProfit'],						'2' => $data ['invoicecategoryProportion'] . '%',						'3' => $data ['categoryProfit'],						'4' => $data ['categoryProportion'] . '%'				),				5 => array (						'1' =>$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'],						'2' => $data ['invoiceTotalAmountProportionB'] . '%',						'3' => $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'],						'4' => $data ['invoiceTotalAmountProportion'] . '%'				),						6 => array (						'1' =>$data ['receiptLoanDetail'] ['sum'],						'2' => $data ['invoicesumProportion'] . '%',						'3' => $data ['receiptLoanDetail'] ['sum'],						'4' => $data ['sumProportion'] . '%'				),				7 => array (						'1' =>$data ['invoiceTrainingDetail'] ['RIAmount'],						'2' => $data ['invoiceRIAmountProportion'] . '%',						'3' => $data ['invoiceTrainingDetail'] ['RIAmount'],						'4' => $data ['RIAmountProportion'] . '%'				),				8 => array (						'1' =>$data ['categoryActualExpenditure'],						'2' => $data ['ICAEP'] . '%',						'3' => $data ['categoryActualExpenditure'] ,						'4' => $data ['categoryActualExpenditureProportion'] . '%'				),				9 => array (						'1' =>$data ['payment'],						'2' => $data ['invoicepaymentProportion'] . '%',						'3' => $data ['payment'] ,						'4' => $data ['paymentProportion'] . '%'				),				10 => array (						'participants' =>$data ['receiptTrainingDetail'] ['participants'],						'lectureCount' => $data ['lectureCount'] ,				),				11=>array(						'total'=>$data ['total'],						'totalProportion'=>$data ['totalProportion']				),		);		$data ['summaryJson'] =URLEncode(json_encode($summaryJson));		$data ['aiListJson'] =URLEncode(json_encode($data ['aiList']));		 		$data['inputDate']=date ( "Y-m-d H:i:s" );				$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrain", $data );	}		/**	 * 培训班借款	 */	function receiptTrainLoan() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();		Doo::loadModel ( 'verify' );		$verify = new verify ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		$data ['receiptMemu'] = 'expenses';		if ($showType == 'approval') {			$data ['receiptMemu'] = 'approvalExpenses';			// if ($receiptDetail ['status'] != 2)			// die ();		} elseif ($showType == 'implement') {			$data ['receiptMemu'] = 'implement';			// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))			// die ();		}		$data ['showType'] = $showType;				$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );		// 借款详情HTML		// 获得借款信息		$receiptLoanHtml = '';		if (! empty ( $receiptDetail ['trainLoanRid'] )) {									$receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );			foreach ($receiptLoanList as $key=>$value){				// 获得某费用单审批信息				$verifylist = $verify->getVerifyByRid ( $value ['rid'] );				Doo::loadClass ( 'receipt.func' );				$extendHtml = '';				$receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );						}								}				$data ['receiptLoanHtml'] = $receiptLoanHtml;		$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "LOAN";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrainLoan", $data );	}		/**	 * 培训班结算 ---开票	 */	function receiptTrainInvoice() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();		Doo::loadModel ( 'invoice' );		$invoice = new invoice ();		Doo::loadModel ( 'invoiceTraining' );		$invoiceTraining = new invoiceTraining ();		$receiptDetail = $receipt->getReceiptByRid ( $rid );		$data ['receiptMemu'] = 'expenses';		if ($showType == 'approval') {			$data ['receiptMemu'] = 'approvalExpenses';			// if ($receiptDetail ['status'] != 2)			// die ();		} elseif ($showType == 'implement') {			$data ['receiptMemu'] = 'implement';			// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))			// die ();		}		$data ['showType'] = $showType;		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				$invoiceList = $invoiceTrainingDetail = array ('invoiceTotalAmount'=>0,'invoiceArriveAmount'=>0);		if ($receiptDetail ['invoiceTrainId'] != 0) {			$invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );			$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );		}		//收款是否完成更新状态        //$RIC=$invoiceTrainingDetail['RIAmount']+$invoiceTrainingDetail['invoiceCompanyAmount'];		if ($invoiceTrainingDetail['invoiceTotalAmount']<=$invoiceTrainingDetail['invoiceArriveAmount']&&$receiptDetail['paidStatus']==0){            $receipt = new receipt ();            $itemData = array (                'rid' => $rid,                'paidStatus' => 1,            );            $receipt->setReceiptByCondition($itemData);        }		// print_r($invoiceList);		$data ['invoiceList'] = $invoiceList;		$data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;		$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "INVOICE";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrainInvoice", $data );	}		/**	 * 培训班结算	 */	function receiptTrainItem() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';        $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();		Doo::loadModel ( 'RItem' );		$RItem = new RItem ();		Doo::loadModel ( 'accountItem' );		$accountItem = new accountItem ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		$data ['receiptMemu'] = 'expenses';		if ($showType == 'approval') {			$data ['receiptMemu'] = 'approvalExpenses';			// if ($receiptDetail ['status'] != 2)			// die ();		} elseif ($showType == 'implement') {			$data ['receiptMemu'] = 'implement';			// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))			// die ();		}		$data ['showType'] = $showType;		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				$RItemList = $RItem->getRItemByRid ( $rid,$name );		$aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );				// print_r($RItemList);        $data ['name'] = $name;		$data ['RItemList'] = $RItemList;		$data ['aiList'] = $aiList;				$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "ITEM";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrainItem", $data );	}		/**	 * 培训班结算-讲师	 */	function receiptTrainLecturer() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();		Doo::loadModel ( 'RILecturer' );		$RILecturer = new RILecturer ();				Doo::loadModel ( 'lecturer' );		$lecturer = new lecturer ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		$data ['receiptMemu'] = 'expenses';		if ($showType == 'approval') {			$data ['receiptMemu'] = 'approvalExpenses';			// if ($receiptDetail ['status'] != 2)			// die ();		} elseif ($showType == 'implement') {			$data ['receiptMemu'] = 'implement';			// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6))			// die ();		}		$data ['showType'] = $showType;		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );				$lecturerList = $lecturer->getLecturerAll ();		$INSIDEhtml = $OUTSIDEhtml = '';		foreach ( $lecturerList as $key => $value ) {			if ($value ['ltype'] == 'INSIDE') {				$INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';			} elseif ($value ['ltype'] == 'OUTSIDE') {				$OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';			}		}		$data ['INSIDEhtml'] = $INSIDEhtml;		$data ['OUTSIDEhtml'] = $OUTSIDEhtml;		// print_r($RItemList);		$data ['RILecturerList'] = $RILecturerList;				$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "LECTURER";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrainLecturer", $data );	}		/**	 * 培训班结算编辑-协助	 */	function receiptTrainAssistEdi() {		$ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();		Doo::loadModel ( 'RAssist' );		$RAssist = new RAssist ();		Doo::loadModel ( 'staff' );		$staff = new staff ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))			die ();		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				$RAssistList = $RAssist->getRAssistByRid ( $rid );		$assistStaffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );				// print_r($RAssistList);		$data ['$assistStaffList'] = $assistStaffList;		$data ['RAssistList'] = $RAssistList;				$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "ASSIST";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['receiptMemu'] = 'saeaBorad';		$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrainAssistEdi", $data );	}		/**	 * 添加协助人	 */	function receiptTrainAssistAddDo() {		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";		$sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";				if (! empty ( $ridKey ) && ! empty ( $sidKey )) {			Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			Doo::loadModel ( 'RAssist' );			$RAssist = new RAssist ();						$rid = $XDeode->decode ( $ridKey );			$sid = $XDeode->decode ( $sidKey );			if (! is_numeric ( $rid ) || ! is_numeric ( $sid )) {				die ( 'illegal request' );			}						$RAssist->rid = $rid;			$RAssist->sid = $sid;			$RAssist->date = date ( "Y-m-d" );			$RAssist->insert ();						$XDeode = new XDeode ( 7 );			return '/receiptTrainAssistEdi/' . $XDeode->encode ( $rid ) . '.html';		} else			die ( 'illegal request' );	}		/**	 * 删除协作人	 */	function receiptTrainAssistDelDo() {		$aidKey = isset ( $this->params ['aidKey'] ) ? $this->params ['aidKey'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$aid = $XDeode->decode ( $aidKey );		$rid = $XDeode->decode ( $ridKey );		if (! is_numeric ( $aid )) {			die ( 'illegal request--id' );		}				Doo::loadModel ( 'RAssist' );		$RAssist = new RAssist ();				$RAssist->delete ( array (				'where' => 'aid=' . $aid 		) );		$XDeode = new XDeode ( 7 );		return '/receiptTrainAssistEdi/' . $XDeode->encode ( $rid ) . '.html';	}		/*	 * 培训班结算-审批	 */	function receiptTrainApproval() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();				Doo::loadModel ( 'lecturer' );		$lecturer = new lecturer ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		// 是否有权访问		if ($showType != 'info') {			if (! in_array ( $this->staff [0] ['sid'], $this->verifyId )) {				die ( 'illegal request-verifyId' );			}		}				// 用户的访问页面类型		$data ['receiptMemu'] = 'expenses';		if ($showType == 'approval') {			$data ['receiptMemu'] = 'approvalExpenses';			// if ($receiptDetail ['status'] != 2)			// die ();		}		$data ['showType'] = $showType;				$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				// 获取审批日志		Doo::loadModel ( 'receiptLog' );		$receiptLog = new receiptLog ();				// echo $rid;		$rlList = $receiptLog->find ( array (				'where' => 'rid=' . $rid,				'asc' => 'rlid',				'asArray' => true 		) );				$data ['rlList'] = $rlList;				// 审批组		Doo::loadModel ( 'verify' );		$verify = new verify ();		$verifyList = $verify->getOne ( array (				'where' => 'vid=' . $receiptDetail ['verify'],				'asArray' => true 		) );		$verifyList = json_decode ( $verifyList ['staff'], true );		$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );		$verifyList = $this->fnGetReceiptApprovalProcess ( $verifyList, $verifyStaff );		$data ['verifyList'] = $verifyList ['verifyList'];		// print_r($verifyList['verifyList']);				$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "APPROVAL";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;		if ($showType == 'approval') {			$this->render ( "/receipt/receiptTrainApproval", $data );		} else {			$this->render ( "/receipt/receiptTrainApprovalInfo", $data );		}	}		/**	 * 培训班结算--执行	 */	function receiptTrainImplement() {		$showType = isset ( $this->params ['showType'] ) ? $this->params ['showType'] : 'implement';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();				Doo::loadModel ( 'lecturer' );		$lecturer = new lecturer ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		// 是否有权访问				if (! in_array ( $this->staff [0] ['sid'], $this->executeId )) {			die ( 'illegal request' );		}				// 用户的访问页面类型				$data ['receiptMemu'] = 'implement';		// if (! ($receiptDetail ['status'] == 1 || $receiptDetail ['status'] == 6)) {		// die ();		// }		$data ['showType'] = $showType;				$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				// 获取审批日志		Doo::loadModel ( 'receiptLog' );		$receiptLog = new receiptLog ();				// echo $rid;		$rlList = $receiptLog->find ( array (				'where' => 'rid=' . $rid,				'asc' => 'rlid',				'asArray' => true 		) );				$data ['rlList'] = $rlList;				// 审批组		Doo::loadModel ( 'verify' );		$verify = new verify ();		$verifyList = $verify->getOne ( array (				'where' => 'vid=' . $receiptDetail ['verify'],				'asArray' => true 		) );		$verifyList = json_decode ( $verifyList ['staff'], true );		$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );		$verifyList = $this->fnGetReceiptApprovalProcess ( $verifyList, $verifyStaff );		$data ['verifyList'] = $verifyList ['verifyList'];		// print_r($verifyList['verifyList']);				// 执行组		$executeList = json_decode ( $receiptDetail ['executeCopy'], true );		$executeStaff = array ();		if (! empty ( $receiptDetail ['executeStaff'] )) {			$executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );		}				$button2 = 0;		if (isset ( $executeList )) {			foreach ( $executeList as $op => $lo ) {								$executeList [$op] ['date'] = "";				$executeList [$op] ['opinion'] = "";				$executeList [$op] ['status'] = "";								foreach ( $executeStaff as $m => $u ) {					if ($lo [0] == $m) {						$executeList [$op] ['date'] = $u ['date'];						$executeList [$op] ['opinion'] = $u ['opinion'];						$executeList [$op] ['status'] = $u ['status'];						break;					}				}								if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {					$button2 = 1;					$executeList [$op] ['status'] = 4;				}			}		}				//执行人是否是最后一位		$executeCopy = json_decode ( $receiptDetail ['executeCopy'], true );		$executeStaff = json_decode ( $receiptDetail ['executeStaff'], true );		$executePrimary=count($executeCopy)-1;		$lastOne=true;		if($executePrimary!=count($executeStaff)){			$lastOne=false;		}		$data['lastOne']=$lastOne;		// 是否写入过流水		$accountType = 0;		if ($receiptDetail ['Rtype'] == 3) {			$accountType = 12;		}		Doo::loadModel ( 'wasteBook' );		$wasteBook = new wasteBook ();		$wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptDetail ['rid'] );		$data ['wbDetail'] = $wbDetail;						$data ['button2'] = $button2;		$data ['executeList'] = $executeList;				$data ['receiptTrainingDetail'] = $receiptTrainingDetail;		$data ['receiptDetail'] = $receiptDetail;		$data ['trainEdiType'] = "implement";		$data ['ridKey'] = $ridKey;		$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptTrainImplement", $data );	}	function receiptTrainApprovalDo() {		$opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";		$statusKey = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : '';		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';				if (! empty ( $ridKey ) && ! empty ( $statusKey )) {						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			$rid = $XDeode->decode ( $ridKey );						if ($statusKey == 'AGREE') {				$status = 1;			} elseif ($statusKey == 'END') {				$status = 3;			} else {				die ( 'illegal request--status' );			}						Doo::loadModel ( "verify" );			$verify = new verify ();			Doo::loadModel ( "receiptDetail" );			$receiptDetailObj = new receiptDetail ();			Doo::loadModel ( "itemStatistics" );			Doo::loadModel ( "statistics" );			$statistics = new statistics ();			$itemStatistics = new itemStatistics ();						Doo::loadModel ( "receipt" );			$receipt = new receipt ();						$receiptDetail = $receipt->getOne ( array (					'where' => 'rid=' . $rid . ' and status=2 ',					'asArray' => true 			) );						//计算汇款金额			// 收入合计			Doo::loadModel ( 'invoiceTraining' );			$invoiceTraining = new invoiceTraining ();			$invoiceTrainingDetail = array (					'invoiceArriveAmount' => '0.00',					'RIAmount' => '0.00',					'invoiceTotalAmount' => '0.00',					'invoiceCompanyAmount' => '0.00',					'invoiceArriveAmountM'=>'0.00',					'invoiceCompanyAmountM'=>'0.00'			);			if ($receiptDetail ['invoiceTrainId'] != 0) {				$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail['invoiceTrainId'] );			}			$invoiceArriveAmount = $RIAmount = 0;			if (! empty ( $invoiceTrainingDetail )) {				$invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];				$RIAmount = $invoiceTrainingDetail ['RIAmount'];			}						// 备用金			$sum = 0;			if (! empty ( $receiptDetail ['trainLoanRid'] )) {								$receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );				foreach ($receiptLoanList as $key=>$value){					$sum+=$value['sum'];				}								// 				$receiptLoanDetailBak = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );// 				$sum = $receiptLoanDetailBak ['sum'];			}						// 支出项金额详情			// 项目金额合计			Doo::loadModel ( 'RItem' );			$RItem = new RItem ();			Doo::loadModel ( 'accountItem' );			$accountItem = new accountItem ();			// 讲师获得			Doo::loadModel ( 'RILecturer' );			$RILecturer = new RILecturer ();			$RItemList = $RItem->getRItemByRid ( $rid );			$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );			// 支出项金额详情			$aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );			$categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];						$payment = $sum + $RIAmount - $categoryActualExpenditure;																		$nslist = explode ( ',', $receiptDetail ['nowStaff'] );			$nsflag = true;			foreach ( $nslist as $value ) {				if ($value == $this->staff ['0'] ['sid']) {					$nsflag = false;					break;				}			}			// 该用户是否能审批			if (empty ( $receiptDetail ) || $nsflag)				return "/approvalExpenses/pendApproval";						$verifyDetail = $verify->getOne ( array (					'where' => ' vid =' . $receiptDetail ['verify'],					'asArray' => true 			) );			$verifyString = $verifyDetail ['staff'];			$verifyDetail = json_decode ( $verifyDetail ['staff'], true );			$verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );						if (empty ( $opinion )) {				if ($status == 3)					$opinion = "终止";				else					$opinion = "同意支付";			}						$nowStaff = 0;			$nowStaffList = array ();						if (empty ( $verifyStaff )) {								// 还需加入是否已经进入角色审批				if ($verifyDetail [0] [1] == 'ROLE') {										$vStaffString = json_decode ( $verifyDetail [0] [3] );										foreach ( $vStaffString as $key => $value ) {						$staffK = explode ( "_", $value );						if ($staffK [0] != $this->staff [0] ['sid'])							array_push ( $nowStaffList, $staffK [0] );					}										// print_r($verifyDetail);					// die;					if (! empty ( $nowStaffList )) {						$nowStaff = implode ( ',', $nowStaffList );						$verifyStaff = array (								$this->staff [0] ['sid'] . "_R" => array (										'date' => date ( 'Y-m-d' ),										'opinion' => $opinion,										'status' => $status,										'nextStaff' => $verifyDetail [0] [0],										'ROLE' => 1 								) 						);					} else {						$nowStaff = $verifyDetail [1] [0];						$verifyStaff = array (								$this->staff [0] ['sid'] . "_R" => array (										'date' => date ( 'Y-m-d' ),										'opinion' => $opinion,										'status' => $status,										'nextStaff' => $verifyDetail [1] [0] 								) 						);					}				} else {										if ($verifyDetail [1] [1] == 'ROLE') {						$vStaffString = json_decode ( $verifyDetail [1] [3] );						// echo "dd";						foreach ( $vStaffString as $key => $value ) {							$staffK = explode ( "_", $value );							array_push ( $nowStaffList, $staffK [0] );						}						$nowStaff = implode ( ',', $nowStaffList );						$verifyStaff = array (								$this->staff [0] ['sid'] => array (										'date' => date ( 'Y-m-d' ),										'opinion' => $opinion,										'status' => $status,										'nextStaff' => $verifyDetail [1] [0],										'ROLE' => 1 								) 						);					} else {						$nowStaff = $verifyDetail [1] [0];						$verifyStaff = array (								$this->staff [0] ['sid'] => array (										'date' => date ( 'Y-m-d' ),										'opinion' => $opinion,										'status' => $status,										'nextStaff' => $verifyDetail [1] [0] 								) 						);					}				}								if ($status == 3)					$verifyStaff = array (							'final' => $status,							$this->staff [0] ['sid'] => array (									'date' => date ( 'Y-m-d' ),									'opinion' => $opinion,									'status' => $status 							) 					);								$vStaffString = json_encode ( $verifyStaff );				$receipt->nowStaff = $nowStaff;				$receipt->verifyStaff = $vStaffString;			} else {				$VS = end ( $verifyStaff );								// 非角色审批				if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {					$nextStaff = 0;					$roleSTF = false;					foreach ( $verifyDetail as $key => $value ) {						if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {							if (isset ( $verifyDetail [$key + 1] )) {								$nextStaff = $verifyDetail [$key + 1] [0];								if ($verifyDetail [$key + 1] [1] == 'ROLE')									$roleSTF = true;							}							break;						}					}										if (! $roleSTF) {						$nowStaff = $nextStaff;						$verifyStaff [$this->staff [0] ['sid']] = array (								'date' => date ( 'Y-m-d' ),								'opinion' => $opinion,								'status' => $status,								'nextStaff' => $nextStaff 						);					} else {						// 获取角色下的所有用户ID						$nowStaffList = array ();						foreach ( $verifyDetail as $vfk ) {							if ($vfk [1] == 'ROLE') {								$vStaffString = json_decode ( $vfk [3] );								foreach ( $vStaffString as $key => $value ) {									$staffK = explode ( "_", $value );									array_push ( $nowStaffList, $staffK [0] );								}							}						}												$nowStaff = implode ( ',', $nowStaffList );						$verifyStaff [$this->staff [0] ['sid']] = array (								'date' => date ( 'Y-m-d' ),								'opinion' => $opinion,								'status' => $status,								'nextStaff' => $nextStaff,								'ROLE' => 0 						);					}										if ($status == 3) {						$verifyStaff ['final'] = $status;						$verifyStaff [$this->staff [0] ['sid']] = array (								'date' => date ( 'Y-m-d' ),								'opinion' => $opinion,								'status' => $status 						);					}					$vStaffString = json_encode ( $verifyStaff );					$receipt->nowStaff = $nowStaff;					$receipt->verifyStaff = $vStaffString;				}								// 角色审批				if (isset ( $VS ['ROLE'] )) {										// 找出角色人 当前审批角色组					$verifyJSStaff = array ();					$nowStaffList2 = array ();					foreach ( $verifyDetail as $key => $value ) {						if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {							$verifyJSStaff = json_decode ( $value [3] );							foreach ( $verifyJSStaff as $m ) {								$staffK = explode ( "_", $m );								array_push ( $nowStaffList2, $staffK [0] );							}							// print_r($nowStaffList2);						}					}										$RoleVerifyStaff = array ();					foreach ( $verifyStaff as $key => $value ) {						if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {							foreach ( $nowStaffList2 as $m ) {								if ($key == $m . "_R")									$RoleVerifyStaff [$key] = $value;							}						}					}										$jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;					if ($jsCount == count ( $RoleVerifyStaff )) { // 或者					                                              // 下一个审批人ID						$nextStaff = 0;						$falg = false;						foreach ( $verifyDetail as $key => $value ) {							if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {																if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {									$falg = true;									$vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );									$nowStaffList = array ();									foreach ( $vStaffString as $v ) {										$staffK = explode ( "_", $v );										array_push ( $nowStaffList, $staffK [0] );									}									$nowStaff = implode ( ',', $nowStaffList );																		$nextStaff = $verifyDetail [$key + 1] [0];								} elseif (isset ( $verifyDetail [$key + 1] )) {									$nextStaff = $verifyDetail [$key + 1] [0];									$nowStaff = $nextStaff;								} else									$nowStaff = '';								break;							}						}												if ($falg)							$verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (									'date' => date ( 'Y-m-d' ),									'opinion' => $opinion,									'status' => $status,									'nextStaff' => $nextStaff,									'ROLE' => 1 							);						else							$verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (									'date' => date ( 'Y-m-d' ),									'opinion' => $opinion,									'status' => $status,									'nextStaff' => $nextStaff 							);												// print_r($verifyStaff);						// echo $nowStaff;die;					} else { // 进入下一个角色或者审批人					         						// echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);					         //						$nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );												$verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (								'date' => date ( 'Y-m-d' ),								'opinion' => $opinion,								'status' => $status,								'nextStaff' => $VS ['nextStaff'],								'ROLE' => 1 						);						// print_r($verifyStaff);						// die;					}					if ($status == 3) {						$verifyStaff ['final'] = $status;						$verifyStaff [$this->staff [0] ['sid']] = array (								'date' => date ( 'Y-m-d' ),								'opinion' => $opinion,								'status' => $status 						);					}					$vStaffString = json_encode ( $verifyStaff );					$receipt->verifyStaff = $vStaffString;					$receipt->nowStaff = $nowStaff;				}				// print_r($verifyStaff);die;			}			// print_r($verifyDetail);			$roleKey = 0;			$roleId = 0;			$verifyDetailCopy = array ();			foreach ( $verifyDetail as $k => $v ) {				if ($v [1] == 'ROLE') {					$roleId = $v [0];					$roleVerify = json_decode ( $v [3], true );					$roleKey = $k;					$roleArray = array ();					foreach ( $roleVerify as $o => $p ) {						$staffID = explode ( '_', $p );						$exp = array (								0 => $staffID [0],								1 => $staffID [1] 						);						array_push ( $roleArray, $exp );					}					$verifyDetailCopy [$v [0]] = $roleArray;				}			}			// print_r($verifyDetail);			foreach ( $verifyDetailCopy as $k => $v ) {				foreach ( $verifyDetail as $m => $n ) {					if ($n [0] == $k) {						array_splice ( $verifyDetail, $m, 1, $v );					}				}			}						Doo::loadModel ( "receiptLog" );			$receiptLog = new receiptLog ();			// 审批日志			if (! isset ( $verifyStaff ['final'] )) {								if (! empty ( $roleId )) {					Doo::loadModel ( "role" );					$role = new role ();					$roleInfo = $role->getOne ( array (							'where' => 'rid=' . $roleId,							'asArray' => true 					) );										$receiptLog->rolename = $roleInfo ['name'];				}								$receiptLog->username = $this->staff [0] ['username'];				$receiptLog->uid = $this->staff [0] ['sid'];				$receiptLog->date = date ( "Y-m-d" );				$receiptLog->opinion = $opinion;				$receiptLog->img = $this->staff [0] ['avatar'];				$receiptLog->status = 1;				$receiptLog->rid = $rid;				$receiptLog->insert ();			}						if (isset ( $verifyStaff ['final'] )) { // rDetail				$receipt->verifyBreakup = $verifyString;				$receipt->status = 3;				$receiptDetailObj->status = 3;				$receiptDetailObj->update ( array (						'where' => 'rid=' . $rid 				) );								if (! empty ( $roleId )) {					Doo::loadModel ( "role" );					$role = new role ();					$roleInfo = $role->getOne ( array (							'where' => 'rid=' . $roleId,							'asArray' => true 					) );										$receiptLog->rolename = $roleInfo ['name'];				}								$receiptLog->username = $this->staff [0] ['username'];				$receiptLog->uid = $this->staff [0] ['sid'];				$receiptLog->date = date ( "Y-m-d" );				$receiptLog->opinion = $opinion;				$receiptLog->img = $this->staff [0] ['avatar'];				$receiptLog->status = 3;				$receiptLog->rid = $rid;				$receiptLog->insert ();								// 微信企业号通知				// $this->setWXMsg ( $rid, 3 );			} elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量				$receipt->status = 1;				$reviseSum = 0;				$receipt->verifyBreakup = $verifyString;								$receiptDetailObj = new receiptDetail ();				$receiptDetailObj->status = 1;				$receiptDetailObj->pastDate = date ( "Y-m-d" );				$receiptDetailObj->update ( array (						'where' => 'rid=' . $rid 				) );								$dateArray = explode ( "-", $receiptDetail ['date'] );				$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];				$stat = $statistics->getOne ( array (						'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,						'asArray' => true 				) );				if (empty ( $stat )) {					$statistics->date = $receiptDetail ['date'];					$statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];					$statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];					$statistics->agPrice = $receiptDetail ['sum'];					$statistics->rePrice = $reviseSum;					$statistics->insert ();				} else {					$statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];					$statistics->rePrice = $stat ['rePrice'] + $reviseSum;					$statistics->update ( array (							'where' => 'sid=' . $stat ['sid'] 					) );				}								$dateArray = explode ( "-", $receiptDetail ['date'] );				$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];				$accountItem = json_decode ( $receiptDetail ['accountItem'], true );				foreach ( $accountItem ['cSum'] as $key => $value ) {					if ($key == "trainSum") {						$iStatistics = $itemStatistics->getOne ( array (								'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,								'asArray' => true 						) );						if (empty ( $iStatistics )) {							$itemStatistics->cid = $receiptDetail ['cid'];							$itemStatistics->staff = $receiptDetail ['staff'];							$itemStatistics->price = $receiptDetail ['sum'];							$itemStatistics->itemCategory = $this->TRAIN;							$itemStatistics->date = $receiptDetail ['date'];							$itemStatistics->insert ();						} else {							if (! empty ( $value )) {								$itemStatistics->price = $receiptDetail ['sum'] + $iStatistics ['price'];								$itemStatistics->update ( array (										'where' => 'sid=' . $iStatistics ['sid'] 								) );							}						}					}				}				$receipt->pastDate = date ( "Y-m-d" );								// 微信企业号通知				// $this->setWXMsg ( $rid, 1 );			}						//汇款金额			$receipt->amount=$payment;						$receipt->update ( array (					'where' => ' rid = ' . $rid 			) );		}		return "/approvalExpenses/pendApproval";	}		/**	 * 培训班结算--撤回	 */	function receiptTrainApprovalBackDo() {		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';		$opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";				if (! empty ( $ridKey )) {						Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			$rid = $XDeode->decode ( $ridKey );						// 操作记录			Doo::loadModel ( "receipt" );			$receipt = new receipt ();			Doo::loadModel ( "receiptLog" );			$receiptLog = new receiptLog ();			Doo::loadModel ( "verify" );			$verify = new verify ();						$receiptInfo = $receipt->getOne ( array (					'where' => 'rid=' . $rid . ' and status=2',					'asArray' => true 			) );						if (empty ( $receiptInfo )) {				echo json_encode ( array (						'status' => 2 				) );				die ();			}						$vr = $verify->getOne ( array (					'where' => 'vid=' . $receiptInfo ['verify'],					'asArray' => true 			) );						$jd = json_decode ( $vr ['staff'] );			$roleId = 0;						foreach ( $jd as $key => $value ) {				if ($value [1] == 'ROLE') {					$pos = strpos ( $value [3], $this->staff [0] ['sid'] );					if ($pos !== false) {						$roleId = $value [0];					}				}			}			// 审批日志			// echo $roleId;die;			if (! empty ( $roleId )) {				Doo::loadModel ( "role" );				$role = new role ();				$roleInfo = $role->getOne ( array (						'where' => 'rid=' . $roleId,						'asArray' => true 				) );								$receiptLog->rolename = $roleInfo ['name'];			}						$receiptLog->username = $this->staff [0] ['username'];			$receiptLog->uid = $this->staff [0] ['sid'];			$receiptLog->date = date ( "Y-m-d" );			$receiptLog->opinion = $opinion;			$receiptLog->img = $this->staff [0] ['avatar'];			$receiptLog->status = 4;			$receiptLog->rid = $rid;			$receiptLog->insert ();						$receipt->status = 4;			$receipt->update ( array (					'where' => 'rid=' . $rid 			) );						// 微信企业号通知			$this->setWXMsg ( $rid, 2 );						echo json_encode ( array (					'status' => 1 			) );			die ();		}		echo json_encode ( array (				'status' => 2 		) );		die ();	}		function receiptTrainItemEdiDo(){		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";		$riidKey = $this->get_args ( 'riidKey' ) ? $this->get_args ( 'riidKey' ) : "";				// 支出项信息		$item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";		$price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";		$inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";		$describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";				$payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$rid = $XDeode->decode ( $ridKey );		$riid = $XDeode->decode ( $riidKey );		if (! is_numeric ( $rid ) || ! is_numeric ( $riid )) {			die ( 'illegal request--id' );		}				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'RItem' );		$RItem = new RItem ();		Doo::loadModel ( 'receiptDetail' );						$rDetail = $receipt->getReceiptByRid ( $rid );		if (! ($rDetail ['status'] == 5 || $rDetail ['status'] == 4 || $rDetail ['status'] == 2)) {			die ( 'illegal request-status' );		}				$detail = $RItem->getRItemByRiid ( $riid );		if (empty ( $detail )) {			die ( 'illegal request-dataError' );		}		//创建人可以删除协助人        if(!($rDetail['staff']==$this->staff [0] ['sid'])){		if (! ($this->staff [0] ['sid'] == $detail ['createrId'] || $this->staff [0] ['username'] == $detail ['creater'])) {			die ( 'illegal request-sidError' );		}        }		if ( ! empty ( $item ) &&  is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {						//--------------------移除支出信息						$this->_receiptTrainItemDel($RItem, $rDetail, $riid, $rid, $detail, $receipt);						//---------------------添加支出信息						$receiptDetail = new receiptDetail ();			$receipt = new receipt ();			$RItem = new RItem ();						$order = array (					"\r\n",					"\n",					"\r"			);			$replace = '<br/>';			$describe = str_replace ( $order, $replace, $describe );			$itemData = array (					'rid' => $rid,					'item' => $item,					'price' => $price,								'date' => $date,					'inputer' => $inputer,			        'identifying'=>$detail['identifying'],					'describe' => $describe,					'creater' => $this->staff['0']['username'],					'createrId' => $this->staff['0']['sid'],					'creatDate' => date ( "Y-m-d H:i:s" )			);			if($payType=='company'){				$itemData += array (						'payType' => 1				);			}			$RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);			$XDeode = new XDeode ( 7 );			if($payType=='company'){				return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';			}else{				return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';			}		}else			die ( 'illegal request-dataError' );			}		//移除培训班结算-支出列	private function _receiptTrainItemDel($RItem,$rDetail,$riid,$rid,$detail,$receipt){		$RItem->delete ( array (				'where' => 'riid=' . $riid		) );				// 更新费用合计金额		$rInfo = $receipt->getReceiptByRid ( $rid );		$receipt = new receipt ();		$receipt->sum = $rDetail ['sum'] - $detail ['price'];		$receipt->update ( array (				'where' => 'rid=' . $rid		) );		Doo::loadModel ( 'receiptDetail' );		$receiptDetail = new receiptDetail ();		$rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $detail ['item'], '培训班费用' );		$receiptDetail = new receiptDetail ();		$rdInfo ['price'] -= $detail ['price'];		$receiptDetail->price = $rdInfo ['price'];		$receiptDetail->update ( array (				'where' => 'rid=' . $rid . ' and item like "' . $detail ['item'] . '" and itemCategory like "培训班费用"'		) );				//汇总金额--提交审批之后有 支出项时 需要更新汇总		if($detail['payType']==1){			Doo::loadModel ( "statistics" );			$statistics = new statistics ();					$dateArray = explode ( "-", $rInfo ['date'] );			$dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];					$stat = $statistics->getOne ( array (					'where' => 'staff=' . $rInfo ['staff'] . $dateCondition,					'asArray' => true			) );			if (!empty($stat)){				$statistics->rePrice = $stat ['rePrice'] - $detail['price'];									$statistics->update ( array (						'where' => 'sid=' . $stat ['sid']				) );			}		}			}		/**	 * 移除培训班结算-支出列	 */	function receiptTrainItemDelDo() {		$riidKey = isset ( $this->params ['riidKey'] ) ? $this->params ['riidKey'] : '';		$ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';				Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$rid = $XDeode->decode ( $ridKey );		$riid = $XDeode->decode ( $riidKey );		if (! is_numeric ( $rid ) || ! is_numeric ( $riid )) {			die ( 'illegal request--id' );		}				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'RItem' );		$RItem = new RItem ();				$rDetail = $receipt->getReceiptByRid ( $rid );		if (! ($rDetail ['status'] == 5 || $rDetail ['status'] == 4 || $rDetail ['status'] == 2)) {			die ( 'illegal request-status' );		}				$detail = $RItem->getRItemByRiid ( $riid );		if (empty ( $detail )) {			die ( 'illegal request-dataError' );		}				if (! ($this->staff [0] ['sid'] == $detail ['createrId'] || $this->staff [0] ['username'] == $detail ['creater'])) {			die ( 'illegal request-sidError' );		}				$this->_receiptTrainItemDel($RItem, $rDetail, $riid, $rid, $detail, $receipt);						$XDeode = new XDeode ( 7 );		if ($rDetail ['status'] == 2) {			return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';		} else {			return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';		}	}		/**	 * 生成对冲收款	 */	function invoiceReceivablesStrikeAddDo() {		$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';				if (empty ( $iidKey ) || empty ( $ridKey )) {			die ( 'illegal request--idKey' );		}		Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$XDeode7 = new XDeode ( 7 );		$iid = $XDeode->decode ( $iidKey );		$rid = $XDeode7->decode ( $ridKey );				Doo::loadModel ( 'invoiceReceivables' );		$invoiceReceivables = new invoiceReceivables ();		Doo::loadModel ( 'invoice' );		$invoice = new invoice ();		Doo::loadModel ( 'invoiceTraining' );		$invoiceTraining = new invoiceTraining ();		Doo::loadModel ( 'invoiceOperationLog' );		$invoiceOperationLog = new invoiceOperationLog ();		Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();				$detail = $invoice->getInvoiceByIid ( $iid );		$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $detail ['trainId'] );				$receiptDetail = $receipt->getReceiptByRid ( $rid );		$receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );				if (empty ( $invoiceTrainingDetail ) || empty ( $detail ) || $detail ['untreadStatus'] == 3 || ! empty ( $detail ['irid'] )) {			die ( 'illegal request--trainId-status-irid' );		}		// 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],		// 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],		// 添加收款		$item = array (				'iid' => $detail ['iid'],				'bindStatus' => 1,				'bindPrice' => $detail ['invoicePrice'],				'inputStaff' => $this->staff [0] ['username'],				'source' => 2,				'bindDate' => date ( "Y-m-d" ),				'confirmTime' => date ( "Y-m-d H:i:s" ),								'receivablesPrice' => $detail ['invoicePrice'],				'OriginalPrice' => $detail ['invoicePrice'],				'receivablesMessage' => $receiptTrainingDetail ['trainName'] . '冲账',				'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),				'receivablesBank' => '财务录入',				'receivablesDate' => date ( "Y-m-d" ),				'inputStaff' => $this->staff [0] ['username'],				'date' => date ( "Y-m-d" ),				'receivablesCategory' => $detail ['cid'] . ":" . $detail ['categoryName'],				'receivablesStaff' => $detail ['sid'] . "-" . $detail ['userName'] 		);		$irid = $invoiceReceivables->addInvoiceReceivables ( $item );		// 更新发票绑定收款		$iridString = "";		if (empty ( $detail ['irid'] ))			$iridString = $irid;		else			$iridString = $detail ['irid'] . ',' . $irid;		$item = array (				'iid' => $detail ['iid'],				'irid' => $iridString,				'untreadStatus' => 3,				'bindTime' => date ( "Y-m-d H:i:s" ) 		);		$invoice->setInvoiceByCondition ( $item );				// 在是对冲收款 确保已收款不被删除		// Doo::loadModel ( 'RIExtend' );		// $RIExtend = new RIExtend ();				// 操作日志		$item = array (				'date' => date ( "Y-m-d H:i:s" ),				'operation' => "收款" . $invoiceTrainingDetail ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],				'status' => 8,				'img' => $this->staff [0] ['avatar'],				'username' => $this->staff [0] ['username'],				'uid' => $this->staff [0] ['sid'],				'category' => $this->staff [0] ['category'],				'iid' => $detail ['iid'] 		);		$invoiceOperationLog->setInvoiceOperationLog ( $item );		// 是否加入统计--冲账不需要加入汇总				return '/receiptTrainInvoice/approval/' . $ridKey . '.html';	}		/**	 * 培训班结算--执行	 */	function receiptTrainImplementDo() {		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';		$implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";				if (! empty ( $ridKey )) {			Doo::loadModel ( 'receipt' );			$receipt = new receipt ();			Doo::loadModel ( 'wasteBook' );			$wasteBook = new wasteBook ();			Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );						$rid = $XDeode->decode ( $ridKey );						$rinfo = $receipt->getReceiptByRid ( $rid );			if (empty ( $rinfo )) {				die ( 'illegal request--rid' );			}						$accountType = '';			if ($rinfo ['Rtype'] == 1) {				if ($rinfo ['loanRid'] != 0)					$accountType = 2;				else					$accountType = 1;			} elseif ($rinfo ['Rtype'] == 2) {				$accountType = 4;			} elseif ($rinfo ['Rtype'] == 0) {				$accountType = 3;			} elseif ($rinfo ['Rtype'] == 3) {				$accountType = 12;			}						if (empty ( $accountType ))				die ( 'illegal request' );						$executeCopy = json_decode ( $rinfo ['executeCopy'], true );			$executeStaff = json_decode ( $rinfo ['executeStaff'], true );						if (empty ( $executeStaff )) {								$executeStaff = array (						$this->staff [0] ['sid'] => array (								'date' => date ( 'Y-m-d' ),								'opinion' => $implementOpinions,								'status' => 1 						) 				);			} else {								$executeStaff [$this->staff [0] ['sid']] = array (						'date' => date ( 'Y-m-d' ),						'opinion' => $implementOpinions,						'status' => 1 				);			}						if (count ( $executeStaff ) == count ( $executeCopy )) {				// 费用执行没有				$wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rinfo ['rid'] );				if (empty ( $wbDetail )) {					die ( 'illegal request--wate' );				}								$receipt->executeStaff = json_encode ( $executeStaff );								$receipt->status = 8;				if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)					$receipt->status = 9;								if ($rinfo ['status'] == 6) {					$receipt->loanDate = date ( "Y-m-d" );				}								$receipt->executeDate = date ( "Y-m-d" );			} else {				$receipt->executeStaff = json_encode ( $executeStaff );			}						$receipt->update ( array (					'where' => 'rid=' . $rid 			) );			return '/hisImplement/train';		}		die ( 'illegal request-dataError' );	}		/**	 * 生成执行流水	 */	function receiptTrainImplementWateDo() {		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : '';		$bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";				$amountTrain = $this->get_args ( 'amount' )  ? $this->get_args ( 'amount' ) : '';		$expensesType = $this->get_args ( 'expensesType' ) ? $this->get_args ( 'expensesType' ) : "";				$inputDate = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : date ( "Y-m-d H:i:s" );		$remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : "";				$actionType = $this->get_args ( 'actionType' ) ? $this->get_args ( 'actionType' ) : "";		if (! empty ( $actionType )) {			if ($actionType != 'NOTRAIN')				die ( 'illegal request--errorActionType' );		}				if (! empty ( $ridKey )) {			Doo::loadModel ( 'receipt' );			$receipt = new receipt ();			Doo::loadModel ( 'wasteBook' );			$wasteBook = new wasteBook ();			Doo::loadClass ( 'XDeode' );			$XDeode = new XDeode ( 5 );			$rid = $XDeode->decode ( $ridKey );						$rinfo = $receipt->getReceiptByRid ( $rid );			$amount=$rinfo['amount'];						if (empty ( $rinfo )) {				die ( 'illegal request--noData' );			}			$accountType = '';			if ($rinfo ['Rtype'] == 0) {				$accountType = 3;				$expensesType='EXPENDITURE';			} elseif ($rinfo ['Rtype'] == 1) {				if (! empty ( $rinfo ['accountItem'] )){					$accountType = 2;					if ($amount>=0){						$expensesType='EXPENDITURE';					}else{						$expensesType='INCOME';					}				}else{					$accountType = 1;					$expensesType='EXPENDITURE';				}			} elseif ($rinfo ['Rtype'] == 2) {				$accountType = 4;				$expensesType='EXPENDITURE';			} elseif ($rinfo ['Rtype'] == 3) {//培训班结算 收支类型				$accountType = 12;                Doo::loadClass ( 'authcode.func' );                $amountTrain=authcode($amountTrain);                if(!is_numeric ( $amountTrain )) {                    die('illegal request--payType');                }				if($amountTrain>=0){					$expensesType='INCOME';				}else{					$expensesType='EXPENDITURE';				}				$amount=$amountTrain;			}						if (empty ( $accountType )) {				die ( 'illegal request--accountType' );			}			if (empty ( $bank ) || (! ($bank == 'CGBDeposit' || $bank == 'ICBCDeposit' || $bank == 'HUADeposit' || $bank == 'PersonalDeposit'))) {				die ( 'illegal request--Bank' );			}						if($accountType==12){			$receipt->amount = $amount;			$receipt->update ( array (					'where' => 'rid=' . $rid 			) );			}			/*			// 更新借款汇款金额			if ($accountType == 1) {				Doo::loadModel ( 'loanReceipt' );				$loanReceipt = new loanReceipt ();				$loanReceipt->amount = $amount;								$loanReceipt->update ( array (						'where' => ' rid = ' . $rinfo ['loanRid'] 				) );			}*/									//汇款金额正数			$amount=abs($amount);			// $accountType = 12;			$accountBank = $bank;			if ($expensesType == "INCOME") {				$expensesTypeWaste = 1;				$accountPriceShow = $accountPrice = $amount;			} elseif ($expensesType == "EXPENDITURE") {				$expensesTypeWaste = 2;				$accountPriceShow = $amount;				$accountPrice = - $amount;			} else {				die ( 'illegal request--expensesType' );			}						// 公司流水记录			$abDetail = $wasteBook->getAccountBookByAid ( $expensesTypeWaste, $accountType, $rid );			// 银行			if (empty ( $abDetail )) {				$item = array (						'dataID' => $rid,						'expensesType' => $expensesTypeWaste,						'accountType' => $accountType,						'accountPriceShow' => $accountPriceShow,						'accountPrice' => $accountPrice,						'accountBank' => $accountBank,												'category' => $rinfo ['category'] [0] ['title'],						'cid' => $rinfo ['category'] [0] ['cid'],						'name' => $rinfo ['staffDetail'] ['username'],						'sid' => $rinfo ['staffDetail'] ['sid'],						'inputDate' => $inputDate,						'remarks'=>$remarks				);				$wasteBook->setAccountBookStatistics ( $item );			}		}				if (empty ( $actionType )) {			$XDeode = new XDeode ( 7 );			return '/receiptTrain/implement/' . $XDeode->encode ( $rid ) . '.html?trainEdiType=COLLECT';		} elseif ($actionType == 'NOTRAIN') {			$XDeode = new XDeode ( 5 );			if ($rinfo['Rtype']==1){				return "/implement/loan/" . $XDeode->encode ( $rid ) . ".html";			}elseif($rinfo['Rtype']==0){				return "/implement/receipt/" . $XDeode->encode ( $rid ) . ".html";			}elseif($rinfo['Rtype']==2){				return "/implement/public/" . $XDeode->encode ( $rid ) . ".html";			}					}	}		/**	 * 费用流水	 */	function receiptWasteBook() {		Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		Doo::loadModel ( 'receipt' );		$receipt = new receipt ();				$receiptList = $receipt->getReceiptByWaste ();		foreach ($receiptList as $key=>$value){			$receiptList[$key]['balance']='';			if($value['Rtype']==1){				$receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];				$receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);			}elseif($value['Rtype']==3){				$payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);				$receiptList[$key]['payment']=$payment;				$receiptList[$key]['paymentABS']=abs($payment);			}			$receiptList[$key]['amountABS']=abs($value['amount']);		}						$data ['inputDate'] = date ( "Y-m-d H:i:s" );		$data ['receiptList'] = $receiptList;				$data ['memu'] = "receipt";		$data ['staff'] = $this->staff;				$data ['receiptMemu'] = 'receiptWasteBook';		$data ['verifyId'] = $this->verifyId;		$data ['executeId'] = $this->executeId;				$this->render ( "/receipt/receiptWasteBook", $data );	}		function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){		// 收入合计		Doo::loadModel ( 'invoiceTraining' );		$invoiceTraining = new invoiceTraining ();		Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		$invoiceTrainingDetail = array (				'invoiceArriveAmount' => '0.00',				'RIAmount' => '0.00',				'invoiceTotalAmount' => '0.00',				'invoiceCompanyAmount' => '0.00',				'invoiceArriveAmountM'=>'0.00',				'invoiceCompanyAmountM'=>'0.00'		);		if ($invoiceTrainId != 0) {			$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );		}		$invoiceArriveAmount = $RIAmount = 0;		if (! empty ( $invoiceTrainingDetail )) {			$invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];			$RIAmount = $invoiceTrainingDetail ['RIAmount'];		}					// 备用金		$sum = 0;		if (! empty ( $trainLoanRid )) {						$receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );			foreach ($receiptLoanList as $key=>$value){				$sum+=$value['sum'];			}			// 			$receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );// 			$sum = $receiptLoanDetailBak ['sum'];		}					// 支出项金额详情		// 项目金额合计		Doo::loadModel ( 'RItem' );		$RItem = new RItem ();		Doo::loadModel ( 'accountItem' );		$accountItem = new accountItem ();		// 讲师获得		Doo::loadModel ( 'RILecturer' );		$RILecturer = new RILecturer ();		$RItemList = $RItem->getRItemByRid ($rid );		$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );		// 支出项金额详情		$aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );		$categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];					$payment = $sum + $RIAmount - $categoryActualExpenditure;		return $payment;	}		/**	 * 费用流水新增	 */	function receiptWasteBookAddDo() {		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";		if (empty ( $ridKey )) {			die ( 'illegal request--ridKey' );		}				$receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : "";		$receivedRemarks = $this->get_args ( 'receivedRemarks' ) ? $this->get_args ( 'receivedRemarks' ) : "";		$receivedInputDate = $this->get_args ( 'receivedInputDate' ) ? $this->get_args ( 'receivedInputDate' ) : date ( "Y-m-d H:i:s" );		$amountTrain = $this->get_args ( 'paymentAuthCode' )  ? $this->get_args ( 'paymentAuthCode' ) : '';				if ( empty ( $receivedBank )) {			die ( 'illegal request--Bank' );		}						/*		$expensesType = $this->get_args ( 'expensesType' ) ? $this->get_args ( 'expensesType' ) : "";		$expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : "";		$expenditurePrice = $this->get_args ( 'expenditurePrice' ) ? $this->get_args ( 'expenditurePrice' ) : "";		$expenditureRemarks = $this->get_args ( 'expenditureRemarks' ) ? $this->get_args ( 'expenditureRemarks' ) : "";		$expenditureInputDate = $this->get_args ( 'expenditureInputDate' ) ? $this->get_args ( 'expenditureInputDate' ) : date ( "Y-m-d H:i:s" );		$receivedPrice = $this->get_args ( 'receivedPrice' ) ? $this->get_args ( 'receivedPrice' ) : "";				if (empty ( $expenditureBank ) || empty ( $receivedBank )) {			die ( 'illegal request--Bank' );		}        $expenditurePrice=str_replace(',','',$expenditurePrice);        $receivedPrice=str_replace(',','',$receivedPrice);        if ($expensesType == "INCOME") {            if(!is_numeric($receivedPrice)){                die ( 'illegal request--receivedPrice' );            }        } elseif ($expensesType == "EXPENDITURE") {            if(!is_numeric($expenditurePrice)){                die ( 'illegal request--expenditurePrice' );            }        }        */		Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 5 );		$rid = $XDeode->decode ( $ridKey );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();				$detail = $receipt->getReceiptByRid ( $rid );		if (empty ( $detail )) {			die ( 'illegal request--noData' );		}		$amount=$detail['amount'];				$accountType = '';		/*		if ($detail ['Rtype'] == 1) {			if (! empty ( $detail ['accountItem'] ))				$accountType = 2;			else				$accountType = 1;		} elseif ($detail ['Rtype'] == 2) {			$accountType = 4;		} elseif ($detail ['Rtype'] == 0) {			$accountType = 3;		} elseif ($detail ['Rtype'] == 3) {			$accountType = 12;		}		*/				if ($detail ['Rtype'] == 0) {			$accountType = 3;			$expensesType='EXPENDITURE';		} elseif ($detail ['Rtype'] == 1) {			if (! empty ( $rinfo ['accountItem'] )){				$accountType = 2;				if ($amount>=0){					$expensesType='EXPENDITURE';				}else{					$expensesType='INCOME';				}			}else{				$accountType = 1;				$expensesType='EXPENDITURE';			}		} elseif ($detail ['Rtype'] == 2) {			$accountType = 4;			$expensesType='EXPENDITURE';		} elseif ($detail ['Rtype'] == 3) {//培训班结算 收支类型			$accountType = 12;			Doo::loadClass ( 'authcode.func' );			$amountTrain=authcode($amountTrain);			if(!is_numeric ( $amountTrain )) {				die('illegal request--payType');			}						if($amountTrain>=0){				$expensesType='INCOME';			}else{				$expensesType='EXPENDITURE';			}			$amount=$amountTrain;		}				//汇款金额正数		$amount=abs($amount);		//$accountType = 12;		$accountBank = $receivedBank;		$inputDate = $receivedInputDate;		if ($expensesType == "INCOME") {			$expensesTypeWaste = 1;			$accountPriceShow = $accountPrice = $amount;		} elseif ($expensesType == "EXPENDITURE") {			$expensesTypeWaste = 2;			$accountPriceShow = $amount;			$accountPrice = - $amount;		} else {			die ( 'illegal request--expensesType' );		}						/*		$accountPriceShow = $accountPrice = 0;		$expensesTypeWaste = 0;		$accountBank = '';		$inputDate = date ( "Y-m-d H:i:s" );		if ($expensesType == "INCOME") {			$expensesTypeWaste = 1;			$accountPriceShow = $receivedPrice;			$accountPrice = $receivedPrice;			$accountBank = $receivedBank;			$inputDate = $receivedInputDate;		} elseif ($expensesType == "EXPENDITURE") {			$expensesTypeWaste = 2;			$accountPriceShow = $expenditurePrice;			$accountPrice = - $expenditurePrice;			$accountBank = $expenditureBank;			$inputDate = $expenditureInputDate;		} else {			die ( 'illegal request--expensesType' );		}		*/				$receipt = new receipt ();		$receipt->amount = $accountPrice;		$receipt->update ( array (				'where' => 'rid=' . $rid 		) );						// 更新借款汇款金额		if ($accountType == 1) {			Doo::loadModel ( 'loanReceipt' );			$loanReceipt = new loanReceipt ();			$loanReceipt->amount = $accountPrice;						$loanReceipt->update ( array (					'where' => ' rid = ' . $detail ['loanRid'] 			));		}				// 公司流水记录		Doo::loadModel ( 'wasteBook' );		$wasteBook = new wasteBook ();				$abDetail = $wasteBook->getAccountBookByAid ( $expensesTypeWaste, $accountType, $rid );		// 银行		if (empty ( $abDetail )) {			$item = array (					'dataID' => $rid,					'expensesType' => $expensesTypeWaste,					'accountType' => $accountType,					'accountPriceShow' => $accountPriceShow,					'accountPrice' => $accountPrice,					'accountBank' => $accountBank,										'category' => $detail ['category'] [0] ['title'],					'cid' => $detail ['category'] [0] ['cid'],					'name' => $detail ['staffDetail'] ['username'],					'sid' => $detail ['staffDetail'] ['sid'],					'inputDate' => $inputDate 			);			$wasteBook->setAccountBookStatistics ( $item );		}		return '/receiptWasteBook';	}    /**     * 培训班结算营收总计     */	function receiptTrainRevenue(){        //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';        Doo::loadModel ( 'receipt' );        $receipt = new receipt ();        //获得可查看的办事处        Doo::loadModel ( "receiptTrainManage" );        $invoiceCategoryManage = new receiptTrainManage ();        $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );        if(empty($imcStaff)){            die ( 'illegal request--Insufficient Permissions' );        }        $cidList = array ();        foreach ( $imcStaff as $key => $value ) {            array_push ( $cidList, $value ['cid'] );        }        $cidString=implode ( ',', $cidList );        //初始化收款数据        $where=" where a.status not in (3,4,5) and a.Rtype=3 and a.trainId!=0 and paidStatus=0 and invoiceTrainId!=0 ";        $sql="select invoiceTrainId,rid        from CLD_receipt as a        ".$where." and a.cid in (".$cidString.") ";        $receipt->initReceiptTrainRevenue($sql);        $unpaid=$receipt->getReceiptTrainByPaid(0,5,$cidString);        $paid=$receipt->getReceiptTrainByPaid(1,5,$cidString);        $MonthPriceList=$receipt->getReceiptTrainByYearChart($cidString);        $income=$month=$pay=$profit=array();        for ($i=1;$i<=12;$i++){            $flag=true;            array_push($month,date("Y").'-'.$i);            foreach ($MonthPriceList as $key=>$value){                if($key==$i){                    $flag=false;                    array_push($income,$value['ITprice']);                    array_push($pay,$value['RIprice']);                    array_push($profit,$value['ITprice']-$value['RIprice']);                }            }            if ($flag){                array_push($income,0);                array_push($pay,0);                array_push($profit,0);            }        }        $data ['income'] =json_encode ( $income );        $data ['pay'] =json_encode ( $pay );        $data ['profit'] =json_encode ( $profit );        $data ['month'] =json_encode ( $month );        $data ['paid'] = $paid;        $data ['unpaid'] = $unpaid;        $data ['memu'] = "receipt";        $data ['staff'] = $this->staff;        //var_dump( $this->executeId) ;        //die;        $data ['receiptMemu'] = 'receiptTrainRevenue';        $data ['verifyId'] = $this->verifyId;        $data ['executeId'] = $this->executeId;        $this->render ( "/receipt/receiptTrainRevenue", $data );    }    /**     * 所有培训班结算     */    function receiptTrainRevenueAchieve(){        //$paid = $this->get_args ( 'paid' )  ? $this->get_args ( 'paid' ) : '';        $paid =isset ( $this->params ['paid'] ) ? $this->params ['paid'] : 'ALL';        $cidKey = $this->get_args ( 'cidKey' )  ? $this->get_args ( 'cidKey' ) : '';        $page_size = 12;        $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;        $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";        $get='/'.$paid ;//= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );        Doo::loadModel ( 'receipt' );        $receipt = new receipt ();        Doo::loadModel ( 'L_category' );        $Lcategory = new L_category ();        Doo::loadClass ( 'XDeode' );        $XDeode = new XDeode ( 5 );        $cidSql=$cid='';        if(!empty($cidKey)){            $cid = $XDeode->decode ( $cidKey );            $cidSql=" and a.cid=".$cid." ";        }        //获得可查看的办事处        Doo::loadModel ( "receiptTrainManage" );        $invoiceCategoryManage = new receiptTrainManage ();        $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );        $cidList = array ();        foreach ( $imcStaff as $key => $value ) {            array_push ( $cidList, $value ['cid'] );        }        if(!empty($cid)&&!in_array($cid, $cidList)){            die("illegal request-cid");        }        $cidString=implode ( ',', $cidList );        $categoryList = $Lcategory->getCategoryInCid ( $cidString );        $psSql='';$paidKey='';        if(!empty($paid)&&$paid!="ALL"){            if ($paid=='UNPAID'){                $paidKey='0';            }elseif($paid=='PAID'){                $paidKey='1';            }            $psSql=" and a.paidStatus=".$paidKey." ";        }        $dateArr = explode ( ':', $trainEndDate );        $D1 = $dateString = '';        $D2 = '';        if (! empty ( $trainEndDate )) {            $D1 = $dateArr [0];            if (isset ( $dateArr [1] ))                $D2 = $dateArr [1];            else                $D2 = '';            $dateString = $D1 . ":" . $D2;        }        $dateSql='';        if (! empty ( $D1 ) && ! empty ( $D2 )){            $dateSql = ' and trainEndDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';        }elseif (! empty ( $D1 ) && empty ( $D2 )){            $dateSql = ' and trainEndDate like "%' . $D1 . '%"  ';        }        $selectCount=" count(*) as count ";        $where=" where a.status not in (3,4,5) and a.Rtype=3 and a.trainId!=0  and invoiceTrainId!=0 ".$psSql;        $sql = "select ".$selectCount."                from CLD_receipt as a left JOIN CLD_receiptTraining as b on (a.trainId=b.rtid)                   ".$where." and a.cid in (".$cidString.") ".$cidSql.$dateSql;        $action="receiptTrainRevenueAchieve";        $pageinfo = $this->get_page (  $sql, $page, $page_size, $action, $get, "" );        $limit = $pageinfo ['lower'] . ',' . $page_size;        $rtpa=$receipt->getReceiptTrainByPaidAll($paidKey,$cid,$dateSql,$limit,$cidString,$where);        //金额合计功能        $sql="select invoiceTrainId,rid        from CLD_receipt as a        ".$where." and a.cid in (".$cidString.") ";        $receiptTrainPriceList=$receipt->getReceiptTrainSumByItid($sql);        $data ['receiptTrainPriceList']=$receiptTrainPriceList;        $data ['dateString']=$dateString;        $data ['cidKey']=$cidKey;        $data ['categoryList'] =$categoryList;        $data ['paid'] = $paid;        $data ['get'] = $get;        $data ['page'] = $pageinfo;        $data ['onpage'] = $page;        $data ['rtpa'] = $rtpa;        $data ['memu'] = "receipt";        $data ['staff'] = $this->staff;        $data ['receiptMemu'] = 'receiptTrainRevenue';        $data ['verifyId'] = $this->verifyId;        $data ['executeId'] = $this->executeId;        $this->render ( "/receipt/receiptTrainRevenueAchieve", $data );    }    /*     * 全年办事处汇总明细     */    function receiptSummaryStatisticsByAgency(){    	    	//$cidIn = $this->get_args ( 'cidIn' ) ? $this->get_args ( 'cidIn' ) : '12,10,9';    	//include Doo::conf()->BASE_PATH.'diagnostic/debug.php';    	Doo::loadClass ( 'XDeode' );    	//参数    	$cidKeyIn=file_get_contents( "protected/config/receipt/summary.conf.ini");    	if(!empty($cidKeyIn)){	    	$cidKeyIn=explode(',', $cidKeyIn);$cidIn=array();	    	foreach ($cidKeyIn as $key=>$value){	    		$XDeode = new XDeode ( 5 );	    		array_push($cidIn, $XDeode->decode($value));	    	}	    	$cidIn=implode(',', $cidIn);    	}else{    		$cidKeyIn=array();    	}    	    	$year= $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date('Y');    	    	//主体    	Doo::loadModel ( 'L_category' );    	$category = new L_category ();    	$sectionHtml=$sectionItemHtml='';$dataSummary=array();$summaryDateHtml='';    	if(!empty($cidIn)){    		Doo::loadModel ( 'receiptDetail' );    		$receiptDetail = new receiptDetail ();    		Doo::loadModel ( 'accountItem' );    		$accountItem = new accountItem ();    		    		    		$aiList=$accountItem->getCategory();    		$aiAllList=$accountItem->getAccountItem();    		$list=$receiptDetail->getReceiptDetailByYear($cidIn,$year);    		    		$cidArray=explode(',', $cidIn);    		    		foreach ($cidArray as $cak=>$cav){    			$dataSummary[$cav]=array();    			for($month=1;$month<=12;$month++){    				foreach ($aiList as $aik=>$aiv){    					$dataSummary[$cav][$month][$aiv['category']]=array();    				}    				$dataSummary[$cav][$month]['报销金额调整']=array();    			}    		}    		foreach ($list as $key=>$value){    			array_push($dataSummary[$value['cid']][$value['month']][$value['itemCategory']], $value);    		}    		    		//print_r($dataSummary);die;    		    		Doo::loadClass ( 'receipt.func' );    		//构建数据html    		$cglist=$category->getCategoryInCid($cidIn);    		$summaryDateHtml=_getReceiptSummaryHtml($cglist,$aiAllList,$dataSummary,$year);    		    		//构建栏目展示Html    		foreach ($aiAllList as $key=>$value){    			//栏目    			$sectionCount=count($value)+1;    			$sectionHtml.='<th colspan="'.$sectionCount.'">'.$key.'</th>';    			//栏目细则    			$sectionItemHtml.='<th class="colRed">合计</th>';    			foreach ($value as $k=>$v){    				$sectionItemHtml.='<th>'.$v['name'].'</th>';    			}    		}    		    	}    	    	//办事处显示设置    	$categoryList=$category->getCategory();    	$selectedSummary=$cidKeyIn;    	foreach ($categoryList as $key=>$value){    		$categoryList[$key]['checked']='';    		foreach ($selectedSummary as $v){    			if($value['cidKey']==$v){    				$categoryList[$key]['checked']='checked';    				break;    			}    		}    	}    	    	//年份展示    	Doo::loadClass ( 'date.func' );    	$dateHtml=_getDateHtml($year);    	    	$summarData=json_encode($dataSummary);    	    	$data['summarData']=URLEncode($summarData);    	$data['categoryList']=$categoryList;    	    	$data['dateHtml']=$dateHtml;    	$data['sectionHtml']=$sectionHtml;    	$data['sectionItemHtml']=$sectionItemHtml;    	$data['summaryDateHtml']=$summaryDateHtml;    	    	$data['year']=$year;    	    	$data ['memu'] = "receipt";    	$data ['staff'] = $this->staff;    	    	$data ['receiptMemu'] = 'companyCategoryCollect';    	$data ['verifyId'] = $this->verifyId;    	$data ['executeId'] = $this->executeId;    	    	$this->render ( "/receipt/receiptSummaryStatisticsByAgency", $data );    }        //设置办事处展示明细    function setSummaryCategory(){    	$cidKey= $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";    	    	$cidKey=implode(',', $cidKey);    	file_put_contents ( "protected/config/receipt/summary.conf.ini", $cidKey);    	    	return '/receiptSummaryStatisticsByAgency';    }        //导出办事处全年费用汇总excel    function exportReceiptSummaryExcel(){    	$summaryData= $this->get_args ( 'summaryData' ) ? $this->get_args ( 'summaryData' ) : "";    	$year= $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";    	//$cidIn = $this->get_args ( 'cidIn' ) ? $this->get_args ( 'cidIn' ) : '12,10,9';    	    	Doo::loadClass ( 'XDeode' );    	    	$cidKeyIn=file_get_contents( "protected/config/receipt/summary.conf.ini");    	$cidKeyIn=explode(',', $cidKeyIn);$cidIn=array();    	foreach ($cidKeyIn as $key=>$value){    		$XDeode = new XDeode ( 5 );    		array_push($cidIn, $XDeode->decode($value));    	}    	$cidIn=implode(',', $cidIn);    	    	if(!empty($summaryData)){    		    		Doo::loadModel ( 'accountItem' );    		$accountItem = new accountItem ();    		Doo::loadModel ( 'L_category' );    		$category = new L_category ();    		    		$aiAllList=$accountItem->getAccountItem();    		$cglist=$category->getCategoryInCid($cidIn);    		    		$summaryData=json_decode(urldecode($summaryData), true);    		Doo::loadClass ( 'receipt.func' );    		    		excelRCData($summaryData,$aiAllList,$cglist,$year);    	}    	    	die ( 'illegal request--excel Data null' );    }    	function exportReceiptTrainExcel() {		$rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";		$ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";				$summaryJson = $this->get_args ( 'summaryJson' ) ? $this->get_args ( 'summaryJson' ) : "";		$aiListJson = $this->get_args ( 'aiListJson' ) ? $this->get_args ( 'aiListJson' ) : "";						Doo::loadClass ( 'XDeode' );		$XDeode = new XDeode ( 7 );		$rid = $XDeode->decode ( $ridKey );				if (! is_numeric ( $rid ))			die ( 'illegal request' );				Doo::loadModel ( 'receipt' );		$receipt = new receipt ();		Doo::loadModel ( 'receiptTraining' );		$receiptTraining = new receiptTraining ();				$receiptDetail = $receipt->getReceiptByRid ( $rid );		$receiptTrainDetail = $receiptTraining->getReceiptTrainingByRtid ( $rtidKey );								$summary=json_decode(urldecode($summaryJson), true);		$aiList=json_decode(urldecode($aiListJson), true);		//借款相关		$receiptLoanDetail=array();		if (! empty ( $receiptDetail ['trainLoanRid'] )) {			$receiptLoanDetail = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );		}				//收入		Doo::loadModel ( 'invoice' );		$invoice = new invoice ();		Doo::loadModel ( 'invoiceTraining' );		$invoiceTraining = new invoiceTraining ();		$invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );		$invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );				//支出		Doo::loadModel ( 'RItem' );		$RItem = new RItem ();		$RItemList = $RItem->getRItemByRid ( $rid );				//讲师		Doo::loadModel ( 'RILecturer' );		$RILecturer = new RILecturer ();		$RILecturerList = $RILecturer->getRILecturerByRid ( $rid );				Doo::loadClass ( 'receipt.func' );		excelData ( $receiptTrainDetail, $receiptDetail, $summary, $aiList,$receiptLoanDetail,$invoiceList,$RItemList,$RILecturerList,$invoiceTrainingDetail );	}		/**	 * 获得审批流程	 */	private function fnGetReceiptApprovalProcess($verifyList = array(), $verifyStaff = array()) {		Doo::loadModel ( 'role' );		$role = new role ();		Doo::loadModel ( 'staff' );		$staff = new staff ();				$flag = true;		$roleKey = $button = 0;		$endStaffArray = array ();		$roleArrayCopy = array ();		foreach ( $verifyList as $k => $v ) {						if ($v [1] == 'ROLE') {				if (! empty ( $verifyStaff )) {					$endStaffArray = end ( $verifyStaff );					if ($v [0] == $endStaffArray ['nextStaff']) {						$roleId = $v [0];					}				}								$roleVerify = json_decode ( $v [3], true );				$roleKey = $k;				$roleArray = array ();				$rolename = $role->getOne ( array (						'where' => 'rid=' . $v [0],						'asArray' => true 				) );								foreach ( $roleVerify as $o => $p ) {					$staffID = explode ( '_', $p );					$staffInfo = $staff->getOne ( array (							'where' => 'sid=' . $staffID [0],							'asArray' => true 					) );					// print_r($staffID);					$exp = array (							0 => $staffInfo ['sid'],							1 => $staffID [1],							2 => $staffInfo ['avatar'],							'date' => '',							'date' => '',							'opinion' => '',							'status' => '',							'rolename' => $rolename ['name'] 					);					array_push ( $roleArray, $exp );				}				$roleArrayCopy [$v [0]] = $roleArray;				// $verifyList[$k]['roleArray']=$roleArray;			}			// print_r($roleArray);						$verifyList [$k] ['date'] = "";			$verifyList [$k] ['opinion'] = "";			$verifyList [$k] ['status'] = "";			if (empty ( $verifyStaff )) {				$verifyList [$k] ['date'] = "";				$verifyList [$k] ['opinion'] = "";				if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {					$verifyList [$k] ['status'] = 4;					$button = 4;					$flag = false;				}			} else {								foreach ( $verifyStaff as $m => $u ) {					if ($v [0] == $m) {						$verifyList [$k] ['date'] = $u ['date'];						$verifyList [$k] ['opinion'] = $u ['opinion'];						$verifyList [$k] ['status'] = $u ['status'];						$flag = false;						break;					}				}								$endStaffArray = end ( $verifyStaff );				if (isset ( $endStaffArray ['ROLE'] )) {				} else {					$endKey = key ( $verifyStaff );					if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {						$button = 4;						$verifyList [$k] ['status'] = 4;					}				}			}		}				$rolename ['name'] = '';		if (! empty ( $roleId )) {			Doo::loadModel ( 'role' );			$role = new role ();			$rolename = $role->getOne ( array (					'where' => 'rid=' . $roleId,					'asArray' => true 			) );		}				if (! empty ( $verifyStaff ))			$endStaffArray = end ( $verifyStaff );				$KOP = false;		foreach ( $roleArrayCopy as $P => $A ) {						foreach ( $A as $MKI => $AVL ) {				if (! empty ( $verifyStaff )) {					// &&$rolename['rid']==$endStaffArray['nextStaff']					if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {						$button = 4;						$roleArrayCopy [$P] [$MKI] ['status'] = 4;					}										foreach ( $verifyStaff as $m => $u ) {						$AVLFK = $AVL [0] . '_R';						// echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';												if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1							$roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];							$roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];							$roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];														break;						}					}				} else {										if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {						$button = 4;						$roleArrayCopy [$P] [$MKI] ['status'] = 4;					}				}				// $roleArray[$MKI]['rolename']=$rolename['name'];				$KOP = true;			}		}				foreach ( $roleArrayCopy as $k => $v ) {			foreach ( $verifyList as $m => $n ) {				if ($n [0] == $k) {					array_splice ( $verifyList, $m, 1, $v );				}			}		}				return array (				'verifyList' => $verifyList,				'isApproval' => $button 		);	}	function _GetFileEXT($filename) {		$pics = explode ( '.', $filename );				$num = count ( $pics );				return $pics [$num - 1];	}		/**	 * 获取get或者POST值	 * @param string $name 属性名称	 * @return fixed 值	 */	function get_args($name) {		if (isset ( $_GET [$name] )) {			if (is_array ( $_GET [$name] ))				return $_GET [$name];			else				return addslashes ( $_GET [$name] );		} elseif (isset ( $_POST [$name] )) {			if (is_array ( $_POST [$name] ))				return $_POST [$name];			else				return addslashes ( $_POST [$name] );		} else			return false;	}	function num_to_rmb($num) {		$c1 = "零壹贰叁肆伍陆柒捌玖";		$c2 = "分角元拾佰仟万拾佰仟亿";		// 精确到分后面就不要了,所以只留两个小数位		$num = round ( $num, 2 );		// 将数字转化为整数		$num = $num * 100;		if (strlen ( $num ) > 10) {			return "金额太大,请检查";		}		$i = 0;		$c = "";		while ( 1 ) {			if ($i == 0) {				// 获取最后一位数字				$n = substr ( $num, strlen ( $num ) - 1, 1 );			} else {				$n = $num % 10;			}			// 每次将最后一位数字转化为中文			$p1 = substr ( $c1, 3 * $n, 3 );			$p2 = substr ( $c2, 3 * $i, 3 );						if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {				$c = $p1 . $p2 . $c;			} else {				$c = $p1 . $c;			}			$i = $i + 1;			// 去掉数字最后一位了						$num = $num / 10;			// echo $num.'</br>';			$num = ( int ) $num;			// $num =floor($num);			// $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );			// echo $num.'</br>';			// 结束循环			if ($num == 0) {				break;			}		}		// echo $c.'</br>';		$j = 0;		$slen = strlen ( $c );		while ( $j < $slen ) {			// utf8一个汉字相当3个字符			$m = substr ( $c, $j, 6 );			// 处理数字中很多0的情况,每次循环去掉一个汉字“零”			if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {				$left = substr ( $c, 0, $j );				$right = substr ( $c, $j + 3 );				$c = $left . $right;				$j = $j - 3;				$slen = $slen - 3;			}			$j = $j + 3;		}		// 这个是为了去掉类似23.0中最后一个“零”字		if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {			$c = substr ( $c, 0, strlen ( $c ) - 3 );		}		// 将处理的汉字加上“整”		if (empty ( $c )) {			return "零元整";		} else {			return $c . "整";		}	}		/**	 * 获得分页数据	 * @param unknown_type $table	 * @param unknown_type $condition	 * @param unknown_type $on_page	 * @param unknown_type $page_size	 */	function get_page($sql = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {		$page_c = "";		$page ['previous'] = $this->get_previous ( $on_page );		$page ['on_page'] = $on_page;		$total_count = $this->get_table_count ( $sql );		$total = intval ( $total_count / $page_size );				$page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;		$page ['total_data'] = $total_count;		$page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;				$i = 1;		$page_max = 1;		$page_width = 3;				if ($on_page >= $page_width) {			$page_max = intval ( $on_page / $page_width ) + 1;			$i = intval ( $on_page / $page_width ) * $page_width - 1;		}				for(; $i <= $page ['total_page']; $i ++) {			if ($i == $on_page)				$page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';			else				$page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';						if ($i == ($page_width * $page_max))				break;		}				$page ['page'] = $page_c;		$page ['lower'] = (-- $on_page) * $page_size;		return $page;	}		/**	 * 获取总页数	 * @param unknown_type $table	 * @param unknown_type $condition	 */	public function get_table_count($sql="") {		// $sql = "select count(*) as count from " . $table . " where 1 " . $condition;		$query = Doo::db ()->query ( $sql );		$result = $query->fetch ();		return $result ['count'];	}	/**	 * 获取上一页	 * @param unknown_type $on_page	 */	function get_previous($on_page = 1) {		return $on_page != 0 ? $on_page - 1 : $on_page;	}}?>
 |