CodeIgniter Forums
printing an invoice using CI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: printing an invoice using CI (/thread-32804.html)



printing an invoice using CI - El Forum - 08-05-2010

[eluser]rangana[/eluser]
Hi guys,

I'm just started CI and,I'm developing a system for a hospital as my university project, i need to print a invoice kind of thing (actually it is a small chit given to the patient, it has patient reference number, doctor unit etc.) i want to print the point at the point where patient is registered as a patient in the hospital. can you please help me to do this? any tutorial link, or simple explanation containing how to do it is good!

regards,
Rangana


printing an invoice using CI - El Forum - 08-05-2010

[eluser]rwestergren[/eluser]
This isn't very specific, but you'll just need to pass your query results to the view with something like this:
Code:
//Get query results
$data['result'] = $this->SomeModel->someFunction();

//Pass to view
$this->load->view('someView', $data);

Display the results in view:
Code:
echo $result['column'];

Format the view however you'd like.


printing an invoice using CI - El Forum - 08-05-2010

[eluser]rangana[/eluser]
what i meant was i need to take a hard copy of the registration form, now we can put a print button there, how to code to that button? that was my question? how to perform a printout by pressing a button, how to code to the button it self to get out a print out?


printing an invoice using CI - El Forum - 08-05-2010

[eluser]rwestergren[/eluser]
[quote author="rangana" date="1281038947"]what i meant was i need to take a hard copy of the registration form, now we can put a print button there, how to code to that button? that was my question? how to perform a printout by pressing a button, how to code to the button it self to get out a print out?[/quote]

Coding a button to print the current page? You can bind a jQuery click event to the button and have it print like this:

Code:
$(document).ready(function()
{
        $('#button1').click(function()
        {
             window.print();
        });
}



printing an invoice using CI - El Forum - 08-05-2010

[eluser]stevezissou[/eluser]
Also, I would make use of CSS for print. i.e.

Code:
<link rel="stylesheet" href="yourdomain.com/print.css" type="text/css" media="print" />

You can then format your "invoice for print" separately from your "onscreen invoice".


printing an invoice using CI - El Forum - 08-05-2010

[eluser]rangana[/eluser]
Thank you very much rwestergren and stevezissou for the valuable answers, thanx again!