CodeIgniter Forums

Full Version: printing an invoice using CI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

[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.

El Forum

[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?

El Forum

[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();
        });
}

El Forum

[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".

El Forum

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