Zen Cart Logo
Forums / All Other Contributions/Addons / [MOD] - Set customers account as contacted or not.

[MOD] - Set customers account as contacted or not.

Locked

Views: 1,827

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
20 Jun 2006, 3:25 AM
#1
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

[MOD] - Set customers account as contacted or not.

Responding for this topic:

http://www.zen-cart.com/forum/showthread.php?p=218817#post218817

First, since wilt posted an announcement regarding bad news over the contributions section of the forum, hopefully - I'm posting this in the right place. If not, please move it into the right section.

/ What does this MOD do ? /

This MOD has been built for specific users who are handling their customers by phone. That's right, if your business does NOT involve any technical assistance by phone, there's no need to install this addon.

// Tested Zen Cart Version

Zen Cart v1.3.0.1.

// Affected files

  • admin/index.php
  • admin/includes/languages/english/index.php
  • TABLE_CUSTOMERS

// Tested

Definitely !

/ Backup /

Backup the affected files, above, before proceeding below.

// Step 1

First, let's create an additional field called: customers_contacted (and this is NOT a suggestion but part of the steps).

In your admin section - > tools - > SQL Patches.

Note: You may also go to your phpmyadmin if you feel more confortable with it.

Add the following SQL statement:

(Note: You are reminded to backup the affected files before proceeding).

ALTER TABLE customers
ADD customers_contacted INT(1) NOT NULL default '0'

Then, execute the SQL statement.

// Step 2

Log out entirely from your admin section, clear out your cookies and temp files to make sure there's no affect between your current sessions and your new sessions (with this MOD).

Note: It is recommended to do so, since I did had cookie problems and temp files during my codings and once I finished it up, since I did not clear them out (for those who wonders why).

Recall: Again, you are reminded to backup the affected files before proceeding.

In your admin.php file,

find:

<div id="coltwo"> <div class="reportBox"> <div class="header"><?php echo BOX_ENTRY_NEW_CUSTOMERS; ?> </div> <?php $customers = $db->Execute("select c.customers_id as customers_id, c.customers_firstname as customers_firstname, c.customers_lastname as customers_lastname, a.customers_info_date_account_created as customers_info_date_account_created, a.customers_info_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_CUSTOMERS_INFO . " a on c.customers_id = a.customers_info_id order by a.customers_info_date_account_created DESC limit 5");

while (!$customers->EOF) {
echo ' <div class="row"><span class="left"><a href="' . zen_href_link(FILENAME_CUSTOMERS, 'search=' . $customers->fields['customers_lastname'] . '&origin=' . FILENAME_DEFAULT, 'NONSSL') . '" class="contentlink">'. $customers->fields['customers_firstname'] . ' ' . $customers->fields['customers_lastname'] . '</a></span><span class="rigth">' . "\n";
echo zen_date_short($customers->fields['customers_info_date_account_created']);
echo ' </span></div>' . "\n";
$customers->MoveNext();
}
?>

</div> <div class="reportBox"> <?php $counter_query = "select startdate, counter, session_counter from " . TABLE_COUNTER_HISTORY . " order by startdate DESC limit 10"; $counter = $db->Execute($counter_query); ?> <div class="header"><?php echo sprintf(LAST_10_DAYS, $counter->RecordCount()); ?><?php echo '<span class="rigth">    ' . SESSION . ' - ' . TOTAL . '</span>'; ?></div> <?php

while (!$counter->EOF) {
$counter_startdate = $counter->fields['startdate'];
$counter_startdate_formatted = strftime(DATE_FORMAT_SHORT, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4)));
echo ' <div class="row"><span class="left">' . $counter_startdate_formatted . '</span><span class="rigth"> ' . $counter->fields['session_counter'] . ' - ' . $counter->fields['counter'] . '</span> </div>' . "\n";
$counter->MoveNext();
}
?>

</div> </div> <div id="colthree"> <div class="reportBox"> <div class="header"><?php echo BOX_ENTRY_NEW_ORDERS; ?> </div> <?php $orders = $db->Execute("select o.orders_id as orders_id, o.customers_name as customers_name, o.customers_id, o.date_purchased as date_purchased, o.currency, o.currency_value, ot.class, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) where class = 'ot_total' order by orders_id DESC limit 5");

while (!$orders->EOF) {
echo ' <div class="row"><span class="left"><a href="' . zen_href_link(FILENAME_ORDERS, 'oID=' . $orders->fields['orders_id'] . '&origin=' . FILENAME_DEFAULT, 'NONSSL') . '" class="contentlink"> ' . $orders->fields['customers_name'] . '</a></span><span class="center">' . $orders->fields['order_total'] . '</span><span class="rigth">' . "\n";
echo zen_date_short($orders->fields['date_purchased']);
echo ' </span></div>' . "\n";
$orders->MoveNext();
}
?>

</div> </div>

replace the entire block (important: must be replaced exacly as mentionned)

with:

<div id="colthree"> <div class="reportBox"> <div class="header"><table border="0" class="header" width="90%" cellpadding="0" cellspacing="0"><tr><td width="30%" class="header" align="left"><?php echo BOX_ENTRY_NEW_CUSTOMERS; ?> </td><td width="30%" class="header" align="center"><?php echo CUSTOMERS_CONTACTED_TITLE; ?> </td><td width="30%" class="header" align="right"><?php echo BOX_ENTRY_POSTED_DATE; ?> </tr></table></div> <?php $customers = $db->Execute("select c.customers_id as customers_id, c.customers_firstname as customers_firstname, c.customers_lastname as customers_lastname, a.customers_info_date_account_created as customers_info_date_account_created, a.customers_info_id, c.customers_contacted from " . TABLE_CUSTOMERS . " c left join " . TABLE_CUSTOMERS_INFO . " a on c.customers_id = a.customers_info_id order by a.customers_info_date_account_created DESC limit 5");

while (!$customers->EOF) {

if (isset($_GET['action']) && $_GET['action'] == "set_contacted_options") {

if (isset($_GET['customers_contacted']) && $_GET['customers_contacted'] == 0 && $_GET['customers_id'] && $_GET['customers_id'] != 0) {
$db->Execute("update " . TABLE_CUSTOMERS . " set customers_contacted = '1' where customers_id = '" . (int)$_GET['customers_id']. "'");

zen_redirect(zen_href_link(FILENAME_DEFAULT, '', 'NONSSL'));
$messageStack->add_session(CUSTOMERS_CONSIDERED_CONTACTED_SUCCESS, 'success');

} elseif (isset($_GET['customers_contacted']) && $_GET['customers_contacted'] == 1 && $_GET['customers_id'] && $_GET['customers_id'] != 0) {
$db->Execute("update " . TABLE_CUSTOMERS . " set customers_contacted = '0' where customers_id = '" . (int)$_GET['customers_id']. "'");

zen_redirect(zen_href_link(FILENAME_DEFAULT, '', 'NONSSL'));
$messageStack->add_session(CUSTOMERS_NOT_CONSIDERED_CONTACTED_SUCCESS, 'success');

}
}

$set_customers_contacted = (isset($customers->fields['customers_contacted']) && $customers->fields['customers_contacted'] == 1) ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'action=set_contacted_options&customers_contacted=' . $customers->fields['customers_contacted']. '&customers_id='.$customers->fields['customers_id'], 'NONSSL'). '" class="contentlink">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', CUSTOMERS_CONTACTED). '</a>' : '<a href="' . zen_href_link(FILENAME_DEFAULT, 'action=set_contacted_options&customers_contacted=' . $customers->fields['customers_contacted']. '&customers_id=' .$customers->fields['customers_id']). '" class="contentlink">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', CUSTOMERS_NOT_CONTACTED). '</a>';

echo '              <div class="row"><table border="0" class="row" width="90%" cellpadding="0" cellspacing="0"><tr><td width="30%" class="row" align="left"><a href="' . zen_href_link(FILENAME_CUSTOMERS, 'search=' . $customers->fields['customers_lastname'] . '&origin=' . FILENAME_DEFAULT, 'NONSSL') . '" class="contentlink">'. $customers->fields['customers_firstname'] . ' ' . $customers->fields['customers_lastname'] . '</a></td><td width="30%" class="row" align="center">' . $set_customers_contacted . '</td><td width="30%" class="row" align="right">' . "\n";
echo zen_date_short($customers->fields['customers_info_date_account_created']);
echo '              </td></tr></table></div>' . "\n";
$customers->MoveNext();

}
?>

</div> <div class="reportBox"> <?php $counter_query = "select startdate, counter, session_counter from " . TABLE_COUNTER_HISTORY . " order by startdate DESC limit 10"; $counter = $db->Execute($counter_query); ?> <div class="header"><?php echo sprintf(LAST_10_DAYS, $counter->RecordCount()); ?><?php echo '<span class="rigth">    ' . SESSION . ' - ' . TOTAL . '</span>'; ?></div> <?php

while (!$counter->EOF) {
$counter_startdate = $counter->fields['startdate'];
$counter_startdate_formatted = strftime(DATE_FORMAT_SHORT, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4)));
echo ' <div class="row"><span class="left">' . $counter_startdate_formatted . '</span><span class="rigth"> ' . $counter->fields['session_counter'] . ' - ' . $counter->fields['counter'] . '</span> </div>' . "\n";
$counter->MoveNext();
}
?>

</div> </div>

Note: If the zen_redirect module returns a Headers already sent by ... error message, simply replace these two lines, from the replaced block above

to read:

$redirect = "<meta http-equiv="refresh" content="0; url=".zen_href_link(FILENAME_DEFAULT, "", "NONSSL")."">";
echo $redirect;
unset ($redirect);
$messageStack->add_session(CUSTOMERS_CONSIDERED_CONTACTED_SUCCESS, 'success');

and:

$redirect = "<meta http-equiv="refresh" content="0; url=".zen_href_link(FILENAME_DEFAULT, "", "NONSSL")."">";
echo $redirect;
unset ($redirect);
$messageStack->add_session(CUSTOMERS_NOT_CONSIDERED_CONTACTED_SUCCESS, 'success');

Since I had two different results from two different test server, (Linux), I found this amazing solution which works perfectly from my end.

// Step 3

Do NOT login into your admin section just yet. There's this last step to do first !

Now, in your admin/includes/languages/english/index.php file,

find:

define('CUSTOMERS_AUTHORIZATION_3', 'Pending Approval - May browse with prices but may not buy');

add below:

define('CUSTOMERS_CONTACTED_TITLE', 'Contacted');
define('CUSTOMERS_CONTACTED_EMPTY', 'You did not confirmed if the customer were contacted, or not, from the admin's page.');
define('CUSTOMERS_CONTACTED', 'This customer has been contacted.');
define('CUSTOMERS_NOT_CONTACTED', 'This customer has not been contacted.');
define('CUSTOMERS_CONSIDERED_CONTACTED_SUCCESS', 'Done ! The customer's field has now been set as contacted.');
define('CUSTOMERS_NOT_CONSIDERED_CONTACTED_SUCCESS', 'Done ! The customer's field has now been set as NOT contacted.');
define('BOX_ENTRY_POSTED_DATE', 'Date:');

// End of Steps

Now, this completes the installation of this MOD. Simply log in into your admin section and, from the index page - where the customers table (aside the orders table) is located, you should see a red square button (for each customers - set seperately).

/* What do I do ? */

Even your 10 year old kid could learn how this works. Simply click on the red squares button, as it should refresh the page with a successful page message, on top of your admin's header page, as the square should be switched to the green image button.

/* How is it useful ? */

Assuming you are the manager who has some employees that has a technical support job and, since your site supports Zen Cart, there was no way, before today, to confirm these calls from any features inside this beast. From now on, one single click for each users can make your day a lot easier. :thumbsup:

Enjoy !!! :cool:

20 Jun 2006, 1:57 PM
#2
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: [MOD] - Set customers account as contacted or not.

Thanks to aspudden for reporting a slight bug. The Date: row was not aligned correctly, (under IE), which avoided the word to appear.

To correct this, since I cannot edit my post above,

In your admin/index.php file,

change:

<div class="header"><table border="0" class="header" width="90%" cellpadding="0" cellspacing="0"><tr><td width="30%" class="header" align="left"><?php echo BOX_ENTRY_NEW_CUSTOMERS; ?> </td><td width="30%" class="header" align="center"><?php echo CUSTOMERS_CONTACTED_TITLE; ?> </td><td width="30%" class="header" align="right"><?php echo BOX_ENTRY_POSTED_DATE; ?> </tr></table></div>

to read:

<div class="header"><table border="0" class="header" width="90%" cellpadding="0" cellspacing="0"><tr><td width="30%" class="header" align="left"><?php echo BOX_ENTRY_NEW_CUSTOMERS; ?> </td><td width="30%" class="header" align="center"><?php echo CUSTOMERS_CONTACTED_TITLE; ?> </td><td width="30%" class="header" align="right"><?php echo BOX_ENTRY_POSTED_DATE; ?> </td></tr></table></div>

This should do the trick. :thumbsup:

20 Jun 2006, 7:07 PM
#3
jacque427 avatar

jacque427

Zen Follower

Join Date:
Apr 2005
Location:
Spokane, Washington
Posts:
324
Plugin Contributions:
0

Re: [MOD] - Set customers account as contacted or not.

http://www.zen-cart.com/forum/showthread.php?p=219217#post219217

On page 2 there is the code that will work for admin/index.php if you are using version 1.2.6

20 Jun 2006, 7:21 PM
#4
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: [MOD] - Set customers account as contacted or not.

Outstanding. Thanks for posting this. :thumbsup:

22 Jun 2006, 4:14 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: [MOD] - Set customers account as contacted or not.

post moved to the contributions-misc area (since this is not a post about guidelines)

22 Jun 2006, 4:21 AM
#6
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: [MOD] - Set customers account as contacted or not.

Thanks for mentionning where these kinds of subjects should rather be posted.