From 8d2c334da01de1aa5fb5e5489b99ad9ca6e53c2e Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Fri, 21 Feb 2025 16:01:38 +0700 Subject: [PATCH] Different Widget for Admin, Agent, Sales, Customer. Agent, Sales not yet have widget --- system/controllers/dashboard.php | 5 ++++ system/controllers/widgets.php | 8 +++++- ui/ui/admin/dashboard.tpl | 3 ++- ui/ui/admin/settings/widgets.tpl | 15 +++++------ ui/ui/admin/settings/widgets_add_edit.tpl | 31 +++++++++++++---------- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 18f9fb0c..164df183 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -20,6 +20,11 @@ if (isset($_GET['refresh'])) { r2(getUrl('dashboard'), 's', 'Data Refreshed'); } +$tipeUser = _req("user"); +if (empty($tipeUser)) { + $tipeUser = 'Admin'; +} +$ui->assign('tipeUser', $tipeUser); $reset_day = $config['reset_day']; if (empty($reset_day)) { diff --git a/system/controllers/widgets.php b/system/controllers/widgets.php index 0223e01f..ef0a6286 100644 --- a/system/controllers/widgets.php +++ b/system/controllers/widgets.php @@ -18,8 +18,12 @@ $tipeUser = _req("user"); if (empty($tipeUser)) { $tipeUser = 'Admin'; } +if($tipeUser == 'Customer') { + $WIDGET_PATH .= DIRECTORY_SEPARATOR. 'customer'; +} + $ui->assign('tipeUser', $tipeUser); -$max = ORM::for_table('tbl_widgets')->max('position'); +$max = ORM::for_table('tbl_widgets')->where("user", $tipeUser)->max('position'); $max2 = substr_count($config['dashboard_' . $tipeUser], '.') + substr_count($config['dashboard_' . $tipeUser], ',') + 1; if ($max2 > $max) { $max = $max2; @@ -36,6 +40,7 @@ if ($action == 'add') { $title = _post('title'); $widget = _post('widget'); $content = _post('content'); + print_r($_POST); $d = ORM::for_table('tbl_widgets')->create(); $d->orders = $orders; $d->position = $position; @@ -58,6 +63,7 @@ if ($action == 'add') { } } $widget['position'] = $pos; + $widget['user'] = $tipeUser; $ui->assign('users', ORM::for_table('tbl_widgets')->getEnum("user")); $ui->assign('do', 'add'); $ui->assign('widgets', $widgets); diff --git a/ui/ui/admin/dashboard.tpl b/ui/ui/admin/dashboard.tpl index f1ec2ef3..150b6dd2 100644 --- a/ui/ui/admin/dashboard.tpl +++ b/ui/ui/admin/dashboard.tpl @@ -8,8 +8,9 @@ {/foreach} {/function} +{assign dtipe value="dashboard_`$tipeUser`"} -{assign rows explode(".", $_c['dashboard_cr'])} +{assign rows explode(".", $_c[$dtipe])} {assign pos 1} {foreach $rows as $cols} {if $cols == 12} diff --git a/ui/ui/admin/settings/widgets.tpl b/ui/ui/admin/settings/widgets.tpl index 477c39c3..e44b367b 100644 --- a/ui/ui/admin/settings/widgets.tpl +++ b/ui/ui/admin/settings/widgets.tpl @@ -32,11 +32,11 @@
- - {Lang::T("Edit")}
@@ -51,25 +51,25 @@
- {Lang::T("Add new widget")} + {Lang::T("Add new widget")} {/function} - +{assign dtipe value="dashboard_`$tipeUser`"}
{Lang::T("Dashboard Structure")}
- {assign rows explode(".", $_c['dashboard_cr'])} + {assign rows explode(".", $_c[$dtipe])} {assign pos 1} {foreach $rows as $cols} {if $cols == 12} {assign pos value=$pos+1} @@ -78,7 +78,7 @@
{foreach $colss as $c} {assign pos value=$pos+1} {/foreach} @@ -91,7 +91,6 @@
{Lang::T("Structure")} - {assign dtipe value="dashboard_`$tipeUser`"}
diff --git a/ui/ui/admin/settings/widgets_add_edit.tpl b/ui/ui/admin/settings/widgets_add_edit.tpl index 88683740..16b75166 100644 --- a/ui/ui/admin/settings/widgets_add_edit.tpl +++ b/ui/ui/admin/settings/widgets_add_edit.tpl @@ -52,12 +52,10 @@
- +

 

@@ -66,10 +64,12 @@
@@ -79,14 +79,17 @@
- -

{Lang::T("Not all widgets require content. HTML widgets require content, either text or PHP code. Please be careful when writing this content.")}

+ +

+ {Lang::T("Not all widgets require content. HTML widgets require content, either text or PHP code. Please be careful when writing this content.")} +

{if $do == 'edit'} - {Lang::T('Delete')} {/if}
@@ -102,7 +105,7 @@ -{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file