[*] BO : Added simulation mode to the dashboard
This commit is contained in:
@@ -128,6 +128,22 @@
|
||||
<dd><a href="http://www.prestashop.com/en/contact-us?utm_source=backoffice_dashboard" target="_blank">{l s="Go to prestashop.com"}</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section class="dash_simulation panel">
|
||||
<h3><i class="icon-link"></i> {l s="Simulation Mode"}</h3>
|
||||
<span class="switch prestashop-switch">
|
||||
<input id="PS_DASHBOARD_SIMULATION_on" class="ps_dashboard_simulation" type="radio" checked="checked" value="1" name="PS_DASHBOARD_SIMULATION">
|
||||
<label class="radioCheck" for="PS_DASHBOARD_SIMULATION_on">
|
||||
<i class="icon-check-sign color_success"></i> {l s='Yes'}
|
||||
</label>
|
||||
<input id="PS_DASHBOARD_SIMULATION_off" class="ps_dashboard_simulation" type="radio" value="0" name="PS_DASHBOARD_SIMULATION">
|
||||
<label class="radioCheck" for="PS_DASHBOARD_SIMULATION_off">
|
||||
<i class="icon-ban-circle color_danger"></i> {l s='No'}
|
||||
</label>
|
||||
<span class="slide-button btn btn-default"></span>
|
||||
</span>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -309,7 +309,13 @@ class AdminDashboardControllerCore extends AdminController
|
||||
|
||||
die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
|
||||
}
|
||||
|
||||
|
||||
public function ajaxProcessSetSimulationMode()
|
||||
{
|
||||
Configuration::updateValue('PS_DASHBOARD_SIMULATION', (int)Tools::getValue('PS_DASHBOARD_SIMULATION'));
|
||||
die ('k'.Configuration::get('PS_DASHBOARD_SIMULATION').'k');
|
||||
}
|
||||
|
||||
public function ajaxProcessGetBlogRss()
|
||||
{
|
||||
$return = array('has_errors' => false, 'rss' => array());
|
||||
|
||||
@@ -67,6 +67,7 @@ UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'BLOCK_CATEG_NBR_COLU
|
||||
UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPDB_FILENAME';
|
||||
UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPFILES_FILENAME';
|
||||
UPDATE `PREFIX_configuration` SET value = '40' WHERE name = 'CONF_AVERAGE_PRODUCT_MARGIN';
|
||||
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DASHBOARD_SIMULATION';
|
||||
|
||||
/* No right column */
|
||||
DELETE FROM `PREFIX_hook_module` WHERE id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayRightColumn');
|
||||
|
||||
@@ -289,4 +289,18 @@ $(document).ready( function () {
|
||||
getBlogRss();
|
||||
bindSubmitDashConfig();
|
||||
bindCancelDashConfig();
|
||||
|
||||
$('.ps_dashboard_simulation').change(function(e) {
|
||||
$.ajax({
|
||||
url : dashboard_ajax_url,
|
||||
data : {
|
||||
ajax:true,
|
||||
action:'setSimulationMode',
|
||||
PS_DASHBOARD_SIMULATION: $(this).val()
|
||||
},
|
||||
success : function(result) {
|
||||
refreshDashboard(false, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -97,6 +97,45 @@ class Dashactivity extends Module
|
||||
|
||||
public function hookDashboardData($params)
|
||||
{
|
||||
if (Configuration::get('PS_DASHBOARD_SIMULATION'))
|
||||
{
|
||||
$days = round((strtotime($params['date_to']) - strtotime($params['date_from'])) / 3600 / 24);
|
||||
$online_visitor = round(rand(10, 50));
|
||||
$visits = round(rand(200, 2000) * $days);
|
||||
|
||||
return array(
|
||||
'data_value' => array(
|
||||
'pending_orders' => round(rand(0, 5)),
|
||||
'return_exchanges' => round(rand(0, 5)),
|
||||
'abandoned_cart' => round(rand(5, 50)),
|
||||
'products_out_of_stock' => round(rand(1, 10)),
|
||||
'new_messages' => round(rand(1, 10) * $days),
|
||||
'order_inquires' => 42,
|
||||
'product_reviews' => round(rand(5, 50) * $days),
|
||||
'new_customers' => round(rand(1, 5) * $days),
|
||||
'online_visitor' => $online_visitor,
|
||||
'active_shopping_cart' => round($online_visitor / 10),
|
||||
'new_registrations' => round(rand(1, 5) * $days),
|
||||
'total_suscribers' => round(rand(200, 2000)),
|
||||
'visits' => $visits,
|
||||
'unique_visitors' => round($visits * 0.6),
|
||||
),
|
||||
'data_trends' => array(
|
||||
'orders_trends' => array('way' => 'down', 'value' => 0.42),
|
||||
),
|
||||
'data_list_small' => array(
|
||||
'dash_traffic_source' => array('prestashop.com' => round($visits / 2), 'google.com' => round($visits / 3), 'Direct Traffic' => round($visits / 4))
|
||||
),
|
||||
'data_chart' => array(
|
||||
'dash_trends_chart1' => array('chart_type' => 'pie_chart_trends', 'data' => array(
|
||||
array('key' => 'prestashop.com', 'y' => round($visits / 2)),
|
||||
array('key' => 'google.com', 'y' => round($visits / 3)),
|
||||
array('key' => 'Direct Traffic', 'y' => round($visits / 4))
|
||||
))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
||||
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||
{
|
||||
@@ -353,14 +392,14 @@ class Dashactivity extends Module
|
||||
$fields_form['form']['input'][] = array(
|
||||
'label' => $this->l('Cart abandoned (min)'),
|
||||
'desc' => $this->l('Default time range (min) to consider a Shopping cart as abandoned (default 24hrs)'),
|
||||
'name' => 'DASHACTIVITY_CART_ABANDONED_MIN',
|
||||
'name' => 'DASHACTIVITY_CART_ABANDONED',
|
||||
'type' => 'text',
|
||||
'suffix' => $this->l('hrs'),
|
||||
);
|
||||
$fields_form['form']['input'][] = array(
|
||||
'label' => $this->l('Cart abandoned (max)'),
|
||||
'desc' => $this->l('Default time range (max) to consider a Shopping cart as abandoned (default 48hrs)'),
|
||||
'name' => 'DASHACTIVITY_CART_ABANDONED_MAX',
|
||||
'name' => 'DASHACTIVITY_CART_ABANDONED',
|
||||
'type' => 'text',
|
||||
'suffix' => $this->l('hrs'),
|
||||
);
|
||||
|
||||
@@ -75,11 +75,30 @@ class Dashtrends extends Module
|
||||
'total_expenses' => array()
|
||||
);
|
||||
|
||||
$tmp_data['visits'] = AdminStatsControllerCore::getVisits(false, $date_from, $date_to, 'day');
|
||||
$tmp_data['orders'] = AdminStatsControllerCore::getOrders($date_from, $date_to, 'day');
|
||||
$tmp_data['total_paid_tax_excl'] = AdminStatsControllerCore::getTotalSales($date_from, $date_to, 'day');
|
||||
$tmp_data['total_purchases'] = AdminStatsControllerCore::getPurchases($date_from, $date_to, 'day');
|
||||
$tmp_data['total_expenses'] = AdminStatsControllerCore::getExpenses($date_from, $date_to, 'day');
|
||||
if (Configuration::get('PS_DASHBOARD_SIMULATION'))
|
||||
{
|
||||
$from = strtotime($date_from.' 00:00:00');
|
||||
$to = min(time(), strtotime($date_to.' 23:59:59'));
|
||||
for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date))
|
||||
{
|
||||
$tmp_data['visits'][$date] = round(rand(2000, 20000));
|
||||
$tmp_data['conversion_rate'][$date] = rand(80, 250) / 100;
|
||||
$tmp_data['average_cart_value'][$date] = round(rand(60, 200), 2);
|
||||
$tmp_data['orders'][$date] = round($tmp_data['visits'][$date] * $tmp_data['conversion_rate'][$date] / 100);
|
||||
$tmp_data['total_paid_tax_excl'][$date] = $tmp_data['orders'][$date] * $tmp_data['average_cart_value'][$date];
|
||||
$tmp_data['total_purchases'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(50, 70) / 100;
|
||||
$tmp_data['total_expenses'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(0, 10) / 100;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp_data['visits'] = AdminStatsControllerCore::getVisits(false, $date_from, $date_to, 'day');
|
||||
$tmp_data['orders'] = AdminStatsControllerCore::getOrders($date_from, $date_to, 'day');
|
||||
$tmp_data['total_paid_tax_excl'] = AdminStatsControllerCore::getTotalSales($date_from, $date_to, 'day');
|
||||
$tmp_data['total_purchases'] = AdminStatsControllerCore::getPurchases($date_from, $date_to, 'day');
|
||||
$tmp_data['total_expenses'] = AdminStatsControllerCore::getExpenses($date_from, $date_to, 'day');
|
||||
}
|
||||
|
||||
return $tmp_data;
|
||||
}
|
||||
|
||||
@@ -93,7 +112,10 @@ class Dashtrends extends Module
|
||||
'conversion_rate' => array(),
|
||||
'net_profits' => array()
|
||||
);
|
||||
$from = max(strtotime(_PS_CREATION_DATE_.' 00:00:00'), strtotime($date_from.' 00:00:00'));
|
||||
|
||||
$from = strtotime($date_from.' 00:00:00');
|
||||
if (!Configuration::get('PS_DASHBOARD_SIMULATION'))
|
||||
$from = max(strtotime(_PS_CREATION_DATE_.' 00:00:00'), $from);
|
||||
$to = min(time(), strtotime($date_to.' 23:59:59'));
|
||||
for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user