12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535 |
- <?php
- /**
- * 开票功能控制器
- * @author CP
- * @version 1.0
- * @namespace invoice
- * @package invoiceController
- */
- class InvoiceController extends DooController {
- public $staff;
- private $INVOICEKEY = "APPROVAL";
- function __construct() {
- if (isset ( $_COOKIE ["staff"] )) {
- if (! empty ( $_COOKIE ["staff"] )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceManage" );
- $invoiceManage = new invoiceManage ();
-
- // $invoiceManage
-
- $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 ();
- $invoiceList = $invoice->getMyInvoice ( $_COOKIE ["staff"] );
-
- $data ['expressList'] = $expressList;
- $data ['invoiceList'] = $invoiceList;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoice", $data );
- }
- function invoiceAdd() {
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
-
- $category = $lCategory->find ( array (
- 'asArray' => true
- ) );
-
- $data ['category'] = $category;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoiceAdd", $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' ) : "";
-
- $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
- $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
-
- 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 ();
-
- $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
- );
- else {
- $item += array (
- 'invoiceCompany' => $invoiceCompany,
- 'TIN' => $TIN,
- 'address' => $address,
- 'phone' => $phone,
- 'bank' => $bank,
- 'bankAccount' => $bankAccount
- );
- }
- if ($doPost == 1) {
- $item += array (
- 'recipients' => $recipients,
- 'recipientsPhone' => $recipientsPhone,
- 'recipientsAddress' => $recipientsAddress,
- 'mailItems' => $mailItems
- );
- }
-
- $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 );
- }
-
- 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 );
-
- $data ['operation'] = $operation;
- $data ['invoiceDetail'] = $invoiceDetail;
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceApproval';
- $this->render ( "/admin/invoiceEdit", $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' ) : "";
-
- 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
- );
- else {
- $item += array (
- 'invoiceCompany' => $invoiceCompany,
- 'TIN' => $TIN,
- 'address' => $address,
- 'phone' => $phone,
- 'bank' => $bank,
- 'bankAccount' => $bankAccount
- );
- }
- if ($doPost == 1) {
- $item += array (
- 'recipients' => $recipients,
- 'recipientsPhone' => $recipientsPhone,
- 'recipientsAddress' => $recipientsAddress,
- 'mailItems' => $mailItems
- );
- }
- $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 ();
-
- $iid = $invoice->authcode ( $untreadIidKey );
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- $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 ();
-
- $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
- $iid = $XDeode->decode ( $iid );
-
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
- $invoiceDetail = $invoice->getMyInvoice ( $_COOKIE ["staff"], $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;
- }
-
- $data ['invoiceList'] = $invoiceList;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceApproval';
- $this->render ( "/admin/invoiceApproval", $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
- ) );
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
-
- $data ['invoiceDetail'] = $invoiceDetail;
- $data ['invoiceOperationLogList'] = $invoiceOperationLogList;
- $data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceApproval';
- $this->render ( "/admin/invoiceApprovalDetail", $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;
- }
-
- $data ['printed'] = $printed;
- $data ['toPrint'] = $toPrint;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoicePrint';
- $this->render ( "/admin/invoicePrint", $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 );
-
- $data ['invoiceDetail'] = $invoiceDetail;
- $data ['invoiceOperationLogList'] = $invoiceOperationLogList;
- $data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoicePrint';
- $this->render ( "/admin/invoicePrintDetail", $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" ),
- '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 ();
-
- $data ['expressList'] = $expressList;
- $data ['invoicePost'] = $invoicePost;
- $data ['invoicePosted'] = $invoicePosted;
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoicePost';
- $this->render ( "/admin/invoicePost", $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 );
- return '/invoicePost';
- }
- /**
- * 退票处理页面
- */
- function invoiceUntread() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1 );
- $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
-
- $data ['untreadInvoice'] = $untreadInvoice;
- $data ['establishedInvoice'] = $establishedInvoice;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceUntread';
- $this->render ( "/admin/invoiceUntread", $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() {
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $category = $lCategory->getCategory ();
- $staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
-
- $data ['staffList'] = $staffList;
- $data ['category'] = $category;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceReceivables';
- $this->render ( "/admin/invoiceReceivables", $data );
- }
-
- /**
- * 录入收款数据
- * @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 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- 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'],
-
- 'receivablesCategory' => $receivablesCategory,
- 'receivablesStaff' => $receivablesStaff
- );
- $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
- }
-
- return "/invoiceReceivables";
- }
- /**
- * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
- */
- function invoiceReceivablesClaim() {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'] );
-
- $data ['receivablesList'] = $receivablesList;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceReceivablesClaim';
- $this->render ( "/admin/invoiceReceivablesClaim", $data );
- }
-
- /**
- * 管理员录入的收款 ,确认认领到谁的名下
- */
- function invoiceReceivablesAscription() {
- $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-
- if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC') {
- $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" ),
- 'source' => 1
- );
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
- }
-
- return "/invoiceReceivablesClaim";
- }
-
- /**
- */
- function invoiceMyReceivables() {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
-
- $data ['list'] = $list;
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceMyReceivables';
- $this->render ( "/admin/invoiceMyReceivables", $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 ();
-
- $detail=$invoice->getInvoiceByIid($invoiceKey);
- $detailM=$invoiceReceivables->getInvoiceReceivablesByIrid($claimKey);
-
- if (empty($detail)&&empty($detailM))
- 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 "/invoiceMyReceivables";
- }
-
- /**
- * 发票收款完成
- */
- 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 ();
-
- $detail=$invoice->getInvoiceByIid($invoiceKey);
-
- if (empty($detail))
- die ( 'illegal request' );
- /*
- $receivablesPrice=0;$iridString=$detail['irid'];$iridList=array();
- foreach ($invoiceClaim as $key=>$value){
- $detailM=$invoiceReceivables->getInvoiceReceivablesByIrid($value);
- $receivablesPrice+=$detailM['receivablesPrice'];
- if (empty($iridString))
- $iridString=$detailM['irid'];
- else
- $iridString.=",".$detailM['irid'];
- array_push($iridList, $detailM['irid']);
- }
-
- if ($receivablesPrice>=$detail['invoicePrice']){
- $price=$receivablesPrice-$detail['invoicePrice'];
- die('<p>收款金额超出开票金额 ¥'.$price.'元,请谨慎操作</p><a href="/invoice">返回</a>');
- }
- */
-
- $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 );
-
- /*
- foreach ($iridList as $key=>$value){
- $item = array (
- 'iid' => $detail['iid'],
- 'irid' => $value,
- 'bindDate'=>date ( "Y-m-d H:i:s" ),
- 'bindStatus' => 1
-
- );
- $invoiceReceivables->setInvoiceReceivablesByCondition($item);
- }
- */
- return "/invoice";
- }
-
- /**
- * 获得与我有关可收款的发票
- */
- 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 );
-
- 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 );
- echo json_encode ( array (
- 'status' => 1,
- 'invoiceDetail' => $invoiceDetail
- ) );
- }
-
- 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;
- $list=$invoiceReceivables->getInvoiceReceivablesInIridString($iridString);
- $receivablesPrice=0;
- foreach ($list as $key=>$value){
- $receivablesPrice+=$value['receivablesPrice'];
- }
- if ($receivablesPrice>=$detail['invoicePrice']){
- $price=$receivablesPrice-$detail['invoicePrice'];
- $priceStatus=1;
- }
-
- 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 href="">移除</a></td></tr>',
- 'price'=>$price,
- 'priceStatus'=>$priceStatus
- ) );
- }
-
- /**
- * 我的收款中 选择哪个发票入账,进行金额判断
- */
- 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
- ) );
- }
-
- /*
- * 获得与我有关收款数据
- */
- 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=\"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.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-Claim="true_'.$i.'" p-data="'.$value ['iidKey'].'" name="invoiceClaim" >移除</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=\"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.status == 2){
- $("p[node-loading=\"true\"]").html(data.msg);
- }
- },
- error : function(err) {
- }
- });
- });
- </script>
- ';
- $i++;
- }
-
- $price=0;$priceStatus=0;
- $list=$invoiceReceivables->getInvoiceReceivablesInIridString($detail['irid']);
- $receivablesPrice=0;
- foreach ($list as $key=>$value){
- $receivablesPrice+=$value['receivablesPrice'];
- }
- if ($receivablesPrice>=$detail['invoicePrice']){
- $price=$receivablesPrice-$detail['invoicePrice'];
- $priceStatus=1;
- }
-
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html,
- 'html2'=>$html2,
- 'price'=>$price,
- 'priceStatus'=>$priceStatus
- ) );
- }
-
- function _GetFileEXT($filename) {
- $pics = explode ( '.', $filename );
- $num = count ( $pics );
- return $pics [$num - 1];
- }
-
- /**
- * 获取get或者POST值
- *
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else
- return addslashes ( $_GET [$name] );
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else
- return addslashes ( $_POST [$name] );
- } else
- return false;
- }
- }
- ?>
|