123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939 |
- <?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' => $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(){
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $data ['receiptMemu'] = 'invoiceReceivables';
- $this->render ( "/admin/invoiceReceivables", $data );
- }
-
-
- /**
- * 异步获取一条发票的邮寄信息
- */
- 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 _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;
- }
- }
- ?>
|