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-iacd' );
}
// 单独判断应收款访问权限
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 = 'INVOICE';
if (empty ( $detail ['cldAccessArray'] ))
die ( 'illegal request' );
else {
if (in_array ( $accessModular, $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 testSend() {
// 测试根据规则发送信息 普通发送
// $pendingApprovalsSid = 41;
// Doo::loadModel ( 'staff' );
// $staff = new staff ();
// $username2 = $staff->getOne ( array ( 'select' => 'wxid', 'where' => 'sid=' . $pendingApprovalsSid, 'asArray' => TRUE ) );
// // 发送微信审批通知
// $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
// $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
// Doo::loadModel ( 'staff' );
// $staff = new staff ();
// $toparty = $this->getToparty ( '广东办' );
// $wxList = array ();
// if (! empty ( $toparty )) {
// $userList = $this->getUserByToparty ( $toparty );
// $userCon = implode ( ',', $userList );
// // echo $userCon;
// $sidList = $staff->getStaffByWxid ( $userCon );
// foreach ( $sidList as $key => $value ) {
// $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
// if ($falg) {
// array_push ( $wxList, $value ['wxid'] );
// }
// }
// $wxString = implode ( '|', $wxList );
// print_r ( $wxList );
// echo $wxString;
// }
// 测试发送
/*
* //$toparty = $this->getWxidByCategory( $receivablesCategory [1] ); $toparty = $this->getToparty ( $receivablesCategory [1] ); $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。'; if ($toparty != 0) $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
*/
// print_r ( $userList );
// $msTouser='caipin|outaozhen';
// $toparty = $this->getToparty ( $receivablesCategory [1] );
// $title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
// $hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
// $toparty= $this->getToparty('广东办');
// $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
// $toparty = 26;
// $msg = '';
// $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
// $hfreult = $this->msgSendToparty ( $msg, '', '', $toparty,'text' );
}
function invoice() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'express' );
$express = new express ();
$expressList = $express->getExpressByAll ();
$this->data ['expressList'] = $expressList;
// Doo::loadModel ( 'invoiceReceivables' );
// $invoiceReceivables = new invoiceReceivables ();
// $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$sid = $XDeode->decode ( $_COOKIE ["staff"] );
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$isMonth = $invoiceStatistics->getStatisticsByMonth ( $sid );
// 缓存统计结果
$year = date ( "Y" );
$tmp_date = date ( "Ym" );
$tmp_year = substr ( $tmp_date, 0, 4 );
$tmp_mon = substr ( $tmp_date, 4, 2 );
$tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
$fm_forward_month = date ( "m", $tmp_forwardmonth );
$path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . "_" . $sid . ".htm";
if (is_file ( $path ))
$htm = file_get_contents ( $path );
else
$htm = $this->showCache ( $path, $sid );
$invoiceList = $invoice->getMyInvoice ( $sid );
$sql = 'status=2 and printStatus=1 and irid!="" and sid=' . $sid;
$list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
// 我的待入账发票 and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
$sql = "status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid=" . $sid;
$myInvoiceUnAccount = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
// 获得已退票功能
$untreadStatusList = $invoice->getMyInvoiceByUntreadStatus ( 2, 0, 5, $sid );
$this->data ['untreadStatusList'] = $untreadStatusList;
// print_r($untreadStatusList);
$this->data ['isMonth'] = $isMonth;
$this->data ['htm'] = $htm;
$this->data ['invoiceList'] = $invoiceList;
$this->data ['receivablesList'] = $list;
$this->data ['myInvoiceUnAccount'] = $myInvoiceUnAccount;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoice';
$this->render ( "/admin/invoice", $this->data );
}
function invoiceExpress() {
$expressCom = isset ( $this->params ['expressCom'] ) ? $this->params ['expressCom'] : "";
$expressNumber = isset ( $this->params ['expressNumber'] ) ? $this->params ['expressNumber'] : "";
$this->data ['expressCom'] = $expressCom;
$this->data ['expressNumber'] = $expressNumber;
$this->render ( "/admin/invoiceExpress", $this->data );
}
function invoiceAdd() {
session_start ();
/*Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$detail = $invoice->getInvoiceByNew ( $this->staff [0] ['sid'] );*/
Doo::loadModel ( 'L_category' );
$lCategory = new L_category ();
$category = $lCategory->find ( array (
'asArray' => true
) );
$this->data ['category'] = $category;
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$itList = $invoiceTraining->getInvoiceTrainingByCid ( $this->staff [0] ['cid'] );
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
foreach ( $itList as $key => $value ) { // 不展示已结算完结的培训班
$receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $value ['itid'] );
if (! empty ( $receiptDetail )) {
if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9) {
unset ( $itList [$key] );
}
}
}
$this->data ['itList'] = $itList;
$token = $this->set_token ();
$tokenTime=time().rand(5, 15);
$_SESSION ['token_' . $this->staff [0] ['sidKey'].'_'.$tokenTime] = $token;
$this->data ['token'] = $token;
$this->data['tokenTime']=$tokenTime;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoice';
$this->render ( "/admin/invoiceAdd", $this->data );
}
/**
* 自更新发票信息库
* @param unknown $invoicePrintDetail
*/
function autoUpdateInvoiceInfoBase($invoicePrintDetail) {
// 发票信息库
Doo::loadModel ( 'invoiceInfoBase' );
$invoiceInfoBase = new invoiceInfoBase ();
$updateDate = strtotime ( $invoicePrintDetail ['date'] );
$TIN = $invoicePrintDetail ['TIN'];
$invoiceTitle = $invoicePrintDetail ['invoiceTitle'];
if (empty ( $invoiceTitle ))
$invoiceTitle = $invoicePrintDetail ['invoiceCompany'];
$IIBList = $invoiceInfoBase->getInvoiceInfoByTT ( $TIN, $invoiceTitle );
// 确认有该条发票信息
$invoiceInfoBase = new invoiceInfoBase ();
if (! empty ( $IIBList )) {
// 发票库里的信息数量
$IIBListCount = count ( $IIBList );
if ($IIBListCount == 1) { // 更新发票--提交是最新的时间
$item = array (
'iibID' => $IIBList [0] ['iibID'],
'invoiceTitle' => $invoiceTitle,
'TIN' => $TIN
);
if (! empty ( $invoicePrintDetail ['address'] )) {
$item += array (
'address' => $invoicePrintDetail ['address']
);
}
if (! empty ( $invoicePrintDetail ['phone'] )) {
$item += array (
'phone' => $invoicePrintDetail ['phone']
);
}
if (! empty ( $invoicePrintDetail ['bank'] )) {
$item += array (
'bank' => $invoicePrintDetail ['bank']
);
}
if (! empty ( $invoicePrintDetail ['bankAccount'] )) {
$item += array (
'bankAccount' => $invoicePrintDetail ['bankAccount']
);
}
if ($updateDate >= strtotime ($IIBList [0] ['updateDate'])) {
$item += array (
'updateDate' => $invoicePrintDetail ['date']
);
$invoiceInfoBase->setInvoiceInfoBaseByCondition ( $item );
}
} else { // 删除多张发票,重新添加发票
$iibIDStr = '';
$iibID = array ();
foreach ( $IIBList as $key => $value ) {
array_push ( $iibID, $value ['iibID'] );
}
$iibIDStr = implode ( ",", $iibID ); // 删除
$invoiceInfoBase->delInvoiceInfoBaseByIibStr ( $iibIDStr );
$item = array (
'invoiceTitle' => $invoiceTitle,
'TIN' => $TIN,
'address' => $invoicePrintDetail ['address'],
'phone' => $invoicePrintDetail ['phone'],
'bank' => $invoicePrintDetail ['bank'],
'bankAccount' => $invoicePrintDetail ['bankAccount'],
'updateDate' => $invoicePrintDetail ['date']
);
$invoiceInfoBase->addInvoiceInfoBase ( $item );
}
} else { // 没有新增发票信息
$item = array (
'invoiceTitle' => $invoiceTitle,
'TIN' => $TIN,
'address' => $invoicePrintDetail ['address'],
'phone' => $invoicePrintDetail ['phone'],
'bank' => $invoicePrintDetail ['bank'],
'bankAccount' => $invoicePrintDetail ['bankAccount'],
'updateDate' => $invoicePrintDetail ['date']
);
$invoiceInfoBase->addInvoiceInfoBase ( $item );
}
}
function invoiceAddFill() {
session_start ();
Doo::loadModel ( 'L_category' );
$lCategory = new L_category ();
$category = $lCategory->find ( array (
'asArray' => true
) );
$this->data ['category'] = $category;
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$itList = $invoiceTraining->getInvoiceTrainingByCid ( $this->staff [0] ['cid'] );
$this->data ['itList'] = $itList;
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$detail = $invoice->getInvoiceByNew ( $this->staff [0] ['sid'] );
$detail ['mailItemsArray'] = json_decode ( $detail ['mailItemsJson'], true );
$token = $this->set_token ();
$tokenTime=time().rand(5, 15);
$_SESSION ['token_' . $this->staff [0] ['sidKey'].'_'.$tokenTime] = $token;
$this->data ['token'] = $token;
$this->data['tokenTime']=$tokenTime;
$this->data ['invoiceDetail'] = $detail;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoice';
$this->render ( "/admin/invoiceAddFill", $this->data );
}
/**
* 提交一份开票申请,并记录下操作日志
*
* @since 1.0.0
* @var integer cid 办事处ID
* @var integer invoiceType 发票类型
* @var integer doPost 是否邮寄
* @var integer invoicePrice 开票金额
* @var string invoiceElement 开票内容
* @var string invoiceTitle 发票抬头
* @var string invoiceCompany 单位名称
* @var string TIN 纳税人识别码
* @var string address 注册地址
* @var string phone 注册电话
* @var string bank 开户银行
* @var string bankAccount 银行账户
* @var string recipients 收件人
* @var string recipientsPhone 收件人手机/电话
* @var string recipientsAddress 收件地址
* @var string mailItems 邮寄物品
* @var string remark 备注
* @return string 返回跳转开票主页路径
*/
function invoiceAddDo() {
$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
$invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
$doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
// $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
$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' ) : "";
$trainId = $this->get_args ( 'trainId' ) ? $this->get_args ( 'trainId' ) : 0;
$settlementType = $this->get_args ( 'settlementType' ) ? $this->get_args ( 'settlementType' ) : "";
/*
* $mailList=array(); array_push($mailList, array('invoice'=>1)); array_push($mailList, array('mailItems'=>$mailItems)); if (!empty($softLock)) array_push($mailList, array('softLock'=>$softLockNum)); if (!empty($contract)) array_push($mailList, array('contract'=>$contractNum)); if (!empty($instructions)) array_push($mailList, array('instructions'=>$instructionsNum)); if (!empty($remittance)) array_push($mailList, array('remittance'=>$remittance)); echo json_encode($mailList) ; print_r($mailList); die;
*/
$token = $this->get_args ( 'token' ) ? $this->get_args ( 'token' ) : "";
$tokenTime = $this->get_args ( 'tokenTime' ) ? $this->get_args ( 'tokenTime' ) : "";
if (empty ( $token )) {
die ( 'illegal request-token' );
} else {
session_start ();
$sessionKey='token_' . $this->staff [0] ['sidKey'].'_'.$tokenTime;
header ( 'Content-Type:text/html;charset=utf-8' );
if (!isset($_SESSION [$sessionKey])||empty($_SESSION [$sessionKey])) {
die ( '请重新刷新发票申请页面' );
}elseif($_SESSION [$sessionKey]=='repeat'){
die ( '请勿重复申请发票' );
} else {
echo $_SESSION [$sessionKey].'
'.$token;
if ($_SESSION [$sessionKey] != $token){
die ( '请勿重复申请发票' );
}else{
$_SESSION [$sessionKey] = 'repeat';
}
}
}
if ($invoiceType == 1) {
$temporary = $invoiceQuantity * $invoiceUnitPrice;
if ($temporary > 10000) {
header ( 'Content-Type:text/html;charset=utf-8' );
die ( '专用发票总金额暂时不能超过10000.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 ) && ! empty ( $settlementType )) {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'L_category' );
$lCategory = new L_category ();
Doo::loadModel ( 'invoiceManage' );
$invoiceManage = new invoiceManage ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainId = $XDeode->decode ( $trainId );
$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];
$st = '';
if ($settlementType == 'SOFTWARE') {
$st = 0;
$trainId = 0;
} elseif ($settlementType == 'TRAINING') {
$st = 1;
if (empty ( $trainId ) && ! is_numeric ( $trainId )) {
die ( 'illegal request-trainingIdError' );
}
} else {
die ( 'illegal request-settlementError' );
}
$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
);
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 );
// 如果是培训班结算 创建培训班发票到培训班备份中
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 );
Doo::loadModel ( 'staff' );
$staff = new staff ();
$username2 = $staff->getOne ( array (
'select' => 'wxid',
'where' => 'sid=' . $pendingApprovalsSid,
'asArray' => TRUE
) );
// 发送微信审批通知
$title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
$this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
}
return "/invoice";
}
function invoiceEdit() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
$iid = $XDeode->decode ( $iid );
if (! is_numeric ( $iid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
$operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
$invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
$this->data ['operation'] = $operation;
$this->data ['invoiceDetail'] = $invoiceDetail;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoice';
$this->render ( "/admin/invoiceEdit", $this->data );
}
/**
* 重新编辑退回的发票
* @return string
*/
function invoiceEditDo() {
$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$iid = $invoice->authcode ( $iidKey );
if (! empty ( $iid ) && ! is_numeric ( $iid ))
die ( 'illegal request' );
$cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
$invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
$doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
$invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
$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' ) : "";
$mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
$remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
$TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
$addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
$phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
$bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
$bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
$softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
$softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
$contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
$contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
$instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
$instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
$remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
if ($invoiceType == 1) {
$temporary = $invoiceQuantity * $invoiceUnitPrice;
if ($temporary > 10000)
die ( 'illegal request-Please priceError' );
}
if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
Doo::loadModel ( 'invoiceManage' );
$invoiceManage = new invoiceManage ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
$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'];
}
$invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
$item = array (
'iid' => $iid,
'cid' => $cid [0],
'categoryName' => $cid [1],
'invoiceElement' => $invoiceElement,
'invoiceQuantity' => $invoiceQuantity,
'invoiceUnitPrice' => $invoiceUnitPrice,
'invoicePrice' => $invoicePrice,
'invoiceType' => $invoiceType,
'doPost' => $doPost,
'status' => 1,
'updateTime' => date ( "Y-m-d H:i:s" ),
'remark' => $remark
);
if ($invoiceType == 0)
$item += array (
'invoiceTitle' => $invoiceTitle,
'TIN' => $TINT,
'address' => $addressT,
'phone' => $phoneT,
'bank' => $bankT,
'bankAccount' => $bankAccountT
);
else {
$item += array (
'invoiceCompany' => $invoiceCompany,
'TIN' => $TIN,
'address' => $address,
'phone' => $phone,
'bank' => $bank,
'bankAccount' => $bankAccount
);
}
if ($doPost == 1) {
$mailList = array (
'invoice' => 1,
'mailItems' => $mailItems
);
if (! empty ( $softLock ))
$mailList += array (
'softLock' => $softLockNum
);
else
$mailList += array (
'softLock' => '0'
);
if (! empty ( $contract ))
$mailList += array (
'contract' => $contractNum
);
else
$mailList += array (
'contract' => '0'
);
if (! empty ( $instructions ))
$mailList += array (
'instructions' => $instructionsNum
);
else
$mailList += array (
'instructions' => '0'
);
if (! empty ( $remittance ))
$mailList += array (
'remittance' => $remittance
);
else
$mailList += array (
'remittance' => ''
);
$mailString = '发票x1,备注:' . $mailItems;
if (! empty ( $softLock ))
$mailString .= ',软件锁x' . $softLockNum;
if (! empty ( $contract ))
$mailString .= ',合同x' . $contractNum;
if (! empty ( $instructions ))
$mailString .= ',说明书x' . $instructionsNum;
if (! empty ( $remittance ))
$mailString .= ',汇款账号单';
$item += array (
'recipients' => $recipients,
'recipientsPhone' => $recipientsPhone,
'recipientsAddress' => $recipientsAddress,
'mailItems' => $mailString,
'mailItemsJson' => json_encode ( $mailList )
);
}
$invoice->setInvoiceByCondition ( $item );
// 更新培训班仓库里的发票
$detail = $invoice->getInvoiceByIid ( $iid );
if (! empty ( $detail ['isid'] )) {
$invoiceStore->isid = $detail ['isid'];
$invoiceStore->invoiceQuantity = $invoiceQuantity;
$invoiceStore->invoiceUnitPrice = $invoiceUnitPrice;
$invoiceStore->invoicePrice = $invoicePrice;
$invoiceStore->update ();
}
$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 invoiceTraining() {
Doo::loadModel ( 'L_category' );
$lCategory = new L_category ();
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
Doo::loadModel ( 'invoiceTrainManage' );
$invoiceTrainManage = new invoiceTrainManage ();
$imcStaff = $invoiceTrainManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
$cidList = array ();
foreach ( $imcStaff as $key => $value ) {
array_push ( $cidList, $value ['cid'] );
}
if (empty ( $cidList )) {
$cidString = $this->staff [0] ['cid'];
} else {
$cidString = implode ( ',', $cidList );
$cidString .= $cidString . ',' . $this->staff [0] ['cid'];
}
$itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $cidString, $this->staff [0] ['sid'] );
$itedList = $invoiceTraining->getInvoiceTrainingByStatus ( 2, '', $cidString, $this->staff [0] ['sid'] );
$category = $lCategory->getCategory ();
$itid = array ();
foreach ( $itTodoList as $key => $value ) {
array_push ( $itid, $value ['itid'] );
// 如果入账100%更新为已完成
if ($itTodoList [$key] ['arriveSchedule'] >= 100) {
$invoiceTraining = new invoiceTraining ();
$invoiceTraining->itid = $value ['itid'];
$invoiceTraining->status = 2;
$invoiceTraining->update ();
}
}
foreach ( $itedList as $value ) {
array_push ( $itid, $value ['itid'] );
}
$itid = implode ( ',', $itid );
$this->data ['itStatist'] = $invoiceTraining->getInvoiceTrainStatistics ( $itid );
// print_r($itTodoList);
$this->data ['trainCount'] = count ( $itTodoList ) + count ( $itedList );
$this->data ['itTodoList'] = $itTodoList;
$this->data ['itedList'] = $itedList;
$this->data ['category'] = $category;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceTraining';
$this->render ( "/admin/invoiceTraining", $this->data );
}
/**
* 创建培训班
*/
function invoiceTrainingAdd() {
$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
$trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
$trainDate = $this->get_args ( 'trainDate' ) ? $this->get_args ( 'trainDate' ) : "";
if (empty ( $this->staff [0] ))
die ( 'illegal request' );
if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate )) {
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
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 ();
$item = array (
'cid' => $cid,
'trainName' => $trainName,
'trainDate' => $trainDate,
'creator' => $this->staff [0] ['sid'],
'creatorDate' => date ( "Y-m-d H:i:s" )
);
$itid = $invoiceTraining->addInvoiceTraining ( $item );
}
return "/invoiceTraining";
}
/**
* 删除培训班
*/
function invoiceTrainingDelDo() {
$itid = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
if (! empty ( $itid )) {
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$invoiceTraining->delInvoiceTrainingByItid ( $itid );
}
return "/invoiceTraining";
}
/**
* 培训班详情
*/
function invoiceTrainingDetail() {
$trainStatus = $this->get_args ( 'trainStatus' ) ? $this->get_args ( 'trainStatus' ) : "ALL";
$itid = isset ( $this->params ['trainingKey'] ) ? $this->params ['trainingKey'] : "";
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
if (empty ( $itid ))
die ( 'illegal request' );
$con = ' (b.untreadStatus is null or b.untreadStatus!=2) and ';
if ($trainStatus == "SUBED")
$con = ' (b.untreadStatus is null ) and ';
elseif ($trainStatus == "APPROVAL")
$con = ' ( b.status=1 and b.untreadStatus!=2 ) and ';
elseif ($trainStatus == "TICKET")
$con = ' (b.printStatus=1 and b.status=2 and b.untreadStatus!=2) and ';
elseif ($trainStatus == "TICKETING") {
$con = ' (b.status=2 and b.untreadStatus=1) and ';
}
$detail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
$isList = $invoiceStore->getinvoiceStoreByItid ( $itid, $con );
//print_r($isList);
$trainlist = array ();
foreach ( $isList as $key => $value ) {
$irDetail = array ();
if ($value ['apStatus'] == 1) {
// array_push ( $irDetail, '' );
array_push ( $irDetail, '' );
} else {
array_push ( $irDetail, ' 编辑
提交审批
移除' );
}
array_push ( $irDetail, $value ['invoiceSerial'] );
if ($value ['invoiceType'] == 1)
array_push ( $irDetail, $value ['invoiceCompany'] );
else
array_push ( $irDetail, $value ['invoiceTitle'] );
array_push ( $irDetail, $value ['TIN'] );
array_push ( $irDetail, $value ['userName'] );
if (empty ( $value ['mailItems'] ) && $value ['apStatus'] != 1) {
array_push ( $irDetail, '设置邮寄物品' );
} else
array_push ( $irDetail, $value ['mailItems'] );
array_push ( $irDetail, $value ['recipientsAddress'] . $value ['recipients'] . $value ['recipientsPhone'] );
array_push ( $irDetail, $value ['address'] . $value ['phone'] );
array_push ( $irDetail, $value ['bank'] . $value ['bankAccount'] );
array_push ( $irDetail, $value ['invoiceElement'] );
array_push ( $irDetail, $value ['invoiceQuantity'] );
array_push ( $irDetail, $value ['invoiceUnitPrice'] );
if ($value ['invoiceType'] == 1)
array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '专' );
else
array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
array_push ( $irDetail, $value ['remark'] );
if ($value ['status'] == 1)
array_push ( $irDetail, '审批中' );
elseif ($value ['status'] == 2 && $value ['printStatus'] == 1)
array_push ( $irDetail, '已出票' );
elseif ($value ['status'] == 2 && $value ['printStatus'] == 1 && $value ['printStatus'] != 'irid' && ($value ['untreadStatus'] == 3 || $value ['untreadStatus'] == 0))
array_push ( $irDetail, '已入账' );
else
array_push ( $irDetail, '' );
array_push ( $irDetail, $value ['invoiceNo'] );
array_push ( $irDetail, $value ['printTime'] );
$html = '';
foreach ( $value ['invoiceReceivables'] as $value ) {
$html .= ' ' . $value [1] . '';
}
array_push ( $irDetail, $html );
array_push ( $trainlist, $irDetail );
}
$trainlistJson = json_encode ( $trainlist );
if (empty ( $detail ))
die ( 'illegal request' );
// 培训班结算是否有和是否已经结算完成
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
$receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $itid );
$this->data ['receiptDetail'] = $receiptDetail;
$this->data ['trainStatus'] = $trainStatus;
$this->data ['itid'] = $itid;
$this->data ['trainlistJson'] = $trainlistJson;
$this->data ['iTrainDetail'] = $detail;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceTraining';
$this->render ( "/admin/invoiceTrainingDetail", $this->data );
}
/**
* 上传培训班发票
* @return string
*/
function invoiceTrainingUpload() {
$POST_MAX_SIZE = ini_get ( 'post_max_size' );
$unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
$multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
header ( "HTTP/1.1 500 Internal Server Error" );
echo "POST exceeded maximum allowed size.";
exit ( 0 );
}
// Settings
$save_path = DOO::conf ()->SITE_PATH . "upload/invoiceTraining/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
$upload_name = "Filedata";
$max_file_size_in_bytes = 2147483647; // 2GB in bytes
$extension_whitelist = array (
"doc",
"txt",
"jpg",
"gif",
"png"
); // Allowed file extensions
$valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
// Other variables
$MAX_FILENAME_LENGTH = 260;
$file_name = "";
$file_extension = "";
$uploadErrors = array (
0 => "文件上传成功",
1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
3 => "上传的文件仅为部分文件",
4 => "没有文件上传",
6 => "缺少临时文件夹"
);
$nk = time ();
$file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
echo "文件无法保存.";
exit ( 0 );
}
// Return output to the browser (only supported by SWFUpload for Flash Player 9)
echo json_encode ( array (
'filename' => $file_name,
'id' => $nk
) );
exit ( 0 );
}
/**
* 导入发票临时仓库
*/
function invoiceStoreImport() {
// include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
$trainingKey = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
$path = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
if ($path != "" && ! empty ( $trainingKey )) {
Doo::loadModel ( 'invoiceStore' );
Doo::loadModel ( 'staff' );
$staff = new staff ();
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$itid = $XDeode->decode ( $trainingKey );
// 培训班结算是否有和是否已经结算完成
Doo::loadModel ( 'receipt' );
$receipt = new receipt ();
$receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $itid );
if (! empty ( $receiptDetail )) {
if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9)
die ( 'illegal request--status' );
}
$exlArray = $this->formatExcelToArrayTrain ( DOO::conf ()->SITE_PATH . "upload/invoiceTraining/" . $path );
$userName = $this->staff [0] ['username'];
$sDetail = $staff->getStaffByName ( $userName );
// die('sdd');
// 可以优化
foreach ( $exlArray as $key => $value ) {
// 开票
$invoice = new invoiceStore ();
$invoice->trainId = $itid;
$invoice->invoiceType = 0;
if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
$invoice->invoiceType = 1;
$invoice->invoiceQuantity = $value ['invoiceQuantity'];
$invoice->invoiceUnitPrice = $value ['invoiceUnitPrice'];
$invoice->invoicePrice = $value ['invoiceQuantity'] * $value ['invoiceUnitPrice'];
$invoice->invoiceTitle = $value ['invoiceTitle'];
if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
$invoice->invoiceCompany = $value ['invoiceTitle'];
$invoice->userName = $userName;
$invoice->sid = $sDetail ['sid'];
$invoice->cid = $sDetail ['cid'];
$invoice->categoryName = $sDetail ['category'];
$invoice->invoiceElement = $value ['invoiceElement'];
$invoice->remark = $value ['remark'];
// $invoice->date = $value ['date'];
// $invoice->printTime = $value ['date'];
$invoice->ipSource = 1;
$invoice->printStatus = 0;
$invoice->status = 0;
$invoice->postStatus = 1;
$invoice->untreadStatus = 0;
// $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
$invoice->TIN = $value ['TIN'];
$invoice->address = $value ['address'];
$invoice->phone = $value ['phone'];
$invoice->bank = $value ['bank'];
$invoice->bankAccount = $value ['bankAccount'];
$invoice->recipientsAddress = $value ['recipientsAddress'];
$invoice->recipients = $value ['recipients'];
$invoice->recipientsPhone = $value ['recipientsPhone'];
$iid = $invoice->insert ();
}
// 加入发票总数量
$item = array (
'itid' => $itid,
'invoiceTotal' => count ( $exlArray )
);
$invoiceTraining->setInvoiceTrainByCondition ( $item );
return '/invoiceTrainingDetail/' . $trainingKey . ".html";
}
echo 'no file';
}
/**
* 编辑仓库里的发票
*/
function invoiceStoreEdit() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$iid = isset ( $this->params ['storeKey'] ) ? $this->params ['storeKey'] : "";
$iid = $XDeode->decode ( $iid );
if (! is_numeric ( $iid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
$invoiceDetail = $invoiceStore->getInvoiceStoreByIsid ( $iid );
// print_r($invoiceDetail);
$invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
$this->data ['invoiceDetail'] = $invoiceDetail;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceTraining';
$this->render ( "/admin/invoiceStoreEdit", $this->data );
}
function invoiceStoreEditDo() {
$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
Doo::loadModel ( 'invoiceStore' );
$invoice = new invoiceStore ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$iid = $XDeode->decode ( $storeKey );
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' ) : "";
$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' ) : "";
$mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
$remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
$TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
$addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
$phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
$bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
$bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
$softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
$softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
$contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
$contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
$instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
$instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
$remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
$cid = explode ( ':', $cid );
$invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
$item = array (
'isid' => $iid,
'cid' => $cid [0],
'categoryName' => $cid [1],
'invoiceElement' => $invoiceElement,
'invoiceQuantity' => $invoiceQuantity,
'invoiceUnitPrice' => $invoiceUnitPrice,
'invoicePrice' => $invoicePrice,
'invoiceType' => $invoiceType,
'doPost' => $doPost,
'status' => 1,
'updateTime' => date ( "Y-m-d H:i:s" ),
'remark' => $remark
);
if ($invoiceType == 0)
$item += array (
'invoiceTitle' => $invoiceTitle,
'TIN' => $TINT,
'address' => $addressT,
'phone' => $phoneT,
'bank' => $bankT,
'bankAccount' => $bankAccountT
);
else {
$item += array (
'invoiceCompany' => $invoiceCompany,
'TIN' => $TIN,
'address' => $address,
'phone' => $phone,
'bank' => $bank,
'bankAccount' => $bankAccount
);
}
if ($doPost == 1) {
$mailList = array (
'invoice' => 1,
'mailItems' => $mailItems
);
if (! empty ( $softLock ))
$mailList += array (
'softLock' => $softLockNum
);
else
$mailList += array (
'softLock' => '0'
);
if (! empty ( $contract ))
$mailList += array (
'contract' => $contractNum
);
else
$mailList += array (
'contract' => '0'
);
if (! empty ( $instructions ))
$mailList += array (
'instructions' => $instructionsNum
);
else
$mailList += array (
'instructions' => '0'
);
if (! empty ( $remittance ))
$mailList += array (
'remittance' => $remittance
);
else
$mailList += array (
'remittance' => ''
);
$mailString = '发票x1,备注:' . $mailItems;
if (! empty ( $softLock ))
$mailString .= ',软件锁x' . $softLockNum;
if (! empty ( $contract ))
$mailString .= ',合同x' . $contractNum;
if (! empty ( $instructions ))
$mailString .= ',说明书x' . $instructionsNum;
if (! empty ( $remittance ))
$mailString .= ',汇款账号单';
$item += array (
'recipients' => $recipients,
'recipientsPhone' => $recipientsPhone,
'recipientsAddress' => $recipientsAddress,
'mailItems' => $mailString,
'mailItemsJson' => json_encode ( $mailList )
);
}
$invoice->setInvoiceStoreByCondition ( $item );
}
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
*
* @return string
*/
function invoiceStoreDelete() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
$iStoreKey = $this->get_args ( 'iStoreKey' ) ? $this->get_args ( 'iStoreKey' ) : 0;
$isid = $XDeode->decode ( $iStoreKey );
$itid = $XDeode->decode ( $trainKey );
if (! is_numeric ( $isid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
$invoiceStore->delete ( array (
'where' => 'isid=' . $isid,
'limit' => 1
) );
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
$item = array (
'itid' => $itid,
'invoiceTotal' => $itDetail ['invoiceTotal'] - 1
);
$invoiceTraining->setInvoiceTrainByCondition ( $item );
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
* 批量删除库里发票
*/
function invoiceStoreBatchDelete() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
if (empty ( $trainKey ) || empty ( $storeKey ))
die ( 'illegal request-IdKey' );
$tid = $XDeode->decode ( $trainKey );
if (! is_numeric ( $tid ) && ! empty ( $storeKey ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
$isidKeyList = explode ( ',', $storeKey );
$isidList = array ();
foreach ( $isidKeyList as $value ) {
$isid = $XDeode->decode ( $value );
if (! empty ( $isid ) && is_numeric ( $isid ))
array_push ( $isidList, $isid );
}
$isidString = implode ( ',', $isidList );
$invoiceStore = new invoiceStore ();
$isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,apStatus' );
$isidList = array ();
foreach ( $isList as $key => $value ) {
if ($value ['apStatus'] == 0)
array_push ( $isidList, $value ['isid'] );
}
$isidString = implode ( ',', $isidList );
// print_r($isList);
// echo $isidString;
$invoiceStore = new invoiceStore ();
$invoiceStore->delete ( array (
'where' => "isid in ( " . $isidString . ")",
'asArray' => TRUE
) );
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
$item = array (
'itid' => $tid,
'invoiceTotal' => $itDetail ['invoiceTotal'] - count ( $isidList )
);
$invoiceTraining->setInvoiceTrainByCondition ( $item );
// echo $tid;
// echo $storeKey;
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
* 仓库发票提交审批
* @return string
*/
function invoiceStoreApproval() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
$iStoreKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
$isid = $XDeode->decode ( $iStoreKey );
$trainId = $XDeode->decode ( $trainKey );
if (! is_numeric ( $isid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
// 加入限制必须填写入开票内容和邮寄物品
$invoiceStore = new invoiceStore ();
$isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid, 'isid,trainId ,invoiceElement,mailItemsJson' );
if (empty ( $isDetail ['invoiceElement'] ) || empty ( $isDetail ['mailItemsJson'] )) {
header ( 'Content-Type:text/html;charset=utf-8' );
die ( 'illegal request! 请设置开票内容或邮寄物品' );
}
// 拷贝插入一条发票数据
$invoiceStore = new invoiceStore ();
$iid = $invoiceStore->setInvoiceStoreToApproval ( $isid );
$invoiceStore = new invoiceStore ();
$item = array (
'isid' => $isid,
'iid' => $iid,
'apStatus' => 1
);
$invoiceStore->setInvoiceStoreByCondition ( $item );
Doo::loadModel ( 'invoiceManage' );
$invoiceManage = new invoiceManage ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
$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'];
}
$pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
$item = array (
'iid' => $iid,
'isid' => $isid,
'invoiceSerial' => "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
'date' => date ( "Y-m-d H:i:s" ),
'status' => 1,
'updateTime' => date ( "Y-m-d H:i:s" ),
'trainId' => $trainId,
'invoiceManage' => $invoiceManageDetail ['staff'],
'moldManage' => json_encode ( $moldManage ),
'settlementType' => 1,
'pendingApprovals' => $pendingApprovalsSid
);
$invoice->setInvoiceByCondition ( $item );
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$item = array (
'itid' => $trainId,
'submitStatus' => 1
);
$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 );
Doo::loadModel ( 'staff' );
$staff = new staff ();
$username2 = $staff->getOne ( array (
'select' => 'wxid',
'where' => 'sid=' . $pendingApprovalsSid,
'asArray' => TRUE
) );
// 发送微信审批通知
$title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
$this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
* 批量提交发票
* @return string
*/
function invoiceStoreBatchApproval() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
if (empty ( $trainKey ) || empty ( $storeKey ))
die ( 'illegal request-IdKey' );
$trainId = $XDeode->decode ( $trainKey );
$isidKeyList = explode ( ',', $storeKey );
$isidList = array ();
foreach ( $isidKeyList as $value ) {
$isid = $XDeode->decode ( $value );
if (! empty ( $isid ) && is_numeric ( $isid ))
array_push ( $isidList, $isid );
}
$isidString = implode ( ',', $isidList );
if (! is_numeric ( $trainId ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
Doo::loadModel ( 'invoice' );
// 判断哪些已经加入审批过
// 加入限制必须填写入开票内容和邮寄物品
$invoiceStore = new invoiceStore ();
$isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,trainId ,invoiceElement,mailItemsJson' );
foreach ( $isList as $key => $value ) {
if (empty ( $value ['invoiceElement'] ) || empty ( $value ['mailItemsJson'] )) {
header ( 'Content-Type:text/html;charset=utf-8' );
die ( 'illegal request! 请设置开票内容或邮寄物品' );
}
}
// 拷贝插入一条发票数据
$invoiceStore = new invoiceStore ();
$invoiceStore->setInvoiceStoreBatchToApproval ( $isidString );
$invoiceStore = new invoiceStore ();
$item = array (
'apStatus' => 1
);
$invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
// 获得正式发票ID
$invoice = new invoice ();
$iidList = $invoice->getInvoiceByIstoreid ( $isidString, 'iid,isid' );
$sqlList = array ();
$iidString = '';
$iida = array ();
foreach ( $iidList as $key => $value ) {
$sqlList [$value ['isid']] = $value ['iid'];
array_push ( $iida, $value ['iid'] );
}
$iidString = implode ( ',', $iida );
$ids = implode ( ',', array_keys ( $sqlList ) );
$sql = "UPDATE CLD_invoiceStore SET iid = CASE isid ";
foreach ( $sqlList as $id => $ordinal ) {
$sql .= sprintf ( "WHEN %d THEN %d ", $id, $ordinal );
}
$sql .= "END WHERE isid IN ($ids)";
$invoiceStore = new invoiceStore ();
$invoiceStore->UpdateBatchInvoiceStore ( $sql );
Doo::loadModel ( 'invoiceManage' );
$invoiceManage = new invoiceManage ();
$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'];
}
$pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
// 批量更新发票信息
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'status' => 1,
'updateTime' => date ( "Y-m-d H:i:s" ),
'trainId' => $trainId,
'invoiceManage' => $invoiceManageDetail ['staff'],
'moldManage' => json_encode ( $moldManage ),
'settlementType' => 1,
'pendingApprovals' => $pendingApprovalsSid
);
$invoice = new invoice ();
$invoice->BatchInvoiceByCondition ( $item, $iidString );
// 批量更新发票中仓库isid
$sql = "UPDATE CLD_invoiceStore SET isid = CASE iid ";
foreach ( $sqlList as $isid => $iid ) {
$sql .= sprintf ( "WHEN %d THEN %d ", $iid, $isid );
}
$sql .= "END WHERE iid IN ($iidString)";
$invoice = new invoice ();
$invoice->UpdateBatchInvoice ( $sql );
// 批量更新发票序列号
$sqlList = array ();
foreach ( $iida as $value ) {
$sqlList [$value] = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
}
$ids = implode ( ',', array_keys ( $sqlList ) );
$sql = "UPDATE CLD_invoice SET invoiceSerial = CASE iid ";
foreach ( $sqlList as $id => $ordinal ) {
$sql .= sprintf ( "WHEN %d THEN '%s' ", $id, $ordinal );
}
$sql .= "END WHERE iid IN ($ids)";
$invoiceStore = new invoiceStore ();
$invoiceStore->UpdateBatchInvoiceStore ( $sql );
// 批量生产操作日志
Doo::loadModel ( 'invoiceOperationLog' );
$sqlList = array ();
foreach ( $iida as $key => $value ) {
$sql = '("' . date ( "Y-m-d H:i:s" ) . '","创建","1","' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value . '"),
("' . date ( "Y-m-d H:i:s" ) . '","提交审批","1","' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value . '") ';
array_push ( $sqlList, $sql );
}
$iolSql = implode ( ',', $sqlList );
$sql = "INSERT INTO `CLD_invoiceOperationLog` (`date`, `operation`, `status`, `img`, `username`, `uid`, `category`, `iid`) VALUES " . $iolSql;
$invoiceOperationLog = new invoiceOperationLog ();
$invoiceOperationLog->setInvoiceOperationLogBySql ( $sql );
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$item = array (
'itid' => $trainId,
'submitStatus' => 1
);
$invoiceTraining->setInvoiceTrainByCondition ( $item );
Doo::loadModel ( 'staff' );
$staff = new staff ();
$username2 = $staff->getOne ( array (
'select' => 'wxid',
'where' => 'sid=' . $pendingApprovalsSid,
'asArray' => TRUE
) );
// 发送微信审批通知
$title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
$this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
*/
function invoiceStoreMailItemSet() {
$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' ) : "";
$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' ) : "";
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
$isid = $XDeode->decode ( $storeKey );
$trainId = $XDeode->decode ( $trainKey );
if (! is_numeric ( $isid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
$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 (
'isid' => $isid,
'doPost' => 1,
'mailItems' => $mailString,
'mailItemsJson' => json_encode ( $mailList )
);
$invoiceStore->setInvoiceStoreByCondition ( $item );
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
* 批量设置邮寄物品
*/
function invoiceStoreBatchMailItemSet() {
$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' ) : "";
$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' ) : "";
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
if (empty ( $trainKey ) || empty ( $storeKey ))
die ( 'illegal request-IdKey' );
$isidKeyList = explode ( ',', $storeKey );
$isidList = array ();
foreach ( $isidKeyList as $value ) {
$isid = $XDeode->decode ( $value );
if (! empty ( $isid ) && is_numeric ( $isid ))
array_push ( $isidList, $isid );
}
$isidString = implode ( ',', $isidList );
$trainId = $XDeode->decode ( $trainKey );
if (! is_numeric ( $isid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
$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 (
'doPost' => 1,
'mailItems' => $mailString,
'mailItemsJson' => json_encode ( $mailList )
);
$invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
return "/invoiceTrainingDetail/" . $trainKey . ".html";
}
/**
* 废弃
*/
function ajaxGetMailItemByIstore() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
$isid = $XDeode->decode ( $storeKey );
if (! is_numeric ( $isid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
$isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid );
$isDetail ['mailItemsJson'] = json_decode ( $isDetail ['mailItemsJson'], true );
echo json_encode ( $isDetail ['mailItemsJson'] );
exit ();
}
/**
* 终止开票
*/
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 invoiceUntreadMailDo() {
$untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
$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 ();
$iid = $invoice->authcode ( $untreadIidKey );
if (! empty ( $iid ) && ! is_numeric ( $iid ))
die ( 'illegal request' );
$item = array (
'iid' => $iid,
'untreadCompany' => $untreadCompany,
'untreadNumber' => $untreadNumber,
'untreadItems' => $untreadItems
);
$invoice->setInvoiceByCondition ( $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' ) : "";
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
$iid = $invoice->authcode ( $untreadIidKey );
if (! empty ( $iid ) && ! is_numeric ( $iid ))
die ( 'illegal request' );
/*
* 需求变革 有绑定收款也可以退票 $lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey ); if (! empty ( $lt )) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '该发票有收款绑定,请先移除!' ); }
*/
$item = array (
'iid' => $iid,
'untreadStatus' => 1,
'untreadReason' => $untreadReason,
'untreadPost' => $untreadPost,
'updateTime' => date ( "Y-m-d H:i:s" )
);
$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::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$sid = $XDeode->decode ( $_COOKIE ["staff"] );
$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
$iid = $XDeode->decode ( $iid );
Doo::loadModel ( 'invoiceStore' );
$invoiceStore = new invoiceStore ();
if (! is_numeric ( $iid ))
die ( 'illegal request' );
$invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
if (empty ( $invoiceDetail ))
die ( 'illegal request' );
$item = array (
'iid' => $iid,
'isDelete' => 1,
'updateTime' => date ( "Y-m-d H:i:s" )
);
$invoice->setInvoiceByCondition ( $item );
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'operation' => '删除了已终止的发票',
'status' => 4,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'iid' => $iid
);
$invoiceOperationLog->setInvoiceOperationLog ( $item );
// 删除培训班发票仓库里的发票
$invoiceStore->delInvoiceStoreByIsid ( $invoiceDetail ['isid'] );
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',
'limit' => 10,
'asArray' => true
) );
foreach ( $invoiceList as $key => $value ) {
$invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
$lastApprover = json_decode ( $value ['processApprovals'], true );
if (! empty ( $lastApprover )) {
$lastApproverKey = array_keys ( $lastApprover );
$lastApprover = end ( $lastApprover );
$staffDetail = $staff->getOne ( array (
'where' => 'sid=' . end ( $lastApproverKey ),
'asArray' => true
) );
$lastApprover ['username'] = $staffDetail ['username'];
}
$invoiceList [$key] ['lastApprover'] = $lastApprover;
}
$ilist = $invoice->getInvoiceByProcessStatus ();
foreach ( $ilist as $key => $value ) {
$ilist [$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'];
}
$ilist [$key] ['lastApprover'] = $lastApprover;
}
// print_r($ilist);
$this->data ['invoiceList'] = $invoiceList;
$this->data ['ilist'] = $ilist;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceApproval';
$this->render ( "/admin/invoiceApproval", $this->data );
}
function invoiceDetail() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
$iid = $XDeode->decode ( $iid );
if (! is_numeric ( $iid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
$invoiceDetail = $invoice->getOne ( array (
'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
'asArray' => true
) );
if (empty ( $invoiceDetail ))
die ( 'illegal request' );
if ($invoiceDetail ['settlementType'] == 1) {
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$invoiceDetail ['invoiceTraining'] = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail ['trainId'] );
}
$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
$this->data ['invoiceDetail'] = $invoiceDetail;
$this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
$this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceApproval';
$this->render ( "/admin/invoiceApprovalDetail", $this->data );
}
/**
* 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
*
* @since 1.0.0
* @var integer iid 开票ID 已加密
* @var integer status 发票审批状态
* @var integer opintion 审批发票的意见
* @return string 如操作成功返回审批首页
*/
function invoiceApprovalDo() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
$status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
$opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
$divApproval = $this->get_args ( 'divApproval' ) ? $this->get_args ( 'divApproval' ) : "";
$iid = $invoice->authcode ( $iid );
if (! is_numeric ( $iid ))
die ( 'illegal request' );
// && ! empty ( $opinion )
if (! empty ( $iid ) && ! empty ( $status )) {
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
)
);
// var_dump(next($invoiceManage));
$nextInvoiceManage = next ( $invoiceManage );
// print_r($nextInvoiceManage);
if ($status != 4 && $nextInvoiceManage !== false)
$invoice->pendingApprovals = $nextInvoiceManage [0];
$invoice->processApprovals = json_encode ( $processApprovals );
// var_dump($invoice);
// print_r($invoiceManage);
} 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;
$invoice->approvalTime = date ( "Y-m-d H:i:s" );
} 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 );
if (empty ( $divApproval ))
return '/invoiceApproval';
else
return '/invoiceApprovalAchieve/PEND';
}
die ( 'illegal request' );
}
/**
* 展示需要打印的发票数据
*
* @since 1.0.0
*/
function invoicePrint() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'staff' );
$staff = new staff ();
$toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
$printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
foreach ( $toPrint as $key => $value ) {
$toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
$lastApprover = json_decode ( $value ['processApprovals'], true );
if (! empty ( $lastApprover )) {
$lastApproverKey = array_keys ( $lastApprover );
$lastApprover = end ( $lastApprover );
$staffDetail = $staff->getOne ( array (
'where' => 'sid=' . end ( $lastApproverKey ),
'asArray' => true
) );
$lastApprover ['username'] = $staffDetail ['username'];
}
$toPrint [$key] ['lastApprover'] = $lastApprover;
}
foreach ( $printed as $key => $value ) {
$printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
$lastApprover = json_decode ( $value ['processApprovals'], true );
if (! empty ( $lastApprover )) {
$lastApproverKey = array_keys ( $lastApprover );
$lastApprover = end ( $lastApprover );
$staffDetail = $staff->getOne ( array (
'where' => 'sid=' . end ( $lastApproverKey ),
'asArray' => true
) );
$lastApprover ['username'] = $staffDetail ['username'];
}
$printed [$key] ['lastApprover'] = $lastApprover;
}
$this->data ['printed'] = $printed;
$this->data ['toPrint'] = $toPrint;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoicePrint';
$this->render ( "/admin/invoicePrint", $this->data );
}
/**
* 展示发票打印的详情页面
*
* @since 1.0.0
*/
function invoicePrintDetail() {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
$iid = $XDeode->decode ( $iid );
if (! is_numeric ( $iid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadModel ( 'invoicePaper' );
$invoicePaper = new invoicePaper ();
$invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
if (empty ( $invoiceDetail ))
die ( 'illegal request' );
$invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $invoiceDetail ['invoiceType'] );
$invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
if ($invoiceDetail ['settlementType'] == 1) {
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$invoiceDetail ['invoiceTraining'] = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail ['trainId'] );
}
$this->data ['invoicePaperList'] = $invoicePaperList;
$this->data ['invoiceDetail'] = $invoiceDetail;
$this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
$this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoicePrint';
$this->render ( "/admin/invoicePrintDetail", $this->data );
}
/**
* 所有待打印 发票
*/
function invoicePrintStayAchieve() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'staff' );
$staff = new staff ();
$MebSea = $this->get_args ( 'MebSea' ) ? urldecode ( $this->get_args ( 'MebSea' ) ) : "";
$invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
$invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
$invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
Doo::loadModel ( 'invoiceTraining' );
$invoiceTraining = new invoiceTraining ();
$trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
$page_size = 12;
$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
$status = isset ( $this->params ['status'] ) ? $this->params ['status'] : "ALL";
// $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "ALL";
$get = "/" . $status;
$con = ' and status=2 ';
if ($status == 'TOPRINT')
$con = ' and status=2 and printStatus=0 ';
elseif ($status == 'PRINTED')
$con = ' and status=2 and printStatus=1';
if ($invoiceType == 'ORDINARY')
$con .= ' and invoiceType=0 ';
elseif ($invoiceType == 'SPECIAL')
$con .= ' and invoiceType=1 ';
if ($invoiceTrain == 'ORDINARY')
$con .= ' and trainId=0 ';
elseif ($invoiceTrain == 'TRAIN')
$con .= ' and trainId!=0 ';
if ($invoiceTrainName != 'ALL') {
$trainId = $XDeode->decode ( $invoiceTrainName );
if (is_numeric ( $trainId ))
$con .= ' and trainId =' . $trainId;
}
$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
$dateArr = explode ( ':', $date );
$D1 = '';
$D2 = '';
if (! empty ( $date )) {
$D1 = $dateArr [0];
$D2 = $dateArr [1];
}
if (! empty ( $D1 ) && ! empty ( $D2 ) && ! empty ( $date ))
$con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
if (! empty ( $MebSea )) {
$con .= ' and ( invoiceNo like "%' . $MebSea . '%" or invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
}
$pageinfo ['page'] = array (
'previous' => ''
);
$get .= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ) . "&invoiceType=" . urlencode ( $invoiceType ) . "&invoiceTrain=" . urlencode ( $invoiceTrain ) . "";
$sql = " (untreadStatus=0 or untreadStatus=3) and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
$action = "invoicePrintStayAchieve";
$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
$limit = $pageinfo ['lower'] . ',' . $page_size;
$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 5 );
$this->data ['trainList'] = $trainList;
$this->data ['invoiceType'] = $invoiceType;
$this->data ['invoiceTrain'] = $invoiceTrain;
$this->data ['invoiceTrainName'] = $invoiceTrainName;
$this->data ['MebSeaEn'] = $MebSea;
$this->data ['MebSea'] = urlencode ( $MebSea );
$this->data ['get'] = $get;
$this->data ['page'] = $pageinfo;
$this->data ['date'] = $date;
$this->data ['status'] = $status;
$this->data ['invoiceType'] = $invoiceType;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
foreach ( $list as $key => $value ) {
$list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
$lastApprover = json_decode ( $value ['processApprovals'], true );
if (! empty ( $lastApprover )) {
$lastApproverKey = array_keys ( $lastApprover );
$lastApprover = end ( $lastApprover );
$staffDetail = $staff->getOne ( array (
'where' => 'sid=' . end ( $lastApproverKey ),
'asArray' => true
) );
$lastApprover ['username'] = $staffDetail ['username'];
}
$list [$key] ['lastApprover'] = $lastApprover;
}
$this->data ['receiptMemu'] = 'invoicePrint';
$this->data ['list'] = $list;
$this->render ( "/admin/invoicePrintStayAchieve", $this->data );
}
/**
* 填写票号并完成打印
* @since 1.0.0
*/
function invoicePrintDo() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
$invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
$invoicePrintType = $this->get_args ( 'invoicePrintType' ) ? $this->get_args ( 'invoicePrintType' ) : "";
$iid = $invoice->authcode ( $iid );
if (! is_numeric ( $iid ))
die ( 'illegal request' );
if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'invoicePaper' );
$invoicePaper = new invoicePaper ();
$invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
if (empty ( $invoicePrintDetail ))
die ( 'illegal request' );
//
$ipid = $XDeode->decode ( $invoiceNo );
$paperDetail = $invoicePaper->getInvoicePaperByIpid ( $ipid );
if (empty ( $paperDetail ))
die ( 'illegal request' );
$invoicePaper = new invoicePaper ();
$item = array (
'iid' => $iid,
'ipid' => $ipid
);
$invoicePaper->setInvoicePaperByCondition ( $item );
$item = array (
'iid' => $iid,
'printStatus' => 1,
'updateTime' => date ( "Y-m-d H:i:s" ),
'printer' => $this->staff [0] ['username'],
'printTime' => date ( "Y-m-d H:i:s" ),
'invoiceNo' => $paperDetail ['invoiceNo']
);
$invoice->setInvoiceByCondition ( $item );
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'operation' => '打印发票号:' . $paperDetail ['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 );
// 去统计--负票不汇总
if ($invoicePrintDetail ['untreadStatus'] != 4) {
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'priceClass' => 1,
'cid' => $invoicePrintDetail ['cid'],
'staff' => $invoicePrintDetail ['sid'],
'invoicePrice' => $invoicePrintDetail ['invoicePrice']
);
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
}
// 发送通知信息到微信-去除
// $this->setWXMsg($iid,'PRINT');
// 发票信息库
$this->autoUpdateInvoiceInfoBase ( $invoicePrintDetail );
// 申请人获取微信通知
Doo::loadModel ( 'staff' );
$staff = new staff ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$username2 = $staff->getOne ( array (
'select' => 'wxid',
'where' => 'sid=' . $invoicePrintDetail ['sid'],
'asArray' => TRUE
) );
$title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '完成打印';
$msg = '';
$url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/' . $XDeode->encode ( $invoicePrintDetail ['iid'] ) . '.html';
$hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
if (empty ( $invoicePrintType ))
return "/invoicePrint";
else
return "/invoicePrintStayAchieve";
}
}
/**
* 需要邮寄的发票
* @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 ();
$invoicePostExpress = "";
if (isset ( $_COOKIE ["invoicePostExpress"] ))
$invoicePostExpress = $_COOKIE ["invoicePostExpress"];
$this->data ['invoicePostExpress'] = $invoicePostExpress;
$this->data ['expressList'] = $expressList;
$this->data ['invoicePost'] = $invoicePost;
$this->data ['invoicePosted'] = $invoicePosted;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoicePost';
$this->render ( "/admin/invoicePost", $this->data );
}
/**
* 添加发票邮寄信息
*/
function invoiceExpressAddDo() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
$expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
$expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
$actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
$iid = $iid = $invoice->authcode ( $iid );
if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
die ( 'illegal request' );
$invoicePrintDetail = $invoice->getInvoiceByIid ( $iid );
setcookie ( 'invoicePostExpress', $expressNumber );
$item = array (
'iid' => $iid,
'postStatus' => 1,
'updateTime' => date ( "Y-m-d H:i:s" ),
'postTime' => date ( "Y-m-d H:i:s" ),
'expressCompany' => $expressCompany,
'expressNumber' => $expressNumber,
'actualItems' => $actualItems,
'poster' => $this->staff [0] ['username']
);
$invoice->setInvoiceByCondition ( $item );
// 微信通知-去掉
// $this->setWXMsg ( $iid );
Doo::loadModel ( 'staff' );
$staff = new staff ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$username2 = $staff->getOne ( array (
'select' => 'wxid',
'where' => 'sid=' . $invoicePrintDetail ['sid'],
'asArray' => TRUE
) );
$title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '已邮寄';
$expCom = explode ( ":", $invoicePrintDetail ['expressCompany'] );
if (empty ( $expCom ))
$expCom [0] = '';
$msg = $expCom [0] . ':' . $invoicePrintDetail ['expressNumber'] . '';
$url = 'https://m.kuaidi100.com/result.jsp?nu=' . $invoicePrintDetail ['expressNumber'];
$hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
return '/invoicePost';
}
function invoiceExpressUpdateDo() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
$iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
$expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
$expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
$actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
$iid = $invoice->authcode ( $iid );
if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
die ( 'illegal request' );
$item = array (
'iid' => $iid,
'updateTime' => date ( "Y-m-d H:i:s" ),
'expressCompany' => $expressCompany,
'expressNumber' => $expressNumber,
'actualItems' => $actualItems,
'poster' => $this->staff [0] ['username']
);
$invoice->setInvoiceByCondition ( $item );
return $action;
}
/**
* 可退票管理
*/
function invoiceUntreadIsAchieve() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
/*
* Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $page_size = 18; $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1; $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : ""; $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ); $dateArr = explode ( ':', $date ); $D1 = ''; $D2 = ''; if (! empty ( $date )) { $D1 = $dateArr [0]; $D2 = $dateArr [1]; } $con = ''; if (! empty ( $D1 ) && ! empty ( $D2 )) $con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" '; // if ($date == 'MONTHO') // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)'; // elseif ($date == 'MONTHT') // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)'; // elseif ($date == 'MONTHY') // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)'; if (! empty ( $MebSea )) { $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )'; } $pageinfo ['page'] = array ( 'previous' => '' );
*/
if (empty ( $MebSea )) {//
$con = ' and invoiceNo like "NULL" ';
} else {
$con = ' and (invoiceNo like "%' . $MebSea . '%" or invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
}
// printStatus=1 and
$sql = " (untreadStatus=0 or untreadStatus=3) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
/*
* $action = "invoiceUntreadIsAchieve"; $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" ); $limit = $pageinfo ['lower'] . ',' . $page_size;
*/
$limit = '0,20';
$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
// print_r($list);
$this->data ['MebSeaEn'] = $MebSea;
/*
* $this->data ['get'] = $get; $this->data ['page'] = $pageinfo; $this->data ['date'] = $date;
*/
$this->data ['list'] = $list;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoice';
$this->render ( "/admin/invoiceUntreadIsAchieve", $this->data );
}
// 已经退票的发票
function invoiceUntreadED() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
$invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "";
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$page_size = 18;
$page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
$get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
$dateArr = explode ( ':', $date );
$D1 = '';
$D2 = '';
if (! empty ( $date )) {
$D1 = $dateArr [0];
$D2 = $dateArr [1];
}
$con = '';
if (! empty ( $D1 ) && ! empty ( $D2 )) {
$con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
}
// if ($date == 'MONTHO')
// $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
// elseif ($date == 'MONTHT')
// $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
// elseif ($date == 'MONTHY')
// $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
if (! empty ( $MebSea )) {
$con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
}
if ($invoiceType == 'ORDINARY') {
$con .= ' and invoiceType=0 ';
} elseif ($invoiceType == 'SPECIAL') {
$con .= ' and invoiceType=1 ';
}
$pageinfo ['page'] = array (
'previous' => ''
);
// printStatus=1 and
$sql = " (untreadStatus=2 ) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
$action = "invoiceUntreadED";
$pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
$limit = $pageinfo ['lower'] . ',' . $page_size;
$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
// print_r($list);
$this->data ['MebSeaEn'] = $MebSea;
$this->data ['get'] = $get;
$this->data ['page'] = $pageinfo;
$this->data ['date'] = $date;
$this->data ['invoiceType'] = $invoiceType;
$this->data ['list'] = $list;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoice';
$this->render ( "/admin/invoiceUntreadED", $this->data );
}
/**
* 退票处理页面
*/
function invoiceUntread() {
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
$untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1, 0, 50 );
$establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
foreach ( $establishedInvoice as $key => $value ) {
// months
$lossDate = strtotime ( "+1 month", strtotime ( $value ['OperationLog'] ['date'] ) );
$nowDate = strtotime ( 'now' );
$establishedInvoice [$key] ['lossShow'] = false;
if ($lossDate < $nowDate)
$establishedInvoice [$key] ['lossShow'] = true;
}
$this->data ['untreadInvoice'] = $untreadInvoice;
$this->data ['establishedInvoice'] = $establishedInvoice;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceUntread';
$this->render ( "/admin/invoiceUntread", $this->data );
}
/**
* 确认收到退回的发票,开票状态为退回 //收款状态解绑,公司统计扣除入账额度
*/
function invoiceUntreadEstablishedDo() {
$untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
Doo::loadModel ( 'invoiceReceivables' );
Doo::loadModel ( 'invoiceStatistics' );
$iid = $invoice->authcode ( $untreadIidKey );
if (! empty ( $iid ) && ! is_numeric ( $iid ))
die ( 'illegal request' );
$invoiceDetails = $invoice->getInvoiceByIid ( $iid );
if ($invoiceDetails ['untreadStatus'] != 1)
die ( 'illegal request' );
$item = array (
'iid' => $iid,
// 'irid'=>'',
'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 );
// 收款解绑以及入账扣除 收款扣除
if (! empty ( $invoiceDetails ['irid'] )) {
$iridList = explode ( ',', $invoiceDetails ['irid'] );
foreach ( $iridList as $value ) {
$invoiceReceivables = new invoiceReceivables ();
$irDetails = $invoiceReceivables->getOne ( array (
'where' => " irid=" . $value . ' and bindStatus=1',
'asArray' => TRUE
) );
$item = array (
'irid' => $value,
'bindStatus' => 0,
'untreadStatus' => 1,
'untreadStaff' => $invoiceDetails ['userName'],
'unbundlingTime' => date ( "Y-m-d H:i:s" ),
'iid' => 0
);
$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
if (! empty ( $irDetails )) {
// 扣除入账
$invoiceStatistics = new invoiceStatistics ();
$item = array (
'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
'priceClass' => 3,
'cid' => $invoiceDetails ['cid'],
'staff' => $invoiceDetails ['sid'],
'accountPrice' => - $irDetails ['receivablesPrice']
);
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
// 扣除收款
$invoiceStatistics = new invoiceStatistics ();
$item = array (
'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
'priceClass' => 2,
'cid' => $invoiceDetails ['cid'],
'staff' => $invoiceDetails ['sid'],
'irid' => $irDetails ['irid'],
'receivablesPrice' => - $irDetails ['receivablesPrice']
);
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
}
// 解绑时删除收入流水
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
$wasteBook->delete ( array (
'where' => 'dataID=' . $value . ' and accountType=7',
'limit' => 1
) );
}
}
return "/invoiceUntread";
}
function invoiceUntreadRecallDo() {
$iidKey = isset ( $this->params ['iidKey'] ) ? $this->params ['iidKey'] : "";
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
$iid = $XDeode->decode ( $iidKey );
$invoiceDetail = $invoice->getInvoiceByIid ( $iid );
if (empty ( $invoiceDetail )) {
die ( 'illegal request-DATANULL' );
}
$item = array (
'iid' => $iid,
'untreadStatus' => 0
);
$invoice->setInvoiceByCondition ( $item );
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'operation' => '撤回申请退票',
'status' => 13,
'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 invoiceLossDo() {
$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
if (! empty ( $iidKey )) {
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
$iidKey = $XDeode->decode ( $iidKey );
$invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
// 拷贝插入一条发票数据
$iid = $invoice->setInvoiceLoss ( $iidKey );
// 更新负票
$invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
$invoice = new invoice ();
$item = array (
'iid' => $iid,
'sid' => $this->staff [0] ['sid'],
'userName' => $this->staff [0] ['username'],
'cid' => $this->staff [0] ['cid'],
'categoryName' => $this->staff [0] ['category'],
'invoiceQuantity' => - $invoiceDetail ['invoiceQuantity'],
'invoicePrice' => - $invoiceDetail ['invoicePrice'],
'invoiceSerial' => $invoiceSerial,
'invoiceNo' => '',
'printStatus' => 0,
'untreadStatus' => 4,
// 关联发票号
'lossIid' => $invoiceDetail ['iid']
);
$invoice->setInvoiceByCondition ( $item );
// 更新原发票
$invoice = new invoice ();
$item = array (
'iid' => $invoiceDetail ['iid'],
'lossIid' => $iid
);
$invoice->setInvoiceByCondition ( $item );
// 操作日志
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'operation' => "创建负票" . $invoiceSerial,
'status' => 12,
'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 );
// print_r($invoiceDetail);
// echo $iid;die;
}
return '/invoiceUntread';
}
/**
* 上传银行到账 收款文件
*/
function invoiceReceivablesBankUpload() {
$POST_MAX_SIZE = ini_get ( 'post_max_size' );
$unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
$multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
header ( "HTTP/1.1 500 Internal Server Error" );
echo "POST exceeded maximum allowed size.";
exit ( 0 );
}
// Settings
$save_path = DOO::conf ()->SITE_PATH . "upload/invoiceReceivablesBank/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
$upload_name = "Filedata";
$file_name = "";
$nk = time ();
$file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
echo "文件无法保存.";
exit ( 0 );
}
echo json_encode ( array (
'filename' => $file_name,
'id' => $nk
) );
exit ( 0 );
}
/**
* 解析银行到账收款execl并导入库中
*/
function invoiceReceivablesImport() {
$path = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
if ($path != "") {
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadClass ( 'invoice.func' );
Doo::loadModel ( 'invoiceROLog' );
$invoiceROLog = new invoiceROLog ();
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$exlArray = formatExcelToArrayBank ( DOO::conf ()->SITE_PATH . "upload/invoiceReceivablesBank/" . $path );
$bankBatchNumber = 'BBN_' . time ();
Doo::db ()->beginTransaction ();
// 批量存储收款--由于必须获得收款ID,
$sql = 'INSERT INTO CLD_invoiceReceivables (OriginalPrice,receivablesPrice, receivablesMessage,receivablesSerial,receivablesBank,receivablesDate,inputStaff,date,receivablesCategory,receivablesStaff,bankBatchNumber,recepitTitleMark)
VALUES ';
$date = date ( "Y-m-d" );
$receivablesList = array ();
foreach ( $exlArray as $key => $value ) {
$receivablesSql = '(' . $value ["receivablesPrice"] . ',' . $value ["receivablesPrice"] . ',"' . $value ["receivablesMessage"] . '",' . '"#SK' . date ( "Ymd" ) . mt_rand ( 1000, 9999 ) . '","' . $value ["receivablesBank"] . '","' . $value ["receivablesDate"] . '","' . $this->staff [0] ['username'] . '","' . $date . '","PUBLIC","PUBLIC","' . $bankBatchNumber . '","' . $value ["receivablesMessage"] . '")';
array_push ( $receivablesList, $receivablesSql );
}
$sql = $sql . implode ( ',', $receivablesList );
// echo $sql;
Doo::db ()->query ( $sql );
// 批量存储收款统计
// 获得刚刚导入数据的irid组-缺少办事处和人员
$iridList = $invoiceReceivables->getInvoiceReceivablesByBBN ( $bankBatchNumber );
// 没有irid 回滚所有操作
if (empty ( $iridList )) {
Doo::db ()->rollBack ();
header ( 'Content-Type:text/html;charset=utf-8' );
die ( '文档或数据不正确,请重新上传.' );
}
$sql = 'INSERT INTO CLD_invoiceStatistics (date, priceClass,irid,receivablesPrice)
VALUES ';
$statisticsList = array ();
foreach ( $iridList as $value ) {
$statisticsSql = '("' . $date . '",2,' . $value ['irid'] . ',' . $value ["receivablesPrice"] . ')';
array_push ( $statisticsList, $statisticsSql );
}
$sql = $sql . implode ( ',', $statisticsList );
Doo::db ()->query ( $sql );
// 批量存储操作日志
$sql = 'INSERT INTO CLD_invoiceROLog (operation, date,status,img, username,uid,category,irid)
VALUES ';
$ROLogList = array ();
foreach ( $iridList as $value ) {
$ROLogSql = '("' . $this->staff [0] ['username'] . ' 转入 公共待认领款项","' . $date . '",1,"' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value ['irid'] . '")';
array_push ( $ROLogList, $ROLogSql );
}
$sql = $sql . implode ( ',', $ROLogList );
Doo::db ()->query ( $sql );
// 批量写入流水
$sql = 'INSERT INTO CLD_wasteBook (dataID, expensesType,accountType,accountPriceShow, accountPrice,accountBank,category,cid,name,sid,inputDate)
VALUES ';
$wasteBookList = array ();
foreach ( $iridList as $value ) {
$accountBank = '';
if ($value ['receivablesBank'] == '纵横广发') {
$accountBank = 'CGBDeposit';
} elseif ($value ['receivablesBank'] == '纵横工行') {
$accountBank = 'ICBCDeposit';
} elseif ($value ['receivablesBank'] == '华润银行') {
$accountBank = 'HUADeposit';
} elseif ($value ['receivablesBank'] == '个人广发') {
$accountBank = 'PersonalDeposit';
}
$wasteBookSql = '("' . $value ['irid'] . ' ",1,7,"' . $value ['receivablesPrice'] . '","' . $value ['receivablesPrice'] . '","' . $accountBank . '",
"' . $this->staff [0] ['category'] . '","' . $this->staff [0] ['cid'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . date ( "Y-m-d H:i:s" ) . '")';
array_push ( $wasteBookList, $wasteBookSql );
}
$sql = $sql . implode ( ',', $wasteBookList );
Doo::db ()->query ( $sql );
Doo::db ()->commit ();
return "/invoiceReceivables";
}
echo 'no file';
}
function invoiceReceivables() {
$invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
Doo::loadModel ( 'L_category' );
$lCategory = new L_category ();
Doo::loadModel ( 'staff' );
$staff = new staff ();
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$category = $lCategory->getCategory ();
$staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
$sql = 'bindStatus=1 and iid!=0';
$receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ( 4, $sql );
// 获取未入账发票
$invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
$invoiceExistAccount = $invoice->getInvoiceByUnAccount ( '', true );
foreach ( $invoiceUnAccount as $key => $value ) {
$invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
$lastApprover = json_decode ( $value ['processApprovals'], true );
if (! empty ( $lastApprover )) {
$lastApproverKey = array_keys ( $lastApprover );
$lastApprover = end ( $lastApprover );
$staffDetail = $staff->getOne ( array (
'where' => 'sid=' . end ( $lastApproverKey ),
'asArray' => true
) );
$lastApprover ['username'] = $staffDetail ['username'];
}
$invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
}
foreach ( $invoiceExistAccount as $key => $value ) {
$irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
if (empty ( $irList ))
$irList [0] ['sumPrice'] = 0;
$balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
$invoiceExistAccount [$key] ['existAccount'] = $irList [0] ['sumPrice'];
$invoiceExistAccount [$key] ['balance'] = $balance;
}
$receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
$halfList = $invoiceReceivables->getInvoiceReceivablesByHalf ();
$this->data ['halfList'] = $halfList;
$this->data ['halfCount'] = count ( $halfList );
// print_r($receivablesList);
$this->data ['receivablesDate'] = date ( "Y-m-d" );
$this->data ['ieaCount'] = count ( $invoiceExistAccount );
$this->data ['invoiceExistAccount'] = $invoiceExistAccount;
$this->data ['receivablesInput'] = $receivablesInput;
$this->data ['year'] = date ( 'Y' );
$this->data ['invoiceUnAccount'] = $invoiceUnAccount;
$this->data ['receivablesList'] = $receivablesList;
$this->data ['staffList'] = $staffList;
$this->data ['category'] = $category;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceReceivables';
$this->render ( "/admin/invoiceReceivables", $this->data );
}
/**
* 设置收款认领地区
*/
function setInvoiceReceivablesClaim() {
$iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
$receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
$action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
if (! empty ( $iridKey ) && ! empty ( $receivablesCategory )) {
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'invoiceROLog' );
$invoiceROLog = new invoiceROLog ();
$irid = $XDeode->decode ( $iridKey );
$irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
if (empty ( $irDetail ))
die ( 'illegal request' );
$item = array (
'irid' => $irid,
'receivablesCategory' => $receivablesCategory
);
if ($receivablesCategory != 'PUBLIC') {
$item += array (
'confirmTime' => date ( "Y-m-d H:i:s" ),
'inputType' => 1
);
}
$invoiceReceivables = new invoiceReceivables ();
$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
// 收款操作日志
$item = array (
'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 ",
'date' => date ( "Y-m-d" ),
'status' => 1,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'irid' => $irid
);
$invoiceROLog->setInvoiceROLog ( $item );
if (empty ( $action ))
return '/invoiceReceivables';
else
return "/invoiceReceivablesAS";
}
die ( 'illegal request' );
}
/**
* 新添加收款直接入账发票
*/
function invoiceCompareClaimPrice() {
// 收款录入
$iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
$receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
$receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
$receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
$receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoiceROLog' );
$invoiceROLog = new invoiceROLog ();
Doo::loadModel ( 'invoiceStatistics' );
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
$iidKey = $XDeode->decode ( $iidKey );
$invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
if (! ($invoiceDetail ['status'] == 2 && $invoiceDetail ['printStatus'] == 1 && $invoiceDetail ['untreadStatus'] == 0))
die ( 'illegal request' );
$receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
// 收款录入 并绑定发票
Doo::db ()->beginTransaction ();
$bindStatus = 0;
if ($receivablesPrice <= $invoiceDetail ['invoicePrice']){
$bindStatus = 1;
}
$titleMark = $invoiceDetail ['invoiceTitle'];
if (! empty ( $invoiceDetail ['invoiceCompany'] ))
$titleMark = $invoiceDetail ['invoiceCompany'];
$item = array (
'recepitTitleMark' => $titleMark,
'bindStatus' => $bindStatus,
'iid' => $invoiceDetail ['iid'],
'bindPrice' => $invoiceDetail ['invoicePrice'],
'bindDate' => date ( "Y-m-d H:i:s" ),
'receivablesPrice' => $receivablesPrice,
'OriginalPrice' => $receivablesPrice,
'receivablesMessage' => $receivablesMessage,
'receivablesSerial' => $receivablesSerial,
'receivablesBank' => $receivablesBank,
'receivablesDate' => $receivablesDate,
'inputStaff' => $this->staff [0] ['username'],
'accountClerk' => $this->staff [0] ['username'],
'date' => date ( "Y-m-d" ),
'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
'confirmTime' => date ( "Y-m-d H:i:s" )
);
$irid = $invoiceReceivables->addInvoiceReceivables ( $item );
$item = array ();
// 收款操作日志
$item = array (
'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName']
);
$item += array (
'date' => date ( "Y-m-d" ),
'status' => 1,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'irid' => $irid
);
$invoiceROLog->setInvoiceROLog ( $item );
// 收款统计
$invoiceStatistics = new invoiceStatistics ();
$item = array (
'date' => $receivablesDate,
'priceClass' => 2,
'irid' => $irid,
'cid' => $invoiceDetail ['cid'],
'staff' => $invoiceDetail ['sid'],
'receivablesPrice' => $receivablesPrice
);
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
// 收款 入 发票
$detail = $invoiceDetail;
$iridString = "";
if (empty ( $detail ['irid'] ))
$iridString = $irid;
else
$iridString = $detail ['irid'] . ',' . $irid;
$item = array (
'irid' => $iridString,
'bindTime' => date ( "Y-m-d H:i:s" ),
'updateTime' => date ( "Y-m-d H:i:s" ),
'iid' => $detail ['iid']
);
$invoiceReceivables = new invoiceReceivables ();
$sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
if ($detail ['invoicePrice'] <= $sum)
$item += array (
'untreadStatus' => 3
);
$invoice->setInvoiceByCondition ( $item );
// 操作日志
$item = array (
'date' => date ( "Y-m-d H:i:s" ),
'operation' => "收款入账" . $receivablesSerial . "到发票" . $detail ['invoiceSerial'],
'status' => 8,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'iid' => $detail ['iid']
);
$invoiceOperationLog->setInvoiceOperationLog ( $item );
// 入账汇总
$invoiceStatistics = new invoiceStatistics ();
// $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
// $accountPrice = 0;
// foreach ( $list as $key => $value ) {
// $accountPrice += $value ['receivablesPrice'];
// }
$item = array (
'date' => $receivablesDate,
'priceClass' => 3,
'cid' => $invoiceDetail ['cid'],
'staff' => $invoiceDetail ['sid'],
'accountPrice' => $receivablesPrice
);
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
// 公司流水记录
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
$abDetail = $wasteBook->getAccountBookByAid ( 2, 7, $irid );
$accountBank = '';
if ($receivablesBank == '纵横广发') {
$accountBank = 'CGBDeposit';
} elseif ($receivablesBank == '纵横工行') {
$accountBank = 'ICBCDeposit';
} elseif ($receivablesBank == '华润银行') {
$accountBank = 'HUADeposit';
} elseif ($receivablesBank == '个人广发') {
$accountBank = 'PersonalDeposit';
}
if (empty ( $abDetail )) {
$item = array (
'dataID' => $irid,
'expensesType' => 1,
'accountType' => 7,
'accountPrice' => $receivablesPrice,
'accountPriceShow' => $receivablesPrice,
'accountBank' => $accountBank,
'category' => $this->staff [0] ['category'],
'cid' => $this->staff [0] ['cid'],
'name' => $this->staff [0] ['username'],
'sid' => $this->staff [0] ['sid'],
'inputDate' => date ( "Y-m-d H:i:s" )
);
$wasteBook->setAccountBookStatistics ( $item );
}
Doo::db ()->commit ();
}
return '/invoiceReceivables';
}
/**
* 录入收款数据
* @return string
*/
function invoiceReceivablesDo() {
$receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
$receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
$receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
$receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
$receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
$receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoiceROLog' );
$invoiceROLog = new invoiceROLog ();
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
$item = array (
'receivablesPrice' => $receivablesPrice,
'OriginalPrice' => $receivablesPrice,
'receivablesMessage' => $receivablesMessage,
'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
'receivablesBank' => $receivablesBank,
'receivablesDate' => $receivablesDate,
'inputStaff' => $this->staff [0] ['username'],
'date' => date ( "Y-m-d" ),
'receivablesCategory' => $receivablesCategory,
'receivablesStaff' => $receivablesStaff
);
if ($receivablesCategory != 'PUBLIC') {
$item += array (
'confirmTime' => date ( "Y-m-d H:i:s" ),
'inputType' => 1
);
}
$irid = $invoiceReceivables->addInvoiceReceivables ( $item );
$item = array ();
// 收款操作日志
if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
$item = array (
'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
);
elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
$item = array (
'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
);
elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
$receivablesStaff = explode ( '-', $receivablesStaff );
$item = array (
'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
);
}
$item += array (
'date' => date ( "Y-m-d" ),
'status' => 1,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'irid' => $irid
);
$invoiceROLog->setInvoiceROLog ( $item );
$item = array (
'date' => $receivablesDate,
'priceClass' => 2,
'irid' => $irid,
'receivablesPrice' => $receivablesPrice
);
if ($receivablesCategory != 'PUBLIC') {
$receivablesCategory = explode ( ":", $receivablesCategory );
$item += array (
'cid' => $receivablesCategory [0]
);
}
if ($receivablesStaff2 != 'PUBLIC') {
$receivablesStaff = explode ( "-", $receivablesStaff2 );
$item += array (
'staff' => $receivablesStaff [0]
);
}
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
$toparty = $this->getWxidByCategory ( $receivablesCategory [1] );
// $toparty = $this->getToparty ( $receivablesCategory [1] );
$msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
if ($toparty != 0)
$this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
// 公司流水记录
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
$abDetail = $wasteBook->getAccountBookByAid ( 1, 7, $irid );
$accountBank = '';
if ($receivablesBank == '纵横广发') {
$accountBank = 'CGBDeposit';
} elseif ($receivablesBank == '纵横工行') {
$accountBank = 'ICBCDeposit';
} elseif ($receivablesBank == '华润银行') {
$accountBank = 'HUADeposit';
} elseif ($receivablesBank == '个人广发') {
$accountBank = 'PersonalDeposit';
}
$item = array (
'dataID' => $irid,
'expensesType' => 1,
'accountType' => 7,
'accountPriceShow' => $receivablesPrice,
'accountPrice' => $receivablesPrice,
'accountBank' => $accountBank,
'category' => $this->staff [0] ['category'],
'cid' => $this->staff [0] ['cid'],
'name' => $this->staff [0] ['username'],
'sid' => $this->staff [0] ['sid'],
'inputDate' => date ( "Y-m-d H:i:s" )
);
$wasteBook->setAccountBookStatistics ( $item );
}
return "/invoiceReceivables";
}
/**
* 收款认领页面-包括公共认领 办事处认领 最近已认领数据
*/
function invoiceReceivablesClaim() {
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
$receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
$this->data ['receivablesList'] = $receivablesList;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
$this->render ( "/admin/invoiceReceivablesClaim", $this->data );
}
function invoiceReceivablesTitleMarkSet() {
$iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
$recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
if (empty ( $iridKey ) || empty ( $recepitTitleMark ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadClass ( 'XDeode' );
$XDeode = new XDeode ( 5 );
$irid = $XDeode->decode ( $iridKey );
if (! is_numeric ( $irid ))
die ( 'illegal request' );
$invoiceReceivables->recepitTitleMark = $recepitTitleMark;
$invoiceReceivables->update ( array (
'where' => 'irid = ' . $irid
) );
return '/invoiceReceivablesClaim';
}
/**
* 更新收款相关数据
*/
function invoiceReceivablesUpdateClaim() {
$receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
$receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
$receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
$receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
$receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
$receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
$claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
if (empty ( $claimKey ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoiceROLog' );
$invoiceROLog = new invoiceROLog ();
$con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
if (empty ( $detail ))
die ( 'illegal request' );
$invoiceReceivables = new invoiceReceivables ();
$item = array (
'irid' => $detail ['irid']
);
if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
$item += array (
'confirmTime' => date ( "Y-m-d H:i:s" )
);
}
if (! empty ( $receivablesCategory ))
$item += array (
'receivablesCategory' => $receivablesCategory
);
if (! empty ( $receivablesStaff ))
$item += array (
'receivablesStaff' => $receivablesStaff
);
if (! empty ( $receivablesPrice ))
$item += array (
'receivablesPrice' => $receivablesPrice
);
if (! empty ( $receivablesMessage ))
$item += array (
'receivablesMessage' => $receivablesMessage
);
if (! empty ( $receivablesBank ))
$item += array (
'receivablesBank' => $receivablesBank
);
if (! empty ( $receivablesDate ))
$item += array (
'receivablesDate' => $receivablesDate
);
$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
// 收款操作日志
$item = array ();
if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
$item = array (
'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
);
elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
$item = array (
'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
);
elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
$receivablesStaff = explode ( '-', $receivablesStaff );
$item = array (
'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
);
}
$item += array (
'date' => date ( "Y-m-d" ),
'status' => 1,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'irid' => $detail ['irid']
);
$invoiceROLog->setInvoiceROLog ( $item );
return '/invoiceReceivablesAS';
}
function invoiceReceivablesDelete() {
$claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
$skll = $this->get_args ( 'skll' ) ? $this->get_args ( 'skll' ) : "";
if ($skll != '删除到款')
die ( 'illegal request' );
if (empty ( $claimKey ))
die ( 'illegal request' );
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
$con = ' and bindStatus=0 ';
$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
if (empty ( $detail ))
die ( 'illegal request' );
$invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
// 扣除收款汇总信息 汇总
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$item = array (
'date' => $detail ['receivablesDate'],
'priceClass' => 2,
'irid' => $detail ['irid'],
'receivablesPrice' => - $detail ['receivablesPrice']
);
if ($detail ['receivablesCategory'] != 'PUBLIC') {
$receivablesCategory = explode ( ":", $detail ['receivablesCategory'] );
$item += array (
'cid' => $receivablesCategory [0]
);
}
if ($detail ['receivablesStaff'] != 'PUBLIC') {
$receivablesStaff = explode ( "-", $detail ['receivablesStaff'] );
$item += array (
'staff' => $receivablesStaff [0]
);
}
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
// 公司流水-删除时删除流水
Doo::loadModel ( 'wasteBook' );
$wasteBook = new wasteBook ();
$wasteBook->delete ( array (
'where' => 'dataID=' . $detail ['irid'] . ' and accountType=7',
'limit' => 1
) );
return '/invoiceReceivablesAS';
}
/**
* 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
*/
function invoiceReceivablesAscription() {
$irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
$recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoiceROLog' );
$invoiceROLog = new invoiceROLog ();
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC' && ! empty ( $recepitTitleMark )) {
$item = array (
'irid' => $detail ['irid'],
'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
'confirmTime' => date ( "Y-m-d H:i:s" ),
'recepitTitleMark' => $recepitTitleMark,
'source' => 1
);
$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
$item = array (
'date' => date ( "Y-m-d" ),
'operation' => $this->staff [0] ['username'] . " 认领 ",
'status' => 2,
'img' => $this->staff [0] ['avatar'],
'username' => $this->staff [0] ['username'],
'uid' => $this->staff [0] ['sid'],
'category' => $this->staff [0] ['category'],
'irid' => $irid
);
$invoiceROLog->setInvoiceROLog ( $item );
$item = array (
'cid' => $this->staff [0] ['cid'],
'staff' => $this->staff [0] ['sid']
);
$invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'], 2 );
}
return "/invoiceReceivablesClaim";
}
/**
*/
function invoiceMyReceivables() {
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$isMonth = $invoiceStatistics->getStatisticsByMonth ( $this->staff [0] ['sid'] );
$year = date ( "Y" );
$tmp_date = date ( "Ym" );
$tmp_year = substr ( $tmp_date, 0, 4 );
$tmp_mon = substr ( $tmp_date, 4, 2 );
$tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
$fm_forward_month = date ( "m", $tmp_forwardmonth );
$path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
$htm = $this->showCache ( $path );
$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
$this->data ['isMonth'] = $isMonth;
$this->data ['htm'] = $htm;
$this->data ['list'] = $list;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoiceMyReceivables';
$this->render ( "/admin/invoiceMyReceivables", $this->data );
}
/**
* 纸票管理
*/
function invoicePaper() {
$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
$invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
$this->data ['dateString'] = $date;
$this->data ['status'] = $status;
$this->data ['invoiceType'] = $invoiceType;
$this->data ['memu'] = "invoice";
$this->data ['staff'] = $this->staff;
$this->data ['receiptMemu'] = 'invoicePaper';
$this->render ( "/admin/invoicePaper", $this->data );
}
/**
* 获得纸票分页数据
*/
function ajaxGetinvoicePaperAchieve() {
Doo::loadModel ( 'invoicePaper' );
$invoicePaper = new invoicePaper ();
$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
$invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
$invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ORDINARY";
$date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
$page = $this->get_args ( 'start' ) && is_numeric ( $this->get_args ( 'start' ) ) ? $this->get_args ( 'start' ) : 0;
$draw = $this->get_args ( 'draw' ) && is_numeric ( $this->get_args ( 'draw' ) ) ? $this->get_args ( 'draw' ) : 1;
$length = $this->get_args ( 'length' ) && is_numeric ( $this->get_args ( 'length' ) ) ? $this->get_args ( 'length' ) : 10;
$MebSea = $this->get_args ( 'search' );
$MebSea = $MebSea ['value'];
$page_size = $length;
$con = '';
if ($status == 'ALL')
$con = ' where 1 ';
elseif ($status == 'PRINTED')
$con = ' where a.iid!=0 '; // $con = ' where b.isDelete=0 and a.iid!=0 and b.status=2 and b.untreadStatus=0 ';
elseif ($status == 'UNPRINT')
$con = ' where a.iid=0 '; // $con = ' where b.isDelete=0 and a.iid=0 and b.status=2 and b.untreadStatus=0 ';
elseif ($status == 'TICKET')
$con = ' where b.isDelete=0 and b.untreadStatus=2';
if ($invoiceType == 'ORDINARY')
$con .= ' and a.invoiceType=0 ';
elseif ($invoiceType == 'SPECIAL')
$con .= ' and a.invoiceType=1 ';
$dateArr = explode ( ':', $date );
$D1 = $dateString = '';
$D2 = '';
if (! empty ( $date )) {
$D1 = $dateArr [0];
if (isset ( $dateArr [1] ))
$D2 = $dateArr [1];
else
$D2 = '';
$dateString = $D1 . " : " . $D2;
}
if (! empty ( $D1 ) && ! empty ( $D2 ))
$con .= ' and b.printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
elseif (! empty ( $D1 ) && empty ( $D2 ))
$con .= ' and b.printTime like "%' . $D1 . '%" ';
if (! empty ( $MebSea ))
$con .= ' and ( b.invoiceTitle like "%' . $MebSea . '%" or b.invoiceCompany like "%' . $MebSea . '%" or a.invoiceNo like "%' . $MebSea . '%" )';
$invoiceTotal = $invoicePaper->getInvoicePaperCount ();
$sql = ' ' . $con;
$limit = $page . ',' . $page_size;
$list = $invoicePaper->getInvoicePaper ( $limit, $sql, 'desc' );
$paperList = array ();
foreach ( $list as $key => $value ) {
$irDetail = array ();
if ($value ['iid'] == 0)
array_push ( $irDetail, '删除' );
else
array_push ( $irDetail, '' );
array_push ( $irDetail, $value ['invoiceCode'] );
array_push ( $irDetail, $value ['invoiceNo'] );
array_push ( $irDetail, '' . $value ['invoiceSerial'] . '' );
if ($value ['invoiceType'] == 1)
array_push ( $irDetail, $value ['invoiceCompany'] );
else
array_push ( $irDetail, $value ['invoiceTitle'] );
if ($value ['invoiceType'] == 1)
array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '专' );
else
array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
array_push ( $irDetail, $value ['invoiceElement'] );
array_push ( $irDetail, $value ['categoryName'] . '-' . $value ['userName'] );
array_push ( $irDetail, $value ['printTime'] );
array_push ( $paperList, $irDetail );
}
// $approvalListJson = json_encode ( $approvalList );
$recordsFiltered = $invoiceTotal;
echo json_encode ( array (
"draw" => intval ( $draw ),
"recordsTotal" => intval ( $invoiceTotal ),
"recordsFiltered" => intval ( $recordsFiltered ),
"data" => $paperList
), JSON_UNESCAPED_UNICODE );
}
function invoicePaperDel() {
$ipidKey = isset ( $this->params ['ipidKey'] ) ? $this->params ['ipidKey'] : "";
$XDeode = new XDeode ( 5 );
$ipid = $XDeode->decode ( $ipidKey );
if (empty ( $ipid ))
die ( 'illegal request' );
Doo::loadModel ( 'invoicePaper' );
$invoicePaper = new invoicePaper ();
$invoicePaper->delete ( array (
'where' => 'ipid=' . $ipid . ' and iid=0',
'limit' => 1
) );
return '/invoicePaper';
}
/**
* 添加纸质发票号
*/
function invoicePaperAdd() {
$invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : '0';
$invoiceCode = $this->get_args ( 'invoiceCode' ) ? $this->get_args ( 'invoiceCode' ) : "";
$invoiceNoStart = $this->get_args ( 'invoiceNoStart' ) && is_numeric ( $this->get_args ( 'invoiceNoStart' ) ) ? $this->get_args ( 'invoiceNoStart' ) : 0;
$invoiceNoTotal = $this->get_args ( 'invoiceNoTotal' ) && is_numeric ( $this->get_args ( 'invoiceNoTotal' ) ) ? $this->get_args ( 'invoiceNoTotal' ) : 0;
if ($invoiceType != '' && ! empty ( $invoiceCode ) && ! empty ( $invoiceNoStart ) && ! empty ( $invoiceNoTotal )) {
$sum = $invoiceNoStart + $invoiceNoTotal;
if (empty ( $sum ))
die ( 'illegal request' );
// echo $invoiceNoStart;
// echo $sum;
// echo strlen((int)$invoiceNoStart);
$sumLenght = strlen ( $invoiceNoStart ) - strlen ( ( int ) $invoiceNoStart );
Doo::db ()->beginTransaction ();
// 批量存储纸质发票
$date = date ( "Y-m-d H:i:s" );
$sql = 'INSERT INTO CLD_invoicePaper (invoiceType, invoiceCode,invoiceNo,date)
VALUES ';
$paperList = array ();
for($invoiceNoStart; $invoiceNoStart <= $sum - 1; $invoiceNoStart ++) {
// 数字前面自加0
$INLENGHT = strlen ( ( int ) $invoiceNoStart ) + $sumLenght;
$var = sprintf ( "%0" . $INLENGHT . "d", $invoiceNoStart );
$paperSql = '(' . $invoiceType . ',"' . $invoiceCode . '","' . $var . '","' . $date . '")';
array_push ( $paperList, $paperSql );
}
if (empty ( $paperList ))
die ( 'illegal request' );
$sql = $sql . implode ( ',', $paperList );
Doo::db ()->query ( $sql );
Doo::db ()->commit ();
return 'invoicePaper';
}
die ( 'illegal request' );
}
/**
* 收款绑定发票 ,//一个收款只能绑定一个发票
*/
function invoiceBindReceivables() {
$claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
$invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
Doo::loadModel ( 'invoice' );
$invoice = new invoice ();
Doo::loadModel ( 'invoiceReceivables' );
$invoiceReceivables = new invoiceReceivables ();
Doo::loadModel ( 'invoiceOperationLog' );
$invoiceOperationLog = new invoiceOperationLog ();
if (empty ( $invoiceKey ) || empty ( $claimKey ))
die ( 'illegal request' );
$detail = $invoice->getInvoiceByIid ( $invoiceKey );
$detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
if (empty ( $detail ) && empty ( $detailM ))
die ( 'illegal request' );
if ($detail ['untreadStatus'] == 3)
die ( 'illegal request' );
// 修改 绑定状态改为 金额
$invoiceReceivables = new invoiceReceivables ();
$invoicePrice = $detail ['invoicePrice'] + $detailM ['bindPrice'];
if ($detailM ['receivablesPrice'] > $invoicePrice) {
$item = array (
'bindPrice' => $invoicePrice
);
} elseif ($detailM ['receivablesPrice'] <= $invoicePrice) {
$item = array (
'bindPrice' => $invoicePrice,
'bindStatus' => 1,
'bindDate' => date ( "Y-m-d H:i:s" )
);
} else {
die ( 'illegal request' );
}
if ($detailM ['iid'] == 0) {
$item += array (
'iid' => $detail ['iid']
);
} else {
$iidExtend = explode ( ',', $detailM ['iidExtend'] );
array_push ( $iidExtend, $detail ['iid'] );
$item += array (
'iidExtend' => implode ( ',', $iidExtend )
);
}
$titleMark = $detail ['invoiceTitle'];
if (! empty ( $detail ['invoiceCompany'] ))
$titleMark = $detail ['invoiceCompany'];
$item += array (
'irid' => $detailM ['irid'],
'recepitTitleMark' => $titleMark,
'accountClerk' => $this->staff [0] ['username']
);
// 如何没有人收款 则自动绑定收款
if ($detailM ['receivablesCategory'] == 'PUBLIC' || $detailM ['receivablesStaff'] == 'PUBLIC') {
$item += array (
'receivablesCategory' => $detail ['cid'] . ':' . $detail ['categoryName'],
'receivablesStaff' => $detail ['sid'] . '-' . $detail ['userName']
);
}
$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
$iridString = "";
if (empty ( $detail ['irid'] ))
$iridString = $detailM ['irid'];
else
$iridString = $detail ['irid'] . ',' . $detailM ['irid'];
$item = array (
'iid' => $detail ['iid'],
'irid' => $iridString
);
$invoiceReceivables = new invoiceReceivables ();
$sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
if ($detail ['invoicePrice'] <= $sum)
$item += array (
'untreadStatus' => 3,
'bindTime' => date ( "Y-m-d H:i:s" )
);
// print_r($item);
// echo $sum;die;
$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 );
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
$item = array (
'date' => $detailM ['receivablesDate'],
'priceClass' => 3,
'cid' => $detail ['cid'],
'staff' => $detail ['sid'],
'accountPrice' => $detailM ['receivablesPrice']
);
$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
// 公司流水记录
// Doo::loadModel ( 'wasteBook' );
// $wasteBook = new wasteBook ();
// $abDetail = $wasteBook->getAccountBookByAid (1,8,$detail ['iid'] );
// $accountBank='';
// if ($detailM ['receivablesBank']=='纵横广发'){
// $accountBank='CGBDeposit';
// }elseif($detailM ['receivablesBank']=='纵横工行'){
// $accountBank='ICBCDeposit';
// }elseif($detailM ['receivablesBank']=='华润银行'){
// $accountBank='HUADeposit';
// }elseif($detailM ['receivablesBank']=='个人广发'){
// $accountBank='PersonalDeposit';
// }
// if (empty($abDetail)){
// $item = array (
// 'dataID' => $detail ['iid'],
// 'expensesType' => 1,
// 'accountType' => 8,
// 'accountPriceShow'=>$detail ['invoicePrice'],
// 'accountPrice'=>$detail ['invoicePrice'],
// 'accountBank'=>$accountBank,
// 'category'=>$this->staff[0]['category'],
// 'cid'=>$this->staff[0]['cid'],
// 'name'=>$this->staff[0]['username'],
// 'sid'=>$this->staff[0]['sid'],
// 'inputDate'=>date ( "Y-m-d H:i:s" )
// );
// $wasteBook->setAccountBookStatistics($item);
// }
return "/invoiceReceivables";
}
/**
* 核销 动作,确认入账统计 发票收款完成--需求更变 废弃 function invoiceEnterReceivables() { $invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; // $invoiceClaim = $this->get_args ( 'invoiceClaim' ) ? $this->get_args ( 'invoiceClaim' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); Doo::loadModel ( 'invoiceStatistics' ); $invoiceStatistics = new invoiceStatistics (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); if (empty ( $detail )) die ( 'illegal request' ); if (empty ( $detail ['irid'] )) die ( 'illegal request' ); $item = array ( 'untreadStatus' => 3, 'updateTime' => date ( "Y-m-d H:i:s" ), 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "发票" . $detail ['invoiceSerial'] . "收款完成", 'status' => 9, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] ); $accountPrice = 0; foreach ( $list as $key => $value ) { $accountPrice += $value ['receivablesPrice']; } $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'priceClass' => 3, 'cid' => $this->staff [0] ['cid'], 'staff' => $this->staff [0] ['sid'], 'accountPrice' => $accountPrice ); $invoiceStatistics->setInvoiceStatisticsByCondition ( $item ); return "/invoice"; }
*/
function invoiceAggregate() {
$year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
Doo::loadModel ( 'invoiceStatistics' );
$invoiceStatistics = new invoiceStatistics ();
Doo::loadModel ( 'L_category' );
$Lcategory = new L_category ();
$isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
$LcategoryList = $Lcategory->getCategory ();
// print_r($isList);
$html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
foreach ( $LcategoryList as $key => $value ) {
$html .= '