Different Widget for admin, Agent, Sales and Customers Editor
This commit is contained in:
parent
f929560384
commit
da86f2c422
17
init.php
17
init.php
@ -113,10 +113,23 @@ foreach ($result as $value) {
|
|||||||
$config[$value['setting']] = $value['value'];
|
$config[$value['setting']] = $value['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($config['dashboard_cr'])){
|
if(empty($config['dashboard_Admin'])){
|
||||||
$config['dashboard_cr'] = "12.7,5.12";
|
$config['dashboard_Admin'] = "12.7,5.12";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(empty($config['dashboard_Agent'])){
|
||||||
|
$config['dashboard_Agent'] = "12.7,5.12";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($config['dashboard_Sales'])){
|
||||||
|
$config['dashboard_Sales'] = "12.7,5.12";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($config['dashboard_Customer'])){
|
||||||
|
$config['dashboard_Customer'] = "12.12";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$_c = $config;
|
$_c = $config;
|
||||||
if (empty($http_proxy) && !empty($config['http_proxy'])) {
|
if (empty($http_proxy) && !empty($config['http_proxy'])) {
|
||||||
$http_proxy = $config['http_proxy'];
|
$http_proxy = $config['http_proxy'];
|
||||||
|
@ -36,7 +36,12 @@ $current_date = date('Y-m-d');
|
|||||||
$ui->assign('start_date', $start_date);
|
$ui->assign('start_date', $start_date);
|
||||||
$ui->assign('current_date', $current_date);
|
$ui->assign('current_date', $current_date);
|
||||||
|
|
||||||
$widgets = ORM::for_table('tbl_widgets')->selects("enabled", 1)->order_by_asc("orders")->findArray();
|
$tipeUser = $admin['user_type'];
|
||||||
|
if (in_array($tipeUser, ['SuperAdmin', 'Admin'])) {
|
||||||
|
$tipeUser = 'Admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
$widgets = ORM::for_table('tbl_widgets')->where("enabled", 1)->where('user', $tipeUser)->order_by_asc("orders")->findArray();
|
||||||
$count = count($widgets);
|
$count = count($widgets);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
try{
|
try{
|
||||||
|
@ -5,14 +5,22 @@
|
|||||||
* by https://t.me/ibnux
|
* by https://t.me/ibnux
|
||||||
**/
|
**/
|
||||||
_admin();
|
_admin();
|
||||||
$ui->assign('_title', Lang::T('Widgets'));
|
$ui->assign('_title', Lang::T('Dashboard Widgets'));
|
||||||
$ui->assign('_system_menu', 'settings');
|
$ui->assign('_system_menu', 'settings');
|
||||||
|
|
||||||
$action = alphanumeric($routes['1']);
|
$action = alphanumeric($routes['1']);
|
||||||
$ui->assign('_admin', $admin);
|
$ui->assign('_admin', $admin);
|
||||||
|
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
|
r2(getUrl('dashboard'), 'e', Lang::T('You do not have permission to access this page'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$tipeUser = _req("user");
|
||||||
|
if (empty($tipeUser)) {
|
||||||
|
$tipeUser = 'Admin';
|
||||||
|
}
|
||||||
|
$ui->assign('tipeUser', $tipeUser);
|
||||||
$max = ORM::for_table('tbl_widgets')->max('position');
|
$max = ORM::for_table('tbl_widgets')->max('position');
|
||||||
$max2 = substr_count($config['dashboard_cr'], '.')+substr_count($config['dashboard_cr'], ',')+1;
|
$max2 = substr_count($config['dashboard_' . $tipeUser], '.') + substr_count($config['dashboard_' . $tipeUser], ',') + 1;
|
||||||
if ($max2 > $max) {
|
if ($max2 > $max) {
|
||||||
$max = $max2;
|
$max = $max2;
|
||||||
}
|
}
|
||||||
@ -23,6 +31,7 @@ if ($action == 'add') {
|
|||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$orders = alphanumeric($_POST['orders']);
|
$orders = alphanumeric($_POST['orders']);
|
||||||
$position = alphanumeric($_POST['position']);
|
$position = alphanumeric($_POST['position']);
|
||||||
|
$tipeUser = alphanumeric($_POST['tipeUser']);
|
||||||
$enabled = alphanumeric($_POST['enabled']);
|
$enabled = alphanumeric($_POST['enabled']);
|
||||||
$title = _post('title');
|
$title = _post('title');
|
||||||
$widget = _post('widget');
|
$widget = _post('widget');
|
||||||
@ -30,13 +39,14 @@ if ($action == 'add') {
|
|||||||
$d = ORM::for_table('tbl_widgets')->create();
|
$d = ORM::for_table('tbl_widgets')->create();
|
||||||
$d->orders = $orders;
|
$d->orders = $orders;
|
||||||
$d->position = $position;
|
$d->position = $position;
|
||||||
|
$d->user = $tipeUser;
|
||||||
$d->enabled = $enabled;
|
$d->enabled = $enabled;
|
||||||
$d->title = $title;
|
$d->title = $title;
|
||||||
$d->widget = $widget;
|
$d->widget = $widget;
|
||||||
$d->content = $content;
|
$d->content = $content;
|
||||||
$d->save();
|
$d->save();
|
||||||
if ($d->id() > 0) {
|
if ($d->id() > 0) {
|
||||||
r2(getUrl('widgets'), 's', 'Widget Added Successfully');
|
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget Added Successfully');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$files = scandir($WIDGET_PATH);
|
$files = scandir($WIDGET_PATH);
|
||||||
@ -48,6 +58,7 @@ if ($action == 'add') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$widget['position'] = $pos;
|
$widget['position'] = $pos;
|
||||||
|
$ui->assign('users', ORM::for_table('tbl_widgets')->getEnum("user"));
|
||||||
$ui->assign('do', 'add');
|
$ui->assign('do', 'add');
|
||||||
$ui->assign('widgets', $widgets);
|
$ui->assign('widgets', $widgets);
|
||||||
$ui->assign('widget', $widget);
|
$ui->assign('widget', $widget);
|
||||||
@ -58,6 +69,7 @@ if ($action == 'add') {
|
|||||||
$id = alphanumeric($_POST['id']);
|
$id = alphanumeric($_POST['id']);
|
||||||
$orders = alphanumeric($_POST['orders']);
|
$orders = alphanumeric($_POST['orders']);
|
||||||
$position = alphanumeric($_POST['position']);
|
$position = alphanumeric($_POST['position']);
|
||||||
|
$tipeUser = alphanumeric($_POST['tipeUser']);
|
||||||
$enabled = alphanumeric($_POST['enabled']);
|
$enabled = alphanumeric($_POST['enabled']);
|
||||||
$title = _post('title');
|
$title = _post('title');
|
||||||
$widget = _post('widget');
|
$widget = _post('widget');
|
||||||
@ -66,12 +78,13 @@ if ($action == 'add') {
|
|||||||
$d = ORM::for_table('tbl_widgets')->find_one($id);
|
$d = ORM::for_table('tbl_widgets')->find_one($id);
|
||||||
$d->orders = $orders;
|
$d->orders = $orders;
|
||||||
$d->position = $position;
|
$d->position = $position;
|
||||||
|
$d->user = $tipeUser;
|
||||||
$d->enabled = $enabled;
|
$d->enabled = $enabled;
|
||||||
$d->title = $title;
|
$d->title = $title;
|
||||||
$d->widget = $widget;
|
$d->widget = $widget;
|
||||||
$d->content = $content;
|
$d->content = $content;
|
||||||
$d->save();
|
$d->save();
|
||||||
r2(getUrl('widgets'), 's', 'Widget Saved Successfully');
|
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget Saved Successfully');
|
||||||
}
|
}
|
||||||
$id = alphanumeric($routes['2']);
|
$id = alphanumeric($routes['2']);
|
||||||
$widget = ORM::for_table('tbl_widgets')->find_one($id);
|
$widget = ORM::for_table('tbl_widgets')->find_one($id);
|
||||||
@ -83,6 +96,7 @@ if ($action == 'add') {
|
|||||||
$widgets[str_replace('.php', '', $file)] = $name;
|
$widgets[str_replace('.php', '', $file)] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ui->assign('users', ORM::for_table('tbl_widgets')->getEnum("user"));
|
||||||
$ui->assign('do', 'edit');
|
$ui->assign('do', 'edit');
|
||||||
$ui->assign('widgets', $widgets);
|
$ui->assign('widgets', $widgets);
|
||||||
$ui->assign('widget', $widget);
|
$ui->assign('widget', $widget);
|
||||||
@ -92,9 +106,9 @@ if ($action == 'add') {
|
|||||||
$d = ORM::for_table('tbl_widgets')->find_one($id);
|
$d = ORM::for_table('tbl_widgets')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
$d->delete();
|
$d->delete();
|
||||||
r2(getUrl('widgets'), 's', 'Widget Deleted Successfully');
|
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget Deleted Successfully');
|
||||||
}
|
}
|
||||||
r2(getUrl('widgets'), 'e', 'Widget Not Found');
|
r2(getUrl('widgets&user=' . $tipeUser), 'e', 'Widget Not Found');
|
||||||
} else if (!empty($action) && file_exists("system/widget/$action.php") && !empty($routes['2'])) {
|
} else if (!empty($action) && file_exists("system/widget/$action.php") && !empty($routes['2'])) {
|
||||||
require_once "system/widget/$action.php";
|
require_once "system/widget/$action.php";
|
||||||
try {
|
try {
|
||||||
@ -109,22 +123,22 @@ if ($action == 'add') {
|
|||||||
$d->orders = $_POST['orders'][$i];
|
$d->orders = $_POST['orders'][$i];
|
||||||
$d->save();
|
$d->save();
|
||||||
}
|
}
|
||||||
r2(getUrl('widgets'), 's', 'Widget order Saved Successfully');
|
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget order Saved Successfully');
|
||||||
} else {
|
} else {
|
||||||
if (_post("save") == 'struct') {
|
if (_post("save") == 'struct') {
|
||||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'dashboard_cr')->find_one();
|
$d = ORM::for_table('tbl_appconfig')->where('setting', 'dashboard_' . $tipeUser)->find_one();
|
||||||
if ($d) {
|
if ($d) {
|
||||||
$d->value = _post('dashboard_cr');
|
$d->value = _post('dashboard');
|
||||||
$d->save();
|
$d->save();
|
||||||
} else {
|
} else {
|
||||||
$d = ORM::for_table('tbl_appconfig')->create();
|
$d = ORM::for_table('tbl_appconfig')->create();
|
||||||
$d->setting = 'dashboard_cr';
|
$d->setting = 'dashboard_' . $tipeUser;
|
||||||
$d->value = _post('dashboard_cr');
|
$d->value = _post('dashboard');
|
||||||
$d->save();
|
$d->save();
|
||||||
}
|
}
|
||||||
_alert("Dashboard Structure Saved Successfully", "success", getUrl('widgets'));
|
_alert("Dashboard Structure Saved Successfully", "success", getUrl('widgets&user=' . $tipeUser));
|
||||||
}
|
}
|
||||||
$widgets = ORM::for_table('tbl_widgets')->selects("position", 1)->order_by_asc("orders")->find_many();
|
$widgets = ORM::for_table('tbl_widgets')->where("user", $tipeUser)->order_by_asc("orders")->find_many();
|
||||||
$ui->assign('widgets', $widgets);
|
$ui->assign('widgets', $widgets);
|
||||||
$ui->display('admin/settings/widgets.tpl');
|
$ui->display('admin/settings/widgets.tpl');
|
||||||
}
|
}
|
||||||
|
@ -1052,5 +1052,7 @@
|
|||||||
"Failed_to_send_the_message__Please_try_again_": "Failed to send the message. Please try again.",
|
"Failed_to_send_the_message__Please_try_again_": "Failed to send the message. Please try again.",
|
||||||
"Dashboard_Structure": "Dashboard Structure",
|
"Dashboard_Structure": "Dashboard Structure",
|
||||||
"Read_documentation": "Read documentation",
|
"Read_documentation": "Read documentation",
|
||||||
"Structure": "Structure"
|
"Structure": "Structure",
|
||||||
|
"Dashboard_Widgets": "Dashboard Widgets",
|
||||||
|
"User": "User"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{include file="sections/header.tpl"}
|
{include file="sections/header.tpl"}
|
||||||
|
<ul class="nav nav-tabs nav-justified">
|
||||||
|
<li role="presentation" {if $tipeUser=='Admin'} class="active" {/if}><a
|
||||||
<hr>
|
href="{Text::url('widgets&user=Admin')}">Admin</a></li>
|
||||||
|
<li role="presentation" {if $tipeUser=='Agent'} class="active" {/if}><a
|
||||||
|
href="{Text::url('widgets&user=Agent')}">Agent</a></li>
|
||||||
|
<li role="presentation" {if $tipeUser=='Sales'} class="active" {/if}><a
|
||||||
|
href="{Text::url('widgets&user=Sales')}">Sales</a></li>
|
||||||
|
<li role="presentation" {if $tipeUser=='Customer'} class="active" {/if}><a
|
||||||
|
href="{Text::url('widgets&user=Customer')}">Customer</a></li>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
{function showWidget pos=0}
|
{function showWidget pos=0}
|
||||||
<form method="post" action="{Text::url('widgets/pos/')}">
|
<form method="post" action="{Text::url('widgets/pos/', '&user=', $tipeUser)}">
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">{Lang::T("Area Fields")} {$pos}</div>
|
<div class="panel-heading">{Lang::T("Area Fields")} {$pos}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@ -44,7 +51,7 @@
|
|||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button type="submit" class="btn btn-info">{Lang::T("Save sequence")}</button>
|
<button type="submit" class="btn btn-info">{Lang::T("Save sequence")}</button>
|
||||||
</div>
|
</div>
|
||||||
<a href="{Text::url('widgets/add/', $pos)}" class="btn btn-primary">{Lang::T("Add new widget")}</a>
|
<a href="{Text::url('widgets/add/', $pos, '&user=', $tipeUser)}" class="btn btn-primary">{Lang::T("Add new widget")}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -80,14 +87,16 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<form method="post" action="{Text::url('widgets')}">
|
<form method="post">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon"><a href="{$app_url}/docs/#Dashboard%20Structure"
|
<span class="input-group-addon"><a href="{$app_url}/docs/#Dashboard%20Structure"
|
||||||
target="_blank">{Lang::T("Structure")}</a></span>
|
target="_blank">{Lang::T("Structure")}</a></span>
|
||||||
<input type="text" name="dashboard_cr" value="{$_c['dashboard_cr']}" class="form-control"
|
{assign dtipe value="dashboard_`$tipeUser`"}
|
||||||
|
<input type="text" name="dashboard" value="{$_c[$dtipe]}" class="form-control"
|
||||||
placeholder="Dashboard">
|
placeholder="Dashboard">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary btn-block" name="save" value="struct">{Lang::T("Save")}</button>
|
<button type="submit" class="btn btn-primary btn-block" name="save"
|
||||||
|
value="struct">{Lang::T("Save")}</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,6 +49,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="help-block col-md-4"> </p>
|
<p class="help-block col-md-4"> </p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-3 control-label">{Lang::T('User')}</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<select name="tipeUser" id="tipeUser" class="form-control">
|
||||||
|
{foreach $users as $u}
|
||||||
|
<option value="{$u}" {if $tipeUser eq $u}selected="selected" {/if}>
|
||||||
|
Dashboard {$u}
|
||||||
|
</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="help-block col-md-4"> </p>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-3 control-label">{Lang::T('Status')}</label>
|
<label class="col-md-3 control-label">{Lang::T('Status')}</label>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user