Просмотр исходного кода

Ticket #4113 - Credits: Improvements: Points 1-2.

AntonLV 4 лет назад
Родитель
Сommit
7a0f56527b

+ 6 - 0
modules/boonex/credits/classes/BxCreditsConfig.php

@@ -83,6 +83,8 @@ class BxCreditsConfig extends BxBaseModGeneralConfig
             'OBJECT_FORM_BUNDLE' => 'bx_credits_bundle',
             'OBJECT_FORM_BUNDLE_DISPLAY_ADD' => 'bx_credits_bundle_add',
             'OBJECT_FORM_BUNDLE_DISPLAY_EDIT' => 'bx_credits_bundle_edit',
+            'OBJECT_FORM_PROFILE' => 'bx_credits_profile',
+            'OBJECT_FORM_PROFILE_DISPLAY_EDIT' => 'bx_credits_profile_edit',
             'OBJECT_MENU_SUBMENU' => 'bx_credits_submenu', 
             'OBJECT_MENU_MANAGE_SUBMENU' => 'bx_credits_manage_submenu',
             'OBJECT_GRID_BUNDLES' => 'bx_credits_bundles',
@@ -90,6 +92,7 @@ class BxCreditsConfig extends BxBaseModGeneralConfig
             'OBJECT_GRID_ORDERS_COMMON' => 'bx_credits_orders_common',
             'OBJECT_GRID_HISTORY_ADMINISTRATION' => 'bx_credits_history_administration',
             'OBJECT_GRID_HISTORY_COMMON' => 'bx_credits_history_common',
+            'OBJECT_GRID_PROFILES_ADMINISTRATION' => 'bx_credits_profiles_administration',
 
             // email templates
             'ETEMPLATE_GRANTED' => 'bx_credits_granted',
@@ -137,6 +140,8 @@ class BxCreditsConfig extends BxBaseModGeneralConfig
             'withdraw_field_amount' => $sPrefix . '-wff-amount',
             'withdraw_field_result' => $sPrefix . '-wff-result',
 
+            'edit_profile_popup' =>  $sPrefix . '-edit-profile-popup',
+
             'subscribe_popup' =>  $sPrefix . '-subscribe-popup',
         );
 
@@ -207,6 +212,7 @@ class BxCreditsConfig extends BxBaseModGeneralConfig
         return [
             BX_CREDITS_TRANSFER_TYPE_CHECKOUT,
             BX_CREDITS_TRANSFER_TYPE_SEND,
+            BX_CREDITS_TRANSFER_TYPE_WITHDRAW,
             BX_CREDITS_TRANSFER_TYPE_SERVICE
         ];
     }

+ 2 - 1
modules/boonex/credits/classes/BxCreditsDb.php

@@ -350,7 +350,8 @@ class BxCreditsDb extends BxBaseModGeneralDb
                     'clearing' => $aParams['clearing']
                 ];
 
-                $sWhereClause = " AND `th`.`direction`='in' AND `th`.`type` IN (" . $this->implode_escape($this->_oConfig->getTransferTypesForClearing()) . ") AND `th`.`date` < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL :clearing DAY)) AND `th`.`cleared`='0'";
+                $sJoinClause = " LEFT JOIN `" . $CNF['TABLE_PROFILES'] . "` AS `tp` ON `th`.`first_pid`=`tp`.`id`";
+                $sWhereClause = " AND `th`.`direction`='in' AND `th`.`type` IN (" . $this->implode_escape($this->_oConfig->getTransferTypesForClearing()) . ") AND `th`.`date` < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL IF(`tp`.`wdw_clearing` <> 0, `tp`.`wdw_clearing`, :clearing) DAY)) AND `th`.`cleared`='0'";
                 break;
         }
 

+ 29 - 0
modules/boonex/credits/classes/BxCreditsFormProfile.php

@@ -0,0 +1,29 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Credits Credits
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+/**
+ * Add/Edit profile form
+ */
+class BxCreditsFormProfile extends BxTemplStudioFormView
+{
+    protected $_sModule;
+    protected $_oModule;
+
+    public function __construct($aInfo, $oTemplate = false)
+    {
+        $this->_sModule = 'bx_credits';
+        $this->_oModule = BxDolModule::getInstance($this->_sModule);
+
+        parent::__construct($aInfo, $oTemplate);
+    }
+}
+
+/** @} */

+ 6 - 3
modules/boonex/credits/classes/BxCreditsGridHistoryAdministration.php

@@ -110,9 +110,12 @@ class BxCreditsGridHistoryAdministration extends BxTemplGrid
 
         if($aRow[$CNF['FIELD_H_DIRECTION']] == BX_CREDITS_DIRECTION_IN) {
             if(empty($mixedValue)) {
-                $iPeriod = $this->_oModule->_oConfig->getWithdrawClearing();
-                if($iPeriod == 0)
-                    $iPeriod = 1;
+                $iPeriod = (int)$aRow['wdw_clearing'];
+                if($iPeriod == 0) {
+                    $iPeriod = $this->_oModule->_oConfig->getWithdrawClearing();
+                    if($iPeriod == 0)
+                        $iPeriod = 1;
+                }
 
                 $oDate = date_create('@' . $aRow[$CNF['FIELD_H_DATE']]);
                 date_add($oDate, new DateInterval('P' . $iPeriod . 'D'));

+ 101 - 0
modules/boonex/credits/classes/BxCreditsGridProfilesAdministration.php

@@ -0,0 +1,101 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Credits Credits
+ * @ingroup     UnaModules
+ * 
+ * @{
+ */
+
+class BxCreditsGridProfilesAdministration extends BxTemplGrid
+{
+    protected $_sModule;
+    protected $_oModule;
+
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+    	$this->_sModule = 'bx_credits';
+    	$this->_oModule = BxDolModule::getInstance($this->_sModule);
+    	if(!$oTemplate)
+            $oTemplate = $this->_oModule->_oTemplate;
+
+        parent::__construct ($aOptions, $oTemplate);
+    }
+
+    public function performActionEdit()
+    {
+        $sAction = 'edit';
+
+        $aIds = bx_get('ids');
+        if(!$aIds || !is_array($aIds)) {
+            $iId = (int)bx_get('id');
+            if(!$iId)
+                return false;
+
+            $aIds = [$iId];
+        }
+
+        $iId = $aIds[0];
+
+        $aProfile = $this->_oModule->_oDb->getProfile(['type' => 'id', 'id' => $iId]);
+        if(empty($aProfile) || !is_array($aProfile))
+            return echoJson([]);
+
+        $oForm = $this->_getFormObject($sAction, $aProfile);
+        $oForm->initChecker($aProfile);
+
+        if($oForm->isSubmittedAndValid()) {
+            if($oForm->update($iId) !== false)
+                $aRes = ['grid' => $this->getCode(false), 'blink' => $iId];
+            else
+                $aRes = ['msg' => _t('_bx_credits_txt_err_cannot_perform_action')];
+
+            echoJson($aRes);
+        }
+        else {
+            $sContent = BxTemplFunctions::getInstance()->popupBox($this->_oModule->_oConfig->getHtmlIds('edit_profile_popup'), _t('_bx_credits_grid_popup_title_pfl_edit', BxDolProfile::getInstanceMagic($aProfile['id'])->getDisplayName()), $this->_oModule->_oTemplate->parseHtmlByName('profile_form.html', [
+                'form_id' => $oForm->aFormAttrs['id'],
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            ]));
+
+            echoJson(['popup' => ['html' => $sContent, 'options' => ['closeOnOuterClick' => false, 'removeOnClose' => true]]]);
+        }
+    }
+
+    protected function _getFormObject($sAction, $aProfile = array())
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_PROFILE'], $CNF['OBJECT_FORM_PROFILE_DISPLAY_' . strtoupper($sAction)]);
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
+        if(!empty($aProfile['id']))
+            $oForm->aFormAttrs['action'] .= '&id=' . $aProfile['id'];
+
+        return $oForm;
+    }
+
+    protected function _getCellId($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault($this->_getProfile($mixedValue), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellBalanceCleared($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault($this->_oModule->getProfileBalanceCleared($aRow['id']), $sKey, $aField, $aRow);
+    }
+
+    protected function _getProfile($mixedValue) 
+    {
+        $oProfile = BxDolProfile::getInstanceMagic($mixedValue);
+        if(!$oProfile)
+            return $mixedValue;
+
+        return $oProfile->getUnit(0, ['template' => ['name' => 'unit', 'size' => 'icon']]);
+    }
+}
+
+/** @} */

+ 53 - 8
modules/boonex/credits/classes/BxCreditsModule.php

@@ -319,7 +319,7 @@ class BxCreditsModule extends BxBaseModGeneralModule
      * @page service Service Calls
      * @section bx_credits Credits
      * @subsection bx_credits-page_blocks Page Blocks
-     * @subsubsection bx_credits-block_orders get_block_orders
+     * @subsubsection bx_credits-get_block_orders get_block_orders
      * 
      * @code bx_srv('bx_credits', 'get_block_orders', [...]); @endcode
      * 
@@ -327,7 +327,7 @@ class BxCreditsModule extends BxBaseModGeneralModule
      *
      * @return an array describing a block to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
      * 
-     * @see BxCreditsModule::serviceBlockLicenses
+     * @see BxCreditsModule::serviceGetBlockOrders
      */
     /** 
      * @ref bx_credits-get_block_orders "get_block_orders"
@@ -359,6 +359,28 @@ class BxCreditsModule extends BxBaseModGeneralModule
         return $this->_getBlockHistory($sType);
     }
 
+    /**
+     * @page service Service Calls
+     * @section bx_credits Credits
+     * @subsection bx_credits-page_blocks Page Blocks
+     * @subsubsection bx_credits-get_block_profiles get_block_profiles
+     * 
+     * @code bx_srv('bx_credits', 'get_block_profiles', [...]); @endcode
+     * 
+     * Get page block with a list of profiles for managing their parameters.
+     *
+     * @return an array describing a block to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
+     * 
+     * @see BxCreditsModule::serviceGetBlockProfiles
+     */
+    /** 
+     * @ref bx_credits-get_block_profiles "get_block_profiles"
+     */
+    public function serviceGetBlockProfiles($sType = 'common') 
+    {
+        return $this->_getBlockProfiles($sType);
+    }
+
     /**
      * @page service Service Calls
      * @section bx_credits Credits
@@ -895,11 +917,15 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if($fAmount > $fBalanceCleared)
             return ['code' => 2, 'msg' => '_bx_credits_err_low_balance'];
 
-        if($fAmount < ($iWithdrawMinimum = (int)getParam($CNF['PARAM_WITHDRAW_MINIMUM'])))
+        $aProfileInfo = $this->_oDb->getProfile(['type' => 'id', 'id' => $iProfileId]);
+
+        $iWithdrawMinimum = !empty($aProfileInfo['wdw_minimum']) ? (int)$aProfileInfo['wdw_minimum'] : (int)getParam($CNF['PARAM_WITHDRAW_MINIMUM']);
+        if($fAmount < $iWithdrawMinimum)
             return ['code' => 3, 'msg' => _t('_bx_credits_err_withdraw_minimum', $iWithdrawMinimum)];
 
         $fBalance = $this->getProfileBalance($iProfileId);
-        if(($fBalance - $fAmount) < ($iWithdrawRemaining = (int)getParam($CNF['PARAM_WITHDRAW_REMAINING'])))
+        $iWithdrawRemaining = !empty($aProfileInfo['wdw_remaining']) ? (int)$aProfileInfo['wdw_remaining'] : (int)getParam($CNF['PARAM_WITHDRAW_REMAINING']);
+        if(($fBalance - $fAmount) < $iWithdrawRemaining)
             return ['code' => 4, 'msg' => _t('_bx_credits_err_withdraw_remaining', $iWithdrawRemaining)];
 
         $aResult = ['code' => 5, 'msg' => '_bx_credits_err_cannot_send'];
@@ -1082,10 +1108,10 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if(!$oGrid)
             return '';
 
-        return array(
+        return [
             'content' => $oGrid->getCode(),
             'menu' => $CNF['OBJECT_MENU_MANAGE_SUBMENU']
-        );
+        ];
     }
 
     protected function _getBlockHistory($sType) 
@@ -1097,10 +1123,29 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if(!$oGrid)
             return '';
 
-        return array(
+        return [
             'content' => $oGrid->getCode(),
             'menu' => $CNF['OBJECT_MENU_MANAGE_SUBMENU']
-        );
+        ];
+    }
+
+    protected function _getBlockProfiles($sType) 
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $sKey = 'OBJECT_GRID_PROFILES_' . strtoupper($sType);
+        if(empty($CNF[$sKey]))
+            return '';
+
+        $sGrid = $CNF[$sKey];
+        $oGrid = BxDolGrid::getObjectInstance($sGrid);
+        if(!$oGrid)
+            return '';
+
+        return [
+            'content' => $oGrid->getCode(),
+            'menu' => $CNF['OBJECT_MENU_MANAGE_SUBMENU']
+        ];
     }
 }
 

+ 35 - 0
modules/boonex/credits/classes/BxCreditsPageProfiles.php

@@ -0,0 +1,35 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Credits Credits
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+/**
+ * Profiles page.
+ */
+class BxCreditsPageProfiles extends BxTemplPage
+{
+    protected $_sModule;
+
+    public function __construct($aObject, $oTemplate = false)
+    {
+        $this->_sModule = 'bx_credits';
+
+        parent::__construct($aObject, $oTemplate);
+
+        $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
+        if($oMenuSubmenu) {
+            $sMenuSubmenu = 'sys_account_dashboard';
+            $oMenuSubmenu->setObjectSubmenu($sMenuSubmenu, ['title' => _t('_sys_menu_item_title_account_dashboard'), 'link' => '', 'icon' => '']);
+
+            BxDolMenu::getObjectInstance($sMenuSubmenu)->setSelected($this->_sModule, 'credits-manage');
+        }
+    }
+}
+
+/** @} */

+ 33 - 3
modules/boonex/credits/install/langs/en.xml

@@ -43,8 +43,8 @@
     <string name="_bx_credits_form_credit"><![CDATA[Credit]]></string>
     <string name="_bx_credits_form_credit_display_grant"><![CDATA[Grant]]></string>
     <string name="_bx_credits_form_credit_display_send"><![CDATA[Send]]></string>
-    <string name="_bx_credits_form_credit_display_withdraw_request"><![CDATA[Request Withdraw]]></string>
-    <string name="_bx_credits_form_credit_display_withdraw_confirm"><![CDATA[Confirm withdraw]]></string>
+    <string name="_bx_credits_form_credit_display_withdraw_request"><![CDATA[Request Withdrawal]]></string>
+    <string name="_bx_credits_form_credit_display_withdraw_confirm"><![CDATA[Confirm Withdrawal]]></string>
     <string name="_bx_credits_form_credit_input_sys_balance"><![CDATA[Balance]]></string>
     <string name="_bx_credits_form_credit_input_balance"><![CDATA[Balance]]></string>
     <string name="_bx_credits_form_credit_input_sys_cleared"><![CDATA[Cleared Balance]]></string>
@@ -68,6 +68,22 @@
     <string name="_bx_credits_form_credit_input_sys_do_cancel"><![CDATA[Cancel]]></string>
     <string name="_bx_credits_form_credit_input_do_cancel"><![CDATA[Cancel]]></string>
 
+    <string name="_bx_credits_form_profile"><![CDATA[Profile]]></string>
+    <string name="_bx_credits_form_profile_display_edit"><![CDATA[Edit Profile]]></string>
+    <string name="_bx_credits_form_profile_input_sys_wdw_clearing"><![CDATA[Clearing period]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_clearing"><![CDATA[Clearing period (in days)]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_clearing_inf"><![CDATA[Leave empty (0) to use global value]]></string>
+    <string name="_bx_credits_form_profile_input_sys_wdw_minimum"><![CDATA[Minimum withdrawal amount]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_minimum"><![CDATA[Minimum withdrawal amount]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_minimum_inf"><![CDATA[Leave empty (0) to use global value]]></string>
+    <string name="_bx_credits_form_profile_input_sys_wdw_remaining"><![CDATA[Minimum remaining amount]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_remaining"><![CDATA[Minimum remaining amount]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_remaining_inf"><![CDATA[Leave empty (0) to use global value]]></string>
+    <string name="_bx_credits_form_profile_input_sys_do_submit"><![CDATA[Submit]]></string>
+    <string name="_bx_credits_form_profile_input_do_submit"><![CDATA[Submit]]></string>
+    <string name="_bx_credits_form_profile_input_sys_do_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_credits_form_profile_input_do_cancel"><![CDATA[Cancel]]></string>
+
 
     <!-- Pages -->
     <string name="_bx_credits_page_title_sys_home"><![CDATA[Credits]]></string>
@@ -97,6 +113,10 @@
     <string name="_bx_credits_page_title_orders_administration"><![CDATA[Orders]]></string>
     <string name="_bx_credits_page_block_title_sys_orders_administration"><![CDATA[All Orders]]></string>
     <string name="_bx_credits_page_block_title_orders_administration"><![CDATA[Orders]]></string>
+    <string name="_bx_credits_page_title_sys_profiles_administration"><![CDATA[All Profiles]]></string>
+    <string name="_bx_credits_page_title_profiles_administration"><![CDATA[Profiles]]></string>
+    <string name="_bx_credits_page_block_title_sys_profiles_administration"><![CDATA[All Profiles]]></string>
+    <string name="_bx_credits_page_block_title_profiles_administration"><![CDATA[Profiles]]></string>
 
 
     <!-- Menus -->
@@ -125,6 +145,8 @@
     <string name="_bx_credits_menu_item_title_history_administration"><![CDATA[All History]]></string>
     <string name="_bx_credits_menu_item_title_system_history_common"><![CDATA[My History]]></string>
     <string name="_bx_credits_menu_item_title_history_common"><![CDATA[My History]]></string>
+    <string name="_bx_credits_menu_item_title_system_profiles_administration"><![CDATA[All Profiles]]></string>
+    <string name="_bx_credits_menu_item_title_profiles_administration"><![CDATA[All Profiles]]></string>
 
 
     <!-- Grids -->
@@ -166,6 +188,14 @@
     <string name="_bx_credits_grid_column_title_ord_added"><![CDATA[Added]]></string>
     <string name="_bx_credits_grid_column_title_ord_expired"><![CDATA[Expires]]></string>
 
+    <string name="_bx_credits_grid_column_title_pfl_id"><![CDATA[Profile]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_wdw_clearing"><![CDATA[Clearing period (in days)]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_wdw_minimum"><![CDATA[Min withdrawal amount]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_wdw_remaining"><![CDATA[Min remaining amount]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_balance"><![CDATA[Balance]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_balance_cleared"><![CDATA[Cleared balance]]></string>
+    <string name="_bx_credits_grid_action_title_pfl_edit"><![CDATA[Edit]]></string>
+    <string name="_bx_credits_grid_popup_title_pfl_edit"><![CDATA[Edit '{0}' Profile's Limitations]]></string>
 
     <!-- Email templates -->
     <string name="_bx_credits_et_txt_name_granted"><![CDATA[Credits granted.]]></string>
@@ -232,7 +262,7 @@
     <string name="_bx_credits_txt_history_info_send"><![CDATA[Transfer]]></string>
     <string name="_bx_credits_txt_history_info_purchase"><![CDATA[Bundle purchase]]></string>
     <string name="_bx_credits_txt_history_info_checkout"><![CDATA[Profile to profile checkout]]></string>
-    <string name="_bx_credits_txt_history_info_withdraw"><![CDATA[Withdraw by request]]></string>
+    <string name="_bx_credits_txt_history_info_withdraw"><![CDATA[Withdrawal by request]]></string>
     <string name="_bx_credits_txt_history_info_service"><![CDATA[Artificially initiated transfer]]></string>
     <string name="_bx_credits_txt_history_info_refund"><![CDATA[Refund]]></string>
     <string name="_bx_credits_txt_history_info_cancellation"><![CDATA[Cancellation]]></string>

+ 29 - 5
modules/boonex/credits/install/sql/enable.sql

@@ -55,20 +55,27 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 ('bx_credits_orders_administration', 1, 'bx_credits', '_bx_credits_page_block_title_sys_orders_administration', '_bx_credits_page_block_title_orders_administration', 11, 192, 'service', 'a:3:{s:6:"module";s:10:"bx_credits";s:6:"method";s:16:"get_block_orders";s:6:"params";a:1:{i:0;s:14:"administration";}}', 0, 0, 1, 0);
 
--- PAGE: module manage own
+-- PAGE: profile's history
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_credits_history_common', '_bx_credits_page_title_sys_history_common', '_bx_credits_page_title_history_common', 'bx_credits', 5, 2147483647, 1, 'credits-history-common', 'page.php?i=credits-history-common', '', '', '', 0, 1, 0, 'BxCreditsPageHistory', 'modules/boonex/credits/classes/BxCreditsPageHistory.php');
 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
 ('bx_credits_history_common', 1, 'bx_credits', '_bx_credits_page_block_title_sys_history_common', '_bx_credits_page_block_title_history_common', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:10:"bx_credits";s:6:"method";s:17:"get_block_history";}}', 0, 1, 0);
 
--- PAGE: module manage all
+-- PAGE: history administration
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_credits_history_administration', '_bx_credits_page_title_sys_history_administration', '_bx_credits_page_title_history_administration', 'bx_credits', 5, 192, 1, 'credits-history-administration', 'page.php?i=credits-history-administration', '', '', '', 0, 1, 0, 'BxCreditsPageHistory', 'modules/boonex/credits/classes/BxCreditsPageHistory.php');
 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
 ('bx_credits_history_administration', 1, 'bx_credits', '_bx_credits_page_block_title_sys_history_administration', '_bx_credits_page_block_title_history_administration', 11, 192, 'service', 'a:3:{s:6:"module";s:10:"bx_credits";s:6:"method";s:17:"get_block_history";s:6:"params";a:1:{i:0;s:14:"administration";}}', 0, 1, 0);
 
+-- PAGE: profiles administration
+INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
+('bx_credits_profiles_administration', '_bx_credits_page_title_sys_profiles_administration', '_bx_credits_page_title_profiles_administration', 'bx_credits', 5, 192, 1, 'credits-profiles-administration', 'page.php?i=credits-profiles-administration', '', '', '', 0, 1, 0, 'BxCreditsPageProfiles', 'modules/boonex/credits/classes/BxCreditsPageProfiles.php');
+
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
+('bx_credits_profiles_administration', 1, 'bx_credits', '_bx_credits_page_block_title_sys_profiles_administration', '_bx_credits_page_block_title_profiles_administration', 11, 192, 'service', 'a:3:{s:6:"module";s:10:"bx_credits";s:6:"method";s:18:"get_block_profiles";s:6:"params";a:1:{i:0;s:14:"administration";}}', 0, 1, 0);
+
 
 -- MENU: add to site menu
 SET @iSiteMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_site' AND `active` = 1 AND `order` < 9999 ORDER BY `order` DESC LIMIT 1);
@@ -116,7 +123,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_credits_manage_submenu', 'bx_credits', 'credits-history-common', '_bx_credits_menu_item_title_system_history_common', '_bx_credits_menu_item_title_history_common', 'page.php?i=credits-history-common', '', '_self', '', '', '', 2147483646, 1, 0, 1, 1),
 ('bx_credits_manage_submenu', 'bx_credits', 'credits-history-administration', '_bx_credits_menu_item_title_system_history_administration', '_bx_credits_menu_item_title_history_administration', 'page.php?i=credits-history-administration', '', '_self', '', '', '', 192, 1, 0, 1, 2),
 ('bx_credits_manage_submenu', 'bx_credits', 'credits-orders-common', '_bx_credits_menu_item_title_system_orders_common', '_bx_credits_menu_item_title_orders_common', 'page.php?i=credits-orders-common', '', '_self', '', '', '', 2147483646, 1, 0, 1, 3),
-('bx_credits_manage_submenu', 'bx_credits', 'credits-orders-administration', '_bx_credits_menu_item_title_system_orders_administration', '_bx_credits_menu_item_title_orders_administration', 'page.php?i=credits-orders-administration', '', '_self', '', '', '', 192, 1, 0, 1, 4);
+('bx_credits_manage_submenu', 'bx_credits', 'credits-orders-administration', '_bx_credits_menu_item_title_system_orders_administration', '_bx_credits_menu_item_title_orders_administration', 'page.php?i=credits-orders-administration', '', '_self', '', '', '', 192, 1, 0, 1, 4),
+('bx_credits_manage_submenu', 'bx_credits', 'credits-profiles-administration', '_bx_credits_menu_item_title_system_profiles_administration', '_bx_credits_menu_item_title_profiles_administration', 'page.php?i=credits-profiles-administration', '', '_self', '', '', '', 192, 1, 0, 1, 5);
 
 -- MENU: dashboard manage tools
 SET @iManageMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name`='sys_account_dashboard_manage_tools' LIMIT 1);
@@ -165,8 +173,8 @@ INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable
 
 -- GRIDS: history
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
-('bx_credits_history_administration', 'Sql', 'SELECT * FROM `bx_credits_history` WHERE 1 ', 'bx_credits_history', 'id', 'date', '', '', 20, NULL, 'start', '', 'direction,order,info', '', 'like', '', '', 192, 'BxCreditsGridHistoryAdministration', 'modules/boonex/credits/classes/BxCreditsGridHistoryAdministration.php'),
-('bx_credits_history_common', 'Sql', 'SELECT * FROM `bx_credits_history` WHERE 1 ', 'bx_credits_history', 'id', 'date', '', '', 20, NULL, 'start', '', 'direction,order,info', '', 'like', '', '', 2147483647, 'BxCreditsGridHistoryCommon', 'modules/boonex/credits/classes/BxCreditsGridHistoryCommon.php');
+('bx_credits_history_administration', 'Sql', 'SELECT `th`.*, `tp`.`wdw_clearing` FROM `bx_credits_history` AS `th` LEFT JOIN `bx_credits_profiles` AS `tp` ON `th`.`first_pid`=`tp`.`id` WHERE 1 ', 'bx_credits_history', 'id', 'date', '', '', 20, NULL, 'start', '', 'th`.`direction,th`.`order,th`.`info', '', 'like', '', '', 192, 'BxCreditsGridHistoryAdministration', 'modules/boonex/credits/classes/BxCreditsGridHistoryAdministration.php'),
+('bx_credits_history_common', 'Sql', 'SELECT `th`.*, `tp`.`wdw_clearing` FROM `bx_credits_history` AS `th` LEFT JOIN `bx_credits_profiles` AS `tp` ON `th`.`first_pid`=`tp`.`id` WHERE 1 ', 'bx_credits_history', 'id', 'date', '', '', 20, NULL, 'start', '', 'th`.`direction,th`.`order,th`.`info', '', 'like', '', '', 2147483647, 'BxCreditsGridHistoryCommon', 'modules/boonex/credits/classes/BxCreditsGridHistoryCommon.php');
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
 ('bx_credits_history_administration', 'first_pid', '_bx_credits_grid_column_title_htr_first_pid', '15%', 0, '', '', 1),
@@ -193,6 +201,22 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon
 ('bx_credits_history_common', 'independent', 'send', '_bx_credits_grid_action_title_htr_send', '', 0, 0, 1),
 ('bx_credits_history_common', 'independent', 'withdraw_request', '_bx_credits_grid_action_title_htr_withdraw_request', '', 0, 0, 2);
 
+-- GRIDS: profiles
+INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
+('bx_credits_profiles_administration', 'Sql', 'SELECT * FROM `bx_credits_profiles` WHERE 1 ', 'bx_credits_profiles', 'id', '', '', '', 20, NULL, 'start', '', '', '', 'like', '', '', 192, 'BxCreditsGridProfilesAdministration', 'modules/boonex/credits/classes/BxCreditsGridProfilesAdministration.php');
+
+INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
+('bx_credits_profiles_administration', 'id', '_bx_credits_grid_column_title_pfl_id', '40%', 0, '', '', 1),
+('bx_credits_profiles_administration', 'wdw_clearing', '_bx_credits_grid_column_title_pfl_wdw_clearing', '10%', 0, '', '', 2),
+('bx_credits_profiles_administration', 'wdw_minimum', '_bx_credits_grid_column_title_pfl_wdw_minimum', '10%', 0, '', '', 3),
+('bx_credits_profiles_administration', 'wdw_remaining', '_bx_credits_grid_column_title_pfl_wdw_remaining', '10%', 0, '', '', 4),
+('bx_credits_profiles_administration', 'balance', '_bx_credits_grid_column_title_pfl_balance', '15%', 0, '', '', 5),
+('bx_credits_profiles_administration', 'balance_cleared', '_bx_credits_grid_column_title_pfl_balance_cleared', '15%', 0, '', '', 6),
+('bx_credits_profiles_administration', 'actions', '', '20%', 0, '', '', 7);
+
+INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES
+('bx_credits_profiles_administration', 'single', 'edit', '_bx_credits_grid_action_title_pfl_edit', 'pencil-alt', 1, 0, 1);
+
 
 -- ALERTS
 INSERT INTO `sys_alerts_handlers` (`name`, `class`, `file`, `service_call`) VALUES 

+ 27 - 1
modules/boonex/credits/install/sql/install.sql

@@ -50,6 +50,9 @@ CREATE TABLE IF NOT EXISTS `bx_credits_orders_deleted` (
 -- TABLE: profiles
 CREATE TABLE IF NOT EXISTS `bx_credits_profiles` (
   `id` int(11) NOT NULL DEFAULT '0',
+  `wdw_clearing` int(11) unsigned NOT NULL default '0',
+  `wdw_minimum` int(11) unsigned NOT NULL default '0',
+  `wdw_remaining` int(11) unsigned NOT NULL default '0',
   `balance` float NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`)
 );
@@ -127,7 +130,7 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 
 -- FORMS: bundle
 INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
-('bx_credits_bundle', 'bx_credits', '_bx_credits_form_bundle', '', 'a:1:{s:7:"enctype";s:19:"multipart/form-data";}', 'bx_credits_bundles', 'id', '', '', 'a:1:{i:0;s:9:"do_submit";}', '', 0, 1, 'BxCreditsFormBundle', 'modules/boonex/credits/classes/BxCreditsFormBundle.php');
+('bx_credits_bundle', 'bx_credits', '_bx_credits_form_profile', '', 'a:1:{s:7:"enctype";s:19:"multipart/form-data";}', 'bx_credits_bundles', 'id', '', '', 'a:1:{i:0;s:9:"do_submit";}', '', 0, 1, 'BxCreditsFormBundle', 'modules/boonex/credits/classes/BxCreditsFormBundle.php');
 
 INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`, `title`) VALUES 
 ('bx_credits_bundle', 'bx_credits_bundle_add', 'bx_credits', 0, '_bx_credits_form_bundle_display_add'),
@@ -162,6 +165,29 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_credits_bundle_edit', 'do_submit', 2147483647, 1, 7),
 ('bx_credits_bundle_edit', 'do_cancel', 2147483647, 1, 8);
 
+-- FORMS: profile
+INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
+('bx_credits_profile', 'bx_credits', '_bx_credits_form_profile', '', 'a:1:{s:7:"enctype";s:19:"multipart/form-data";}', 'bx_credits_profiles', 'id', '', '', 'a:1:{i:0;s:9:"do_submit";}', '', 0, 1, 'BxCreditsFormProfile', 'modules/boonex/credits/classes/BxCreditsFormProfile.php');
+
+INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`, `title`) VALUES 
+('bx_credits_profile', 'bx_credits_profile_edit', 'bx_credits', 0, '_bx_credits_form_profile_display_edit');
+
+INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES 
+('bx_credits_profile', 'bx_credits', 'wdw_clearing', '', '', 0, 'text', '_bx_credits_form_profile_input_sys_wdw_clearing', '_bx_credits_form_profile_input_wdw_clearing', '_bx_credits_form_profile_input_wdw_clearing_inf', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
+('bx_credits_profile', 'bx_credits', 'wdw_minimum', '', '', 0, 'text', '_bx_credits_form_profile_input_sys_wdw_minimum', '_bx_credits_form_profile_input_wdw_minimum', '_bx_credits_form_profile_input_wdw_minimum_inf', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
+('bx_credits_profile', 'bx_credits', 'wdw_remaining', '', '', 0, 'text', '_bx_credits_form_profile_input_sys_wdw_remaining', '_bx_credits_form_profile_input_wdw_remaining', '_bx_credits_form_profile_input_wdw_remaining_inf', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
+('bx_credits_profile', 'bx_credits', 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_credits_profile', 'bx_credits', 'do_submit', '_bx_credits_form_profile_input_do_submit', '', 0, 'submit', '_bx_credits_form_profile_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_credits_profile', 'bx_credits', 'do_cancel', '_bx_credits_form_profile_input_do_cancel', '', 0, 'button', '_bx_credits_form_bundle_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 1, 0);
+
+INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES 
+('bx_credits_profile_edit', 'wdw_clearing', 2147483647, 1, 1),
+('bx_credits_profile_edit', 'wdw_minimum', 2147483647, 1, 2),
+('bx_credits_profile_edit', 'wdw_remaining', 2147483647, 1, 3),
+('bx_credits_profile_edit', 'controls', 2147483647, 1, 4),
+('bx_credits_profile_edit', 'do_submit', 2147483647, 1, 5),
+('bx_credits_profile_edit', 'do_cancel', 2147483647, 1, 6);
+
 
 -- STUDIO: page & widget
 INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES

+ 1 - 1
modules/boonex/credits/template/bundle_form.html

@@ -1,4 +1,4 @@
-<div class="bx-credits-bundle-form bx-def-color-bg-block">
+<div class="bx-credits-bundle-form">
     <div class="bx-credits-bundle-form-cnt">
         __form__
         <script language="javascript">

+ 19 - 0
modules/boonex/credits/template/profile_form.html

@@ -0,0 +1,19 @@
+<div class="bx-credits-profile-form">
+    <div class="bx-credits-profile-form-cnt">
+        __form__
+        <script language="javascript">
+            $(document).ready(function () {
+                $("#__form_id__").ajaxForm({ 
+                    dataType: "json",
+                    beforeSubmit: function (formData, jqForm, options) {
+                        bx_loading($("#__form_id__"), true);
+                    },
+                    success: function (data) {
+                        $(".bx-popup-applied:visible").dolPopupHide();
+                        glGrids.__object__.processJson(data, '__action__');
+                    }
+                });
+            });
+        </script>
+    </div>
+</div>

+ 29 - 0
modules/boonex/russian/data/langs/bx_credits/ru.xml

@@ -68,6 +68,21 @@
     <string name="_bx_credits_form_credit_input_sys_do_cancel"><![CDATA[Отмена]]></string>
     <string name="_bx_credits_form_credit_input_do_cancel"><![CDATA[Отмена]]></string>
 
+    <string name="_bx_credits_form_profile"><![CDATA[Профиль]]></string>
+    <string name="_bx_credits_form_profile_display_edit"><![CDATA[Редактировать профиль]]></string>
+    <string name="_bx_credits_form_profile_input_sys_wdw_clearing"><![CDATA[Клиринговый период]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_clearing"><![CDATA[Клиринговый период (в днях)]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_clearing_inf"><![CDATA[Оставьте пустым (0), чтобы использовать глобальное значение]]></string>
+    <string name="_bx_credits_form_profile_input_sys_wdw_minimum"><![CDATA[Минимальная сумма вывода]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_minimum"><![CDATA[Минимальная сумма вывода]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_minimum_inf"><![CDATA[Оставьте пустым (0), чтобы использовать глобальное значение]]></string>
+    <string name="_bx_credits_form_profile_input_sys_wdw_remaining"><![CDATA[Минимальная оставшаяся сумма]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_remaining"><![CDATA[Минимальная оставшаяся сумма]]></string>
+    <string name="_bx_credits_form_profile_input_wdw_remaining_inf"><![CDATA[Оставьте пустым (0), чтобы использовать глобальное значение]]></string>
+    <string name="_bx_credits_form_profile_input_sys_do_submit"><![CDATA[Выполнить]]></string>
+    <string name="_bx_credits_form_profile_input_do_submit"><![CDATA[Выполнить]]></string>
+    <string name="_bx_credits_form_profile_input_sys_do_cancel"><![CDATA[Отмена]]></string>
+    <string name="_bx_credits_form_profile_input_do_cancel"><![CDATA[Отмена]]></string>
 
     <!-- Pages -->
     <string name="_bx_credits_page_title_sys_home"><![CDATA[Кредиты]]></string>
@@ -97,6 +112,10 @@
     <string name="_bx_credits_page_title_orders_administration"><![CDATA[Ордеры]]></string>
     <string name="_bx_credits_page_block_title_sys_orders_administration"><![CDATA[Все ордеры]]></string>
     <string name="_bx_credits_page_block_title_orders_administration"><![CDATA[Ордеры]]></string>
+    <string name="_bx_credits_page_title_sys_profiles_administration"><![CDATA[Все профили]]></string>
+    <string name="_bx_credits_page_title_profiles_administration"><![CDATA[Профили]]></string>
+    <string name="_bx_credits_page_block_title_sys_profiles_administration"><![CDATA[Все профили]]></string>
+    <string name="_bx_credits_page_block_title_profiles_administration"><![CDATA[Профили]]></string>
 
 
     <!-- Menus -->
@@ -125,6 +144,8 @@
     <string name="_bx_credits_menu_item_title_history_administration"><![CDATA[Вся история]]></string>
     <string name="_bx_credits_menu_item_title_system_history_common"><![CDATA[Моя история]]></string>
     <string name="_bx_credits_menu_item_title_history_common"><![CDATA[Моя история]]></string>
+    <string name="_bx_credits_menu_item_title_system_profiles_administration"><![CDATA[Все профили]]></string>
+    <string name="_bx_credits_menu_item_title_profiles_administration"><![CDATA[Все профили]]></string>
 
 
     <!-- Grids -->
@@ -166,6 +187,14 @@
     <string name="_bx_credits_grid_column_title_ord_added"><![CDATA[Добавлено]]></string>
     <string name="_bx_credits_grid_column_title_ord_expired"><![CDATA[Закончится]]></string>
 
+    <string name="_bx_credits_grid_column_title_pfl_id"><![CDATA[Профиль]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_wdw_clearing"><![CDATA[Клиринговый период (в днях)]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_wdw_minimum"><![CDATA[Минимальная сумма вывода]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_wdw_remaining"><![CDATA[Минимальная оставшаяся сумма]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_balance"><![CDATA[Баланс]]></string>
+    <string name="_bx_credits_grid_column_title_pfl_balance_cleared"><![CDATA[Очищенный баланс]]></string>
+    <string name="_bx_credits_grid_action_title_pfl_edit"><![CDATA[Редактировать]]></string>
+    <string name="_bx_credits_grid_popup_title_pfl_edit"><![CDATA[Редактировать ограничения профиля '{0}']]></string>
 
     <!-- Email templates -->
     <string name="_bx_credits_et_txt_name_granted"><![CDATA[Кредиты подарены.]]></string>