|
@@ -177,10 +177,12 @@ class InvoiceController extends DooController {
|
|
|
$invoice=new invoice();
|
|
|
Doo::loadModel('invoiceManage');
|
|
|
$invoiceManage=new invoiceManage();
|
|
|
+ Doo::loadClass('XDeode');
|
|
|
+ $XDeode=new XDeode(5);
|
|
|
|
|
|
$invoiceList=$invoice->find(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
|
|
|
foreach ($invoiceList as $key=>$value){
|
|
|
- $invoiceList[$key]['iidKey']=base64_encode($value['iid']);
|
|
|
+ $invoiceList[$key]['iidKey']=$XDeode->encode($value['iid']);//base64_encode($value['iid']);
|
|
|
}
|
|
|
|
|
|
$data['invoiceList']=$invoiceList;
|
|
@@ -194,15 +196,18 @@ class InvoiceController extends DooController {
|
|
|
}
|
|
|
|
|
|
function invoiceDetail(){
|
|
|
+ Doo::loadClass('XDeode');
|
|
|
+ $XDeode=new XDeode(5);
|
|
|
|
|
|
$iid=isset($this->params['iid'])?$this->params['iid']:"";
|
|
|
- $iid=base64_decode($iid);
|
|
|
+ $iid=$XDeode->decode($iid);//base64_decode($iid);
|
|
|
|
|
|
Doo::loadModel('invoice');
|
|
|
$invoice=new invoice();
|
|
|
Doo::loadModel('invoiceManage');
|
|
|
$invoiceManage=new invoiceManage();
|
|
|
|
|
|
+
|
|
|
$invoiceDetail=$invoice->getOne(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'].' and iid='.$iid,'asArray'=>true));
|
|
|
|
|
|
$invoiceManageDetail=$invoiceManage->getOne(array('SELECT'=>'title','where'=>'mold="发票审批"','asArray'=>true));
|
|
@@ -222,7 +227,7 @@ class InvoiceController extends DooController {
|
|
|
}
|
|
|
|
|
|
function invoiceApprovalDo(){
|
|
|
- $iid=$this->get_args('iid')?$this->get_args('iid'):"";
|
|
|
+ $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'):"";
|
|
|
|
|
@@ -233,10 +238,186 @@ class InvoiceController extends DooController {
|
|
|
$invoice=new invoice();
|
|
|
|
|
|
$iid=$this->authcode($iid);
|
|
|
+ $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);
|
|
|
|
|
|
- $invoice->getOne(array('where'=>'status=1 and iid='.$iid.' and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
|
|
|
+ $invoice->status=$status;
|
|
|
+ if ($status==3){
|
|
|
+ //操作日志
|
|
|
+ }else{
|
|
|
+ if(empty($processApprovals)){//记录下一个IDKEY
|
|
|
+ $processApprovals=array($this->staff[0]['sid']=>array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status));
|
|
|
+ //if($status==4)
|
|
|
+ // $processApprovals=array('final'=>$status,$this->staff[0]['sid']=>array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status));
|
|
|
+ if ($status!=4)
|
|
|
+ $invoice->pendingApprovals=$invoiceManage[1][0];
|
|
|
+ $invoice->processApprovals=$processApprovals;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ $processApprovals[$this->staff[0]['sid']]=array('date'=>date('Y-m-d'),'opinion'=>$opinion,'status'=>$status);
|
|
|
+ if($status!=4)
|
|
|
+ $invoice->pendingApprovals=$invoiceManage[1][0];
|
|
|
+
|
|
|
+ $invoice->processApprovals=$processApprovals;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ print_r($processApprovals);
|
|
|
|
|
|
+ //$invoice->
|
|
|
+ /*
|
|
|
+ if (isset($verifyStaff['final'])){//rDetail
|
|
|
+ $receipt->verifyBreakup=$verifyString;
|
|
|
+ $receipt->status=3;
|
|
|
+ $receiptDetailObj->status=3;
|
|
|
+ $receiptDetailObj->update(array('where'=>'rid='.$rid));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!empty($roleId)){
|
|
|
+ Doo::loadModel("role");
|
|
|
+ $role=new role();
|
|
|
+ $roleInfo=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true));
|
|
|
+
|
|
|
+ $receiptLog->rolename=$roleInfo['name'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $receiptLog->username=$this->staff[0]['username'];
|
|
|
+ $receiptLog->uid=$this->staff[0]['sid'];
|
|
|
+ $receiptLog->date=date("Y-m-d");
|
|
|
+ $receiptLog->opinion=$opinion;
|
|
|
+ $receiptLog->img=$this->staff[0]['avatar'];
|
|
|
+ $receiptLog->status=3;
|
|
|
+ $receiptLog->rid=$rid;
|
|
|
+ $receiptLog->insert();
|
|
|
+
|
|
|
+
|
|
|
+ }elseif(count($verifyStaff)==count($verifyDetail)){//要修改 角色的数量
|
|
|
+ $receipt->status=1;$reviseSum=0;
|
|
|
+ $receipt->verifyBreakup=$verifyString;
|
|
|
+ if(!empty($receiptDetail['reviseDetail'])){//statistics item rDetail
|
|
|
+ $reviseDetail=json_decode($receiptDetail['reviseDetail'],true);
|
|
|
+
|
|
|
+ foreach ($reviseDetail as $key=>$value){
|
|
|
+ $receiptDetailObj=new receiptDetail();
|
|
|
+ $receiptDetailObj->staff=$receiptDetail['staff'];// $this->staff[0]['sid'];
|
|
|
+ $receiptDetailObj->item=$value['description'];
|
|
|
+ $receiptDetailObj->itemCategory="报销金额调整";
|
|
|
+ $receiptDetailObj->price=$value['price'];
|
|
|
+ $receiptDetailObj->date=$receiptDetail['date'];
|
|
|
+ $receiptDetailObj->cid=$this->staff[0]['cid'];
|
|
|
+ $receiptDetailObj->rid=$rid;
|
|
|
+ $receiptDetailObj->status=1;
|
|
|
+ $receiptDetailObj->insert();
|
|
|
+ $reviseSum+=$value['price'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $itemStatistics=new itemStatistics();
|
|
|
+ $itemStatistics->cid=$receiptDetail['cid'];//$this->staff[0]['cid'];
|
|
|
+ $itemStatistics->staff=$receiptDetail['staff'];//$this->staff[0]['sid'];
|
|
|
+ $itemStatistics->price=$reviseSum;
|
|
|
+ $itemStatistics->itemCategory="报销金额调整";
|
|
|
+ $itemStatistics->date=$receiptDetail['date'];
|
|
|
+ $itemStatistics->insert();
|
|
|
+ }
|
|
|
+ $receiptDetailObj=new receiptDetail();
|
|
|
+ $receiptDetailObj->status=1;
|
|
|
+ $receiptDetailObj->pastDate=date("Y-m-d");
|
|
|
+ $receiptDetailObj->update(array('where'=>'rid='.$rid));
|
|
|
+
|
|
|
+ $dateArray=explode("-", $receiptDetail['date']);
|
|
|
+ $dateCondition=" and Year(date) =".$dateArray[0]." and Month(date) = ".$dateArray[1];
|
|
|
+ $stat=$statistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].$dateCondition,'asArray'=>true));
|
|
|
+ if(empty($stat)){
|
|
|
+ $statistics->date=$receiptDetail['date'];
|
|
|
+ $statistics->cid=$receiptDetail['cid'];//$this->staff[0]['cid'];
|
|
|
+ $statistics->staff=$receiptDetail['staff'];//$this->staff[0]['sid'];
|
|
|
+ $statistics->agPrice=$receiptDetail['sum'];
|
|
|
+ $statistics->rePrice=$reviseSum;
|
|
|
+ $statistics->insert();
|
|
|
+ }else{
|
|
|
+ $statistics->agPrice=$stat['agPrice']+$receiptDetail['sum'];
|
|
|
+ $statistics->rePrice=$stat['rePrice']+$reviseSum;
|
|
|
+ $statistics->update(array('where'=>'sid='.$stat['sid']));
|
|
|
+ }
|
|
|
+
|
|
|
+ $dateArray=explode("-", $receiptDetail['date']);
|
|
|
+ $dateCondition=" and Year(date) =".$dateArray[0]." and Month(date) = ".$dateArray[1];
|
|
|
+ $accountItem=json_decode($receiptDetail['accountItem'],true);
|
|
|
+ foreach ($accountItem['cSum'] as $key=>$value){
|
|
|
+ if($key=="agencySum"){
|
|
|
+ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
|
|
|
+ if(empty($iStatistics)){
|
|
|
+ $itemStatistics->cid=$receiptDetail['cid'];;
|
|
|
+ $itemStatistics->staff=$receiptDetail['staff'];
|
|
|
+ $itemStatistics->price=$value;
|
|
|
+ $itemStatistics->itemCategory=$this->AGENCY;
|
|
|
+ $itemStatistics->date=$receiptDetail['date'];
|
|
|
+ $itemStatistics->insert();
|
|
|
+ }else{
|
|
|
+ if (!empty($value)){
|
|
|
+ $itemStatistics->price=$value+$iStatistics['price'];
|
|
|
+ $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }elseif($key=="travelSum"){
|
|
|
+ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
|
|
|
+ if(empty($iStatistics)){
|
|
|
+ $itemStatistics->cid=$receiptDetail['cid'];
|
|
|
+ $itemStatistics->staff=$receiptDetail['staff'];
|
|
|
+ $itemStatistics->price=$value;
|
|
|
+ $itemStatistics->itemCategory=$this->TRAVEL;
|
|
|
+ $itemStatistics->date=$receiptDetail['date'];
|
|
|
+ $itemStatistics->insert();
|
|
|
+ }else{
|
|
|
+ if (!empty($value)){
|
|
|
+ $itemStatistics->price=$value+$iStatistics['price'];
|
|
|
+ $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }elseif($key=="trainSum"){
|
|
|
+ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
|
|
|
+ if(empty($iStatistics)){
|
|
|
+ $itemStatistics->cid=$receiptDetail['cid'];
|
|
|
+ $itemStatistics->staff=$receiptDetail['staff'];
|
|
|
+ $itemStatistics->price=$value;
|
|
|
+ $itemStatistics->itemCategory=$this->TRAIN;
|
|
|
+ $itemStatistics->date=$receiptDetail['date'];
|
|
|
+ $itemStatistics->insert();
|
|
|
+ }else{
|
|
|
+ if (!empty($value)){
|
|
|
+ $itemStatistics->price=$value+$iStatistics['price'];
|
|
|
+ $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }elseif($key=="otherSum"){
|
|
|
+ $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$receiptDetail['staff'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
|
|
|
+ if(empty($iStatistics)){
|
|
|
+ $itemStatistics->cid=$receiptDetail['cid'];
|
|
|
+ $itemStatistics->staff=$receiptDetail['staff'];
|
|
|
+ $itemStatistics->price=$value;
|
|
|
+ $itemStatistics->itemCategory=$this->OTHER;
|
|
|
+ $itemStatistics->date=$receiptDetail['date'];
|
|
|
+ $itemStatistics->insert();
|
|
|
+ }else{
|
|
|
+ if (!empty($value)){
|
|
|
+ $itemStatistics->price=$value+$iStatistics['price'];
|
|
|
+ $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $receipt->pastDate=date("Y-m-d");
|
|
|
+ }
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
echo $iid.$status.$opinion;
|
|
|
|
|
|
}
|