【调度系统】广东民航医疗快线调度系统源代码
wanglizhong
2025-06-16 ae5b0a8c63979351028215b8fe8cdf4b0766c272
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
<?php require '/inc/odbc.php';?>
<?php require '/inc/function.php';?>
<?php 
if(isDepartment("0302")==0){
  header("Location: /"); 
  exit;
}
 
$searchTXT=empty($_REQUEST['searchTXT'])==true ? "" : addslashes($_REQUEST['searchTXT']);
$orderby=empty($_REQUEST['orderby'])==true ? "" : addslashes($_REQUEST['orderby']);
$OrdDateType=empty($_REQUEST['OrdDateType'])==true ? "7" : addslashes($_REQUEST['OrdDateType']);
$OrdDateStart=empty($_REQUEST['OrdDateStart'])==true ? "" : addslashes($_REQUEST['OrdDateStart']);
$OrdDateEnd=empty($_REQUEST['OrdDateEnd'])==true ? "" : addslashes($_REQUEST['OrdDateEnd']);
$AuditStatus=empty($_REQUEST['AuditStatus'])==true ? "0" : addslashes($_REQUEST['AuditStatus']);
 
$InvoiceType=empty($_REQUEST['InvoiceType'])==true ? "0" : addslashes($_REQUEST['InvoiceType']);
$page=empty($_REQUEST['page'])==true ? 1 : $_REQUEST['page']; //当前页数
 
$OrdDateTypeName="";
if ($OrdDateType=="-1") {
    if ($OrdDateStart=="" and $OrdDateEnd=="") {
        $OrdDateStart=date("Y-m-d");
        $OrdDateEnd=date("Y-m-d");
    }
    elseif ($OrdDateStart!="" and $OrdDateEnd=="") {
        $OrdDateEnd=$OrdDateStart;
    }
    elseif ($OrdDateStart=="" and $OrdDateEnd!="") {
        $OrdDateStart=$OrdDateEnd;
    }
    If ($OrdDateStart>$OrdDateEnd) {
        $OrdDateStart1=$OrdDateStart;
        $OrdDateStart=$OrdDateEnd;
        $OrdDateEnd=$OrdDateStart1;
    }
    If ($OrdDateStart==$OrdDateEnd) {
        $OrdDateTypeName=$OrdDateStart;
        $OrdDateTypeName1=$OrdDateTypeName;
    }
    Else {
        $OrdDateTypeName=$OrdDateStart." 至 ".$OrdDateEnd;
        $OrdDateTypeName1="时间段 ".$OrdDateTypeName;
    }
    $SqlOrdDateType=" between '".$OrdDateStart."' and '".$OrdDateEnd." 23:59:59'";
}Else {
    $sql = "select top 1 vID,vtext,vOrder2 from dictionary where vType>=1 and vtitle='OrdDateType' and vID=".$OrdDateType ;
    $data = sqlsrv_query($conn,$sql);
    if($data == true){
        if (sqlsrv_rows_affected($data)!=0) {
            while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
                $OrdDateTypeName    = $rs['vtext'];
                $OrdDateTypeName1    = $OrdDateTypeName;
                $SqlOrdDateType    = $rs['vOrder2'];
            }
        } else {
            $OrdDateType="4";
            $OrdDateTypeName="本月";
            $OrdDateTypeName1=$OrdDateTypeName;
            $SqlOrdDateType="between DATEADD(mm,DATEDIFF(mm,0,getdate()),0) and dateadd(ms,-3,DATEADD(mm,DATEDIFF(m,0,getdate())+1,0))";
 
        }
    }
    
}
 
//各种返回信息
$SystemMessageTXT="";
$SystemMessageType=empty($_REQUEST['SystemMessageType'])==true ? "" : $_REQUEST['SystemMessageType'];
$SMT=empty($_REQUEST['SMT'])==true ? "" : $_REQUEST['SMT'];
if ($SystemMessageType!="") {
    if ($SMT=="1") {
        $SystemMessageTXT="保存成功";
    }elseif ($SMT=="2") {
        $SystemMessageTXT="参数错误";
    }
}
 
//时间段列表
$OrdDateTypes=array();
$sql = "select vID,vtext from dictionary where vType>=1 and vtitle='OrdDateType' order by vOrder" ;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $i=0;
    while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
        $OrdDateTypes[$i]=array($rs['vID'],$rs['vtext']);
        $i++;
    }
}
 
//发票处理状态
$AuditStatusName="全部";
$AuditStatusArray=array();
$AuditStatusArray[0]=array(-1,"全部");
$sql = "select vID,vtext from dictionary where vType>=1 and vtitle='AuditStatus' order by vOrder" ;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $i=1;
    while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
        $AuditStatusArray[$i]=array($rs['vID'],$rs['vtext']);
        if (strval($rs['vID'])==$AuditStatus){$AuditStatusName = $rs['vtext'];}
        $i++;
    }
}
 
//分公司名称列表
$UnitNameListArray=array();
$sql = "select ServiceBranch,case when UnitShort='微信小程序' then '广州' else UnitShort END as UnitShort from IntroducerUnitData where ServiceBranch<>'' and UnitID<>32" ;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $i=1;
    while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
        $UnitNameListArray[$i]=array($rs['ServiceBranch'],$rs['UnitShort']);
        $i++;
    }
}
 
//默认显示字段
$Report_Name    = "发票管理";
 
$page_URL_noDate="h_menu1_1=2&searchTXT=".$searchTXT."&orderby=".$orderby."&InvoiceType=".$InvoiceType."&AuditStatus=".$AuditStatus."&OrdDateType=".$OrdDateType."&OrdDateStart=".$OrdDateStart."&OrdDateEnd=".$OrdDateEnd;
$page_URL="h_menu1_1=2&searchTXT=".$searchTXT."&orderby=".$orderby."&InvoiceType=".$InvoiceType."&AuditStatus=".$AuditStatus."&OrdDateType=".$OrdDateType."&OrdDateStart=".$OrdDateStart."&OrdDateEnd=".$OrdDateEnd;
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title><?php echo $LindemanAdmin?></title>
        <?php require '/inc/ccs.php';?>
        <!-- DataTables -->
        <link rel="stylesheet" type="text/css" href="/js/media/css/jquery.dataTables.css">
        <script type="text/javascript" charset="utf8" src="/js/media/js/jquery.js"></script>
        <script type="text/javascript" charset="utf8" src="/js/media/js/jquery.dataTables.js"></script>
        <style type="text/css">
        #content div.box table td {
            border-right: 1px solid #cdcdcd;
            text-align: center;
        }
        </style>
    </head>
    <body onkeydown="xKeyEvent(event)">
        <?php require 'menu_header.php';?>
        <!-- content -->
        <div id="content">
            <?php require 'Dispatch_menu_left.php';?>
            <!-- content / right -->
            <div id="right">
                <!-- table -->
                <div class="box">
                    <!-- box / title -->
                    <div class="title">
                        <h5><?php if($searchTXT!=""){echo $Report_Name." ".$searchTXT;} else {echo $Report_Name;} ?></h5>
                        <ul class="links">
                            <li><a onclick="javascript:JS_CarGasAdd();">新建</a></li>
                            <li><a href="Invoice_List_Excel.php?<?php echo $page_URL;?>">导出</a></li>
                            <li>
                                <?php
                                //下拉菜单设定
                                $DownMenuName="处理状态";        //菜单名称
                                $DownMenuNameID="AuditStatus";    //菜单ID
                                $DownMenuArray=$AuditStatusArray;    //菜单数组
                                $DownMenuOldName=$AuditStatusName;    //默认值名称
                                $DownMenuOldID=$AuditStatus    //默认值ID
                                ?>
                                <div class="search">
                                <div name="DownMenu_container" id="<?php echo $DownMenuNameID?>_container" class="select-container" style="overflow: hidden;cursor:pointer" onclick="JS_DownMenu('<?php echo $DownMenuNameID?>')">
                                    <span class="select-content" style="width: 46px;"><?php echo $DownMenuName.":".$DownMenuOldName?></span><span class="arrow" id="<?php echo $DownMenuNameID?>_arrow" name="DownMenu_arrow"></span>
                                </div>
                                <div name="DownMenu_list" id="<?php echo $DownMenuNameID?>_list" class="select-list scroll-pane" style="overflow: hidden; position: absolute; background-color: white; width: 90px; display: none;background-position: initial initial; background-repeat: initial initial;margin-left: 69px;">
                                    <div class="jspContainer" style="width: 90px;">
                                        <div style="padding: 0px; top: 0px; width: 90px;">
                                        <?php for($i=0;$i<count($DownMenuArray);$i++) {?>
                                          <span title="<?php echo $DownMenuArray[$i][1]?>" name="DownMenu_<?php echo $DownMenuNameID?>" onmouseover="JS_DownMenuMouseover('<?php echo $DownMenuNameID?>',<?php echo $i?>)" onclick="JS_DownMenuJump('<?php echo "?".$page_URL?>','<?php echo $DownMenuOldID?>','<?php echo $DownMenuNameID?>','<?php echo $DownMenuArray[$i][0]?>')" class="list-option<?php if ($DownMenuArray[$i][0]==$DownMenuOldID){echo " option";}?>"><?php echo $DownMenuArray[$i][1]?></span>
                                        <?php }?>
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </li>
                            <li>
                                <div class="search">
                                <div id="Date_container" class="select-container" style="overflow: hidden;cursor:pointer" onclick="JS_OrdDateType()">
                                    <span class="select-content" style="width: 46px;">期间:<?php echo $OrdDateTypeName?></span><span class="arrow" id="Date_arrow"></span>
                                </div>
                                <div id="Date_list" class="select-list scroll-pane" style="overflow: hidden; position: absolute; background-color: white; width: 65px; display: none;background-position: initial initial; background-repeat: initial initial;margin-left: 35px;">
                                    <div class="jspContainer" style="width: 63px;">
                                        <div style="padding: 0px; top: 0px; width: 63px;">
                                        <?php for($i=0;$i<count($OrdDateTypes);$i++) {?>
                                          <span title="<?php echo $OrdDateTypes[$i][1]?>" onmouseover="JS_OrdDateTypeMouseover('OrdDateType_<?php echo $OrdDateTypes[$i][0]?>')" onclick="JS_OrdDateTypeJump('<?php echo $OrdDateTypes[$i][0]?>')" id="OrdDateType_<?php echo $OrdDateTypes[$i][0]?>" class="list-option<?php if ($OrdDateTypes[$i][0]==$OrdDateType){echo " option";}?>"><?php echo $OrdDateTypes[$i][1]?></span>
                                        <?php }?>
                                        <span title="自定义" onmouseover="JS_OrdDateTypeMouseover('OrdDateType_0')" onclick="JS_OrdDateTypeCreateOpen()" id="OrdDateType_0" name="OrdDateType" class="list-option">自定义</span>
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </li>
                    <div class="dialogJ  dialogJfix dialogJshadow" id="OrdDateTypeCreate" style="width: 440px;right: 80px; top: 150px;height:80px ;display:none;z-index: 100;">
                        <div class="dialogJtitle">
                            <a href="javascript:JS_OrdDateTypeCreateClose();" class="dialogJclose" title="关闭本窗口">&nbsp;</a>
                            <span class="dialogJtxt" id="EditPhotoTXT">请选择时间段</span>
                        </div>
                        <div class="dialogJcontent" style="margin-left: 5px;margin-right:5px;">
                            <div class="input" style="float:left;margin-top: 10px;margin-left: 5px;" id="two-inputs">
                                期间:
                                <input type="text" id="OrdDateStart" name="OrdDateStart" class="date" style="width:138px;" value="<?php echo $OrdDateStart?>">
                                至
                                <input type="text" id="OrdDateEnd" name="OrdDateEnd" class="date" style="width:138px;" value="<?php echo $OrdDateEnd?>">
                                <input type="button" class="dialogJbtn first-child" onclick="JS_OrdDateJump()" value="查询">
                            </div>
                        </div>
                    </div>
                    <!--时间选择js  liang------------->
                    <link rel="stylesheet" href="css/daterangepicker.css">
                    <script src="js/moment.min.js"></script>
                    <script src="js/jquery.daterangepicker.js"></script>
                    <script>
                            $(function()
                        {
                            $('#two-inputs').dateRangePicker(
                            {
                                separator : ' to ',
                                getValue: function()
                                {
                                    if ($('#OrdDateStart').val() && $('#OrdDateEnd').val() )
                                        return $('#OrdDateStart').val() + ' to ' + $('#OrdDateEnd').val();
                                    else
                                        return '';
                                },
                                setValue: function(s,s1,s2)
                                {
                                    $('#OrdDateStart').val(s1);
                                    $('#OrdDateEnd').val(s2);
                                }
 
                            });
                        });
                    </script>
                <!--时间选择js  liang------------->
                    <script type="text/javascript">
                        //时间表列显示下拉菜单
                        function JS_OrdDateType(){
                          if (Date_container.className!="select-container select-container-show-list"){
                            Date_container.className="select-container select-container-show-list";
                            Date_arrow.className="arrow arrow-up";
                            Date_list.style.display="block";
                            OrdClass_container.className="select-container";
                            OrdClass_arrow.className="arrow";
                            OrdClass_list.style.display="none";
                            OrdDateTypeCreate.style.display="none";
                          }
                          else {
                            Date_container.className="select-container";
                            Date_arrow.className="arrow";
                            Date_list.style.display="none";
                          }
                        }
                        //时间表列指针移动到下拉菜单
                        function JS_OrdDateTypeMouseover(id){
                          var d=document.getElementById(id);
                          <?php for($i=0;$i<count($OrdDateTypes);$i++) {?>
                          document.getElementById("OrdDateType_<?php echo $OrdDateTypes[$i][0]?>").className="list-option";
                          <?php }?>
                          document.getElementById("OrdDateType_0").className="list-option";
                          d.className="list-option option";
                        }
                        //自定义时间-打开窗口
                        function JS_OrdDateTypeCreateOpen()
                        {
                            JS_OrdDateType();
                            OrdDateTypeCreate.style.display="block";
                        }
                        //自定义时间-关闭窗口
                        function JS_OrdDateTypeCreateClose()
                        {
                            JS_OrdDateType();
                            OrdDateTypeCreate.style.display="none";
                        }
                        //自定义时间-确定时间
                        function JS_OrdDateTypeCreateSave()
                        {
                        document.getElementById('ServiceOrdTraStreet').value=document.getElementById('Duration').value;
                        document.getElementById('ServiceOrdTraEnd').value=document.getElementById('ServiceOrdTraEnd').value;
                        document.getElementById('ServiceOrdTraStreetCoo').value=results.sw.point.lng + ','+ results.sw.point.lat; //起点坐标
                        document.getElementById('ServiceOrdTraEndCoo').value=results.Lu.point.lng + ','+ results.Lu.point.lat; //起点坐标
                        }
                        //时间类表列转跳
                        function JS_OrdDateJump(id){
                            var OrdDateStart=document.getElementById("OrdDateStart").value;
                            var OrdDateEnd=document.getElementById("OrdDateEnd").value;
                            //var searchTXT=document.getElementById("searchTXT").value;
                            window.location.href='Invoice_List.php?<?php echo $page_URL_noDate?>&OrdDateType=-1&OrdDateStart='+OrdDateStart+'&OrdDateEnd='+OrdDateEnd;
                        }
                        //自定义时间转跳
                        function JS_OrdDateTypeJump(id){
                            //var searchTXT=document.getElementById("searchTXT").value;
                            window.location.href='Invoice_List.php?<?php echo $page_URL_noDate?>&OrdDateType='+id;
                        }
 
                        //时间表列转跳
                        function JS_OrdClassTypeJump(id){
                            //var searchTXT=document.getElementById("searchTXT").value;
                            window.location.href='Invoice_List.php?<?php echo $page_URL_noDate?>&OrdClassList='+id;
                        }
                        
                    </script>
                    <script LANGUAGE="javascript">
 
                        //新建字典-关闭上传窗口
                        function JS_CarCreateClose()
                        {
                        CarCreate.style.display="none";
                        }
                        function JS_InvoiceType(){
                            InvoiceType = document.form2.InvoiceType.value;
                            if(InvoiceType=='2') {
                                InvoiceCompanyAddDiv.style.display="none";
                                InvoiceCompanyBankDiv.style.display="none";
                                Invoice_strAddDiv.style.display="none";
                                InvoiceOddNoDiv.style.display="none";
                                InvoiceURLDiv.style.display="block";
                                Invoice_strEmailDiv.style.display="block";
                                Invoice_strNameTXT.innerHTML="接收人<font color='#ff0000'>*</font>:";
                                Invoice_strPhoneTXT.innerHTML="接收短信电话<font color='#ff0000'>*</font>:";
                            }else if (InvoiceType=='3') {
                                InvoiceCompanyAddDiv.style.display="none";
                                InvoiceCompanyBankDiv.style.display="none";
                                Invoice_strAddDiv.style.display="block";
                                InvoiceOddNoDiv.style.display="block";
                                InvoiceURLDiv.style.display="none";
                                Invoice_strEmailDiv.style.display="none";
                                Invoice_strNameTXT.innerHTML="收件人<font color='#ff0000'>*</font>:";
                                Invoice_strPhoneTXT.innerHTML="收件人电话<font color='#ff0000'>*</font>:";
                            }else if (InvoiceType=='4') {
                                InvoiceCompanyAddDiv.style.display="block";
                                InvoiceCompanyBankDiv.style.display="block";
                                Invoice_strAddDiv.style.display="block";
                                InvoiceOddNoDiv.style.display="block";
                                InvoiceURLDiv.style.display="none";
                                Invoice_strEmailDiv.style.display="none";
                                Invoice_strNameTXT.innerHTML="收件人<font color='#ff0000'>*</font>:";
                                Invoice_strPhoneTXT.innerHTML="收件人电话<font color='#ff0000'>*</font>:";
                            }
                        }
                        //新建字典-保存
                        function JS_CarCreateSave()
                        {
                            InvoiceType=document.form2.InvoiceType.value;
                            InvoiceMoney=document.form2.InvoiceMoney.value;
                            InvoiceName=document.form2.InvoiceName.value;
                            InvoiceCompanyID=document.form2.InvoiceCompanyID.value;
                            Invoice_strAdd=document.form2.Invoice_strAdd.value;
                            Invoice_strName=document.form2.Invoice_strName.value;
                            Invoice_strPhone=document.form2.Invoice_strPhone.value;
                            Invoice_strEmail=document.form2.Invoice_strEmail.value;
                            if (InvoiceMoney==''){alert("请填写开票金额!");return false;}
                            if (InvoiceName==''){alert("请填写发票抬头!");return false;}
                            if (InvoiceName.indexOf("公司")>=0 && InvoiceCompanyID==''){alert("请填写纳税识别号!");return false;}
                            if (InvoiceType=='2'){
                                if (Invoice_strEmail==''){alert("请填写电子邮箱!");return false;}
                                if (Invoice_strPhone==''){alert("请填写接收短信电话!");return false;}
                            }else if (InvoiceType=='3'){
                                if (Invoice_strPhone==''){alert("请填写收件人电话!");return false;}
                                if (Invoice_strName==''){alert("请填写收件人!");return false;}
                                if (Invoice_strAdd==''){alert("请填写邮寄地址!");return false;}
                            }
                            form2.submit();
                        }
                        //受理单调单查询
                        function JS_ServiceOrdSearch()
                        {
                        ServiceOrdNo=document.form2.ServiceOrdNo.value;
                        window.HiddenFrame.location.replace('Search_ServiceOrd.gds?Invoice=1&ServiceOrdNo='+ServiceOrdNo);
                        }
                        //显示车牌号
                        function JS_PaidMoneyData(ServiceOrdID,ServiceOrdPtName,InvoiceMoney)
                        {
                            
                            if (ServiceOrdID=='')
                            {
                                document.form2.ServiceOrdID.value=0;
                                alert("服务单号错误!!");
                            }
                            else 
                            {
                                if (InvoiceMoney==0){
                                    document.getElementById('ErrorsTXT').innerHTML = '已有开票记录,禁止重复申请!!'; 
                                    //JS_CarGasAdd();
                                }else{
                                    document.form2.ServiceOrdID.value=ServiceOrdID;
                                    document.getElementById('InvoiceMoney').value = InvoiceMoney; 
                                    document.getElementById('ServiceOrdNo').className = 'valid'; 
                                    document.getElementById('ServiceOrdNo').readOnly=true;
                                    document.getElementById('AuditMakeout').className = ''; 
                                    document.getElementById('AuditMakeout').readOnly=false;
                                    document.getElementById('InvoiceMoney').className = ''; 
                                    document.getElementById('InvoiceMoney').readOnly=false;
                                    document.getElementById('InvoiceNo').className = ''; 
                                    document.getElementById('InvoiceNo').readOnly=false;
                                    document.getElementById('InvoiceURL').className = ''; 
                                    document.getElementById('InvoiceURL').readOnly=false;
                                    document.getElementById('InvoiceOddNo').className = ''; 
                                    document.getElementById('InvoiceOddNo').readOnly=false;
                                    document.getElementById('InvoiceName').value = ServiceOrdPtName; 
                                    document.getElementById('InvoiceName').className='';
                                    document.getElementById('InvoiceName').readOnly=false;
                                    document.getElementById('InvoiceMakeout').className = ''; 
                                    document.getElementById('InvoiceMakeout').readOnly=false;
                                    document.getElementById('InvoiceCompanyPhone').className = ''; 
                                    document.getElementById('InvoiceCompanyPhone').readOnly=false;
                                    document.getElementById('InvoiceCompanyID').className = ''; 
                                    document.getElementById('InvoiceCompanyID').readOnly=false;
                                    document.getElementById('InvoiceCompanyAdd').className = ''; 
                                    document.getElementById('InvoiceCompanyAdd').readOnly=false;
                                    document.getElementById('InvoiceCompanyBank').className = ''; 
                                    document.getElementById('InvoiceCompanyBank').readOnly=false;
                                    document.getElementById('InvoiceCompanyBankNo').className = ''; 
                                    document.getElementById('InvoiceCompanyBankNo').readOnly=false;
                                    document.getElementById('InvoiceZipCode').className = ''; 
                                    document.getElementById('InvoiceZipCode').readOnly=false;
                                    document.getElementById('Invoice_strAdd').className = ''; 
                                    document.getElementById('Invoice_strAdd').readOnly=false;
                                    document.getElementById('Invoice_strEmail').className = ''; 
                                    document.getElementById('Invoice_strEmail').readOnly=false;
                                    document.getElementById('Invoice_strName').className = ''; 
                                    document.getElementById('Invoice_strName').readOnly=false;
                                    document.getElementById('Invoice_strPhone').className = ''; 
                                    document.getElementById('Invoice_strPhone').readOnly=false;
                                }
                            }
                        }
                        //新建单据信息
                        function JS_CarGasAdd()
                        {
                            CarCreate.style.display='block';
                            document.getElementById('EditPhotoTXT').innerHTML = '新建发票申请'; 
                            document.getElementById('ErrorsTXT').innerHTML = ''; 
                            document.form2.admin_save.value='13';
                            document.form2.ServiceOrdID.value=0;
                            document.form2.InvoiceID.value=0;
                            document.getElementById('ServiceOrdNo').value = ''; 
                            document.getElementById('ServiceOrdNo').className = ''; 
                            document.getElementById('ServiceOrdNo').readOnly=false;
                            document.getElementById('AuditMakeout').value = ''; 
                            document.getElementById('AuditMakeout').className = 'valid'; 
                            document.getElementById('AuditMakeout').readOnly=true;
                            document.getElementById('InvoiceMoney').value = ''; 
                            document.getElementById('InvoiceMoney').className = 'valid'; 
                            document.getElementById('InvoiceMoney').readOnly=true;
                            document.getElementById('InvoiceNo').value = ''; 
                            document.getElementById('InvoiceNo').className = 'valid'; 
                            document.getElementById('InvoiceNo').readOnly=true;
                            document.getElementById('InvoiceURL').value = ''; 
                            document.getElementById('InvoiceURL').className = 'valid'; 
                            document.getElementById('InvoiceURL').readOnly=true;
                            document.getElementById('InvoiceOddNo').value = ''; 
                            document.getElementById('InvoiceOddNo').className = 'valid'; 
                            document.getElementById('InvoiceOddNo').readOnly=true;
                            document.getElementById('InvoiceName').value = ''; 
                            document.getElementById('InvoiceName').className = 'valid'; 
                            document.getElementById('InvoiceName').readOnly=true;
                            document.getElementById('InvoiceMakeout').value = ''; 
                            document.getElementById('InvoiceMakeout').className = 'valid'; 
                            document.getElementById('InvoiceMakeout').readOnly=true;
                            
                            document.getElementById('InvoiceCompanyPhone').value = ''; 
                            document.getElementById('InvoiceCompanyPhone').className = 'valid'; 
                            document.getElementById('InvoiceCompanyPhone').readOnly=true;
                            document.getElementById('InvoiceCompanyID').value = ''; 
                            document.getElementById('InvoiceCompanyID').className = 'valid'; 
                            document.getElementById('InvoiceCompanyID').readOnly=true;
                            document.getElementById('InvoiceCompanyAdd').value = ''; 
                            document.getElementById('InvoiceCompanyAdd').className = 'valid'; 
                            document.getElementById('InvoiceCompanyAdd').readOnly=true;
                            document.getElementById('InvoiceCompanyBank').value = ''; 
                            document.getElementById('InvoiceCompanyBank').className = 'valid'; 
                            document.getElementById('InvoiceCompanyBank').readOnly=true;
                            document.getElementById('InvoiceCompanyBankNo').value = ''; 
                            document.getElementById('InvoiceCompanyBankNo').className = 'valid'; 
                            document.getElementById('InvoiceCompanyBankNo').readOnly=true;
                            document.getElementById('InvoiceZipCode').value = ''; 
                            document.getElementById('InvoiceZipCode').className = 'valid'; 
                            document.getElementById('InvoiceZipCode').readOnly=true;
                            document.getElementById('Invoice_strAdd').value = ''; 
                            document.getElementById('Invoice_strAdd').className = 'valid'; 
                            document.getElementById('Invoice_strAdd').readOnly=true;
                            document.getElementById('Invoice_strEmail').value = ''; 
                            document.getElementById('Invoice_strEmail').className = 'valid'; 
                            document.getElementById('Invoice_strEmail').readOnly=true;
                            document.getElementById('Invoice_strName').value = ''; 
                            document.getElementById('Invoice_strName').className = 'valid'; 
                            document.getElementById('Invoice_strName').readOnly=true;
                            document.getElementById('Invoice_strPhone').value = ''; 
                            document.getElementById('Invoice_strPhone').className = 'valid'; 
                            document.getElementById('Invoice_strPhone').readOnly=true;
 
                            document.getElementById('ApplicationTime').innerHTML = ''; 
                            document.getElementById('AuditTime').innerHTML = ''; 
                            document.getElementById('AuditOAID').innerHTML = ''; 
                            $("#AuditStatus").val(0);
                            $("#InvoiceType").val(2);
                            document.form2.ServiceOrdNo.value='';
                            JS_InvoiceType();
                        }
 
                        //显示修改单据信息
                        function JS_InvoiceEdit(InvoiceID,ServiceOrdID,ServiceOrdNo,InvoiceName,InvoiceMakeout,InvoiceCompanyPhone,InvoiceCompanyID,InvoiceCompanyAdd,InvoiceCompanyBank,InvoiceCompanyBankNo,InvoiceZipCode,Invoice_strAdd,Invoice_strEmail,Invoice_strName,Invoice_strPhone,AuditMakeout,InvoiceMoney,InvoiceNo,ApplicationTime,AuditTime,AuditOAID,AuditStatus,InvoiceType,InvoiceURL,InvoiceOddNo,EleCloud_ZTDM,EleCloud_ZTXX,EleCloud_Time)
                        {
                            CarCreate.style.display='block';
                            document.getElementById('EditPhotoTXT').innerHTML = '发票申请信息'; 
                            document.form2.admin_save.value='13';
                            document.form2.ServiceOrdID.value=ServiceOrdID;
                            document.form2.InvoiceID.value=InvoiceID;
                            document.getElementById('ServiceOrdNo').value = ServiceOrdNo; 
                            document.getElementById('ServiceOrdNo').className = 'valid'; 
                            document.getElementById('ServiceOrdNo').readOnly=true;
                            document.getElementById('AuditMakeout').value = AuditMakeout; 
                            document.getElementById('AuditMakeout').className = ''; 
                            document.getElementById('AuditMakeout').readOnly=false;
                            document.getElementById('InvoiceMoney').value = InvoiceMoney; 
                            document.getElementById('InvoiceMoney').className = ''; 
                            document.getElementById('InvoiceMoney').readOnly=false;
                            document.getElementById('InvoiceNo').value = InvoiceNo; 
                            document.getElementById('InvoiceNo').className = ''; 
                            document.getElementById('InvoiceNo').readOnly=false;
                            document.getElementById('InvoiceName').value = InvoiceName; 
                            document.getElementById('InvoiceName').className = ''; 
                            document.getElementById('InvoiceName').readOnly=false;
                            document.getElementById('InvoiceMakeout').value = InvoiceMakeout; 
                            document.getElementById('InvoiceMakeout').className = ''; 
                            document.getElementById('InvoiceMakeout').readOnly=false;
                            document.getElementById('InvoiceURL').value = InvoiceURL; 
                            document.getElementById('InvoiceURL').className = ''; 
                            document.getElementById('InvoiceURL').readOnly=false;
                            document.getElementById('InvoiceOddNo').value = InvoiceOddNo; 
                            document.getElementById('InvoiceOddNo').className = ''; 
                            document.getElementById('InvoiceOddNo').readOnly=false;
                            
                            document.getElementById('InvoiceCompanyPhone').value = InvoiceCompanyPhone; 
                            document.getElementById('InvoiceCompanyPhone').className = ''; 
                            document.getElementById('InvoiceCompanyPhone').readOnly=false;
                            document.getElementById('InvoiceCompanyID').value = InvoiceCompanyID; 
                            document.getElementById('InvoiceCompanyID').className = ''; 
                            document.getElementById('InvoiceCompanyID').readOnly=false;
                            document.getElementById('InvoiceCompanyAdd').value = InvoiceCompanyAdd; 
                            document.getElementById('InvoiceCompanyAdd').className = ''; 
                            document.getElementById('InvoiceCompanyAdd').readOnly=false;
                            document.getElementById('InvoiceCompanyBank').value = InvoiceCompanyBank; 
                            document.getElementById('InvoiceCompanyBank').className = ''; 
                            document.getElementById('InvoiceCompanyBank').readOnly=false;
                            document.getElementById('InvoiceCompanyBankNo').value = InvoiceCompanyBankNo; 
                            document.getElementById('InvoiceCompanyBankNo').className = ''; 
                            document.getElementById('InvoiceCompanyBankNo').readOnly=false;
                            document.getElementById('InvoiceZipCode').value = InvoiceZipCode; 
                            document.getElementById('InvoiceZipCode').className = ''; 
                            document.getElementById('InvoiceZipCode').readOnly=false;
                            document.getElementById('Invoice_strAdd').value = Invoice_strAdd; 
                            document.getElementById('Invoice_strAdd').className = ''; 
                            document.getElementById('Invoice_strAdd').readOnly=false;
                            document.getElementById('Invoice_strEmail').value = Invoice_strEmail; 
                            document.getElementById('Invoice_strEmail').className = ''; 
                            document.getElementById('Invoice_strEmail').readOnly=false;
                            document.getElementById('Invoice_strName').value = Invoice_strName; 
                            document.getElementById('Invoice_strName').className = ''; 
                            document.getElementById('Invoice_strName').readOnly=false;
                            document.getElementById('Invoice_strPhone').value = Invoice_strPhone; 
                            document.getElementById('Invoice_strPhone').className = ''; 
                            document.getElementById('Invoice_strPhone').readOnly=false;
 
                            document.getElementById('ApplicationTime').innerHTML = ApplicationTime; 
                            document.getElementById('AuditTime').innerHTML = AuditTime; 
                            document.getElementById('AuditOAID').innerHTML = AuditOAID; 
                            $("#AuditStatus").val(AuditStatus);
                            $("#InvoiceType").val(InvoiceType);
                            document.form2.ServiceOrdNo.value=ServiceOrdNo;
                            JS_InvoiceType();
                        }
                    </script>
 
                    <div class="dialogJ  dialogJfix dialogJshadow" id="CarCreate" style="width:800px; right: 300px; top: 80px;display:none;">
                    
                        <div class="dialogJtitle">
                            <a href="javascript:JS_CarCreateClose();" class="dialogJclose" title="关闭本窗口">&nbsp;</a>
                            <span class="dialogJtxt" id="EditPhotoTXT">发票申请信息</span>
                        </div>
                        <form id="form2" name="form2" action="admin_save.php" method="post">
                        <input name="admin_save" type="hidden" value="13">
                        <input name="searchTXT" type="hidden" value="<?php echo $searchTXT?>">
                        <input name="ServiceOrdID" type="hidden" value="">
                        <input name="InvoiceID" type="hidden" value="0">
                        <input name="page" type="hidden" value="<?php echo $page?>">
                        <div class="dialogJcontent">
                            <div class="dialogJbody" id="dialogJbody">
                                <div class="modify-album-name">
                                    <span>服务单号:</span>
                                    <input id="ServiceOrdNo" name="ServiceOrdNo" type="text" value="" style="width: 165px;" maxlength="99/"><input type="button" style="text-indent:initial;" class="dialogJbtn first-child" onclick="JS_ServiceOrdSearch()" value="调用"> <input type="button" style="text-indent:initial;" class="dialogJbtn first-child" onclick="JS_CarGasAdd()" value="重置"> <span class="dialogJtxt" id="ErrorsTXT" style="color: #ef0303;"></span>
                                </div>
                                <div class="modify-album-name">
                                    <span>处理状态:</span>
                                    <select id="AuditStatus" name="AuditStatus" style="padding: 5px 0 5px 8px;">
                                        <?php for($i=0;$i<count($AuditStatusArray);$i++) {?>
                                          <option value="<?php echo $AuditStatusArray[$i][0]?>"><?php echo $AuditStatusArray[$i][1]?></option>
                                        <?php }?>
                                    </select>
                                    <span>处理日期:</span>
                                    <span id="AuditTime"></span>
                                    <span>处理人员:</span>
                                    <span id="AuditOAID"></span>
                                </div>
                                <div class="modify-album-name">
                                    <span>处理备注:</span>
                                    <input id="AuditMakeout" name="AuditMakeout" type="text" value="" maxlength="99/" style="width: 400px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name">
                                    <span>发票号码:</span>
                                    <input id="InvoiceNo" name="InvoiceNo" type="text" value="" maxlength="99/" style="width: 400px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name">
                                    <span>发票类型:</span>
                                    <select id="InvoiceType" name="InvoiceType" onchange="JS_InvoiceType();" style="padding: 5px 0 5px 8px;">
                                        <option value="1">不开发票</option>
                                        <option value="2">电子发票</option>
                                        <option value="3">增值税普票</option>
                                        <option value="4">增值税专票</option>
                                    </select>
                                    <span>开票金额<font color="#ff0000">*</font>:</span>
                                    <input id="InvoiceMoney" name="InvoiceMoney" type="text" value="" maxlength="99/" style="width: 100px;" readonly="true" class="valid">
                                    <span>申请日期:</span>
                                    <span id="ApplicationTime"></span>
                                </div>
                                <div class="modify-album-name" id="InvoiceURLDiv">
                                    <span>发票链接:</span>
                                    <input id="InvoiceURL" name="InvoiceURL" type="text" value="" style="width: 400px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name">
                                    <span>发票抬头<font color="#ff0000">*</font>:</span>
                                    <input id="InvoiceName" name="InvoiceName" type="text" value="" maxlength="99/" style="width: 400px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name">
                                    <span>发票备注:</span>
                                    <input id="InvoiceMakeout" name="InvoiceMakeout" type="text" value="" maxlength="99/" style="width: 400px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name">
                                    <span>纳税识别号:</span>
                                    <input id="InvoiceCompanyID" name="InvoiceCompanyID" type="text" value="" maxlength="99/" style="width: 388px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name"  id="InvoiceCompanyAddDiv" style="display:none;">
                                    <span>企业注册地址:</span>
                                    <input id="InvoiceCompanyAdd" name="InvoiceCompanyAdd" type="text" value="" maxlength="99/" style="width: 300px;" readonly="true" class="valid">
                                    <span>企业电话:</span>
                                    <input id="InvoiceCompanyPhone" name="InvoiceCompanyPhone" type="text" value="" maxlength="99/" style="width: 200px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name" id="InvoiceCompanyBankDiv" style="display:none;">
                                    <span>企业开户银行:</span>
                                    <input id="InvoiceCompanyBank" name="InvoiceCompanyBank" type="text" value="" maxlength="99/" style="width: 200px;" readonly="true" class="valid">
                                    <span>企业银行账号:</span>
                                    <input id="InvoiceCompanyBankNo" name="InvoiceCompanyBankNo" type="text" value="" maxlength="99/" style="width: 276px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name" id="Invoice_strAddDiv" style="display:none;">
                                    <span>邮寄地址:</span>
                                    <input id="Invoice_strAdd" name="Invoice_strAdd" type="text" value="" maxlength="99/" style="width: 448px;" readonly="true" class="valid">
                                    <span>邮编:</span>
                                    <input id="InvoiceZipCode" name="InvoiceZipCode" type="text" value="" maxlength="99/" style="width: 100px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name" id="InvoiceOddNoDiv">
                                    <span>物流单号:</span>
                                    <input id="InvoiceOddNo" name="InvoiceOddNo" type="text" value="" maxlength="99/" style="width: 400px;" readonly="true" class="valid">
                                </div>
                                <div class="modify-album-name"  id="Invoice_strEmailDiv">
                                    <span>接收电子邮箱<font color="#ff0000">*</font>:</span>
                                    <input id="Invoice_strEmail" name="Invoice_strEmail" type="text" value="" maxlength="99/" style="width: 200px;" readonly="true" class="valid">若无邮箱,请填写“无”
                                </div>
                                <div class="modify-album-name">
                                    <span id="Invoice_strNameTXT">联系人<font color="#ff0000">*</font>:</span>
                                    <input id="Invoice_strName" name="Invoice_strName" type="text" value="" maxlength="99/" style="width: 200px;" readonly="true" class="valid">
                                    <span id="Invoice_strPhoneTXT">联系电话<font color="#ff0000">*</font>:</span>
                                    <input id="Invoice_strPhone" name="Invoice_strPhone" type="text" value="" maxlength="99/" style="width: 200px;" readonly="true" class="valid">
                                </div>
                            </div>
                        </div>
                        </form>
                        <div class="dialogJanswers" style="padding: 30px 20px 13px 18px;">
                            <input type="button" class="dialogJbtn first-child" onclick="JS_CarCreateSave()" value="确定"> 
                            <input type="button" class="dialogJbtn" onclick="JS_CarCreateClose()" value="取消">
                        </div>
                    </div>
 
                            <div class="search">
                            <form action="?" method="post">
                                <div class="input">
                                    <input type="text" id="searchTXT" name="searchTXT" value="<?php echo $searchTXT?>" />
                                </div>
                                
                                <div class="button">
                                    <input type="submit" name="submit" value="搜索" />
                                </div>
                            </form>
                            </div>
                        </ul>
                    </div>
                    <!-- end box / title -->
                    <?php
                    //分页信息
                    $page=empty($_REQUEST['page'])==true ? 1 : $_REQUEST['page']; //当前页数
                    $page=empty($draw)==true ? $page : $draw; //当前页数
                    $page_size = 20;    //每页显示数量
                    $total_page=0;            //总页数
                    $total_records=0;            //总记录数
                    //查询条件
                    $searchSql="";
                    $searchTXT=empty($searchTXT)==true ? "" : $searchTXT;
                    if (strlen($searchTXT)==14 and !is_numeric(substr($searchTXT,0,2)) And is_numeric(substr($searchTXT,2,8)) And is_numeric(substr($searchTXT,-3)) And substr($searchTXT,10,1)=="-"){
                        $searchSql=" and ((ServiceOrdClass='".substr($searchTXT,0,2)."' and CONVERT(VARCHAR(10),ServiceOrd_CC_Time,120)=CONVERT(VARCHAR(10),'".substr($searchTXT,2,4)."-".substr($searchTXT,6,2)."-".substr($searchTXT,8,2)."',120) and Right('00'+convert(varchar(3),ServiceOrdNo),3)='".substr($searchTXT,-3)."') or ServiceOrdID in (select ServiceOrdIDDt from DispatchOrd where DispatchOrdClass='".substr($searchTXT,0,2)."' and CONVERT(VARCHAR(10),DispatchOrd_NS_Time,120)=CONVERT(VARCHAR(10),'".substr($searchTXT,2,4)."-".substr($searchTXT,6,2)."-".substr($searchTXT,8,2)."',120) and Right('00'+convert(varchar(3),DispatchOrdNo),3)='".substr($searchTXT,-3)."')) ";
                    }elseif ($searchTXT!=""){
                        $searchSql=" and (InvoiceName like '%$searchTXT%' or InvoiceNo='$searchTXT') ";
                    }elseif ($AuditStatus!=-1) {
                        $searchSql=" and AuditStatus=$AuditStatus ";
                        $searchSql = $searchSql." and ApplicationTime ".$SqlOrdDateType;
                    }else{
                        $searchSql=" and AuditStatus<>4 ";
                        $searchSql = $searchSql." and ApplicationTime ".$SqlOrdDateType;
                    }
                    //$searchSql = $searchSql." and ApplicationTime ".$SqlOrdDateType;
                    $orderby=empty($orderby)==true ? "" : $orderby;
                    If (strrpos($orderby," desc")>1){
                        $orderbydesc="";
                        $descTXT="↓";
                    }else{
                        $orderbydesc=" desc";
                        $descTXT="↑";
                    }
 
                    If ($orderby=="") {
                      $orderby="OutHosp|InHosp desc,OutHospPrice|InHospPrice desc";
                      $descTXT="↓";
                    }
                    //echo $OrdClassListSql;
 
                    //查询开始
                    $InvoiceType=empty($InvoiceType)==true ? "1" : $InvoiceType;
                    //按调度单统计
                    //SQL查询条件
                    $sqlWhere=" from InvoiceData,ServiceOrder where ServiceOrderIDPK=ServiceOrdID".$searchSql;
                    //组成计算总页数SQL
                    $total_sql = "select InvoiceID $sqlWhere";    
                    //组成显示结果SQL
                    $Result_sql = "select InvoiceID,InvoiceType,InvoiceName,InvoiceMakeout,InvoiceCompanyPhone,InvoiceCompanyID,InvoiceCompanyAdd,InvoiceCompanyBank,InvoiceCompanyBankNo,InvoiceZipCode,Invoice_strAdd,Invoice_strEmail,Invoice_strName,Invoice_strPhone,ApplicationTime=CONVERT(nvarchar(20),ApplicationTime,120),AuditTime=CONVERT(nvarchar(20),AuditTime,120),AuditStatus,AuditOAID,ApplyOAID,AuditMakeout,InvoiceMoney,InvoiceNo,InvoiceURL,InvoiceOddNo,ServiceOrdID,ServiceOrdType,ServiceOrdClass,ServiceOrdNo=ServiceOrdClass+convert(nvarchar(10),year(ServiceOrd_CC_Time))+right('0'+convert(nvarchar(10),month(ServiceOrd_CC_Time)),2)+right('0'+convert(nvarchar(10),day(ServiceOrd_CC_Time)),2)+'-'+right('00'+convert(nvarchar(10),ServiceOrdNo),3),OrdTraPrice=ServiceOrdTraTxnPrice+(select isnull(SUM(AddMoney),0) from PaidMoney_Add LEFT JOIN dictionary on vtitle='AddMoney' and vID=AddMoneyType where ToServiceOrdID=ServiceOrdID)-(select isnull(SUM(PaidMoney),0) from PaidMoney where (ServiceOrdIDDt=ServiceOrdID) and PaidMoney_AP_Check<>-1 and PaidMoneyType=9),EleCloud_ZTDM,EleCloud_ZTXX,EleCloud_Time=CONVERT(nvarchar(20),EleCloud_Time,120),row_number() over (order by ApplicationTime desc) n  $sqlWhere";    
                    //附加结果SQL
                    $Additional_sql = ",DispatchOrdNo=(select top 1 DispatchOrdClass+convert(nvarchar(10),year(DispatchOrd_NS_Time))+right('0'+convert(nvarchar(10),month(DispatchOrd_NS_Time)),2)+right('0'+convert(nvarchar(10),day(DispatchOrd_NS_Time)),2)+'-'+right('00'+convert(nvarchar(10),DispatchOrdNo),3) from DispatchOrd where ServiceOrdIDDt=ServiceOrdID order by DispatchOrdID desc)";
 
                    //计算总页数
                    $data = sqlsrv_query( $conn, $total_sql, array(), array( "Scrollable" => 'keyset' ));
                    $total_records=sqlsrv_num_rows($data);    //总行数
                    $total_page=ceil($total_records/$page_size);    //总页数
                    //避免page小于0或大于总页数
                    $page=$page<=0?1:$page;
                    $page=$page>$total_page?$total_page:$page;  
                    //计算开始和结束行数
                    $pageStart = ($page-1)*$page_size;
                    $pageEnd = $pageStart+$page_size;
                    $sqlPage = " where sqlData.n > $pageStart and sqlData.n <= $pageEnd " ;
 
                    $sql = "select * $Additional_sql from ($Result_sql) sqlData ".$sqlPage." order by sqlData.n" ;
                    //echo $sql;//exit;
                    $data = sqlsrv_query($conn,$sql);
                    if (sqlsrv_rows_affected($data)==0) {
                        $SystemMessageType=2;
                        $SystemMessageTXT="数据库中相关无数据!";
                    }
                    ?>
                    <?php require '/inc/SystemMessages.php';?>
                    <div class="table" style="overflow:auto">
                        <form id="form1" name="form1" action="" method="post">
                        <input name="admin_save" type="hidden" value="13">
                        <input name="Car_Check" type="hidden" value="">
                        <input name="searchTXT" type="hidden" value="<%=searchTXT%>">
                        <input name="page" type="hidden" value="<%=acc1%>">
                        <table>
                            <thead>
                                <tr style="white-space: nowrap;">
                                    <th>服务单号</th>
                                    <th>调度单号</th>
                                    <th>所属公司</th>
                                    <th>申请时间</th>
                                    <th>发票抬头</th>
                                    <th>发票金额</th>
                                    <th>发票备注</th>
                                    <th>处理状态</th>
                                    <th>发票编号</th>
                                    <th>申请人</th>
                                    <th>处理人</th>
                                    <th>处理时间</th>
                                    <th>下载/物流</th>
                                    <th class="last">处理备注</th>
                                </tr>
                            </thead>
                            <tbody>
            <?php 
            $i=1;
            while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
                $i++;
                $ServiceOrdID        = $rs['ServiceOrdID'];        //服务单ID
                $ServiceOrdNo        = $rs['ServiceOrdNo'];        //服务单号
                //$DispatchOrdID        = $rs['DispatchOrdID'];        //调度单ID
                $DispatchOrdNo        = $rs['DispatchOrdNo'];        //调度单号
                $ServiceOrdClass    = $rs['ServiceOrdClass'];        //对应服务单类型
 
                $InvoiceID            = $rs['InvoiceID'];            //开票信息ID
                $InvoiceType        = $rs['InvoiceType'];        //开票类型
                $InvoiceName        = $rs['InvoiceName'];        //发票抬头
                $InvoiceMakeout        = $rs['InvoiceMakeout'];    //发票备注
                $InvoiceCompanyPhone= $rs['InvoiceCompanyPhone'];//企业电话
                $InvoiceCompanyID    = str_replace(array("\r\n", "\r", "\n"),'',$rs['InvoiceCompanyID']);    //纳税识别号
                $InvoiceCompanyAdd    = $rs['InvoiceCompanyAdd'];    //企业注册地址
                $InvoiceCompanyBank    = $rs['InvoiceCompanyBank'];//企业开户银行
                $InvoiceCompanyBankNo=$rs['InvoiceCompanyBankNo'];//企业银行账号
                $InvoiceZipCode        = $rs['InvoiceZipCode'];    //邮编
                $Invoice_strAdd        = $rs['Invoice_strAdd'];    //邮寄地址
                $Invoice_strEmail    = $rs['Invoice_strEmail'];    //电子邮箱
                $Invoice_strName    = $rs['Invoice_strName'];    //联系人
                $Invoice_strPhone    = $rs['Invoice_strPhone'];    //联系电话
                $ApplicationTime    = $rs['ApplicationTime'];    //申请时间
                $AuditTime            = $rs['AuditTime'];            //处理时间
                $AuditStatus        = $rs['AuditStatus'];        //处理状态
                $AuditOAID            = $rs['AuditOAID'];            //处理人
                $AuditMakeout        = $rs['AuditMakeout'];        //处理备注
                $ApplyOAID            = $rs['ApplyOAID'];            //申请人(0为客户申请)
                $InvoiceMoney        = $rs['InvoiceMoney'];        //发票金额
                $InvoiceNo            = $rs['InvoiceNo'];            //发票编号
                $InvoiceURL            = $rs['InvoiceURL'];        //发票链接
                $InvoiceOddNo        = $rs['InvoiceOddNo'];        //发票物流单号
                $EleCloud_ZTDM        = $rs['EleCloud_ZTDM'];        //大象慧云-申请状态
                $EleCloud_ZTXX        = $rs['EleCloud_ZTXX'];        //大象慧云-状态说明
                $EleCloud_Time        = $rs['EleCloud_Time'];        //大象慧云-开票时间
                $OrdTraPrice        = $rs['OrdTraPrice'];
 
                $AuditOAName=empty($AuditOAID)==true ? "--" : OAUser($AuditOAID,"UserName");
                if ($InvoiceID<=597) {
                    $ApplyOAName="--";
                }else{
                    $ApplyOAName=empty($ApplyOAID)==true ? "客户" : OAUser($ApplyOAID,"UserName");
                }
                
 
                if ($InvoiceMoney==0) {$InvoiceMoney=$rs['OrdTraPrice'];}
            ?>
            
              <tr style="white-space: nowrap;">
                <td class="category category2"><a href="ServiceOrder.gds?ServiceOrdID=<?php echo $ServiceOrdID?>&OrdDateType=13&OrdClassList=0&h_menu1_1=1" target="_blank"><?php echo $ServiceOrdNo?></a></td>
                <td class="category category2"><a href="DispatchOrder_List.gds?h_menu1_1=1&OrdState=0&OrdDateType=13&searchTXT=<?php echo $DispatchOrdNo?>&UnitNameID=0&OrdClassList=0" target="_blank"><?php echo $DispatchOrdNo?></a></td>
                <td class="category category2">
                <?php
                for($z=1;$z<=count($UnitNameListArray);$z++) {
                    if ($UnitNameListArray[$z][0]==$ServiceOrdClass){
                        echo $UnitNameListArray[$z][1];
                    }
                }
                ?>
                </td>
                <td class="category category2"><A onclick="JS_InvoiceEdit(<?php echo str_replace(array("\r\n", "\r", "\n"),'',"'$InvoiceID','$ServiceOrdID','$ServiceOrdNo','$InvoiceName','$InvoiceMakeout','$InvoiceCompanyPhone','$InvoiceCompanyID','$InvoiceCompanyAdd','$InvoiceCompanyBank','$InvoiceCompanyBankNo','$InvoiceZipCode','$Invoice_strAdd','$Invoice_strEmail','$Invoice_strName','$Invoice_strPhone','$AuditMakeout','".floatval(number_format($InvoiceMoney,2,".",""))."','$InvoiceNo','$ApplicationTime','$AuditTime','$AuditOAName','$AuditStatus','$InvoiceType','$InvoiceURL','$InvoiceOddNo','$EleCloud_ZTDM','$EleCloud_ZTXX','$EleCloud_Time'");?>);"><?php echo $ApplicationTime?></A></td>
                <td class="category category2"><A onclick="JS_InvoiceEdit(<?php echo str_replace(array("\r\n", "\r", "\n"),'',"'$InvoiceID','$ServiceOrdID','$ServiceOrdNo','$InvoiceName','$InvoiceMakeout','$InvoiceCompanyPhone','$InvoiceCompanyID','$InvoiceCompanyAdd','$InvoiceCompanyBank','$InvoiceCompanyBankNo','$InvoiceZipCode','$Invoice_strAdd','$Invoice_strEmail','$Invoice_strName','$Invoice_strPhone','$AuditMakeout','".floatval(number_format($InvoiceMoney,2,".",""))."','$InvoiceNo','$ApplicationTime','$AuditTime','$AuditOAName','$AuditStatus','$InvoiceType','$InvoiceURL','$InvoiceOddNo','$EleCloud_ZTDM','$EleCloud_ZTXX','$EleCloud_Time'");?>);"><?php echo $InvoiceName?></A></td>
                <td class="category category2"><A onclick="JS_InvoiceEdit(<?php echo str_replace(array("\r\n", "\r", "\n"),'',"'$InvoiceID','$ServiceOrdID','$ServiceOrdNo','$InvoiceName','$InvoiceMakeout','$InvoiceCompanyPhone','$InvoiceCompanyID','$InvoiceCompanyAdd','$InvoiceCompanyBank','$InvoiceCompanyBankNo','$InvoiceZipCode','$Invoice_strAdd','$Invoice_strEmail','$Invoice_strName','$Invoice_strPhone','$AuditMakeout','".floatval(number_format($InvoiceMoney,2,".",""))."','$InvoiceNo','$ApplicationTime','$AuditTime','$AuditOAName','$AuditStatus','$InvoiceType','$InvoiceURL','$InvoiceOddNo','$EleCloud_ZTDM','$EleCloud_ZTXX','$EleCloud_Time'");?>);">
                <?php 
                echo floatval(number_format($InvoiceMoney,2,".",""));
                if ($InvoiceMoney!=$OrdTraPrice) {
                    echo '(<label style="color: #E91E63;">'.floatval(number_format($OrdTraPrice,2,".",""))."</label>)";
                }
                ?> 
                
                </A></td>
                <td class="category category2"><?php echo $InvoiceMakeout?></td>
                <td class="category category2"><A onclick="JS_InvoiceEdit(<?php echo str_replace(array("\r\n", "\r", "\n"),'',"'$InvoiceID','$ServiceOrdID','$ServiceOrdNo','$InvoiceName','$InvoiceMakeout','$InvoiceCompanyPhone','$InvoiceCompanyID','$InvoiceCompanyAdd','$InvoiceCompanyBank','$InvoiceCompanyBankNo','$InvoiceZipCode','$Invoice_strAdd','$Invoice_strEmail','$Invoice_strName','$Invoice_strPhone','$AuditMakeout','".floatval(number_format($InvoiceMoney,2,".",""))."','$InvoiceNo','$ApplicationTime','$AuditTime','$AuditOAName','$AuditStatus','$InvoiceType','$InvoiceURL','$InvoiceOddNo','$EleCloud_ZTDM','$EleCloud_ZTXX','$EleCloud_Time'");?>);">
                <?php //处理状态
                    if (!empty($EleCloud_ZTDM)){
                        echo $EleCloud_ZTXX;
                    }else{
                        for($z=0;$z<count($AuditStatusArray);$z++) {if ($AuditStatusArray[$z][0]==$AuditStatus){echo $AuditStatusArray[$z][1];}}
                    }
                ?>
                </A></td>
                <td class="category category2"><?php echo $InvoiceNo?></td>
                <td class="category category2"><A onclick="JS_InvoiceEdit(<?php echo "'$InvoiceID','$ServiceOrdID','$ServiceOrdNo','$InvoiceName','$InvoiceMakeout','$InvoiceCompanyPhone','$InvoiceCompanyID','$InvoiceCompanyAdd','$InvoiceCompanyBank','$InvoiceCompanyBankNo','$InvoiceZipCode','$Invoice_strAdd','$Invoice_strEmail','$Invoice_strName','$Invoice_strPhone','$AuditMakeout','".floatval(number_format($InvoiceMoney,2,".",""))."','$InvoiceNo','$ApplicationTime','$AuditTime','$AuditOAName','$AuditStatus','$InvoiceType','$InvoiceURL','$InvoiceOddNo','$EleCloud_ZTDM','$EleCloud_ZTXX','$EleCloud_Time'"?>);"><?php echo $ApplyOAName?></A></td>
                <td class="category category2"><A onclick="JS_InvoiceEdit(<?php echo "'$InvoiceID','$ServiceOrdID','$ServiceOrdNo','$InvoiceName','$InvoiceMakeout','$InvoiceCompanyPhone','$InvoiceCompanyID','$InvoiceCompanyAdd','$InvoiceCompanyBank','$InvoiceCompanyBankNo','$InvoiceZipCode','$Invoice_strAdd','$Invoice_strEmail','$Invoice_strName','$Invoice_strPhone','$AuditMakeout','".floatval(number_format($InvoiceMoney,2,".",""))."','$InvoiceNo','$ApplicationTime','$AuditTime','$AuditOAName','$AuditStatus','$InvoiceType','$InvoiceURL','$InvoiceOddNo','$EleCloud_ZTDM','$EleCloud_ZTXX','$EleCloud_Time'"?>);"><?php echo $AuditOAName?></A></td>
                <td class="category category2"><?php echo $AuditTime?></td>
                <td class="category category2"><?php
                if (!empty($InvoiceURL)) {
                    echo "<a href='".$InvoiceURL."' target='_blank'>下载发票</a>";
                }else{
                    echo $InvoiceOddNo;
                }
                ?></td>
                <td class="category category2 last"><?php echo $AuditMakeout?></td>
              </tr>
            <?php }?>
            <?php
            $classHtml="";
            for($j=$i;$j<=20;$j++) {
                echo "<tr>";
                echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td class='last'>&nbsp;</td>";
                echo "</tr>";
            }
            ?>
                            </tbody>
                        </table>
                        <!-- 分页 -->
                        <?php if ($total_records>=1) {?>
                        <div class="pagination pagination-left">
                            <div class="results">
                                <?php
                                $ShowingLeast = ($page-1)*$page_size+1;
                                $ShowingMax = $page_size*$page;
                                if ($ShowingMax>$total_records) {$ShowingMax=$total_records;}
                                ?>
                                <span><?php echo "显示&nbsp;$ShowingLeast-$ShowingMax&nbsp;of&nbsp;$total_records";?></span>
                            </div>
                            <?php if ($total_page>1) {?>
                            <ul class="pager">
                                <?php
                                if ($page==1) {
                                    echo "<li class=\"disabled\">&laquo; 上页</li>";
                                }else{
                                    echo "<li><a href=\"?page=".($page-1)."&".$page_URL."\">&laquo; 上页</a></li>";
                                }
                                
                                $acc4=0;
                                for($i=1;$i<=$total_page;$i++) {
                                    if ($i==$page) {echo "<li class=\"current\">$i</li>";}
                                    elseif ($i<=3 or $i>($total_page-3)  ) {echo "<li><a href=\"?page=$i&$page_URL\">$i</a></li>";}
                                    elseif ($acc4==0){echo "<li class=\"separator\">...</li>";$acc4=$i<$page ? 1 : 2;}
                                    elseif ($acc4==1 and $i>$page+3){echo "<li class=\"separator\">...</li>";$acc4=2;}
                                    elseif ($acc4==1 and $i>=$page-3){echo "<li><a href=\"?page=$i&$page_URL\">$i</a></li>";}
                                }
 
                                if ($page>=$total_page) {
                                    echo "<li class=\"disabled\">下页 &raquo;</li>";
                                }else{
                                    echo "<li><a href=\"?page=".($page+1)."&".$page_URL."\">下页 &raquo;</a></li>";
                                }
                                ?>
                            </ul>
                            <?php }?>
                        </div>
                        <?php }?>
                        <!-- end 分页 -->
                    </div>
                </div>
                <!-- end table -->
 
 
                
            </div>
            <!-- end content / right -->
        </div>
        <!-- end content -->
        <!--#include FILE="vicgame.asp"-->
        <IFRAME id="HiddenFrame" name="HiddenFrame" WIDTH=0 HEIGHT=0 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=#ffffff></IFRAME>
    </body>
</html>