<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Carrier
{
	function Carrier()
	{
		//$GLOBALS['WebSe'] -> isOnLine();
	}
	
	function infolist(  )
	{
		$pageSize = 20 ;		$pageNumval 	= $GLOBALS['Reque'] -> reqval["pageNum"];
		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}

		//帐号 	真实姓名 	Email地址 	登录次数 	加入时间 	最后登录时间
		
		$sqlQuery = " SELECT carrier_id, chance_id, carrier_date, carrier_item, carrier_result  FROM  ".SQL_PREFIX."carrier  WHERE 1 GROUP BY carrier_id ORDER BY `carrier_id` LIMIT  $LIMITnum , $pageSize ";
		
		$info = $GLOBALS['MySql'] -> selectInfo($sqlQuery);
		
		$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."carrier  WHERE 1  ORDER BY `carrier_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		//var_dump($info);
		
		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=carrier&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"] );
		
		$GLOBALS['Templ']->assign('ADMIN_BASEUSER',ADMIN_BASEUSER);
		
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		$GLOBALS['Templ']->display('carrier_tpl.html');
		
	}
	
	function add(  )
	{
		$GLOBALS['Templ'] -> caching = true;
		$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php/carrier/addinfo");
		$GLOBALS['Templ']->display('carrieradd_tpl.html');
	}

	
	function addinfo()
	{
		$carrier_nameval 		= $GLOBALS['Reque'] -> funpost("carrier_name");
		$carrier_pinyinval 		= $GLOBALS['Reque'] -> funpost("carrier_pinyin");
		$carrier_areaval 		= $GLOBALS['Reque'] -> funpost("carrier_area");
		
		$carrier_addressval 	= $GLOBALS['Reque'] -> funpost("carrier_address");
		$carrier_zipval 		= $GLOBALS['Reque'] -> funpost("carrier_zip");
		$carrier_telval 		= $GLOBALS['Reque'] -> funpost("carrier_tel");
		$carrier_faxval 		= $GLOBALS['Reque'] -> funpost("carrier_fax");
		
		$carrier_websiteval 	= $GLOBALS['Reque'] -> funpost("carrier_website");
		$carrier_emailval 		= $GLOBALS['Reque'] -> funpost("carrier_email");
		$carrier_licenceval 	= $GLOBALS['Reque'] -> funpost("carrier_licence");
		$carrier_chieftainval 	= $GLOBALS['Reque'] -> funpost("carrier_chieftain");
		$carrier_bankrollval 	= $GLOBALS['Reque'] -> funpost("carrier_bankroll");
		$carrier_turnoverval 	= $GLOBALS['Reque'] -> funpost("carrier_turnover");
		$carrier_bankval 		= $GLOBALS['Reque'] -> funpost("carrier_bank");
		
		$carrier_bankaccountval 	= $GLOBALS['Reque'] -> funpost("carrier_bankaccount");
		$carrier_localtaxnoval 	= $GLOBALS['Reque'] -> funpost("carrier_localtaxno");
		$carrier_nationaltaxnoval 	= $GLOBALS['Reque'] -> funpost("carrier_nationaltaxno");
		$carrier_manageridval 		= $GLOBALS['Reque'] -> funpost("carrier_managerid");
		$carrier_levelval 			= $GLOBALS['Reque'] -> funpost("carrier_level");
		$carrier_satisfyval 		= $GLOBALS['Reque'] -> funpost("carrier_satisfy");
		$carrier_creditval 		= $GLOBALS['Reque'] -> funpost("carrier_credit");
		$carrier_losecountval 		= $GLOBALS['Reque'] -> funpost("carrier_losecount");
		$carrier_statusval 		= $GLOBALS['Reque'] -> funpost("carrier_status");
		
		
		$carrier_regtimeval 	= time();
		
		if($carrier_nameval !='' and $carrier_emailval !='' and $carrier_telval !='' and $carrier_pinyinval !='' )
		{
			$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."carrier  WHERE carrier_name = '".$carrier_nameval."' ORDER BY `carrier_id` ";
			
			$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
			
			if( $info["CNUM"] < 1 )
			{
				
				$insertip ="INSERT INTO `".SQL_PREFIX."carrier` (`carrier_name` , `carrier_pinyin` , `carrier_area` , `carrier_address` , `carrier_zip`, `carrier_tel` , `carrier_fax` , `carrier_website` , `carrier_email` , `carrier_licence` , `carrier_chieftain` , `carrier_bankroll` , `carrier_turnover`, `carrier_bank` , `carrier_bankaccount` , `carrier_localtaxno` , `carrier_nationaltaxno` , `carrier_managerid`, `carrier_level` , `carrier_satisfy` , `carrier_credit` , `carrier_losecount`  , `carrier_status` ) VALUES (  '$carrier_nameval', '$carrier_pinyinval', '$carrier_areaval', '$carrier_addressval', '$carrier_zipval', '$carrier_telval', '$carrier_faxval', '$carrier_websiteval', '$carrier_emailval', '$carrier_licenceval', '$carrier_chieftainval', '$carrier_bankrollval', '$carrier_turnoverval', '$carrier_bankval', '$carrier_bankaccountval', '$carrier_localtaxnoval', '$carrier_nationaltaxnoval', '$carrier_manageridval', '$carrier_levelval', '$carrier_satisfyval', '$carrier_creditval', '$carrier_losecountval', '$carrier_statusval')";

				$GLOBALS['MySql'] -> querySql($insertip);
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/carrier/infolist");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
				
			}else{
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_isrealyerror']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/carrier/add/");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
			}
			
			
		}else{
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/carrier/add/");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');		}
			//var_dump($_REQUEST);
	}
	
	function del( )
	{
		$indel = implode(',', $delArray);

		//$deletesql ="DELETE FROM `carrier` WHERE `carrier`.`carrier_id` in ( $indel ) and carrier_name != '".ADMIN_BASEUSER."' ";
		$deletesql ="UPDATE `".SQL_PREFIX."carrier` SET  carrier_status = 5 WHERE `carrier`.`carrier_id` IN ( $indel )  ";
		
		$GLOBALS['MySql'] -> querySql($deletesql);
		
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/carrier/infolist/");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function info(  )
	{
		$infoid = $infoArray[0];
		
		$sqlQuery = " SELECT *  FROM  ".SQL_PREFIX."carrier  WHERE carrier_id = '".$infoid."' ORDER BY `carrier_id` ";
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
				
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php/carrier/editinfo");
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('carrieredit_tpl.html');
	
	}
	
	
	function editinfo( )
	{	
	
		$carrier_idval 		= $GLOBALS['Reque'] -> funpost("carrier_id");
		$carrier_nameval 		= $GLOBALS['Reque'] -> funpost("carrier_name");
		$carrier_pinyinval 	= $GLOBALS['Reque'] -> funpost("carrier_pinyin");
		$carrier_areaval 		= $GLOBALS['Reque'] -> funpost("carrier_area");
		
		$carrier_addressval 	= $GLOBALS['Reque'] -> funpost("carrier_address");
		$carrier_zipval 		= $GLOBALS['Reque'] -> funpost("carrier_zip");
		$carrier_telval 		= $GLOBALS['Reque'] -> funpost("carrier_tel");
		$carrier_faxval 		= $GLOBALS['Reque'] -> funpost("carrier_fax");
		
		$carrier_websiteval 	= $GLOBALS['Reque'] -> funpost("carrier_website");
		$carrier_emailval 		= $GLOBALS['Reque'] -> funpost("carrier_email");
		$carrier_licenceval 	= $GLOBALS['Reque'] -> funpost("carrier_licence");
		$carrier_chieftainval 	= $GLOBALS['Reque'] -> funpost("carrier_chieftain");
		$carrier_bankrollval 	= $GLOBALS['Reque'] -> funpost("carrier_bankroll");
		$carrier_turnoverval 	= $GLOBALS['Reque'] -> funpost("carrier_turnover");
		$carrier_bankval 		= $GLOBALS['Reque'] -> funpost("carrier_bank");
		
		$carrier_bankaccountval 	= $GLOBALS['Reque'] -> funpost("carrier_bankaccount");
		$carrier_localtaxnoval 	= $GLOBALS['Reque'] -> funpost("carrier_localtaxno");
		$carrier_nationaltaxnoval 	= $GLOBALS['Reque'] -> funpost("carrier_nationaltaxno");
		$carrier_manageridval 		= $GLOBALS['Reque'] -> funpost("carrier_managerid");
		$carrier_levelval 			= $GLOBALS['Reque'] -> funpost("carrier_level");
		$carrier_satisfyval 		= $GLOBALS['Reque'] -> funpost("carrier_satisfy");
		$carrier_creditval 		= $GLOBALS['Reque'] -> funpost("carrier_credit");
		$carrier_losecountval 		= $GLOBALS['Reque'] -> funpost("carrier_losecount");
		$carrier_statusval 		= $GLOBALS['Reque'] -> funpost("carrier_status");
		
		
		$addsetUp = '';
		
		if($carrier_idval !='' and $carrier_nameval !='' )
		{

			$updatecus = "UPDATE `".SQL_PREFIX."carrier` SET  carrier_name = '".$carrier_nameval."' , carrier_pinyin = '".$carrier_pinyinval."' 
			, carrier_area = '".$carrier_areaval."'
			, carrier_address = '".$carrier_addressval."'
			, carrier_zip = '".$carrier_zipval."'
			, carrier_tel = '".$carrier_telval."'
			, carrier_fax = '".$carrier_faxval."'
			, carrier_website = '".$carrier_websiteval."'
			, carrier_email = '".$carrier_emailval."'
			, carrier_licence = '".$carrier_licenceval."'
			, carrier_chieftain = '".$carrier_chieftainval."'
			, carrier_bankroll = '".$carrier_bankrollval."'
			, carrier_turnover = '".$carrier_turnoverval."'
			, carrier_bank = '".$carrier_bankval."'
			, carrier_bankaccount = '".$carrier_bankaccountval."'
			, carrier_localtaxno = '".$carrier_localtaxnoval."'
			, carrier_nationaltaxno = '".$carrier_nationaltaxnoval."'
			, carrier_managerid = '".$carrier_manageridval."'
			, carrier_level = '".$carrier_levelval."'
			, carrier_satisfy = '".$carrier_satisfyval."'
			, carrier_credit = '".$carrier_creditval."'
			, carrier_losecount = '".$carrier_losecountval."'
			, carrier_status = '".$carrier_statusval."'			
			 WHERE  carrier_id = '".$carrier_idval."' ";
			
			$GLOBALS['MySql'] -> querySql( $updatecus );
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/carrier/infolist/");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
				
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php/carrier/info/".$carrier_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
		}
		
	}
	
	

	
	
}

$Carrier = new Carrier();

?>