Skip to content

Commit

Permalink
Merge pull request #8 from khoivan88/fix-DisposedChemical-view
Browse files Browse the repository at this point in the history
Fix disposed chemical view; Add storage barcode and user barcode column for their table in Settings
  • Loading branch information
rudolphi authored Jul 30, 2019
2 parents 250be8d + 2b8b144 commit 6198356
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
14 changes: 12 additions & 2 deletions lib_constants_columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
$columns["disposed_chemical_storage"]=$columns["chemical_storage"];
$columns["disposed_chemical_storage"]["disposed_when"]=DEFAULT_ON;
$columns["disposed_chemical_storage"]["disposed_by"]=DEFAULT_ON;
$columns["disposed_chemical_storage"]["emp_formula_short"]=DEFAULT_OFF;
$columns["disposed_chemical_storage"]["safety_sym"]=DEFAULT_OFF;
$columns["disposed_chemical_storage"]["safety_r_s"]=DEFAULT_OFF;
$columns["disposed_chemical_storage"]["owner_person_id"]=DEFAULT_OFF;
$columns["disposed_chemical_storage"]["comment_cheminstor"]=DEFAULT_ON;
$columns["disposed_chemical_storage"]["chemical_storage_barcode"]=DEFAULT_ON;

$columns["analytical_data"]=array(
"reaction_name" => DEFAULT_ON,
Expand Down Expand Up @@ -341,9 +347,11 @@

$columns["person"]=array(
"person_name" => DEFAULT_ON+NO_OFF,
"person_institution" => DEFAULT_ON+NO_OFF,
// "person_institution" => DEFAULT_ON+NO_OFF,
"person_institution" => DEFAULT_ON,
"username" => DEFAULT_ON+NO_OFF,
"permissions" => DEFAULT_ON+NO_OFF,
"person_barcode" => DEFAULT_ON,
"links_person" => DEFAULT_ON+NO_OFF,
);

Expand All @@ -368,7 +376,9 @@

$columns["storage"]=array(
"storage_name" => DEFAULT_ON+NO_OFF,
"institution" => DEFAULT_ON+NO_OFF,
// "institution" => DEFAULT_ON+NO_OFF,
"institution" => DEFAULT_ON, // Khoi: make option to turn this column off
"storage_barcode" => DEFAULT_ON, // Khoi: turn on storage barcode column
"links_storage" => DEFAULT_ON+NO_OFF,
);

Expand Down
19 changes: 17 additions & 2 deletions lib_constants_order_by.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
),
"for_table" => array("person"),
),
// Khoi: added for ordering of users according to barcode
"person_barcode" => array(
"columns" => array(
array("field" => "person_barcode"),
),
"for_table" => array("person"),
),

"storage_name" => array(
"columns" => array(
Expand All @@ -84,7 +91,14 @@
),
"for_table" => array("institution"),
),

// Khoi: added for ordering of users according to barcode
"storage_barcode" => array(
"columns" => array(
array("field" => "storage_barcode"),
),
"for_table" => array("storage"),
),

"from_person" => array(
"columns" => array(
array("field" => "from_person"),
Expand Down Expand Up @@ -236,7 +250,8 @@
"for_table" => array("chemical_storage"),
),
"disposed_when" => array(
"columns" => array(array("field" => "disposed_when", "order" => "DESC") ),
// "columns" => array(array("field" => "disposed_when", "order" => "DESC") ),
"columns" => array(array("field" => "disposed_when", "order" => "ASC") ), // Khoi: date search in asc order: oldest -> newest; desc: newest -> oldest
"for_table" => array("chemical_storage"),
),
"disposed_by" => array(
Expand Down
24 changes: 23 additions & 1 deletion lib_output.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,10 @@ function addTHeadCell(& $output,& $fieldIdx,$fullCol,$paramHash=array()) { // gi
case "person_institution":
case "username":
case "permissions":
case "person_barcode";
case "storage_name":
case "institution":
case "storage_barcode";
case "from_person":
case "issued":
case "message_subject":
Expand Down Expand Up @@ -2136,9 +2138,20 @@ function addTBodyCell(& $output,& $files,$idx,$subidx,& $fieldIdx,$row,$col,$par
else {
$retval=($row["pos_liste"]?s("pos_liste"):"")." ".($row["neg_liste"]?s("neg_liste"):"");
}
break; case "institution":
break;

// Khoi: Storage --------------------------------------------------------------------------
case "institution":
$retval=joinIfNotEmpty(array($row["institution_name"],$row["city"]),", ");
break;
case "storage_barcode":
if (!empty($row[$col])) {
$retval=$row[$col];
}
else {
$retval=getEAN8(findBarcodePrefixForPk("storage"),$row["storage_id"]);
}
break;
case "links_storage":
if ($paramHash["output_type"]=="html") {
$retval=getCombiButton(array(
Expand Down Expand Up @@ -2196,6 +2209,15 @@ function addTBodyCell(& $output,& $files,$idx,$subidx,& $fieldIdx,$row,$col,$par
$retval=@join("; ",a("permissions_list",$row["permissions"]));
}
break;
// Khoi: add person barcode as a view column
case "person_barcode":
if (!empty($row[$col])) {
$retval=$row[$col];
}
else {
$retval=getEAN8(findBarcodePrefixForPk("person"),$row["person_id"]);
}
break;
case "links_person":
if ($paramHash["output_type"]=="html") {
if ($permissions & (_lj_read+_lj_read_all)) {
Expand Down
3 changes: 2 additions & 1 deletion list.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
$desired_action=$_REQUEST["desired_action"];
$name=s($baseTable);

if (empty($_REQUEST["fields"]) && !empty($g_settings["views"][$baseTable]["view_standard"])) {
// Khoi: added $_REQUEST["table"] != "disposed_chemical_storage" to have disposed_chemicals list display correctly
if ($_REQUEST["table"] != "disposed_chemical_storage" && empty($_REQUEST["fields"]) && !empty($g_settings["views"][$baseTable]["view_standard"])) {
$_REQUEST["fields"]=$g_settings["views"][$baseTable]["view_standard"];
}

Expand Down

0 comments on commit 6198356

Please sign in to comment.