Skip to content

Commit

Permalink
Merge branch '6.1.9-branch' into developer-preview-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
abrookbanks committed Aug 15, 2017
2 parents c9203f5 + 767adec commit 14e4172
Show file tree
Hide file tree
Showing 51 changed files with 286 additions and 152 deletions.
1 change: 1 addition & 0 deletions admin/skins/default/csrf.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
array('_g'=>'plugins','type'=>false,'module'=>false,'delete'=>'1'), // Delete extension
/* END DELETE */
array('_g'=>'customers','node'=>'email','action'=>'send','newsletter_id'=>false),
array('_g'=>'logout')
);
25 changes: 22 additions & 3 deletions admin/skins/default/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ $(document).ready(function() {
}), $("a.colorbox.address-form").colorbox({
href: "#address-form",
inline: !0,
innerHeight: "400px",
innerWidth: "650px"
innerHeight: "685px",
innerWidth: "420px"
}), $("#loading_content").hide(), $("div#progress_bar>img.newsletter").each(function() {
window.onbeforeunload = function() {
return !0
Expand Down Expand Up @@ -727,15 +727,31 @@ $('a.add, a.inline-add, input[type="button"].add').on("click", function() {
$(this).val($(this).attr("original"))
})
} else {

var fields_ok = true;
$(this).parents("div:first,tr:first").find(".add:input").each(function() {
if($(this).attr("required")=='required' && $(this).val()=='') {
$(this).addClass('required-error');
$(this).click(function(){$(this).removeClass('required-error')});
fields_ok = false;
}
});

if(!fields_ok) {
return false;
}

var o = document.createElement("div"),
c = document.createElement("span"),
d = document.createElement("a"),
h = document.createElement("i");

$('input[name="add_div_class"]') && $(o).addClass($('input[name="add_div_class"]').val()), $(h).attr({
"class": "fa fa-trash"
}), $(d).attr({
href: "#"
}).addClass("remove dynamic").append(h), $(c).addClass("actions").append(d), $(this).parents("div:first,tr:first").find(".add:input").each(function() {

if ($(this).hasClass("display")) {
"" == $(this).val() && (s = !1);
var t = $(this).is("select") ? $(this).find(":selected").text() : "<strong>" + $(this).val() + "</strong>";
Expand All @@ -749,7 +765,10 @@ $('a.add, a.inline-add, input[type="button"].add').on("click", function() {
value: $(this).val()
}), $(o).append(e)
}
$(this).val("")

$.fn.colorbox.close()

//$(this).val("")
}), $(o).prepend(c)
}
return 1 == s && e.length > 1 && 1 == $("#" + e).length ? t($(this), $("#" + e), o) : $(i).before(o), $(".update-subtotal input.number").trigger("change"), inline_add_offset++, updateStriping(), $(".dymanic_none").hide(), !1
Expand Down
16 changes: 8 additions & 8 deletions admin/skins/default/templates/customers.index.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@
<div id="address-form" class="tb-form">
<h3>{$LANG.address.address_add}</h3>
<fieldset>
<div><label for="edit_description">{$LANG.common.description}</label><span><input type="text" name="address[description][]" id="edit_description" class="textbox add display"> *</span></div>
<div><label for="edit_description">{$LANG.common.description}</label><span><input type="text" name="address[description][]" id="edit_description" class="textbox add display" required="required"> *</span></div>
<div><label for="edit_title">{$LANG.user.title}</label><span><input type="text" name="address[title][]" id="edit_title" class="textbox add capitalize"></span></div>
<div><label for="edit_first_name">{$LANG.user.name_first}</label><span><input type="text" name="address[first_name][]" id="edit_first_name" class="textbox add capitalize"> *</span></div>
<div><label for="edit_last_name">{$LANG.user.name_last}</label><span><input type="text" name="address[last_name][]" id="edit_last_name" class="textbox add capitalize"> *</span></div>
<div><label for="edit_first_name">{$LANG.user.name_first}</label><span><input type="text" name="address[first_name][]" id="edit_first_name" class="textbox add capitalize" required="required"> *</span></div>
<div><label for="edit_last_name">{$LANG.user.name_last}</label><span><input type="text" name="address[last_name][]" id="edit_last_name" class="textbox add capitalize" required="required"> *</span></div>
<div><label for="edit_company_name">{$LANG.address.company_name}</label><span><input type="text" name="address[company_name][]" id="edit_company_name" class="textbox add"></span></div>
<div><label for="edit_line1">{$LANG.address.line1}</label><span><input type="text" name="address[line1][]" id="edit_line1" class="textbox add"> *</span></div>
<div><label for="edit_line1">{$LANG.address.line1}</label><span><input type="text" name="address[line1][]" id="edit_line1" class="textbox add" required="required"> *</span></div>
<div><label for="edit_line2">{$LANG.address.line2}</label><span><input type="text" name="address[line2][]" id="edit_line2" class="textbox add"></span></div>
<div><label for="edit_town">{$LANG.address.town}</label><span><input type="text" name="address[town][]" id="edit_town" class="textbox add"> *</span></div>
<div><label for="edit_town">{$LANG.address.town}</label><span><input type="text" name="address[town][]" id="edit_town" class="textbox add" required="required"> *</span></div>
<div>
<label for="edit_country">{$LANG.address.country}</label>
<span>
Expand All @@ -268,13 +268,13 @@
</select>
*</span>
</div>
<div><label for="edit_state">{$LANG.address.state}</label><span><input type="text" name="address[state][]" id="edit_state" class="textbox add state-list"> *</span></div>
<div><label for="edit_postcode">{$LANG.address.postcode}</label><span><input type="text" name="address[postcode][]" id="edit_postcode" class="textbox add uppercase"> *</span></div>
<div><label for="edit_state">{$LANG.address.state}</label><span><input type="text" name="address[state][]" id="edit_state" class="textbox add state-list" required="required"> *</span></div>
<div><label for="edit_postcode">{$LANG.address.postcode}</label><span><input type="text" name="address[postcode][]" id="edit_postcode" class="textbox add uppercase" required="required"> *</span></div>
<div><label for="billing">{$LANG.address.billing_address}</label><span><input type="checkbox" name="address[billing][]" id="billing" class="add" value="1"></span></div>
<div><label for="default">{$LANG.address.default_delivery_address}</label><span><input type="checkbox" name="address[default][]" id="default" class="add" value="1"></span></div>
</fieldset>
<input type="hidden" name="add_div_class" value="note">
<input type="button" value="{$LANG.common.add}" class="add" target="address-list" onclick="$.fn.colorbox.close()">
<input type="button" value="{$LANG.common.add}" class="add" target="address-list">
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion admin/skins/default/templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<body>
<div id="header">
<a href="?"><img src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/images/logo.cubecart.png" width="158" height="30" id="logo"></a>
<span class="user_info">{$LANG.settings.title_welcome_back} <a href="?_g=settings&node=admins&action=edit&admin_id={$ADMIN_UID}">{$ADMIN_USER}</a> - <a href="?_g=logout">{$LANG.account.logout} <i class="fa fa-sign-out"></i></a></span>
<span class="user_info">{$LANG.settings.title_welcome_back} <a href="?_g=settings&node=admins&action=edit&admin_id={$ADMIN_UID}">{$ADMIN_USER}</a> - <a href="?_g=logout&amp;token={$SESSION_TOKEN}">{$LANG.account.logout} <i class="fa fa-sign-out"></i></a></span>
</div>
<div id="wrapper">
<div id="navigation">
Expand Down
4 changes: 2 additions & 2 deletions admin/skins/default/templates/reports.index.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
</span>
</div>
<div>
<label for="date_range">{$LANG.orders.title_order_status}</label>
<label for="report_status">{$LANG.orders.title_order_status}</label>
<span>
<select multiple="multiple" name="report[status][]">
<select id="report_status" multiple="multiple" name="report[status][]">
{foreach from=$STATUS item=status}
<option value="{$status.value}" {$status.selected}>{$status.name}</option>
{/foreach}
Expand Down
8 changes: 6 additions & 2 deletions admin/skins/default/templates/statistics.emaillog.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
<a href="?_g=customers&q={$email}" title="{$LANG.search.title_search_customers}">{$email}</a><br>
{/foreach}</td>
<td>
<a href="#" onclick="{literal}$.colorbox({title:'{/literal}{$log.subject} ({$LANG.common.html}){literal}',width:'90%', height:'90%', html:'<iframe width=\'100%\' height=\'95%\' frameBorder=\'0\' src=\'?_g=xml&amp;function=viewEmail&amp;id={/literal}{$log.id}{literal}&amp;mode=content_html\'></iframe>'}){/literal}">{$LANG.common.html}</a>
{if !empty($log.content_html)}
<a href="#" onclick="{literal}$.colorbox({title:'{/literal}{$log.subject|escape:'javascript'} ({$LANG.common.html}){literal}',width:'90%', height:'90%', html:'<iframe width=\'100%\' height=\'95%\' frameBorder=\'0\' src=\'?_g=xml&amp;function=viewEmail&amp;id={/literal}{$log.id}{literal}&amp;mode=content_html\'></iframe>'}){/literal}">{$LANG.common.html}</a>
{/if}
</td>
<td>
<a href="#" onclick="{literal}$.colorbox({title:'{/literal}{$log.subject} ({$LANG.common.plain_text}){literal}',width:'90%', height:'90%', html:'<iframe width=\'100%\' height=\'95%\' frameBorder=\'0\' src=\'?_g=xml&amp;function=viewEmail&amp;id={/literal}{$log.id}{literal}&amp;mode=content_text\'></iframe>'}){/literal}">{$LANG.common.plain_text}</a>
{if !empty($log.content_text)}
<a href="#" onclick="{literal}$.colorbox({title:'{/literal}{$log.subject|escape:'javascript'} ({$LANG.common.plain_text}){literal}',width:'90%', height:'90%', html:'<iframe width=\'100%\' height=\'95%\' frameBorder=\'0\' src=\'?_g=xml&amp;function=viewEmail&amp;id={/literal}{$log.id}{literal}&amp;mode=content_text\'></iframe>'}){/literal}">{$LANG.common.plain_text}</a>
{/if}
</td>
<td>{$log.date}</td>
<td align="center">{if $log.email_content_id>0}<a href="?_g=documents&amp;node=email&amp;type=content&amp;action=edit&amp;content_id={$log.email_content_id}"><i class="fa fa-pencil-square-o" title="{$LANG.common.edit}"></i></a>{/if}</td>
Expand Down
11 changes: 11 additions & 0 deletions admin/sources/customers.index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,18 @@
$address[0][$field] = $content;
}
}

$required_fields = array('first_name','last_name','line1','town','country','state','postcode');

foreach ($address as $offset => $record) {

foreach($record as $record_key => $record_value) {
if(in_array($record_key, $required_fields) && empty($record_value)) {
$GLOBALS['main']->setACPWarning($lang['common']['error_fields_required']);
continue 2;
}
}

// Format data nicely from mr barney brimstock to Mr Barney Brimstock & Post/Zip code to uppercase
$record['title'] = ucwords($record['title']);
$record['first_name'] = ucwords($record['first_name']);
Expand Down
69 changes: 37 additions & 32 deletions admin/sources/dashboard.index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
## Check if setup folder remains after install/upgrade
if ($glob['installed'] && file_exists(CC_ROOT_DIR.'/setup')) {
## Attempt auto delete as we have just upgraded or installed
if($_COOKIE['delete_setup']) {
if(isset($_COOKIE['delete_setup']) && $_COOKIE['delete_setup']) {
recursiveDelete(CC_ROOT_DIR.'/setup');
unlink(CC_ROOT_DIR.'/setup');
setcookie('delete_setup', '', time()-3600);
Expand Down Expand Up @@ -180,6 +180,37 @@
$quick_stats['this_month'] = Tax::getInstance()->priceFormat((float)$this_month_sales[0]['this_month']);

$GLOBALS['smarty']->assign('QUICK_STATS', $quick_stats);

## Statistics (Google Charts)
$sales = $GLOBALS['db']->select('CubeCart_order_summary', array('order_date', 'total'), array('order_date' => '>='.$last_year_start, 'status' => array(2, 3), 'total' => '>0'));
$data= array();
if ($sales) { ## Get data to put in chart
foreach ($sales as $sale) {
$year = date('Y', $sale['order_date']);
$month = date('M', $sale['order_date']);
if (isset($data[$year][$month])) {
$data[$year][$month] += sprintf('%0.2f', $sale['total']);
} else {
$data[$year][$month] = sprintf('%0.2f', $sale['total']);
}
}
}

$this_year = date('Y');
$last_year = $this_year - 1;

$chart_data['data'] = "['Month', '$this_year', '$last_year'],";

for ($month = 1; $month <= 12; $month++) {
$m = date("M", mktime(0, 0, 0, $month, 10));
$last_year_month = (isset($data[$last_year][$m]) && $data[$last_year][$m]>0) ? $data[$last_year][$m] : 0;
$this_year_month = (isset($data[$this_year][$m]) && $data[$this_year][$m]>0) ? $data[$this_year][$m] : 0;
$chart_data['data'] .= "['$m', $this_year_month, $last_year_month],";
}

$chart_data['title'] = $lang['dashboard']['title_sales_stats'].': '.$last_year.' - '.$this_year;
$GLOBALS['smarty']->assign('CHART', $chart_data);

}
## Last 5 orders
if (($last_orders = $GLOBALS['db']->select('CubeCart_order_summary', array('cart_order_id', 'first_name', 'last_name', 'name'), false, array('order_date' => 'DESC'), 5)) !== false) {
Expand All @@ -194,36 +225,6 @@
foreach ($GLOBALS['hooks']->load('admin.dashboard.quick_tasks') as $hook) include $hook;
$GLOBALS['smarty']->assign('QUICK_TASKS', $quick_tasks);

## Statistics (Google Charts)
$sales = $GLOBALS['db']->select('CubeCart_order_summary', array('order_date', 'total'), array('order_date' => '>='.$last_year_start, 'status' => array(2, 3), 'total' => '>0'));
$data= array();
if ($sales) { ## Get data to put in chart
foreach ($sales as $sale) {
$year = date('Y', $sale['order_date']);
$month = date('M', $sale['order_date']);
if (isset($data[$year][$month])) {
$data[$year][$month] += sprintf('%0.2f', $sale['total']);
} else {
$data[$year][$month] = sprintf('%0.2f', $sale['total']);
}
}
}

$this_year = date('Y');
$last_year = $this_year - 1;

$chart_data['data'] = "['Month', '$this_year', '$last_year'],";

for ($month = 1; $month <= 12; $month++) {
$m = date("M", mktime(0, 0, 0, $month, 10));
$last_year_month = (isset($data[$last_year][$m]) && $data[$last_year][$m]>0) ? $data[$last_year][$m] : 0;
$this_year_month = (isset($data[$this_year][$m]) && $data[$this_year][$m]>0) ? $data[$this_year][$m] : 0;
$chart_data['data'] .= "['$m', $this_year_month, $last_year_month],";
}

$chart_data['title'] = $lang['dashboard']['title_sales_stats'].': '.$last_year.' - '.$this_year;
$GLOBALS['smarty']->assign('CHART', $chart_data);

## Pending Orders Tab
$page = (isset($_GET['orders'])) ? $_GET['orders'] : 1;
$unsettled_count = $GLOBALS['db']->count('CubeCart_order_summary', 'cart_order_id', array('status' => array(1, 2)));
Expand Down Expand Up @@ -295,6 +296,8 @@
$orders = merge_array($orders, $order_notes);
}

foreach ($GLOBALS['hooks']->load('admin.dashboard.unsettled_orders') as $hook) include $hook;

$GLOBALS['smarty']->assign('ORDERS', $orders);
$GLOBALS['smarty']->assign('ORDER_PAGINATION', $GLOBALS['db']->pagination($unsettled_count, $results_per_page, $page, $show = 5, 'orders', 'orders', $glue = ' ', $view_all = true));
}
Expand Down Expand Up @@ -377,7 +380,9 @@
}

foreach ($GLOBALS['hooks']->load('admin.dashboard.tabs') as $hook) include $hook;
$GLOBALS['smarty']->assign('PLUGIN_TABS', $smarty_data['plugin_tabs']);
if(isset($smarty_data['plugin_tabs'])) {
$GLOBALS['smarty']->assign('PLUGIN_TABS', $smarty_data['plugin_tabs']);
}

## Latest News (from RSS)
if ($GLOBALS['config']->has('config', 'default_rss_feed') && !$GLOBALS['config']->isEmpty('config', 'default_rss_feed') && filter_var($GLOBALS['config']->get('config', 'default_rss_feed'), FILTER_VALIDATE_URL)) {
Expand Down
9 changes: 5 additions & 4 deletions admin/sources/products.import.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@
if(!isset($product_record['product_code']) || empty($product_record['product_code'])) {
$product_record['product_code'] = generate_product_code($product_record['name']);
}
if(!isset($product_record['latest']) || empty($product_record['latest'])) {
$product_record['latest'] = 1;

if(!isset($product_record['latest']) || !in_array((string)$product_record['latest'], array('1','0'))) {
$product_record['latest'] = '1';
}
if(!isset($product_record['featured']) || empty($product_record['featured'])) {
$product_record['featured'] = 1;
if(!isset($product_record['featured']) || !in_array((string)$product_record['featured'], array('1','0'))) {
$product_record['featured'] = '1';
}
// If no stock level is set we assume no stock control is used
if(isset($product_record['use_stock_level']) && ($product_record['use_stock_level']==1 || strtolower($product_record['use_stock_level'])=='true')) {
Expand Down
11 changes: 9 additions & 2 deletions admin/sources/products.index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
httpredir(currentPage($rem_array, $add_array), 'translate');
}

if (((isset($_GET['delete']) && !empty($_GET['delete'])) || (isset($_POST['delete']) && is_array($_POST['delete']))) && Admin::getInstance()->permissions('products', CC_PERM_DELETE)) {
if (((isset($_GET['delete']) && !empty($_GET['delete'])) || (isset($_POST['delete']) && is_array($_POST['delete']) && $_POST['action']=='delete')) && Admin::getInstance()->permissions('products', CC_PERM_DELETE)) {
// Delete Product
foreach ($GLOBALS['hooks']->load('admin.product.delete') as $hook) include $hook;

Expand Down Expand Up @@ -1023,8 +1023,15 @@ function option_matrix($unique_groups) {

// update cached name
if (isset($smarty_data['option_matrix']['all_possible']) && is_array($smarty_data['option_matrix']['all_possible'])) {
$pc_postfix = 1;
foreach ($smarty_data['option_matrix']['all_possible'] as $option_group) {
$GLOBALS['db']->update('CubeCart_option_matrix', array('cached_name' => $option_group['options_values'], 'status' => 1), array('options_identifier' => $option_group['options_identifier'], 'product_id' => $product_id));
if($GLOBALS['db']->select('CubeCart_option_matrix', 'matrix_id', array('options_identifier' => $option_group['options_identifier']))) {
$GLOBALS['db']->update('CubeCart_option_matrix', array('cached_name' => $option_group['options_values'], 'status' => 1), array('options_identifier' => $option_group['options_identifier'], 'product_id' => $product_id));
} else {
$GLOBALS['db']->insert('CubeCart_option_matrix', array('cached_name' => $option_group['options_values'], 'status' => 1, 'options_identifier' => $option_group['options_identifier'], 'product_id' => $product_id, 'product_code' => $result[0]['product_code'].'-'.(string)$pc_postfix));
}
$pc_postfix++;

}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/sources/settings.errorlog.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}

$GLOBALS['smarty']->assign('ADMIN_ERROR_LOG', $smarty_data['error_log']);
$count = $GLOBALS['db']->count('CubeCart_admin_error_log', 'log_id', array('admin_id' => Admin::getInstance()->get('admin_id')));
$count = $GLOBALS['db']->getFoundRows();
$GLOBALS['smarty']->assign('PAGINATION_ADMIN_ERROR_LOG', $GLOBALS['db']->pagination($count, $per_page, $page, 5, 'page', 'admin_error_log'));

if (Admin::getInstance()->superUser()) {
Expand All @@ -83,7 +83,7 @@
$GLOBALS['smarty']->assign('SYSTEM_ERROR_LOG', $smarty_data['system_error_log']);
}

$count = $GLOBALS['db']->count('CubeCart_system_error_log', 'log_id');
$count = $GLOBALS['db']->getFoundRows();
$GLOBALS['smarty']->assign('PAGINATION_SYSTEM_ERROR_LOG', $GLOBALS['db']->pagination($count, $per_page, $page, 5, 'page', 'system_error_log'));
}
$page_content = $GLOBALS['smarty']->fetch('templates/settings.errorlog.php');
1 change: 1 addition & 0 deletions admin/sources/settings.index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
}

$config_new = $_POST['config'];
$config_new['enc_key'] = $config_old['enc_key']; // Keep old encryption key
$config_new['offline_content'] = $GLOBALS['RAW']['POST']['config']['offline_content'];
$config_new['store_copyright'] = $GLOBALS['RAW']['POST']['config']['store_copyright'];

Expand Down
2 changes: 1 addition & 1 deletion admin/sources/settings.requestlog.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

$GLOBALS['smarty']->assign('REQUEST_LOG', $smarty_data['request_log']);
$count = $GLOBALS['db']->count('CubeCart_request_log', 'request_id');
$count = $GLOBALS['db']->getFoundRows();
$GLOBALS['smarty']->assign('PAGINATION_REQUEST_LOG', $GLOBALS['db']->pagination($count, $per_page, $page, 5, 'page'));
}
$page_content = $GLOBALS['smarty']->fetch('templates/settings.requestlog.php');
Loading

0 comments on commit 14e4172

Please sign in to comment.