caipin 4 年 前
コミット
eecc8dabbd

+ 1 - 1
global/css/global.css

@@ -4173,7 +4173,7 @@ td div.dlLev3{
 .popupTip{
   position: absolute;
   top: 0px;
-  z-index: 999;
+  z-index: 9999;
   width: 960px;
   text-align: center;
 }

+ 2 - 2
global/vue/fee/fee_receipt_data.js

@@ -9,9 +9,9 @@ let data = {
         {
             id: 0,
             name: "办事处相关费用",
-            show: false,
+            show: true,
             anchor: "officeAnchor",
-            active: false,
+            active: true,
             daily: accountItem.daily,
             other: accountItem.other,
             officeExplain: [{ officeExplain: "" }],

+ 1 - 1
global/vue/fee/receipt_create.js

@@ -29,7 +29,7 @@ new Vue({
      
       checkReceipt(event, this);
       // dev 不提交
-      // event.preventDefault();
+      //  event.preventDefault();
     },
     // 附件上传
     enclosurFile: function (event) {

+ 180 - 42
global/vue/fee/receipt_create_fn.js

@@ -15,63 +15,150 @@ function checkReceipt(event, obj) {
     }
   }
 
-   //2.选择办事处费用 
-   if (obj.receiptTypeMenu[2].show) {
+  //2.选择办事处费用 
+  if (obj.receiptTypeMenu[2].show) {
     if (obj.receiptTypeMenu[2].trainExplain[0].trainExplain == "") {
       obj.alertDia("请填写 内部培训费用 报销说明");
       flag = true;
     }
   }
 
+
+  //3.行程时间判定
+  if (obj.receiptTypeMenu[1].show) {
+    // if (obj.receiptTypeMenu[1]['traveList'].length > 1) {
+    let sortList = new Array();
+    // obj.receiptTypeMenu[1]['traveList'].forEach(element => {
+    //   let dateArray = element.tripTime.split(" - ");
+
+    //   if (dateArray.length != 2) {
+    //     obj.alertDia("差旅行程时间填写有误");
+    //     event.preventDefault();
+    //     return 
+    //   }
+
+    //   let item = new Array(new Date(dateArray[0]).getTime() / 1000 - 28800, new Date(dateArray[1]).getTime() / 1000 - 28800);
+    //   sortList.push(item);
+    // });
+
+    for (let i = 0; i < obj.receiptTypeMenu[1]['traveList'].length; i++) {
+      let dateArray = obj.receiptTypeMenu[1]['traveList'][i].tripTime.split(" - ");
+      if (dateArray.length != 2) {
+        obj.alertDia("差旅行程时间填写有误");
+        event.preventDefault();
+        return
+      }
+      let dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
+      if (!dateFormat.test(dateArray[0])) {
+        obj.alertDia("差旅行程时间填写有误");
+        event.preventDefault();
+        return
+      }
+      if (!dateFormat.test(dateArray[1])) {
+        obj.alertDia("差旅行程时间填写有误");
+        event.preventDefault();
+        return
+      }
+
+      let item = new Array(new Date(dateArray[0]).getTime() / 1000 - 28800, new Date(dateArray[1]).getTime() / 1000 - 28800);
+      sortList.push(item);
+    }
+
+
+    //验证差旅时间
+    console.log(obj.receiptTypeMenu[1]['traveList'])
+    //  let dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
+    //  if (sortList[i].length != 2) {
+    //   flag = true;
+    //   break;
+    // } else {
+    //   if (!dateFormat.test(sortList[i][0])) {
+    //     flag = true;
+    //     break;
+    //   }
+    //   if (!dateFormat.test(sortList[i][1])) {
+    //     flag = true;
+    //     break;
+    //   }
+    // }
+
+
+    let alertDia = obj.alertDia;
+    $.ajax({
+      type: "GET",
+      url: "/json/trave/date/all",
+      dataType: "json",
+      processData: false,
+      contentType: false,
+    }).success(function (data) {
+      sortList.forEach(element => {
+        data.push(element);
+      });
+
+      let TraveStatus = isTraveDate(sortList);
+      if (TraveStatus == 2) {
+        alertDia("差旅日期格式不正确");
+        flag = true;
+      }
+
+    }).fail(function (msg) {
+      alertDia("历史差旅时间获取失败");
+      flag = true;
+    });
+
+  }
+
   // 选择费用类型
   if (obj.receiptTypeMenu[0].show === false && obj.receiptTypeMenu[1].show === false && obj.receiptTypeMenu[2].show === false) {
     obj.alertDia("请选择 费用类型");
     flag = true;
   }
 
- 
 
- 
+
+
 
   // 设置参数
   // 1.办事处相关费用
   let officeData_input_dom = obj.$refs.officeData_input;
-  officeData_input_dom.value="";
+  officeData_input_dom.value = "";
   if (obj.receiptTypeMenu[0].show) {
-    officeData_input_dom.value=JSON.stringify(obj.receiptTypeMenu[0]);
+    officeData_input_dom.value = JSON.stringify(obj.receiptTypeMenu[0]);
   }
   // 2.差旅相关费用
   let traveData_input_dom = obj.$refs.traveData_input;
-  traveData_input_dom.value="";
+  traveData_input_dom.value = "";
   if (obj.receiptTypeMenu[1].show) {
-    
-    traveData_input_dom.value=JSON.stringify(obj.receiptTypeMenu[1]);
+
+    traveData_input_dom.value = JSON.stringify(obj.receiptTypeMenu[1]);
   }
-   // 3.差旅相关费用
-   let trainData_input_dom = obj.$refs.trainData_input;
-   trainData_input_dom.value="";
-   if (obj.receiptTypeMenu[2].show) {
-    trainData_input_dom.value=JSON.stringify(obj.receiptTypeMenu[2]);
+  // 3.差旅相关费用
+  let trainData_input_dom = obj.$refs.trainData_input;
+  trainData_input_dom.value = "";
+  if (obj.receiptTypeMenu[2].show) {
+    trainData_input_dom.value = JSON.stringify(obj.receiptTypeMenu[2]);
   }
 
   // 4.附件内容相关
   let enclosurFiles_input_dom = obj.$refs.enclosurFiles_input;
-  enclosurFiles_input_dom.value="";
-  if(obj.enclosurFiles.length!=0){
-    enclosurFiles_input_dom.value=JSON.stringify(obj.enclosurFiles);
+  enclosurFiles_input_dom.value = "";
+  if (obj.enclosurFiles.length != 0) {
+    enclosurFiles_input_dom.value = JSON.stringify(obj.enclosurFiles);
   }
 
+
+
   // 校验设置后的参数
-  if( obj.verifyId===""){
+  if (obj.verifyId === "") {
     obj.alertDia("请选择 审批组");
     flag = true;
   }
- 
+
   if (flag) {
     event.preventDefault();
   }
 
-  
+
 
   // // 1-2日常费用
   // let officeDailyData_input_dom = obj.$refs.officeDailyData_input;
@@ -96,7 +183,7 @@ function checkReceipt(event, obj) {
   // officeExplain_input_dom.value = obj.receiptTypeMenu[0].officeExplain[0].officeExplain;
 
 
-  
+
 
 }
 // 办事处相关费用合计
@@ -162,25 +249,76 @@ function toDecimal2(x) {
   return s;
 }
 
-function delEnclosurByKey(id){
-	
-	var url = "/ajaxRemEnclousur";
-	$.ajax({
-		url : url,
-		type : "post",
-		cache : false,
-		dataType : "json",
-		data : {
-			key : id
-		},
-		global : true,
-		success : function(data) {
-			
-			if (data.status == 1) {
-				$('#'+id).remove(); 
-			} 
-		},
-		error : function(err) {
-		}
-	});
+function delEnclosurByKey(id) {
+
+  var url = "/ajaxRemEnclousur";
+  $.ajax({
+    url: url,
+    type: "post",
+    cache: false,
+    dataType: "json",
+    data: {
+      key: id
+    },
+    global: true,
+    success: function (data) {
+
+      if (data.status == 1) {
+        $('#' + id).remove();
+      }
+    },
+    error: function (err) {
+    }
+  });
+}
+
+function isTraveDate(sortList) {
+  let flag = 0;
+  let sortlength = sortList.length;
+
+  for (var index = 0; index < sortlength; index++) {
+    let start = sortList[index][0];
+    let end = sortList[index][1];
+    itemIndex = index + 1;
+    if (sortList.length === itemIndex) {
+      break;
+    }
+
+    let isRangeStartAndEnd = sortList.some((item, i) => {
+      if (i != index) {
+        return (item[0] <= start && item[1] >= start) || (item[0] <= end && item[1] >= end)
+      }
+    })
+
+    if (isRangeStartAndEnd) {
+      // 有重复区间
+      //flag = true;
+      flag = 2;
+      break;
+    }
+
+  }
+
+  // sortList.forEach((element, index) => {
+  //   let start = element[0];
+  //   let end = element[1];
+  //   itemIndex = index + 1;
+  //   if (sortList.length === itemIndex) {
+  //     return true;
+  //   }
+  //   let isRangeStartAndEnd = sortList.some((item, i) => {
+  //     if (i != index) {
+  //       return (item[0] <= start && item[1] >= start) || (item[0] <= end && item[1] >= end)
+  //     }
+  //     //return (sortList[itemIndex][0]<=start&&sortList[itemIndex][1]>=start)||(sortList[itemIndex][0]<=end&&sortList[itemIndex][1]>=end)
+  //   })
+  //   if (isRangeStartAndEnd) {
+  //     // 有重复区间
+  //     //flag = true;
+  //     flag = 2;
+  //     return true;
+  //   }
+  // });
+
+  return flag;
 }

+ 129 - 25
global/vue/fee/receipt_trave_component.js

@@ -9,18 +9,25 @@ Vue.component("trave", {
     data: function () {
         return {
             // 行程时间
+            traveDay: 0,
             tripTime: "",
 
             regionOption: region,
-            regionLeve2Option: region[0].child,
-            arrivalLeve2Option: region[0].child,
+            // regionLeve2Option: region[0].child,
+            // arrivalLeve2Option: region[0].child,
+            regionLeve2Option: region[defaultTraveProvinceIndex].child,
+            arrivalLeve2Option: region[defaultTraveProvinceIndex].child,
 
             // 出发地 省 市
-            departureProvince: region[0].name,
-            departureCity: region[0].child[0].name,
+            // departureProvince: region[0].name,
+            // departureCity: region[0].child[0].name,
+            departureProvince: defaultTraveProvince,
+            departureCity: region[defaultTraveProvinceIndex].child[0].name,
             // 结束地 省 市
-            arrivalProvince: region[0].name,
-            arrivalCity: region[0].child[0].name,
+            // arrivalProvince: region[0].name,
+            // arrivalCity: region[0].child[0].name,
+            arrivalProvince: defaultTraveProvince,
+            arrivalCity: region[defaultTraveProvinceIndex].child[0].name,
             // 目的地数组
             arrivalList: [],
 
@@ -33,24 +40,77 @@ Vue.component("trave", {
             // arrivalListEdi: [],
         }
     },
-    props: ['traveItem', 'alertDia', 'traveList','traveExplain'],
+    props: ['traveItem', 'alertDia', 'traveList', 'traveExplain'],
     computed: {
         travePrice: function () {
             return travePrice(this.traveList);
-            // let sum = 0;
-            // this.traveList.forEach(element => {
-            //     element.tripList.forEach(elementlv2 => {
-            //         elementlv2.tripItem.forEach(elementlv3 => {
-            //             sum += Number(elementlv3.price);
-            //         });
-            //     });
-            // });
-            // return sum.toFixed(2);
         }
     },
     methods: {
+        //行程时间验证
         changeCount: function (event) {
             this.tripTime = event.target.value;
+            this.tripTimeEdi = event.target.value;
+            let dateArray = event.target.value.split(" - ");
+            if (dateArray.length != 2) {
+                this.alertDia("差旅行程时间填写有误");
+                return 
+            }
+            let dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
+            if (!dateFormat.test(dateArray[0])) {
+                this.alertDia("差旅行程时间填写有误");
+                return 
+            }
+            if (!dateFormat.test(dateArray[1])) {
+                this.alertDia("差旅行程时间填写有误");
+                return 
+            }
+
+
+
+            traveDay = (Math.abs(Date.parse(dateArray[0]) - Date.parse(dateArray[1]))) / (1000 * 60 * 60 * 24) + 1;
+            if (!isNaN(traveDay)) {
+                this.traveDay = traveDay;
+                let alertDia = this.alertDia;
+                // 验证时间
+                $.ajax({
+                    type: "GET",
+                    url: "/json/trave/date/all",
+                    dataType: "json",
+                    processData: false,
+                    contentType: false,
+                }).success(function (sortList) {
+                    let item = new Array(new Date(Math.round(new Date(dateArray[0]).getTime() / 1000 - 28800)).getTime(), new Date(Math.round(new Date(dateArray[1]).getTime() / 1000 - 28800)).getTime());
+                    sortList.push(item);
+                    let TraveStatus = isTraveDate(sortList);
+                    if (TraveStatus == 2) {
+                        alertDia("差旅行程日期段-有重复");
+                    }
+                    // console.log(sortList);
+                    // sortList.forEach((element,index) => {
+                    //     const start = element[0];
+                    //     const end = element[1];
+                    //     itemIndex=index+1;
+                    //     if(sortList.length===itemIndex){
+                    //       return 
+                    //     }
+                    //     const isRangeStartAndEnd = sortList.some(item => {
+                    //       return (sortList[itemIndex][0]<=start&&sortList[itemIndex][1]>=start)||(sortList[itemIndex][0]<=end&&sortList[itemIndex][1]>=end)
+                    //     })
+                    //     if(isRangeStartAndEnd) {
+                    //       // 有重复区间
+                    //       alertDia("历史差旅行程时间段-有重复");
+                    //       flag = true;
+                    //       return ;
+                    //     } 
+                    // });
+
+
+                }).fail(function (msg) {
+                    alertDia("历史差旅时间获取失败");
+                });
+            }
+            // this.traveDay=new Date(dateArray[1]).getDate()-new Date(dateArray[0]).getDate()+1;
         },
         changeRegionLeve2: function (event, model) {
             this.regionOption.forEach(element => {
@@ -58,14 +118,26 @@ Vue.component("trave", {
                     if (model == "departureCity") {
                         this.regionLeve2Option = element.child;
                         this.departureCity = element.child[0].name;
+                        this.departureCityEdi = element.child[0].name;
+                        this.arrivalProvinceEdi = element.name;
+                        this.arrivalProvince = element.name;
+                        this.arrivalLeve2Option = element.child;
+                        this.arrivalCity = element.child[0].name;
+                        this.arrivalCityEdi = element.child[0].name;
                     } else if (model == "arrivalCity") {
                         this.arrivalLeve2Option = element.child;
                         this.arrivalCity = element.child[0].name;
+                        this.arrivalCityEdi = element.child[0].name;
+
                     }
                     return
                 }
             });
         },
+        changeArrivalCity: function (event) {
+            this.arrivalCity = event.target.value
+            this.arrivalCityEdi = event.target.value
+        },
         // 行程单相关
         // 打开行程单
         openTrip: function () {
@@ -200,11 +272,39 @@ Vue.component("trave", {
             this.arrivalList = [];
             $('#route-edi').modal('hide')
         },
-        addArrivalDom: function () {
+        addArrivalDom: function (option) {
+            // dom = {
+            //     "arrivalProvince": region[0].name,
+            //     "arrivalCity": region[0].child[0].name,
+            //     "arrivalCityOption": region[0].child,
+            // }
+            //1.没有目的地的时候
+
+            let arrivalProvince = this.departureProvince;
+            let arrivalCity = this.departureCity;
+            let childIndexValue = this.departureProvince;
+            if (option == "edi") {
+                arrivalProvince = this.departureProvinceEdi;
+                arrivalCity = this.departureCityEdi;
+                childIndexValue = this.departureProvinceEdi;
+            }
+
+            if (this.arrivalList.length !== 0) {
+                childIndexValue = this.arrivalList[this.arrivalList.length - 1].arrivalProvince
+                arrivalProvince = childIndexValue;
+                arrivalCity = this.arrivalList[this.arrivalList.length - 1].arrivalCity;
+            }
+            let index = 0;
+            region.forEach((element, i) => {
+                if (element.name === childIndexValue) {
+                    index = i;
+                    return;
+                }
+            });
             dom = {
-                "arrivalProvince": region[0].name,
-                "arrivalCity": region[0].child[0].name,
-                "arrivalCityOption": region[0].child,
+                "arrivalProvince": arrivalProvince,
+                "arrivalCity": arrivalCity,
+                "arrivalCityOption": region[index].child,
             }
             this.arrivalList.push(dom);
         },
@@ -372,7 +472,9 @@ Vue.component("trave", {
                     <tr>
                         <th>出发/结束日期</th>
                         <td><input class="datepicker-here span3" placeholder="按时间筛选" type="text" data-range="true"
-                                data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTimeEdi" ></td>
+                                data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTimeEdi" >
+                                &nbsp;&nbsp;旅程合计:<b class="colRed">{{ traveDay }}</b>天
+                        </td>
                     </tr>
                     <tr>
                         <th><span>┌</span> 出发地</th>
@@ -380,10 +482,10 @@ Vue.component("trave", {
                             <select v-model="departureProvinceEdi" @change="changeRegionLeve2($event,'departureCity')" >
                                     <option v-for="option in regionOption" :value="option.name" >{{option.name}}</option>
                             </select>
-                            <select v-model="departureCityEdi">
+                            <select v-model="departureCityEdi" @change="changeArrivalCity($event)">
                                 <option v-for="option in regionLeve2Option">{{option.name}}</option>
                             </select>
-                            <a href="javascript:void(0)" @click="addArrivalDom" >+添加目的地</a>
+                            <a href="javascript:void(0)" @click="addArrivalDom('edi')" >+添加目的地</a>
                         </td>
                     </tr>
 
@@ -437,7 +539,9 @@ Vue.component("trave", {
                     <tr>
                         <th>出发/结束日期</th>
                         <td><input class="datepicker-here span3" placeholder="按时间筛选" type="text" data-range="true"
-                                data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTime" ></td>
+                                data-multiple-dates-separator=" - " data-language="zh" @blur.prevent="changeCount" v-model="tripTime" >
+                            &nbsp;&nbsp;旅程合计:<b class="colRed">{{ traveDay }}</b>天        
+                        </td>
                     </tr>
                     <tr>
                         <th><span>┌</span> 出发地</th>
@@ -445,7 +549,7 @@ Vue.component("trave", {
                             <select v-model="departureProvince" @change="changeRegionLeve2($event,'departureCity')" >
                                     <option v-for="option in regionOption" :value="option.name" >{{option.name}}</option>
                             </select>
-                            <select v-model="departureCity">
+                            <select v-model="departureCity" @change="changeArrivalCity($event)">
                                 <option v-for="option in regionLeve2Option">{{option.name}}</option>
                             </select>
                             <a href="javascript:void(0)" @click="addArrivalDom" >+添加目的地</a>

+ 7 - 1
protected/class/comm_cld.php

@@ -59,9 +59,15 @@ function makeReceiptDataVersion1($receiptList){
 			$tripTotal=0;
 			$tripItem=array();
 			//1.行程list
+			
 			foreach ($value['tripList'] as $k=>$v){
 				//2.组合各个城市
-				$detailCity.=$v['city'].' ';
+				if(count($value['tripList'])==($k+1)){
+					$detailCity.=$v['city'];
+				}else{
+					$detailCity.=$v['city'].' - ';
+				}
+				
 				//3.组合列详情
 				foreach ($v['tripItem'] as $tk=>$tv){
 					if (!isset($tripItem[$tv['name']])){

+ 1 - 0
protected/config/acl.conf.php

@@ -391,6 +391,7 @@ $acl ['RECEIPTS'] ['allow'] = array (
 				'GetViewLoanReceiptCreate',
 				'PostLoanReceiptEdit',
 				'GetViewReceiptApproval',
+				'GetJsonTraveDateAll',
 		),
 		'ReceiptController' => array (
 				'saeaBorad',

+ 2 - 0
protected/config/routes_receipt.php

@@ -7,6 +7,8 @@ $route['get']['/view/loan/receipt/add/:receiptId'] = array('fee/fee_controller',
 $route['get']['/view/loan/receipt/edi/:receiptId'] = array('fee/fee_controller', 'GetViewLoanReceiptCreate','extension'=>'.html');
 $route['get']['/view/receipt/approval/:receiptId'] = array('fee/fee_controller', 'GetViewReceiptApproval','extension'=>'.html');
 
+$route['get']['/json/trave/date/all'] = array('fee/fee_controller', 'GetJsonTraveDateAll','extension'=>'.json');
+
 
 $route['post']['/receipt/create'] = array('fee/fee_controller', 'PostReceiptCreate');
 $route['post']['/receipt/edit'] = array('fee/fee_controller', 'PostReceiptEdit');

+ 2 - 2
protected/controller/InvoiceExtendController.php

@@ -348,9 +348,9 @@ class InvoiceExtendController extends DooController {
 		
 		$temporary = $invoiceQuantity * $invoiceUnitPrice;
 		if ($invoiceType == 1) {
-			if ($temporary > 10000) {
+			if ($temporary > 100000) {
 				header ( 'Content-Type:text/html;charset=utf-8' );
-				die ( '专用发票总金额暂时不能超过10000.00(一万)元。' );
+				die ( '专用发票总金额暂时不能超过100000.00(十万)元。' );
 				// die ( 'illegal request-Please priceError' );
 			}
 		}

+ 196 - 5
protected/controller/ReceiptController.php

@@ -159,7 +159,8 @@ class ReceiptController extends DooController {
 				$eidList = array_filter ( explode ( ",", $eidList ) );
 				
 				$this->executeId = array_merge ( $list2, $eidList );
-				//print_r($this->executeId);
+				
+				
 				$this->verifyId = $list;
 				$this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
 				
@@ -211,7 +212,7 @@ class ReceiptController extends DooController {
 		$receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
 		
 		$receiptDetail = $receipt->find ( array (
-				'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
+				'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8  and Rtype=1)',
 				'desc' => 'rid',
 				'asArray' => true 
 		) );
@@ -249,6 +250,7 @@ class ReceiptController extends DooController {
 		}
 		// print_r($receiptLogList);
 		
+		// 协助修改TODO,只显示未完成的
 		Doo::loadModel ( 'RAssist' );
 		$RAssist = new RAssist ();
 		$receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
@@ -5385,6 +5387,13 @@ class ReceiptController extends DooController {
 				$trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
 				$receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
 			}
+			
+			if($value['version']==1){
+				
+				$receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
+				
+			}
+			
 		}
 		
 		$reportList = array_unique ( $reportList );
@@ -7243,10 +7252,19 @@ class ReceiptController extends DooController {
 		if ($receiptList [0] ['Rtype'] == 0) {
 			$accountType = 3;
 		} elseif ($receiptList [0] ['Rtype'] == 1) {
-			if (!empty($receiptList [0]['accountItem']) )
+			if($receiptList [0]['version']==1){
+				$accountType = 2;
+			}else{
+				
+ 				if (!empty($receiptList [0]['accountItem']) ){
+// 				if (!empty($receiptList [0]['loanRid']) ){
 					$accountType = 2;
-				else
+				}else{
 					$accountType = 1;
+				}
+			}
+			
+					
 		} elseif ($receiptList [0] ['Rtype'] == 2) {
 			$accountType = 4;
 		} elseif ($receiptList [0] ['Rtype'] == 3) {
@@ -7258,8 +7276,11 @@ class ReceiptController extends DooController {
 		$data ['wbDetail'] = $wbDetail;
 		
 		$wbDetailLoan=array();
+		
 		if ($accountType==2){
 			$wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
+			
+			
 		}
 		$data ['wbDetailLoan'] = $wbDetailLoan;
 		
@@ -8390,6 +8411,13 @@ class ReceiptController extends DooController {
 				array_push ( $remittanceList, $remittanceDetail );
 				$staffBatchNumber ++;
 			}
+			
+			
+			if($value['version']==1){
+				$receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
+			}
+			
+			
 		}
 		
 		$data ['remittanceList'] = json_encode ( $remittanceList );
@@ -8823,8 +8851,26 @@ class ReceiptController extends DooController {
 				'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
 				'asArray' => true 
 		) );
-		if (empty ( $receiptDetailList ))
+		if (empty ( $receiptDetailList )){
 			return "/saeaBorad";
+		}
+			
+		// 如果是新报销单,有差旅的情况下写入日期
+		if($receiptDetailList['version']==1){
+			if(!empty($receiptDetailList['traveJson'])){
+				$traveJson=json_decode($receiptDetailList['traveJson'],true)['traveList'];
+				foreach ($traveJson as $key=>$value){
+					Doo::loadModel ( 'cld/traveDate_cld' );
+					$traveDate = new traveDate_cld ();
+					$traveDate->sid=$this->staff [0] ['sid'];
+					$traveDate->rid=$receiptDetailList['rid'];
+					$tripTime = explode(" - ", $value['tripTime']);
+					$traveDate->start=$tripTime[0];
+					$traveDate->end=$tripTime[1];
+					$traveDate->insert ();
+				}
+			}
+		}
 		
 		$verifyDetail = $verify->getOne ( array (
 				'where' => ' vid =' . $receiptDetailList ['verify'],
@@ -14458,13 +14504,146 @@ class ReceiptController extends DooController {
 		$detail ['verifyList'] = $verifyList;
 		return $detail;
 	}
+	
+	//获得新版报销单费用说明
+	private function getReceiptVerson1Explanation($value){
+		if($value['version']==1){
+			
+			$version_1_explanation="";
+			if(!empty($value['officeJson'])){
+				$officeJson=json_decode($value['officeJson'],true);
+				$version_1_explanation.=$officeJson['officeExplain'][0]['officeExplain']."\n";
+			}
+			if(!empty($value['traveJson'])){
+				$traveJson=json_decode($value['traveJson'],true);
+				$version_1_explanation.=$traveJson['traveExplain'][0]['traveExplain']."\n";
+			}
+			if(!empty($value['trainJson'])){
+				$trainJson=json_decode($value['trainJson'],true);
+				$version_1_explanation.=$trainJson['trainExplain'][0]['trainExplain']."\n";
+			}
+		}
+		return $version_1_explanation;
+	}
+	//获得新版报销单 详情HTML
+	private function getReceiptVerson1Html($detail){
+		$html='<table class="table table-bordered table-condensed">
+						<tbody>';
+		if($detail['version']==1){
+				
+			if(!empty($detail['officeJson'])){
+				$officeJson=json_decode($detail['officeJson'],true);
+				$html .= '
+					<tr>
+					<th colspan="2" class="taC">日常相关费用</th>
+				</tr>';
+				// 日常相关费用
+				$total=0;
+				foreach ( $officeJson['daily'] as $key => $value ) {
+					if(!empty($value['price'])){
+						$html .= '
+							<tr>
+								<th>' . $value ['name'] . '</th>
+								<td width="140" class="taR">¥' . $value ['price'] . '</td>
+							</tr>';
+						$total=bcadd($total,$value ['price'],2);
+					}
+				}
+				$html .= '
+				<tr>
+					<th class="taR">合计</th>
+					<td class="colGreen taR">¥' .$total . '</td>
+				</tr>';
+				// 其他
+				$html .= '<tr>
+					<th colspan="2" class="taC">其他</th>
+				</tr>';
+				$total=0;
+				foreach ( $officeJson['other'] as $key => $value ) {
+					if(!empty($value['price'])){
+						$html .= '
+							<tr>
+								<th>' . $value ['name'] . '</th>
+								<td width="140" class="taR">¥' . $value ['price'] . '</td>
+							</tr>';
+						$total=bcadd($total,$value ['price'],2);
+					}
+				}
+				$html .= '
+				<tr>
+					<th class="taR">合计</th>
+					<td class="colGreen taR">¥' . $total . '</td>
+				</tr>';
+			}
+			if(!empty($detail['traveJson'])){
+				$traveJson=json_decode($detail['traveJson'],true);
+				// 差旅
+				$html .= '<tr>
+					<th colspan="2" class="taC">差旅相关费用</th>
+				</tr>';
+				$total=0;
+				foreach ( $traveJson['trave'] as $key => $value ) {
+					if(!empty($value['price'])){
+						$html .= '
+							<tr>
+								<th>' . $value ['name'] . '</th>
+								<td width="140" class="taR">¥' . $value ['price'] . '</td>
+							</tr>';
+						$total=bcadd($total,$value ['price'],2);
+					}
+				}
+				$html .= '
+				<tr>
+					<th class="taR">合计</th>
+					<td class="colGreen taR">¥' . $total . '</td>
+				</tr>';
+			}
+			if(!empty($detail['trainJson'])){
+				$trainJson=json_decode($detail['trainJson'],true);
+				// 内部培训费用
+				$html .= '<tr>
+					<th colspan="2" class="taC">内部培训费用</th>
+				</tr>';
+				$total=0;
+				foreach ( $trainJson['train'] as $key => $value ) {
+					if(!empty($value['price'])){
+						$html .= '
+							<tr>
+								<th>' . $value ['name'] . '</th>
+								<td width="140" class="taR">¥' . $value ['price'] . '</td>
+							</tr>';
+						$total=bcadd($total,$value ['price'],2);
+					}
+				}
+				$html .= '
+				<tr>
+					<th class="taR">合计</th>
+					<td class="colGreen taR">¥' . $total . '</td>
+				</tr>';
+			}
+				
+		}
+		return $html;
+	}
+	
 	function getWasteReceiptHtml($detail = array(),$accountType=1) {
 		if (empty ( $detail ))
 			return '';
 		
 		$html = '';
+		
+		
+		
+		
+// 		die;
 		if ($detail ['Rtype'] == 0) { // 报销单
 			
+			if($detail ['version']==1){
+				$html .= $this->getReceiptVerson1Html($detail);
+			}else{
+				
+			
+			
 			$html .= '<table class="table table-bordered table-condensed">
 						<tbody>
 					<tr>
@@ -14536,6 +14715,9 @@ class ReceiptController extends DooController {
 					<td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
 				</tr>';
 			
+			}
+			
+			
 			$html .= '<tr>
 					<th colspan="2" class="taC">报销金额调整</th>
 				</tr>';
@@ -14646,6 +14828,12 @@ class ReceiptController extends DooController {
 				
 				$balance=$detail ['sum']-$loanList ['sum'];
 				$balanceCN=$this->num_to_rmb($balance);
+				
+				
+				if($detail ['version']==1){
+					$html .= $this->getReceiptVerson1Html($detail);
+				}else{
+					
 				$html .= '<table class="table table-bordered table-condensed">
 						<tbody>
 					<tr>
@@ -14717,6 +14905,9 @@ class ReceiptController extends DooController {
 					<td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
 				</tr>';
 				
+				}
+				
+				
 				$html .= '<tr>
 					<th colspan="2" class="taC">报销金额调整</th>
 				</tr>';

+ 15 - 3
protected/controller/ReceiptExtendController.php

@@ -2373,7 +2373,8 @@ class ReceiptExtendController extends DooController {
 				$accountType = 3;
 				$expensesType='EXPENDITURE';
 			} elseif ($rinfo ['Rtype'] == 1) {
-				if (! empty ( $rinfo ['accountItem'] )){
+				
+				if($rinfo ['version'] == 1){
 					$accountType = 2;
 					if ($amount>=0){
 						$expensesType='EXPENDITURE';
@@ -2381,9 +2382,20 @@ class ReceiptExtendController extends DooController {
 						$expensesType='INCOME';
 					}
 				}else{
-					$accountType = 1;
-					$expensesType='EXPENDITURE';
+					if (! empty ( $rinfo ['accountItem'] )){
+						$accountType = 2;
+						if ($amount>=0){
+							$expensesType='EXPENDITURE';
+						}else{
+							$expensesType='INCOME';
+						}
+					}else{
+						$accountType = 1;
+						$expensesType='EXPENDITURE';
+					}
 				}
+				
+				
 			} elseif ($rinfo ['Rtype'] == 2) {
 				$accountType = 4;
 				$expensesType='EXPENDITURE';

+ 75 - 0
protected/controller/fee/fee_controller.php

@@ -155,6 +155,30 @@ class fee_controller extends DooController {
 		$data ['office'] = $this->officeService->GetAll ();
 		// 默认办事处
 		$data ['officeId'] = $this->staff ['cid'];
+		
+		//设置默认差旅地区
+		$traveDefault=$this->makeTraveDefault($region);
+		$data['defaultTraveProvince']=$traveDefault['defaultTraveProvince'];
+		$data['defaultTraveProvinceIndex']=$traveDefault['defaultTraveProvinceIndex'];
+		
+// 		$defaultTraveProvince="";
+// 		if($this->staff['category']=="总部"){
+// 			$defaultTraveProvince="广东省";
+// 		}else{
+// 			$defaultTraveProvince=str_replace("办","省",$this->staff['category']);
+// 		}
+// 		$data['defaultTraveProvince']=$defaultTraveProvince;
+		
+// 		// 获得二级地区的index
+// 		$defaultTraveProvinceIndex=0;
+// 		foreach ($region as $key=>$value){
+// 			if($value['name']==$defaultTraveProvince){
+// 				$defaultTraveProvinceIndex=$key;
+// 			}
+// 		}
+// 		$data['defaultTraveProvinceIndex']=$defaultTraveProvinceIndex;
+		
+		
 		// 附件
 		$data ['enclosurList'] = array ();
 		
@@ -200,6 +224,11 @@ class fee_controller extends DooController {
 		$data ['officeId'] = $detail ['cid'];
 		$data ['receiptId'] = $detail ['receiptId'];
 		
+		//设置默认差旅地区
+		$traveDefault=$this->makeTraveDefault($region);
+		$data['defaultTraveProvince']=$traveDefault['defaultTraveProvince'];
+		$data['defaultTraveProvinceIndex']=$traveDefault['defaultTraveProvinceIndex'];
+		
 		$data ['staff'] = $this->staff;
 		$data ['verifyId'] = $this->verifyId;
 		$data ['executeId'] = $this->executeId;
@@ -301,6 +330,27 @@ class fee_controller extends DooController {
 		// 请求
 		$data ['action'] = "/loan/receipt/edit";
 		
+		$traveDefault=$this->makeTraveDefault($region);
+		$data['defaultTraveProvince']=$traveDefault['defaultTraveProvince'];
+		$data['defaultTraveProvinceIndex']=$traveDefault['defaultTraveProvinceIndex'];
+// 		$defaultTraveProvince="";
+// 		if($this->staff['category']=="总部"){
+// 			$defaultTraveProvince="广东省";
+// 		}else{
+// 			$defaultTraveProvince=str_replace("办","省",$this->staff['category']);
+// 		}
+// 		$data['defaultTraveProvince']=$defaultTraveProvince;
+		
+		// 获得二级地区的index
+// 		$defaultTraveProvinceIndex=0;
+// 		foreach ($region as $key=>$value){
+// 			if($value['name']==$defaultTraveProvince){
+// 				$defaultTraveProvinceIndex=$key;
+// 			}
+// 		}
+// 		$data['defaultTraveProvinceIndex']=$defaultTraveProvinceIndex;
+		
+		
 		$data ['staff'] = $this->staff;
 		$data ['verifyId'] = $this->verifyId;
 		$data ['executeId'] = $this->executeId;
@@ -375,6 +425,31 @@ class fee_controller extends DooController {
 		
 	}
 	
+	// 获得个人所有的差旅时间
+	public function GetJsonTraveDateAll(){
+		$traveData=$this->feeService->GetTraveDateAll($this->staff['sid']);
+		echo json_encode($traveData);
+	}
+	
+	private function makeTraveDefault($region){
+		$defaultTraveProvince="";
+		if($this->staff['category']=="总部"||$this->staff['category']=="总部1"){
+			$defaultTraveProvince="广东省";
+		}else{
+			$defaultTraveProvince=str_replace("办","省",$this->staff['category']);
+		}
+		
+		// 获得二级地区的index
+		$defaultTraveProvinceIndex=0;
+		foreach ($region as $key=>$value){
+			if($value['name']==$defaultTraveProvince){
+				$defaultTraveProvinceIndex=$key;
+			}
+		}
+		
+		return array("defaultTraveProvince"=>$defaultTraveProvince,"defaultTraveProvinceIndex"=>$defaultTraveProvinceIndex);
+	}
+	
 	// 构造页面数据
 	private function makeReceiptEdiData($data, $accountItem, $verify) {
 		$officeJson = array (

+ 33 - 0
protected/model/cld/traveDate_cld.php

@@ -0,0 +1,33 @@
+<?php
+Doo::loadCore ( 'db/DooModel' );
+class traveDate_cld extends DooModel {
+	public $id;
+	public $sid;
+	public $rid;
+	public $start;
+	public $end;
+	public $_table = 'CLD_traveDate';
+	public $_primarykey = 'id';
+	public $_fields = array (
+			'id',
+			'sid',
+			'rid',
+			'start',
+			'end' 
+	);
+	
+	// 获得员工信息
+	public function GetAllBySid($sid) {
+		$result = $this->find ( array (
+				'where' => "sid = ? ",
+				'param' => array (
+						$sid 
+				),
+				'asArray' => TRUE 
+		) );
+		
+		return $result;
+	}
+}
+
+?>

+ 1 - 0
protected/model/invoice.php

@@ -767,6 +767,7 @@ class invoice extends DooModel {
 			array_push($result, $this->_SumRecelvables($value));
 			
 		}
+		//print_r($result);
 		return $result;
 		
 	}

+ 2 - 1
protected/model/invoiceTraining.php

@@ -197,6 +197,7 @@ class invoiceTraining extends DooModel {
 			
 			// 1.所有培训班发票 收款合计
 			$invoiceRecelvablesList = $invoice->InvoiceTrainIncomesPrice($itid);
+			//print_r($invoiceRecelvablesList);
 			//$invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidSql );
 			
 			// 收款有多个发票绑定,导致收款金额没有统计--TODO
@@ -238,7 +239,7 @@ class invoiceTraining extends DooModel {
 					$list [$key] ['invoiceArriveAmount'] = $o ['receivablesPrice'];
 					$list [$key] ['arriveSchedule'] = "0";
 					if ($value ['invoiceTotal'] != 0) {
-						$list [$key] ['invoiceArriveAmount']+=$itidSum[$value ['itid']];
+						//$list [$key] ['invoiceArriveAmount']+=$itidSum[$value ['itid']];
 						$list [$key] ['arriveSchedule'] = round ( $list [$key] ['invoiceArriveAmount'] / $list [$key] ['invoiceTotalAmount'] * 100, 2 );
 						// $list [$key] ['arriveSchedule'] = round ( $o ['count'] / $value ['invoiceTotal'] * 100, 2 );
 					}

+ 1 - 2
protected/plugin/TemplateTag.php

@@ -529,11 +529,10 @@ function getExeCount() {
 	$XDeode = new XDeode ( 5 );
 	$st[0]['sid'] = $XDeode->decode ( $_COOKIE["staff"] );
 	$receiptList = $receipt->find ( array (
-			'where' => '(executeCopy like \'%["' . $st[0]['sid'] . '%\' and executeStaff NOT LIKE \'%' . $st[0]['sid'] . '%\' ) and (status=1 or status=6)',
+			'where' => '(executeCopy like \'%["' . $st[0]['sid'] . '%\' and ( executeStaff NOT LIKE \'%' . $st[0]['sid'] . '%\' or executeStaff is null ) ) and (status=1 or status=6)',
 			'desc' => 'rid',
 			'asArray' => true 
 	) );
-	
 	$GLOBALS ['NEW2'] = count ( $receiptList );
 }
 

+ 15 - 0
protected/services/fee_service.php

@@ -17,6 +17,8 @@ class fee_service {
 		Doo::loadModel ( 'receiptDetail' );
 		Doo::loadModel ( 'cld/category_cld' );
 		$this->category = new category_cld ();
+		Doo::loadModel ( 'cld/traveDate_cld' );
+		$this->traveDate_cld = new traveDate_cld ();
 	}
 	
 	// 费用 报销单-创建-参数校验
@@ -339,6 +341,19 @@ class fee_service {
 		return $loan;
 	}
 	
+	// 获得差旅日期
+	public function GetTraveDateAll($sid){
+		$traveData=$this->traveDate_cld->GetAllBySid($sid);
+		$data=array();
+		
+		foreach ($traveData as $key=>$value){
+			if(!empty($value['start'])&&!empty($value['end'])){
+				array_push($data, array(strtotime($value['start']),strtotime($value['end'])));
+			}
+		}
+		return $data;
+	}
+	
 	// 获得审批流程
 	private function makeVerifyProcess($verifyId, $verifyStaff) {
 		// 检测编辑状态

+ 7 - 1
protected/view/admin/approvalExpenses.html

@@ -134,7 +134,13 @@
 	  							</td>
 	  							<td>{{receiptDetail' value.category}}</td>
 	  							<td>{{receiptDetail' value.receiptOrder}}<p class="colGray">{{receiptDetail' value.date}}</p></td>
-	  							<td>{{receiptDetail' value.explanation}}</td>
+	  							<td>
+<!-- if {{receiptList' value.version}}==1 -->
+							<pre>{{receiptList' value.version_1_explanation}}</pre>
+							<!-- else -->
+							{{receiptList' value.explanation}}
+							<!-- endif -->
+								</td>
 	  							<td>
 	  							<!-- if {{receiptDetail' value.status}}==2 --> 
 	  							审批中

+ 14 - 2
protected/view/admin/hisImplement.html

@@ -121,7 +121,13 @@
 							
 							<td>{{receiptList' value.category}}</td>
 							<td>{{receiptList' value.receiptOrder}}<p class="colGray">{{receiptDetail' value.date}}</p></td>
-							<td>{{receiptList' value.explanation}}</td>
+							<td>
+							<!-- if {{receiptList' value.version}}==1 -->
+							<pre>{{receiptList' value.version_1_explanation}}</pre>
+							<!-- else -->
+							{{receiptList' value.explanation}}
+							<!-- endif -->
+							</td>
 							<td>
 							<!-- if {{receiptList' value.status}}==1 -->
 								执行中
@@ -210,7 +216,13 @@
 							
 							<td>{{receiptList' value.category}}</td>
 							<td>{{receiptList' value.receiptOrder}}<p class="colGray">{{receiptDetail' value.date}}</p></td>
-							<td>{{receiptList' value.explanation}}</td>
+							<td>
+<!-- if {{receiptList' value.version}}==1 -->
+							<pre>{{receiptList' value.version_1_explanation}}</pre>
+							<!-- else -->
+							{{receiptList' value.explanation}}
+							<!-- endif -->
+</td>
 							<td>
 							<!-- if {{receiptList' value.status}}==1 -->
 								执行中

+ 1 - 1
protected/view/expenses/wasteBookExpenditure.html

@@ -144,7 +144,7 @@
 											<td><a href="/receiptTrain/info/{{expenditureList' value.data.ridKey7}}.html" data-toggle="modal">{{expenditureList' value.data.receiptOrder}}</a></td>
 			
 											<!-- else -->
-											<td><a href="#saea-detail1" node-receipt=waste data-key="{{expenditureList' value.data.ridKey}}" data-toggle="modal">{{expenditureList' value.data.receiptOrder}}</a></td>
+											<td><a href="#saea-detail1" node-receipt=waste data-key="{{expenditureList' value.data.ridKey}}" data-accountTypeKey="{{expenditureList' value.accountTypeKey}}" data-toggle="modal">{{expenditureList' value.data.receiptOrder}}</a></td>
 											<!-- endif -->
 											<td>{{expenditureList' value.category}}-{{expenditureList' value.name}}</td>
 										</tr>

+ 1 - 1
protected/view/expenses/wasteBookIncome.html

@@ -143,7 +143,7 @@
 											<!-- elseif {{expenditureList' value.accountType}}==12 -->
 											<td><a href="/receiptTrain/info/{{expenditureList' value.data.ridKey7}}.html" data-toggle="modal">{{expenditureList' value.data.receiptOrder}}</a></td>
 			<!-- elseif {{expenditureList' value.accountType}}==1||{{expenditureList' value.accountType}}==2||{{expenditureList' value.accountType}}==3||{{expenditureList' value.accountType}}==4 -->
-											<td><a href="#saea-detail1" node-receipt=waste data-key="{{expenditureList' value.data.ridKey}}" data-toggle="modal">{{expenditureList' value.data.receiptOrder}}</a></td>
+											<td><a href="#saea-detail1" node-receipt=waste data-key="{{expenditureList' value.data.ridKey}}" data-accountTypeKey="{{expenditureList' value.accountTypeKey}}" data-toggle="modal">{{expenditureList' value.data.receiptOrder}}</a></td>
 											
 											<!-- endif -->
 											<td>{{expenditureList' value.category}}-{{expenditureList' value.name}}</td>

+ 2 - 0
protected/view/fee/create/receipt.html

@@ -334,6 +334,8 @@
 			let accountItem = JSON.parse('{{accountItem}}');
 			let region = JSON.parse('{{region}}');
 			let verify = JSON.parse(`{{verify}}`);
+			let defaultTraveProvince='{{defaultTraveProvince}}';
+			let defaultTraveProvinceIndex='{{defaultTraveProvinceIndex}}';
 		</script>
 		<!-- if {{action}}=='/receipt/edit'||{{action}}=='/loan/receipt/edit' -->
 		<script type="text/javascript">

+ 2 - 1
protected/view/fee/implement/loan_compatible.html

@@ -96,8 +96,9 @@ $(function(){
 	  						</tbody>
 	  					</table>
 	  					
+	  					<p class="taC" style="margin-bottom: 20px" id="open">借款费用详情已收起 <a href="javascript:$('#loanTable').toggle();" >点击</a></p>
 	  					
-	  					<table class="table table-bordered table-condensed table-hover">
+	  					<table class="table table-bordered table-condensed table-hover hide" id="loanTable">
 							<tbody>
 							
 							<tr><td colspan="2">费用审批完成:{{receiptList' value.pastDate}}</td></tr>

+ 3 - 2
protected/view/receipt/receiptFee.html

@@ -23,7 +23,8 @@
 						<div class="borad-menu">
 							<a href="/saeaLoanAdd" class="loan">申请借款</a>
 							<!-- <a href="/saeaCreate" class="receipt">申请报销</a>  --> 
-							<a href="#receipt-add" data-toggle="modal" class="receipt">申请报销</a>
+							<!--  <a href="#receipt-add" data-toggle="modal" class="receipt">申请报销</a>   -->
+							<a href="/view/receipt/create" data-toggle="modal" class="receipt">申请报销</a>
 							<a href="/receiptTrainAdd" class="train">培训班结算</a>
 							<a href="/remitAdd" class="public">申请对公汇款</a>
 						</div>
@@ -87,7 +88,7 @@
 										
 											<!-- if {{receiptDetail' value.Rtype}}==1 and {{receiptDetail' value.status}}==8  -->
 											<a class="button btn-block" href="/view/loan/receipt/add/{{receiptDetail' value.receiptId}}.html">填写费用报销</a><br/>
-											 <a class="button btn-block" href="/saeaLoanReceiptAdd/{{receiptDetail' value.rid}}">填写费用报销</a> 
+											 <!-- <a class="button btn-block" href="/saeaLoanReceiptAdd/{{receiptDetail' value.rid}}">填写费用报销</a>  -->
 											<!-- elseif  ({{receiptDetail' value.status}}==4 or {{receiptDetail' value.status}}==5) and {{receiptDetail' value.Rtype}}==1 and {{receiptDetail' value.isBK}}==0 -->
 											
 											<a class="button btn-gray  btn-inline" href="/saeaLoanEdi/{{receiptDetail' value.ridKey}}.html">返回编辑</a>