Incorporated changes for release 1.3.2
This commit is contained in:
@@ -8,9 +8,26 @@
|
||||
*/
|
||||
|
||||
include("common.php");
|
||||
if (array_key_exists('print',$_REQUEST)) {
|
||||
$print=true;
|
||||
} else {
|
||||
$print=false;
|
||||
}
|
||||
|
||||
if ($_REQUEST['exportcsv']) {
|
||||
$csv_filename="OpenDRS_Search_Results_" . date("Y-m-d_His") . ".csv";
|
||||
// redirect to search.php on cancel button press
|
||||
if (array_key_exists('cancel',$_REQUEST)) {
|
||||
header("Cache-Control:no-cache, must-revalidate");
|
||||
header("Pragma:no-cache");
|
||||
header("Location:search.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
// assign variables from constants
|
||||
$appname=APP_NAME;
|
||||
|
||||
if (array_key_exists('exportcsv',$_REQUEST)) {
|
||||
$exportcsv=true;
|
||||
$csv_filename="{$appname}_Search_Results_" . date("Y-m-d_His") . ".csv";
|
||||
// disable caching
|
||||
$now = gmdate("D, d M Y H:i:s");
|
||||
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
|
||||
@@ -25,51 +42,69 @@ if ($_REQUEST['exportcsv']) {
|
||||
// disposition / encoding on response body
|
||||
header("Content-Disposition: attachment;filename={$csv_filename}");
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
} else {
|
||||
$exportcsv=false;
|
||||
}
|
||||
|
||||
// import session variables
|
||||
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
|
||||
if (isset($_SESSION['userid'])) {
|
||||
$userid=$_SESSION['userid'];
|
||||
} else {
|
||||
$userid=NULL;
|
||||
}
|
||||
|
||||
// import incoming arrays
|
||||
$print=$_REQUEST['print'];
|
||||
$exportcsv=$_REQUEST['exportcsv'];
|
||||
if ($print || $exportcsv) {
|
||||
// if printer friendly or export csv was clicked, values will be
|
||||
// passed in serialized form as "all_parameters" so we need to load
|
||||
// those into $incoming[]
|
||||
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||
} else {
|
||||
if (!$_REQUEST['cancel']) $incoming=arrayCopy($_REQUEST);
|
||||
$incoming=arrayCopy($_REQUEST);
|
||||
}
|
||||
|
||||
// load variables from incoming array
|
||||
$search=$incoming['search'];
|
||||
$viewtype=$incoming['viewtype'];
|
||||
$s_device=$incoming['s_device'];
|
||||
$s_discovered=$incoming['s_discovered'];
|
||||
$s_functional=$incoming['s_functional'];
|
||||
$s_reported_by=$incoming['s_reported_by'];
|
||||
$s_report_date_start=$incoming['s_report_date_start'];
|
||||
$s_report_date_end=$incoming['s_report_date_end'];
|
||||
$s_report_time_start=$incoming['s_report_time_start'];
|
||||
$s_report_time_end=$incoming['s_report_time_end'];
|
||||
$s_action_date_start=$incoming['s_action_date_start'];
|
||||
$s_action_date_end=$incoming['s_action_date_end'];
|
||||
$s_action_time_start=$incoming['s_action_time_start'];
|
||||
$s_action_time_end=$incoming['s_action_time_end'];
|
||||
$s_action_by=$incoming['s_action_by'];
|
||||
$s_action_reason=$incoming['s_action_reason'];
|
||||
$s_action_text=$incoming['s_action_text'];
|
||||
$s_subsystem=$incoming['s_subsystem'];
|
||||
$s_id=$incoming['s_id'];
|
||||
$s_discrepancy_text=$incoming['s_discrepancy_text'];
|
||||
$s_status=$incoming['s_status'];
|
||||
$s_group=$incoming['s_group'];
|
||||
$sort=$incoming['sort'];
|
||||
$order=$incoming['order'];
|
||||
// extract incoming array keys into variables
|
||||
extract($incoming, EXTR_SKIP);
|
||||
/*
|
||||
* possible keys are:
|
||||
* search
|
||||
* viewtype
|
||||
* s_device
|
||||
* s_discovered
|
||||
* s_functional
|
||||
* s_reported_by
|
||||
* s_report_date_start
|
||||
* s_report_date_end
|
||||
* s_report_time_start
|
||||
* s_report_time_end
|
||||
* s_action_date_start
|
||||
* s_action_date_end
|
||||
* s_action_time_start
|
||||
* s_action_time_end
|
||||
* s_action_by
|
||||
* s_action_reason
|
||||
* s_action_text
|
||||
* s_subsystem
|
||||
* s_id
|
||||
* s_discrepancy_text
|
||||
* s_status
|
||||
* s_group
|
||||
* sort
|
||||
* order
|
||||
*/
|
||||
|
||||
// assign variables from constants
|
||||
$appname=APP_NAME;
|
||||
if (!isset($search)) $search=false;
|
||||
if (!isset($viewtype)) $viewtype="summary";
|
||||
if (!isset($s_id)) $s_id=NULL;
|
||||
if (!isset($s_discrepancy_text)) $s_discrepancy_text=NULL;
|
||||
if (!isset($s_reported_by)) $s_reported_by=NULL;
|
||||
if (!isset($s_action_text)) $s_action_text=NULL;
|
||||
if (!isset($s_action_date_start)) $s_action_date_start=NULL;
|
||||
if (!isset($s_action_date_end)) $s_action_date_end=NULL;
|
||||
if (!isset($s_action_time_start)) $s_action_time_start=NULL;
|
||||
if (!isset($s_action_time_end)) $s_action_time_end=NULL;
|
||||
if (!isset($sort)) $sort=NULL;
|
||||
if (!isset($order)) $order=NULL;
|
||||
|
||||
if ($print) {
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
@@ -93,10 +128,10 @@ if (! $exportcsv) framework("begin","$appname",$pgtitle,$print);
|
||||
// get min, max report and action_dates from writeups table, validate input dates/times and set defaults
|
||||
$minmaxqry=mysqli_query($drs_db,"select min(report_date),max(report_date),min(action_date),max(action_date) from writeups");
|
||||
$minmaxdates=mysqli_fetch_row($minmaxqry);
|
||||
if (!$s_report_date_start || !validateDate($s_report_date_start)) $s_report_date_start=$minmaxdates[0];
|
||||
if (!$s_report_date_end || !validateDate($s_report_date_end)) $s_report_date_end=$minmaxdates[1];
|
||||
if (!$s_report_time_start || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
|
||||
if (!$s_report_time_end || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
|
||||
if (!isset($s_report_date_start) || !validateDate($s_report_date_start)) $s_report_date_start=$minmaxdates[0];
|
||||
if (!isset($s_report_date_end) || !validateDate($s_report_date_end)) $s_report_date_end=$minmaxdates[1];
|
||||
if (!isset($s_report_time_start) || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
|
||||
if (!isset($s_report_time_end) || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
|
||||
|
||||
if ($search) {
|
||||
// strip whitespace from beginning and end of text fields
|
||||
@@ -303,10 +338,10 @@ if ($search) {
|
||||
$query_string="select * from writeups where {$query_string} order by $sort $order";
|
||||
|
||||
// group membership
|
||||
if ($s_group) {
|
||||
if (isset($s_group)) {
|
||||
$group_param="Group member: ";
|
||||
// create an array of writeups that are members of the groups specified
|
||||
$group_writeups=array();
|
||||
$group_writeups=[];
|
||||
foreach ($s_group as $group_val) {
|
||||
$wulink_query=mysqli_query($drs_db,"select writeupid from links where linkgroup=$group_val");
|
||||
while($wulinkrow=mysqli_fetch_assoc($wulink_query)){
|
||||
@@ -505,6 +540,7 @@ if (! $exportcsv) {
|
||||
Group Assignments:<br>
|
||||
<select style=\"max-width:40%;\" name=\"s_group[]\" id=\"ms-group\" multiple title=\"Select the groups the results should be a member of. If you uncheck them all, this field will not be included in the search.\">
|
||||
";
|
||||
if (!isset($s_group)) $s_group=[];
|
||||
$grow=mysqli_query($drs_db,"select * from groups order by id asc");
|
||||
while ($gitem=mysqli_fetch_assoc($grow)) {
|
||||
if ($gitem["name"]=="") {
|
||||
@@ -566,7 +602,11 @@ if (! $exportcsv) {
|
||||
";
|
||||
$persrow=mysqli_query($drs_db,"select id,firstname,lastname from users order by lastname asc");
|
||||
while ($persitem=mysqli_fetch_assoc($persrow)) {
|
||||
printf("<option value=\"%s\" selected>%s %s</option>",$persitem["id"],$persitem["firstname"],$persitem["lastname"]);
|
||||
if (!$search || in_array($persitem["id"],$s_action_by,true)) {
|
||||
printf("<option value=\"%s\" selected>%s %s</option>",$persitem["id"],$persitem["firstname"],$persitem["lastname"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s %s</option>",$persitem["id"],$persitem["firstname"],$persitem["lastname"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
@@ -584,7 +624,11 @@ if (! $exportcsv) {
|
||||
";
|
||||
$reasrow=mysqli_query($drs_db,"select id,text from reasons order by id asc");
|
||||
while ($reasitem=mysqli_fetch_assoc($reasrow)) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$reasitem["id"],$reasitem["text"]);
|
||||
if (!$search || in_array($reasitem["id"],$s_action_reason,true)) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$reasitem["id"],$reasitem["text"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$reasitem["id"],$reasitem["text"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
@@ -776,19 +820,20 @@ if ($search) {
|
||||
}
|
||||
$writeup=mysqli_query($drs_db,$query_string);
|
||||
// create an array of ids returned by the query string
|
||||
$result_ids=array();
|
||||
$result_ids=[];
|
||||
while ($eachid=mysqli_fetch_assoc($writeup)) {
|
||||
$result_ids[]=$eachid['id'];
|
||||
}
|
||||
|
||||
mysqli_data_seek($writeup,0);
|
||||
if (!isset($group_writeups)) $group_writeups=[];
|
||||
reset($group_writeups);
|
||||
$num_results=mysqli_num_rows($writeup);
|
||||
if ($num_results > 0) {
|
||||
if ($exportcsv) {
|
||||
// generate csv file
|
||||
// create an array of lines of the csv data
|
||||
$csv_data=array();
|
||||
$csv_data=[];
|
||||
$csv_data[]=['WriteupID','Status',$device_term,'Subsystem',$discovered_term_short,$functional_term,'Discrepancy','Group','Report date','Report time','Reported by','Action taken by','Status Change Reason','Action taken','Action date','Action time'];
|
||||
|
||||
$csv_fp=fopen('php://temp', 'w+');
|
||||
@@ -871,14 +916,10 @@ if ($search) {
|
||||
// action time for csv
|
||||
$csv_action_time="{$tablerow["action_time"]}";
|
||||
|
||||
|
||||
|
||||
if (($show_groupmems == $show_nongroupmems) || ($is_member && $show_groupmems) || (!$is_member && $show_nongroupmems)) {
|
||||
// add line of results to csv array
|
||||
$csv_data[]=[$csv_id, $csv_status_text, $csv_dname, $csv_ssname, $csv_discovered, $csv_func_text, $csv_disc_txt, $csv_member_group_name, $csv_report_date, $csv_report_time, $csv_reported_by_text, $csv_action_by, $csv_reasonname, $csv_action_text, $csv_action_date, $csv_action_time];
|
||||
|
||||
}
|
||||
// add line of results to csv array
|
||||
$csv_data[]=[$csv_id, $csv_status_text, $csv_dname, $csv_ssname, $csv_discovered, $csv_func_text, $csv_disc_txt, $csv_member_group_name, $csv_report_date, $csv_report_time, $csv_reported_by_text, $csv_action_by, $csv_reasonname, $csv_action_text, $csv_action_date, $csv_action_time];
|
||||
}
|
||||
|
||||
foreach ($csv_data as $csv_fields) {
|
||||
// add row to csv buffer
|
||||
fputcsv($csv_fp, $csv_fields);
|
||||
|
||||
Reference in New Issue
Block a user