<?php


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


if($_POST['action'] =='save') {
    if($_POST['data']) {
        $data = $_POST['data'];
        
       $vasSetPromotRecord = new VasSetPromotRecord();
       $id = intval($data['id']);
       $conf_where = "id = ".$id;
       if($data['status']==2){
           $fieldData['start_time'] = $data['stime'];
           $fieldData['end_time'] = $data['etime'];
           
       }
       $fieldData['status'] = intval($data['status']);
       $returnNum = $vasSetPromotRecord->update($fieldData, $conf_where);
       if($returnNum>0){
            if($data['status']==2){
                $type = $vasSetPromotRecord->findTypeByRecordId($id);
                //某类型排队人数减一
                $vasqueue = new VasQueueLimit();
                $vasqueue->addNumberToOneType($type,-1);
            }
            //定投推广设置
            $logMessage = "定投推广设置,data:".  json_encode($data);
            $operateRecord->insertData('', 'update', 
            $logMessage, $_SESSION['esfadmin']['username']);
           
       }
       
   
    }
}


if($_POST['action'] =='savepacking') {
    if($_POST['data']) {
        $data = $_POST['data'];

       $VasRecord = new VasRecord('vas_packing_house_record');
       $id = intval($data['id']);
       $conf_where = "id = ".$id;
       if($data['status']==2){
           $fieldData['start_time'] = $data['stime'];
           $fieldData['end_time'] = $data['etime'];

       }
       $fieldData['status'] = intval($data['status']);
       $returnNum = $VasRecord->update($fieldData, $conf_where);
       if($returnNum>0){
            if($data['status']==2){
                $type = $VasRecord->findTypeByRecordId($id);
                //某类型排队人数减一
                $vasqueue = new VasQueueLimit();
               
                $vasqueue->addNumberToOneType($type,-1);
            }
            //定投推广设置
            $logMessage = "房源包装设置,data:".  json_encode($data);
            $operateRecord->insertData('', 'update',
            $logMessage, $_SESSION['esfadmin']['username']);

       }


    }
}
$result = array('result'=>'1');
echo json_encode($result);