<?php
include_once("../includes/tag_inc.php");
//=========================================================
$sql="select a.* from ".BUY." a where a.id='$_GET[id]'";
$db->query($sql);
if($db->next_record())
{
	$id=$db->f('id');
	$type=$db->f('type');
	$userid=$db->f('userid');
	$user=$db->f('user');
	$title=$db->f('title');
	$con=$db->f('con');
	$detail=$db->f('desc');
	$keyword=$db->f('keywords');
	$catid=$db->f('catid');
	$uptime=$db->f('uptime');
	$country=$db->f('country');
	$country=$db->f('province');
	$country=$db->f('city');
	$valid_time=$db->f('valid_time');
	$buy_time=$db->f('buy_time');
	$delivery_time=$db->f('delivery_time');
	$seller_country=$db->f('seller_country');
	$seller_province=$db->f('seller_province');
	$seller_city=$db->f('seller_city');
	$seller_need=$db->f('seller_need');
	$pic=$db->f('pic');
	if(!empty($pic))
	{
		$pic=explode(',',$pic);	
		foreach($pic as $key=>$val)
		{
			if(!empty($val))
				$pic[$key]=substr_replace($val,'/big_',strripos($val,'/'),1);
		}
	}	
}
$sql="select cat from ".OCAT." where catid='$catid'";
$db->query($sql);
$cat=$db->fetchField('cat');
?>
<!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>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="main.css" rel="stylesheet" type="text/css" />
<style>
.titlebg{ height:20px; background:#E8F2FF; font-weight:bold; color:#0099CC;}

</style>
</HEAD>
<body style="margin:0px; padding:0px;">
<div class="bigbox">
  <div class="bigboxbody" style="margin:0 auto;">
  
    <table width="600" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="2" class='titlebg'><?php echo lang_show('buy_in');?></td>
      </tr>
      <tr>
        <td class="lefttitle" width="120" ><?php echo lang_show('buying_title');?></td>
        <td  ><?php echo $title;?>&nbsp; </td>
      </tr>
       <tr>
        <td class="lefttitle" ><?php echo lang_show('purchase_type');?></td>
        <td ><?php echo $cat;?>&nbsp; </td>
      </tr>
      
        <tr>
        <td class="lefttitle" ><?php echo lang_show('summary');?></td>
        <td><?php echo $con;?>&nbsp;</td>
      </tr>
      <tr>
        <td class="lefttitle" height="22"><?php echo lang_show('update_date');?></td>
        <td height="22"><?php echo $uptime;?> &nbsp;</td>
      </tr>
      <tr>
        <td class="lefttitle"><?php echo lang_show('detail');?></td>
        <td><?php echo $detail; ?> &nbsp;</td>
      </tr>
      <tr>
        <td class="lefttitle" ><?php echo lang_show('picture');?></td>
        <td><?php 
			if(!empty($pic))
			 {
				 foreach($pic as $list){ ?>
		  		<img src="<?php echo $config['weburl'] ;?>/<?php echo $list;?>" width="250">
			  	<?php } 
			 }
			 else
			 {
				echo '无图片';
			 }
		 ?>
        </td>
      </tr>
       <tr>
        <td colspan="2" class='titlebg'><?php echo lang_show('description');?></td>
      </tr>
      <tr>
      	  <td colspan="2" >
          	<table border="0" width="100%" cellspacing="0" align="left" cellpadding="0">
            <tbody>
                <tr class="thead">
                    <th align="left" width="20%"><?php echo lang_show('business_title');?></th>
                    <th align="left" width="20%"><?php echo lang_show('num');?></th>
                    <th align="left" width="20%"><?php echo lang_show('unit');?></th>
                    <th align="left"><?php echo lang_show('target_price');?></th>
                </tr>
                <?php 
					$db->query("select * from ".BUYPRO." where buy_id='$id'");
					$re=$db->getRows();
					foreach($re as $key=>$val)
					{
				 ?>
                <tr>
                    <td><?php echo $val['pname'];?></td>
                    <td><?php echo $val['number']; ?></td>
                    <td><?php echo $val['unit']; ?></td>
                    <td><?php echo $val['price'];?></td>
                </tr>
               <?php } ?>
            </tbody>
            </table>
          </td>
      </tr>
      <tr>
        <td colspan="2" class='titlebg'><?php echo lang_show('req_seller');?></td>
      </tr>
      <tr>
        <td class="lefttitle" ><?php echo lang_show('req_deadline');?></td>
        <td ><?php echo lang_show('deadline_quote');?>： <font color="#0099CC"><?php echo date('Y-m-d',strtotime(date($valid_time)));?></font>   <?php echo lang_show('expected_date');?>：<font color="#0099CC"><?php echo date('Y-m-d',strtotime(date($buy_time)));?></font>   <?php echo lang_show('delivery_date');?>：<font color="#0099CC"><?php  echo date('Y-m-d',strtotime(date($delivery_time)));?></font></td>
      </tr>
       <tr>
        <td class="lefttitle" ><?php echo lang_show('area');?></td>
        <td><?php echo $seller_country;?></td>
      </tr>
      <tr>
        <td  class="lefttitle" ><?php echo lang_show('province_city');?></td>
        <td><?php echo $seller_province;?>	<?php echo $seller_city;?></td>
      </tr>
       <tr>
        <td  class="lefttitle"><?php echo lang_show('condition');?></td>
        <td><?php echo  $seller_need;?></td>
      </tr>
         <?php
			//=====================================================
			$sql="select * from ".ALLUSER." where userid='$userid' limit 1";
			$db->query($sql);
			$deuser=$db->fetchRow();
			$company_id=$deuser['company_id'];
			
			$sql="select a.*,b.intro  from ".COMPANY."  a   left  join  ".CDETAIL."  b  on a.company_id=b.company_id where a.company_id='$company_id'";
			$db->query($sql);
			$de=$db->fetchRow();
			$ifpay=$de['ifpay'];
			$statu=$de['statu'];
			$rank =$de['rank'];
			$uptime=$de['uptime'];
			$identity=explode('|',$config['identity']);
		?>
       <tr>
        <td colspan="2"  class='titlebg'><?php echo lang_show('individual_member');?> </td>
      </tr>
       <tr>
        <td><?php echo lang_show('account_number');?></td>
        <td><?php echo $deuser['user'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('name');?></td>
        <td><?php echo $deuser['name'];?>&nbsp;</td>
      </tr> 
      <tr>
        <td><?php echo lang_show('tel');?></td>
        <td><?php echo $deuser['tel'];?>&nbsp;</td>
      </tr>
       <tr>
        <td><?php echo lang_show('mail');?></td>
        <td><?php echo $deuser['email'];?>&nbsp;</td>
      </tr>
      <?php if(!empty($de)){ ?>
      <?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($config['webroot']."/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('user_g');?></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 colspan="2"  class='titlebg'><?php echo lang_show('company_info');?> </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('zip');?></td>
        <td><?php echo $de['zip'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('compant_web');?></td>
        <td><?php echo $de['url'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('address');?></td>
        <td><?php echo $de['province'].$de['city'].$de['adder'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('business_type');?></td>
        <td><?php echo $de['ctype'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('main_products');?></td>
        <td><?php echo $de['main_pro'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('buy_pro');?></td>
        <td><?php echo $de['purch_pro'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('employees_num');?></td>
        <td><?php echo $de['staff_num'];?>&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo lang_show('reg_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('com_introduction');?></td>
        <td><?php echo $de['intro'];?>&nbsp; </td>
      </tr>
      <?php } ?>
    	</td>
      </tr>
    </table>

  </div>
</div>
</body>
</html>
