define("ADMIN",FALSE); function html_head() { global $config; echo "\n
\n"; $title = "C3 RP2 Organization & Project"; if ( ADMIN ) { $title .= " Administration"; } echo "\n"; echo "
\n"; echo "\n"; echo "\n"; } require "./common.php"; require "./functions.php"; $debug=FALSE; $action=$_GET['action']; $type=$_GET['type']; $view=$_GET['view']; $org_id=$_GET['org_id']; $proj_id=$_GET['proj_id']; $contact_id=$_GET['contact_id']; $title=$_GET['title']; $show_descriptions=$_GET['show_descriptions']; $show_projects=$_GET['show_projects']; // ACTIONS if ( ADMIN && $_GET['action'] ) { switch ($type) { case 'org': $view='org'; $table="organization"; $type='org'; $table="organization"; $friendly="ORGANIZATION"; $id=$_GET['org_id']; break; case 'proj': $view='proj'; $table="project"; $type='proj'; $table="project"; $friendly="PROJECT"; $id=$_GET['proj_id']; break; case 'contact': $view='contact'; $table="contact"; $type='contact'; $table="contact"; $friendly="CONTACT"; $id=$_GET['contact_id']; break; default: if ( empty($_GET['proj_id']) && empty($_GET['org_id']) && empty($_GET['contact_id']) ) { // should have been passed $type die(); } else if ( $_GET['proj_id'] ) { $type='proj'; $table="project"; $friendly="PROJECT"; $id=$_GET['proj_id']; } else if ( $_GET['org_id'] ) { $type='org'; $table="organization"; $friendly="ORGANIZATION"; $id=$_GET['org_id']; } else { $type='contact'; $table="contact"; $friendly="CONTACT"; $id=$_GET['contact_id']; } } switch ($_GET['action']) { case 'edit': html_head(); if (empty($view) ) { $view="org"; } echo "
\n"; html_foot(); exit; break; case 'save': // save from add or edit for ( $i=0; $i < count($field_name); $i++ ) { if ( empty($id) ) { // insert into $query="INSERT INTO rp2_".$table." SET ".$field_name[$i]."='".$field_value[$i]."'"; } else { // update where $query="UPDATE rp2_".$table." SET ".$field_name[$i]."='".$field_value[$i]."' WHERE id='".$id."'"; } $result=mysql_query($query); if ( empty($id) ) { // set $id so the next query is an update $id=mysql_insert_id(); } //echo "".$query."\n";; } break; case 'delete': // are you sure? html_head(); echo "
\n"; html_foot(); exit; break; case 'scrub': // delete from table where id $query="DELETE FROM rp2_".$table." WHERE id='".$id."'"; $result=mysql_query($query); /* html_head(); echo "\n"; html_foot();*/ //exit; break; case 'toggle': switch ($type) { case 'org': $table="organization"; break; case 'proj': $table="project"; break; case 'contact': $table='contact'; break; } // load current setting $query="SELECT * FROM rp2_".$table." where id='$id'"; $result=mysql_query($query); $temp=mysql_fetch_array($result); //figure opposite if (round($temp['active']/2) == $temp['active']/2 ) { $opposite=TRUE; } else { $opposite=FALSE; } // update with the opposite $query="UPDATE rp2_".$table." SET active='".$opposite."' where id=".$id; $result=mysql_query($query); if( empty($temp['active']) && $type=='proj' ) { //must make parent active also $query="UPDATE rp2_organization SET active='1' where id=".$temp['org_id']; $result=mysql_query($query); } // if it's $type=='contact' then need to set project & org active ... break; } } // END ACTIONS $html_title=html_head(); ?>IMPORTANT NOTICE unset($where); $delim=" "; if ($degree) { $where .= $delim."location='$degree'"; $delim=" and "; } if ($title) { $where .= $delim."title='$title'"; $delim=" and "; } if ($description) { $where .= $delim."description is like '%".$description."%'"; $delim=" and "; } if ($year) { switch ($yrelation) { case '<': $where .= $delim."year<='$year'"; break; case '>': $where .= $delim."year>='$year'"; break; default: case '=': $where .= $delim."year='$year'"; break; } $delim=" and "; } if ($quarter) { $where .= $delim."quarter='$quarter'"; $delim=" and "; } if ($location) { $where .= $delim."location='$location'"; $delim=" and "; } switch ( $view ) { default: case 'org': $view="org"; $query="select * from rp2_organization"; if ($where) { $query .= " where (".$where.")"; } if ( !ADMIN ) { if ( $where ) { $query .= " and"; } else { $query .= " where"; } $query .= " active=1"; } $query.= " order by title asc"; break; case 'proj': $query="select * from rp2_project"; if ($where) { $query .= " where (".$where.")"; } if ( !ADMIN ) { if ( $where ) { $query .= " and"; } else { $query .= " where"; } $query .= " active=1"; } $query.= " order by title asc"; break; case 'proj_detail': case 'detail': if ( empty($proj_id) && empty($org_id) ) { $query="select id from rp2_organization"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by title asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $org_id=$temp['id']; $query="select id from rp2_project where org_id='$org_id'"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by title asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $proj_id=$temp['id']; } else if ( empty($org_id) ) { // but proj_id is known $query="select org_id from rp2_project where id='$proj_id'"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by title asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $org_id=$temp['org_id']; } else if ( empty($proj_id) ) { // but org_id is known $query="select id from rp2_project where org_id='$org_id'"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by title asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $proj_id=$temp['id']; } else { // both org_id and proj_id are known // well, okay. there's nothing wrong with that. } $query="select * from rp2_project where id=".$proj_id; break; case 'org_detail': // not used any more if ( empty($org_id) ) { $query="select id from rp2_organization"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by title asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $org_id=$temp['id']; } if ( empty($proj_id) ) { $query="select id from rp2_project where org_id='$org_id'"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by title asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $proj_id=$temp['id']; } $query="select * from rp2_organization where id=".$org_id; break; case 'contact': if ( empty($contact_id) ) { $query="select id from rp2_contact"; if ( !ADMIN ) { $query .= " and active=1"; } $query .= " order by last_name asc limit 1"; $result=mysql_query($query); $temp=@mysql_fetch_array($result); $org_id=$temp['id']; } $query="select * from rp2_contact where id=".$contact_id; break; } $result=mysql_query($query); if ( $debug || FALSE ) { echo "
".$query; } //if ( @mysql_num_rows($result) ) { for ( $i=0; $i<@mysql_num_rows($result); $i++ ) { $row[$i]=mysql_fetch_array($result); } $numrows=@mysql_num_rows($result); echo "
\n";
echo " SEARCH: "; echo " [ Organizations ] "; echo " [ Projects ] "; if ( ADMIN ) { echo " or BROWSE: "; echo " [ Details ] "; //echo " [ Org. Detail ] "; //echo " [ Proj. Detail ] "; //echo " [ Contacts ] "; } echo " | |||
\n";
echo " $html_title"; echo " | |||
\n"; switch ( $view ) { default: case 'proj': case 'org': echo " | |||
\n";
echo " \n"; echo " | |||
No Results |
"; echo "\n"; echo " |
\n";
// content area
echo "
| ||
\n"; echo org_detail($org_id); echo " | ||
\n"; echo proj_detail($proj_id); echo " | ||
\n";
$query="select * from rp2_contact where proj_id='$proj_id'";
$result=mysql_query($query);
if ( @mysql_num_rows($result) ) {
for ( $i=0; $i<@mysql_num_rows($result); $i++ ) {
$row=mysql_fetch_array($result);
echo "
|
"; echo "\n"; echo " | |||
\n"; echo contact_detail($contact_id); echo " |
*** NOTICE ***
This code is preliminary and may do unexpected things. The tool is experimental and may not work and/or break at various times, doing various things. The data is incomplete, preliminary and may be innacurate or not reflect what actually is. The tool is not permanent and may go away or not be available without future notice. Etc ... Etc ...
*** NOTICE ***
";
html_foot();
?>