js:
<script type="text/javascript">
$(function(){
$('#orderDate').change(function(){
var user_name=$('#seller').val();
var date=$('#orderDate').val();
var table='c1';
ajax(user_name,date,table);
})
$('#seller').change(function(){
var user_name=$('#seller').val();
var date=$('#orderDate').val();
var table='c1';
ajax(user_name,date,table);
})
})
function ajax(user_name,date,table){
//alert(table);return;
var inputchange=$('#inputchange').val();
$.post(inputchange,{user_name:user_name,date:date,table:table},function(res){
if(res=='0'){
return false;
}
var re=$.parseJSON(res); //js转json对象
$('#basis').val(parseInt(re.basicPerformance)); //parseInt 转int类型
$('#arrival').val(re.datas);
$('#arrivalcount').val(re.ordersum);
$('#paymentmoney').val(re.datas1);
$('#paymentmoneycount').val(re.ordersum1);
})
}
</script>
php:
<input id='inputchange' type='hidden' value='<?php echo str_replace('.html','',helper::createLink('crm.order', 'ajax', ""));?>'/> //设置隐藏的跳转路径
<table class='table table-form'>
<tr>
<th class='w-60px'>接单人</th>
<td><?php echo html::select('seller', $sellers, '', "class='form-control' style='width:300px'");?></td>
</tr>
<tr>
<th class='w-60px'>选择日期</th>
<td><?php echo html::input('orderDate', '', "class='form-control form-date' style='width:300px'");?></td>
</tr>
<tr>
<th class='w-60px'>基础绩效</th>
<td><?php echo html::input('basis', '', "class='form-control' style='width:300px'");?></td>
</tr>
<tr>
<th class='w-60px'>到账金额</th>
<td><?php echo html::input('arrival', '', "class='form-control' style='width:300px'");?></td>
</tr>
<tr>
<th class='w-60px'>到账笔数</th>
<td><?php echo html::input('arrivalcount', '', "class='form-control' style='width:300px'");?></td>
</tr>
<tr>
<th class='w-60px'>支付金额</th>
<td><?php echo html::input('paymentmoney', '', "class='form-control' style='width:300px'");?></td>
</tr>
<tr>
<th class='w-60px'>支付笔数</th>
<td><?php echo html::input('paymentmoneycount', '', "class='form-control ' style='width:300px'");?></td>
</tr>
</table>
control中 ajax 方法:
public function ajax(){
//print_r($_POST['table']);
if($_POST['table']=='c1'){
$basicPerformance=0;
if($_POST['user_name']!="" && $_POST['date']!=""){
//到账金额 、笔数
$data=$this->dao->select('price,paymentChannel')->from(TABLE_ORDERC1)
->where('seller')->eq($_POST['user_name'])
->andWhere('arrivalDate')->eq($_POST['date'])
->andWhere('deleted')->eq(0)
->fetchAll();
$datas=0;
$ordersum=0;
foreach ($data as $v){
if($v->paymentChannel=='tbhs'){
$ordersum=$ordersum+1;
}
$datas +=$v->price;
}
//支付金额 、笔数
$data1=$this->dao->select('price,paymentChannel')->from(TABLE_ORDERC1)
->where('seller')->eq($_POST['user_name'])
->andWhere('orderDate')->eq($_POST['date'])
->andWhere('deleted')->eq(0)
->fetchAll();
$datas1=0;
$ordersum1=0;
foreach ($data1 as $v){
if($v->paymentChannel=='tbhs'){
$ordersum1=$ordersum1+1;
}
$datas1 +=$v->price;
}
$basicPerformance=$datas*PFMRATE3+70*$ordersum+$datas1*PFMRATE1+70*$ordersum1;
$money['datas']=$datas; //到账金额
$money['ordersum']=$ordersum; //到账笔数
$money['datas1']=$datas1; //支付金额
$money['ordersum1']=$ordersum1;//支付笔数
$money['basicPerformance']=$basicPerformance;//基础绩效
$res=json_encode($money);
echo $res;
}else{
echo 0;
}
}