You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simple-yewu/frontend/views/car/order-add.php

596 lines
32 KiB

<?php
use \common\libs\MyLib;
use common\models\PriceT;
?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>
<div class="wrapper wrapper-content animated fadeInRight">
<form class="form-horizontal" id="orderFrm">
<input type="hidden" name="car_id" value="<?=$order_info->car_id?>">
<input type="hidden" name="id" value="<?=$order_info->id?>">
<input type="hidden" name="celuo_id" id="celuo_id" value="<?=$order_info->celuo_id?>">
<input type="hidden" name="fanxian_id" id="fanxian_id" value="<?=$order_info->fanxian_id?>">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>保单信息</h5>
</div>
<div class="ibox-content">
<table class="table table-bordered">
<tr>
<th class="bg-warning">车牌号</th>
<td><input name="car_no" class="form-control" style="width:100%;" type="text" value="<?=$order_info->car_no!='' ? $order_info->car_no:$car_info->car_no?>"></td>
<th class="bg-warning" nowrap>初登日期</th>
<td><input name="register_date" class="form-control date" style="width:100%;" type="text" value="<?=$car_info->register_date?>"></td>
<th class="bg-warning" nowrap>座位数</th>
<td><input name="seats" class="form-control" style="width:100%;" type="text" value="<?=$order_info->seats ? $order_info->seats:$car_info->seats?>"></td>
<th class="bg-warning" nowrap>电子邮件</th>
<td><input name="email" class="form-control" style="width:100%;" type="text" value="<?=$order_info->email?>"></td>
</tr>
<tr>
<th class="bg-warning">车架号</th>
<td><input name="car_frame_no" class="form-control" style="width:100%;" type="text" value="<?=$order_info->car_frame_no!='' ? $order_info->car_frame_no:$car_info->car_frame_no?>"></td>
<th class="bg-warning" nowrap>发动机号</th>
<td><input name="engine_no" class="form-control date" style="width:100%;" type="text" value="<?=$order_info->engine_no!='' ? $order_info->engine_no:$car_info->engine_no?>"></td>
<th class="bg-warning" nowrap>厂牌型号</th>
<td><input name="factory_model" class="form-control" style="width:100%;" type="text" value="<?=$order_info->factory_model!='' ? $order_info->factory_model:$car_info->factory_model?>"></td>
<th class="bg-warning" nowrap>新车购置价</th>
<td><input name="purchase_price" class="form-control" style="width:100%;" type="text" value="<?=$order_info->purchase_price!='' ? $order_info->purchase_price:$car_info->purchase_price?>"></td>
</tr>
<tr>
<th class="bg-warning">车主</th>
<td><input name="car_man" class="form-control" style="width:100%;" type="text" value="<?=$order_info->car_man!='' ? $order_info->car_man:$car_info->car_man?>"></td>
<th class="bg-warning">证件类型</th>
<td>
<select name="car_man_type" class="form-control">
<option value="身份证">身份证</option>
<option value="营业执照">营业执照</option>
</select>
</td>
<th class="bg-warning" nowrap>证件号码</th>
<td><input name="car_man_number" class="form-control" style="width:100%;" type="text" value="<?=$order_info->car_man_number!='' ? $order_info->car_man_number:$car_info->car_man_number?>"></td>
<th class="bg-warning">联系电话</th>
<td><input name="car_man_phone" class="form-control" style="width:100%;" type="text" value="<?=$order_info->car_man_phone!='' ? $order_info->car_man_phone:$car_info->phone?>"></td>
</tr>
<tr>
<th class="bg-warning">被保险人</th>
<td><input name="id_man" class="form-control" style="width:100%;" type="text" value="<?=$order_info->id_man!='' ? $order_info->id_man:$car_info->id_man?>"></td>
<th class="bg-warning">证件类型</th>
<td>
<select name="id_man_type" class="form-control">
<option value="身份证">身份证</option>
<option value="营业执照">营业执照</option>
</select>
</td>
<th class="bg-warning">证件号码</th>
<td><input name="id_man_number" class="form-control" style="width:100%;" type="text" value="<?=$order_info->id_man_number!='' ? $order_info->id_man_number:$car_info->id_number?>"></td>
<th class="bg-warning">联系电话</th>
<td><input name="id_man_phone" class="form-control" style="width:100%;" type="text" value="<?=$order_info->id_man_phone!='' ? $order_info->id_man_phone:$car_info->id_phone?>"></td>
</tr>
<tr>
<th class="bg-warning">投保人</th>
<td><input name="link_man" class="form-control" style="width:100%;" type="text" value="<?=$order_info->link_man!='' ? $order_info->link_man:''?>"></td>
<th class="bg-warning">证件类型</th>
<td>
<select name="link_man_type" class="form-control">
<option value="身份证">身份证</option>
<option value="营业执照">营业执照</option>
</select>
</td>
<th class="bg-warning">证件号码</th>
<td><input name="link_man_number" class="form-control" style="width:100%;" type="text" value="<?=$order_info->link_man_number!='' ? $order_info->link_man_number:''?>"></td>
<th class="bg-warning">联系电话</th>
<td><input name="link_man_phone" class="form-control" style="width:100%;" type="text" value="<?=$order_info->link_man_phone!='' ? $order_info->link_man_phone:''?>"></td>
</tr>
<tr>
<th class="bg-warning" nowrap>商业起保日期</th>
<td>
<input type="text" id="insurer1_begin_date" name="insurer1_begin_date" class="form-control date" value="<?=$order_info->insurer1_begin_date?>" autocomplete="off">
</td>
<th class="bg-warning" nowrap>交强起保日期</th>
<td>
<input type="text" id="insurer2_begin_date" name="insurer2_begin_date" class="form-control date" value="<?=$order_info->insurer2_begin_date?>" autocomplete="off">
</td>
<th class="bg-warning">保险公司</th>
<td>
<select name="company_id" id="company_id" class="form-control">
<option value="0">---请选择---</option>
<?php
foreach($insurer_company_items as $item) {
echo '<option value="'.$item->id.'"';
if($item->id == $order_info->company_id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
</td>
<th class="bg-warning">车辆使用性质</th>
<td class="form-inline" nowrap>
<select name="car_use_id" id="car_use_id" class="form-control">
<option value="0">---请选择---</option>
<?php
foreach($car_use_items as $item) {
echo '<option value="'.$item->id.'"';
if($item->id == $order_info->car->car_use_id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
</td>
</tr>
</table>
</div>
</div>
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>险种</h5>
</div>
<div class="ibox-content">
<table class="table table-bordered">
<tr>
<?php
$len = count($insurer_type_items);
for($i = 0; $i < $len; $i++) {
$item = $insurer_type_items[$i];
$order_id = $order_info->id;
if(!$order_id)
$order_id = 0;
$tmp_row = PriceT::find()
->where('order_id='.$order_id.' and type_id='.$item->id)
->one();
?>
<th class="bg-warning">
<?=$item->name?>(<?=$item->code?>)
</th>
<td>
<?php
if($item->content != '') {
$tmp_items = explode(',',$item->content);
echo '<select name="types['.$item->id.']" class="form-control insurer-select" data-id="'.$item->id.'">';
$tmp_items = explode(',',$item->content);
foreach($tmp_items as $tmp_item) {
echo '<option';
if(!empty($tmp_row) && $tmp_row->val == $tmp_item)
echo ' selected ';
echo '>'.$tmp_item.'</option>';
}
echo '</select>';
} else {
echo '<input name="types['.$item->id.']" class="form-control insurer-input" data-id="'.$item->id.'" style="width:100px;" type="text"';
if(!empty($tmp_row))
echo ' value="'.$tmp_row->val.'" ';
echo '>';
}
?>
</td>
<td>
<?php if($item->has_nopay == 1) { ?>
<div class="checkbox checkbox-inline">
<input type="checkbox" name="nopays[<?=$item->id?>]" id="nopays_<?=$item->id?>" value="1" <?=(!empty($tmp_row) && $tmp_row->is_nopay == 1)?'checked':''?>>
<label for="nopays_<?=$item->id?>"> 不计免赔 </label>
</div>
<?php } ?>
</td>
<?php
if(($i+1)%3==0) {
echo '</tr>';
echo '<tr>';
}
}
?>
</tr>
</table>
</div>
</div>
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>保费信息</h5>
<div class="ibox-tools">
<a class="btn btn-primary btn-xs" data-id="0" href="javascript:void(0);" onclick="getYingXiao();">
<i class="fa fa-gift"></i> 获取策略
</a>
</div>
</div>
<div class="ibox-content">
<table class="table table-bordered">
<tr>
<th class="bg-warning">商业总净保费</th>
<td><input name="total1_clear" id="total1_clear" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total1_clear?>"></td>
<th class="bg-warning">商业含税总保费</th>
<td><input name="total1" id="total1" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total1?>"></td>
<th class="bg-warning">车船税</th>
<td><input name="total3" id="total3" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total3?>"></td>
</tr>
<tr>
<th class="bg-warning">交强总净保费</th>
<td><input name="total2_clear" id="total2_clear" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total2_clear?>"></td>
<th class="bg-warning">交强含税总保费</th>
<td><input name="total2" id="total2" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total2?>"></td>
<th class="bg-warning">业务自付金额</th>
<td><input name="yuangong_money" id="yuangong_money" class="form-control" style="width:120px;" type="text" value="<?=$order_info->yuangong_money?>"></td>
</tr>
<tr>
<th class="bg-warning">折扣后商业净保费</th>
<td><input name="total1_real" id="total1_real" class="form-control" readonly style="width:120px;" type="text" value="<?=$order_info->total1_real?>"></td>
<th class="bg-warning">减免金额</th>
<td><input name="total1_dis" id="total1_dis" class="form-control" readonly style="width:120px;" type="text" value="<?=$order_info->total1_dis?>"></td>
<th class="bg-warning">商业折扣率</th>
<td><input name="total1_percent" id="total1_percent" class="form-control" readonly style="width:120px;" type="text" value="<?=$order_info->total1_percent?>"></td>
</tr>
<tr>
<th class="bg-warning">共计签单</th>
<td><input name="total_all" id="total_all" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total_all?>"></td>
<th class="bg-warning">应收</th>
<td><input name="total_real" id="total_real" class="form-control" style="width:120px;" type="text" value="<?=$order_info->total_real?>"></td>
<th class="bg-warning">支付方式</th>
<td>
<select name="pay_type_id" id="pay_type_id" class="form-control">
<option value="0">---请选择---</option>
<?php
foreach($pay_type_items as $item) {
echo '<option value="'.$item->id.'"';
if($item->id == $order_info->pay_type_id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<th class="bg-warning">备注</th>
<td colspan="5"><input name="price_remark" id="price_remark" class="form-control" style="width:100%;" type="text" value="<?=$order_info->price_remark?>"></td>
</tr>
<tr>
<th class="bg-warning">短信</th>
<td colspan="5">
<div class="row">
<div class="col-sm-12">
<textarea name="sms-msg" id="sms-msg" class="form-control"></textarea>
</div>
</div>
<div class="row" style="margin-top: 8px;">
<div class="col-sm-12 form-inline">
<label>手机号码</label>
<input type="text" name="sms-tel" id="sms-tel" class="form-control">
<button type="button" class="btn btn-primary sms-make-btn">生成短信</button>
<button type="button" class="btn btn-danger sms-send-btn">发送短信</button>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
<div id="gifts">
</div>
<div id="quans">
</div>
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>其他信息</h5>
</div>
<div class="ibox-content">
<table class="table table-bordered">
<tr>
<th class="bg-warning">领款人</th>
<td><input name="money_man" class="form-control" style="width:100%;" type="text" value="<?=$order_info->money_man?>"></td>
<th class="bg-warning">开户行</th>
<td><input name="money_bank" class="form-control" style="width:100%;" type="text" value="<?=$order_info->money_bank?>"></td>
<th class="bg-warning">银行账号</th>
<td><input name="money_no" class="form-control" style="width:100%;" type="text" value="<?=$order_info->money_no?>"></td>
</tr>
<tr>
<th class="bg-warning">送单地址</th>
<td colspan="5" class="form-inline">
<select name="send_city_id" class="form-control">
<option value="0">选择城市</option>
<?php
foreach($city_items as $item) {
echo '<option value="'.$item->id.'"';
if($order_info->send_city_id == $item->id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
<select name="send_district_id" class="form-control">
<option value="0">选择区县</option>
<?php
foreach($district_items as $item) {
echo '<option value="'.$item->id.'"';
if($order_info->send_district_id == $item->id)
echo ' selected ';
echo '>'.$item->name.'</option>';
}
?>
</select>
<input type="text" name="send_address" class="form-control" style="width:70%;" value="<?=$order_info->send_address?>">
</td>
</tr>
<tr>
<th class="bg-warning">备注</th>
<td colspan="7"><input name="order_remark" class="form-control" style="width:100%;" type="text" value="<?=$order_info->remark?>"></td>
</tr>
</table>
<div>
<div class="row">
<div class="col-md-5 col-md-offset-5">
<button type="button" class="btn btn-primary btn-save" type="button">
<strong>保 存</strong>
</button>
<button type="button" class="btn btn-primary btn-submit" type="button">
<strong>提 交</strong>
</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<?php $this->beginBlock('footer_js'); ?>
<script>
var o = {};
var fanxian_rate = 0, max_fanxian = 0;
//获取策略
function getYingXiao() {
var params = $('#orderFrm').serialize();
$.post('/marketing-strategy/get-yingxiao', params, function(obj) {
if(obj.success) {
$('#celuo_id').val(obj.celuo_id);
if(obj.num > 1) {
layer_show('选择策略', '/marketing-strategy/select-fanxian?ids=' + obj.ids);
} else {
selectFanxian(obj.ids);
}
} else {
parent.layer.msg(obj.msg);
}
}, 'json');
}
function selectFanxian(fanxian_id) {
$('#fanxian_id').val(fanxian_id);
getGifts(fanxian_id);
$.get('/marketing-strategy/get-fanxian?fanxian_id=' + fanxian_id, function(obj) {
if(obj.success) {
fanxian_rate = obj.fanxian_rate;
max_fanxian = obj.max_fanxian;
calc();
}
}, 'json');
}
function getGifts(fanxian_id) {
$('#gifts').html('');
$.get('/marketing-strategy/get-gifts?type=1&order_id=<?=$order_info->id?>&fanxian_id=' + fanxian_id, function(obj){
if(obj.success) {
var html = '<div class="ibox float-e-margins">';
html += '<div class="ibox-title">';
html += '<h5>礼品</h5>';
html += '</div>';
html += '<div class="ibox-content">';
obj.gifts.forEach(function(item, index) {
html += '<table class="table table-bordered">';
html += '<tr>';
html += '<th class="bg-warning">' + item.free_type + '</th>';
html += '</tr>';
html += '<tr>';
html += '<td>';
item.gifts.forEach(function(sub_item, sub_index) {
html += '<div class="checkbox checkbox-inline">';
html += '<input type="checkbox" id="gift_' + item.id + '_' + sub_item.id + '" name="gift_ids[]" value="' + item.id + '-' + sub_item.id + '"';
if(sub_item.selected == 1)
html += ' checked ';
html += '>';
html += '<label for="gift_' + item.id + '_' + sub_item.id + '">' + sub_item.name + '</label>';
html += '&nbsp;<a href="' + sub_item.original_img + '" target="_blank" title="预览"> <i class="fa fa-image"></i> </a>';
html += '</div>';
});
html += '</td>';
html += '</tr>';
html += '</table>';
});
html += '</div>';
html += '</div>';
$('#gifts').html(html);
} else {
// parent.layer.msg(obj.msg);
}
}, 'json');
$('#quans').html('');
$.get('/marketing-strategy/get-gifts?type=2&order_id=<?=$order_info->id?>&fanxian_id=' + fanxian_id, function(obj){
if(obj.success) {
var html = '<div class="ibox float-e-margins">';
html += '<div class="ibox-title">';
html += '<h5>礼券</h5>';
html += '</div>';
html += '<div class="ibox-content">';
obj.gifts.forEach(function(item, index) {
html += '<table class="table table-bordered">';
html += '<tr>';
html += '<th class="bg-warning">' + item.free_type + '</th>';
html += '</tr>';
html += '<tr>';
html += '<td>';
item.gifts.forEach(function(sub_item, sub_index) {
html += '<div class="checkbox checkbox-inline">';
html += '<input type="checkbox" id="gift_' + item.id + '_' + sub_item.id + '" name="gift_ids[]" value="' + item.id + '-' + sub_item.id + '"';
if(sub_item.selected == 1)
html += ' checked ';
html += '>';
html += '<label for="gift_' + item.id + '_' + sub_item.id + '">' + sub_item.name + '</label>';
html += '&nbsp;<a href="' + sub_item.original_img + '" target="_blank" title="预览"> <i class="fa fa-image"></i> </a>';
html += '</div>';
});
html += '</td>';
html += '</tr>';
html += '</table>';
});
html += '</div>';
html += '</div>';
$('#quans').html(html);
} else {
//parent.layer.msg(obj.msg);
}
}, 'json');
}
//判断是否填写了选项
function isNull(data){
if(data == "" || data == undefined || data == null){
return true;
}else{
return false;
}
}
//报价计算
function calc() {
var total1_clear = Number($('#total1_clear').val());
var total1 = Number($('#total1').val());
var total2_clear = Number($('#total2_clear').val());
var total2 = Number($('#total2').val());
var total3 = Number($('#total3').val());
var total1_real = Number($('#total1_real').val());
var total1_dis = Number($('#total1_dis').val());
var total1_percent = Number($('#total1_percent').val());
var total_all = Number($('#total_all').val());
var total_real = Number($('#total_real').val());
var yuangong_money = Number($('#yuangong_money').val());
total_all = total1 + total2 + total3;
total1_real = total1_clear * ( 1 - fanxian_rate) - yuangong_money;
total1_dis = total1_clear * fanxian_rate;
total_real = total_all - total1_dis - yuangong_money;
total1_percent = parseFloat(total1_real/total1_clear);
$('#total1_real').val(total1_real.toFixed(2));
$('#total1_dis').val(total1_dis.toFixed(2));
$('#total1_percent').val(total1_percent.toFixed(2));
$('#total_all').val(total_all.toFixed(2));
$('#total_real').val(total_real.toFixed(2));
}
//保存订单
function saveOrder(status_id) {
var params = $('#orderFrm').serialize();
params = params + '&status_id=' + status_id;
$.post('/car/order-save',params,function(obj){
parent.layer.msg(obj.msg);
if(obj.success && status_id>1) {
layer_close();
}
},'json');
}
$(function() {
//绑定日期控件
$('.date').datepicker({
todayBtn: "linked",
keyboardNavigation: false,
forceParse: false,
calendarWeeks: true,
autoclose: true
});
//险种选择框事件
$('.insurer-select').change(function() {
var id = $(this).data('id');
var val = $(this).val();
if(val !== '否') {
$('#nopays_' + id).prop('checked', 'checked');
} else {
$('#nopays_' + id).prop('checked', '');
}
});
//险种输入框事件
$('.insurer-input').change(function() {
var id = $(this).data('id');
var val = $(this).val();
if(val !== '') {
$('#nopays_' + id).prop('checked', 'checked');
} else {
$('#nopays_' + id).prop('checked', '');
}
});
getGifts(<?=$order_info->fanxian_id?>);
$('#total1_clear').blur(function(){
$('#total1').val(($(this).val() * 1.06).toFixed(2));
calc();
});
$('#total1').blur(function(){
$('#total1_clear').val(($(this).val()/1.06).toFixed(2));
calc();
});
$('#total2_clear').blur(function(){
$('#total2').val(($(this).val() * 1.06).toFixed(2));
calc();
});
$('#total2').blur(function(){
$('#total2_clear').val(($(this).val()/1.06).toFixed(2));
calc();
});
$('#yuangong_money').blur(function(){
calc();
});
//生成短信内容
$('.sms-make-btn').click(function(){
var params = $('#orderFrm').serialize();
var baoxiangs=$('#company_id').val();
var smstel=$('#sms-tel').val();
if(isNull(smstel)){
parent.layer.msg('请填写电话号码');
return ;
}
if(baoxiangs==0){
parent.layer.msg('请选择保险公司');
return ;
}
$.post('/car/sms-make',params,function(obj){
if(obj.success) {
$('#sms-msg').val(obj.msg);
} else {
parent.layer.msg(obj.msg);
}
},'json');
});
//发送短信内容
$('.sms-send-btn').click(function(){
var tel = $('#sms-tel').val();
var msg = $('#sms-msg').val();
var baoxiangs=$('#company_id').val();
var smstel=$('#sms-tel').val();
var smsmsg=$('#sms-msg').val();
if(smsmsg==''){
parent.layer.msg('短信内容不能为空,请生成短信');
return ;
}
if(isNull(smstel)){
parent.layer.msg('请填写电话号码');
return ;
}
if(baoxiangs==0){
parent.layer.msg('请选择保险公司');
return ;
}
// return;
$.post('/car/sms-send',{tel:tel,msg:msg,company_id:baoxiangs},function(obj){
parent.layer.msg(obj.msg);
},'json');
});
$('.btn-save').click(function(){
saveOrder(1);
});
$('.btn-submit').click(function(){
saveOrder(2);
});
});
</script>
<?php $this->endBlock(); ?>