<?

define("N_NEWITEM",0);
define("N_ITEMUPDATE",1);
define("N_WORKSCHEDULED",2);
define("N_NEWS",3);
define("N_CUSTOM",4);
define("N_SIZE",10);

function makeRating($rating) {
  $ret = "<SELECT NAME=\"data[rating][$vid]\">\n";
  $ret .= "<OPTION VALUE=\"1\">Y</OPTION>\n";
  $ret .= "<OPTION VALUE=\"1\">Y7</OPTION>\n";
  $ret .= "<OPTION VALUE=\"1\">G</OPTION>\n";
  $ret .= "<OPTION VALUE=\"1\">PG</OPTION>\n";
  $ret .= "<OPTION VALUE=\"1\">14</OPTION>\n";
  $ret .= "<OPTION VALUE=\"1\">MA</OPTION>\n";
  $ret .= "<OPTION VALUE=\"1\">AD</OPTION>\n";
  $ret .= "</SELECT>\n";
  return($ret);
  }




function getCompany($data,$cid) {
  if ($cid == -1)
    return("Everyone");
  else {
    $query = "SELECT company FROM users WHERE UID='$cid'";
    $result = mysql_query($query); 
    return(mysql_result($result,0,'company'));
    }
  }

function getGroup($data,$gid) {
  $query = "SELECT * FROM groups WHERE id='$gid'";
  $result = mysql_query($query);
  return(mysql_result($result,0,'group'));
  }

function mkGroupList($data) {
  $group = "<OPTION VALUE=\"\">Select Group</OPTION>\n";
  if ($data[lg] != "") {
    $query = "SELECT * FROM groups WHERE id > 1";
    $gid = $data[lg];
    }
  else { 
    $query = "SELECT * FROM groups";
    $gid = $data[gid];
    }
  $result = mysql_query($query);
  $rows = mysql_numrows($result);
  for ($i=0;$i<$rows;$i++) {
    $id = mysql_result($result,$i,'id');
    if ($gid == $id)
      $sel = "SELECTED";
    else
      $sel = "";
    $group .= "<OPTION VALUE=\"$id\" $sel>" . mysql_result($result,$i,'group') . "</OPTION>\n";
    } 
  return($group);
  }

function mkCompanyList($data) {
  $company = "<OPTION VALUE=\"\">Select Company</OPTION>\n"; 
  if ($data[gid] == 1)
    $query = "SELECT company,uid FROM users WHERE GID = 2 AND active = 1 ORDER BY company";
  else 
    $query = "SELECT company,uid FROM users WHERE UID='$data[uid]' ORDER BY company";
  $result = mysql_query($query);
  $num = mysql_numrows($result);
  if ($data[company] == -1) 
    $sel = "SELECTED";
  $company .= "<OPTION VALUE=\"-1\" $sel>All Companies</OPTION>\n";
  for ($i=0;$i<$num;$i++) {
    $uid = mysql_result($result,$i,'uid');
    if ($data[company] == $uid)
      $sel = "SELECTED";
    else 
      $sel = "";
    $company .= "<OPTION VALUE=\"$uid\" $sel>" . mysql_result($result,$i,'company') . "</OPTION>\n";
    }
  return($company);
  }

?>
