| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502 | 
							- <?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 = "其他";
 
- 	
 
- 	public function beforeRun($resource, $action) {
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
 
- 		// 单独判断公司汇总的访问权限
 
- 		if ($action == 'companyCategoryCollect') {
 
- 			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 paymentsDelete(){
 
- 		$aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
 
- 		if (! empty ( $aidKey )) {
 
- 			Doo::loadClass ( 'XDeode' );
 
- 			$XDeode = new XDeode ( 5 );
 
- 			
 
- 			$aid = $XDeode->decode ( $aidKey );
 
- 			
 
- 			Doo::loadModel ( "accountBook" );
 
- 			$accountBook = new accountBook ();
 
- 			
 
- 			$abDetail = $accountBook->getAccountBookByAid ( $aid );
 
- 			
 
- 			if (empty ( $abDetail )){
 
- 				die ( 'illegal request' );
 
- 			}
 
- 			// 删除收支统计
 
- 			Doo::loadModel ( "accountBookStatistics" );
 
- 			$accountBookStatistics = new accountBookStatistics ();
 
- 			$accountBookStatistics->delete ( array (
 
- 				'where' => 'aid=' . $aid,
 
- 				'limit' => 1 
 
- 			) );
 
- 			//删除日常收支
 
- 			$accountBook->delete ( array (
 
- 				'where' => 'aid=' . $aid,
 
- 				'limit' => 1 
 
- 			) );
 
- 			//TODO 2020-07-23 删除新增理财和银行存款流水
 
- 			$accountType = '';
 
- 			if ($abDetail ['expensesType'] == 1) {
 
- 				$accountType = 6;
 
- 			}elseif($abDetail ['expensesType'] == 2){
 
- 				$accountType = 5;
 
- 			}
 
- 			Doo::loadModel ( 'wasteBook' );
 
- 			$wasteBook = new wasteBook ();
 
- 			$wasteBook->delete ( array (
 
- 				'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
 
- 				'limit' => 1 
 
- 			) );
 
- 		}
 
- 		return '/paymentsAchieve';
 
- 	}
 
- 	/**
 
- 	 * 银行存款相关
 
- 	 *
 
- 	 * @return void
 
- 	 */
 
- 	function paymentsBankDo(){
 
- 		//支出部分
 
- 		$outlayBank = $this->get_args ( 'outlayBank' ) ? $this->get_args ( 'outlayBank' ) : "";
 
- 		$outlayMsg = $this->get_args ( 'outlayMsg' ) ? $this->get_args ( 'outlayMsg' ) : "";
 
- 		$outlayDate = $this->get_args ( 'outlayDate' ) ? $this->get_args ( 'outlayDate' ) : "";
 
- 		$outlayRemarks = $this->get_args ( 'outlayRemarks' ) ? $this->get_args ( 'outlayRemarks' ) : "";
 
- 		$outlayPrice = is_numeric ( $this->get_args ( 'outlayPrice' ) ) ? $this->get_args ( 'outlayPrice' ) : 0;
 
- 		//收入部分
 
- 		$revenueBank = $this->get_args ( 'revenueBank' ) ? $this->get_args ( 'revenueBank' ) : "";
 
- 		$revenueMsg = $this->get_args ( 'revenueMsg' ) ? $this->get_args ( 'revenueMsg' ) : "";
 
- 		$revenueDate = $this->get_args ( 'revenueDate' ) ? $this->get_args ( 'revenueDate' ) : "";
 
- 		$revenueRemarks = $this->get_args ( 'revenueRemarks' ) ? $this->get_args ( 'revenueRemarks' ) : "";
 
- 		
 
- 		$revenuePrice = is_numeric ( $this->get_args ( 'revenuePrice' ) ) ? $this->get_args ( 'revenuePrice' ) : 0;
 
- 		if(! empty ( $outlayPrice ) && ! empty ( $outlayMsg ) && ! empty ( $outlayBank ) && ! empty ( $outlayDate ) && 
 
- 		   ! empty ( $revenuePrice ) && ! empty ( $revenueMsg ) && ! empty ( $revenueBank ) && ! empty ( $revenueDate )){
 
- 			Doo::loadModel ( "accountBook" );
 
- 			Doo::loadModel ( "accountBookStatistics" );
 
- 			Doo::loadModel ( 'wasteBook' );
 
- 			//导入理财func
 
- 			Doo::loadClass ( 'receipt.finances.func' );
 
- 			//公司使用
 
- 			$accountBank_companyOut=_getCompanyBankEN($outlayBank);
 
- 			if(empty($accountBank_companyOut)){
 
- 				die ( '支出信息-公司银行  illegal request' );
 
- 			}
 
- 			//公司银行转换
 
- 			$accountBank_companyRevenue=_getCompanyBankEN($revenueBank);
 
- 			if (empty($accountBank_companyRevenue)) {
 
- 				die('收入信息-公司银行 illegal request');
 
- 			}
 
- 			//1-1 银行支出
 
- 			$depositMethod = '活期';
 
- 			$accountBook = new accountBook();
 
- 			//expensesType,expenditureType,operatingBankType
 
- 			$outlayId = _saveOutlayAB($accountBook, 2, 12, 2, $depositMethod, $outlayMsg, $outlayPrice, $outlayBank, $outlayDate, $outlayRemarks, $this->staff);
 
- 			//1-2 理财支出汇总--存款不需要
 
- 			$abDetail = $accountBook->getAccountBookByAid($outlayId);
 
- 			$accountBookStatistics = new accountBookStatistics();
 
- 			_saveAccountBookStatistics($abDetail, $accountBookStatistics);
 
- 			//1-3 理财-流水支出
 
- 			//公司银行转换
 
- 			$accountBank = $accountBank_companyOut;
 
- 			$wasteBook = new wasteBook();
 
- 			//expensesType,accountType,dailyType,operatingBankType
 
- 			_saveFWB($wasteBook, 2, 5, 3, 2, $depositMethod, -$outlayPrice, $outlayId, $accountBank, $outlayDate, $this->staff);
 
- 			//2-1银行收入
 
- 			$depositMethod = '活期';
 
- 			$accountBook = new accountBook();
 
- 			//expensesType,accountType,operatingBankType
 
- 			$inComeId = _saveRevenueAB($accountBook, 1, 14, 2, $depositMethod, $revenueBank, $revenuePrice, $revenueMsg, $revenueDate, $revenueRemarks, $this->staff);
 
- 			//2-2-2 理财支出汇总
 
- 			$abDetail = $accountBook->getAccountBookByAid($inComeId);
 
- 			$accountBookStatistics = new accountBookStatistics();
 
- 			_saveRevenueAccountBookStatistics($abDetail, $accountBookStatistics);
 
- 			//1-2-3 理财-流水收入
 
- 			//公司银行转换
 
- 			$accountBank = $accountBank_companyRevenue;
 
- 			$wasteBook = new wasteBook();
 
- 			//expensesType,accountType,dailyType,operatingBankType
 
- 			_saveFWB($wasteBook, 1, 6, 3, 2, $depositMethod, $revenuePrice, $inComeId, $accountBank, $revenueDate, $this->staff);
 
- 		}
 
- 		return '/payments';
 
- 	}
 
- 	/**
 
- 	 * 理财相关操作
 
- 	 *
 
- 	 * @return void
 
- 	 */
 
- 	function paymentsFinancesDo(){
 
- 		//支出部分
 
- 		$outlayOperatingType = $this->get_args ( 'outlayOperatingType' ) ? $this->get_args ( 'outlayOperatingType' ) : "";
 
- 		$outlayAccountType = $this->get_args ( 'outlayAccountType' ) ? $this->get_args ( 'outlayAccountType' ) : "";
 
- 		$outlayAccountMsg = $this->get_args ( 'outlayAccountMsg' ) ? $this->get_args ( 'outlayAccountMsg' ) : "";
 
- 		$outlayBank = $this->get_args ( 'outlayBank' ) ? $this->get_args ( 'outlayBank' ) : "";
 
- 		$outlayMsg = $this->get_args ( 'outlayMsg' ) ? $this->get_args ( 'outlayMsg' ) : "";
 
- 		$outlayDate = $this->get_args ( 'outlayDate' ) ? $this->get_args ( 'outlayDate' ) : "";
 
- 		$outlayRemarks = $this->get_args ( 'outlayRemarks' ) ? $this->get_args ( 'outlayRemarks' ) : "";
 
- 		
 
- 		$outlayPrice = is_numeric ( $this->get_args ( 'outlayPrice' ) ) ? $this->get_args ( 'outlayPrice' ) : 0;
 
- 		//收入部分
 
- 		$revenueOperatingType = $this->get_args ( 'revenueOperatingType' ) ? $this->get_args ( 'revenueOperatingType' ) : "";
 
- 		$revenueAccountType = $this->get_args ( 'revenueAccountType' ) ? $this->get_args ( 'revenueAccountType' ) : "";
 
- 		$revenueAccountMsg = $this->get_args ( 'revenueAccountMsg' ) ? $this->get_args ( 'revenueAccountMsg' ) : "";
 
- 		$revenueBank = $this->get_args ( 'revenueBank' ) ? $this->get_args ( 'revenueBank' ) : "";
 
- 		$revenueMsg = $this->get_args ( 'revenueMsg' ) ? $this->get_args ( 'revenueMsg' ) : "";
 
- 		$revenueDate = $this->get_args ( 'revenueDate' ) ? $this->get_args ( 'revenueDate' ) : "";
 
- 		$revenueRemarks = $this->get_args ( 'revenueRemarks' ) ? $this->get_args ( 'revenueRemarks' ) : "";
 
- 		
 
- 		$revenuePrice = is_numeric ( $this->get_args ( 'revenuePrice' ) ) ? $this->get_args ( 'revenuePrice' ) : 0;
 
- 		//信息完整性检查
 
- 		if(!empty ( $outlayOperatingType ) &&!empty ( $outlayAccountType ) && ! empty ( $outlayPrice ) && ! empty ( $outlayMsg ) && ! empty ( $outlayBank ) && ! empty ( $outlayDate ) && !empty($outlayAccountMsg) &&
 
- 		!empty ( $revenueOperatingType ) &&!empty ( $revenueAccountType ) && ! empty ( $revenuePrice ) && ! empty ( $revenueMsg ) && ! empty ( $revenueBank ) && ! empty ( $revenueDate )){
 
- 			Doo::loadModel ( "accountBook" );
 
- 			Doo::loadModel ( "accountBookStatistics" );
 
- 			Doo::loadModel ( 'wasteBook' );
 
- 			//导入理财func
 
- 			Doo::loadClass ( 'receipt.finances.func' );
 
- 			//信息判定
 
- 			$depositMethod_out=_checkDepositMethod($outlayAccountMsg);
 
- 			//流水使用
 
- 			$accountBank_out= _getFinancesBankEN($outlayAccountType);
 
- 			//公司使用
 
- 			$accountBank_companyOut=_getCompanyBankEN($outlayBank);
 
- 			if(empty($depositMethod_out)||empty($accountBank_out)||empty($accountBank_companyOut)){
 
- 				die ( '支出信息-理财或者公司银行  illegal request' );
 
- 			}
 
- 			//信息完整性判断
 
- 			$depositMethod_revenue=_checkDepositMethod($revenueAccountMsg);
 
- 			//流水使用
 
- 			$accountBank_revenue= _getFinancesBankEN($revenueAccountType);
 
- 			//公司银行转换
 
- 			$accountBank_companyRevenue=_getCompanyBankEN($revenueBank);
 
- 			if (empty($accountBank_companyRevenue)||empty($depositMethod_revenue)||empty($accountBank_revenue)) {
 
- 				die('收入信息-理财或者公司银行 illegal request');
 
- 			}
 
- 			//处理支出信息
 
- 			//1.1-理财支出
 
- 			if($outlayOperatingType=='finances'){
 
- 				//活或固
 
- 				$depositMethod=$depositMethod_out;
 
- 				
 
- 				//1-1-1-日常支出
 
- 				$accountBook = new accountBook ();
 
- 				$outlayId =_saveOutlayAB($accountBook,2,11,1,$depositMethod,$outlayMsg,$outlayPrice,$outlayAccountType,$outlayDate,$outlayRemarks,$this->staff);
 
- 				
 
- 				//1-1-2 理财支出汇总
 
- 				$abDetail = $accountBook->getAccountBookByAid ( $outlayId );
 
- 				$accountBookStatistics = new accountBookStatistics ();
 
- 				_saveAccountBookStatistics($abDetail,$accountBookStatistics);
 
- 				
 
- 				//1-1-3 理财-流水支出
 
- 				//理财银行
 
- 				$accountBank= $accountBank_out;
 
- 				$wasteBook = new wasteBook ();
 
- 				_saveFWB($wasteBook,2,5,2,1,$depositMethod,-$outlayPrice,$outlayId,$accountBank,$outlayDate,$this->staff);
 
- 			}
 
- 			//1.2-银行支出
 
- 			if($outlayOperatingType=='bank'){
 
- 				
 
- 				//1-2-1-日常支出
 
- 				$depositMethod = '活期';
 
- 				$accountBook = new accountBook ();
 
- 				$outlayId =_saveOutlayAB($accountBook,2,11,2,$depositMethod,$outlayMsg,$outlayPrice,$outlayBank,$outlayDate,$outlayRemarks,$this->staff);
 
- 				
 
- 				//1-2-2 理财支出汇总
 
- 				$abDetail = $accountBook->getAccountBookByAid ( $outlayId );
 
- 				$accountBookStatistics = new accountBookStatistics ();
 
- 				_saveAccountBookStatistics($abDetail,$accountBookStatistics);
 
- 				//1-2-3 理财-流水支出
 
- 				//公司银行转换
 
- 				$accountBank=$accountBank_companyOut;
 
- 				$wasteBook = new wasteBook ();
 
- 				//expensesType,accountType,dailyType,operatingBankType
 
- 				_saveFWB($wasteBook,2,5,2,2,$depositMethod,-$outlayPrice,$outlayId,$accountBank,$outlayDate,$this->staff);
 
- 			}
 
- 		
 
- 			//处理收入信息
 
- 			//2-1 理财收入
 
- 			if($revenueOperatingType=='finances'){
 
- 				//信息完整性判断
 
- 				$depositMethod=$depositMethod_revenue;
 
- 				//2-1-1-日常收入
 
- 				$accountBook = new accountBook();
 
- 				$inComeId =_saveRevenueAB($accountBook,1,13,1,$depositMethod,$revenueAccountType,$revenuePrice,$revenueMsg,$revenueDate,$revenueRemarks,$this->staff);
 
- 				//2-1-2 理财收入汇总
 
- 				$abDetail = $accountBook->getAccountBookByAid($inComeId);
 
- 				$accountBookStatistics = new accountBookStatistics();
 
- 				_saveRevenueAccountBookStatistics($abDetail,$accountBookStatistics);
 
- 				
 
- 				//2-1-3 理财-流水收入
 
- 				//流水使用
 
- 				$accountBank= $accountBank_revenue;
 
- 				$wasteBook = new wasteBook ();
 
- 				//expensesType,accountType,dailyType,operatingBankType
 
- 				_saveFWB($wasteBook,1,6,2,1,$depositMethod,$revenuePrice,$inComeId,$accountBank,$revenueDate,$this->staff);
 
- 			}
 
- 			//2-2银行收入
 
- 			if($revenueOperatingType=='bank'){
 
- 				
 
- 				//2-2-1-日常支出
 
- 				$depositMethod = '活期';
 
- 				$accountBook = new accountBook();
 
- 				//expensesType,accountType,operatingBankType
 
- 				$inComeId =_saveRevenueAB($accountBook,1,13,2,$depositMethod,$revenueBank,$revenuePrice,$revenueMsg,$revenueDate,$revenueRemarks,$this->staff);
 
- 				//2-2-2 理财支出汇总
 
- 				$abDetail = $accountBook->getAccountBookByAid($inComeId);
 
- 				$accountBookStatistics = new accountBookStatistics();
 
- 				_saveRevenueAccountBookStatistics($abDetail,$accountBookStatistics);
 
- 				//1-2-3 理财-流水收入
 
- 				//公司银行转换
 
- 				$accountBank=$accountBank_companyRevenue;
 
- 				$wasteBook = new wasteBook();
 
- 				//expensesType,accountType,dailyType,operatingBankType
 
- 				_saveFWB($wasteBook, 1, 6, 2, 2, $depositMethod, $revenuePrice, $inComeId, $accountBank, $revenueDate, $this->staff);
 
- 			}	
 
- 		}
 
- 		return '/payments';
 
- 	}
 
- 	/**
 
- 	 * 查看审批培训班结算
 
- 	 */
 
- 	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=$billPrice = 0;
 
- 		if (! empty ( $invoiceTrainingDetail )) {
 
- 			$invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
 
- 			$RIAmount = $invoiceTrainingDetail ['RIAmount'];
 
- 			if (!empty($invoiceTrainingDetail ['billPrice'])){
 
- 				$billPrice=$invoiceTrainingDetail ['billPrice'];
 
- 			}
 
- 			
 
- 		}
 
- 		
 
- 		$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 );
 
- 		
 
- 		$billProfit=$billPrice - $aiData ['total'];
 
- 		$companyBillProfit = $billProfit * 0.6;
 
- 		$categoryBillProfit = $billProfit * 0.4;
 
- 		$data ['billProfit'] = sprintf ( "%.2f", $billProfit );
 
- 		$data ['companyBillProfit'] = sprintf ( "%.2f", $companyBillProfit );
 
- 		$data ['categoryBillProfit'] = sprintf ( "%.2f", $categoryBillProfit );
 
- 		
 
- 		// 发票利润
 
- 		$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($billPrice != 0){
 
- 			$data ['totalBillProportion'] = sprintf ( "%.2f", $aiData ['total'] / $billPrice * 100 ); //入账金额占比新
 
- 			$data ['profitBillProportion'] = sprintf ( "%.2f", $billProfit / $billPrice * 100 ); //入账金额占比新
 
- 			$data ['companyBillProfitProportion'] = sprintf ( "%.2f", $companyBillProfit / $billPrice * 100 );
 
- 			$data ['categoryBillProportion'] = sprintf ( "%.2f", $categoryBillProfit / $billPrice * 100 );
 
- 			$data ['invoiceBillTotalAmountProportion'] = sprintf ( "%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $billPrice * 100 );
 
- 		}else{
 
- 			$data ['totalBillProportion'] =$data ['profitBillProportion'] =$data ['companyBillProfitProportion'] =$data ['categoryBillProportion'] =$data ['invoiceBillTotalAmountProportion'] =0;
 
- 		}
 
- 		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' );
 
- 		
 
- 	}
 
- 	
 
- 	function wasteBookReport(){
 
- 		$data ['memu'] = "receipt";
 
- 		$data ['staff'] = $this->staff;
 
- 		$data ['verifyId'] = $this->verifyId;
 
- 		$data['receiptMemu']='wasteBookReport';
 
- 		$data ['executeId'] = $this->executeId;
 
- 		$this->render ( "/expenses/wasteBookReport", $data );
 
- 	}
 
- 	
 
- 	function frame_wasteBookReport(){
 
- 		$data='';
 
- 		$this->render ( "/wbReport/index", $data );
 
- 	}
 
- 	
 
- 	
 
- 	//移除培训班结算-支出列
 
- 	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 ( 'bill' );
 
- 		$bill = new bill ();
 
- 		$bill->iid=$detail ['iid'];
 
- 		$bill->trainId=$detail['trainId'];
 
- 		$bill->irid=$irid;
 
- 		$bill->create_time=date ( "Y-m-d H:i:s" );
 
- 		$bill->price=$detail ['invoicePrice'];
 
- 		$bill->insert ();
 
- 		
 
- 		
 
- 		
 
- 		// 在是对冲收款 确保已收款不被删除
 
- 		// 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($rinfo ['version'] == 1){
 
- 					$accountType = 2;
 
- 					if ($amount>=0){
 
- 						$expensesType='EXPENDITURE';
 
- 					}else{
 
- 						$expensesType='INCOME';
 
- 					}
 
- 				}else{
 
- 					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']=sprintf("%.2f",abs($receiptList[$key]['balance']));
 
- 			}elseif($value['Rtype']==3){
 
- 				$payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
 
- 				$receiptList[$key]['payment']=$payment;
 
- 				$receiptList[$key]['paymentABS']=sprintf("%.2f",abs($payment));
 
- 			}
 
- 			$receiptList[$key]['amountABS']=sprintf("%.2f",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' );
 
- 		}
 
- 		
 
- 		
 
- 		//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
 
- 		
 
- 		/*
 
- 		$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($detail['version']==1){
 
- 				$accountType = 2;
 
- 				if ($amount>=0){
 
- 					$expensesType='EXPENDITURE';
 
- 				}else{
 
- 					$expensesType='INCOME';
 
- 				}
 
- 			}else{
 
- 				if (! empty ( $detail ['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() {
 
- 		
 
- 		//include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
 
- 		$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=array();
 
- 		$invoiceTrainingDetail=array();
 
- 		if($receiptDetail ['invoiceTrainId']!=0){
 
- 			$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;
 
- 	}
 
- }
 
 
  |