Zen Cart Logo
Forums / General Questions / Who's Online - Add Company Name to view?

Who's Online - Add Company Name to view?

Views: 821

Results 1 to 10 of 10
30 Sep 2013, 3:45 AM
#1
jonnoc avatar

jonnoc

New Zenner

Join Date:
May 2013
Location:
Australia
Posts:
14
Plugin Contributions:
0

Who's Online - Add Company Name to view?

Hi All

I'm running the latest build of Zencart 1.51 and find the Who's Online view very good however it currently displays the username but I would also like it to show the company name as well (perhaps underneath the logged in user name might be good as there seems to be lots of space there).

Is this kind of change easy to do and could any one help with this suggestion? :smartalec:

Cheers!

30 Sep 2013, 3:55 AM
#2
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Who's Online - Add Company Name to view?

JonnoC:

Hi All

I'm running the latest build of Zencart 1.51 and find the Who's Online view very good however it currently displays the username but I would also like it to show the company name as well (perhaps underneath the logged in user name might be good as there seems to be lots of space there).

Is this kind of change easy to do and could any one help with this suggestion? :smartalec:

Cheers!

Can we have a link to your site pls...

30 Sep 2013, 4:14 AM
#3
jonnoc avatar

jonnoc

New Zenner

Join Date:
May 2013
Location:
Australia
Posts:
14
Plugin Contributions:
0

Re: Who's Online - Add Company Name to view?

Hi Frank,

Thanks for the quick reply, sorry I forgot to mention the Who's Online part I'm referring to is the one in the back end Admin section, whilst browsing the forum I've noticed there must be some kind of front end one as well although it's not something we use.

It can be found at the following back end location which we have blocked for public use:
Admin --> Tools --> Who's Online

The file location is normally this:
\admin\whos_online.php

It seems allot of the tables details are defined in the following file from what I can gather but might be wrong:
\admin\includes\languages\english\

Hope this helps... Cheers!

30 Sep 2013, 4:37 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Who's Online - Add Company Name to view?

You would have to customize the file:
/includes/functions/whos_online.php

and customize the code:

function zen_update_whos_online() {
  global $db;

  if (isset($_SESSION['customer_id']) && $_SESSION['customer_id']) {
    $wo_customer_id = $_SESSION['customer_id'];

    $customer_query = "select customers_firstname, customers_lastname
                         from " . TABLE_CUSTOMERS . "
                         where customers_id = '" . (int)$_SESSION['customer_id'] . "'";

    $customer = $db->Execute($customer_query);

    $wo_full_name = $customer->fields['customers_lastname'] . ', ' . $customer->fields['customers_firstname'];

to include the table:
address_book

to obtain the field:
entry_company

based on table customers on the field:
customers_default_address_id

to the table address_book to the field:
address_book_id

30 Sep 2013, 11:20 PM
#5
jonnoc avatar

jonnoc

New Zenner

Join Date:
May 2013
Location:
Australia
Posts:
14
Plugin Contributions:
0

Re: Who's Online - Add Company Name to view?

Hi Ajeh

Thanks for the details and information, I'm a little new at this so been doing some searching on how to get this done, would I be right in saying I would need to make changes using something like the following syntax and inner join command?

SELECT <Table>.<Field>, <Table>.<Field> FROM <Table 1>
INNER JOIN <Table 2> ON <Table 1>.<Primary Key>=<Table 2>.<Foreign Key>
WHERE <Conditions>

Thanks once again for your help!

30 Sep 2013, 11:50 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Who's Online - Add Company Name to view?

Yes, something fun like that is needed to grab the company info from the address_book ...

Let us know what you come up with ... :smile:

1 Oct 2013, 7:39 AM
#7
jonnoc avatar

jonnoc

New Zenner

Join Date:
May 2013
Location:
Australia
Posts:
14
Plugin Contributions:
0

Re: Who's Online - Add Company Name to view?

This is what I've come up with so far but I might need to use the other ID's you listed above and am still testing things out...

function zen_update_whos_online() {
global $db;

if (isset($_SESSION['customer_id']) && $_SESSION['customer_id']) {
$wo_customer_id = $_SESSION['customer_id'];

$customer_query = "select customers.customers_firstname, customers.customers_lastname, address_book.entry_company
                     from customers
					 inner join address_book on customers.customers_id = address_book.customers_id
                     where customers.customers_id = '" . (int)$_SESSION['customer_id'] . "'";

$customer = $db->Execute($customer_query);

$wo_full_name = $customer->fields['entry_company'] . ', ' . $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname'];

One issue I've run into is the output line looks as follows on the who's online screen from the admin view:
Company Name, First Last names

The issue is it can get rather long with some company and user names and I've tired to insert a /n for new line withough any luck as yet so the company will be on the first line then first/second name will be on the second line below the company name....

Thanks for your help and suggestions so far hope this might help someone else in the future but still open to idea's and advice on the above code and if it might have any impact on any other items on the website I have not through as well as well as idea's on the other items mentioned above.

1 Oct 2013, 2:03 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Who's Online - Add Company Name to view?

Using your SELECT I have:

  if (isset($_SESSION['customer_id']) && $_SESSION['customer_id']) {
    $wo_customer_id = $_SESSION['customer_id'];

[B]// BOF: customize whos_online to include company
/*
    $customer_query = "select customers_firstname, customers_lastname
                         from " . TABLE_CUSTOMERS . "
                         where customers_id = '" . (int)$_SESSION['customer_id'] . "'";
*/

 $customer_query = "select customers.customers_firstname, customers.customers_lastname, address_book.entry_company
                    from customers
                    inner join address_book on customers.customers_id = address_book.customers_id
                    where customers.customers_id = '" . (int)$_SESSION['customer_id'] . "'";

    $customer = $db->Execute($customer_query);

    $wo_full_name = ($customer->fields['entry_company'] ? $customer->fields['entry_company'] . '<br />' : '') . $customer->fields['customers_lastname'] . ', ' . $customer->fields['customers_firstname'];
// EOF: customize whos_online to include company
[/B]  } else {

Seems to work for me ...

NOTE: depending on your version of Zen Cart make sure you are showing the Admin in your Who's Online ...

2 Oct 2013, 3:02 AM
#9
jonnoc avatar

jonnoc

New Zenner

Join Date:
May 2013
Location:
Australia
Posts:
14
Plugin Contributions:
0

Re: Who's Online - Add Company Name to view?

Hi Ajeh's

Fantastic, the link break is working 100% well and does make sense now that I think of what it's doing (needs to be HTML code and not php code)...

Learning slowly as we go along but main thing is it makes sense now that you have shown me....

Thanks once again for your help!

2 Oct 2013, 3:10 AM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Who's Online - Add Company Name to view?

Glad this is working for you ... thanks for the update! :smile:

Give yourself time ... I started with less knowledge than you and now my silly partners on the Zen Cart Team actually let me write code ... :cool: