<!-- include '../header' -->
<link rel=stylesheet href="<?= WEB_SITE_GLOBAL ?>css/jquery.validator.css"> 
<script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/jquery.validator.min.js"></script>
<script type="text/javascript" src="<?= WEB_SITE_GLOBAL ?>js/zh-CN.js"></script>
<script src="<?= receipt ?>"></script>
<script src="<?= invoice ?>"></script>
<script>
$(function() {

	$('.CONFIRMReceivables').live('click', function() {
		var iidKey=$(this).attr("data-iidKey");
		var ridKey=$(this).attr("data-ridKey");
		
		$.ajax({
			url: '/receiptTrainReceivables/CONFIRM',
			type : "post",
			cache : false,
			dataType : "json",
			data : {
				iidKey : iidKey,
				ridKey:ridKey
			},
			global : true,
			success : function(data) {
				if (data.status == 1) {
					$("#"+iidKey).addClass("warning");
$('#RTR_'+iidKey).html('<a href="javascript:void(0)" class="CANCELReceivables colRed"  data-iidKey="'+iidKey+'" data-ridKey="'+ridKey+'" >取消[办事处已收款]</a> ');
				} else{
					alert('操作失败');
				}	
			},
			error : function(err) {
				alert('操作失败');
			}
		});
	});
	
	$('.CANCELReceivables').live('click', function() {
		var iidKey=$(this).attr("data-iidKey");
		var ridKey=$(this).attr("data-ridKey");
		
		$.ajax({
			url: '/receiptTrainReceivables/CANCEL',
			type : "post",
			cache : false,
			dataType : "json",
			data : {
				iidKey : iidKey,
				ridKey:ridKey
			},
			global : true,
			success : function(data) {
				if (data.status == 1) {
$('#RTR_'+iidKey).html('<a href="javascript:void(0)" class="CONFIRMReceivables"  data-iidKey="'+iidKey+'" data-ridKey="'+ridKey+'" >设置[办事处已收款]</a> ');
$("#"+iidKey).removeClass("warning");
				} else{
					alert('操作失败');
				}	
			},
			error : function(err) {
				alert('操作失败');
			}
		});
	});
	
	
	
	$('a[CANCELReceivablesI]').click(function() {
		var iidKey=$(this).attr("data-iidKey");
		var ridKey=$(this).attr("data-ridKey");
		
		$.ajax({
			url: '/receiptTrainReceivables/CANCEL',
			type : "post",
			cache : false,
			dataType : "json",
			data : {
				iidKey : iidKey,
				ridKey:ridKey
			},
			global : true,
			success : function(data) {
				if (data.status == 1) {
					$("#"+iidKey).removeClass("warning");
$('#RTRI_'+iidKey).html('');
				} else{
					alert('操作失败');
				}	
			},
			error : function(err) {
				alert('操作失败');
			}
		});
	});
	
	
})
</script>

<body>
    <div class="mainLayout">
        <div class="mainMenu">
            <div class="menuItem">
                <a href="#" class="mLogo">CLD</a>
                <ul>
                    <!-- include '../admin/menuReceipt' -->
                </ul>
            </div>
        </div>
        <div class="warpContent">
            <div class="subMenu fL">
                <div class="menuItem">
                    <!-- include '../admin/receipt_menu' -->
                </div>
            </div>
            <div class="adminContent autoHeight" style="height: 821px;">
                <!-- include 'receiptTrainApprovalForm' -->
                <div class="borad-news">
                    <div class="subNav">
                        <!-- include 'receiptTrainMenu' -->
                    </div>
                    <div class="saeaList">
                        <!--还没有培训班开票-->
                        
                        <!-- if {{receiptDetail.invoiceTrainId}}==0 -->
                        <p><a class="button" href="#add-train" getReceiptInvoice data-toggle="modal">添加培训班开票</a></p>
                        <!-- else -->
                        <legend>
                            <div class="fR"></div>培训班发票
                        </legend>
                        <table class="table table-bordered table-condensed">
                            <tbody>
                                <tr>
                                    <th class="taC">培训班名称</th>
                                    <th class="taC">办事处</th>
                                    <th class="taC">创建</th>
                                    <th class="taC">开班时间</th>
                                    <th class="taC" width="90">包含发票</th>
                                    <th class="taC">开票金额合计</th>
                                    <th class="taC">入账金额合计</th>
                                    <th class="taC">公司已收款</th>
                                    <th class="taC">办事处已收款</th>
                                    <th class="taC" width="90">入账完成度</th>
                                    <th class="taC" width="100">操作</th>
                                </tr>
                                <tr>
                                    <td><a href="/invoiceTrainingDetail/{{invoiceTrainingDetail.trainingKey}}.html" target="_blank">{{invoiceTrainingDetail.trainName}}</a></td>
                                    <td>{{invoiceTrainingDetail.category.0.title}}</td>
                                    <td>{{invoiceTrainingDetail.staff.username}}</td>
                                    <td>{{invoiceTrainingDetail.trainDate}}</td>
                                    <td>{{invoiceTrainingDetail.invoiceTotal}}</td>
                                    <td>￥{{invoiceTrainingDetail.invoiceTotalAmount}}</td>
                                    <td>￥{{invoiceTrainingDetail.invoiceArriveAmount}}</td>
                                    <td>￥{{invoiceTrainingDetail.invoiceCompanyAmount}}</td>
                                    <td>￥{{invoiceTrainingDetail.RIAmount}}</td>
                                    <td>{{invoiceTrainingDetail.arriveSchedule}}%</td>
                                    <td>
<a href="javascript:if(confirm('确定移除?')){window.location='/receiptTrainReceivablesDelDo?ridKey={{receiptDetail.ridKey}}&itidKey={{invoiceTrainingDetail.trainingKey}}';}">移除</a></td>
                                </tr>
                            </tbody>
                        </table>
                        <table class="table table-bordered table-condensed">
                            <tbody>
                                <tr>
                                    <th class="taC">开票流水</th>
                                    <th class="taC">开票单位（抬头）</th>
                                    <th class="taC">发票号</th>
                                    <th class="taC">总额</th>
                                    <th class="taC">状态</th>
                                    <th class="taC">收款流水号</th>
                                    <th class="taC">办事处收款</th>
                                </tr>
                                <!-- loop invoiceList -->
 <tr id="{{invoiceList' value.iidKey}}" <!-- if {{invoiceList' value.RIstatus}}==1&&{{pendingInvoice' value.untreadStatus}}!=3 --> class="warning" <!-- endif -->>
                                    <td><a href="#invdetail" node-invoice="INFO" data-iskey="{{invoiceList' value.iidKey}}" data-toggle="modal">{{invoiceList' value.invoiceSerial}}</a></td>
                                    <td>
                                    
                                    <!-- if !empty({{invoiceList' value.invoiceType}}) -->
	                                   	{{invoiceList' value.invoiceCompany}}
	                                <!-- else -->
	                                    {{invoiceList' value.invoiceTitle}}
	                                <!-- endif -->
	                                    </td>
                                    <td>{{invoiceList' value.invoiceNo}}</td>
                                    <td>
                                    <!-- if !empty({{pendingInvoice' value.invoiceType}}) -->
	                                   <b>￥{{pendingInvoice' value.invoicePrice}}</b><sup>专</sup>
	                                <!-- else -->
	                                   <b>￥{{pendingInvoice' value.invoicePrice}}</b>
	                                <!-- endif -->
                                    </td>
                                    <td>
                                    <!-- if {{pendingInvoice' value.untreadStatus}}==3 -->
                                    	已入账
                                    <!-- else -->
                                    	已出票
                                    <!-- endif -->
                                    </td>
                                    <td  >
                                    	
                                    <!-- if {{pendingInvoice' value.untreadStatus}}==3 -->
                                    
                                    	<!-- loop invoiceList' value.irDetail -->
                                    	<a href="#billing" style="display:block" node-invoice="INFO" data-type="receivables" data-iskey="{{invoiceList' value' value.iridKey}}" data-toggle="modal">{{invoiceList' value' value.receivablesSerial}}</a>
                                    	<!-- endloop -->
                                   
                                    <!-- else -->
                   
                                    <!-- endif -->
                                    </td>
                                    <td  >
                                    <!-- if {{pendingInvoice' value.untreadStatus}}!=3 -->
                                    <span id='RTR_{{invoiceList' value.iidKey}}'>
      <!-- if {{invoiceList' value.RIstatus}}==1 -->   
      <a href="javascript:void(0)" class="CANCELReceivables colRed" CANCELReceivables data-iidKey="{{invoiceList' value.iidKey}}" data-ridKey="{{receiptDetail.ridKey}}" >取消[办事处已收款]</a> 
      <!-- else -->                          
      <a href="javascript:void(0)" class="CONFIRMReceivables" CONFIRMReceivables data-iidKey="{{invoiceList' value.iidKey}}" data-ridKey="{{receiptDetail.ridKey}}" >设置[办事处已收款]</a>
      <!-- endif -->
      
      <!-- elseif {{invoiceList' value.RIstatus}}==1&&{{pendingInvoice' value.untreadStatus}}==3 && !{{pendingInvoice' value.isFinance}} -->
    	
      <span id='RTRI_{{invoiceList' value.iidKey}}'>
      <a href="javascript:void(0)" class="colRed"  CANCELReceivablesI data-iidKey="{{invoiceList' value.iidKey}}" data-ridKey="{{receiptDetail.ridKey}}" >取消[办事处已收款]</a> 
      </span>
      <!-- endif -->
      
      
      
      
      </span>  
                                    </td>
                                </tr>
                                <!-- endloop -->
                                
                            </tbody>
                        </table>
                        <!-- endif -->
                        
                    </div>
                </div>
            </div>
        </div>
        <!--弹出-->
        <div class="modal hide fade" id="add-train">
        <form action="/receiptTrainInvoiceEdiDo" method="post" class="nice-validator n-yellow" novalidate="novalidate">
			<input type="hidden" name="ridKey" value="{{receiptDetail.ridKey}}">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3>添加培训班开票</h3>
                    </div>
                    <div class="modal-body">
                        <div class="control-group">
                            <div class="controls clearfix">
                                <select name='itidKey' receiptInvoieSelect>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="submit" value="确定" class="button">
                        <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">取消</a>
                    </div>
                </div>
            </div>
            </form>
        </div>
        <!--弹出内容-->
        <!--弹出（发票详情）-->
     <div loading-msg='true' style="position:absolute;  left:50%;  top:50%;  "></div>
	<div class="modal  fade" id="invdetail">
		
		<div id="nc"></div>
	</div>

	<div class="modal  fade" id="billing">
		<div id="nr"></div>
	</div>
	<!--弹出收款-->
        <script type="text/javascript">
        autoFlashHeight();
        </script>
        </body>