<?php

$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");


$title = "贷款赠送房豆修改";
$zsbLoanReward = new ZsbLoanReward();
$redirect_url = "loan_reward.php";
if($action =="modify"){
    
    $data_info = $zsbLoanReward->findById($id);
   
    if (count($data_info) == 0)
    echo "<script>alert('没有发现您查询的记录');location.href = '".$redirect_url."';</script>";
    $action = "update";
}elseif ($action =="insert") {
    //添加   
    
    $fieldData = array('name'=>$name,'reward_credit'=>$reward_credit,'remark'=>$remark);
    $return_value = $zsbLoanReward->insert($fieldData);

    if($return_value>0){
        echo "<script>alert('添加成功！');location.href = '".$redirect_url."';</script>";
    }else{exit;
        echo "<script>alert('添加失败！');location.href = '".$redirect_url."';</script>";
    }
        
    
}elseif ($action == "update") {  

    $fields = array('id'=>$id,'name'=>$name,'reward_credit'=>$reward_credit,'remark'=>$remark);  
    $return_value = $zsbLoanReward->saveData($fields);
    if($return_value>0){
        echo "<script>alert('修改成功！');location.href = '".$redirect_url."';</script>";
    }else{
        echo "<script>alert('修改失败！');location.href = '".$redirect_url."';</script>";
    }
    
}elseif ($action == "delete") {
    $return_value = $loanProduct->delBy("id=$id");
    if($return_value>0){
        echo "<script>alert('删除成功！');location.href =  '".$redirect_url."';</script>";
    }else{
        echo "<script>alert('删除失败！');location.href =  '".$redirect_url."';</script>";
    }
    
}elseif ($action == "add") {
    $action = 'insert';
}


include_once(Template("header"));
include_once(Template("loan/loan_reward_modify"));
include_once(Template("footer"));