 
<?php 

if($catpid== "") {
  echo 'must have catpid';
  exit;
}
else  ifhaspidname(TABLE_CATE,$catpid);



$jumpv='mod_nodelangrel.php?lang='.$mainlang.'&pid='.$pid;
 
 
$pidnodetitle ='';
//主语言的rel id要先存在。
 $sql = "SELECT * from ".TABLE_NODELANGREL." where nodeid='$pid' and lang='$mainlang' and pidname='$pidname' and pbh='".USERBH."' order by  id";
   if(getnum($sql)==0) {
     echo '关联id不存在 - '.$pidname;
     exit;

   }else   {

      $sql = "SELECT * from ".TABLE_NODE." where   lang='$mainlang' and pidname='$pid' and pbh='".USERBH."' order by  id";

      $row = getrow($sql); 
      $main_title = $row['title'];
      $main_desp = $row['desp'];
      $main_kvsm = UPLOADPATH.'image/'.$mainlang.'/'.$row['kvsm'];

      $pidnodetitle = LANG.' - '.$main_title;
      //get_field_lang($mainlang,TABLE_NODE,'title',$pid,'pidname');
   }

  // echo $pidnodetitle;
//-------------------

  if($act=='update')  {
        
         $sql = "delete from ".TABLE_NODELANGREL." where pidname='$pidname' and lang='".LANG."' and pbh='".USERBH."' order by  id";
         iquery($sql);

      if($abc1==''){
          //add node
          $abc1 = 'node'.$bshou; 
           $ss = "insert into ".TABLE_NODE." (ppid,pid,pidmulti,pidname,pbh,title,lang,desp,kvsm_cus,arr_can,sta_noaccess,dateedit,pos) values ('$catpid','$catpid','$catpid','$abc1','$user2510','$pidnodetitle','".LANG."','$main_desp','$main_kvsm','$arr_nodeV','n','$dateall',5000)";
         // echo $ss;exit;
           iquery($ss); 

      }


         $ss = "insert into ".TABLE_NODELANGREL." (lang,pbh,pidname,nodeid) values ('".LANG."','$user2510','$pidname','$abc1')";
     // echo $ss;exit;
        iquery($ss);
          


        $jumpv = $jumpv_file.'&catpid='.$catpid.'&pidname='.$pidname;

      jump($jumpv);  
 
 

  }
  else{


 $nodeid = '';
 $sql = "SELECT * from ".TABLE_NODELANGREL." where pidname='$pidname' and lang='".LANG."' and pbh='".USERBH."' order by  id";
 //echo $sql;
   if(getnum($sql)>0) {
       $row = getrow($sql);
       $nodeid = $row['nodeid'];
   }



$update = $jumpv_file.'&catpid='.$catpid.'&pidname='.$pidname.'&act=update';
?>



<section class="content-header">
        <h1>关联产品   - 
 <a href="<?php echo $jumpv;?>&file=list"><返回</a></h1>
</section>

 

 <form  action="<?php echo $update; ?>" method="post" enctype="multipart/form-data">


  <table class="formtab ">
     
<tr>
   
   <td  align="right">语言标识：</td>
   <td  > <?php echo  LANG  ?>

  </td>
  

  </tr>
    

  <tr>
   
   <td  align="right">产品标识：</td>
   <td  >
    <input class="treearr_select_input" type="text" name="treearr_select_input"  value="<?php echo $nodeid;?>" size="35"  /> 
<?php 
if($nodeid<>'') {
   if(!ifhaspidname2(TABLE_NODE,$nodeid)) {

    echo '<p class="cred">不存在-  '.$nodeid.'</p>';
   }
   else {
    echo '<p class="cred">'.get_field(TABLE_NODE,'title',$nodeid,'pidname').'</p>';
   }

}
?>
 <p>
  请从其他语言选择产品标识id来添加。 
   如果为空，则是新添加产品，并自动关联这个新产品



 </p>
  

  </td>
  

  </tr>
    
 
  

  <tr>
   
   <td  align="right"> </td>
   <td  > 
 <input class="mysubmit"     type="submit" name="Submit" value="提交" /> 
     
  </td>
  

  </tr>
    


</table>
 
 
<div class="c tc"> 
 

 <?php echo $inputmust;?>

 </div>

 </form>

<?php
}
?>