Create an invoice from table data

RobertG

Member
Hi,

I didn't find here and in the wiki sufficient explanations to do what I'm looking for.
I have a booking form where are added some data I will use later to create an invoice. I don't want to create the invoice on submit but once the booking is validated.
I wonder how to add a button to the list/detail view to create the invoice for the selected row using a new form or directly picking data in the table and print them as PDF.

Could you help me, please?
 
Thanks dimoss!

I saw this page previously and used PDF on a form, but as said troester, printing a form doesn't print data (I wanted to print after filling a form and before submitting it, so I had only labels).
If I understand, I need to create a new list with only the fields I need for the invoice, and add the PDF button.

I know how to select a row in a database with a form databasejoin element but I don't know how to automatically fill in the other fields of the form with data from the same row (for example choose last name and first name in the dropdown and fill in phone, address, etc. or type a 'token' in a text field and find the row that contains it).
I thought to use PHP to select the table row but don't know how to fill all (calc?) fields without adding the code to each field.

Thanks!
 
I'm trying with autofill form but for the moment, I have some difficulties to find how to use it, as I am selecting a row with a concat of a date, a first name and a last name, and autofill returns "error".
I looked this page http://fabrikar.com/forums/index.php?wiki/autofill-form-plugin/ but don't understand what to lookup and observe.
The form will not save in the database.
In the dropdown field I list for select a concat of a date, the last name and the first name (in the same table of the data I want to use). The field is in the form "Invoice form", group "Invoice group", its name is "name_choice" (label Name). I want to fill a field "identity" in the same form, group "invoice_form".
I look at "Student last name" (student_lname) in the table and observe the concat field "Name" (___name_choice) in the form.
On form load, the autofill is deactived, but as soon as I click to look at the list rows, autofill open the alert question, twice if I select a row. Then I have "error" twice.
I tried any options only last name for the field "Name" instead of the concat data, and have the same message.

Could you help me? Thanks!

PS: I tried to use only "access_token" table field to populate the dropdown list and select this field in the autofill plugin , but I have the "error" message too. :(
 
Last edited:
Why don't you use just the details view of your record?

Gesendet von meinem SM-G930F mit Tapatalk
 
The table uses 75 fields and I need only a dozen for creating an invoice. I need another list to display more data to the administrator.
I know how to display different fields in list (full and for invoice only) with menu links but I don't know how to display two different detail views from these lists.
 
Then copy your list ( it's linked to the same DB table), disable all elements you don't need and use this details view for the PDF.

Gesendet von meinem SM-G930F mit Tapatalk
 
Thanks troester. I will try!

But I would like to understand why I get the "error" message.
Perhaps I will need later to ask a student to fill in his "access token" in a form to answer some questions and I will connect this token to a table and pre-fill in some data (name, for example).
For the moment, I didn't find how to do that with an autofill form.
 
Last edited:
Hi,

I just saw, trying with the access token field that this field was not an index. I indexed it and have no more error, but the field I want to prefill remains empty.
So if fields need to be indexed, does that mean I indexed first and last name and the date I use in the concat search field. No more "error" message too.

This field element (calc) full name is "___identity" in the group "invoice_form", the group of the target fields is "invoice_form", the table is "nmne2_fb_stay", the table field "nmne2_fb_stay___student_lname", the search field is in the group "invoice_group".
The map data are :
{"{nmne2_fb_stay___student_lname}":"invoice_form___identity"}
What's wrong?
 
Last edited:
I used the wiki sample:
{"{h1qku_comprofiler___firstname} {h1qku_comprofiler___lastname}":"form_plugin_autofill___fullname"}
Bot how to do with these map data? (nothing is added to the "identity" field) :)
{"{nmne2_fb_stay___student_lname} {nmne2_fb_stay___student_fname}":"invoice_form___identity"}
 
I have a lot reports on my site and for all reports I create custom detail templets with only those fields I need to diplay. Take a look here http://www.fabrikar.com/forums/index.php?wiki/form-and-details-templates/.
So copy folder bootstrap and rename it to e.g. my_tempalte then change delault.php.

Or you can just call elements you need to diplay like: $some_elm = $this->groups['Your group name']->elements['id_invoice']->element_raw; ...or without _raw ...depend what type is data.
Then create HTML template and display data like: echo $some_elem; You can also get data from joining tableas or other tables using query. Finaly create custom css. In a form setting You can choose shoud detail use bootstrap templat or no.

I print all reports in Mpdf and in my experience it is better to not use bootstrap template...bootstrap mess it up all headers and footers and page settings. My delault.php looks something
PHP:
<?php

/**
* Bootstrap Details Template
*
* @package     Joomla
* @subpackage  Fabrik
* @copyright   Copyright (C) 2005-2016  Media A-Team, Inc. - All rights reserved.
* @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
* @since       3.1
*/

// No direct access
defined('_JEXEC') or die('Restricted access');

$form = $this->form;
$model = $this->getModel();

if ($this->isMambot) :
    echo '<div class="fabrikForm fabrikDetails fabrikIsMambot" id="' . $form->formid . '">';
else :
    echo '<div class="fabrikForm fabrikDetails" id="' . $form->formid . '">';
endif;

// elements to diplay

/* First Group elements   */

$user         = $this->groups['Group 1']->elements['uses']->element_raw;
$custumer_name     = $this->groups['Group 1']->elements['custumer_name']->element;
$address_1 = $this->groups['Group 1']->elements['address_1']->element;
$address_2    = $this->groups['Group 1']->elements['addres_2']->element;

/* Secondt Group elements   */

$somethig_1 = $this->groups['Group 2']->elements['somethig_1']->element;
$somethig_2 = $this->groups['Group 2']->elements['somethig_2']->element;
$somethig_3 = $this->groups['Group 2']->elements['somethig_2']->element;

// some querrys

$db = JFactory::getDBO();
$db->setQuery("SELECT name FROM user WHERE userid =" . $db->Quote($user));
$user_name = $db->loadResult();

?>

<htmlpageheader name="kota_header">
        <div class="logo" style="text-align: left; font-weight: bold; font-size: 8pt;"><img src="/images/logo.png" /></div>
        <div class="logo_txt">We are the best company in world</div>
</htmlpageheader>

<!-- Header ends here -->

<!-- Footer start here -->

<htmlpagefooter name="kota_footer">
    <table width="100%" style="font-size: 9px; border-top: 1px;">
        <tr>
            <td width="32%">Report No.: <?php echo $report_no; ?></td>
            <td width="32%" style="text-align: center"><?php echo $custumer_name; ?></td>
            <td style="text-align: right;"> Edition: 09</td>
        </tr>
        <tr>
            <td width="32%">Created: <?php echo $user_name; ?></td>
            <td width="32%" style="text-align: center">{PAGENO}/{nbpg}</td>
            <td style="text-align: right; ">Page {PAGENO}/{nbpg}</td>
        </tr>
    </table>
</htmlpagefooter>

<?

// HTML code ... you can create table or use <div>

?>
<div class="invoice">

    <div class="label">Customer name: <span><?php echo $customer_name;?></span></div>
    <div class="label">Address: <span><?php echo $address_1;?></span></div>

</div>

<?php
//echo $this->pluginbottom;
//echo $this->loadTemplate('actions');
//echo '</div>';
//echo $form->outro;
//echo $this->pluginend;
?>
like
 
Thanks deant for your help !
I think it's a way to create and print the invoices.

But it remains the other problem with autofill to join two forms to a table row, as I said. I can join, but not prefill: {"{nmne2_fb_stay___student_lname} {nmne2_fb_stay___student_fname}":"invoice_form___identity"} displays nothing.
If somebody can tell me what is wrong...
 
my experience it is better to not use bootstrap template
Yup, bootstrap is using float etc (for responsive design). Which is not necessary for things like PDF and print layout and not really supported by the PDF libs.
But if you want a more generic PDF template you can start with a bootstrap copy and add CSS overriding the "responsive" bootstrap classes see the WIKI link @dimoss posted above.

Autofill:
On your site you showed me the invoice form was not recording to the database so the element name would be "___identity" (not sure if autofill is working on forms not recording to DB, these are no "standard" forms)
 
Like I said in previuse post - In template use sql querrys to get data from other tables.
I dont know your db configuration but Im sure you can join two tables and get list data.

Something like :
SELECT student_lname, student_fname FROM nmne2_fb_stay AS s
INNER JOIN invoice_form AS i ON i.id = s.id
WHERE i.id = identity

$db->setQuery($query);
$data = $db->loadObjectList();

if ($data != '') {
foreach ($data as $row) {
$student_lname = $row->student_lname;
$student_fname = $row->student_fname;
}
 
Thanks troester, it was "___identity" I needed instead of "invoice_form___identity" and create/print the invoice from previous saved data.
So now, I can too fill in with autofill plugin some fields for two other forms (language test and parent agreement), without using PHP code but only a token, and save additional data in the same table.
Thanks deant too for this code.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top