Selaa lähdekoodia

开票menu权限

caipin 8 vuotta sitten
vanhempi
commit
be59be8bbd

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 982 - 885
protected/controller/AdminController.php


+ 6 - 75
protected/controller/InvoiceController.php

@@ -9,69 +9,18 @@
  */
 class InvoiceController extends DooController {
 	public $staff;
-	public $verifyId;
-	public $executeId;
-	public static $NEW = 0;
-	public static $NEW2 = 0;
 	private $INVOICEKEY = "APPROVAL";
 	function __construct() {
 		if (isset ( $_COOKIE ["staff"] )) {
-			
 			if (! empty ( $_COOKIE ["staff"] )) {
-				
 				Doo::loadModel ( 'staff' );
-				Doo::loadModel ( 'verify' );
-				$verify = new verify ();
 				$staff = new staff ();
-				Doo::loadModel ( "execute" );
-				$execute = new execute ();
+				Doo::loadModel("invoiceManage");
+				$invoiceManage=new invoiceManage();
 				
-				$verifyList = $verify->find ( array (
-						'select' => 'staff',
-						'asArray' => true 
-				) );
-				$list = array ();
+				//$invoiceManage
 				
-				// 判断角色的审批权限
-				foreach ( $verifyList as $key => $value ) {
-					$ver = json_decode ( $value ['staff'] );
-					
-					foreach ( $ver as $k => $v ) {
-						if ($v [1] == 'ROLE') {
-							$roleList = json_decode ( $v [3] );
-							foreach ( $roleList as $t => $g ) {
-								$gList = explode ( "_", $g );
-								array_push ( $list, $gList [0] );
-								// print_r($list);
-							}
-						} else
-							array_push ( $list, $v [0] );
-					}
-				}
-				
-				// 判断执行人的审批权限
-				$executeList = $execute->find ( array (
-						'select' => 'staff',
-						'asArray' => true 
-				) );
-				$list2 = array ();
-				foreach ( $executeList as $key => $value ) {
-					$ver = json_decode ( $value ['staff'] );
-					
-					foreach ( $ver as $k => $v ) {
-						array_push ( $list2, $v [0] );
-					}
-				}
-				
-				$eidList = file_get_contents ( "protected/config/execute/execute.ini" );
-				$eidList = array_filter ( explode ( ",", $eidList ) );
-				
-				$this->executeId = array_merge ( $list2, $eidList );
-				
-				$this->verifyId = $list;
 				$this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
-				ReceiptController::$NEW = $this->getReceiptCount ();
-				ReceiptController::$NEW2 = $this->getExeCount ();
 				return "/";
 			}
 		}
@@ -96,8 +45,6 @@ class InvoiceController extends DooController {
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoice';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoice", $data );
 	}
 	function invoiceAdd() {
@@ -113,8 +60,6 @@ class InvoiceController extends DooController {
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoice';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoiceAdd", $data );
 	}
 	
@@ -279,8 +224,6 @@ class InvoiceController extends DooController {
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoiceApproval';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoiceApproval", $data );
 	}
 	function invoiceDetail() {
@@ -309,8 +252,6 @@ class InvoiceController extends DooController {
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoiceApproval';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoiceApprovalDetail", $data );
 	}
 	
@@ -486,8 +427,6 @@ class InvoiceController extends DooController {
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoicePrint';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoicePrint", $data );
 	}
 	/**
@@ -522,8 +461,6 @@ class InvoiceController extends DooController {
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoicePrint';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoicePrintDetail", $data );
 	}
 	/**
@@ -549,8 +486,8 @@ class InvoiceController extends DooController {
 			$item = array (
 					'iid' => $iid,
 					'status' => 5,
-					'updateTime'=>date ( "Y-m-d H:i:s" ),
-					'printTime'=>date ( "Y-m-d H:i:s" ),
+					'updateTime' => date ( "Y-m-d H:i:s" ),
+					'printTime' => date ( "Y-m-d H:i:s" ),
 					'invoiceNo' => $invoiceNo 
 			);
 			$invoice->setPrintByInvoice ( $item );
@@ -576,15 +513,13 @@ class InvoiceController extends DooController {
 		Doo::loadModel ( 'invoice' );
 		$invoice = new invoice ();
 		
-		$invoicePost=$invoice->getPostByInvoice();
+		$invoicePost = $invoice->getPostByInvoice ();
 		
 		$data ['invoicePost'] = $invoicePost;
 		
 		$data ['memu'] = "invoice";
 		$data ['staff'] = $this->staff;
 		$data ['receiptMemu'] = 'invoicePost';
-		$data ['verifyId'] = $this->verifyId;
-		$data ['executeId'] = $this->executeId;
 		$this->render ( "/admin/invoicePost", $data );
 	}
 	private function getExeCount() {
@@ -704,9 +639,5 @@ class InvoiceController extends DooController {
 		}
 	}
 }
-class ReceiptController {
-	public static $NEW = 0;
-	public static $NEW2 = 0;
-}
 
 ?>

+ 35 - 15
protected/model/invoiceManage.php

@@ -1,19 +1,39 @@
 <?php
-
-Doo::loadCore('db/DooModel');
-
+Doo::loadCore ( 'db/DooModel' );
+/**
+ *
+ * @author CP.
+ * @version 1.0
+ * @namespace
+ *
+ * @package
+ *
+ */
 class invoiceManage extends DooModel {
-
-    public $iid;
-    
-    public $staff;
-    public $mold;
-    
-    public $_table = 'CLD_invoiceManage';
-    public $_primarykey = 'iid';
-    
-    public $_fields = array('iid', 'staff','mold');
-
+	public $iid;
+	public $staff;
+	public $mold;
+	public $_table = 'CLD_invoiceManage';
+	public $_primarykey = 'iid';
+	public $_fields = array (
+			'iid',
+			'staff',
+			'mold' 
+	);
+	/**
+	 * 更加类型获取审批组成员
+	 * @return unknown
+	 */
+	public function getInvoiceByMold($mold = "") {
+		$list = array ();
+		if (! empty ( $mold )) {
+			$list = $this->find ( array (
+					'where' => 'mold="' . $mold.'"',
+					'asArray' => TRUE 
+			) );
+		}
+		return $list;
+	}
 }
 
-?>
+// ?>

+ 64 - 32
protected/plugin/TemplateTag.php

@@ -14,22 +14,42 @@ Doo::conf ()->TEMPLATE_GLOBAL_TAGS = array (
 		'isset',
 		'empty',
 		'make_date',
-		'inarray' ,
-		'getGlobals'
+		'inarray',
+		'getGlobals' ,
+		'isInvoiceMoldShow'
 );
-
 /**
- * Define as class (optional)
- * class TemplateTag { public static test(){} public static test2(){} }
+ * 判断发票的审批权限
+ * @param number $sid 用户ID
+ * @param string $mold 项目类型
+ * @return boolean
  */
+function isInvoiceMoldShow($sid = 0, $mold = '') {
+	if (! empty ( $sid ) && ! empty ( $mold )) {
+		Doo::loadModel ( "invoiceManage" );
+		$invoiceManage = new invoiceManage ();
+		$imList = $invoiceManage->getInvoiceByMold($mold);
+		$list=array();
+		foreach ($imList as $key=>$value){
+			$ver=json_decode($value['staff']);
+			foreach ($ver as $k=>$v){
+				array_push($list, $v[0]);
+			}
+		}
+		$fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
+		$fileInvoice = json_decode ( $fileInvoice, true );
+		print_r($fileInvoice);
+	} else
+		return false;
+}
 function getGlobals($var) {
-	if ($var=='NEW')
-	getReceiptCount();
-	elseif ($var=='NEW2')
-	getExeCount();
-	//echo $GLOBALS['NEW'].'<br/>';
+	if ($var == 'NEW')
+		getReceiptCount ();
+	elseif ($var == 'NEW2')
+		getExeCount ();
+		// echo $GLOBALS['NEW'].'<br/>';
 	
-	return $GLOBALS[$var] ;
+	return $GLOBALS [$var];
 }
 function inarray($v1, $v2) {
 	return in_array ( $v1, $v2 );
@@ -97,27 +117,39 @@ function url2($controller, $method, $param = null, $addRootUrl = false) {
 	
 	return DooUrlBuilder::url2 ( $controller, $method, null, $addRootUrl );
 }
-
-function getReceiptCount(){
-
-	$status=2;
-	$year=date('Y');
-
-	Doo::loadModel('receipt');
-	$receipt=new receipt();
-
-	$dateCondition=" and Year(date) =".$year;
-
-	$approvalCondition=' and nowStaff like "%'.$_COOKIE["staff"].'%" ';
-	$receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
-
-	$GLOBALS['NEW']= count($receiptList);
+/**
+ * 获得正在审批的费用单数量
+ */
+function getReceiptCount() {
+	$status = 2;
+	$year = date ( 'Y' );
+	
+	Doo::loadModel ( 'receipt' );
+	$receipt = new receipt ();
+	
+	$dateCondition = " and Year(date) =" . $year;
+	
+	$approvalCondition = ' and nowStaff like "%' . $_COOKIE ["staff"] . '%" ';
+	$receiptList = $receipt->find ( array (
+			'where' => ' status=' . $status . $dateCondition . $approvalCondition,
+			'desc' => 'rid',
+			'asArray' => true 
+	) );
+	
+	$GLOBALS ['NEW'] = count ( $receiptList );
 }
-function getExeCount(){
-	Doo::loadModel('receipt');
-	$receipt=new receipt();
-	$receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$_COOKIE["staff"].'%\' and executeStaff NOT LIKE \'%'.$_COOKIE["staff"].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
-
-	$GLOBALS['NEW2']= count($receiptList);
+/**
+ * 获得执行费用的数量
+ */
+function getExeCount() {
+	Doo::loadModel ( 'receipt' );
+	$receipt = new receipt ();
+	$receiptList = $receipt->find ( array (
+			'where' => '(executeCopy like \'%["' . $_COOKIE ["staff"] . '%\' and executeStaff NOT LIKE \'%' . $_COOKIE ["staff"] . '%\' ) and (status=1 or status=6)',
+			'desc' => 'rid',
+			'asArray' => true 
+	) );
+	
+	$GLOBALS ['NEW2'] = count ( $receiptList );
 }
 ?>

+ 26 - 4
protected/view/admin/invoiceMenu.html

@@ -1,12 +1,34 @@
 <ul>
 	<li class="invoiceTitle">发票申请</li>
-	<li class="news"><a href="/invoice" <!-- if {{receiptMemu}}=="invoice" --> class="selected" <!-- endif --> >我的发票</a></li>
+	<li class="news"><a href="/invoice"
+			<!-- if {{receiptMemu}}=="invoice" --> class="selected" <!-- endif -->
+			>我的发票
+	</a></li>
 	<li class="news"><a href="invoice-billing-my.html">我的收款</a></li>
 	<li><a href="invoice-billing.html">收款认领</a></li>
+	
+	
+	
+	
 	<li class="topLine"><a href="invoice-input-billing.html">收款录入</a></li>
-	<li><a <!-- if {{receiptMemu}}=="invoiceApproval" --> class="selected" <!-- endif --> href="/invoiceApproval">发票审批</a></li>
-	<li class="news"><a <!-- if {{receiptMemu}}=="invoicePrint" --> class="selected" <!-- endif --> href="/invoicePrint">发票打印</a></li>
-	<li class="news"><a <!-- if {{receiptMemu}}=="invoicePost" --> class="selected" <!-- endif --> href="/invoicePost">发票邮寄</a></li>
+	
+	<!-- if isInvoiceMoldShow({{staff.0.sid}},'发票审批') -->
+	<li><a
+			<!-- if {{receiptMemu}}=="invoiceApproval" --> class="selected" <!-- endif -->
+			href="/invoiceApproval">发票审批
+	</a></li>
+	<!-- endif -->
+	
+	<li class="news"><a
+			<!-- if {{receiptMemu}}=="invoicePrint" --> class="selected" <!-- endif -->
+			href="/invoicePrint">发票打印
+	</a></li>
+	
+	<li class="news"><a
+			<!-- if {{receiptMemu}}=="invoicePost" --> class="selected" <!-- endif -->
+			href="/invoicePost">发票邮寄
+	</a></li>
+	
 	<li><a href="invoice-return.html">发票退票</a></li>
 	<li><a href="invoice-dlist-category-year.html">公司汇总</a></li>
 </ul>