⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


Creating Custom Header During Printing

Custom Header Custom Footer Print Enterprise

  • Please log in to reply
11 replies to this topic

#1 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 23 June 2017 - 08:09 AM

In the Community Edition I was able to create a custom header and footer during printing (clicking the print button). 

See image for reference: 

 

image.png

I did it by modifying the file:Grocery_CRUD.php located in 'application\libraries\'

and adding the following line above the code: $string_to_print .= '<table width="100%" cellpadding="0" cellspacing="0" ><tr>';

//LARA ADDED THIS LAST NOV.30, 2016 TO ALLOW CUSTOM HEADER DURING PRINT
if(isset($_SESSION['CustomHeader']) && $_SESSION['CustomHeader']<>'') $string_to_print .= $_SESSION['CustomHeader'];

Now I was wondering if It can be done in the Enterprise Edition by using a custom model instead of editing the core or library.

This would be useful to fully maximize the printout or report generated by the CRUD.

 



#2 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 04 July 2017 - 01:37 AM

Any ideas in this one? 



#3 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 11 July 2017 - 05:17 AM

Sir @web-johnny,
 
Please provide a hidden div or table on the top and bottom part of the print out.
In that way I can use it to place my custom header and footer and I will not
need to edit the core of GroceryCRUD.
 
If you had better ideas than this method it would be great.
 
Thanks!


#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 13 July 2017 - 05:24 AM

Well need to look ahead in the Enterprise Edition so far for the functionality.. But one thing - you may need to alter the library (core to add functionality) .. and also the read file template.

 

What you can do in there is.. add the same in a certain print only css class so it will be enabled in case of printing and not in case of simply viewing.

 

Happy GCing :)



#5 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 14 July 2017 - 12:22 AM

Well need to look ahead in the Enterprise Edition so far for the functionality.. But one thing - you may need to alter the library (core to add functionality) .. and also the read file template.

 

What you can do in there is.. add the same in a certain print only css class so it will be enabled in case of printing and not in case of simply viewing.

 

Happy GCing :)

 

Thank you for this.

I'll look into it.  :)



#6 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 19 July 2017 - 02:34 AM

I was able to accomplish this again by modifying certain files of the core.

 

Again I added (For the Header):

<?php if(isset($_SESSION["CustomHeader"]) && $_SESSION["CustomHeader"]<>'') echo $_SESSION["CustomHeader"]; ?>

and for the Footer:

<?php if(isset($_SESSION["CustomFooter"]) && $_SESSION["CustomFooter"]<>'') echo $_SESSION["CustomFooter"]; ?>

to the file: "main.html"

located in: "application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Themes\Bootstrap\views\build\"

 

I just hope this helps some who are needing this functionality.

 

Happy Gcing to all  :)  ;)  :lol:



#7 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 19 July 2017 - 06:46 AM

Great Job ...

 

Good to see you cracking it so good.

 

Happy GCing:)



#8 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 13 October 2017 - 12:57 AM

Updates to this post: If you upgrade to 2.3.5.

 

The lines to add in: the file: "main.html" located in: "application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Themes\Bootstrap\views\build\" are:

<?php if(isset($_SESSION["CustomHeader"]) && $_SESSION["CustomHeader"]<>'') echo $_SESSION["CustomHeader"]; ?>

and

<?php if(isset($_SESSION["CustomFooter"]) && $_SESSION["CustomFooter"]<>'') echo $_SESSION["CustomFooter"]; ?>


Happy Gcing to all   :)   ;)   :lol:



#9 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 28 October 2017 - 08:39 AM

ANOTHER UPDATE:

 

I noticed that upon update the line number may change.

 

So instead of specifying the line number, just find:

<div class="print-table">
and paste: 
<?php if(isset($_SESSION["CustomHeader"]) && $_SESSION["CustomHeader"]<>'') echo $_SESSION["CustomHeader"]; ?>

before the tag: <table> and:

<?php if(isset($_SESSION["CustomFooter"]) && $_SESSION["CustomFooter"]<>'') echo $_SESSION["CustomFooter"]; ?> 

after the tag: </table>

 

Happy Gcing to all    :)    ;)    :lol:



#10 langithitam

langithitam

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 09 November 2017 - 05:55 AM

Hy larasmith,

 

I'm new in php and gc, can you show me example to echo $_SESSION["CustomHeader"]; 

from your code?

 

thanks



#11 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 09 November 2017 - 06:27 AM

Hello @langithitam!

 

Sure... This is how I do it:

 

Prior generating the list the custom header is assigned to the session variable:

$_SESSION['CustomHeader']   = $this->m_Shared->CreateCustomHeader("Security Log List");

and the output is:

Sample01.png

 

Please do take note that CreateCustomHeader there in my code is function that customly formats my header.

 

You can actually just assign any text to the custom header for example:

$_SESSION['CustomHeader']   = "This is my sample header.";

and the output is:

Sample02.png

 

 

Happy GCing!  :)  ;)  :D



#12 nazzo

nazzo

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 06 November 2018 - 08:09 AM

In the Community Edition I was able to create a custom header and footer during printing (clicking the print button). 

See image for reference: 

 

image.png

I did it by modifying the file:Grocery_CRUD.php located in 'application\libraries\'

and adding the following line above the code: $string_to_print .= '<table width="100%" cellpadding="0" cellspacing="0" ><tr>';

//LARA ADDED THIS LAST NOV.30, 2016 TO ALLOW CUSTOM HEADER DURING PRINT
if(isset($_SESSION['CustomHeader']) && $_SESSION['CustomHeader']<>'') $string_to_print .= $_SESSION['CustomHeader'];

Now I was wondering if It can be done in the Enterprise Edition by using a custom model instead of editing the core or library.

This would be useful to fully maximize the printout or report generated by the CRUD.

Hi larasmith.

This is great. How do I get a logo into the print too.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users