소스 검색

#3958 - Attendant app enhancement

roman.lesnikov@gmail.com 4 년 전
부모
커밋
4a7d2375a9

+ 47 - 3
modules/boonex/attendant/classes/BxAttendantModule.php

@@ -19,13 +19,12 @@ class BxAttendantModule extends BxDolModule
         parent::__construct($aModule);
     }
 
-    public function actionRecomendedPopup($sModule, $sEvent, $iObjectId)
+    public function actionRecomendedPopup($sModule, $sEvent, $iObjectId, $bManual)
     {
         $sRv = '';
         $aModules = explode(',', getParam('bx_attendant_on_profile_creation_modules'));
         $aModuleData = array();
         foreach($aModules as $sModuleName){
-
             if(BxDolRequest::serviceExists($sModuleName, BX_ATTENDANT_ON_PROFILE_CREATION_METHOD)){
                 $aTmp = BxDolService::call($sModuleName, BX_ATTENDANT_ON_PROFILE_CREATION_METHOD, ['unit_view' => 'showcase', 'empty_message' => false, "ajax_paginate" => false]);
 
@@ -36,7 +35,52 @@ class BxAttendantModule extends BxDolModule
                 }
             }
         }
-        $sRv = $this->_oTemplate->popup($aModuleData);
+        $bRedirect = true; // todo setting
+        
+        $oSession = BxDolSession::getInstance();
+        $sFirstPage = $oSession->getValue('sys_entrance_url');
+        $sFirstPage = 'page.php?i=view-group-profile&id=72';
+       
+        if ($sFirstPage){
+            if ($bRedirect){
+                echo json_encode(['redirect' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($sFirstPage)]);  
+                exit();
+            }
+            else{
+                list($sPageLink, $aPageParams) = bx_get_base_url($sFirstPage);
+                if (isset($aPageParams['i']) && isset($aPageParams['id'])){
+                    $oPage = BxDolPage::getObjectInstanceByURI($aPageParams['i']);
+
+                    if ($oPage){
+                        $sModuleName = $oPage->getModule();
+                        if(bx_srv('system', 'is_module_context', [$sModuleName])){
+
+                            $oModule = BxDolModule::getInstance($sModuleName);
+                            $aTmp = $oModule->serviceBrowse([
+                                'mode' => 'recent',
+                                'params' => [
+                                    'filter' => [
+                                        'field' => 'id',
+                                        'value' => [$aPageParams['id']],
+                                        'operator' => 'in',
+                                        'table' => 'tableSearch'
+                                    ],
+                                ]
+                            ]);
+                            echo $aPageParams['id'];
+                            print_r($aTmp);
+                            if (isset($aTmp['content'])){
+                                $sTmp = $aTmp['content'];
+                                $sTmp = str_replace('bx_conn_action', 'bx_attendant_conn_action', $sTmp);
+                                $aModuleData[$sModuleName. '_initial_link'] = $sTmp;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        
+        $sRv = $this->_oTemplate->popup($aModuleData, $bManual);
         
         bx_alert('bx_attendant', 'show_popup', bx_get_logged_profile_id(), 0, ['module' => $sModule, 'event' => $sEvent, 'object_id' => $iObjectId, 'result' => &$sRv]);
         

+ 21 - 15
modules/boonex/attendant/classes/BxAttendantTemplate.php

@@ -37,7 +37,7 @@ class BxAttendantTemplate extends BxBaseModGeneralTemplate
         return $this->getJsCode('main') . BxBaseFunctions::getInstance()->transBox($this->sContainerId, '', true, true);
     }
     
-    public function popup($aModuleData)
+    public function popup($aModuleData, $bManual)
     {
         $aVars = [];
         
@@ -49,21 +49,26 @@ class BxAttendantTemplate extends BxBaseModGeneralTemplate
            ];
         }
         
-        return $this->parseHtmlByName('popup_recommended.html', [
-                'bx_if:data' => [
-                    'condition' => count($aVars) > 0,
-                    'content' => [
-                        'bx_repeat:items' => $aVars, 
-                        'button_text' => _t('_bx_attendant_popup_with_recommended_button_text')
-                    ]
-                ],
-                'bx_if:nodata' => [
-                    'condition' => count($aVars) == 0,
-                    'content' => [
+        if ($bManual || count($aVars) >0){
+            return $this->parseHtmlByName('popup_recommended.html', [
+                    'bx_if:data' => [
+                        'condition' => count($aVars) > 0,
+                        'content' => [
+                            'bx_repeat:items' => $aVars, 
+                            'button_text' => _t('_bx_attendant_popup_with_recommended_button_text')
+                        ]
+                    ],
+                    'bx_if:nodata' => [
+                        'condition' => count($aVars) == 0,
+                        'content' => [
+                        ]
                     ]
                 ]
-            ]
-        );
+            );
+        }
+        else{
+            return '';
+        }
     }
     
     public function getJsCode($sType, $aParams = array(), $bWrap = true)
@@ -103,7 +108,8 @@ class BxAttendantTemplate extends BxBaseModGeneralTemplate
         $sValue = _t($sFullKey);
         if ($sValue == $sFullKey){
             $oModule = BxDolModule::getInstance($sModuleName);
-            $sValue =_t($sKey . 'default', $oModule->_aModule['title']);
+            if ($oModule)
+                $sValue =_t($sKey . 'default', $oModule->_aModule['title']);
         }
         return $sValue;
     }

+ 1 - 1
modules/boonex/attendant/install/sql/enable.sql

@@ -32,4 +32,4 @@ INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 -- MENU: notifications
 SET @iMIOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_account_notifications' AND `order` < 9999);
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES
-('sys_account_notifications', @sName, 'notifications-attendant', '_bx_attendant_menu_item_title_system_attendant', '_bx_attendant_menu_item_title_attendant', 'javascript:', 'oBxAttendant.showPopup()', '', 'fab buffer', '', '', 2147483646, 1, 0, @iMIOrder + 1);
+('sys_account_notifications', @sName, 'notifications-attendant', '_bx_attendant_menu_item_title_system_attendant', '_bx_attendant_menu_item_title_attendant', 'javascript:', 'oBxAttendant.showPopup(1)', '', 'fab buffer', '', '', 2147483646, 1, 0, @iMIOrder + 1);

+ 30 - 20
modules/boonex/attendant/js/main.js

@@ -15,29 +15,39 @@ function BxAttendant(oOptions) {
     var $this = this;
 }
 
-BxAttendant.prototype.showPopup = function (sModule = 'default', sEvent = 'default', sObject = 0) {
+BxAttendant.prototype.showPopup = function (bManual = 0, sModule = 'default', sEvent = 'default', sObject = 0) {
     var $this = this;
     
-    $(window).dolPopupAjax({
-        url: $this._sActionsUri + 'RecomendedPopup/' + sModule + '/' + sEvent + '/' + sObject + '/',
-        closeOnOuterClick: true,
-		removeOnClose: true,
-        onLoad: function(sPopupSelector){
-            $(sPopupSelector + ' .bx-pwropa-item-container').hide().first().show();
-            $this.reInitFlickity(sPopupSelector);
-            $(sPopupSelector + ' .bx-pwropa-button').click(function () {
-                $oCurr = $(sPopupSelector + ' .bx-pwropa-item-container:visible').hide();
-                $oNext = $oCurr.next(); 
-                $oNext.show();
-                $this.reInitFlickity(sPopupSelector);
-                if ($oNext.length == 0) {
-                    $(sPopupSelector).dolPopupHide();
-                    if ($this._sUrlAfterShow != '') {
-                        location.href = $this._sUrlAfterShow;
+    $.get($this._sActionsUri + 'RecomendedPopup/' + sModule + '/' + sEvent + '/' + sObject + '/' + bManual + '/', function (sData) {
+        if (sData != ''){
+            oData = $.parseJSON(sData);
+            if (oData.redirect){
+                window.location = oData.redirect;
+            }
+            else{
+                $(window).dolPopupAjax({
+                    url: $this._sActionsUri + 'RecomendedPopup/' + sModule + '/' + sEvent + '/' + sObject + '/' + bManual + '/',
+                    closeOnOuterClick: true,
+                    removeOnClose: true,
+                    onLoad: function(sPopupSelector){
+                        $(sPopupSelector + ' .bx-pwropa-item-container').hide().first().show();
+                            $this.reInitFlickity(sPopupSelector);
+                            $(sPopupSelector + ' .bx-pwropa-button').click(function () {
+                                $oCurr = $(sPopupSelector + ' .bx-pwropa-item-container:visible').hide();
+                                $oNext = $oCurr.next(); 
+                                $oNext.show();
+                                $this.reInitFlickity(sPopupSelector);
+                                if ($oNext.length == 0) {
+                                    $(sPopupSelector).dolPopupHide();
+                                    if ($this._sUrlAfterShow != '') {
+                                        location.href = $this._sUrlAfterShow;
+                                    }
+                                }
+                            });
+
                     }
-                }
-            });
-            
+                });
+            }
         }
     });
 }

+ 1 - 1
modules/boonex/attendant/template/popup_recommended.html

@@ -14,7 +14,7 @@
         </div>
     </bx_if:data>
     <bx_if:nodata>
-        <div class="bx-pwropa-item-container">
+        <div class="bx-pwropa-item-container bx-pwropa-item-container-no-data">
             <div class="bx-db-title bx-def-font-h2"><bx_text:_bx_attendant_popup_with_recommended_title_no_data /></div>
             <div class="bx-tl-content bx-def-margin-bottom"><bx_text:_bx_attendant_popup_with_recommended_description_no_data /></div>
         </div>