浏览代码

更新代码

caipin 8 年之前
父节点
当前提交
d4fc622050

+ 3 - 99
global/js/invoice.js

@@ -1,105 +1,9 @@
-function invoiceShow(){
-	
-	 var chkRadio = $('input:radio[name="invoiceType"]:checked').val();
-     if (chkRadio == null) {
-         alert("没有选中项");
-         return false;
-     } else if(chkRadio==1) {
-    	 $('#plainInvoice_box').hide();
-    	 $('#specialInvoice_box').show();
-     }else if(chkRadio==0){
-    	 $('#plainInvoice_box').show();
-    	 $('#specialInvoice_box').hide();
-     }
-    
-}
-
-function mailShow(){
-	var chkRadio = $('input:radio[name="doPost"]:checked').val();
-    if (chkRadio == null) {
-        alert("没有选中项");
-        return false;
-    } else if(chkRadio==1) {
-   	 $('#mail_box').show();
-    }else if(chkRadio==0){
-   	 $('#mail_box').hide();
-    }
-}
-
 $(function () {
-	
-	$('#invoice').validator({
-	    timely: 3,
-	    focusCleanup: true,
-	    rules: {
-	    	invoiceTitle: function() {
-	    		return $('#invoicePlain').prop('checked');
-	        },
-	        invoiceCompany: function() {
-	        	return $('#invoiceSpecial').prop('checked');
-		        }
-	        ,isMail: function() {
-	        	return $('#isMail').prop('checked');
-	        }
-	    },
-	    fields: {
-	    	invoiceTitle: 'required(invoiceTitle);',
-	    	invoiceCompany:'required(invoiceCompany);',
-	    	TIN:'required(invoiceCompany);',
-	    	address:'required(invoiceCompany);',
-	    	phone:'required(invoiceCompany);',
-	    	bank:'required(invoiceCompany);',
-	    	bankAccount:'required(invoiceCompany);',
-	    	'invoicePrice': 'required; '
-		    ,invoiceElement: 'required; '
-		    ,'invoiceType': 'required'
-			,recipients: 'required(isMail); '
-			,recipientsPhone: 'required(isMail); '
-			,recipientsAddress: 'required(isMail); '
-	    }
+	$("a[node-approval^='approval']").click(function(){
+		$("input[name='status']").val($(this).attr("diss-data"));
+		$("form[name='invoiceApproval']").submit();
 	});
 	
 	
-	$('#invoice2').validator({
-		/*
-		submitHandler: function(form){   
-            alert("提交表单");  
-            return false;
-            //form.submit();   
-        },
-        
-        
-        
-        invoiceTilte:function(element,params){
-    			console.log('ddd222');
-    			if (params==1){
-    					console.log('ddd');
-    					return true;
-    			}else {
-    				console.log(element.value+"dd"+params);
-    				this.renderMsg("只接受{1}后缀");
-    				return false;
-    				//this.renderMsg("只接受{1}后缀", ext.replace('|', ','));
-    			};
-    			
-    		}
-        
-        */
-        
-		
-       
-	    fields: {
-	        'invoicePrice': 'required; '
-	        ,'invoiceElement': 'required; '
-	        ,'invoiceType': 'required'
-	        ,'invoiceTitle': "invoiceTilte"
-	        ,'company': 'required;'
-	        ,'realName': 'required;'
-	        ,'telephone': 'required;'
-	        ,'email': 'required;email;remote[yn2/check/Report, email]'
-	    }
-	   
-	});
-	
 
 })

+ 1 - 1
index.php

@@ -1,5 +1,5 @@
 <?php
-555
+
 include './protected/config/common.conf.php';
 include './protected/config/routes.conf.php';
 include './protected/config/db.conf.php';

+ 1 - 1
protected/config/routes.conf.php

@@ -361,7 +361,7 @@ $route['*']['/invoiceAdd'] = array('InvoiceController', 'invoiceAdd');
 $route['*']['/invoiceAddDo'] = array('InvoiceController', 'invoiceAddDo');
 $route['*']['/invoiceApproval'] = array('InvoiceController', 'invoiceApproval');
 $route['*']['/invoiceDetail/:iid'] = array('InvoiceController', 'invoiceDetail','extension'=>'.html');
-
+$route['*']['/invoiceApprovalDo'] = array('InvoiceController', 'invoiceApprovalDo');
 
 
 ?>

+ 86 - 68
protected/controller/InvoiceController.php

@@ -9,9 +9,7 @@ class InvoiceController extends DooController {
 	public $executeId;
 	public static $NEW = 0;
 	public static $NEW2 = 0;
-	
-	
-	
+	private $INVOICEKEY="APPROVAL";
 	
 	function __construct() { 
 		if(isset($_COOKIE["staff"])){
@@ -124,8 +122,7 @@ class InvoiceController extends DooController {
 		
 		$mailItems=$this->get_args('mailItems')?$this->get_args('mailItems'):"";
 		$remark=$this->get_args('remark')?$this->get_args('remark'):"";
-		//&&!empty($invoiceTitle)&&!empty($invoiceCompany)&&!empty($TIN)&&!empty($address)
-		//   &&!empty($phone)&&!empty($bank)&&!empty($bankAccount)&&!empty($recipients)&&!empty($recipientsPhone)&&!empty($recipientsAddress)
+		
 		if(!empty($cid)&&!empty($invoicePrice)&&!empty($invoiceElement)){
 			Doo::loadModel('invoice');
 			$invoice=new invoice();
@@ -182,6 +179,9 @@ class InvoiceController extends DooController {
 		$invoiceManage=new invoiceManage();
 		
 		$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']);
+		}
 		
 		$data['invoiceList']=$invoiceList;
 		
@@ -195,14 +195,15 @@ class InvoiceController extends DooController {
 	
 	function invoiceDetail(){
 		
-		$iid=isset($this->params['iid'])&&is_numeric($this->params['iid'])?$this->params['iid']:0;
+		$iid=isset($this->params['iid'])?$this->params['iid']:"";
+		$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'],'asArray'=>true));
+		$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));
 		
@@ -211,6 +212,7 @@ class InvoiceController extends DooController {
 		
 		$data['invoiceDetail']=$invoiceDetail;
 		
+		$data['INVOICEKEY']=$this->authcode($invoiceDetail['iid'],'');
 		$data['memu']="invoice";
 		$data['staff']=$this->staff;
 		$data['receiptMemu']='invoiceApproval';
@@ -219,6 +221,27 @@ class InvoiceController extends DooController {
 		$this->render ( "/admin/invoiceApprovalDetail", $data );
 	}
 	
+	function invoiceApprovalDo(){
+		$iid=$this->get_args('iid')?$this->get_args('iid'):"";
+		$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'):"";
+		
+		if (!empty($iid)&&!empty($status)&&!empty($opinion)){
+			if (!($status==2||$status==3||$status==4))
+				die('illegal request');
+			Doo::loadModel('invoice');
+			$invoice=new invoice();
+			
+			$iid=$this->authcode($iid);
+			
+			$invoice->getOne(array('where'=>'status=1 and iid='.$iid.' and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
+			
+			
+			echo $iid.$status.$opinion;
+			
+		}
+	}
+	
 	private function getExeCount(){
 		Doo::loadModel('receipt');
 		$receipt=new receipt();
@@ -272,67 +295,62 @@ class InvoiceController extends DooController {
 	}
 
 	
-function num_to_rmb($num){
-        $c1 = "零壹贰叁肆伍陆柒捌玖";
-        $c2 = "分角元拾佰仟万拾佰仟亿";
-        //精确到分后面就不要了,所以只留两个小数位
-        $num = round($num, 2); 
-        //将数字转化为整数
-        $num = $num * 100;
-        if (strlen($num) > 10) {
-                return "金额太大,请检查";
-        } 
-        $i = 0;
-        $c = "";
-        while (1) {
-                if ($i == 0) {
-                        //获取最后一位数字
-                        $n = substr($num, strlen($num)-1, 1);
-                } else {
-                        $n = $num % 10;
-                }
-                //每次将最后一位数字转化为中文
-                $p1 = substr($c1, 3 * $n, 3);
-                $p2 = substr($c2, 3 * $i, 3);
-                if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
-                        $c = $p1 . $p2 . $c;
-                } else {
-                        $c = $p1 . $c;
-                }
-                $i = $i + 1;
-                //去掉数字最后一位了
-                $num = $num / 10;
-                $num = (int)$num;
-                //结束循环
-                if ($num == 0) {
-                        break;
-                } 
-        }
-        $j = 0;
-        $slen = strlen($c);
-        while ($j < $slen) {
-                //utf8一个汉字相当3个字符
-                $m = substr($c, $j, 6);
-                //处理数字中很多0的情况,每次循环去掉一个汉字“零”
-                if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
-                        $left = substr($c, 0, $j);
-                        $right = substr($c, $j + 3);
-                        $c = $left . $right;
-                        $j = $j-3;
-                        $slen = $slen-3;
-                } 
-                $j = $j + 3;
-        } 
-        //这个是为了去掉类似23.0中最后一个“零”字
-        if (substr($c, strlen($c)-3, 3) == '零') {
-                $c = substr($c, 0, strlen($c)-3);
-        }
-        //将处理的汉字加上“整”
-        if (empty($c)) {
-                return "零元整";
-        }else{
-                return $c . "整";
-        }
+/**
+ * 加密或解密指定字符串
+ * @param string $string 要加密或解密的字符串
+ * @param string $operation 当取值为'DECODE'时表示解密,否则为加密
+ * @param string $key 加解密的key
+ * @param $expiry 超时值
+ * */
+function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
+	$ckey_length = 4;
+	if (! $key) {
+		$key = $this->INVOICEKEY;
+	}
+	$key = md5 ( $key );
+	$keya = md5 ( substr ( $key, 0, 16 ) );
+	$keyb = md5 ( substr ( $key, 16, 16 ) );
+	$keyc = $ckey_length ? ($operation == 'DECODE' ? substr ( $string, 0, $ckey_length ) : substr ( md5 ( microtime () ), - $ckey_length )) : '';
+	
+	$cryptkey = $keya . md5 ( $keya . $keyc );
+	$key_length = strlen ( $cryptkey );
+	
+	$string = $operation == 'DECODE' ? base64_decode ( substr ( $string, $ckey_length ) ) : sprintf ( '%010d', $expiry ? $expiry + time () : 0 ) . substr ( md5 ( $string . $keyb ), 0, 16 ) . $string;
+	$string_length = strlen ( $string );
+	
+	$result = '';
+	$box = range ( 0, 255 );
+	
+	$rndkey = array ();
+	for($i = 0; $i <= 255; $i ++) {
+		$rndkey [$i] = ord ( $cryptkey [$i % $key_length] );
+	}
+	
+	for($j = $i = 0; $i < 256; $i ++) {
+		$j = ($j + $box [$i] + $rndkey [$i]) % 256;
+		$tmp = $box [$i];
+		$box [$i] = $box [$j];
+		$box [$j] = $tmp;
+	}
+	
+	for($a = $j = $i = 0; $i < $string_length; $i ++) {
+		$a = ($a + 1) % 256;
+		$j = ($j + $box [$a]) % 256;
+		$tmp = $box [$a];
+		$box [$a] = $box [$j];
+		$box [$j] = $tmp;
+		$result .= chr ( ord ( $string [$i] ) ^ ($box [($box [$a] + $box [$j]) % 256]) );
+	}
+	
+	if ($operation == 'DECODE') {
+		if ((substr ( $result, 0, 10 ) == 0 || substr ( $result, 0, 10 ) - time () > 0) && substr ( $result, 10, 16 ) == substr ( md5 ( substr ( $result, 26 ) . $keyb ), 0, 16 )) {
+			return substr ( $result, 26 );
+		} else {
+			return '';
+		}
+	} else {
+		return $keyc . str_replace ( '=', '', base64_encode ( $result ) );
+	}
 }
 
 

+ 2 - 1
protected/model/invoice.php

@@ -8,6 +8,7 @@ class invoice extends DooModel {
     public $status;
     public $invoiceManage;
     public $pendingApprovals;
+    public $processApprovals;
     public $invoiceSerial;
     public $invoicePrice;
     
@@ -39,7 +40,7 @@ class invoice extends DooModel {
     public $_table = 'CLD_invoice';
     public $_primarykey = 'iid';
     
-    public $_fields = array('iid','invoiceManage', 'pendingApprovals' ,'status' ,'invoicePrice', 'cid','categoryName', 'remark', 'invoiceElement','invoiceType', 'invoiceTitle', 'invoiceCompany'
+    public $_fields = array('iid','invoiceManage', 'pendingApprovals','processApprovals' ,'status' ,'invoicePrice', 'cid','categoryName', 'remark', 'invoiceElement','invoiceType', 'invoiceTitle', 'invoiceCompany'
     , 'TIN', 'address','phone', 'bank', 'bankAccount','doPost', 'recipients', 'recipientsPhone','recipientsAddress', 'mailItems','sid','userName','date');
 
    

+ 1 - 1
protected/view/admin/invoiceAdd.html

@@ -2,7 +2,7 @@
 <link rel=stylesheet href="<?= WEB_SITE_GLOBAL ?>css/jquery.validator.css"> 
 <script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/jquery.validator.min.js"></script>
 <script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/zh-CN.js"></script>
-<script src="<?= WEB_SITE_GLOBAL ?>js/invoice.js"></script>
+<script src="<?= WEB_SITE_GLOBAL ?>js/invoice.validator.js"></script>
 <body>
 	<div class="mainLayout">
 		<div class="mainMenu">

+ 1 - 1
protected/view/admin/invoiceApproval.html

@@ -47,7 +47,7 @@
                                     </td>
                                     <td>{{invoiceList' value.categoryName}}{{invoiceList' value.userName}} {{invoiceList' value.date}}</td>
                                     <td></td>
-                                    <td><a class="button btn-block" href="/invoiceDetail/{{invoiceList' vlaue.iid}}.html" >审批开票</a></td>
+                                    <td><a class="button btn-block" href="/invoiceDetail/{{invoiceList' vlaue.iidKey}}.html" >审批开票</a></td>
                                 </tr>
                                 <!-- endloop -->
                                 

+ 1 - 1
protected/viewc/admin/invoiceApproval.php

@@ -47,7 +47,7 @@
                                     </td>
                                     <td><?php echo $v1['categoryName']; ?><?php echo $v1['userName']; ?> <?php echo $v1['date']; ?></td>
                                     <td></td>
-                                    <td><a class="button btn-block" href="/invoiceDetail/<?php echo $v1['iid']; ?>.html" >审批开票</a></td>
+                                    <td><a class="button btn-block" href="/invoiceDetail/<?php echo $v1['iidKey']; ?>.html" >审批开票</a></td>
                                 </tr>
                                 <?php endforeach; ?>