| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817 | 
							- <?php
 
- /**
 
-  * 开票功能控制器
 
-  * @author CP
 
-  * @version 1.0
 
-  * @namespace invoice
 
-  * @package invoiceController
 
-  */
 
- class InvoiceController extends DooController {
 
- 	public $staff;
 
- 	public $NEW;
 
- 	public $data;
 
- 	private $INVOICEKEY = "APPROVAL";
 
- 	private $INVOICECOLLECTPATH = "protected/cache/invoiceCollect/";
 
- 	private $ACTION = '';
 
- 	public function beforeRun($resource, $action) {
 
- 		Doo::loadModel ( "invoiceManage" );
 
- 		$invoiceManage = new invoiceManage ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
 
- 		header ( 'Content-Type:text/html;charset=utf-8' );
 
- 		$moldList = $invoiceManage->getInvoiceByStaff ( $sid );
 
- 		
 
- 		if (empty ( $moldList )) {
 
- 			$flag = false;
 
- 			$uGroups = 'ordinary';
 
- 			if (Doo::acl ()->isAllowed ( $uGroups, $resource, $action )) {
 
- 				$flag = true;
 
- 			}
 
- 		} else {
 
- 			$flag = false;
 
- 			array_push ( $moldList, array (
 
- 					'mold' => 'ordinary' 
 
- 			) );
 
- 			foreach ( $moldList as $value ) {
 
- 				// echo $value['mold'];
 
- 				// echo $action;
 
- 				
 
- 				if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) {
 
- 					$flag = true;
 
- 					break;
 
- 				}
 
- 			}
 
- 		}
 
- 		/*
 
- 		 * Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
 
- 		 */
 
- 		// var_dump($flag) ;
 
- 		if (! $flag)
 
- 			die ( 'illegal request' );
 
- 	}
 
- 	
 
- 	function __construct() {
 
- 		if (isset ( $_COOKIE ["staff"] )) {
 
- 			if (! empty ( $_COOKIE ["staff"] )) {
 
- 				Doo::loadModel ( 'staff' );
 
- 				$staff = new staff ();
 
- 				
 
- 				$uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
 
- 				$this->ACTION = $uriPartsOrig [1];
 
- 				
 
- 				$this->data ['new'] = $this->isInvoiceNew ();
 
- 				$this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
 
- 				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 invoice() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- // 		Doo::loadModel ( 'express' );
 
- // 		$express = new express ();
 
- // 		$expressList = $express->getExpressByAll ();
 
- // 		$this->data ['expressList'] = $expressList;
 
- 		
 
- // 		Doo::loadModel ( 'invoiceReceivables' );
 
- // 		$invoiceReceivables = new invoiceReceivables ();
 
- // 		$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 
- 		
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		
 
- 		$isMonth = $invoiceStatistics->getStatisticsByMonth ();
 
- 		
 
- 		$year = date ( "Y" );
 
- 		$tmp_date = date ( "Ym" );
 
- 		$tmp_year = substr ( $tmp_date, 0, 4 );
 
- 		$tmp_mon = substr ( $tmp_date, 4, 2 );
 
- 		$tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
 
- 		$fm_forward_month = date ( "m", $tmp_forwardmonth );
 
- 		$path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
 
- 		$htm = $this->showCache ( $path );
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
 
- 		
 
- 		$invoiceList = $invoice->getMyInvoice ( $sid );
 
- 		
 
- 		$sql = 'status=2 and printStatus=1 and irid!="" and sid=' . $sid;
 
- 		$list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
 
- 		
 
- 		// print_r($list);
 
- 		
 
- 		$this->data ['isMonth'] = $isMonth;
 
- 		$this->data ['htm'] = $htm;
 
- 		
 
- 		$this->data ['invoiceList'] = $invoiceList;
 
- 		$this->data ['receivablesList'] = $list;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoice';
 
- 		$this->render ( "/admin/invoice", $this->data );
 
- 	}
 
- 	function invoiceAdd() {
 
- 		Doo::loadModel ( 'L_category' );
 
- 		$lCategory = new L_category ();
 
- 		
 
- 		$category = $lCategory->find ( array (
 
- 				'asArray' => true 
 
- 		) );
 
- 		
 
- 		$this->data ['category'] = $category;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoice';
 
- 		$this->render ( "/admin/invoiceAdd", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 提交一份开票申请,并记录下操作日志
 
- 	 *
 
- 	 * @since 1.0.0
 
- 	 * @var integer cid 办事处ID
 
- 	 * @var integer invoiceType 发票类型
 
- 	 * @var integer doPost 是否邮寄
 
- 	 * @var integer invoicePrice 开票金额
 
- 	 * @var string invoiceElement 开票内容
 
- 	 * @var string invoiceTitle 发票抬头
 
- 	 * @var string invoiceCompany 单位名称
 
- 	 * @var string TIN 纳税人识别码
 
- 	 * @var string address 注册地址
 
- 	 * @var string phone 注册电话
 
- 	 * @var string bank 开户银行
 
- 	 * @var string bankAccount 银行账户
 
- 	 * @var string recipients 收件人
 
- 	 * @var string recipientsPhone 收件人手机/电话
 
- 	 * @var string recipientsAddress 收件地址
 
- 	 * @var string mailItems 邮寄物品
 
- 	 * @var string remark 备注
 
- 	 * @return string 返回跳转开票主页路径
 
- 	 */
 
- 	function invoiceAddDo() {
 
- 		$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
 
- 		$invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
 
- 		$doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
 
- 		$invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
 
- 		$invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
 
- 		$invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
 
- 		$invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
 
- 		$TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
 
- 		$address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
 
- 		$phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
 
- 		$bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
 
- 		$bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
 
- 		$recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
 
- 		$recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
 
- 		$recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
 
- 		
 
- 		$remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
 
- 		
 
- 		$TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
 
- 		$addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
 
- 		$phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
 
- 		$bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
 
- 		$bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
 
- 		
 
- 		$softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
 
- 		$softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
 
- 		$contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
 
- 		$contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
 
- 		$instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
 
- 		$instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
 
- 		$remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
 
- 		
 
- 		$mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
 
- 		// echo $softLock;die;
 
- 		/*
 
- 		 * $mailList=array(); array_push($mailList, array('invoice'=>1)); array_push($mailList, array('mailItems'=>$mailItems)); if (!empty($softLock)) array_push($mailList, array('softLock'=>$softLockNum)); if (!empty($contract)) array_push($mailList, array('contract'=>$contractNum)); if (!empty($instructions)) array_push($mailList, array('instructions'=>$instructionsNum)); if (!empty($remittance)) array_push($mailList, array('remittance'=>$remittance)); echo json_encode($mailList) ; print_r($mailList); die;
 
- 		 */
 
- 		
 
- 		if (! empty ( $cid ) && ! empty ( $invoicePrice ) && ! empty ( $invoiceElement )) {
 
- 			Doo::loadModel ( 'invoice' );
 
- 			$invoice = new invoice ();
 
- 			Doo::loadModel ( 'L_category' );
 
- 			$lCategory = new L_category ();
 
- 			Doo::loadModel ( 'invoiceManage' );
 
- 			$invoiceManage = new invoiceManage ();
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			Doo::loadModel ( 'invoiceStatistics' );
 
- 			$invoiceStatistics = new invoiceStatistics ();
 
- 			
 
- 			$categoryDetil = $lCategory->getOne ( array (
 
- 					'SELECT' => 'title',
 
- 					'where' => 'cid=' . $cid,
 
- 					'asArray' => true 
 
- 			) );
 
- 			
 
- 			$invoiceManageList = $invoiceManage->getInvoiceByAll ();
 
- 			$invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
 
- 			
 
- 			$moldManage = array ();
 
- 			foreach ( $invoiceManageList as $key => $value ) {
 
- 				if ($value ['mold'] == '发票打印')
 
- 					$moldManage [$value ['mold']] = $value ['staffList'];
 
- 				elseif ($value ['mold'] == '发票邮寄')
 
- 					$moldManage [$value ['mold']] = $value ['staffList'];
 
- 				elseif ($value ['mold'] == '发票退票')
 
- 					$moldManage [$value ['mold']] = $value ['staffList'];
 
- 			}
 
- 			
 
- 			$item = array (
 
- 					'cid' => $cid,
 
- 					'categoryName' => $categoryDetil ['title'],
 
- 					'invoiceElement' => $invoiceElement,
 
- 					'invoicePrice' => $invoicePrice,
 
- 					'invoiceType' => $invoiceType,
 
- 					'doPost' => $doPost,
 
- 					'status' => 1,
 
- 					'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 					'sid' => $this->staff [0] ['sid'],
 
- 					'userName' => $this->staff [0] ['username'],
 
- 					'invoiceManage' => $invoiceManageDetail ['staff'],
 
- 					'pendingApprovals' => $invoiceManageDetail ['staffList'] [0] [0],
 
- 					'moldManage' => json_encode ( $moldManage ),
 
- 					'remark' => $remark 
 
- 			);
 
- 			if ($invoiceType == 0)
 
- 				$item += array (
 
- 						'invoiceTitle' => $invoiceTitle,
 
- 						'TIN' => $TINT,
 
- 						'address' => $addressT,
 
- 						'phone' => $phoneT,
 
- 						'bank' => $bankT,
 
- 						'bankAccount' => $bankAccountT 
 
- 				);
 
- 			else {
 
- 				$item += array (
 
- 						'invoiceCompany' => $invoiceCompany,
 
- 						'TIN' => $TIN,
 
- 						'address' => $address,
 
- 						'phone' => $phone,
 
- 						'bank' => $bank,
 
- 						'bankAccount' => $bankAccount 
 
- 				);
 
- 			}
 
- 			if ($doPost == 1) {
 
- 				
 
- 				$mailList = array (
 
- 						'invoice' => 1,
 
- 						'mailItems' => $mailItems 
 
- 				);
 
- 				if (! empty ( $softLock ))
 
- 					$mailList += array (
 
- 							'softLock' => $softLockNum 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'softLock' => 0 
 
- 					);
 
- 				if (! empty ( $contract ))
 
- 					$mailList += array (
 
- 							'contract' => $contractNum 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'contract' => 0 
 
- 					);
 
- 				if (! empty ( $instructions ))
 
- 					$mailList += array (
 
- 							'instructions' => $instructionsNum 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'instructions' => 0 
 
- 					);
 
- 				if (! empty ( $remittance ))
 
- 					$mailList += array (
 
- 							'remittance' => $remittance 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'remittance' => '' 
 
- 					);
 
- 				
 
- 				$mailString = '发票x1,备注:' . $mailItems;
 
- 				if (! empty ( $softLock ))
 
- 					$mailString .= ',软件锁x' . $softLockNum;
 
- 				if (! empty ( $contract ))
 
- 					$mailString .= ',合同x' . $contractNum;
 
- 				if (! empty ( $instructions ))
 
- 					$mailString .= ',说明书x' . $instructionsNum;
 
- 				if (! empty ( $remittance ))
 
- 					$mailString .= ',汇款账号单';
 
- 				
 
- 				$item += array (
 
- 						'recipients' => $recipients,
 
- 						'recipientsPhone' => $recipientsPhone,
 
- 						'recipientsAddress' => $recipientsAddress,
 
- 						'mailItems' => $mailString,
 
- 						'mailItemsJson' => json_encode ( $mailList ) 
 
- 				);
 
- 			}
 
- 			
 
- 			$iid = $invoice->addInvoice ( $item );
 
- 			
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'operation' => "创建",
 
- 					'status' => 1,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'iid' => $iid 
 
- 			);
 
- 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'operation' => "提交审批",
 
- 					'status' => 1,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'iid' => $iid 
 
- 			);
 
- 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 			
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'priceClass' => 1,
 
- 					'cid' => $this->staff [0] ['cid'],
 
- 					'staff' => $this->staff [0] ['sid'],
 
- 					'invoicePrice' => $invoicePrice 
 
- 			);
 
- 			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 
- 		}
 
- 		
 
- 		return "/invoice";
 
- 	}
 
- 	function invoiceEdit() {
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		
 
- 		$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
 
- 		$iid = $XDeode->decode ( $iid );
 
- 		if (! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
 
- 		$operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
 
- 		
 
- 		$invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
 
- 		
 
- 		$this->data ['operation'] = $operation;
 
- 		$this->data ['invoiceDetail'] = $invoiceDetail;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoice';
 
- 		$this->render ( "/admin/invoiceEdit", $this->data );
 
- 	}
 
- 	/**
 
- 	 * 重新编辑退回的发票
 
- 	 * @return string
 
- 	 */
 
- 	function invoiceEditDo() {
 
- 		$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		$iid = $invoice->authcode ( $iidKey );
 
- 		if (! empty ( $iid ) && ! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
 
- 		$invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
 
- 		$doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
 
- 		$invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
 
- 		$invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
 
- 		$invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
 
- 		$invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
 
- 		$TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
 
- 		$address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
 
- 		$phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
 
- 		$bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
 
- 		$bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
 
- 		$recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
 
- 		$recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
 
- 		$recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
 
- 		
 
- 		$mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
 
- 		$remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
 
- 		
 
- 		$TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
 
- 		$addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
 
- 		$phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
 
- 		$bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
 
- 		$bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
 
- 		
 
- 		$softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
 
- 		$softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
 
- 		$contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
 
- 		$contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
 
- 		$instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
 
- 		$instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
 
- 		$remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
 
- 		
 
- 		if (! empty ( $cid ) && ! empty ( $invoicePrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
 
- 			
 
- 			Doo::loadModel ( 'invoiceManage' );
 
- 			$invoiceManage = new invoiceManage ();
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			$cid = explode ( ':', $cid );
 
- 			
 
- 			$invoiceManageList = $invoiceManage->getInvoiceByAll ();
 
- 			$invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
 
- 			
 
- 			$moldManage = array ();
 
- 			foreach ( $invoiceManageList as $key => $value ) {
 
- 				if ($value ['mold'] == '发票打印')
 
- 					$moldManage [$value ['mold']] = $value ['staffList'];
 
- 				elseif ($value ['mold'] == '发票邮寄')
 
- 					$moldManage [$value ['mold']] = $value ['staffList'];
 
- 				elseif ($value ['mold'] == '发票打印')
 
- 					$moldManage [$value ['mold']] = $value ['staffList'];
 
- 			}
 
- 			
 
- 			$item = array (
 
- 					'iid' => $iid,
 
- 					'cid' => $cid [0],
 
- 					'categoryName' => $cid [1],
 
- 					'invoiceElement' => $invoiceElement,
 
- 					'invoicePrice' => $invoicePrice,
 
- 					'invoiceType' => $invoiceType,
 
- 					'doPost' => $doPost,
 
- 					'status' => 1,
 
- 					'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 					'remark' => $remark 
 
- 			);
 
- 			if ($invoiceType == 0)
 
- 				$item += array (
 
- 						'invoiceTitle' => $invoiceTitle,
 
- 						
 
- 						'TIN' => $TINT,
 
- 						'address' => $addressT,
 
- 						'phone' => $phoneT,
 
- 						'bank' => $bankT,
 
- 						'bankAccount' => $bankAccountT 
 
- 				);
 
- 			else {
 
- 				$item += array (
 
- 						'invoiceCompany' => $invoiceCompany,
 
- 						'TIN' => $TIN,
 
- 						'address' => $address,
 
- 						'phone' => $phone,
 
- 						'bank' => $bank,
 
- 						'bankAccount' => $bankAccount 
 
- 				);
 
- 			}
 
- 			if ($doPost == 1) {
 
- 				
 
- 				$mailList = array (
 
- 						'invoice' => 1,
 
- 						'mailItems' => $mailItems 
 
- 				);
 
- 				if (! empty ( $softLock ))
 
- 					$mailList += array (
 
- 							'softLock' => $softLockNum 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'softLock' => '0' 
 
- 					);
 
- 				if (! empty ( $contract ))
 
- 					$mailList += array (
 
- 							'contract' => $contractNum 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'contract' => '0' 
 
- 					);
 
- 				if (! empty ( $instructions ))
 
- 					$mailList += array (
 
- 							'instructions' => $instructionsNum 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'instructions' => '0' 
 
- 					);
 
- 				if (! empty ( $remittance ))
 
- 					$mailList += array (
 
- 							'remittance' => $remittance 
 
- 					);
 
- 				else
 
- 					$mailList += array (
 
- 							'remittance' => '' 
 
- 					);
 
- 				
 
- 				$mailString = '发票x1,备注:' . $mailItems;
 
- 				if (! empty ( $softLock ))
 
- 					$mailString .= ',软件锁x' . $softLockNum;
 
- 				if (! empty ( $contract ))
 
- 					$mailString .= ',合同x' . $contractNum;
 
- 				if (! empty ( $instructions ))
 
- 					$mailString .= ',说明书x' . $instructionsNum;
 
- 				if (! empty ( $remittance ))
 
- 					$mailString .= ',汇款账号单';
 
- 				
 
- 				$item += array (
 
- 						'recipients' => $recipients,
 
- 						'recipientsPhone' => $recipientsPhone,
 
- 						'recipientsAddress' => $recipientsAddress,
 
- 						'mailItems' => $mailString,
 
- 						'mailItemsJson' => json_encode ( $mailList ) 
 
- 				);
 
- 			}
 
- 			$invoice->setInvoiceByCondition ( $item );
 
- 			
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'operation' => "重新提交审批",
 
- 					'status' => 1,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'iid' => $iid 
 
- 			);
 
- 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 		}
 
- 		
 
- 		return "/invoice";
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 终止开票
 
- 	 */
 
- 	function invoiceDroppedDo() {
 
- 		$droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$iid = $invoice->authcode ( $droppedIidKey );
 
- 		if (! empty ( $iid ) && ! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$item = array (
 
- 				'iid' => $iid,
 
- 				'status' => 4,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ) 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => '终止了开票',
 
- 				'status' => 4,
 
- 				'img' => $this->staff [0] ['avatar'],
 
- 				'username' => $this->staff [0] ['username'],
 
- 				'uid' => $this->staff [0] ['sid'],
 
- 				'category' => $this->staff [0] ['category'],
 
- 				'iid' => $iid 
 
- 		);
 
- 		$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 		return "/invoice";
 
- 	}
 
- 	/**
 
- 	 * 
 
- 	 * 申请退票 --
 
- 	*/
 
- 	function invoiceUntreadDo() {
 
- 		$untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
 
- 		$untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
 
- 		$untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : "";
 
- 		$untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
 
- 		$untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
 
- 		$untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$iid = $invoice->authcode ( $untreadIidKey );
 
- 		if (! empty ( $iid ) && ! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		/* 需求变革 有绑定收款也可以退票
 
- 		$lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey );
 
- 		if (! empty ( $lt )) {
 
- 			header ( 'Content-Type:text/html;charset=utf-8' );
 
- 			die ( '该发票有收款绑定,请先移除!' );
 
- 		}
 
- 		*/
 
- 			
 
- 		$item = array (
 
- 				'iid' => $iid,
 
- 				'untreadStatus' => 1,
 
- 				'untreadReason' => $untreadReason,
 
- 				'untreadPost' => $untreadPost,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ) 
 
- 		);
 
- 		if ($untreadPost == 1) {
 
- 			$item += array (
 
- 					'untreadCompany' => $untreadCompany,
 
- 					'untreadNumber' => $untreadNumber,
 
- 					'untreadItems' => $untreadItems 
 
- 			);
 
- 		}
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => '申请退票',
 
- 				'status' => 7,
 
- 				'img' => $this->staff [0] ['avatar'],
 
- 				'username' => $this->staff [0] ['username'],
 
- 				'uid' => $this->staff [0] ['sid'],
 
- 				'category' => $this->staff [0] ['category'],
 
- 				'iid' => $iid 
 
- 		);
 
- 		$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 		
 
- 		return "/invoice";
 
- 	}
 
- 	
 
- 		
 
- 	/**
 
- 	 * 删除已终止的开票
 
- 	 */
 
- 	function invoiceDelDo() {
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
 
- 		$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
 
- 		$iid = $XDeode->decode ( $iid );
 
- 		
 
- 		if (! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		$invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
 
- 		if (empty ( $invoiceDetail ))
 
- 			die ( 'illegal request' );
 
- 		$item = array (
 
- 				'iid' => $iid,
 
- 				'isDelete' => 1,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ) 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => '删除了已终止的发票',
 
- 				'status' => 4,
 
- 				'img' => $this->staff [0] ['avatar'],
 
- 				'username' => $this->staff [0] ['username'],
 
- 				'uid' => $this->staff [0] ['sid'],
 
- 				'category' => $this->staff [0] ['category'],
 
- 				'iid' => $iid 
 
- 		);
 
- 		$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 		return "/invoice";
 
- 	}
 
- 	function invoiceApproval() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$invoiceList = $invoice->find ( array (
 
- 				'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
 
- 				'desc' => 'iid',
 
- 				'asArray' => true 
 
- 		) );
 
- 		foreach ( $invoiceList as $key => $value ) {
 
- 			$invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 
- 			
 
- 			$lastApprover = json_decode ( $value ['processApprovals'], true );
 
- 			if (! empty ( $lastApprover )) {
 
- 				$lastApproverKey = array_keys ( $lastApprover );
 
- 				$lastApprover = end ( $lastApprover );
 
- 				
 
- 				$staffDetail = $staff->getOne ( array (
 
- 						'where' => 'sid=' . end ( $lastApproverKey ),
 
- 						'asArray' => true 
 
- 				) );
 
- 				$lastApprover ['username'] = $staffDetail ['username'];
 
- 			}
 
- 			$invoiceList [$key] ['lastApprover'] = $lastApprover;
 
- 		}
 
- 		
 
- 		$ilist = $invoice->getInvoiceByProcessStatus ();
 
- 		
 
- 		// print_r($ilist);
 
- 		
 
- 		$this->data ['invoiceList'] = $invoiceList;
 
- 		$this->data ['ilist'] = $ilist;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceApproval';
 
- 		$this->render ( "/admin/invoiceApproval", $this->data );
 
- 	}
 
- 	function invoiceDetail() {
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		
 
- 		$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
 
- 		$iid = $XDeode->decode ( $iid );
 
- 		if (! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$invoiceDetail = $invoice->getOne ( array (
 
- 				'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
 
- 				'asArray' => true 
 
- 		) );
 
- 		if (empty($invoiceDetail))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
 
- 		
 
- 		$this->data ['invoiceDetail'] = $invoiceDetail;
 
- 		$this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
 
- 		$this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceApproval';
 
- 		$this->render ( "/admin/invoiceApprovalDetail", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
 
- 	 *
 
- 	 * @since 1.0.0
 
- 	 * @var integer iid 开票ID 已加密
 
- 	 * @var integer status 发票审批状态
 
- 	 * @var integer opintion 审批发票的意见
 
- 	 * @return string 如操作成功返回审批首页
 
- 	 */
 
- 	function invoiceApprovalDo() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 
- 		$status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
 
- 		$opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
 
- 		$iid = $invoice->authcode ( $iid );
 
- 		if (! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		if (! empty ( $iid ) && ! empty ( $status ) && ! empty ( $opinion )) {
 
- 			if (! ($status == 2 || $status == 3 || $status == 4))
 
- 				die ( 'illegal request' );
 
- 			
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			$invoiceDetail = $invoice->getOne ( array (
 
- 					'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
 
- 					'asArray' => true 
 
- 			) );
 
- 			if (empty ( $invoiceDetail ))
 
- 				die ( 'illegal request' );
 
- 			
 
- 			$processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
 
- 			$invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
 
- 			
 
- 			if ($status == 3) {
 
- 				$invoice->status = $status;
 
- 				$item = array (
 
- 						'operation' => $opinion 
 
- 				);
 
- 			} else {
 
- 				if (empty ( $processApprovals )) {
 
- 					$processApprovals = array (
 
- 							$this->staff [0] ['sid'] => array (
 
- 									'date' => date ( "Y-m-d H:i:s" ),
 
- 									'opinion' => $opinion,
 
- 									'status' => $status 
 
- 							) 
 
- 					);
 
- 					if ($status != 4 && isset ( $invoiceManage [1] ))
 
- 						$invoice->pendingApprovals = $invoiceManage [1] [0];
 
- 					$invoice->processApprovals = json_encode ( $processApprovals );
 
- 				} else {
 
- 					$processApprovals [$this->staff [0] ['sid']] = array (
 
- 							'date' => date ( "Y-m-d H:i:s" ),
 
- 							'opinion' => $opinion,
 
- 							'status' => $status 
 
- 					);
 
- 					
 
- 					$pendingApprovals = 0;
 
- 					foreach ( $invoiceManage as $key => $value ) {
 
- 						if ($value [0] == $this->staff [0] ['sid']) {
 
- 							if (isset ( $invoiceManage [$key + 1] ))
 
- 								$pendingApprovals = $invoiceManage [$key + 1] [0];
 
- 							break;
 
- 						}
 
- 					}
 
- 					
 
- 					if ($status != 4 && ! empty ( $pendingApprovals ))
 
- 						$invoice->pendingApprovals = $pendingApprovals;
 
- 					$invoice->processApprovals = json_encode ( $processApprovals );
 
- 				}
 
- 				
 
- 				$item = array (
 
- 						'operation' => $opinion 
 
- 				);
 
- 				if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
 
- 					$invoice->status = $status;
 
- 					$invoice->pendingApprovals = 0;
 
- 				} elseif ($status == 4) {
 
- 					$invoice->status = $status;
 
- 					$item = array (
 
- 							'operation' => $opinion 
 
- 					);
 
- 				}
 
- 			}
 
- 			$invoice->updateTime = date ( "Y-m-d H:i:s" );
 
- 			$invoice->update ( array (
 
- 					'where' => 'iid=' . $iid 
 
- 			) );
 
- 			
 
- 			$item += array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'status' => $status,
 
- 					'iid' => $iid 
 
- 			);
 
- 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 			
 
- 			return '/invoiceApproval';
 
- 		}
 
- 		die ( 'illegal request' );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 展示需要打印的发票数据
 
- 	 *
 
- 	 * @since 1.0.0
 
- 	 */
 
- 	function invoicePrint() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
 
- 		$printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
 
- 		
 
- 		foreach ( $toPrint as $key => $value ) {
 
- 			$toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 
- 			
 
- 			$lastApprover = json_decode ( $value ['processApprovals'], true );
 
- 			if (! empty ( $lastApprover )) {
 
- 				$lastApproverKey = array_keys ( $lastApprover );
 
- 				$lastApprover = end ( $lastApprover );
 
- 				
 
- 				$staffDetail = $staff->getOne ( array (
 
- 						'where' => 'sid=' . end ( $lastApproverKey ),
 
- 						'asArray' => true 
 
- 				) );
 
- 				$lastApprover ['username'] = $staffDetail ['username'];
 
- 			}
 
- 			$toPrint [$key] ['lastApprover'] = $lastApprover;
 
- 		}
 
- 		
 
- 		foreach ( $printed as $key => $value ) {
 
- 			$printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 
- 			
 
- 			$lastApprover = json_decode ( $value ['processApprovals'], true );
 
- 			if (! empty ( $lastApprover )) {
 
- 				$lastApproverKey = array_keys ( $lastApprover );
 
- 				$lastApprover = end ( $lastApprover );
 
- 				
 
- 				$staffDetail = $staff->getOne ( array (
 
- 						'where' => 'sid=' . end ( $lastApproverKey ),
 
- 						'asArray' => true 
 
- 				) );
 
- 				$lastApprover ['username'] = $staffDetail ['username'];
 
- 			}
 
- 			$printed [$key] ['lastApprover'] = $lastApprover;
 
- 		}
 
- 		
 
- 		$this->data ['printed'] = $printed;
 
- 		$this->data ['toPrint'] = $toPrint;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoicePrint';
 
- 		$this->render ( "/admin/invoicePrint", $this->data );
 
- 	}
 
- 	/**
 
- 	 * 展示发票打印的详情页面
 
- 	 *
 
- 	 * @since 1.0.0
 
- 	 */
 
- 	function invoicePrintDetail() {
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		
 
- 		$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
 
- 		$iid = $XDeode->decode ( $iid );
 
- 		if (! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
 
- 		// if (empty ( $invoiceDetail ))
 
- 		// die ( 'illegal request' );
 
- 		
 
- 		$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
 
- 		
 
- 		$this->data ['invoiceDetail'] = $invoiceDetail;
 
- 		$this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
 
- 		$this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoicePrint';
 
- 		$this->render ( "/admin/invoicePrintDetail", $this->data );
 
- 	}
 
- 	/**
 
- 	 * 填写票号并完成打印
 
- 	 * @since 1.0.0
 
- 	 */
 
- 	function invoicePrintDo() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		$iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 
- 		$invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
 
- 		
 
- 		$iid = $invoice->authcode ( $iid );
 
- 		if (! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
 
- 			
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			$invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
 
- 			if (empty ( $invoicePrintDetail ))
 
- 				die ( 'illegal request' );
 
- 			$item = array (
 
- 					'iid' => $iid,
 
- 					'printStatus' => 1,
 
- 					'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 					'printer'=> $this->staff [0] ['username'],
 
- 					'printTime' => date ( "Y-m-d H:i:s" ),
 
- 					'invoiceNo' => $invoiceNo 
 
- 			);
 
- 			$invoice->setInvoiceByCondition ( $item );
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'operation' => $invoiceNo,
 
- 					'status' => 5,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'iid' => $iid 
 
- 			);
 
- 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 			return "/invoicePrint";
 
- 		}
 
- 	}
 
- 	/**
 
- 	 * 需要邮寄的发票
 
- 	 * @since 1.0.0
 
- 	 */
 
- 	function invoicePost() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'express' );
 
- 		$express = new express ();
 
- 		
 
- 		$invoicePost = $invoice->getPostByInvoice ();
 
- 		$invoicePosted = $invoice->getPostByInvoice ( 1 );
 
- 		$expressList = $express->getExpressByAll ();
 
- 		
 
- 		$this->data ['expressList'] = $expressList;
 
- 		$this->data ['invoicePost'] = $invoicePost;
 
- 		$this->data ['invoicePosted'] = $invoicePosted;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoicePost';
 
- 		$this->render ( "/admin/invoicePost", $this->data );
 
- 	}
 
- 	/**
 
- 	 * 添加发票邮寄信息
 
- 	 */
 
- 	function invoiceExpressAddDo() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 
- 		$expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
 
- 		$expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
 
- 		$actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
 
- 		$iid = $iid = $invoice->authcode ( $iid );
 
- 		if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$item = array (
 
- 				'iid' => $iid,
 
- 				'postStatus' => 1,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 				'postTime' => date ( "Y-m-d H:i:s" ),
 
- 				'expressCompany' => $expressCompany,
 
- 				'expressNumber' => $expressNumber,
 
- 				'actualItems' => $actualItems,
 
- 				'poster' => $this->staff [0] ['username'] 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		
 
- 		// $this->setWXMsg ( $iid, 41 );
 
- 		
 
- 		return '/invoicePost';
 
- 	}
 
- 	function invoiceExpressUpdateDo() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
 
- 		
 
- 		$iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 
- 		$expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
 
- 		$expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
 
- 		$actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
 
- 		$iid = $invoice->authcode ( $iid );
 
- 		if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$item = array (
 
- 				'iid' => $iid,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 				
 
- 				'expressCompany' => $expressCompany,
 
- 				'expressNumber' => $expressNumber,
 
- 				'actualItems' => $actualItems,
 
- 				'poster' => $this->staff [0] ['username'] 
 
- 		);
 
- 		
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		return $action;
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 可退票管理
 
- 	 */
 
- 	function invoiceUntreadIsAchieve(){
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$MebSea =$this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : ""; 
 
- 		
 
- 		$page_size = 18;
 
- 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 
- 		$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
 
- 		
 
- 		$get = "?date=" . urlencode ($date)."&MebSea=".urlencode ($MebSea);
 
- 		
 
- 		$dateArr=explode(':', $date);$D1='';$D2='';
 
- 		if (!empty($date)){
 
- 			$D1=$dateArr[0];
 
- 			$D2=$dateArr[1];
 
- 		}
 
- 		$con = '';
 
- 		if (!empty($D1)&&!empty($D2))
 
- 			$con=' and bindTime BETWEEN "'.$D1.'" AND "'.$D2.'" ';
 
- 		
 
- // 		if ($date == 'MONTHO')
 
- // 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
 
- // 		elseif ($date == 'MONTHT')
 
- // 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
 
- // 		elseif ($date == 'MONTHY')
 
- // 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 
- 		
 
- 		if (! empty ( $MebSea )) {
 
- 			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
 
- 		}
 
- 		$pageinfo ['page'] = array (
 
- 					'previous' => ''
 
- 		);
 
- 		
 
-  		$sql = " printStatus=1 and untreadStatus=0 and status=2 " . $con;
 
-  		$action = "invoiceUntreadIsAchieve";
 
- 			
 
- 		
 
- 		$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
 
- 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 
- 		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 
- 		
 
- 		Doo::loadModel ( 'express' );
 
- 		$express = new express ();
 
- 		$expressList = $express->getExpressByAll ();
 
- 		$this->data ['expressList'] = $expressList;
 
- 		
 
- 		//print_r($list);
 
- 		
 
- 		$this->data ['MebSeaEn'] = $MebSea;
 
- 		//$this->data ['MebSea'] = urlencode ( $MebSea );
 
- 		$this->data ['get'] = $get;
 
- 		$this->data ['page'] = $pageinfo;
 
- 		
 
- 		$this->data ['date'] = $date;
 
- 		$this->data ['list'] = $list;
 
-  		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoice';
 
- 		$this->render ( "/admin/invoiceUntreadIsAchieve", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 退票处理页面
 
- 	 */
 
- 	function invoiceUntread() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
 
- 		$establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
 
- 		
 
- 		$this->data ['untreadInvoice'] = $untreadInvoice;
 
- 		$this->data ['establishedInvoice'] = $establishedInvoice;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceUntread';
 
- 		$this->render ( "/admin/invoiceUntread", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 确认收到退回的发票,开票状态为退回
 
- 	 */
 
- 	function invoiceUntreadEstablishedDo() {
 
- 		$untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$iid = $invoice->authcode ( $untreadIidKey );
 
- 		if (! empty ( $iid ) && ! is_numeric ( $iid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$item = array (
 
- 				'iid' => $iid,
 
- 				'untreadStatus' => 2,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ) 
 
- 		);
 
- 		
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => '已确认退票',
 
- 				'status' => 6,
 
- 				'img' => $this->staff [0] ['avatar'],
 
- 				'username' => $this->staff [0] ['username'],
 
- 				'uid' => $this->staff [0] ['sid'],
 
- 				'category' => $this->staff [0] ['category'],
 
- 				'iid' => $iid 
 
- 		);
 
- 		$invoiceOperationLog->setInvoiceOperationLog ( $item );
 
- 		
 
- 		return "/invoiceUntread";
 
- 	}
 
- 	function invoiceReceivables() {
 
- 		$invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
 
- 		
 
- 		Doo::loadModel ( 'L_category' );
 
- 		$lCategory = new L_category ();
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		
 
- 		$category = $lCategory->getCategory ();
 
- 		$staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
 
- 		
 
- 		$sql = 'bindStatus=1 and iid!=0';
 
- 		$receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew (4,$sql);
 
- 		
 
- 		// 获取未入账发票
 
- 		$invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
 
- 		
 
- 		foreach ( $invoiceUnAccount as $key => $value ) {
 
- 			$invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 
- 			
 
- 			$lastApprover = json_decode ( $value ['processApprovals'], true );
 
- 			if (! empty ( $lastApprover )) {
 
- 				$lastApproverKey = array_keys ( $lastApprover );
 
- 				$lastApprover = end ( $lastApprover );
 
- 				
 
- 				$staffDetail = $staff->getOne ( array (
 
- 						'where' => 'sid=' . end ( $lastApproverKey ),
 
- 						'asArray' => true 
 
- 				) );
 
- 				$lastApprover ['username'] = $staffDetail ['username'];
 
- 			}
 
- 			$invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
 
- 		}
 
- 		
 
- 		$receivablesInput=$invoiceReceivables->getInvoiceReceivablesByInput();
 
- 		
 
- 		//print_r($receivablesInput);
 
- 		
 
- 		$this->data ['receivablesInput'] = $receivablesInput;
 
- 		$this->data ['year'] = date ( 'Y' );
 
- 		$this->data ['invoiceUnAccount'] = $invoiceUnAccount;
 
- 		$this->data ['receivablesList'] = $receivablesList;
 
- 		$this->data ['staffList'] = $staffList;
 
- 		$this->data ['category'] = $category;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceReceivables';
 
- 		$this->render ( "/admin/invoiceReceivables", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 新添加收款直接入账发票
 
- 	 */
 
- 	function invoiceCompareClaimPrice() {
 
- 		// 收款录入
 
- 		$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 
- 		
 
- 		$receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
 
- 		$receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
 
- 		$receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
 
- 		$receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
 
- 		
 
- 		if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
 
- 			Doo::loadModel ( 'invoiceReceivables' );
 
- 			$invoiceReceivables = new invoiceReceivables ();
 
- 			Doo::loadModel ( 'invoiceROLog' );
 
- 			$invoiceROLog = new invoiceROLog ();
 
- 			Doo::loadModel ( 'invoiceStatistics' );
 
- 			$invoiceStatistics = new invoiceStatistics ();
 
- 			Doo::loadModel ( 'invoice' );
 
- 			$invoice = new invoice ();
 
- 			Doo::loadClass ( 'XDeode' );
 
- 			$XDeode = new XDeode ( 5 );
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			$iidKey = $XDeode->decode ( $iidKey );
 
- 			
 
- 			$invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
 
- 			$receivablesSerial="#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
 
- 			
 
- 			// 收款录入 并绑定发票
 
- 			Doo::db ()->beginTransaction ();
 
- 			$item = array (
 
- 					'bindStatus' => 1,
 
- 					'iid' => $invoiceDetail ['iid'],
 
- 					'bindDate' => date ( "Y-m-d H:i:s" ),
 
- 					'receivablesPrice' => $receivablesPrice,
 
- 					'receivablesMessage' => $receivablesMessage,
 
- 					'receivablesSerial' => $receivablesSerial,
 
- 					'receivablesBank' => $receivablesBank,
 
- 					'receivablesDate' => $receivablesDate,
 
- 					'inputStaff' => $this->staff [0] ['username'],
 
- 					'date' => date ( "Y-m-d" ),
 
- 					'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
 
- 					'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
 
- 					'confirmTime' => date ( "Y-m-d H:i:s" ) 
 
- 			);
 
- 			
 
- 			$irid = $invoiceReceivables->addInvoiceReceivables ( $item );
 
- 			
 
- 			$item = array ();
 
- 			// 收款操作日志
 
- 			$item = array (
 
- 					'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName'] 
 
- 			);
 
- 			$item += array (
 
- 					'date' => date ( "Y-m-d" ),
 
- 					'status' => 1,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'irid' => $irid 
 
- 			);
 
- 			$invoiceROLog->setInvoiceROLog ( $item );
 
- 			// 收款统计
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'priceClass' => 2,
 
- 					'irid' => $irid,
 
- 					'cid' => $invoiceDetail ['cid'],
 
- 					'staff' => $invoiceDetail ['sid'],
 
- 					'receivablesPrice' => $receivablesPrice 
 
- 			);
 
- 			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 
- 			
 
- 			// 收款 入 发票
 
- 			$detail = $invoiceDetail;
 
- 			
 
- 			$iridString = "";
 
- 			if (empty ( $detail ['irid'] ))
 
- 				$iridString = $irid;
 
- 			else
 
- 				$iridString = $detail ['irid'] . ',' . $irid;
 
- 			
 
- 			$item = array (
 
- 					'irid' => $iridString,
 
- 					'bindTime' => date ( "Y-m-d H:i:s" ),
 
- 					'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 					'iid' => $detail ['iid'] 
 
- 			);
 
- 			$invoice->setInvoiceByCondition ( $item );
 
- 			
 
- 			// 操作日志
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'operation' => "收款入账" . $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 );
 
- 			Doo::db ()->commit ();
 
- 			
 
- 		}
 
- 		
 
- 		return '/invoiceReceivables';
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 检索未入账发票数据
 
- 	 */
 
- 	function sir() {
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 录入收款数据
 
- 	 * @return string
 
- 	 */
 
- 	function invoiceReceivablesDo() {
 
- 		$receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
 
- 		$receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
 
- 		$receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
 
- 		$receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
 
- 		$receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
 
- 		$receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceROLog' );
 
- 		$invoiceROLog = new invoiceROLog ();
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		
 
- 		if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
 
- 			
 
- 			$item = array (
 
- 					'receivablesPrice' => $receivablesPrice,
 
- 					'receivablesMessage' => $receivablesMessage,
 
- 					'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
 
- 					'receivablesBank' => $receivablesBank,
 
- 					'receivablesDate' => $receivablesDate,
 
- 					'inputStaff' => $this->staff [0] ['username'],
 
- 					'date' => date ( "Y-m-d" ),
 
- 					'receivablesCategory' => $receivablesCategory,
 
- 					'receivablesStaff' => $receivablesStaff 
 
- 			);
 
- 			if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
 
- 				$item += array (
 
- 						'confirmTime' => date ( "Y-m-d H:i:s" ),
 
- 						'inputType' => 1
 
- 				);
 
- 			}
 
- 			
 
- 			$irid = $invoiceReceivables->addInvoiceReceivables ( $item );
 
- 			
 
- 			$item = array ();
 
- 			// 收款操作日志
 
- 			if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
 
- 				$item = array (
 
- 						'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 " 
 
- 				);
 
- 			elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
 
- 				$item = array (
 
- 						'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项" 
 
- 				);
 
- 			elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
 
- 				$receivablesStaff = explode ( '-', $receivablesStaff );
 
- 				$item = array (
 
- 						'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1] 
 
- 				);
 
- 			}
 
- 			$item += array (
 
- 					'date' => date ( "Y-m-d" ),
 
- 					'status' => 1,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'irid' => $irid 
 
- 			);
 
- 			$invoiceROLog->setInvoiceROLog ( $item );
 
- 			
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d H:i:s" ),
 
- 					'priceClass' => 2,
 
- 					'irid' => $irid,
 
- 					'receivablesPrice' => $receivablesPrice 
 
- 			);
 
- 			if ($receivablesCategory != 'PUBLIC') {
 
- 				$receivablesCategory = explode ( ":", $receivablesCategory );
 
- 				$item += array (
 
- 						'cid' => $receivablesCategory [0] 
 
- 				);
 
- 			}
 
- 			
 
- 			if ($receivablesStaff2 != 'PUBLIC') {
 
- 				$receivablesStaff = explode ( "-", $receivablesStaff2 );
 
- 				$item += array (
 
- 						'staff' => $receivablesStaff [0] 
 
- 				);
 
- 			}
 
- 			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 
- 		}
 
- 		
 
- 		return "/invoiceReceivables";
 
- 	}
 
- 	/**
 
- 	 * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
 
- 	 */
 
- 	function invoiceReceivablesClaim() {
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'],$this->staff [0] ['sid'] );
 
- 		
 
- 		$this->data ['receivablesList'] = $receivablesList;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
 
- 		$this->render ( "/admin/invoiceReceivablesClaim", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 更新收款相关数据
 
- 	 */
 
- 	function invoiceReceivablesUpdateClaim() {
 
- 		$receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
 
- 		$receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
 
- 		$receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
 
- 		$receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
 
- 		$receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
 
- 		$receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
 
- 		
 
- 		$claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
 
- 		
 
- 		if (empty ( $claimKey ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceROLog' );
 
- 		$invoiceROLog = new invoiceROLog ();
 
- 		$con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
 
- 		$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
 
- 		if (empty ( $detail ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$item = array (
 
- 				'irid' => $detail ['irid'] 
 
- 		);
 
- 		if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
 
- 			$item += array (
 
- 					'confirmTime' => date ( "Y-m-d H:i:s" ) 
 
- 			);
 
- 		}
 
- 		if (! empty ( $receivablesCategory ))
 
- 			$item += array (
 
- 					'receivablesCategory' => $receivablesCategory 
 
- 			);
 
- 		if (! empty ( $receivablesStaff ))
 
- 			$item += array (
 
- 					'receivablesStaff' => $receivablesStaff 
 
- 			);
 
- 		if (! empty ( $receivablesPrice ))
 
- 			$item += array (
 
- 					'receivablesPrice' => $receivablesPrice 
 
- 			);
 
- 		if (! empty ( $receivablesMessage ))
 
- 			$item += array (
 
- 					'receivablesMessage' => $receivablesMessage 
 
- 			);
 
- 		if (! empty ( $receivablesBank ))
 
- 			$item += array (
 
- 					'receivablesBank' => $receivablesBank 
 
- 			);
 
- 		if (! empty ( $receivablesDate ))
 
- 			$item += array (
 
- 					'receivablesDate' => $receivablesDate 
 
- 			);
 
- 		$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 
- 		
 
- 		// 收款操作日志
 
- 		$item = array ();
 
- 		if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
 
- 			$item = array (
 
- 					'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 " 
 
- 			);
 
- 		elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
 
- 			$item = array (
 
- 					'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项" 
 
- 			);
 
- 		elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
 
- 			$receivablesStaff = explode ( '-', $receivablesStaff );
 
- 			$item = array (
 
- 					'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1] 
 
- 			);
 
- 		}
 
- 		$item += array (
 
- 				'date' => date ( "Y-m-d" ),
 
- 				'status' => 1,
 
- 				'img' => $this->staff [0] ['avatar'],
 
- 				'username' => $this->staff [0] ['username'],
 
- 				'uid' => $this->staff [0] ['sid'],
 
- 				'category' => $this->staff [0] ['category'],
 
- 				'irid' => $detail ['irid'] 
 
- 		);
 
- 		$invoiceROLog->setInvoiceROLog ( $item );
 
- 		
 
- 		return '/invoiceReceivablesAS';
 
- 	}
 
- 	function invoiceReceivablesDelete() {
 
- 		$claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
 
- 		
 
- 		if (empty ( $claimKey ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$con = ' and iid=0 and bindStatus=0 and receivablesStaff="PUBLIC"';
 
- 		$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
 
- 		if (empty ( $detail ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
 
- 		return '/invoiceReceivablesAS';
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
 
- 	 */
 
- 	function invoiceReceivablesAscription() {
 
- 		$irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		$recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceROLog' );
 
- 		$invoiceROLog = new invoiceROLog ();
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		
 
- 		$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
 
- 		
 
- 		if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC'&&!empty($recepitTitleMark)) {
 
- 			$item = array (
 
- 					'irid' => $detail ['irid'],
 
- 					'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
 
- 					'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
 
- 					'confirmTime' => date ( "Y-m-d H:i:s" ),
 
- 					'recepitTitleMark' => $recepitTitleMark,
 
- 					'source' => 1 
 
- 			);
 
- 			$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 
- 			
 
- 			$item = array (
 
- 					'date' => date ( "Y-m-d" ),
 
- 					'operation' => $this->staff [0] ['username'] . " 认领 ",
 
- 					'status' => 2,
 
- 					'img' => $this->staff [0] ['avatar'],
 
- 					'username' => $this->staff [0] ['username'],
 
- 					'uid' => $this->staff [0] ['sid'],
 
- 					'category' => $this->staff [0] ['category'],
 
- 					'irid' => $irid 
 
- 			);
 
- 			$invoiceROLog->setInvoiceROLog ( $item );
 
- 			
 
- 			$item = array (
 
- 					'cid' => $this->staff [0] ['cid'],
 
- 					'staff' => $this->staff [0] ['sid'] 
 
- 			);
 
- 			$invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'] );
 
- 		}
 
- 		
 
- 		return "/invoiceReceivablesClaim";
 
- 	}
 
- 	
 
- 	/**
 
- 	 */
 
- 	function invoiceMyReceivables() {
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		
 
- 		$isMonth = $invoiceStatistics->getStatisticsByMonth ();
 
- 		
 
- 		$year = date ( "Y" );
 
- 		$tmp_date = date ( "Ym" );
 
- 		$tmp_year = substr ( $tmp_date, 0, 4 );
 
- 		$tmp_mon = substr ( $tmp_date, 4, 2 );
 
- 		$tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
 
- 		$fm_forward_month = date ( "m", $tmp_forwardmonth );
 
- 		$path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
 
- 		$htm = $this->showCache ( $path );
 
- 		
 
- 		$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 
- 		
 
- 		$this->data ['isMonth'] = $isMonth;
 
- 		$this->data ['htm'] = $htm;
 
- 		$this->data ['list'] = $list;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceMyReceivables';
 
- 		$this->render ( "/admin/invoiceMyReceivables", $this->data );
 
- 	}
 
- 	
 
- 	/**
 
- 	 *
 
- 	 * 收款绑定发票 ,一个收款只能绑定一个发票 
 
- 	 */
 
- 	function invoiceBindReceivables() {
 
- 		$claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		$invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		if (empty ( $invoiceKey ) || empty ( $claimKey ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$detail = $invoice->getInvoiceByIid ( $invoiceKey );
 
- 		$detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
 
- 		
 
- 		if (empty ( $detail ) && empty ( $detailM ))
 
- 			die ( 'illegal request' );
 
- 		if(!empty($detail['irid']))	
 
- 			die ( 'illegal request' );
 
- 		
 
- 			// if ($detailM ['receivablesPrice'] >= $detail ['invoicePrice']) {
 
- 			// $price = $detailM ['receivablesPrice'] - $detail ['invoicePrice'];
 
- 			// die ( '<p>收款金额超出开票金额 ¥' . $price . '元,请谨慎操作</p><a href="/invoiceMyReceivables">返回</a>' );
 
- 			// }
 
- 		
 
- 		$item = array (
 
- 				'irid' => $detailM ['irid'],
 
- 				'bindStatus' => 1,
 
- 				'iid' => $detail ['iid'],
 
- 				'bindDate' => date ( "Y-m-d H:i:s" ) 
 
- 		);
 
- 		$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 
- 		
 
- 		$iridString = "";
 
- 		if (empty ( $detail ['irid'] ))
 
- 			$iridString = $detailM ['irid'];
 
- 		else
 
- 			$iridString = $detail ['irid'] . ',' . $detailM ['irid'];
 
- 		$item = array (
 
- 				'iid' => $detail ['iid'],
 
- 				'irid' => $iridString 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		
 
- 		// 操作日志
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => "收款" . $detailM ['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 "/invoiceReceivables";
 
- 	}
 
- 	
 
- 	
 
- 	/**
 
- 	 * @deprecated
 
- 	 * 发票收款完成--需求更变 废弃
 
- 	function invoiceEnterReceivables() {
 
- 		$invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		// $invoiceClaim = $this->get_args ( 'invoiceClaim' ) ? $this->get_args ( 'invoiceClaim' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$detail = $invoice->getInvoiceByIid ( $invoiceKey );
 
- 		
 
- 		if (empty ( $detail ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		if (empty ( $detail ['irid'] ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$item = array (
 
- 				'untreadStatus' => 3,
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 				'iid' => $detail ['iid'] 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		
 
- 		// 操作日志
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => "发票" . $detail ['invoiceSerial'] . "收款完成",
 
- 				'status' => 9,
 
- 				'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 );
 
- 		
 
- 		$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
 
- 		$accountPrice = 0;
 
- 		foreach ( $list as $key => $value ) {
 
- 			$accountPrice += $value ['receivablesPrice'];
 
- 		}
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'priceClass' => 3,
 
- 				
 
- 				'cid' => $this->staff [0] ['cid'],
 
- 				'staff' => $this->staff [0] ['sid'],
 
- 				'accountPrice' => $accountPrice 
 
- 		);
 
- 		$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 
- 		
 
- 		return "/invoice";
 
- 	}
 
- 	*/
 
- 	
 
- 	function invoiceAggregate() {
 
- 		$year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
 
- 		
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		Doo::loadModel ( 'L_category' );
 
- 		$Lcategory = new L_category ();
 
- 		
 
- 		$isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
 
- 		$LcategoryList = $Lcategory->getCategory ();
 
- 		// print_r($isList);
 
- 		
 
- 		$html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
 
- 		foreach ( $LcategoryList as $key => $value ) {
 
- 			$html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
 
- 			$month = 1;
 
- 			$invoicePriceYear = 0;
 
- 			$receivablesPriceYear = 0;
 
- 			$accountPriceYear = 0;
 
- 			for(; $month <= 12; $month ++) {
 
- 				$flag = true;
 
- 				foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
 
- 					if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
 
- 						$html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
 
- 								<td class="taR">¥' . $v ['receivablesPrice'] . '</td>
 
- 								<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
 
- 								';
 
- 						$invoicePriceYear += $v ['invoicePrice'];
 
- 						$receivablesPriceYear += $v ['receivablesPrice'];
 
- 						$accountPriceYear += $v ['accountPrice'];
 
- 						$flag = false;
 
- 						break;
 
- 					}
 
- 				}
 
- 				if ($flag)
 
- 					$html .= '<td class="taR"></td>
 
- 								<td class="taR"></td>
 
- 								<td class="taR"><b></b></td>
 
- 								';
 
- 			}
 
- 			$html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
 
- 					<td class="taR colOrange">' . $receivablesPriceYear . '</td>
 
- 					<td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
 
- 								';
 
- 			$html .= '</tr>';
 
- 		}
 
- 		
 
- 		$html .= '<tr><th><b class="colGreen">月合计</b></th>';
 
- 		$invoicePriceYear = 0;
 
- 		$receivablesPriceYear = 0;
 
- 		$accountPriceYear = 0;
 
- 		for($month = 1; $month <= 12; $month ++) {
 
- 			$flag = true;
 
- 			foreach ( $isList ['statisticsMonth'] as $k => $v ) {
 
- 				if ($month == $v ['month']) {
 
- 					$html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
 
- 							<td class="taR">¥' . $v ['receivablesPrice'] . '</td>
 
- 							<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
 
- 								';
 
- 					$invoicePriceYear += $v ['invoicePrice'];
 
- 					$receivablesPriceYear += $v ['receivablesPrice'];
 
- 					$accountPriceYear += $v ['accountPrice'];
 
- 					$flag = false;
 
- 					break;
 
- 				}
 
- 				if ($flag)
 
- 					$html .= '<td class="taR"></td>
 
- 								<td class="taR"></td>
 
- 								<td class="taR"><b></b></td>
 
- 								';
 
- 			}
 
- 		}
 
- 		$html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
 
- 				<td class="taR colOrange">' . $receivablesPriceYear . '</td>
 
- 				<td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
 
- 				';
 
- 		$html .= '</tr>';
 
- 		
 
- 		$this->data ['html'] = $html;
 
- 		$this->data ['LcategoryList'] = $LcategoryList;
 
- 		$this->data ['isList'] = $isList;
 
- 		
 
- 		$this->data ['year'] = $year;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceAggregate';
 
- 		$this->render ( "/admin/invoiceAggregate", $this->data );
 
- 	}
 
- 	function invoiceAggregateStaff() {
 
- 		$year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
 
- 		
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		Doo::loadModel ( 'L_category' );
 
- 		$Lcategory = new L_category ();
 
- 		
 
- 		$toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
 
- 		$staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
 
- 		$cStaff = $Lcategory->getCategoryStaff ();
 
- 		
 
- 		$html = '';
 
- 		foreach ( $cStaff as $key => $value ) {
 
- 			$categoryFir = true;
 
- 			foreach ( $value ['staff'] as $k => $v ) {
 
- 				if ($categoryFir) {
 
- 					$width = count ( $value ['staff'] ) + 1;
 
- 					$html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
 
- 					$categoryFir = false;
 
- 				} else
 
- 					$html .= '<tr>';
 
- 				$html .= '<th>' . $v ['username'] . '</th>';
 
- 				$invoicePriceStaffYear = 0;
 
- 				$receivablesPriceStaffYear = 0;
 
- 				$accountPriceStaffYear = 0;
 
- 				for($month = 1; $month <= 12; $month ++) {
 
- 					$flag = true;
 
- 					foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
 
- 						if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
 
- 							$html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
 
- 							<td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
 
- 							<td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
 
- 								';
 
- 							$invoicePriceStaffYear += $slv ['invoicePrice'];
 
- 							$receivablesPriceStaffYear += $slv ['receivablesPrice'];
 
- 							$accountPriceStaffYear += $slv ['accountPrice'];
 
- 							$flag = false;
 
- 							break;
 
- 						}
 
- 					}
 
- 					if ($flag)
 
- 						$html .= '<td class="taR"></td>
 
- 								<td class="taR"></td>
 
- 								<td class="taR"><b></b></td>
 
- 								';
 
- 				}
 
- 				$html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
 
- 					<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
 
- 					<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
 
- 								';
 
- 			}
 
- 			$html .= '</tr>';
 
- 			
 
- 			// 小计
 
- 			if (! empty ( $value ['staff'] )) {
 
- 				$html .= '<tr><th class="taR">小计</th>';
 
- 				$invoicePriceStaffYear = 0;
 
- 				$receivablesPriceStaffYear = 0;
 
- 				$accountPriceStaffYear = 0;
 
- 				for($month = 1; $month <= 12; $month ++) {
 
- 					$flag = true;
 
- 					foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
 
- 						if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
 
- 							$html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
 
- 							<td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
 
- 							<td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
 
- 								';
 
- 							$invoicePriceStaffYear += $slv ['invoicePrice'];
 
- 							$receivablesPriceStaffYear += $slv ['receivablesPrice'];
 
- 							$accountPriceStaffYear += $slv ['accountPrice'];
 
- 							$flag = false;
 
- 							break;
 
- 						}
 
- 					}
 
- 					if ($flag)
 
- 						$html .= '<td class="taR"></td>
 
- 								<td class="taR"></td>
 
- 								<td class="taR"><b></b></td>
 
- 								';
 
- 				}
 
- 				$html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
 
- 					<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
 
- 					<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
 
- 								';
 
- 				$html .= '</tr>';
 
- 			}
 
- 		}
 
- 		
 
- 		$html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
 
- 		$invoicePriceYear = 0;
 
- 		$receivablesPriceYear = 0;
 
- 		$accountPriceYear = 0;
 
- 		for($month = 1; $month <= 12; $month ++) {
 
- 			$flag = true;
 
- 			foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
 
- 				if ($month == $v ['month']) {
 
- 					$html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
 
- 							<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
 
- 							<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
 
- 								';
 
- 					$invoicePriceYear += $v ['invoicePrice'];
 
- 					$receivablesPriceYear += $v ['receivablesPrice'];
 
- 					$accountPriceYear += $v ['accountPrice'];
 
- 					$flag = false;
 
- 					break;
 
- 				}
 
- 				if ($flag)
 
- 					$html .= '<td class="taR"></td>
 
- 								<td class="taR"></td>
 
- 								<td class="taR"><b></b></td>
 
- 								';
 
- 			}
 
- 		}
 
- 		$html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
 
- 				<td class="taR colOrange">' . $receivablesPriceYear . '</td>
 
- 				<td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
 
- 				';
 
- 		$html .= '</tr>';
 
- 		
 
- 		$this->data ['html'] = $html;
 
- 		$this->data ['isList'] = $toteList;
 
- 		$this->data ['year'] = $year;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceAggregate';
 
- 		$this->render ( "/admin/invoiceAggregateStaff", $this->data );
 
- 	}
 
- 	function invoiceAggregateCategory() {
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		
 
- 		$cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
 
- 		$cid = $XDeode->decode ( $cid );
 
- 		if (! is_numeric ( $cid ))
 
- 			die ( 'illegal request' );
 
- 		
 
- 		$year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
 
- 		
 
- 		Doo::loadModel ( 'invoiceStatistics' );
 
- 		$invoiceStatistics = new invoiceStatistics ();
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$list = $staff->getStaffByCid ( $cid );
 
- 		$isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
 
- 		$toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
 
- 		
 
- 		if (empty ( $list ))
 
- 			die ( '该办事处没有成员' );
 
- 		$htmlA = $htmlB = $htmlC = $html = '';
 
- 		foreach ( $list as $key => $value ) {
 
- 			$htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
 
- 			$htmlB = '<tr><th class="taC">收款</th>';
 
- 			$htmlC = '<tr><th class="taC">入账</th>';
 
- 			$invoicePriceStaffYear = 0;
 
- 			$receivablesPriceStaffYear = 0;
 
- 			$accountPriceStaffYear = 0;
 
- 			for($month = 1; $month <= 12; $month ++) {
 
- 				$flag = true;
 
- 				foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
 
- 					if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
 
- 						$htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
 
- 						$htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
 
- 						$htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
 
- 						$invoicePriceStaffYear += $v ['invoicePrice'];
 
- 						$receivablesPriceStaffYear += $v ['receivablesPrice'];
 
- 						$accountPriceStaffYear += $v ['accountPrice'];
 
- 						$flag = false;
 
- 						break;
 
- 					}
 
- 				}
 
- 				if ($flag) {
 
- 					$htmlA .= '<td class="taR">-</td>';
 
- 					$htmlB .= '<td class="taR">-</td>';
 
- 					$htmlC .= '<td class="taR"><b>-</b></td>';
 
- 				}
 
- 			}
 
- 			$htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
 
- 			$htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
 
- 			$htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
 
- 			
 
- 			$htmlA .= '</tr>';
 
- 			$htmlB .= '</tr>';
 
- 			$htmlC .= '</tr>';
 
- 			$html .= $htmlA . $htmlB . $htmlC;
 
- 		}
 
- 		
 
- 		$htmlA = $htmlB = $htmlC = "";
 
- 		
 
- 		$htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
 
- 		$htmlB = '<tr><th class="taC">收款</th>';
 
- 		$htmlC = '<tr><th class="taC">入账</th>';
 
- 		$invoicePriceStaffYear = 0;
 
- 		$receivablesPriceStaffYear = 0;
 
- 		$accountPriceStaffYear = 0;
 
- 		for($month = 1; $month <= 12; $month ++) {
 
- 			$flag = true;
 
- 			foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
 
- 				if ($month == $v ['month']) {
 
- 					$htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
 
- 					$htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
 
- 					$htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
 
- 					$invoicePriceStaffYear += $v ['invoicePrice'];
 
- 					$receivablesPriceStaffYear += $v ['receivablesPrice'];
 
- 					$accountPriceStaffYear += $v ['accountPrice'];
 
- 					$flag = false;
 
- 					break;
 
- 				}
 
- 			}
 
- 			if ($flag) {
 
- 				$htmlA .= '<td class="taR">-</td>';
 
- 				$htmlB .= '<td class="taR">-</td>';
 
- 				$htmlC .= '<td class="taR"><b>-</b></td>';
 
- 			}
 
- 		}
 
- 		$htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
 
- 		$htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
 
- 		$htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
 
- 		
 
- 		$htmlA .= '</tr>';
 
- 		$htmlB .= '</tr>';
 
- 		$htmlC .= '</tr>';
 
- 		$html .= $htmlA . $htmlB . $htmlC;
 
- 		
 
- 		$this->data ['html'] = $html;
 
- 		
 
- 		$this->data ['cidKey'] = $cidKey;
 
- 		$this->data ['slist'] = $list;
 
- 		$this->data ['isList'] = $toteList;
 
- 		$this->data ['year'] = $year;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceAggregate';
 
- 		$this->render ( "/admin/invoiceAggregateCategory", $this->data );
 
- 	}
 
- 	function invoiceAchieve() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
 
- 		$MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
 
- 		
 
- 		$page_size = 18;
 
- 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 
- 		$date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
 
- 		
 
- 		$get = "/" . $date;
 
- 		
 
- 		$con = '';
 
- 		if ($date == 'MONTHO')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
 
- 		elseif ($date == 'MONTHT')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
 
- 		elseif ($date == 'MONTHY')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 
- 		
 
- 		if (! empty ( $MebSea )) {
 
- 			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
 
- 			$get .= "/" . $MebSea;
 
- 		}
 
- 		$pageinfo ['page'] = array (
 
- 				'previous' => '' 
 
- 		);
 
- 		$sql = 'status=2 and untreadStatus=3 and sid=' . $sid . $con;
 
- 		$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceAchieve", $get, "" );
 
- 		
 
- 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 
- 		
 
- 		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 
- 		// print_r($pageinfo);
 
- 		$this->data ['MebSeaEn'] = $MebSea;
 
- 		$this->data ['MebSea'] = urlencode ( $MebSea );
 
- 		$this->data ['get'] = $get;
 
- 		$this->data ['page'] = $pageinfo;
 
- 		$this->data ['list'] = $list;
 
- 		$this->data ['date'] = $date;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoice';
 
- 		$this->render ( "/admin/invoiceAchieve", $this->data );
 
- 	}
 
- 	function invoiceReceivablesAchieve() {
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		$sid = $XDeode->decode ( $_COOKIE ["staff"] );
 
- 		$MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
 
- 		
 
- 		$page_size = 1;
 
- 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 
- 		$date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
 
- 		
 
- 		$get = "/" . $date;
 
- 		
 
- 		$con = '';
 
- 		if ($date == 'MONTHO')
 
- 			$con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
 
- 		elseif ($date == 'MONTHT')
 
- 			$con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
 
- 		elseif ($date == 'MONTHY')
 
- 			$con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 
- 		
 
- 		if (! empty ( $MebSea )) {
 
- 			$con .= ' and ( receivablesMessage like "%' . $MebSea . '%"  or receivablesPrice like "%' . $MebSea . '%" )';
 
- 			$get .= "/" . $MebSea;
 
- 		}
 
- 		$pageinfo ['page'] = array (
 
- 				'previous' => '' 
 
- 		);
 
- 		$sql = " bindStatus=1 and receivablesStaff like '" . $sid . "_%' " . $con;
 
- 		$pageinfo = $this->get_page ( "CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve", $get, "" );
 
- 		
 
- 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 
- 		
 
- 		$list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $sql );
 
- 		// print_r($pageinfo);
 
- 		$this->data ['MebSeaEn'] = $MebSea;
 
- 		$this->data ['MebSea'] = urlencode ( $MebSea );
 
- 		$this->data ['get'] = $get;
 
- 		$this->data ['page'] = $pageinfo;
 
- 		$this->data ['list'] = $list;
 
- 		$this->data ['date'] = $date;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceMyReceivables';
 
- 		$this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
 
- 	}
 
- 	function invoiceReceivablesAS() {
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$MebSea = isset ( $this->params ['MebSea'] ) ? addslashes ( urldecode ( $this->params ['MebSea'] ) ) : '';
 
- 		
 
- 		$page_size = 12;
 
- 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 
- 		$status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
 
- 		
 
- 		$year = isset ( $this->params ['year'] ) && is_numeric ( $this->params ['year'] ) ? $this->params ['year'] : date ( 'Y' );
 
- 		$month = isset ( $this->params ['month'] ) && is_numeric ( $this->params ['month'] ) ? $this->params ['month'] : "All";
 
- 		
 
- 		$con = "Year(date) =" . $year;
 
- 		if ($month != "All")
 
- 			$con = "Year(date) =" . $year . " and Month(date) = " . $month;
 
- 		
 
- 		if ($status == 'Unclaimed')
 
- 			$con .= ' and bindStatus=0';
 
- 		elseif ($status == 'Credited')
 
- 			$con .= ' and bindStatus=1';
 
- 		
 
- 		$get = "/" . $status . "/" . $year . "/" . $month;
 
- 		
 
- 		if (! empty ( $MebSea )) {
 
- 			$con .= ' and ( receivablesMessage like "%' . $MebSea . '%"  or receivablesPrice like "%' . $MebSea . '%" )';
 
- 			$get .= "/" . $MebSea;
 
- 		}
 
- 		$pageinfo ['page'] = array (
 
- 				'previous' => '' 
 
- 		);
 
- 		$pageinfo = $this->get_page ( "CLD_invoiceReceivables", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
 
- 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 
- 		
 
- 		$list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $con );
 
- 		// print_r($pageinfo);
 
- 		$mothHtml = "";
 
- 		for($i = 1; $i <= 12; $i ++) {
 
- 			if ($month == $i)
 
- 				$mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
 
- 			else
 
- 				$mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
 
- 		}
 
- 		
 
- 		$this->data ['MebSeaEn'] = $MebSea;
 
- 		$this->data ['MebSea'] = urlencode ( $MebSea );
 
- 		$this->data ['mothHtml'] = $mothHtml;
 
- 		$this->data ['year'] = $year;
 
- 		$this->data ['month'] = $month;
 
- 		$this->data ['page'] = $pageinfo;
 
- 		$this->data ['get'] = $get;
 
- 		$this->data ['list'] = $list;
 
- 		$this->data ['status'] = $status;
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceReceivables';
 
- 		$this->render ( "/admin/invoiceReceivablesAS", $this->data );
 
- 	}
 
- 	function invoiceApprovalAchieve() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
 
- 		
 
- 		$page_size = 2;
 
- 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 
- 		$date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
 
- 		
 
- 		$get = "/" . $date;
 
- 		
 
- 		$con = '';
 
- 		if ($date == 'MONTHO')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
 
- 		elseif ($date == 'MONTHT')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
 
- 		elseif ($date == 'MONTHY')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 
- 		
 
- 		if (! empty ( $MebSea )) {
 
- 			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
 
- 			$get .= "/" . $MebSea;
 
- 		}
 
- 		$pageinfo ['page'] = array (
 
- 				'previous' => '' 
 
- 		);
 
- 		$sql = '(status=1 or status=3 or status=4) and processApprovals!=""' . $con;
 
- 		$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", $get, "" );
 
- 		
 
- 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 
- 		
 
- 		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 
- 		// print_r($list);
 
- 		$this->data ['MebSeaEn'] = $MebSea;
 
- 		$this->data ['MebSea'] = urlencode ( $MebSea );
 
- 		$this->data ['get'] = $get;
 
- 		$this->data ['page'] = $pageinfo;
 
- 		$this->data ['list'] = $list;
 
- 		$this->data ['date'] = $date;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		$this->data ['receiptMemu'] = 'invoiceApproval';
 
- 		$this->render ( "/admin/invoiceApprovalAchieve", $this->data );
 
- 	}
 
- 	function invoiceTAchieve() {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadClass ( 'XDeode' );
 
- 		$XDeode = new XDeode ( 5 );
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
 
- 		
 
- 		$page_size = 2;
 
- 		$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 
- 		$date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
 
- 		
 
- 		$get = "/" . $date;
 
- 		
 
- 		$con = '';
 
- 		if ($date == 'MONTHO')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
 
- 		elseif ($date == 'MONTHT')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
 
- 		elseif ($date == 'MONTHY')
 
- 			$con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
 
- 		
 
- 		if (! empty ( $MebSea )) {
 
- 			$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
 
- 			$get .= "/" . $MebSea;
 
- 		}
 
- 		$pageinfo ['page'] = array (
 
- 				'previous' => '' 
 
- 		);
 
- 		
 
- 		$sql = "";
 
- 		$action = "";
 
- 		if ($this->ACTION == 'invoicePrintAchieve') {
 
- 			$sql = "status=2 and printStatus=1 and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
 
- 			$action = "invoicePrintAchieve";
 
- 		} elseif ($this->ACTION == 'invoicePostAchieve') {
 
- 			// and untreadStatus=0
 
- 			$sql = "postStatus=1 and doPost=1 and status=2 and isDelete=0" . $con;
 
- 			$action = "invoicePostAchieve";
 
- 		} elseif ($this->ACTION == 'invoiceUntreadAchieve') {
 
- 			$sql = " printStatus=1 and untreadStatus=2 and status=2 " . $con;
 
- 			$action = "invoiceUntreadAchieve";
 
- 		}
 
- 		
 
- 		$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
 
- 		$limit = $pageinfo ['lower'] . ',' . $page_size;
 
- 		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
 
- 		
 
- 		$this->data ['MebSeaEn'] = $MebSea;
 
- 		$this->data ['MebSea'] = urlencode ( $MebSea );
 
- 		$this->data ['get'] = $get;
 
- 		$this->data ['page'] = $pageinfo;
 
- 		
 
- 		$this->data ['date'] = $date;
 
- 		
 
- 		$this->data ['memu'] = "invoice";
 
- 		$this->data ['staff'] = $this->staff;
 
- 		
 
- 		if ($this->ACTION == 'invoicePrintAchieve') {
 
- 			foreach ( $list as $key => $value ) {
 
- 				$list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
 
- 				
 
- 				$lastApprover = json_decode ( $value ['processApprovals'], true );
 
- 				if (! empty ( $lastApprover )) {
 
- 					$lastApproverKey = array_keys ( $lastApprover );
 
- 					$lastApprover = end ( $lastApprover );
 
- 					
 
- 					$staffDetail = $staff->getOne ( array (
 
- 							'where' => 'sid=' . end ( $lastApproverKey ),
 
- 							'asArray' => true 
 
- 					) );
 
- 					$lastApprover ['username'] = $staffDetail ['username'];
 
- 				}
 
- 				$list [$key] ['lastApprover'] = $lastApprover;
 
- 			}
 
- 			$this->data ['receiptMemu'] = 'invoicePrint';
 
- 			$this->data ['list'] = $list;
 
- 			$this->render ( "/admin/invoicePrintAchieve", $this->data );
 
- 		} elseif ($this->ACTION == 'invoicePostAchieve') {
 
- 			
 
- 			Doo::loadModel ( 'express' );
 
- 			$express = new express ();
 
- 			$expressList = $express->getExpressByAll ();
 
- 			
 
- 			$this->data ['expressList'] = $expressList;
 
- 			$this->data ['receiptMemu'] = 'invoicePost';
 
- 			$this->data ['list'] = $list;
 
- 			$this->render ( "/admin/invoicePostAchieve", $this->data );
 
- 		} elseif ($this->ACTION == 'invoiceUntreadAchieve') {
 
- 			
 
- 			$this->data ['receiptMemu'] = 'invoiceUntread';
 
- 			$this->data ['list'] = $list;
 
- 			$this->render ( "/admin/invoiceUntreadAchieve", $this->data );
 
- 		}
 
- 	}
 
- 	
 
- 	/**
 
- 	 * @deprecated
 
- 	 * 获得与我有关可收款的发票  废弃
 
- 	function ajaxGetInvoiceByStaff() {
 
- 		$irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$list = $invoice->getInvoiceByReceivables ( $this->staff [0] ['sid'] );
 
- 		
 
- 		$html = "";
 
- 		$i = 1;
 
- 		foreach ( $list as $key => $value ) {
 
- 			$html .= '<tr>
 
- 					<td>' . $value ['invoiceElement'] . '</td>
 
- 					<td>¥' . $value ['invoicePrice'] . '</td>';
 
- 			if (! empty ( $value ['invoiceType'] )) {
 
- 				$html .= '<td>增值税专用发票</td>
 
- 							<td>' . $value ['invoiceCompany'] . '</td>';
 
- 			} else {
 
- 				$html .= '<td>增值税普通发票</td>
 
- 							<td>' . $value ['invoiceTitle'] . '</td>';
 
- 			}
 
- 			
 
- 			$html .= '<td><label><input type="radio" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim"> 使用Ta</label></td></tr>
 
- 					<script>
 
- 					$(\'input[node-Claim="true_' . $i . '"]\').click(function() {
 
- 					
 
- 						var invoiceKey=  $(this).attr("p-data");
 
- 						var claimKey=$("input[name=\'key\']").val();
 
- 						$("p[node-msg=\"true\"]").hide();
 
- 						
 
- 						var url = "/ajaxCompareInvoicePrice";
 
- 						$.ajax({
 
- 							url : url,
 
- 							type : "post",
 
- 							cache : false,
 
- 							dataType : "json",
 
- 							data : {
 
- 								claimKey : claimKey,
 
- 								invoiceKey:invoiceKey
 
- 							},
 
- 							global : true,
 
- 							success : function(data) {
 
- 								$("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
 
- 								if (data.status == 1) {
 
- 									
 
- 									$("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 									$("p[node-msg=\"true\"]").show();
 
- 								}
 
- 							},
 
- 							error : function(err) {
 
- 							}
 
- 						});
 
- 					});
 
- 					</script>
 
- 					';
 
- 			$i ++;
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'html' => $html 
 
- 		) );
 
- 	}
 
- 	*/
 
- 	
 
- 	/**
 
- 	 * 获取一条收款信息
 
- 	 */
 
- 	function ajaxGetInvoiceReceivables() {
 
- 		$irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'detail' => $detail 
 
- 		) );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 异步获取办事处用户
 
- 	 */
 
- 	function ajaxGetStaffByCategory() {
 
- 		$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		if ($cid == "PUBLIC") {
 
- 			echo json_encode ( array (
 
- 					'status' => 1,
 
- 					'html' => '<option value="PUBLIC">办事处待认领款项</option>' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		if (! is_numeric ( $cid )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 0,
 
- 					'msg' => 'illegal request' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		$staffList = $staff->getStaffByCid ( $cid );
 
- 		
 
- 		$html = '<option value="PUBLIC">办事处待认领款项</option>';
 
- 		foreach ( $staffList as $key => $value ) {
 
- 			$html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'html' => $html 
 
- 		) );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 异步获取一条发票的邮寄信息
 
- 	 */
 
- 	function ajaxGetInvoicePostDetail() {
 
- 		$iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		$iid = $invoice->authcode ( $iid );
 
- 		Doo::loadModel ( 'express' );
 
- 		$express = new express ();
 
- 		$expressList = $express->getExpressByAll ();
 
- 		
 
- 		if (! is_numeric ( $iid )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 0,
 
- 					'msg' => 'illegal request' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		$select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
 
- 		$invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
 
- 		
 
- 		$html = "";
 
- 		foreach ( $expressList as $key => $value ) {
 
- 			if ($value ['company'] == $invoiceDetail ['expressCompany'])
 
- 				$html .= '<option selected value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
 
- 			else
 
- 				$html .= '<option value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
 
- 		}
 
- 		
 
- 		$invoiceDetail ['eaHtml'] = $html;
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'invoiceDetail' => $invoiceDetail 
 
- 		) );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * @deprecated
 
- 	 * --需求变更 废弃
 
- 	function ajaxCompareClaimPrice() {
 
- 		$irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
 
- 		$invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$detail = $invoice->getInvoiceByIid ( $invoiceKey );
 
- 		$detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
 
- 		
 
- 		if (empty ( $detail ) || empty ( $detailM )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 2,
 
- 					'msg' => '非法请求,请重新登录' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		$iridString = "";
 
- 		if (empty ( $detail ['irid'] ))
 
- 			$iridString = $detailM ['irid'];
 
- 		else
 
- 			$iridString = $detail ['irid'] . ',' . $detailM ['irid'];
 
- 		
 
- 		$item = array (
 
- 				'irid' => $iridString,
 
- 				'bindTime' => date ( "Y-m-d H:i:s" ),
 
- 				'updateTime' => date ( "Y-m-d H:i:s" ),
 
- 				'iid' => $detail ['iid'] 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		
 
- 		// 操作日志
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => "收款入账" . $detailM ['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 );
 
- 		
 
- 		$item = array (
 
- 				'iid' => $detail ['iid'],
 
- 				'irid' => $detailM ['irid'],
 
- 				'bindDate' => date ( "Y-m-d H:i:s" ),
 
- 				'bindStatus' => 1 
 
- 		);
 
- 		$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 
- 		
 
- 		$price = 0;
 
- 		$priceStatus = 0;
 
- 		$isReceivables = 0;
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
 
- 		if (! empty ( $list ))
 
- 			$isReceivables = 1;
 
- 		$receivablesPrice = 0;
 
- 		foreach ( $list as $key => $value ) {
 
- 			$receivablesPrice += $value ['receivablesPrice'];
 
- 		}
 
- 		if ($receivablesPrice > $detail ['invoicePrice']) {
 
- 			$price = $receivablesPrice - $detail ['invoicePrice'];
 
- 			$priceStatus = 1;
 
- 		} elseif ($receivablesPrice < $detail ['invoicePrice']) {
 
- 			$price = $detail ['invoicePrice'] - $receivablesPrice;
 
- 			$priceStatus = 2;
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'html' => '<tr><td>¥' . $detailM ['receivablesPrice'] . '</td><td>' . $detailM ['receivablesMessage'] . '</td><td>' . $detailM ['receivablesBank'] . '</td>
 
- 				<td>' . $detailM ['receivablesDate'] . '</td><td><a node-remove="Da' . $detailM ['iridKey'] . '" href="javascript:void(0);">移除</a></td></tr>
 
- 				<script>
 
- 					$(\'a[node-remove="Da' . $detailM ['iridKey'] . '"]\').click(function() {
 
- 						var invoiceKey=$("input[name=\'key\']").val();
 
-  						var irid=  $(this).attr("p-data");
 
- 						var iridKey="' . $detailM ["iridEn"] . '";
 
- 						var element=($(this));
 
- 						$("p[node-loading=\"true\"]").show();
 
- 						$("p[node-loading=\"true\"]").html("移除处理中...");
 
- 						$("p[node-msg=\"true2\"]").hide();	
 
- 						$("p[node-msg=\"true\"]").hide();
 
- 						var url = "/ajaxReceivablesRemove";
 
- 						$.ajax({
 
- 							url : url,
 
- 							type : "post",
 
- 							cache : false,
 
- 							dataType : "json",
 
- 							data : {
 
- 								key : iridKey,
 
- 								invoiceKey:invoiceKey
 
- 							},
 
- 							global : true,
 
- 							success : function(data) {
 
- 								$("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '");
 
- 								if (data.status == 1) {
 
- 									$(element).parent().parent().remove();
 
- 									$("tbody[data-invoice=\"myReceivables\"]").append(data.html);
 
- 									$("p[node-loading=\"true\"]").hide();
 
- 									if(data.priceStatus == 1){
 
- 										$("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 										$("p[node-msg=\"true\"]").show();
 
- 									}else if(data.priceStatus == 2&& data.isReceivables != 0){
 
- 										$("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 										$("p[node-msg=\"true\"]").show();
 
- 									}
 
- 								}else if(data.status == 2){
 
- 									$("p[node-loading=\"true\"]").html(data.msg);
 
- 								}
 
- 							},
 
- 							error : function(err) {
 
- 							}
 
- 						});
 
- 					});
 
- 					</script>
 
- 				',
 
- 				'price' => $price,
 
- 				'priceStatus' => $priceStatus,
 
- 				'isReceivables' => $isReceivables 
 
- 		) );
 
- 	}
 
- 	*/
 
- 	
 
- 	/**
 
- 	 * @deprecated
 
- 	 * 从发票中移除已经入账的收款 --需求变更 废弃
 
- 	function ajaxReceivablesRemove() {
 
- 		$iridKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		$invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoiceOperationLog' );
 
- 		$invoiceOperationLog = new invoiceOperationLog ();
 
- 		
 
- 		$detail = $invoice->getInvoiceByIid ( $invoiceKey );
 
- 		$detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridKey );
 
- 		// echo $detail['irid']."<br/>";
 
- 		$invoiceIrid = explode ( ",", $detail ['irid'] );
 
- 		foreach ( $invoiceIrid as $key => $value ) {
 
- 			if ($value == $detailM ['irid'])
 
- 				unset ( $invoiceIrid [$key] );
 
- 		}
 
- 		$invoiceIrid = implode ( ",", $invoiceIrid );
 
- 		
 
- 		// echo $invoiceIrid."ddd";
 
- 		// print_r($invoiceIrid);
 
- 		
 
- 		$item = array (
 
- 				'irid' => $invoiceIrid,
 
- 				'iid' => $detail ['iid'] 
 
- 		);
 
- 		$invoice->setInvoiceByCondition ( $item );
 
- 		
 
- 		$item = array (
 
- 				'iid' => 0,
 
- 				'irid' => $detailM ['irid'],
 
- 				'bindDate' => '',
 
- 				'bindStatus' => 0 
 
- 		);
 
- 		$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 
- 		
 
- 		// 操作日志
 
- 		$item = array (
 
- 				'date' => date ( "Y-m-d H:i:s" ),
 
- 				'operation' => "收款移除" . $detailM ['receivablesSerial'],
 
- 				'status' => 10,
 
- 				'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 );
 
- 		
 
- 		$price = 0;
 
- 		$priceStatus = 0;
 
- 		$isReceivables = 0;
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceIrid );
 
- 		
 
- 		if (! empty ( $list ))
 
- 			$isReceivables = 1;
 
- 		$receivablesPrice = 0;
 
- 		foreach ( $list as $key => $value ) {
 
- 			$receivablesPrice += $value ['receivablesPrice'];
 
- 		}
 
- 		if ($receivablesPrice > $detail ['invoicePrice']) {
 
- 			$price = $receivablesPrice - $detail ['invoicePrice'];
 
- 			$priceStatus = 1;
 
- 		} elseif ($receivablesPrice < $detail ['invoicePrice']) {
 
- 			$price = $detail ['invoicePrice'] - $receivablesPrice;
 
- 			$priceStatus = 2;
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'html' => '<tr id="' . $detailM ['receivablesSerial'] . '" >
 
- 					<td>¥' . $detailM ['receivablesPrice'] . '</td>
 
- 					<td>' . $detailM ['receivablesMessage'] . '</td>
 
- 					<td>' . $detailM ['receivablesBank'] . '</td>
 
- 					<td>' . $detailM ['receivablesDate'] . '</td><td>
 
- 					<a href="javascript:void(0)" node-Claim="true_' . $detailM ['iridKey'] . '" p-data="' . $detailM ['iridEn'] . '" name="invoiceClaim" class="button">入账</a>
 
- 					</td></tr>
 
- 					<script>
 
- 					$(\'a[node-Claim="true_' . $detailM ['iridKey'] . '"]\').click(function() {
 
- 						var invoiceKey=$("input[name=\'key\']").val();
 
-  						var irid=  $(this).attr("p-data");
 
- 						var element=($(this));
 
- 						$("p[node-loading=\"true\"]").show();
 
- 						$("p[node-loading=\"true\"]").html("入账处理中...");
 
- 						$("p[node-msg=\"true2\"]").hide();
 
- 						$("p[node-msg=\"true\"]").hide();
 
- 						var url = "/ajaxCompareClaimPrice";
 
- 						$.ajax({
 
- 							url : url,
 
- 							type : "post",
 
- 							cache : false,
 
- 							dataType : "json",
 
- 							data : {
 
- 								irid : irid,
 
- 								invoiceKey:invoiceKey
 
- 							},
 
- 							global : true,
 
- 							success : function(data) {
 
- 								$("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '");
 
- 								if (data.status == 1) {
 
- 									$(element).parent().parent().remove();
 
- 									$("tbody[box-enter=\"true\"]").append(data.html);
 
- 									$("p[node-loading=\"true\"]").hide();
 
- 									if(data.priceStatus == 1){
 
- 										$("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 										$("p[node-msg=\"true\"]").show();
 
- 									}else if(data.priceStatus == 2&& data.isReceivables != 0){
 
- 						$("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 						$("p[node-msg=\"true\"]").show();
 
- 					}
 
- 								}else if(data.status == 2){
 
- 									$("p[node-loading=\"true\"]").html(data.msg);
 
- 								}
 
- 							},
 
- 							error : function(err) {
 
- 							}
 
- 						});
 
- 					});
 
- 					</script>
 
- 				',
 
- 				'price' => $price,
 
- 				'priceStatus' => $priceStatus,
 
- 				'isReceivables' => $isReceivables 
 
- 		) );
 
- 	}
 
- 	*/
 
- 		
 
- 	/**
 
- 	 * 我的收款中 选择哪个发票入账,进行金额判断
 
- 	 */
 
- 	function ajaxCompareInvoicePrice() {
 
- 		$claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
 
- 		$invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$detail = $invoice->getInvoiceByIid ( $invoiceKey );
 
- 		
 
- 		$keyList = explode ( ';', $claimKey );
 
- 		$receivablesPrice = 0;
 
- 		foreach ( $keyList as $key => $value ) {
 
- 			$detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
 
- 			$receivablesPrice += $detailM ['receivablesPrice'];
 
- 		}
 
- 		
 
- 		if ($receivablesPrice > $detail ['invoicePrice']) {
 
- 			$price = $receivablesPrice - $detail ['invoicePrice'];
 
- 			echo json_encode ( array (
 
- 					'status' => 1,
 
- 					'price' => $price 
 
- 			) );
 
- 		} else
 
- 			echo json_encode ( array (
 
- 					'status' => 2 
 
- 			) );
 
- 	}
 
- 	
 
- 	/**
 
- 	 * @deprecated
 
- 	 * 获得与我有关收款数据 --需求变更 废弃
 
- 	function ajaxGetReceivalblesByStaff() {
 
- 		$iid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$detail = $invoice->getInvoiceByIid ( $iid );
 
- 		$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 
- 		
 
- 		$html = "";
 
- 		$i = 1;
 
- 		foreach ( $list ['myClaim'] as $key => $value ) {
 
- 			$html .= '<tr id="' . $value ['receivablesSerial'] . '" >
 
- 					<td>¥' . $value ['receivablesPrice'] . '</td>
 
- 					<td>' . $value ['receivablesMessage'] . '</td>
 
- 					<td>' . $value ['receivablesBank'] . '</td>
 
- 					<td>' . $value ['receivablesDate'] . '</td>';
 
- 			$html .= '<td>
 
- 					<a href="javascript:void(0)" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim" class="button">入账</a>
 
- 					</td></tr>
 
- 					<script>
 
- 					$(\'a[node-Claim="true_' . $i . '"]\').click(function() {
 
- 						var invoiceKey=$("input[name=\'key\']").val();
 
-  						var irid=  $(this).attr("p-data");
 
- 						var element=($(this));
 
- 						$("p[node-loading=\"true\"]").show();
 
- 						$("p[node-loading=\"true\"]").html("入账处理中...");
 
- 						$("p[node-msg=\"true2\"]").hide();	
 
- 						$("p[node-msg=\"true\"]").hide();
 
- 						var url = "/ajaxCompareClaimPrice";
 
- 						$.ajax({
 
- 							url : url,
 
- 							type : "post",
 
- 							cache : false,
 
- 							dataType : "json",
 
- 							data : {
 
- 								irid : irid,
 
- 								invoiceKey:invoiceKey
 
- 							},
 
- 							global : true,
 
- 							success : function(data) {
 
- 								$("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
 
- 								if (data.status == 1) {
 
- 									$(element).parent().parent().remove();
 
- 									$("tbody[box-enter=\"true\"]").append(data.html);
 
- 									$("p[node-loading=\"true\"]").hide();
 
- 									if(data.priceStatus == 1){
 
- 										$("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 										$("p[node-msg=\"true\"]").show();
 
- 									}else if(data.priceStatus == 2&& data.isReceivables != 0){
 
- 						$("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 						$("p[node-msg=\"true\"]").show();
 
- 					}
 
- 								}else if(data.status == 2){
 
- 									$("p[node-loading=\"true\"]").html(data.msg);
 
- 								}
 
- 							},
 
- 							error : function(err) {
 
- 							}
 
- 						});
 
- 					});
 
- 					</script>
 
- 					';
 
- 			$i ++;
 
- 		}
 
- 		
 
- 		$html2 = "";
 
- 		$list2 = $invoiceReceivables->getInvoiceReceivablesByIid ( $iid, 1 );
 
- 		foreach ( $list2 as $key => $value ) {
 
- 			$html2 .= '<tr id="' . $value ['receivablesSerial'] . '" >
 
- 					<td>¥' . $value ['receivablesPrice'] . '</td>
 
- 					<td>' . $value ['receivablesMessage'] . '</td>
 
- 					<td>' . $value ['receivablesBank'] . '</td>
 
- 					<td>' . $value ['receivablesDate'] . '</td>';
 
- 			$html2 .= '<td>
 
- 					<a href="javascript:void(0)"  node-remove="Da' . $value ['iridKey'] . '" >移除</a>
 
- 					</td></tr>
 
- 					<script>
 
- 					$(\'a[node-remove="Da' . $value ['iridKey'] . '"]\').click(function() {
 
- 						var invoiceKey=$("input[name=\'key\']").val();
 
-  						var irid=  $(this).attr("p-data");
 
- 						var iridKey="' . $value ["iidKey"] . '";
 
- 						var element=($(this));
 
- 						$("p[node-loading=\"true\"]").show();
 
- 						$("p[node-loading=\"true\"]").html("移除处理中...");
 
- 						$("p[node-msg=\"true2\"]").hide();	
 
- 						$("p[node-msg=\"true\"]").hide();
 
- 						var url = "/ajaxReceivablesRemove";
 
- 						$.ajax({
 
- 							url : url,
 
- 							type : "post",
 
- 							cache : false,
 
- 							dataType : "json",
 
- 							data : {
 
- 								key : iridKey,
 
- 								invoiceKey:invoiceKey
 
- 							},
 
- 							global : true,
 
- 							success : function(data) {
 
- 								$("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '");
 
- 								if (data.status == 1) {
 
- 									$(element).parent().parent().remove();
 
- 									$("tbody[data-invoice=\"myReceivables\"]").append(data.html);
 
- 									$("p[node-loading=\"true\"]").hide();
 
- 									if(data.priceStatus == 1){
 
- 										$("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 										$("p[node-msg=\"true\"]").show();
 
- 									}else if(data.priceStatus == 2&& data.isReceivables != 0){
 
- 										$("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。");
 
- 										$("p[node-msg=\"true\"]").show();
 
- 									}
 
- 								}else if(data.status == 2){
 
- 									$("p[node-loading=\"true\"]").html(data.msg);
 
- 								}
 
- 							},
 
- 							error : function(err) {
 
- 							}
 
- 						});
 
- 					});
 
- 					</script>
 
- 					';
 
- 			$i ++;
 
- 		}
 
- 		
 
- 		$price = 0;
 
- 		$priceStatus = 0;
 
- 		$isReceivables = 0;
 
- 		$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
 
- 		if (! empty ( $list ))
 
- 			$isReceivables = 1;
 
- 		$receivablesPrice = 0;
 
- 		foreach ( $list as $key => $value ) {
 
- 			$receivablesPrice += $value ['receivablesPrice'];
 
- 		}
 
- 		if ($receivablesPrice > $detail ['invoicePrice']) {
 
- 			$price = $receivablesPrice - $detail ['invoicePrice'];
 
- 			$priceStatus = 1;
 
- 		} elseif ($receivablesPrice < $detail ['invoicePrice']) {
 
- 			$price = $detail ['invoicePrice'] - $receivablesPrice;
 
- 			$priceStatus = 2;
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'html' => $html,
 
- 				'html2' => $html2,
 
- 				'price' => $price,
 
- 				'priceStatus' => $priceStatus,
 
- 				'isReceivables' => $isReceivables 
 
- 		) );
 
- 	}
 
- 	*/
 
- 	
 
- 	function ajaxGetInvoiceInfoByType() {
 
- 		$type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
 
- 		$serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
 
- 		
 
- 		if (empty ( $serial )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 2,
 
- 					'msg' => 'illegal request' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		if ($type == 'INVOICE') {
 
- 			Doo::loadModel ( 'invoice' );
 
- 			$invoice = new invoice ();
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			$detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
 
- 			$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
 
- 			
 
- 			if (empty ( $detail ))
 
- 				$html = '';
 
- 			else {
 
- 				$html = '
 
- 						<div class="modal-dialog modal-lg">
 
- 				<div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
 
- 				<div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
 
- 						<tr>
 
- 							<th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
 
- 							<th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
 
- 							<th class="taC" width="150">备注</th><td>' . $detail ['remark'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC">开票金额</th><td><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
 
- 							<th class="taC">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
 
- 						</tr></tbody></table>';
 
- 				
 
- 				if ($detail ['invoiceType'] == 0)
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody>
 
- 							<tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
 
- 							<th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
 
- 							<th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>		
 
- 									</tr>';
 
- 				else
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody>
 
- 							<tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
 
- 							<th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
 
- 							<th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
 
- 						
 
- 									';
 
- 				
 
- 				$html .= '<tr>
 
- 							<th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
 
- 							<th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
 
- 							<th class="taC">银行账户</th><td>' . $detail ['bank'] . '</td>
 
- 						</tr></tbody></table>';
 
- 				
 
- 				if ($detail ['doPost'] == 1)
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
 
- 							<th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
 
- 							<th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
 
- 						</tr><tr>
 
- 							<th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
 
- 						</tr><tr>
 
- 							<th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
 
- 						</tr></tbody></table>';
 
- 				if (! empty ( $invoiceOperationLogList )) {
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
 
- 					foreach ( $invoiceOperationLogList as $key => $value ) {
 
- 						if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
 
- 							$html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span> 
 
- 							' . $value ['category'] . '-' . $value ['username'] . ' ';
 
- 							if ($value ['status'] == 2) {
 
- 								$html .= '<span class="colGreen">同意</span>';
 
- 							} elseif ($value ['status'] == 3) {
 
- 								$html .= '<span class="colOrange">退回</span>';
 
- 							} elseif ($value ['status'] == 5) {
 
- 								$html .= '<span class="colGreen">打印</span>';
 
- 							}
 
- 							$html .= $value ['operation'] . '</p></blockquote>';
 
- 						}
 
- 					}
 
- 					$html .= '</td></tr></tbody></table>';
 
- 				}
 
- 				$html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
 
- 			}
 
- 			echo json_encode ( array (
 
- 					'status' => 1,
 
- 					'html' => $html 
 
- 			) );
 
- 			die ();
 
- 		} elseif ($type == 'RECEIVABLES') {
 
- 			Doo::loadModel ( 'invoiceReceivables' );
 
- 			$invoiceReceivables = new invoiceReceivables ();
 
- 			
 
- 			$detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial, $this->staff [0] ['sid'] );
 
- 			if (empty ( $detail ))
 
- 				$html = '';
 
- 			else {
 
- 				$html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList"><table class="table table-bordered table-condensed">
 
- 						<tbody><tr>
 
- 							<th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
 
- 							<th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
 
- 						</tr><tr>
 
- 							<th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
 
- 							<th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
 
- 							<th class="taC">银行到帐</th><td>' . $detail ['receivablesDate'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['bindDate'] . '</td>
 
- 						</tr>
 
- 						</tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
 
- 			}
 
- 			echo json_encode ( array (
 
- 					'status' => 1,
 
- 					'html' => $html 
 
- 			) );
 
- 			die ();
 
- 		} elseif ($type == 'IRTC') {
 
- 			
 
- 			Doo::loadModel ( 'invoice' );
 
- 			$invoice = new invoice ();
 
- 			Doo::loadModel ( 'invoiceOperationLog' );
 
- 			$invoiceOperationLog = new invoiceOperationLog ();
 
- 			
 
- 			$detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
 
- 			$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
 
- 			
 
- 			if (empty ( $detail ))
 
- 				$html = '';
 
- 			else {
 
- 				$html = '
 
- 						<table class="table table-bordered table-condensed"><tbody>
 
- 						<tr>
 
- 							<th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
 
- 							<th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
 
- 							<th class="taC" width="150">备注</th><td>' . $detail ['remark'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC">开票金额</th><td><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
 
- 							<th class="taC">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
 
- 						</tr></tbody></table>';
 
- 				
 
- 				if ($detail ['invoiceType'] == 0)
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody>
 
- 							<tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
 
- 							<th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
 
- 							<th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
 
- 									</tr>';
 
- 				else
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody>
 
- 							<tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
 
- 							<th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
 
- 							<th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
 
- 			
 
- 									';
 
- 				
 
- 				$html .= '<tr>
 
- 							<th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
 
- 							<th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
 
- 						</tr>
 
- 						<tr>
 
- 							<th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
 
- 							<th class="taC">银行账户</th><td>' . $detail ['bank'] . '</td>
 
- 						</tr></tbody></table>';
 
- 				
 
- 				if ($detail ['doPost'] == 1)
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
 
- 							<th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
 
- 							<th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
 
- 						</tr><tr>
 
- 							<th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
 
- 						</tr><tr>
 
- 							<th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
 
- 						</tr></tbody></table>';
 
- 				if (! empty ( $invoiceOperationLogList )) {
 
- 					$html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
 
- 					foreach ( $invoiceOperationLogList as $key => $value ) {
 
- 						if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
 
- 							$html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span> 
 
- 							' . $value ['category'] . '-' . $value ['username'] . ' ';
 
- 							if ($value ['status'] == 2) {
 
- 								$html .= '<span class="colGreen">同意</span>';
 
- 							} elseif ($value ['status'] == 3) {
 
- 								$html .= '<span class="colOrange">退回</span>';
 
- 							} elseif ($value ['status'] == 5) {
 
- 								$html .= '<span class="colGreen">打印</span>';
 
- 							}
 
- 							$html .= $value ['operation'] . '</p></blockquote>';
 
- 						}
 
- 					}
 
- 					$html .= '</td></tr></tbody></table>';
 
- 				}
 
- 			}
 
- 			echo json_encode ( array (
 
- 					'status' => 1,
 
- 					'html' => $html,
 
- 					'iidKey' => $serial 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 	}
 
- 	function ajaxGetInvoiceReceivablesByStaff() {
 
- 		$postData = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : "";
 
- 		
 
- 		if (empty ( $postData )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 2,
 
- 					'msg' => 'illegal request' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		
 
- 		$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $postData );
 
- 		if (empty ( $detail )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 2,
 
- 					'msg' => 'illegal request' 
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		Doo::loadModel ( 'L_category' );
 
- 		$lCategory = new L_category ();
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$staffList = $staff->getStaffByCid ( $detail ['cid'] );
 
- 		$category = $lCategory->getCategory ();
 
- 		
 
- 		$categoryHtml = '<option post-data="PUBLIC" value="PUBLIC" >公共待认领款项</option>';
 
- 		$staffHtml = '<option value="PUBLIC">办事处待认领款项</option>';
 
- 		foreach ( $category as $key => $value ) {
 
- 			$categoryHtml .= '<option  post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
 
- 			if ($value ['cid'] == $detail ['cid'])
 
- 				$categoryHtml .= '<option selected  post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
 
- 		}
 
- 		foreach ( $staffList as $key => $value ) {
 
- 			$staffHtml .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
 
- 			if ($value ['sid'] == $detail ['sid'])
 
- 				$staffHtml .= '<option selected value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
 
- 		}
 
- 		
 
- 		$rbankHtml = '<option value="广发银行珠海分行柠溪支行">广发银行珠海分行柠溪支行</option>';
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'categoryHtml' => $categoryHtml,
 
- 				'staffHtml' => $staffHtml,
 
- 				'rbankHtml' => $rbankHtml,
 
- 				'detail' => $detail 
 
- 		) );
 
- 	}
 
- 	
 
- 	function ajaxGetInvoiceReceivablesByIrid(){
 
- 		$irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
 
- 		
 
- 		if (empty ( $irid )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 2,
 
- 					'msg' => 'illegal request'
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$detail=$invoiceReceivables->getInvoiceReceivablesByIrid($irid);
 
- 		$invoiceDetail=$invoice->getInvoiceByTitle($detail['recepitTitleMark'],'EXACTLY'," and status=2 and printStatus=1 and irid='' ");//
 
- 		
 
- 		$receivablesHtml='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="70">收款金额</th><th class="taC">银行到帐信息</th><th class="taC">银行/到帐时间</th><th class="taC">收款认领</th><th class="taC">开票单位</th></tr>
 
- 					<tr>
 
- 						<td><b>¥'.$detail['receivablesPrice'].'</b></td>
 
- 						<td>'.$detail['receivablesMessage'].'</td>
 
- 						<td>'.$detail['receivablesBank'].'<br>'.$detail['receivablesDate'].'</td>
 
- 						<td>'.$detail['title'].'-'.$detail['username'].'<br>'.$detail['confirmTime'].'</td>
 
- 						<td>'.$detail['recepitTitleMark'].'</td>
 
- 					</tr></tbody></table>';
 
- 		
 
- 		
 
- 		$isInvoice=false;$invoiceHtml='';
 
- 		if(empty($invoiceDetail)){
 
- 			$isInvoice=true;
 
- 		}else{
 
- 			$invoiceHtml='<table class="table table-bordered table-condensed">
 
- 			<thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
 
- 			if (! empty ( $invoiceDetail ['invoiceType'] )) {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
 
- 			} else {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
 
- 			}
 
- 			
 
- 			if (! empty ( $invoiceDetail ['invoiceType'] )) {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
 
- 			} else {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
 
- 			}
 
- 			
 
- 			$invoiceHtml.='
 
- 					<td>' . $invoiceDetail ['categoryName'].$invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date']. '</td>
 
- 					<td>' . $invoiceDetail ['printer']. ' ' . $invoiceDetail ['printTime']. '</td>
 
- 					<td>' . $invoiceDetail ['invoiceSerial']. '</td><td><a class="button btn-block" bind-receivables="ir'.$invoiceDetail ['iidKeyXD'].'" data-ikey="'.$invoiceDetail ['iidKey'].'" href="javascript:void(0)">入账</a></td>
 
- 					</tr>
 
- 					';
 
- 			$invoiceHtml.='</tbody></table>
 
- 					
 
- 					
 
- 					<script>
 
- 					$(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
 
- 							$("input[name=\'invoiceKey\']").val("'.$invoiceDetail ['iidKey'].'");
 
- 							var invoiceKey=$("input[name=\'invoiceKey\']").val();
 
- 							if(invoiceKey==""){
 
- 								alert("入账错误,请重新刷新页面");
 
- 								return false;
 
- 							}
 
- 							if(window.confirm("确定入账吗?")){
 
- 				                $("#IBR").submit();
 
- 				              }else{
 
- 				                 return false;
 
- 				             }
 
- 					});
 
- 					</script>
 
- 					
 
- 					
 
- 					';
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'irkey'=>$detail['iridEn'],
 
- 				'receivablesHtml' => $receivablesHtml,
 
- 				'isInvoice'=>$isInvoice,
 
- 				'invoiceHtml' => $invoiceHtml
 
- 		) );
 
- 	}
 
- 	
 
- 	function ajaxGetInvoiceReceivablesByTitle(){
 
- 		$title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
 
- 		
 
- 		if (empty ( $title )) {
 
- 			echo json_encode ( array (
 
- 					'status' => 2,
 
- 					'msg' => 'illegal request'
 
- 			) );
 
- 			die ();
 
- 		}
 
- 		
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		
 
- 		$invoiceDetail=$invoice->getInvoiceByTitle($title,'EXACTLY'," and status=2 and printStatus=1 and irid='' ");
 
- 		
 
- 		$invoiceHtml='';
 
- 		if(!empty($invoiceDetail)){
 
- 			$invoiceHtml='<table class="table table-bordered table-condensed">
 
- 			<thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
 
- 			if (! empty ( $invoiceDetail ['invoiceType'] )) {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoiceCompany'] . '</td>';
 
- 			} else {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoiceTitle'] . '</td>';
 
- 			}
 
- 				
 
- 			if (! empty ( $invoiceDetail ['invoiceType'] )) {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '专</td>';
 
- 			} else {
 
- 				$invoiceHtml .= '<td>' . $invoiceDetail ['invoicePrice'] . '</td>';
 
- 			}
 
- 				
 
- 			$invoiceHtml.='
 
- 					<td>' . $invoiceDetail ['categoryName'].$invoiceDetail ['userName'] . ' ' . $invoiceDetail ['date']. '</td>
 
- 					<td>' . $invoiceDetail ['printer']. ' ' . $invoiceDetail ['printTime']. '</td>
 
- 					<td>' . $invoiceDetail ['invoiceSerial']. '</td><td><a class="button btn-block" bind-receivables="ir'.$invoiceDetail ['iidKeyXD'].'" data-ikey="'.$invoiceDetail ['iidKey'].'" href="#">入账</a></td>
 
- 					</tr>
 
- 					';
 
- 			$invoiceHtml.='</tbody></table>
 
- 					
 
- 					<script>
 
- 					$(\'a[bind-receivables="ir' . $invoiceDetail ['iidKeyXD'] . '"]\').click(function() {
 
- 							$("input[name=\'invoiceKey\']").val("'.$invoiceDetail ['iidKey'].'");
 
- 							var invoiceKey=$("input[name=\'invoiceKey\']").val();
 
- 							if(invoiceKey==""){
 
- 								alert("入账错误,请重新刷新页面");
 
- 								return false;
 
- 							}
 
- 							if(window.confirm("确定入账吗?")){
 
- 				                $("#IBR").submit();
 
- 				              }else{
 
- 				                 return false;
 
- 				             }
 
- 					});
 
- 					</script>
 
- 					';
 
- 		}
 
- 		
 
- 		echo json_encode ( array (
 
- 				'status' => 1,
 
- 				'invoiceHtml' => $invoiceHtml
 
- 		) );
 
- 	}
 
- 	
 
- 	function _GetFileEXT($filename) {
 
- 		$pics = explode ( '.', $filename );
 
- 		$num = count ( $pics );
 
- 		return $pics [$num - 1];
 
- 	}
 
- 	function showCache($path = "") {
 
- 		if (file_exists ( $path )) {
 
- 			$htm = file_get_contents ( $path );
 
- 		} else {
 
- 			Doo::loadModel ( 'invoiceStatistics' );
 
- 			$invoiceStatistics = new invoiceStatistics ();
 
- 			
 
- 			$isBriefly = $invoiceStatistics->getBrieflyStatistics ();
 
- 			$htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
 
- 				<td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
 
- 				<th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
 
- 				<td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
 
- 			/*
 
- 			 * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
 
- 			 */
 
- 			file_put_contents ( $path, $htm, FILE_APPEND );
 
- 		}
 
- 		return $htm;
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 获取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 SafeFilter(&$arr) {
 
- 		$ra = Array (
 
- 				'/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
 
- 				'/script/',
 
- 				'/javascript/',
 
- 				'/vbscript/',
 
- 				'/expression/',
 
- 				'/applet/',
 
- 				'/meta/',
 
- 				'/xml/',
 
- 				'/blink/',
 
- 				'/link/',
 
- 				'/style/',
 
- 				'/embed/',
 
- 				'/object/',
 
- 				'/frame/',
 
- 				'/layer/',
 
- 				'/title/',
 
- 				'/bgsound/',
 
- 				'/base/',
 
- 				'/onload/',
 
- 				'/onunload/',
 
- 				'/onchange/',
 
- 				'/onsubmit/',
 
- 				'/onreset/',
 
- 				'/onselect/',
 
- 				'/onblur/',
 
- 				'/onfocus/',
 
- 				'/onabort/',
 
- 				'/onkeydown/',
 
- 				'/onkeypress/',
 
- 				'/onkeyup/',
 
- 				'/onclick/',
 
- 				'/ondblclick/',
 
- 				'/onmousedown/',
 
- 				'/onmousemove/',
 
- 				'/onmouseout/',
 
- 				'/onmouseover/',
 
- 				'/onmouseup/',
 
- 				'/onunload/' 
 
- 		);
 
- 		
 
- 		if (is_array ( $arr )) {
 
- 			foreach ( $arr as $key => $value ) {
 
- 				if (! is_array ( $value )) {
 
- 					if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
 
- {
 
- 						$value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
 
- 					}
 
- 					$value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
 
- 					$arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
 
- 				} else {
 
- 					SafeFilter ( $arr [$key] );
 
- 				}
 
- 			}
 
- 		}
 
- 	}
 
- 	
 
- 	/**
 
- 	 * Escape String
 
- 	 *
 
- 	 * @access public
 
- 	 * @param string
 
- 	 * @param bool whether or not the string will be used in a LIKE condition
 
- 	 * @return string
 
- 	 */
 
- 	function escape_str($str, $like = FALSE) {
 
- 		if (is_array ( $str )) {
 
- 			foreach ( $str as $key => $val ) {
 
- 				$str [$key] = $this->escape_str ( $val, $like );
 
- 			}
 
- 			return $str;
 
- 		}
 
- 		
 
- 		var_dump ( Doo::db ()->getDbObject () );
 
- 		die ();
 
- 		
 
- 		if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
 
- 			$str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
 
- 		} elseif (function_exists ( 'mysql_escape_string' )) {
 
- 			$str = mysql_escape_string ( $str );
 
- 		} else {
 
- 			$str = addslashes ( $str );
 
- 		}
 
- 		// escape LIKE condition wildcards
 
- 		if ($like === TRUE) {
 
- 			$str = str_replace ( array (
 
- 					'%',
 
- 					'_' 
 
- 			), array (
 
- 					'\\%',
 
- 					'\\_' 
 
- 			), $str );
 
- 		}
 
- 		return $str;
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 获得分页数据
 
- 	 * @param unknown_type $table
 
- 	 * @param unknown_type $condition
 
- 	 * @param unknown_type $on_page
 
- 	 * @param unknown_type $page_size
 
- 	 */
 
- 	function get_page($table = "", $condition = "", $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 ( $table, $condition );
 
- 		$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 $on_page
 
- 	 */
 
- 	function get_previous($on_page = 1) {
 
- 		return $on_page != 0 ? $on_page - 1 : $on_page;
 
- 	}
 
- 	/**
 
- 	 * 获取总页数
 
- 	 * @param unknown_type $table
 
- 	 * @param unknown_type $condition
 
- 	 */
 
- 	public function get_table_count($table = "", $condition = "") {
 
- 		//$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
 
- 		$sql = "select count(*) as count from " . $table . " where  " . $condition;
 
- 		
 
- 		//echo $sql;die;
 
- 		$query = Doo::db ()->query ( $sql );
 
- 		$result = $query->fetch ();
 
- 		return $result ['count'];
 
- 	}
 
- 	function isInvoiceNew($type = "GLOBAL") {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		Doo::loadModel ( 'invoiceReceivables' );
 
- 		$invoiceReceivables = new invoiceReceivables ();
 
- 		Doo::loadModel ( 'staff' );
 
- 		$staff = new staff ();
 
- 		
 
- 		$st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
 
- 		
 
- 		// 我的发票待处理
 
- 		$pendingInvoice = $invoice->getOne ( array (//or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 )
 
- 				'where' => "(status=3 or status=4) and isDelete=0 and sid=" . $st [0] ['sid'],
 
- 				'desc' => 'iid',
 
- 				'asArray' => TRUE 
 
- 		) );
 
- 		// 我的收款待入账
 
- 		/*
 
- 		$myClaim = $invoiceReceivables->getOne ( array (
 
- 				'where' => " receivablesStaff like '" . $st [0] ['sid'] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0",
 
- 				'desc' => 'irid',
 
- 				'asArray' => TRUE 
 
- 		) );
 
- 		*/
 
- 		// 发票审批
 
- 		$approval = $invoice->getOne ( array (
 
- 				'where' => 'status=1 and pendingApprovals=' . $st [0] ['sid'],
 
- 				'desc' => 'iid',
 
- 				'asArray' => true 
 
- 		) );
 
- 		// 发票邮寄
 
- 		$post = $invoice->getOne ( array (
 
- 				'where' => "postStatus=0 and doPost=1 and status=2",
 
- 				'asArray' => TRUE 
 
- 		) );
 
- 		// 发票打印
 
- 		$print = $invoice->getOne ( array (
 
- 				'where' => "status=2 and printStatus=0 and moldManage like '%[\"" . $st [0] ['sid'] . "\",%'",
 
- 				'desc' => 'iid',
 
- 				'asArray' => TRUE 
 
- 		) );
 
- 		// 发票退票
 
- 		$untread = $invoice->getOne ( array (
 
- 				'where' => " printStatus=1 and untreadStatus=1 and status=2 ",
 
- 				'asArray' => TRUE 
 
- 		) );
 
- 		
 
- 		$new = array (
 
- 				'GLOBAL' => FALSE,
 
- 				'pendingInvoice' => FALSE,
 
- //				'myClaim' => FALSE,
 
- 				'approval' => FALSE,
 
- 				'post' => FALSE,
 
- 				'print' => FALSE,
 
- 				'untread' => FALSE 
 
- 		);
 
- 		//|| ! empty ( $myClaim )
 
- 		if (! empty ( $pendingInvoice )  || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
 
- 			$new ['GLOBAL'] = TRUE;
 
- 		if (! empty ( $pendingInvoice ))
 
- 			$new ['pendingInvoice'] = TRUE;
 
- // 		if (! empty ( $myClaim ))
 
- // 			$new ['myClaim'] = TRUE;
 
- 		if (! empty ( $approval ))
 
- 			$new ['approval'] = TRUE;
 
- 		if (! empty ( $post ))
 
- 			$new ['post'] = TRUE;
 
- 		if (! empty ( $print ))
 
- 			$new ['print'] = TRUE;
 
- 		if (! empty ( $untread ))
 
- 			$new ['untread'] = TRUE;
 
- 		return $new;
 
- 	}
 
- 	function setWXMsg($rid, $uid) {
 
- 		Doo::loadModel ( 'invoice' );
 
- 		$invoice = new invoice ();
 
- 		$receiptDetail = $invoice->getOne ( array (
 
- 				'where' => 'iid=' . $rid,
 
- 				'asArray' => true 
 
- 		) );
 
- 		
 
- 		if (! empty ( $receiptDetail )) {
 
- 			Doo::loadModel ( 'staff' );
 
- 			$staff = new staff ();
 
- 			$staffmsg = $staff->getOne ( array (
 
- 					'where' => "sid='" . $uid . "'",
 
- 					'asArray' => TRUE 
 
- 			) );
 
- 			if (! empty ( $staffmsg ['wxid'] )) {
 
- 				require_once (SITE_PATH . '/protected/class/client.php');
 
- 				$client = new client ( 'http://m.cld.smartcost.com.cn/' );
 
- 				$user = $staffmsg ['wxid'];
 
- 				$receiptName = '费用';
 
- 				$msg = '';
 
- 				// switch ($receiptDetail ['Rtype']) {
 
- 				// case 0 :
 
- 				// $receiptName = '报销';
 
- 				// break;
 
- 				// case 1 :
 
- 				// $receiptName = '借款';
 
- 				// break;
 
- 				// case 2 :
 
- 				// $receiptName = '对公汇款';
 
- 				// break;
 
- 				// }
 
- 				
 
- 				// 单位名称 金额 开票内容 已邮寄,顺丰 123123213
 
- 				
 
- 				switch (2) {
 
- 					case 1 :
 
- 						$msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已同意支付。';
 
- 						break;
 
- 					case 2 :
 
- 						$msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['invoiceElement'] . ',¥' . $receiptDetail ['invoicePrice'] . ',已被撤回,请及时处理。';
 
- 						break;
 
- 					case 3 :
 
- 						$msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
 
- 						break;
 
- 				}
 
- 				
 
- 				$result = $client->SendMsg ( $user, $msg, 'text' );
 
- 			}
 
- 		}
 
- 	}
 
- }
 
- ?>
 
 
  |