|  | @@ -91,8 +91,10 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$invoice = new invoice ();
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'express' );
 | 
	
		
			
				|  |  |  		$express = new express ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceReceivables' );
 | 
	
		
			
				|  |  |  		$invoiceReceivables = new invoiceReceivables ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceStatistics' );
 | 
	
		
			
				|  |  |  		$invoiceStatistics = new invoiceStatistics ();
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -110,9 +112,11 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$expressList = $express->getExpressByAll ();
 | 
	
		
			
				|  |  |  		$invoiceList = $invoice->getMyInvoice ( $_COOKIE ["staff"] );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 | 
	
		
			
				|  |  | +		//$list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		// print_r($invoiceList);
 | 
	
		
			
				|  |  | +		$list=$invoice->getInvoiceByUntreadStatusPage(4,$_COOKIE ["staff"]);
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		// print_r($list);
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$this->data ['isMonth'] = $isMonth;
 | 
	
		
			
				|  |  |  		$this->data ['htm'] = $htm;
 | 
	
	
		
			
				|  | @@ -1626,14 +1630,30 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  |  		$invoice = new invoice ();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$page_size=12;
 | 
	
		
			
				|  |  | +		$page_size=1;
 | 
	
		
			
				|  |  |  		$page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
 | 
	
		
			
				|  |  | +		$date = isset($this->params ['date']) ? $this->params ['date'] : 'MONTHO';
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$con='';
 | 
	
		
			
				|  |  | +		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)';
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$pageinfo['page']=array('previous'=>'');
 | 
	
		
			
				|  |  | -		//$pageinfo=$this->get_page("CLD_receipt", $dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.') and status!=5', $page, $page_size, "approvalExpenses","","");
 | 
	
		
			
				|  |  | +		$sql='status=2 and untreadStatus=3 and sid='.$_COOKIE ["staff"].$con;
 | 
	
		
			
				|  |  | +		$pageinfo=$this->get_page("CLD_invoice", $sql, $page, $page_size, "invoiceAchieve","","");
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$invoice->getInvoiceByUntreadStatusPage();
 | 
	
		
			
				|  |  | +		$limit=$pageinfo ['lower'].','.$page_size;
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | +		$list=$invoice->getInvoiceByUntreadStatusPage($limit,$_COOKIE ["staff"],$con);
 | 
	
		
			
				|  |  | +		//print_r($pageinfo);
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$this->data['page']=$pageinfo;
 | 
	
		
			
				|  |  | +		$this->data ['list'] = $list;
 | 
	
		
			
				|  |  | +		$this->data ['date']=$date;
 | 
	
		
			
				|  |  |  		$this->data ['memu'] = "invoice";
 | 
	
		
			
				|  |  |  		$this->data ['staff'] = $this->staff;
 | 
	
		
			
				|  |  |  		$this->data ['receiptMemu'] = 'invoice';
 | 
	
	
		
			
				|  | @@ -2044,7 +2064,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			$receivablesPrice += $detailM ['receivablesPrice'];
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		if ($receivablesPrice >= $detail ['invoicePrice']) {
 | 
	
		
			
				|  |  | +		if ($receivablesPrice > $detail ['invoicePrice']) {
 | 
	
		
			
				|  |  |  			$price = $receivablesPrice - $detail ['invoicePrice'];
 | 
	
		
			
				|  |  |  			echo json_encode ( array (
 | 
	
		
			
				|  |  |  					'status' => 1,
 | 
	
	
		
			
				|  | @@ -2342,6 +2362,74 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		} else
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获得分页数据
 | 
	
		
			
				|  |  | +	 * @param unknown_type $table
 | 
	
		
			
				|  |  | +	 * @param unknown_type $condition
 | 
	
		
			
				|  |  | +	 * @param unknown_type $on_page
 | 
	
		
			
				|  |  | +	 * @param unknown_type $page_size
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
 | 
	
		
			
				|  |  | +		$page_c = "";
 | 
	
		
			
				|  |  | +		$page ['previous'] = $this->get_previous ( $on_page );
 | 
	
		
			
				|  |  | +		$page ['on_page'] = $on_page;
 | 
	
		
			
				|  |  | +		$total_count = $this->get_table_count ( $table, $condition );
 | 
	
		
			
				|  |  | +		$total = intval ( $total_count / $page_size );
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		$page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
 | 
	
		
			
				|  |  | +		$page ['total_data'] = $total_count;
 | 
	
		
			
				|  |  | +		$page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		$i = 1;
 | 
	
		
			
				|  |  | +		$page_max = 1;
 | 
	
		
			
				|  |  | +		$page_width=3;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		if ($on_page >= $page_width) {
 | 
	
		
			
				|  |  | +			$page_max = intval ( $on_page / $page_width ) + 1;
 | 
	
		
			
				|  |  | +			$i = intval ( $on_page / $page_width ) * $page_width - 1;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		for(; $i <= $page ['total_page']; $i ++) {
 | 
	
		
			
				|  |  | +			if ($i == $on_page)
 | 
	
		
			
				|  |  | +				$page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
 | 
	
		
			
				|  |  | +				else
 | 
	
		
			
				|  |  | +					$page_c .= '<li><a href="/' . $action .'/'. $i . $get . '">' . $i . '</a></li>';
 | 
	
		
			
				|  |  | +						
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +					if ($i == ($page_width * $page_max))
 | 
	
		
			
				|  |  | +						break;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		$page ['page'] = $page_c;
 | 
	
		
			
				|  |  | +		$page ['lower'] = (-- $on_page) * $page_size;
 | 
	
		
			
				|  |  | +		return $page;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取上一页
 | 
	
		
			
				|  |  | +	 * @param unknown_type $on_page
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function get_previous($on_page = 1) {
 | 
	
		
			
				|  |  | +		return $on_page != 0 ? $on_page - 1 : $on_page;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取总页数
 | 
	
		
			
				|  |  | +	 * @param unknown_type $table
 | 
	
		
			
				|  |  | +	 * @param unknown_type $condition
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public function get_table_count($table = "", $condition = "") {
 | 
	
		
			
				|  |  | +		//$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		$sql = "select count(*) as count from " . $table . " where  " . $condition;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +		//echo $sql;die;
 | 
	
		
			
				|  |  | +		$query = Doo::db ()->query ( $sql );
 | 
	
		
			
				|  |  | +		$result = $query->fetch ();
 | 
	
		
			
				|  |  | +		return $result ['count'];
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  	function isInvoiceNew($type = "GLOBAL") {
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoice' );
 | 
	
		
			
				|  |  |  		$invoice = new invoice ();
 |