Topic: Name of person whom generated the quotation

Hi

My client requires the name of the person (or username) whom generated a quote to appear on pdf version of the quote.

The medium company has three people working on the system and they are not limited to their own customers, but the whole pool of customers. Thus, when a client does an enquiry, they would know whom to speak to.

I have tweaked the pdf versions for other instances, but i am not sure of the php coding to show the username.

Please help me.

J

Re: Name of person whom generated the quotation

you can get it from the session wa_current_user, there is a bit information of the logged in user, I think you can get the username from this, maybe you need to query it using the user id though

Re: Name of person whom generated the quotation

Thank you for the valuable response.

Do you perhaps have a string (of code) that I can use to add to the pdf template.

J

Re: Name of person whom generated the quotation

$id_user = $_SESSION['wa_current_user']->user;
$user = get_user($id_user)

echo $user['username']

Re: Name of person whom generated the quotation

Joe - can a flag in the config.php be used to toggle this in all reports possibly in the header2.inc or some footer page? This will help avoid having to change each and every report. Also a barcode in the footer of each report too may be useful.

Re: Name of person whom generated the quotation

Ok, I will just know if this is a general wish. We have a Sales Person on the branch.

And the info will go to all documents, otherwise it is getting tricky.

If we decide to implement this, where should we put the info?

Just under the document number with a blank line?

Label? Contact, Printed By or something else?

Barcode in the footer. Wow, is this not a little too much?

/joe

Re: Name of person whom generated the quotation

Thank you for your responses.

I have a bit of difficulty in using the correct string to be able to reflect the user that generated the quote.

i am trying to configure the ....reporting/includes/doctext.inc file under.... case ST_SALESQUOTE:...

What would be the correct string (with reference to the above string) to reflect the username to replace the following string with:

_("Sales Person") => get_salesman_name($this->formData['salesman']),

With other words, "Sales Person" should reflect the user that generated the code.

Please help.

Thank you in advance

J.

Re: Name of person whom generated the quotation

Hi.

Me again.

I have attempted to add the above code into various reports in order for the report to reflect the person who generated to quotation.

I have not been successful in finding the correct report and the correct spot on where to insert the code.

Please help.
-------
$id_user = $_SESSION['wa_current_user']->user;
$user = get_user($id_user)
echo $user['username']
--------

Re: Name of person whom generated the quotation

The first two lines give you a reference to the current user object. Put them somewhere at the beginning, near any other assignments, so that they are executed before you start outputting data.

The third line outputs the username to stdout, so that won't work for you. I presume it was included as an example of how to access the username. You need to use $user['username'] as an argument to one of the output methods of the PDF class. I suggest you look for a place where it outputs a date or a reference or something which appears near where you'd want the name to be.

Then copy that function call, replacing its argument with $user['username'] and see what happens. That should give you something to work with.

Re: Name of person whom generated the quotation

Hi

I would like to give feedback regarding my request.

After I "played" quite a bit I succeeded in pulling the username through to the various printed documents.

This is how I did it:

locate the following file:
reporting/includes/doctext.inc

I added (as suggested) the following code in lines 18 and 19:

$id_user = $_SESSION['wa_current_user']->user;
$user = get_user($id_user);

THEN....

I used the following:

$user['user_id'],

I struggled a bit until I change the ['user'] to $user['user_id']     the _id  seem to have done the trick.

It works for me.

Thank you once again!

Regards

J

Re: Name of person whom generated the quotation

This can be generically included in the core by having a form field to included the report preparer's name / username printed or not for appropriate documents that can be invoices, quotations, etc.

I have included a generic implementation using a hard_coded flag variable and enabled for Sales Quotations along with a screenshot.

@joe - you can include it in the core with any mods thought fit.

Post's attachments

FA_Report_Preparer_Patch.zip 78.1 kb, 10 downloads since 2014-11-21 

You don't have the permssions to download the attachments of this post.

Re: Name of person whom generated the quotation

This now commited to my FAMods in my GitHub Repo

Re: Name of person whom generated the quotation

Where did you exactly use $user['user_id'],

Re: Name of person whom generated the quotation

reporting/includes/doctext.inc has the flag to enable preparer display.
reporting/includes/header2.inc displays either the preparer if present, otherwise, the user_id.
The commit link clearly shows the changes.