<?php
use \common\libs\MyLib;
?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form id="theFrm">
        <input type="hidden" name="order_id" value="<?=$order_info->id?>">
        <tr>
            <td colspan="6" align="center">送单表</td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">收件人</td>
            <td width="300" height="25" class="td_bg"><input  class="Ainput" name="insurer_name" type="text" value="<?=$order_info->id_man?>" style="width:250px;" /></td>
            <td width="100" height="25" class="td_bg">联系电话</td>
            <td width="300" height="25" class="td_bg"><input  class="Ainput" name="link_tel" type="text" value="<?=$order_info->link_phone?>" style="width:250px;" /></td>
        </tr>
        <?php if($order_info->send_address2):?>
        <tr>
            <td width="100" height="25" class="td_bg">正本送单地址</td>
            <td colspan="3" height="25" class="td_bg">
                <?php
                $address2 = $order_info->city2?$order_info->city2->name:'';
                $address2 .= $order_info->district2?$order_info->district2->name:'';
                $address2 .= $order_info->send_address2;
                ?>
                <input  class="Ainput" name="send_address" type="text" value="<?=$address2?>" style="width:770px;"/>
            </td>
        </tr>
        <?php endif;?>


<?php if($order_info->send_address2):?>
    <tr>
            <td width="100" height="25" class="td_bg">收货人省份</td>
            <td height="25" class="td_bg"><input  class="Ainput province" name="receiver_province" type="text" value="" style="width:250px;"/></td>
            <td width="100" height="25" class="td_bg">收货人城市</td>
            <td height="25" class="td_bg"><input  class="Ainput city" name="receiver_city" type="text" value=" " style="width:250px;"/></td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">收货人区县</td>
            <td height="25" class="td_bg"><input  class="Ainput county" name="receiver_county" type="text" value="" style="width:250px;"/></td>
            <td width="100" height="25" class="td_bg">收货人详细地址</td>
            <td height="25" class="td_bg"><input  class="Ainput address" name="receiver_address" type="text" value="" style="width:250px;"/></td>
        </tr>
    <?php elseif($order_info->receiver_province):?>

    <tr>
        <td width="100" height="25" class="td_bg">收货人省份</td>
        <td height="25" class="td_bg"><input  class="Ainput province" name="receiver_province" type="text" value="<?=$order_info->receiver_province?>" style="width:250px;"/></td>
        <td width="100" height="25" class="td_bg">收货人城市</td>
        <td height="25" class="td_bg"><input  class="Ainput city" name="receiver_city" type="text" value="<?=$order_info->receiver_city?>" style="width:250px;"/></td>
    </tr>
    <tr>
        <td width="100" height="25" class="td_bg">收货人区县</td>
        <td height="25" class="td_bg"><input  class="Ainput county" name="receiver_county" type="text" value="<?=$order_info->receiver_county?>" style="width:250px;"/></td>
        <td width="100" height="25" class="td_bg">收货人详细地址</td>
        <td height="25" class="td_bg"><input  class="Ainput address" name="receiver_address" type="text" value="<?=$order_info->receiver_address?>" style="width:250px;"/></td>
    </tr>


    <?php else:?>
    <tr>
            <td width="100" height="25" class="td_bg">收货人省份</td>
            <td height="25" class="td_bg"><input  class="Ainput province" name="receiver_province" type="text" value="<?=$order_info->addr->regionP->name?>" style="width:250px;"/></td>
            <td width="100" height="25" class="td_bg">收货人城市</td>
            <td height="25" class="td_bg"><input  class="Ainput city" name="receiver_city" type="text" value="<?php if($order_info->addr->regionC->name=='市辖区'|| $order_info->addr->regionC->name=='市辖县'|| $order_info->addr->regionC->name=='县'):?><?=$order_info->addr->regionP->name?><?php else:?><?=$order_info->addr->regionC->name?><?php endif;?>

            " style="width:250px;"/></td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">收货人区县</td>
            <td height="25" class="td_bg"><input  class="Ainput county" name="receiver_county" type="text" value="<?=$order_info->addr->regionD->name?>" style="width:250px;"/></td>
            <td width="100" height="25" class="td_bg">收货人详细地址</td>
            <td height="25" class="td_bg"><input  class="Ainput address" name="receiver_address" type="text" value=" <?=$order_info->addr->regionT->name?><?=$order_info->addr->address?>" style="width:250px;"/></td>
        </tr>

            <?php endif;?>




        <tr>
            <td width="100" height="25" class="td_bg">保险公司</td>
            <td height="25" class="td_bg"><input  class="Ainput" name="sender_name" type="text" value="<?=$order_info->company2_id?$order_info->company2->name:''?>" style="width:250px;"/></td>
            <td height="25" class="td_bg" colspan="2"></td>

        </tr>
    </form>
    <tr>
        <td height="22" colspan="6" align="center" class="td_bg">
            <input id="print-btn" type=button class="ACT_btn" name=Submit1 value=" 打印 "/>
            &nbsp;&nbsp;
            <input id="back-btn" type="button" class="ACT_btn" name="Submit3" value=" 关闭 ">
        </td>
    </tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    function isNull(data){

        if(data == "" || data == undefined || data == null){
            return true;
        }else{
            return false;
        }
    }
    $(function () {

        //打印按钮
        $("#print-btn").click(function(){
            var params = $("#theFrm").serialize();
            var province = $('.province').val();
            var city = $('.city').val();
            var county = $('.county').val();
            var address = $('.address').val()
            if(isNull(province)){
                alert('收货人省份必填项!');
                return false;
            }
            if(isNull(city)){
                alert('收货人城市必填项!');
                return false;
            }
            if(isNull(county)){
                alert('收货人区县必填项!');
                return false;
            }
            if(isNull(address)){
                alert('收货人详细地址必填项!');
                return false;
            }

            window.open('/print/op-ems-print1?'+params);
        });

        //返回按钮
        $('#back-btn').click(function(){
            //window.location.href='/insurer/original-send-mng?<?=$back_params?>';
            window.close();
        });
    })
</script>