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'];
|
||||
}
|
||||
|
||||
if(empty($config['dashboard_cr'])){
|
||||
$config['dashboard_cr'] = "12.7,5.12";
|
||||
if(empty($config['dashboard_Admin'])){
|
||||
$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;
|
||||
if (empty($http_proxy) && !empty($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('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);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
try{
|
||||
|
@ -5,15 +5,23 @@
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
_admin();
|
||||
$ui->assign('_title', Lang::T('Widgets'));
|
||||
$ui->assign('_title', Lang::T('Dashboard Widgets'));
|
||||
$ui->assign('_system_menu', 'settings');
|
||||
|
||||
$action = alphanumeric($routes['1']);
|
||||
$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');
|
||||
$max2 = substr_count($config['dashboard_cr'], '.')+substr_count($config['dashboard_cr'], ',')+1;
|
||||
if($max2>$max){
|
||||
$max2 = substr_count($config['dashboard_' . $tipeUser], '.') + substr_count($config['dashboard_' . $tipeUser], ',') + 1;
|
||||
if ($max2 > $max) {
|
||||
$max = $max2;
|
||||
}
|
||||
$ui->assign('max', $max);
|
||||
@ -23,6 +31,7 @@ if ($action == 'add') {
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$orders = alphanumeric($_POST['orders']);
|
||||
$position = alphanumeric($_POST['position']);
|
||||
$tipeUser = alphanumeric($_POST['tipeUser']);
|
||||
$enabled = alphanumeric($_POST['enabled']);
|
||||
$title = _post('title');
|
||||
$widget = _post('widget');
|
||||
@ -30,13 +39,14 @@ if ($action == 'add') {
|
||||
$d = ORM::for_table('tbl_widgets')->create();
|
||||
$d->orders = $orders;
|
||||
$d->position = $position;
|
||||
$d->user = $tipeUser;
|
||||
$d->enabled = $enabled;
|
||||
$d->title = $title;
|
||||
$d->widget = $widget;
|
||||
$d->content = $content;
|
||||
$d->save();
|
||||
if ($d->id() > 0) {
|
||||
r2(getUrl('widgets'), 's', 'Widget Added Successfully');
|
||||
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget Added Successfully');
|
||||
}
|
||||
}
|
||||
$files = scandir($WIDGET_PATH);
|
||||
@ -48,6 +58,7 @@ if ($action == 'add') {
|
||||
}
|
||||
}
|
||||
$widget['position'] = $pos;
|
||||
$ui->assign('users', ORM::for_table('tbl_widgets')->getEnum("user"));
|
||||
$ui->assign('do', 'add');
|
||||
$ui->assign('widgets', $widgets);
|
||||
$ui->assign('widget', $widget);
|
||||
@ -58,6 +69,7 @@ if ($action == 'add') {
|
||||
$id = alphanumeric($_POST['id']);
|
||||
$orders = alphanumeric($_POST['orders']);
|
||||
$position = alphanumeric($_POST['position']);
|
||||
$tipeUser = alphanumeric($_POST['tipeUser']);
|
||||
$enabled = alphanumeric($_POST['enabled']);
|
||||
$title = _post('title');
|
||||
$widget = _post('widget');
|
||||
@ -66,12 +78,13 @@ if ($action == 'add') {
|
||||
$d = ORM::for_table('tbl_widgets')->find_one($id);
|
||||
$d->orders = $orders;
|
||||
$d->position = $position;
|
||||
$d->user = $tipeUser;
|
||||
$d->enabled = $enabled;
|
||||
$d->title = $title;
|
||||
$d->widget = $widget;
|
||||
$d->content = $content;
|
||||
$d->save();
|
||||
r2(getUrl('widgets'), 's', 'Widget Saved Successfully');
|
||||
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget Saved Successfully');
|
||||
}
|
||||
$id = alphanumeric($routes['2']);
|
||||
$widget = ORM::for_table('tbl_widgets')->find_one($id);
|
||||
@ -83,6 +96,7 @@ if ($action == 'add') {
|
||||
$widgets[str_replace('.php', '', $file)] = $name;
|
||||
}
|
||||
}
|
||||
$ui->assign('users', ORM::for_table('tbl_widgets')->getEnum("user"));
|
||||
$ui->assign('do', 'edit');
|
||||
$ui->assign('widgets', $widgets);
|
||||
$ui->assign('widget', $widget);
|
||||
@ -92,9 +106,9 @@ if ($action == 'add') {
|
||||
$d = ORM::for_table('tbl_widgets')->find_one($id);
|
||||
if ($d) {
|
||||
$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'])) {
|
||||
require_once "system/widget/$action.php";
|
||||
try {
|
||||
@ -109,22 +123,22 @@ if ($action == 'add') {
|
||||
$d->orders = $_POST['orders'][$i];
|
||||
$d->save();
|
||||
}
|
||||
r2(getUrl('widgets'), 's', 'Widget order Saved Successfully');
|
||||
r2(getUrl('widgets&user=' . $tipeUser), 's', 'Widget order Saved Successfully');
|
||||
} else {
|
||||
if(_post("save") == 'struct'){
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'dashboard_cr')->find_one();
|
||||
if (_post("save") == 'struct') {
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'dashboard_' . $tipeUser)->find_one();
|
||||
if ($d) {
|
||||
$d->value = _post('dashboard_cr');
|
||||
$d->value = _post('dashboard');
|
||||
$d->save();
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'dashboard_cr';
|
||||
$d->value = _post('dashboard_cr');
|
||||
$d->setting = 'dashboard_' . $tipeUser;
|
||||
$d->value = _post('dashboard');
|
||||
$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->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.",
|
||||
"Dashboard_Structure": "Dashboard Structure",
|
||||
"Read_documentation": "Read documentation",
|
||||
"Structure": "Structure"
|
||||
"Structure": "Structure",
|
||||
"Dashboard_Widgets": "Dashboard Widgets",
|
||||
"User": "User"
|
||||
}
|
@ -1,10 +1,17 @@
|
||||
{include file="sections/header.tpl"}
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<ul class="nav nav-tabs nav-justified">
|
||||
<li role="presentation" {if $tipeUser=='Admin'} class="active" {/if}><a
|
||||
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}
|
||||
<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-heading">{Lang::T("Area Fields")} {$pos}</div>
|
||||
<div class="panel-body">
|
||||
@ -44,7 +51,7 @@
|
||||
<div class="btn-group" role="group">
|
||||
<button type="submit" class="btn btn-info">{Lang::T("Save sequence")}</button>
|
||||
</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>
|
||||
@ -80,14 +87,16 @@
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<form method="post" action="{Text::url('widgets')}">
|
||||
<form method="post">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><a href="{$app_url}/docs/#Dashboard%20Structure"
|
||||
target="_blank">{Lang::T("Structure")}</a></span>
|
||||
<input type="text" name="dashboard_cr" value="{$_c['dashboard_cr']}" class="form-control"
|
||||
target="_blank">{Lang::T("Structure")}</a></span>
|
||||
{assign dtipe value="dashboard_`$tipeUser`"}
|
||||
<input type="text" name="dashboard" value="{$_c[$dtipe]}" class="form-control"
|
||||
placeholder="Dashboard">
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -49,6 +49,19 @@
|
||||
</div>
|
||||
<p class="help-block col-md-4"> </p>
|
||||
</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">
|
||||
<label class="col-md-3 control-label">{Lang::T('Status')}</label>
|
||||
<div class="col-md-5">
|
||||
|
Loading…
x
Reference in New Issue
Block a user