<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
$title = '定投推广价格设置';
$typeArr = array('ASchool','BSchool','GreatBroker');
$request  = new Request();
$vasPrice = new VasPrice();

if($request->isAjax()) {
   
    $priceArr[] = array('type'=>'ASchool','cost_price'=>intval($_POST['cost_priceA']), 'current_price'=> intval($_POST['current_priceA']));
    $priceArr[] = array('type'=>'BSchool','cost_price'=>intval($_POST['cost_priceB']), 'current_price'=> intval($_POST['current_priceB']));
    $priceArr[] = array('type'=>'GreatBroker','cost_price'=>intval($_POST['cost_priceC']), 'current_price'=> intval($_POST['current_priceC']));
 
    if(CommonBase::isFullArray($priceArr)){
        $updateNum = 0;
        foreach ($priceArr as $value){         
             $num = $vasPrice->saveData($value);
             $updateNum += $num;
        }        
        
    }
    if($updateNum>0) {
        //写操作日志
        $operateRecord->insertData('0', 'update', 
                '更新定投推广价格'.$updateNum.'成功', $_SESSION['esfadmin']['username']);
        echo json_encode(array('result'=>1));
    }else {
        //写操作日志
        $operateRecord->insertData('0', 'update', 
                '更新定投推广价格'.$updateNum.'失败', $_SESSION['esfadmin']['username']);
        echo json_encode(array('result'=>0));
    }
    exit;
   
    
    
    
}else{
    $vasPriceArr = $vasPrice->findByTypeArr($typeArr);
    if(is_array($vasPriceArr)&&!empty($vasPriceArr)){
        foreach ($vasPriceArr as $key=>$value){     
            $newVasPriceArr[$value['type']] = $value;
        }    
    }
    
    include_once(Template("header"));
    include_once(Template("vas/set_promot_price"));
    include_once(Template("footer"));

}









