7 Replies Latest reply on Jul 26, 2016 7:38 PM by fac586

    Keep tables on same page when printing

    ChoMan23

      I have a report that I am creating through PL/SQL and I need the tables to not split pages. If a new table is being created and it is going to split pages, I need it to start on a new page. I am using the Printer Friendly template. We are also on APEX 4.1. Any help would be greatly appreciated.

       

      Here is what I have in the HTML header of the page.Here is the PL/SQL code used to create the report.

       

      DECLARE

      vCount NUMBER;

      vSummaryCount NUMBER;

       

       

      BEGIN

       

       

      vCount:= 0;

      vSummaryCount := 0;

       

       

      FOR rec IN( select

            DISTINCT

            c.census_id

            ,TO_CHAR(c.census_date,'MM/DD/YYYY') AS census_date

            ,ss.shift_text

            ,c.constant_attendants

            ,c.dept_id

            ,d.dept_desc

            ,c.census_count

            ,c.workload_adjusted_census

            ,c.entered_by

            ,c.comments

            ,c.staffing_comments

            ,di.CHARGE_PAGER

            ,di.UNIT_NUMBER

            ,di.SORT_ORDER

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 2 THEN REQUESTED_COUNT END),0) AS REQUESTED_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 4 THEN REQUESTED_COUNT END),0) AS REQUESTED_PCA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 6 THEN REQUESTED_COUNT END),0) AS REQUESTED_UC

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 8 THEN REQUESTED_COUNT END),0) AS REQUESTED_LPN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 5 THEN REQUESTED_COUNT END),0) AS REQUESTED_CA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 1 THEN REQUESTED_COUNT END),0) AS REQUESTED_CHARGE_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 9 THEN REQUESTED_COUNT END),0) AS REQUESTED_MHT

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 13 THEN REQUESTED_COUNT END),0) AS REQUESTED_RN_EMU

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 2 THEN SPARED_COUNT END),0) AS SPARED_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 4 THEN SPARED_COUNT END),0) AS SPARED_PCA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 6 THEN SPARED_COUNT END),0) AS SPARED_UC

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 8 THEN SPARED_COUNT END),0) AS SPARED_LPN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 5 THEN SPARED_COUNT END),0) AS SPARED_CA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 1 THEN SPARED_COUNT END),0) AS SPARED_CHARGE_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 9 THEN SPARED_COUNT END),0) AS SPARED_MHT

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 13 THEN SPARED_COUNT END),0) AS SPARED_RN_EMU

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 2 THEN SCHEDULED_STAFFING END),0)   AS SCHEDULED_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 4 THEN SCHEDULED_STAFFING END),0)   AS SCHEDULED_PCA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 6 THEN SCHEDULED_STAFFING END),0)   AS SCHEDULED_UC

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 8 THEN SCHEDULED_STAFFING END),0)   AS SCHEDULED_LPN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 3 THEN SCHEDULED_STAFFING END),0)   AS SCHEDULED_RN_CARE_PARTNER

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 12 THEN SCHEDULED_STAFFING END),0)  AS SCHEDULED_RESOURCE_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 5 THEN SCHEDULED_STAFFING END),0)  AS SCHEDULED_CA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 1 THEN SCHEDULED_STAFFING END),0)  AS SCHEDULED_CHARGE_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 9 THEN SCHEDULED_STAFFING END),0)  AS SCHEDULED_MHT

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 13 THEN SCHEDULED_STAFFING END),0)  AS SCHEDULED_RN_EMU

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 2 THEN WORKLOAD_ADJUSTED_STAFFING END),0)   AS STAFF_NEED_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 4 THEN WORKLOAD_ADJUSTED_STAFFING END),0)   AS STAFF_NEED_PCA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 6 THEN WORKLOAD_ADJUSTED_STAFFING END),0)   AS STAFF_NEED_UC

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 8 THEN WORKLOAD_ADJUSTED_STAFFING END),0)   AS STAFF_NEED_LPN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 3 THEN WORKLOAD_ADJUSTED_STAFFING END),0)   AS STAFF_NEED_RN_CARE_PARTNER

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 12 THEN WORKLOAD_ADJUSTED_STAFFING END),0)  AS STAFF_NEED_RESOURCE_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 13 THEN WORKLOAD_ADJUSTED_STAFFING END),0)  AS STAFF_NEED_RN_EMU

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 5 THEN TOTAL_STAFFING_TARGETS END),0)  AS STAFF_NEED_CA

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 1 THEN SCHEDULED_STAFFING END),0)  AS STAFF_NEED_CHARGE_RN

            ,NVL(SUM(CASE WHEN cp.PROVIDER_TYPE_ID = 9 THEN SCHEDULED_STAFFING END),0)  AS STAFF_NEED_MHT

            from

            APEX_DATA.nurse_staffing_census_counts c

              INNER JOIN APEX_DATA.nurse_staffing_shift ss

                ON ss.shift_id = c.shift_id

              INNER JOIN dept d

                on d.dept_id = c.dept_id

              INNER JOIN APEX_DATA.NURSE_STAFF_TARGET_CNTS_PROV cp

                ON c.CENSUS_ID = cp.CENSUS_ID

             LEFT JOIN APEX_DATA.DEPT_INFORMATION di

                ON d.dept_id = di.dept_id

      where ss.shift_id = :P5_SHIFT

           and c.census_date = TO_DATE(:P5_CENSUS_DATE,'MM/DD/YYYY')

           and (c.dept_id = :P5_DEPARTMENT OR :P5_DEPARTMENT = '-1')

      GROUP BY    

      c.census_id

            ,c.census_date

            ,ss.shift_text

            ,c.constant_attendants

            ,c.dept_id

            ,d.dept_desc

            ,c.census_count

            ,c.entered_by

            ,c.comments

            ,di.CHARGE_PAGER

            ,di.UNIT_NUMBER

            ,di.SORT_ORDER

            ,c.workload_adjusted_census

            ,c.staffing_comments

      ORDER BY di.SORT_ORDER  

      )

       

      LOOP

       

      htp.p('<div class="facilityNote" style="border-left:1px solid #90A3C2;padding:1px;width:700px";>');

       

       

      htp.p('<strong>' || rec.dept_desc || '         &nbsp' || '</strong>'|| '<b>' || 'Charge Number ' ||'</b>'|| rec.CHARGE_PAGER ||

      '       &nbsp' || '<b>'|| 'Unit Number ' ||'</b>'|| rec.UNIT_NUMBER);

       

       

      htp.p('<div style="padding:1+px;display:table;">

       

       

      <table border="1">

      <tr>

      <th>&nbsp Census Date &nbsp</th>

      <th>&nbsp Shift &nbsp</th>

      <th>&nbsp CA &nbsp</th>

      <th>&nbsp Census &nbsp</th>

      <th>&nbsp Workload Adjusted Census &nbsp</th>

      </tr>

      <tr>

      <td align="center">'||rec.census_date||'</td>

      <td align="center">'||rec.shift_text||'</td>

      <td align="center">'||rec.constant_attendants||'</td>

      <td align="center">'||rec.census_count||'</td>

      <td align="center">'||rec.workload_adjusted_census||'</td>

      </tr>

      </table>

       

       

      <table style="float:left;margin-top:25px" border="1">

      <tr>

      <th>Request Type</th>

      <th>Charge RN</th>

      <th>RN</th>

      <th>PCA</th>

      <th>UC</th>

      <th>LPN</th>

      <th>RN CP</th>

      <th>RN RES</th>

      <th>CA</th>

      <th>MHT</th>

      <th>RN EMU</th>

      </tr>

      <tr >

      <td align="center">'|| 'REQUIRED STAFFING' ||'</td>

      <td align="center">'||rec.STAFF_NEED_CHARGE_RN||'</td>

      <td align="center">'||rec.STAFF_NEED_RN||'</td>

      <td align="center">'||rec.STAFF_NEED_PCA||'</td>

      <td align="center">'||rec.STAFF_NEED_UC||'</td>

      <td align="center">'||rec.STAFF_NEED_LPN||'</td>

      <td align="center">'||rec.STAFF_NEED_RN_CARE_PARTNER||'</td>

      <td align="center">'||rec.STAFF_NEED_RESOURCE_RN||'</td>

      <td align="center">'||rec.STAFF_NEED_CA||'</td>

      <td align="center">'||rec.STAFF_NEED_MHT||'</td>

      <td align="center">'||rec.STAFF_NEED_RN_EMU||'</td>

      </tr>

      <tr >

      <td align="center">'|| 'SCHEDULED' ||'</td>

      <td align="center">'||rec.SCHEDULED_CHARGE_RN||'</td>

      <td align="center">'||rec.SCHEDULED_RN||'</td>

      <td align="center">'||rec.SCHEDULED_PCA||'</td>

      <td align="center">'||rec.SCHEDULED_UC||'</td>

      <td align="center">'||rec.SCHEDULED_LPN||'</td>

      <td align="center">'||rec.SCHEDULED_RN_CARE_PARTNER||'</td>

      <td align="center">'||rec.SCHEDULED_RESOURCE_RN||'</td>

      <td align="center">'||rec.SCHEDULED_CA||'</td>

      <td align="center">'||rec.SCHEDULED_MHT||'</td>

      <td align="center">'||rec.SCHEDULED_RN_EMU||'</td>

      </tr>

      <tr >

      <td align="center">'|| 'SPARED' ||'</td>

      <td align="center">'||rec.SPARED_CHARGE_RN||'</td>

      <td align="center">'||rec.SPARED_RN||'</td>

      <td align="center">'||rec.SPARED_PCA||'</td>

      <td align="center">'||rec.SPARED_UC||'</td>

      <td align="center">'||rec.SPARED_LPN||'</td>

      <td align="center">'||0||'</td>

      <td align="center">'||0||'</td>

      <td align="center">'||rec.SPARED_CA||'</td>

      <td align="center">'||rec.SPARED_MHT||'</td>

      <td align="center">'||rec.SPARED_RN_EMU||'</td>

      </tr>

      <tr >

      <td align="center">'|| 'REQUESTED' ||'</td>

      <td align="center">'||rec.REQUESTED_CHARGE_RN||'</td>

      <td align="center">'||rec.REQUESTED_RN||'</td>

      <td align="center">'||rec.REQUESTED_PCA||'</td>

      <td align="center">'||rec.REQUESTED_UC||'</td>

      <td align="center">'||rec.REQUESTED_LPN||'</td>

      <td align="center">'||0||'</td>

      <td align="center">'||0||'</td>

      <td align="center">'||rec.REQUESTED_CA||'</td>

      <td align="center">'||rec.REQUESTED_MHT||'</td>

      <td align="center">'||rec.REQUESTED_RN_EMU||'</td>

      </tr>

       

       

      </table>

       

       

      </div>

      ')

      ;

       

       

      htp.p('<br>');

      htp.p('<strong>' || 'Workload Indicator Comments' || '</strong>');

      htp.p(rec.comments);

       

       

       

       

      htp.p('<br>');

      htp.p('<br>');

       

       

      htp.p('<strong>' || 'Staffing Comments' || '</strong>');

      htp.p(rec.staffing_comments);

       

       

      htp.p('<br>');

      htp.p('<br>');

      htp.p('<br>');

       

       

      htp.p('<hr>');

      vCount := vCount + 1;

       

       

      END LOOP;

      htp.p('</div>');

      END;

       

      Here is the HTML header of the page.

       

      <style>

       

       

        @media screen

         {

         .apex_toolbar, .control_panel, .app-user{font-family:verdana,sans-serif;font-size:14px;}

         }

      @media print

         {

         .apex_toolbar, .control_panel, margin-left:5cm, .app-user{font-family:times,serif;font-size:10px;

      #t17NavBar, #t17Tabs, #t17PageFooter, #P1_SUBMIT, #PRINT, #style-sheet {

       

       

      display: none;

       

       

      }

      }

      @page{

        margin: 1cm!important;

      }

       

       

         }

      @media screen,print

         {

         p.test {font-weight:bold;}

         }

      }

      </style>

        • 1. Re: Keep tables on same page when printing
          TexasApexDeveloper

          Why did you feel the need to HAND-CODE your report when either a Interactive report or a Standard Report could have been used?  Hand-coding of the HTML and such will ultimately cause yoiu more grief that it's worth.  If yo uneed a specific layout you can do this with Standard reports and a custom layout (too many threads here dealing with it to list, just do a google search..)..

           

          Thank you,

           

          Tony Miller

          Los Alamos, NM

          • 2. Re: Keep tables on same page when printing
            ChoMan23

            Thanks for the response, but it needed done this way because of how the application is set up. The report itself is very customized and it would pretty difficult to get a standard report to look like it does.The way it is setup is there is a link for administration to just click a button and have the report printed. I have googled many times and cannot find a solution that fits what I am doing.

            • 3. Re: Keep tables on same page when printing
              TexasApexDeveloper

              I think you should have asked Fac586 about a custom layout using a standard report, he would argue that you CAN do the layout you want.  And where exactly is the link to print the report?  How exactly are you printing the report?  You mean it sends it to the screen and then the user prints that report?  Again very clumsy in my honest opinion.. Not taking advantage of the APEX environment, you could do something like this with a straight HTML page...

               

              Thank you,

               

              Tony Miller

              Los Alamos, NM

              • 4. Re: Keep tables on same page when printing
                ChoMan23

                I am thankful for your responses and I understand it could have been done differently, but it wasn't. There is a link in the top right that allows the users to then select some parameters to run the report. It then send to the screen and they print it. I understand you say there are better ways, but I am just looking for a way to solve my questions as it stands now. I am thankful for your knowledge and I will take it moving forward, but I cannot change the application right now.

                • 5. Re: Keep tables on same page when printing
                  TexasApexDeveloper

                  But to resolve the isue you have, you WILL be required to change the application, right?  Most people will look at what you have done and give the same recommendation, not try and help you go further into a bad idea...

                   

                  If you don't want to hear the answer, then you shouldn't ask the question...

                   

                  Thank you,

                   

                  Tony Miller

                  Los Alamos, NM

                  • 6. Re: Keep tables on same page when printing
                    ChoMan23

                    I completely understand your recommendation and agree, but we don't have the time to stop and completely redo the report. This is something that is needed ASAP and I was hoping to find a quick answer to my current problem. I am thankful for your opinion.

                    • 7. Re: Keep tables on same page when printing
                      fac586

                      TexasApexDeveloper wrote:

                       

                      I think you should have asked Fac586 about a custom layout using a standard report, he would argue that you CAN do the layout you want.

                      Of course you can. There's nothing "very customized" about the report, it's simply a repeating table, which can easily be generated using a custom report template.

                      ChoMan23 wrote:

                       

                      I have a report that I am creating through PL/SQL and I need the tables to not split pages. If a new table is being created and it is going to split pages, I need it to start on a new page. I am using the Printer Friendly template.

                      Use the CSS page-break-before/after property in a rule applied to the relevant element(s).