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' ) ); // 删除审批人后-加入权限问题-暂时关闭 $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" ); $fiML = json_decode ( $fileInvoice, true ); if (empty ( $fiML )) $fiML = array (); foreach ( $fiML as $key => $value ) { $sidList = explode ( ',', $value ); foreach ( $sidList as $k => $v ) { if ($v == $sid) { array_push ( $moldList, array ( 'mold' => $key ) ); break; } } } foreach ( $moldList as $value ) { if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) { $flag = true; break; } } } /* * Doo::acl()->isAllowed($uGroups['groups'], $resource, $action); */ // 单独判断办事处汇总的访问权限 invoiceAggregateCategoryDetail,invoiceAggregateStaffDetail if ($action == 'invoiceAggregateCategoryDetail' || $action == 'invoiceAggregateStaffDetail') { Doo::loadModel ( "invoiceCategoryManage" ); $invoiceCategoryManage = new invoiceCategoryManage (); $icm = $invoiceCategoryManage->getInvoiceCMByStaff ( $sid ); if (empty ( $icm )) die ( 'illegal request' ); } // 单独判断应收款访问权限 if ($action == 'invoiceAggregateCompanyDetail') { Doo::loadModel ( "invoiceCompanyManage" ); $invoiceCompanyManage = new invoiceCompanyManage (); $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid ); if (empty ( $icm )) die ( 'illegal request' ); } // 主权限获得与判断 Doo::loadModel ( 'staff' ); $staff = new staff (); $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] ); $accessModular = 'INVOICEEXTEND'; $accessAuthority = 'INVOICE'; if (empty ( $detail ['cldAccessArray'] )) die ( 'illegal request' ); else { if (in_array ( $accessAuthority, $detail ['cldAccessArray'] )) { if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) { $flag = true; } else { $flag = false; } } else { die ( 'illegal request' ); } } if (! $flag) die ( 'illegal request' ); } function __construct() { if (isset ( $_COOKIE ["staff"] )) { if (! empty ( $_COOKIE ["staff"] )) { Doo::loadModel ( 'staff' ); $staff = new staff (); $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] ); $this->ACTION = $uriPartsOrig [1]; $this->data ['new'] = $this->isInvoiceNew (); $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] ); $this->data ['isStaffCompleteMsg'] = false; $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] ); if (! empty ( $detail )) $this->data ['isStaffCompleteMsg'] = true; return "/"; } } Doo::loadCore ( 'uri/DooUriRouter' ); $router = new DooUriRouter (); $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER ); if ($routeRs ['1'] != "login") { header ( 'Content-Type:text/html;charset=utf-8' ); @header ( "Location: /login" ); } } function invoiceSettlementChange() { $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : ""; $trainId = $this->get_args ( 'trainId' ) ? $this->get_args ( 'trainId' ) : 0; $settlementType = $this->get_args ( 'settlementType' ) ? $this->get_args ( 'settlementType' ) : ""; if (empty ( $this->staff [0] )) { die ( 'illegal request-Please login' ); } if (! empty ( $iidKey ) && ! empty ( $settlementType )) { Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'invoiceTraining' ); $invoiceTraining = new invoiceTraining (); $iid = $XDeode->decode ( $iidKey ); $invoiceDetail = $invoice->getInvoiceByIid ( $iid ); if (empty ( $invoiceDetail )) { die ( 'illegal request-invoiceData NULL' ); } $trainId = $XDeode->decode ( $trainId ); $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainId ); $st = ''; if ($settlementType == 'SOFTWARE') { $st = 0; $trainId = 0; $operation = ' 结算方式 改 软件销售'; } elseif ($settlementType == 'TRAINING') { $st = 1; $operation = ' 结算方式 改 ' . $itDetail ['trainName']; if (empty ( $trainId ) && ! is_numeric ( $trainId )) { die ( 'illegal request-trainingIdError' ); } } else { die ( 'illegal request-settlementError' ); } $invoice->settlementType = $st; $invoice->trainId = $trainId; $invoice->update ( array ( 'where' => 'iid = ' . $iid ) ); Doo::loadModel ( 'invoiceStore' ); $invoiceStore = new invoiceStore (); // 重置结算方式的相关数据 $isSuccess = $invoiceStore->delete ( array ( 'where' => 'iid=' . $iid, 'limit' => 1 ) ); // if($isSuccess){ // $detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail['trainId'] ); // if (!empty($detailIT)){ // $item = array ( // 'itid' => $invoiceDetail['trainId'], // 'invoiceTotal' => $detailIT ['invoiceTotal'] - 1, // ); // $itid = $invoiceTraining->setInvoiceTrainByCondition ( $item ); // } // } // 如果是培训班结算 创建培训班发票到培训班备份中 if (! empty ( $st ) && $st == 1) { $isid = $invoiceStore->setInvoiceToInvoiceStore ( $iid ); $itemIS = array ( 'isid' => $isid, 'ipSource' => 1, 'apStatus' => 1, 'iid' => $iid ); $invoiceStore->setInvoiceStoreByCondition ( $itemIS ); // 更新培训班总数量 $item = array ( 'itid' => $trainId, 'submitStatus' => 1 ); $itid = $invoiceTraining->setInvoiceTrainByCondition ( $item ); } Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); // 操作日志 $invoiceOperationLog->setInvoiceOperationLog ( $item ); $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => $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 "/invoiceApprovalAchieve"; } function invoiceUntreadAdd() { session_start (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $iidKey = isset ( $this->params ['iidKey'] ) ? $this->params ['iidKey'] : ""; $iid = $XDeode->decode ( $iidKey ); 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 ); // 获得继承发票金额合计 $restrictPrice = $invoiceDetail ['invoicePrice']; if (! empty ( $invoiceDetail ['inheritIid'] )) { $restrictList = $invoice->getInvoiceInIid ( $invoiceDetail ['inheritIid'] ); foreach ( $restrictList as $key => $value ) { $restrictPrice -= $value ['invoicePrice']; } } if ($restrictPrice < 0) { $restrictPrice = 0; } $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true ); $token = $this->set_token (); $_SESSION ['token_' . $this->staff [0] ['sidKey']] = $token; $this->data ['token'] = $token; $this->data ['restrictPrice'] = floatval ( $restrictPrice ); $this->data ['operation'] = $operation; $this->data ['invoiceDetail'] = $invoiceDetail; $this->data ['memu'] = "invoice"; $this->data ['staff'] = $this->staff; $this->data ['receiptMemu'] = 'invoice'; $this->render ( "/invoice/invoiceUntreadAdd", $this->data ); } function invoiceUntreadAddDo() { $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' ) && 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' ) : ""; $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0; $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0; $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' ) : ""; $token = $this->get_args ( 'token' ) ? $this->get_args ( 'token' ) : ""; if (empty ( $token )) { die ( 'illegal request-token' ); } else { session_start (); if ($_SESSION ['token_' . $this->staff [0] ['sidKey']] != $token) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '请勿重复申请发票' ); } else { $_SESSION ['token_' . $this->staff [0] ['sidKey']] = ''; } } $temporary = $invoiceQuantity * $invoiceUnitPrice; if ($invoiceType == 1) { if ($temporary > 100000) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '专用发票总金额暂时不能超过100000.00(十万)元。' ); // die ( 'illegal request-Please priceError' ); } } if (empty ( $this->staff [0] )) die ( 'illegal request-Please login' ); if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement )) { Doo::loadModel ( 'L_category' ); $lCategory = new L_category (); Doo::loadModel ( 'invoiceManage' ); $invoiceManage = new invoiceManage (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $categoryDetil = $lCategory->getOne ( array ( 'SELECT' => 'title', 'where' => 'cid=' . $cid, 'asArray' => true ) ); $invoicePrice = $invoiceQuantity * $invoiceUnitPrice; $invoiceManageList = $invoiceManage->getInvoiceByAll (); $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" ); // print_r(current($invoiceManageDetail ['staffList'])); // die; $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']; } $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0]; // 培训班ID--新增关联-发票关系 发票IID关联 $invoice = new invoice (); $invoiceDetail = $invoice->getInvoiceByIid ( $iid ); // 退票后,重新开票金额的限制 $restrictPrice = $invoiceDetail ['invoicePrice']; if (! empty ( $invoiceDetail ['inheritIid'] )) { $restrictList = $invoice->getInvoiceInIid ( $invoiceDetail ['inheritIid'] ); foreach ( $restrictList as $key => $value ) { $restrictPrice -= $value ['invoicePrice']; } } if ($restrictPrice < 0) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '开票金额超出原退票金额-0' ); } else { if ($restrictPrice < $temporary) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '开票金额超出原退票金额-1' ); } } $trainId = $invoiceDetail ['trainId']; $st = 1; if (empty ( $trainId ) && ! is_numeric ( $trainId )) { die ( 'illegal request-trainingIdError' ); } $invoice = new invoice (); $item = array ( 'cid' => $cid, 'categoryName' => $categoryDetil ['title'], 'invoiceElement' => $invoiceElement, 'invoiceQuantity' => $invoiceQuantity, 'invoiceUnitPrice' => $invoiceUnitPrice, 'invoicePrice' => $invoicePrice, 'invoiceType' => $invoiceType, 'settlementType' => $st, 'doPost' => $doPost, 'status' => 1, 'invoiceSerial' => "#F" . date ( 'Ymd' ) . str_pad ( mt_rand ( 1, 99999 ), 5, '0', STR_PAD_LEFT ), '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' => $pendingApprovalsSid, 'moldManage' => json_encode ( $moldManage ), 'remark' => $remark, 'trainId' => $trainId, 'parentUntreadIid' => $trainId ); 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 ); $invoice = new invoice (); if (! empty ( $invoiceDetail ['inheritIid'] )) { $inheritIid = $invoiceDetail ['inheritIid'] . ',' . $iid; } else { $inheritIid = $iid; } $item = array ( 'iid' => $invoiceDetail ['iid'], 'inheritIid' => $inheritIid ); $invoice->setInvoiceByCondition ( $item ); // 如果是培训班结算 创建培训班发票到培训班备份中 if (! empty ( $st ) && $st == 1) { Doo::loadModel ( 'invoiceStore' ); $invoiceStore = new invoiceStore (); Doo::loadModel ( 'invoiceTraining' ); $invoiceTraining = new invoiceTraining (); $isid = $invoiceStore->setInvoiceToInvoiceStore ( $iid ); $itemIS = array ( 'isid' => $isid, 'ipSource' => 1, 'apStatus' => 1, 'iid' => $iid ); $invoiceStore->setInvoiceStoreByCondition ( $itemIS ); // 更新培训班总数量 $detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $trainId ); $item = array ( 'itid' => $trainId, 'invoiceTotal' => $detailIT ['invoiceTotal'] + 1, 'submitStatus' => 1 ); $itid = $invoiceTraining->setInvoiceTrainByCondition ( $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 "/invoiceUntreadED"; } //发票作废 function invoiceInvalid() { $invalidId = $this->get_args ( 'invalidId' ) ? $this->get_args ( 'invalidId' ) : ""; $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "MONTHO"; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'invoiceStatistics' ); $iid = $XDeode->decode ( $invalidId ); if (! is_numeric ( $iid )){ die ( 'illegal request-id' ); } $invoiceDetail = $invoice->getInvoiceByIid ( $iid ); if (empty ( $invoiceDetail )){ die ( 'illegal request-emptyData' ); } if ( $invoiceDetail['untreadStatus']==2&&$invoiceDetail['status']==2&&$invoiceDetail['invalid']==0 ){ $invoice = new invoice (); $invoice->iid = $iid; $invoice->invalid = 1; $invoice->update (); $invoiceStatistics = new invoiceStatistics (); $item = array ( 'date' => $invoiceDetail['date'] , 'priceClass' => 1, 'cid' => $invoiceDetail ['cid'], 'staff' => $invoiceDetail ['sid'], 'invoicePrice' => -$invoiceDetail ['invoicePrice'] ); $invoiceStatistics->setInvoiceStatisticsByCondition ( $item ); return "/invoiceUntreadAchieve/1/".$date; }else{ die ( 'illegal request-status' ); } } //发票撤销作废 function invoiceUndoInvalid() { $invalidId = $this->get_args ( 'invalidId' ) ? $this->get_args ( 'invalidId' ) : ""; $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "MONTHO"; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'invoiceStatistics' ); $iid = $XDeode->decode ( $invalidId ); if (! is_numeric ( $iid )){ die ( 'illegal request-id' ); } $invoiceDetail = $invoice->getInvoiceByIid ( $iid ); if (empty ( $invoiceDetail )){ die ( 'illegal request-emptyData' ); } if ( $invoiceDetail['untreadStatus']==2&&$invoiceDetail['status']==2&&$invoiceDetail['isDelete']==0&&$invoiceDetail['invalid']==1 ){ $invoice = new invoice (); $invoice->iid = $iid; $invoice->invalid = 0; $invoice->update (); $invoiceStatistics = new invoiceStatistics (); $item = array ( 'date' => $invoiceDetail['date'] , 'priceClass' => 1, 'cid' => $invoiceDetail ['cid'], 'staff' => $invoiceDetail ['sid'], 'invoicePrice' => $invoiceDetail ['invoicePrice'] ); $invoiceStatistics->setInvoiceStatisticsByCondition ( $item ); return "/invoiceUntreadAchieve/1/".$date; }else{ die ( 'illegal request-status-发票可能已删除或未退票' ); } } //发票坏账 function invoiceBadDebt(){ $invalidId = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : ""; $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $iid = $XDeode->decode ( $invalidId ); if (! is_numeric ( $iid )){ die ( 'illegal request-id' ); } $invoiceDetail = $invoice->getInvoiceByIid ( $iid ); if (empty ( $invoiceDetail )){ die ( 'illegal request-emptyData' ); } if ($invoiceDetail['untreadStatus']==0&&$invoiceDetail['status']==2&&$invoiceDetail['isDelete']==0&&$invoiceDetail['badDebt']==0 ){ $invoice = new invoice (); $invoice->iid = $iid; $invoice->badDebt = 1; $invoice->update (); // Doo::loadModel ( 'invoiceStatistics' ); // $invoiceStatistics = new invoiceStatistics (); // $item = array ( // 'date' => $invoiceDetail['date'] , // 'priceClass' => 1, // 'cid' => $invoiceDetail ['cid'], // 'staff' => $invoiceDetail ['sid'], // 'invoicePrice' => $invoiceDetail ['invoicePrice'] // ); // $invoiceStatistics->setInvoiceStatisticsByCondition ( $item ); if(empty($status)){ return "/invoiceAS"; }else{ return "/invoiceAS/1/".$status; } }else{ die ( 'illegal request-status' ); } } /** * 旧输入导入 */ function _GetFileEXT($filename) { $pics = explode ( '.', $filename ); $num = count ( $pics ); return $pics [$num - 1]; } /** * 生成token * @return string */ function set_token() { $str = md5 ( uniqid ( md5 ( microtime ( true ) ), true ) ); // 生成一个不会重复的字符串 $str = sha1 ( $str ); // 加密 return $str; } /** * 获取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 .= '