This topic is locked
[SOLVED]

 Print from View page

8/6/2020 4:50:07 PM
PHPRunner General questions
W
WilliamB authorDevClub member

I have a Bill of Lading app that after a record is created and line items are added (details table), it goes to the view page. From here the user can click on one of 3 custom buttons that open 3 different print pages (Bill of Lading, Commercial Invoice, CUSMA) based on the open record.
My code to direct to the appropriate page is below:
Server

$record = $button->getCurrentRecord();

$result["recid"] = $record["ship_id"];


Client after

var id = result["recid"];

var URL = 'bol_main_print.php?page=print_bol&editid1='+id;

window.open(URL, '_blank');


And then on the printer friendly Before SQL query:

if($_GET["editid1"])

$strWhereClause = "ship_id = ".$_GET["editid1"];


Everything directs properly, the proper print page is displayed (Bill of Lading, Commercial Invoice, CUSMA) but on the print page the line items (record details) do not display. It is as if the link is lost after you do the $strWhereClause.
Also if you print (Bill of Lading, Commercial Invoice, CUSMA) from the list page all line items are displayed. This was done by adding two more print buttons and selecting what print page to go to through page designer.
Any idea if I need to add something to the Before SQL query on the printer friendly event?? Any help or ideas welcome.
Thanks,

Billy

Sergey Kornilov admin 8/7/2020

Printer-friendly pages are designed to be open after their respective list pages. The List page populates some session variables that are being used on the printer page lately. If you open printer friendly page directly those variables will be empty and this is why you do not see details tables data, the printer page won't know that we are in the master-details mode.
So you need to investigate what session variables need to be populated by going the "normal" route first and then set those variables in your Server event before redirecting to the printer page.

W
WilliamB authorDevClub member 8/10/2020



Printer-friendly pages are designed to be open after their respective list pages. The List page populates some session variables that are being used on the printer page lately. If you open printer friendly page directly those variables will be empty and this is why you do not see details tables data, the printer page won't know that we are in the master-details mode.
So you need to investigate what session variables need to be populated by going the "normal" route first and then set those variables in your Server event before redirecting to the printer page.


Sergey,
I am looking at the session array and compare it in notepad++. The print page from the list page shows that same as the one from my view page. I actually have 3 extra session var on the print page after coming from my button.
I have these 3 extra:



[dbo.bol_lines_search] => 0

[dbo.bol_lines_pagenumber] => 1

[dbo.bol_main_advsearch] => C:12:"SearchClause":3212:{a:28:{s:6:"_where";a:0:{}s:5:"tName";s:12:"dbo.bol_main";s:8:"pageName";N;s:15:"searchFieldsArr";a:48:{i:0;s:7:"ship_id";i:1;s:9:"ship_date";i:2;s:9:"ship_type";i:3;s:7:"so_curr";i:4;s:9:"ship_ship";i:5;s:13:"ship_shipname";i:6;s:11:"ship_consig";i:7;s:15:"ship_consigname";i:8;s:11:"ship_billto";i:9;s:15:"ship_billtoname";i:10;s:10:"ship_buyer";i:11;s:14:"ship_buyername";i:12;s:12:"ship_carrier";i:13;s:15:"ship_exportname";i:14;s:11:"ship_broker";i:15;s:7:"ship_bl";i:16;s:9:"ship_duty";i:17;s:12:"ship_freight";i:18;s:11:"ship_weight";i:19;s:12:"ship_packing";i:20;s:10:"ship_terms";i:21;s:8:"ship_via";i:22;s:10:"ship_notes";i:23;s:9:"int_notes";i:24;s:10:"bol_status";i:25;s:4:"name";i:26;s:7:"sigfile";i:27;s:5:"title";i:28;s:8:"ship_add";i:29;s:12:"ship_contact";i:30;s:10:"ship_phone";i:31;s:8:"ship_tax";i:32;s:10:"consig_add";i:33;s:14:"consig_contact";i:34;s:12:"consig_phone";i:35;s:10:"consig_tax";i:36;s:9:"buyer_add";i:37;s:13:"buyer_contact";i:38;s:11:"buyer_phone";i:39;s:9:"buyer_tax";i:40;s:11:"fbillto_add";i:41;s:15:"fbillto_contact";i:42;s:13:"fbillto_phone";i:43;s:11:"fbillto_tax";i:44;s:12:"broker_notes";i:45;s:11:"total_value";i:46;s:5:"sonum";i:47;s:13:"cusmacerttype";}s:16:"googleLikeFields";a:11:{i:0;s:7:"ship_id";i:1;s:13:"ship_shipname";i:2;s:15:"ship_consigname";i:3;s:15:"ship_billtoname";i:4;s:14:"ship_buyername";i:5;s:15:"ship_exportname";i:6;s:11:"ship_broker";i:7;s:7:"ship_bl";i:8;s:10:"ship_notes";i:9;s:9:"int_notes";i:10;s:5:"sonum";}s:8:"srchType";s:10:"integrated";s:13:"sessionPrefix";s:12:"dbo.bol_main";s:11:"bIsUsedSrch";b:0;s:16:"filtersActivated";b:0;s:18:"simpleSearchActive";b:0;s:20:"advancedSearchActive";b:0;s:19:"haveAggregateFields";b:0;s:17:"panelSearchFields";b:0;s:13:"searchOptions";a:16:{s:8:"contains";a:2:{s:6:"option";s:8:"Contains";s:3:"not";b:0;}s:6:"equals";a:2:{s:6:"option";s:6:"Equals";s:3:"not";b:0;}s:10:"startswith";a:2:{s:6:"option";s:11:"Starts with";s:3:"not";b:0;}s:8:"morethan";a:2:{s:6:"option";s:9:"More than";s:3:"not";b:0;}s:8:"lessthan";a:2:{s:6:"option";s:9:"Less than";s:3:"not";b:0;}s:7:"between";a:2:{s:6:"option";s:7:"Between";s:3:"not";b:0;}s:5:"empty";a:2:{s:6:"option";s:5:"Empty";s:3:"not";b:0;}s:9:"lessequal";a:2:{s:6:"option";s:9:"More than";s:3:"not";b:1;}s:9:"moreequal";a:2:{s:6:"option";s:9:"Less than";s:3:"not";b:1;}s:10:"notcontain";a:2:{s:6:"option";s:8:"Contains";s:3:"not";b:1;}s:8:"notequal";a:2:{s:6:"option";s:6:"Equals";s:3:"not";b:1;}s:12:"notstartwith";a:2:{s:6:"option";s:11:"Starts with";s:3:"not";b:1;}s:11:"notmorethan";a:2:{s:6:"option";s:9:"More than";s:3:"not";b:1;}s:11:"notlessthan";a:2:{s:6:"option";s:9:"Less than";s:3:"not";b:1;}s:10:"notbetween";a:2:{s:6:"option";s:7:"Between";s:3:"not";b:1;}s:8:"notempty";a:2:{s:6:"option";s:5:"Empty";s:3:"not";b:1;}}s:18:"fieldDelimiterLeft";s:1:")";s:19:"fieldDelimiterRight";s:1:"(";s:14:"valueDelimiter";s:1:"~";s:19:"fieldsUsedForSearch";a:0:{}s:17:"localEditControls";N;s:19:"isShowSimpleSrchOpt";b:0;s:12:"searchParams";a:0:{}s:16:"savedSearchIsRun";b:0;s:14:"filteredFields";a:0:{}s:19:"searchSavingEnabled";b:1;s:9:"dashTName";s:0:"";s:20:"wholeDashboardSearch";b:0;s:21:"dashboardSearchClause";N;s:24:"customFieldSQLConditions";a:0:{}}}


I am using the below to see the session vars:

echo "<pre>".print_r($_SESSION, true)."</pre>";


Am I looking in the wrong place? I thought I understood what you were saying.
Thanks

Billy

Sergey Kornilov admin 8/10/2020

Make sure you are visiting details page via master table page first. There should be variables related to the master-details relationship.

[order details_preview_masterkey1] => 10285

[order details_mastertable] => orders
W
WilliamB authorDevClub member 8/11/2020



Make sure you are visiting details page via master table page first. There should be variables related to the master-details relationship.

[order details_preview_masterkey1] => 10285

[order details_mastertable] => orders



I think I see what you are saying. I have changed my code and added to set the session vars but it is still not working. No details are displayed on the print page.

if($_GET["editid1"]){
$strWhereClause = "ship_id = ".$_GET["editid1"];
$_SESSION["dbo.bol_lines_masterkey1"] = $_GET["editid1"];

$_SESSION["dbo.bol_lines_mastertable"] = "dbo.bol_main";
}


Maybe I am not setting the session vars in the right spot?
Billy

W
WilliamB authorDevClub member 8/12/2020

I got this to work. Not sure if it is the correct way buy it seems to always gives the correct result.
I removed trying to set session vars as admin said and passed the details table in the URL in my button code. So the only thing changed from my original post is the client after.

var id = result["recid"];

var URL = 'bol_main_print.php?page=print_bol&details=bol_lines&editid1='+id;

window.open(URL, '_blank');


Cheers!

Billy