NEF"; if ($eff_val=="1") $eff_dsp="EFF"; $eff_param="{$eff_param} {$eff_dsp}, "; } $eff_param=rtrim($eff_param,", "); $query_string=rtrim($query_string," or "); $query_string="{$query_string})"; $query_string="{$query_string} and "; } // status if ($s_status) { $query_string="{$query_string}("; $status_param="Status:"; foreach ($s_status as $stat_val) { $query_string="{$query_string}status=\"{$stat_val}\" or "; if ($stat_val=="1") $stat_dsp="OPEN"; if ($stat_val=="2") $stat_dsp="CLSD"; if ($stat_val=="3") $stat_dsp="DFRD"; $status_param="{$status_param} {$stat_dsp}, "; } $status_param=rtrim($status_param,", "); $query_string=rtrim($query_string," or "); $query_string="{$query_string})"; $query_string="{$query_string} and "; } // report date $query_string="{$query_string}("; $query_string="{$query_string}report_date between \"{$s_report_date_start}\" and \"{$s_report_date_end}\""; $query_string="{$query_string})"; $query_string="{$query_string} and "; $reportdate_param="Report date between {$s_report_date_start} and {$s_report_date_end}"; // report time $query_string="{$query_string}("; $query_string="{$query_string}report_time between \"{$s_report_time_start}\" and \"{$s_report_time_end}\""; $query_string="{$query_string})"; $query_string="{$query_string} and "; $reporttime_param="Report time between {$s_report_time_start} and {$s_report_time_end}"; // discrepancy text if ($s_discrepancy_text) { $query_string="{$query_string}("; $query_string="{$query_string}discrepancy_text like \"%{$s_discrepancy_text}%\""; $query_string="{$query_string})"; $query_string="{$query_string} and "; $discrepancytext_param="Text in discrepancy: {$s_discrepancy_text}"; } else { $discrepancytext_param="Text in discrepancy: any"; } // reported by if ($s_reported_by) { $query_string="{$query_string}("; $query_string="{$query_string}reported_by like \"%{$s_reported_by}%\""; $query_string="{$query_string})"; $query_string="{$query_string} and "; $repby_param="Text in Reported by: {$s_reported_by}"; } else { $repby_param="Text in Reported by: any"; } $query_string=rtrim($query_string," and "); $query_string="select * from writeups where {$query_string} order by report_date asc"; } // ******** end database manipulation ******** pagetable("begin"); if (!$print) { pageblock("left","begin"); sidemenu(); pageblock("left","end"); } pageblock("right","begin"); banner($print); echo "
"; if ($action=="add") { if (count($targets) > 1) { $plural="s"; } else { $plural=""; } if ($save && !$fail) { format_message(0,"Writeup$plural successfully added. Return to Writeup Groups page."); } elseif ($save && $fail) { format_message(2,"An error was encountered when adding writeup$plural. The error was \" $fail \""); } if ($save) { // show the group $mode="view"; group_table($group,$role,$mode); if ($role) { // show buttons echo "
                       
"; } } else { if ($role){ // show mini search with discrepancy data only echo "
Search Parameters     Enter search terms to find writeups to add to the group.
"; echo " "; echo " "; // **********************************" echo "
"; // Status cell ********************** echo " Status
"; if ($search) { $openstate=$clsdstate=$dfrdstate=""; if (in_array("1",$s_status,true)) $openstate="selected"; if (in_array("2",$s_status,true)) $clsdstate="selected"; if (in_array("3",$s_status,true)) $dfrdstate="selected"; } else { $openstate=$clsdstate=$dfrdstate="selected"; } echo " "; // ********************************** echo "
"; // Device cell ********************* echo " Device
"; // ********************************** echo "
"; // Subsystem cell ******************* echo " Subsystem
"; // ********************************** echo "
"; // Period cell ********************** echo " Period
"; // ********************************** echo "
"; // Report Date cell ***************** echo " Report Date Between
 and  "; // ********************************** echo "
"; // Report Time cell ***************** echo " Report Time Between
 and  "; // ********************************** echo "
"; // Discrepancy text cell ************ echo " Words in Discrepancy

"; // ********************************** echo "
"; // Reported by cell ***************** echo " Reported by
"; // ********************************** echo "
"; // Period effective cell ************ echo " Sim period effective?  
"; if ($search) { $effstate=$nefstate=""; if (in_array("1",$s_period_effective,true)) $effstate="selected"; if (in_array("0",$s_period_effective,true)) $nefstate="selected"; } else { $effstate=$nefstate="selected"; } echo "
"; // display the results if ($search) { $writeup_qry=mysqli_query($drs_db,$query_string); if (mysqli_num_rows($writeup_qry)) { echo "
"; while ($tablerow = mysqli_fetch_assoc($writeup_qry)) { // determine effective icon if($tablerow["period_effective"]==1) { $eff_icon="\"Period"; } else { $eff_icon="\"Period"; } // determine status indicator if ($tablerow['status']==1) $statusind="
OPEN
"; if ($tablerow['status']==2) $statusind="
CLSD
"; if ($tablerow['status']==3) $statusind="
DFRD
"; // convert device number to name $dname=dblookup($drs_db,"devices","id","name",$tablerow["device"]); $disc_txt="{$tablerow["discrepancy_text"]}"; // determine if this is a member of a group $member_qry=mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$tablerow['id']}\""); $is_member=mysqli_num_rows($member_qry); if ($is_member) { $group_count=$is_member; $member_group=mysqli_fetch_row($member_qry)[0]; $member_group_name=dblookup($drs_db,"groups","id","name",$member_group); if ($member_group_name) { $imgtitle="Member of group: $member_group_name"; } else { $imgtitle="Member of group ID: $member_group"; } if ($group_count == 1) { $disc_txt=$disc_txt."
\"GRP\"
"; } else { $disc_txt=$disc_txt."
\"GRP\"
"; } } // print table row printf( "\n", $tablerow["id"], $tablerow["id"],$tablerow["id"], $statusind, $tablerow["report_date"], $dname, $tablerow["reported_by"], $disc_txt, $eff_icon ); } echo "
Select ID Status Date Device Reported by Discrepancy Msn Eff
%s %s %s %s %s %s %s
\n
Select the writeups above you'd like to add to the group and   

If nothing looks appropriate, you can modify the search parameters above and search again or select another menu option.
"; } else { echo " No writeups match your search parameters.

You can modify the search parameters above and search again or select another menu option. "; } } } } } elseif ($action=="remove") { if ($save && !$fail) { format_message(0,"Group successfully modified. Return to Writeup Groups page."); } elseif ($save && $fail) { format_message(2,"An error was encountered when modifying group. The error was \" $fail \""); } if ($role && mysqli_num_rows(mysqli_query($drs_db,"select id from links where linkgroup=$group"))) { // show group table with everything selected echo "
"; group_table($group,$role,"select","all"); echo " Deselect the writeups you want to remove from this group.

NOTE: Deselecting them all will dissolve the group.

     
"; } } elseif ($action=="dissolve") { if ($save && !$fail) { format_message(0,"Group dissolved. Return to Writeup Groups page."); } elseif ($save && $fail) { format_message(2,"An error was encountered when dissolving the group. The error was \" $fail \""); } else { if ($role) { echo "
NOTE: Dissolving this group will unassign its member writeups and remove the group.

It will not delete any writeups or affect their assignment to other groups.

     
"; } // show the group $mode="view"; group_table($group,$role,$mode); if ($role) { // show buttons echo "
                       
"; } } } elseif ($action=="setname") { if ($save && !$fail) { format_message(0,"Group name updated. Return to Writeup Groups page."); } elseif ($save && $fail) { format_message(2,"An error was encountered when updating the group name. The error was \" $fail \""); } if ($role) { // get current group name if there is one and show the form $curr_name=dblookup($drs_db,"groups","id","name",$group); echo "
     
"; } // show the group $mode="view"; group_table($group,$role,$mode); if ($role) { // show buttons echo "
                       
"; } } elseif ($action=="takeaction") { if ($save && !$fail) { format_message(0,"Group action completed. Return to Writeup Groups page."); } elseif ($save && $fail) { format_message(2,"An error was encountered when taking group action. The error was \" $fail \""); } // show the group $mode="view"; group_table($group,$role,$mode); if ($role && ! $save) { // show action form echo "
Status
Action taken by
"; if ($role==ADMIN) { // allow selection of tech name echo " "; } else { // limit the choice to the tech in question echo " "; } echo "
Status change reason
Action Taken (required)

Action Taken Date
Action Taken Time
"; } } else { if ($role) { echo "

"; } if ($group) { // show only the requested group $mode="view"; group_table($group,$role,$mode); if ($role) { // show buttons echo "
                       
"; } echo "

"; } else { // show all groups $mode="view"; $groups_qry=mysqli_query($drs_db,"select id from groups"); if (mysqli_num_rows($groups_qry)) { while ($grouprow=mysqli_fetch_assoc($groups_qry)) { if ($expandgrp == $grouprow['id']) { group_table($grouprow['id'],$role,$mode,"none",$expandgrp); if ($role) { // show buttons echo "
                       
"; } } else { echo " \"Expand "; $groupname=dblookup($drs_db,"groups","id","name",$grouprow['id']); if ($groupname == "") { echo "Group ID:  {$grouprow['id']}"; } else { echo "Group Name:  $groupname"; } } echo "

"; } } else { echo "
No writeup groups were found.


"; } } } echo "
"; banner($print); pageblock("right","end"); pagetable("end"); framework("end","","",$print); ?>