Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v156: Additional /admin/customers.php notifiers #1534

Merged
merged 1 commit into from Oct 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
110 changes: 109 additions & 1 deletion admin/customers.php
Expand Up @@ -31,6 +31,9 @@
ORDER BY firstname, lastname";

$addresses_query = $db->bindVars($addresses_query, ':customersID', $_GET['cID'], 'integer');

$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_LIST_ADDRESSES', $addresses_query);

$addresses = $db->Execute($addresses_query);
$addressArray = array();
while (!$addresses->EOF) {
Expand Down Expand Up @@ -248,6 +251,8 @@
$entry_email_address_exists = false;
}

$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_UPDATE_VALIDATE', array(), $error);

if ($error == false) {

$sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$customers_firstname, 'type'=>'stringIgnoreNull'),
Expand Down Expand Up @@ -294,6 +299,8 @@
}
}

$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_B4_ADDRESS_UPDATE', array('customers_id' => $customers_id, 'address_book_id' => $default_address_id), $sql_data_array);

$db->perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");
zen_record_admin_activity('Customer record updated for customer ID ' . (int)$customers_id, 'notice');
zen_redirect(zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id, 'NONSSL'));
Expand Down Expand Up @@ -365,6 +372,8 @@
}
$customers_id = zen_db_prepare_input($_POST['cID']);

$zco_notifier->notify('NOTIFIER_ADMIN_ZEN_CUSTOMERS_DELETE_CONFIRM', array ('customers_id' => $customers_id));

if (isset($_POST['delete_reviews']) && ($_POST['delete_reviews'] == 'on')) {
$reviews = $db->Execute("select reviews_id
from " . TABLE_REVIEWS . "
Expand Down Expand Up @@ -712,6 +721,33 @@ function init()
}
?></td>
</tr>
<?php
// -----
// If a plugin has additional fields to add to the form, it supplies that information here. The
// additional fields are specified as a simply array of arrays, with each array element identifying
// a new input element:
//
// $additional_fields = array(
// array(
// 'label' => 'The text to include for the field label',
// 'input' => 'The form-related portion of the field',
// ),
// ...
// );
//
$additional_fields = array();
$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_CUSTOMER_EDIT', $cInfo, $additional_fields);
if (is_array($additional_fields)) {
foreach ($additional_fields as $current_field) {
?>
<tr>
<td class="main"><?php echo $current_field['label']; ?></td>
<td class="main"><?php echo $current_field['input']; ?></td>
</tr>
<?php
}
}
?>
</table></td>
</tr>
<?php
Expand Down Expand Up @@ -1063,6 +1099,40 @@ function init()
<a href="<?php echo zen_href_link(basename($PHP_SELF), zen_get_all_get_params(array('list_order','page')) . 'list_order=company', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='company' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</span>'); ?></a>&nbsp;
<a href="<?php echo zen_href_link(basename($PHP_SELF), zen_get_all_get_params(array('list_order','page')) . 'list_order=company-desc', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='company-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</span>'); ?></a>
</td>
<?php
// -----
// If a plugin has additional columns to add to the display, it attaches to both this "listing header" and (see below)
// the "listing data" notifications.
//
// For the header "insert", the observer sets the $additional_headings to include a simple array of arrays. Each
// entry contains the information for one heading column in the format:
//
// $additional_headings = array(
// array(
// 'content' => 'The content for the column',
// 'class' => 'Any additional class for the display',
// 'parms' => 'Any additional parameters for the display',
// ),
// ...
// );
//
// The 'content' element is required; the 'class' and 'parms' are optional.
//
$additional_headings = array();
$additional_heading_count = 0;
$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_LISTING_HEADER', array(), $additional_headings);
if (is_array($additional_headings) && count($additional_headings) != 0) {
$additional_heading_count = count($additional_headings);
foreach ($additional_headings as $heading_data) {
$additional_class = (isset($heading_data['class'])) ? (' ' . $heading_data['class']) : '';
$additional_parms = (isset($heading_data['parms'])) ? (' ' . $heading_data['parms']) : '';
$heading_content = $heading_data['content'];
?>
<td class="dataTableHeadingContent<?php echo $additional_class; ?>"<?php echo $additional_parms; ?>><?php echo $heading_content; ?></td>
<?php
}
}
?>
<td class="dataTableHeadingContent" align="left" valign="top">
<?php echo (($_GET['list_order']=='id-asc' or $_GET['list_order']=='id-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_ACCOUNT_CREATED . '</span>' : TABLE_HEADING_ACCOUNT_CREATED); ?><br>
<a href="<?php echo zen_href_link(basename($PHP_SELF), zen_get_all_get_params(array('list_order','page')) . 'list_order=id-asc', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='id-asc' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</span>'); ?></a>&nbsp;
Expand Down Expand Up @@ -1105,6 +1175,9 @@ function init()
$search = $db->bindVars($search, ':keywords:', $keywords, 'regexp');
}
$new_fields=', c.customers_telephone, a.entry_company, a.entry_street_address, a.entry_city, a.entry_postcode, c.customers_authorization, c.customers_referral';

$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_LISTING_NEW_FIELDS', array(), $new_fields, $disp_order);

$customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_group_pricing, a.entry_country_id, a.entry_company, ci.customers_info_date_of_last_logon, ci.customers_info_date_account_created " . $new_fields . ",
cgc.amount
from " . TABLE_CUSTOMERS . " c
Expand Down Expand Up @@ -1188,6 +1261,41 @@ function init()
<td class="dataTableContent"><?php echo $customers->fields['customers_lastname']; ?></td>
<td class="dataTableContent"><?php echo $customers->fields['customers_firstname']; ?></td>
<td class="dataTableContent"><?php echo $customers->fields['entry_company']; ?></td>
<?php
// -----
// If a plugin has additional columns to add to the display, it attaches to both this "listing element" and (see above)
// the "listing heading" notifications.
//
// For the element "insert", the observer sets the $additional_headings to include a simple array of arrays. Each
// entry contains the information for one element column in the format:
//
// $additional_columns = array(
// array(
// 'content' => 'The content for the column',
// 'class' => 'Any additional class for the display',
// 'parms' => 'Any additional parameters for the display',
// ),
// ...
// );
//
// The 'content' element is required; the 'class' and 'parms' are optional.
//
$additional_columns = array();
$zco_notifier->notify('NOTIFY_ADMIN_CUSTOMERS_LISTING_ELEMENT', $customers->fields, $additional_columns);
if (is_array($additional_columns) && count($additional_columns) != 0) {
if (count($additional_columns) != $additional_heading_count) {
trigger_error("Mismatched additional column heading ($additional_heading_count) and column element (" . count($additional_columns) . ") counts detected for the Customers listing.", E_USER_WARNING);
}
foreach ($additional_columns as $column_data) {
$additional_class = (isset($column_data['class'])) ? (' ' . $column_data['class']) : '';
$additional_parms = (isset($column_data['parms'])) ? (' ' . $column_data['parms']) : '';
$element_content = $column_data['content'];
?>
<td class="dataTableContent<?php echo $additional_class; ?>"<?php echo $additional_parms; ?>><?php echo $element_content; ?></td>
<?php
}
}
?>
<td class="dataTableContent"><?php echo zen_date_short($info->fields['date_account_created']); ?></td>
<td class="dataTableContent"><?php echo zen_date_short($customers->fields['customers_info_date_of_last_logon']); ?></td>
<td class="dataTableContent"><?php echo $group_name_entry; ?></td>
Expand Down Expand Up @@ -1215,7 +1323,7 @@ function init()
}
?>
<tr>
<td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<td colspan="<?php echo $additional_heading_count + 5; ?>"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText" valign="top"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>
<td class="smallText" align="right"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], zen_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>
Expand Down