\n\n"; $title = "C3 RP2 Organization & Project"; if ( ADMIN ) { $title .= " Administration"; } echo "$title\n"; require "./style.html"; echo "\n"; echo "\n"; return $title; } function html_foot() { global $config; 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"; echo "\n"; echo "\n"; if ( $org_id ) { echo "\n"; } if ( $proj_id ) { echo "\n"; } if ( $contact_id ) { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

"; echo "\n"; echo ""; echo "\n"; echo "

EDIT $friendly

\n"; echo edit($type,$id,$org_id); echo "

 

\n"; 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"; echo "\n"; echo "\n"; if ( $org_id ) { echo "\n"; } if ( $proj_id ) { echo "\n"; } if ( $contact_id ) { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

"; echo "\n"; //echo "\n"; echo "

ARE YOU SURE? DELETE $friendly

 

\n"; 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"; echo "\n"; if ( $org_id ) { echo "\n"; } if ( $proj_id ) { echo "\n"; } if ( $contact_id ) { echo "\n"; } //echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

"; echo "\n"; //echo "\n"; echo "

DELETED $friendly

 

\n"; 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 ': $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 "

"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; } } } else { $color=rowcolor(0); echo "\n"; } 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 "\n"; echo ""; // column header echo column_header($view); echo "\n"; } echo "\n"; } // SHOW CONTACTS if ( ( ( $show_contacts == 'on' ) || FALSE ) && FALSE ) { // echo "\n"; //echo "\n"; } else { echo "\n"; echo "

"; echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; if ( $view == 'proj' ) { echo ""; echo "\n"; } echo ""; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "

Title

\n"; // title $query="select distinct title from rp2_"; switch ( $view ) { case 'proj': $query .= "project"; break; default: $query .= "organization"; break; } if ( !ADMIN ) { $query .= " where active=1"; } $query.=" order by title asc"; $result=mysql_query($query); //echo "

".mysql_error(); //echo "

".$query; echo "\n"; echo "

Location

\n"; // location $query="select distinct location from rp2_"; switch ( $view ) { case 'proj': $query .= "project"; break; default: $query .= "organization"; break; } if ( !ADMIN ) { $query .= " where active=1"; } $query.=" order by title asc"; $result=mysql_query($query); //echo "

".mysql_error(); //echo "

".$query; echo "\n"; echo "

Show Descriptions?

\n"; // show descriptions? echo "\n"; if ( $view != 'proj' ) { echo "

Show Projects?

\n"; // show project? echo "\n"; } if ( FALSE ) { echo "

Show Contacts?

\n"; // show contact? echo "\n"; } echo "

 

\n"; echo "\n"; // echo "
\n"; echo "\n"; echo "
\n"; // content area echo "\n"; // EACH MATCHING ROW if ( $numrows ) { for ( $i=0; $i<$numrows; $i++ ) { $color=rowcolor($i); $rcolor=rowcolor($i+1); $local_row=$row[$i]; echo "\n"; echo "\n"; echo ""; // SHOW DESCRIPTIONS if ( $show_descriptions == 'on' || FALSE ) { echo "\n"; } // SHOW PROJECTS if ( ( $view != 'proj' && $show_projects == 'on' ) || FALSE ) { // echo "\n"; //echo "\n"; } else { echo "\n"; echo "

".$local_row['title']; echo "

"; echo "[ Details ]\n"; if ( ADMIN ) { echo " [ edit ]"; echo " [ toggle active ]"; echo " [ delete ]"; } else { echo " "; } echo "
"; //echo "

    Description:"; echo "

    ".$local_row['description']; echo "\n"; echo "

"; $pquery="select * from rp2_project where org_id='".$local_row['id']."' "; if ( !ADMIN ) { $pquery.="and active=1 "; } $pquery.="order by title asc"; $presult=mysql_query($pquery); echo "

\n"; echo ""; //echo ""; echo ""; echo "\n"; if ( @mysql_num_rows($presult) ) { //echo "\n"; for ( $j=0; $j<@mysql_num_rows($presult);$j++ ) { $this_project=mysql_fetch_array($presult); echo "\n"; } echo "

"; echo "

"; if ( ADMIN ) { echo "All"; } else { echo "Active"; } echo " Projects:

"; if ( ADMIN ) { echo " "; } else { echo " "; } echo "

Active Projects:

".$this_project['title']; echo "

"; echo " [ details ]"; if ( ADMIN ) { echo " [ edit ]"; echo " [ toggle active ]"; echo " [ delete ]"; } else { echo " "; } echo "
\n"; echo "
\n"; echo "

    No Active Projects\n"; echo "

\n"; echo "
\n"; echo "

 \n"; echo "

"; $pquery="select * from rp2_contact where "; switch ( $view ) { case 'org': $pquery.="org_id='".$local_row['id']."' "; break; case 'proj': $pquery.="proj_id='".$local_row['id']."' "; break; } $pquery .= "and ( proj_id is NULL or proj_id='' ) "; if ( !ADMIN ) { $pquery.="and active=1 "; } $pquery.="order by last_name,description asc"; $presult=mysql_query($pquery); echo "

\n"; echo ""; //echo ""; echo ""; echo "\n"; if ( @mysql_num_rows($presult) ) { //echo "\n"; for ( $j=0; $j<@mysql_num_rows($presult);$j++ ) { $this_contact=mysql_fetch_array($presult); echo "\n"; } echo "

"; echo "

"; if ( ADMIN ) { echo "All"; } else { echo "Active"; } switch ( $view ) { case 'org': echo " Organizational"; break; case 'proj': echo " Project"; break; } echo " Contacts:

"; if ( ADMIN ) { echo ""; } else { echo " "; } echo "

Active Projects:

".$this_contact['description']; if ( ADMIN ) { switch ( $this_contact['active'] ) { case true: echo " (active)"; break; case false: echo " (inactive)"; break; } } // formatted contact //echo "

"; echo "

".contact_formatted($this_contact['id'],$rcolor); //echo "

\n"; echo "

"; echo " [ details ]"; if ( ADMIN ) { echo " [ toggle active ]"; echo " [ delete ]"; } else { echo " "; } echo "
\n"; echo "
\n"; echo "

    No Active Contacts\n"; echo "

\n"; echo "
\n"; echo "

 \n"; echo "

No Results

\n"; echo "\n"; echo "\n"; break; case 'detail': case 'proj_detail': case 'org_detail': $color=rowcolor(0); $rcolor=rowcolor(1); echo "\n"; /* echo "\n"; echo ""; */ //echo "
"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; // limits form echo "
\n"; echo "
\n"; echo "
\n"; /* // column header echo column_header($view); echo "\n"; // column header echo column_header('proj_detail'); echo scroll($view,'proj',$proj_id,$org_id); echo "\n"; if ( ( ( $show_contacts == 'on' ) || FALSE ) && FALSE ) { // column header echo column_header('contact'); //echo scroll($view,'contact',$contact_id,$org_id,$proj_id); echo "
\n"; // content area echo "\n"; foreach ( $row[0] as $key => $value ) { if ( is_numeric($key) ) { continue; } $color=rowcolor($k); echo "\n"; echo "\n"; echo "\n"; echo "\n"; $k++; } echo "

".ucfirst($key)."

".$value."
\n"; */ // column header echo column_header('org_detail'); echo scroll($view,'org',$org_id); 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 "\n"; echo "\n"; echo "

".$row['description']; echo "

".contact_formatted($row['id'],$rcolor); echo "

\n"; } } else { echo "\n"; echo "\n"; echo "
\n"; echo "

No contacts"; echo "

\n"; } //echo "
"; echo "\n"; } echo "\n"; break; case 'contact': echo "\n"; /* echo "\n"; echo ""; */ // column header echo column_header('contact'); //echo scroll($view,'contact',$contact_id); echo "\n"; echo "
"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; // limits form echo "
\n"; echo "
\n"; echo "
\n"; echo contact_detail($contact_id); echo "
\n"; break; } echo "\n"; echo "

\n"; 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(); ?>