<?php
if(!empty($_POST["action"]))
{
    $_POST['rank']=empty($_POST['rank'])?0:$_POST['rank'];
	$_POST['statu']=empty($_POST['statu'])?0:$_POST['statu'];
	$_POST['stime']=strtotime($_POST['stime']);
	$_POST['etime']=strtotime($_POST['etime']);
	$_POST['identity']*=1;
	$_POST['shop_statu']*=1;
	$_POST['status']*=1;
	$open_country=@implode(",",$_POST['country']);
	$sql="update ".COMPANY." set ifpay='$_POST[ifpay]',statu='$_POST[statu]',stime='$_POST[stime]',etime='$_POST[etime]',
rank='$_POST[rank]',identity='$_POST[identity]',template='$_POST[template]',shop_statu='$_POST[shop_statu]',open_country='$open_country' where company_id='$_GET[userid]'";
	$re=$db->query($sql);
	if($re)
	{
		$sql="update ".INFO." set ifpay='$_POST[ifpay]' where userid='$_GET[userid]'";
		$db->query($sql);
		//unset($_GET['id']);unset($_GET['s']);
		//$getstr=implode('&',convert($_GET));
		//msg("module.php?s=company.php&$getstr");
	}
}
//=====================================================
$sql="select a.*,b.intro  from ".COMPANY."  a   left  join  ".CDETAIL."  b  on a.company_id=b.company_id where a.company_id='$_GET[userid]'";
$db->query($sql);
$de=$db->fetchRow();
$ifpay=$de['ifpay'];
$statu=$de['statu'];
$rank =$de['rank'];
$uptime=$de['uptime'];
if($de['stime'])
	$stime=date("Y-m-d",$de['stime']);
else
	$stime=date("Y-m-d");
	
if($de['etime'])
	$etime=date("Y-m-d",$de['etime']);
else
	$etime=(date("Y")+1).'-'.date("m-d");
	
$companyType=explode('|',$config['companyType']);
$identity=explode('|',$config['identity']);
$de['open_country']=explode(',',$de['open_country']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="main.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
</head>
<body  style="margin:0; border:0px;">
<style>
.titlebg{ height:20px; background:#E8F2FF; font-weight:bold; color:#0099CC;}
</style>
<div class="bigbox"  style="margin:0; padding:0px;">
  <div class="bigboxbody"  style="margin:0; border:0px;" >
    <?php if(empty($_GET['show'])){ ?>
    <table  border='0' cellspacing='0' cellpadding='0' align="center" class="menu"  style="margin:0; border:0px; width:600px;">
      <?php if($config['identity']){?>
      <tr>
        <td height="24" align="left"><?php echo lang_show('member_level');?></td>
        <td><?php
			foreach($identity as $key=>$v)
			{
			  if($de['identity']==$key)
		            echo $v;
			
			}
			?></td>
      </tr>
      <?php } ?>
      <tr>
        <td><?php echo lang_show('information_sop');?></td>
        <td ><?php  
		  include_once("module/company/includes/companyfen_class.php");
		   $companyfen=new companyfen();
		  
		   echo $companyfen->get_all($de['userid']);?>
          /100</td>
      </tr>
      <tr>
        <td width='120' height="24" align="left"><?php echo lang_show('membership_level');?></td>
        <td width="480"><?php
					$sql="select * from ".USERGROUP." order by group_id asc";
					$db->query($sql);
					$re=$db->getRows();
					foreach($re as $v)
					{
					  if ($v['group_id']==$ifpay) 
					       echo $v['name'];
					
					}
					?>
          &nbsp; </td>
      </tr>
      <tr>
        <td height="24" align="left"><?php echo lang_show('recommend');?></td>
        <td ><?php
			$rc_member = array(
				'0'=>lang_show('norec'),
				'1'=>lang_show('reccom'),
				'2'=>lang_show('startcom'),
			)
			?>
          <?php foreach($rc_member as $key=>$v) {
					     if($statu==$key)  
					       echo $v;
					   } ?></td>
      </tr>
      <tr>
        <td height="24"><?php echo lang_show('wh_shop');?></td>
        <td><?php if($de['shop_statu']==1){?>
          <?php echo lang_show('open');?>
          <?php } ?>
          <?php if($de['shop_statu']==2){?>
          <?php echo lang_show('close');?>
          <?php } ?></td>
      </tr>
      <tr>
        <td colspan="2"  class='titlebg'><?php echo lang_show('comp_inf');?> </td>
      </tr>
      <tr>
        <td><?php echo lang_show('company');?></td>
        <td><?php echo $de['company'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('contact');?></td>
        <td><?php echo $de['contact'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('tel');?></td>
        <td><?php echo $de['tel'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('fax');?></td>
        <td><?php echo $de['fax'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('post');?></td>
        <td><?php echo $de['zip'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('comp_link');?></td>
        <td><?php echo $de['url'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('addr');?></td>
        <td><?php echo $de['province'].$de['city'].$de['adder'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('comtype');?></td>
        <td><?php echo $de['ctype'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('main_pro');?></td>
        <td><?php echo $de['main_pro'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('purchase');?></td>
        <td><?php echo $de['purch_pro'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('employees');?></td>
        <td><?php echo $de['staff_num'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('registered_capital');?></td>
        <td><?php echo $de['registered_capital'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('turnover');?></td>
        <td><?php echo $de['turnover'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('cominfo');?></td>
        <td><?php echo $de['intro'];?>&nbsp; </td>
      </tr>
    </table>
    <?php }else{ ?>
    <form method="post" action=""  name=cityform enctype="multipart/form-data">
      <table width='98%' border='0' cellspacing='0' cellpadding='0' align="center" class="menu">
        <?php if($config['identity']){?>
        <tr>
          <td height="24" align="left"><?php echo lang_show('member_level');?></td>
          <td><select class="select" name="identity">
              <?php
			foreach($identity as $key=>$v)
			{
			?>
              <option value="<?php echo $key;?>" <?php if($de['identity']==$key) echo "selected"; ?>><?php echo $v?></option>
              <?php
			}
			?>
            </select></td>
        </tr>
        <?php } ?>
        <tr>
          <td width='15%' height="24" align="left"><?php echo lang_show('membership_level');?></td>
          <td width='92%'><select class="select" name="ifpay">
              <?php
					$sql="select * from ".USERGROUP." order by group_id asc";
					$db->query($sql);
					$re=$db->getRows();
					foreach($re as $v)
					{
					?>
              <option value="<?php echo $v['group_id'];?>"
					<?php if ($v['group_id']==$ifpay) echo " selected";?>><?php echo $v['name'];?></option>
              <?php
					}
					?>
            </select></td>
        </tr>
        <tr>
          <td height="24" align="left"><?php echo lang_show('vloid_time');?></td>
          <td><script language="javascript">
			var cdr = new Calendar("cdr");
			document.write(cdr);
			cdr.showMoreDay = true;
			</script>
            <input type="text" name="stime" value="<?php echo $stime?>" onFocus="cdr.show(this);" class="ltext">
            --
            <input type="text" name="etime" value="<?php echo $etime?>" onFocus="cdr.show(this);" class="rtext">
            (exp:2008-02-01) </td>
        </tr>
        <tr>
          <td height="24" align="left"><?php echo lang_show('rank');?></td>
          <td><input class="text" name="rank" type="text" id="rank" value="<?php echo $rank?>"></td>
        </tr>
        <tr>
          <td width='15%' height="24" align="left"><?php echo lang_show('recommend');?></td>
          <td width='92%'><?php
			$rc_member = array(
				'0'=>lang_show('norec'),
				'1'=>lang_show('reccom'),
				'2'=>lang_show('startcom'),
			)
			?>
            <select class="select" name="statu">
              <?php foreach($rc_member as $key=>$v) {?>
              <option value="<?php echo $key; ?>" <?php if($statu==$key)echo "selected"; ?>><?php echo $v;?></option>
              <?php } ?>
            </select></td>
        </tr>
        <tr>
          <td height="24"><?php echo lang_show('wh_shop');?></td>
          <td><input name="shop_statu" <?php if($de['shop_statu']==1){?>checked="checked"<?php } ?> type="radio" class="radio" value="1" />
            <?php echo lang_show('open');?>
            <input name="shop_statu" <?php if($de['shop_statu']==2){?>checked="checked"<?php } ?> type="radio" class="radio" value="2" />
            <?php echo lang_show('close');?> </td>
        </tr>
        <tr>
          <td height="24"><?php echo lang_show('shop_template');?></td>
          <td><input name="template" value="<?php echo $de['template'];?>" class="text" type="text" /></td>
        </tr>
        <tr>
          <td valign="top"><?php echo lang_show('open_country');?></td>
          <td><a id="open" onclick="$('#cbox').show();$('#close').show();$('#open').hide();" href="#"><?php echo lang_show('expand');?></a> <a style="display:none;" id="close" onclick="$('#cbox').hide();$('#close').hide();$('#open').show();" href="#"><?php echo lang_show('closes');?></a> <span class="bz"><?php echo lang_show('default_open');?></span>
            <div style="display:none;" id="cbox">
              <?php
			$sql="select * from ".COUNTRY." order by nums asc,ename asc";
			$db->query($sql);
			$re=$db->getRows();
			foreach($re as $key=>$v)
			{
				if(is_array($de['open_country'])&&in_array($v['id'],$de['open_country']))
					$str="checked=true";
				else
					$str="";
				echo '<input '.$str.' name="country[]" type="checkbox" value="'.$v['id'].'" />'.$v['ename'].'/'.$v['cname'];
				if(($key+1)%5==0)
					echo '<br>';
			}
			?>
            </div></td>
        </tr>
        <tr>
          <td width='15%' height="24">&nbsp;</td>
          <td width='92%'><input class="btn" type='submit' name='submit' value='<?php echo lang_show('submit');?>'>
            <input name="action" type="hidden" id="action" value="submit"></td>
        </tr>
      </table>
    </form>
    <?php } ?>
  </div>
</div>
</body>
</html>