Solved: Expose CustomerUser Field on Dashboard

English! place to talk about development, programming and coding
Post Reply
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Solved: Expose CustomerUser Field on Dashboard

Post by RBehr »

We have defined a few of our own fields for the CustomerUser table. We have set up the Config.pm file to properly handle these new fields.

We have also changed /Kernel/Output/HTML/Standard/AgentDashboardTicketGeneric.dtl in order to insert a new column into the Dashboard.

We now want to expose one of these new CustomerUser fields on the dashboard (called SomeFieldName in this example):

Code: Select all

<!-- dtl:block:ContentLargeTicketGenericRowMeta -->
            <td class="W10pc">
                <a href="$Env{"Baselink"}Action=AgentTicketZoom;TicketID=$Data{"TicketID"}" title="$QData{"Title"}" class="AsBlock MasterActionLink">$Data{"TicketNumber"}</a>
            </td>
            <td class="W50pc">
                <div title="$QData{"Title"}">$QData{"Title","70"}</div>
            </td>
		<!-- CUSTOM CODE -->
		<td>$QData{"SomeFieldName"}</td>
		<!-- END OF CUSTOM CODE -->
            <td>$QData{"Time"}</td>
        </tr>
How would we expose this new field so we can reference it in AgentDashboardTicketGeneric.dtl by using $Data, $QData or similar?
Last edited by RBehr on 15 Nov 2011, 18:15, edited 1 time in total.
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Expose CustomerUser Field on Dashboard

Post by RBehr »

My own dirty hack as follows:

Obviously, please proceed with caution and ensure you have a solid knowledge of the Perl, HTML and SQL necessary for these changes. Use at own risk - you could easily break OTRS!

Add the new field (in this case CustomerDetail) to the customer_user table and make the changes to the config.pm file as described here: http://forums.otrs.org/viewtopic.php?f=53&t=11508.

In /opt/otrs/Kernel/System/Ticket.pm, make the following changes to the SQL in sub TicketGet:

Change:

Code: Select all

            . ' FROM ticket st, ticket_priority sp, queue sq'
            . ' WHERE sp.id = st.ticket_priority_id AND sq.id = st.queue_id AND st.id = ?',
To:

Code: Select all

            . ' cu.CustomerDetail'
            . ' FROM ticket st'
            . ' JOIN ticket_priority sp ON sp.id = st.ticket_priority_id'
            . ' JOIN queue sq on sq.id = st.queue_id'
            . ' LEFT JOIN customer_user cu ON cu.login = st.customer_user_id'
            . ' WHERE st.id = ?',
And then add:

Code: Select all

$Ticket{CustomerDetail}=$Row[65];
...in the while loop immediately below. You are now able to reference $QData{"CustomerDetail"} when building the HTML. The $Row[] reference is to the number of the column which contains the data you're looking for. 65, in this case, because I added the column at the end of the SQL select clause (ensure you insert a comma at the end of the previous line).

In /opt/otrs/Kernel/Output/HTML/Standard/AgentDashboardTicketGeneric.dtl, insert the following line in <!-- dtl:block:ContentLargeTicketGenericRowMeta --> where you need the new column to appear on the Dashboard:

Code: Select all

<td class="W20pc"><div title="$QData{"CustomerDetail"}">$QData{"CustomerDetail"}</div></td>
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Solved: Expose CustomerUser Field on Dashboard

Post by RBehr »

Eh?
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
edwardbarski
Znuny newbie
Posts: 1
Joined: 01 Mar 2012, 04:39
Znuny Version: OTRS3

Re: Solved: Expose CustomerUser Field on Dashboard

Post by edwardbarski »

Genious! This is just what I needed. Hopefully I won't break my OTRS.
Post Reply