Changeset 1432


Ignore:
Timestamp:
02/21/12 17:24:55 (3 months ago)
Author:
roosit
Message:

Финансы: удаление счета

Location:
modules/money
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • modules/money/includes/dbquery.php

    r1431 r1432  
    170170                        INNER JOIN ".$db->prefix."money_account a ON a.accountid=ur.accountid 
    171171                        INNER JOIN ".$db->prefix."money_group g ON g.groupid=a.groupid 
    172                         WHERE g.deldate=0 AND ur.userid=".bkint($userid)." AND ur.role>0   
     172                        WHERE g.deldate=0 AND a.deldate=0 AND ur.userid=".bkint($userid)." AND ur.role>0   
    173173                                ".($groupid>0?" AND a.groupid=".bkint($groupid):"")." 
    174174                                ".($accountid>0?" AND a.accountid=".bkint($accountid):"")." 
  • modules/money/includes/manager.php

    r1431 r1432  
    4949                        case 'groupremove': return $this->GroupRemove($d->groupid); 
    5050                        case 'accountsave': return $this->AccountSave($d->account); 
     51                        case 'accountremove': return $this->AccountRemove($d->accountid); 
    5152                        case 'opersave': return $this->OperSave($d->oper); 
    5253                        case 'operremove': return $this->OperRemove($d->operid); 
     
    213214                if (!$this->IsWriteRole()){ return null; } 
    214215                $dbAccount = MoneyQuery::Account($this->db, $this->userid, $accountid); 
    215                 if (empty($dbAccount)){ return null; } 
    216                  
    217                 if ($dbAccount['r'] != MoneyAccountRole::ADMIN){ return null; } 
     216 
     217                if (empty($dbAccount) || $dbAccount['r'] != MoneyAccountRole::ADMIN){ return null; } 
    218218                 
    219219                MoneyQuery::AccountRemove($this->db, $accountid); 
    220                 return $accountid; 
     220                 
     221                $ret = new stdClass(); 
     222                $ret->deldate = TIMENOW; 
     223                return $ret; 
    221224        } 
    222225         
  • modules/money/js/accountlist.css

    r1431 r1432  
    9696        background: url("/modules/botask/images/icons001.png") no-repeat scroll -29px -24px transparent; 
    9797} 
     98.aw-money .aclist .arow .amenu .brem { 
     99        background: url("/modules/money/images/icons001.png") no-repeat scroll -42px -24px transparent; 
     100} 
     101 
     102 
    98103.aw-money .aclist .arow .amenu .bc { 
    99104        height: 14px; 
  • modules/money/js/accountlist.htm

    r1431 r1432  
    5454                        <div id="{i#baddc}" class="badd bc"> </div> 
    5555                </div> 
     56                <div id="{i#brem}" class="b" title="Удалить счет"> 
     57                        <div id="{i#bremc}" class="brem bc"> </div> 
     58                </div> 
    5659        </div> 
    5760</div> 
  • modules/money/js/accountlist.js

    r1431 r1432  
    9696                        case tp['badd']: 
    9797                        case tp['baddc']: this.onMenuAddOperClick(); return true; 
     98 
     99                        case tp['brem']: 
     100                        case tp['bremc']: this.onMenuRemoveClick(); return true; 
    98101                        } 
    99102                         
     
    124127                        if (!acc.isEditRole()){ 
    125128                                Dom.setStyle(gel('bedit'), 'display', 'none'); 
     129                                Dom.setStyle(gel('brem'), 'display', 'none'); 
    126130                        } 
    127131                        if (!acc.isOperRole()){ 
     
    131135                onMenuEditClick: function(){ 
    132136                        NS.life(this.cfg['onEditCallback'], this); 
     137                }, 
     138                onMenuRemoveClick: function(){ 
     139                        NS.life(this.cfg['onRemoveCallback'], this); 
    133140                }, 
    134141                onMenuAddOperClick: function(){ 
     
    193200                                        'onEditCallback': function(row){ 
    194201                                                __self.onMenuEditClick(row); 
     202                                        }, 
     203                                        'onRemoveCallback': function(row){ 
     204                                                __self.onMenuRemoveClick(row); 
    195205                                        }, 
    196206                                        'onAddOperCallback': function(row){ 
     
    235245                        NS.life(this.cfg['onEditCallback'], row); 
    236246                }, 
     247                onMenuRemoveClick: function(row){ 
     248                        NS.life(this.cfg['onRemoveCallback'], row); 
     249                }, 
    237250                onSelectByClick: function(rowWidget){ 
    238251                        NS.life(this.cfg['onSelCallback'], rowWidget); 
     
    268281                        this.clickGroupEditEvent = new CE('clickGroupEditEvent'); 
    269282                        this.clickEditEvent = new CE('clickEditEvent'); 
     283                        this.clickRemoveEvent = new CE('clickRemoveEvent'); 
    270284                        this.clickGroupRemoveEvent = new CE('clickGroupRemoveEvent'); 
    271285 
     
    279293                                                'onEditCallback': function(row){ 
    280294                                                        __self.onClickEdit(row.account); 
     295                                                }, 
     296                                                'onRemoveCallback': function(row){ 
     297                                                        __self.onClickRemove(row.account); 
    281298                                                }, 
    282299                                                'onSelCallback': function(row){ 
     
    370387                }, 
    371388                selectAccount: function(account){ 
    372                         this.selectAccountById(account.id); 
     389                        if (L.isNull(account)){ 
     390                                this.selectAccountById(null); 
     391                        }else{ 
     392                                this.selectAccountById(account.id); 
     393                        } 
    373394                }, 
    374395                selectAccountById: function(accountid){ 
     
    397418                        this.clickEditEvent.fire(acc); 
    398419                }, 
     420                onClickRemove: function(acc){ 
     421                        this.clickRemoveEvent.fire(acc); 
     422                }, 
    399423                onClickGroupRemove: function(){ 
    400424                        this.clickGroupRemoveEvent.fire(this.group); 
  • modules/money/js/groupview.htm

    r1431 r1432  
    4040</div> 
    4141 
     42<!--{accremovepanel}--> 
     43<div class='hd'>Удаление бухгалтерии</div> 
     44<div class='bd aw-money'> 
     45        <div id="{i#dialogremove}" class="field"> 
     46                <h4>Удаление бухгалтерии</h4> 
     47                <p> 
     48                        Внимание! <br /> 
     49                        Вы действительно хотите удалить счет "{v#tl}" и все что с ним связано? 
     50                </p> 
     51                <div class="buttons right"> 
     52                        <span id="{i#btns}"> 
     53                                <input id="{i#bremove}" value="Подтверждаю" type="button" /> 
     54                                <input id="{i#bcancel}" value="Отмена" type="button" /> 
     55                        </span> 
     56                        <span id="{i#bloading}" style="display: none"> 
     57                                <img src="/images/loading.gif" /> Удаление... 
     58                        </span> 
     59                </div> 
     60        </div> 
     61</div> 
     62 
    4263<!--{groupremovepanel}--> 
    4364<div class='hd'>Удаление бухгалтерии</div> 
     
    6081        </div> 
    6182</div> 
    62  
    6383 
    6484<!--{orempanel}--> 
  • modules/money/js/groupview.js

    r1431 r1432  
    5555                        this.accountsWidget.clickCreateEvent.subscribe(this.onAccountsClickCreate, this, true); 
    5656                        this.accountsWidget.clickEditEvent.subscribe(this.onAccountsClickEdit, this, true); 
     57                        this.accountsWidget.clickRemoveEvent.subscribe(this.onAccountsClickRemove, this, true); 
    5758                         
    5859                        this.operLogWidget = new NS.OperLogWidget(gel('operlog'), group); 
     
    6465                        }; 
    6566                         
    66                         var acc = group.accounts.getByIndex(0); 
    67                         this.accountsWidget.selectAccount(acc); 
     67                        this.setFirstAccount(); 
    6868                }, 
    6969                destroy: function(){ 
    7070                        if(this.accountsWidget){ 
    7171                                this.accountsWidget.selectChangedEvent.unsubscribe(this.onAccountsSelectChanged); 
     72                                this.accountsWidget.clickGroupEditEvent.unsubscribe(this.onAccountsClickGroupEdit); 
     73                                this.accountsWidget.clickGroupRemoveEvent.unsubscribe(this.onAccountsClickGroupRemove); 
    7274                                this.accountsWidget.clickCreateEvent.unsubscribe(this.onAccountsClickCreate); 
     75                                this.accountsWidget.clickEditEvent.unsubscribe(this.onAccountsClickEdit); 
     76                                this.accountsWidget.clickRemoveEvent.unsubscribe(this.onAccountsClickRemove); 
    7377                                this.accountsWidget.destroy(); 
    7478                                 
     
    8791                        el.parentNode.removeChild(el); 
    8892                }, 
     93                setFirstAccount: function(){ 
     94                        var acc = this.group.accounts.getByIndex(0); 
     95                        this.accountsWidget.selectAccount(acc); 
     96                        return acc; 
     97                }, 
    8998                onAccountsClickCreate: function(){ 
    9099                        this.showAccountEditor(0); 
     
    93102                        var account = prm[0]; 
    94103                        this.showAccountEditor(account.id); 
     104                }, 
     105                onAccountsClickRemove: function(evt, prm){ 
     106                        var account = prm[0], __self = this; 
     107                        new AccountRemovePanel(account, function(){ 
     108                                var acc = __self.setFirstAccount(); 
     109                                if (L.isNull(acc)){ 
     110                                        Brick.Page.reload(NS.navigator.ws); 
     111                                } 
     112                        }); 
    95113                }, 
    96114                onAccountsClickGroupEdit: function(evt, prm){ 
     
    197215        NS.GroupViewWidget = GroupViewWidget; 
    198216         
     217        var AccountRemovePanel = function(account, callback){ 
     218                this.account = account; 
     219                this.callback = callback; 
     220                AccountRemovePanel.superclass.constructor.call(this, {fixedcenter: true}); 
     221        }; 
     222        YAHOO.extend(AccountRemovePanel, Brick.widget.Dialog, { 
     223                initTemplate: function(){ 
     224                        return buildTemplate(this, 'accremovepanel').replace('accremovepanel', { 
     225                                'tl': this.account.getTitle() 
     226                        }); 
     227                }, 
     228                onClick: function(el){ 
     229                        var tp = this._TId['accremovepanel']; 
     230                        switch(el.id){ 
     231                        case tp['bcancel']: this.close(); return true; 
     232                        case tp['bremove']: this.accRemove(); return true; 
     233                        } 
     234                        return false; 
     235                }, 
     236                accRemove: function(){ 
     237                        var TM = this._TM, gel = function(n){ return  TM.getEl('accremovepanel.'+n); }, 
     238                                __self = this; 
     239                        Dom.setStyle(gel('btns'), 'display', 'none'); 
     240                        Dom.setStyle(gel('bloading'), 'display', ''); 
     241                         
     242                        NS.moneyManager.accountRemove(this.account.id, function(){ 
     243                                __self.close(); 
     244                                NS.life(__self.callback); 
     245                        }); 
     246                } 
     247        }); 
     248        NS.AccountRemovePanel = AccountRemovePanel; 
     249 
    199250        var GroupRemovePanel = function(group, callback){ 
    200251                this.group = group; 
  • modules/money/js/lib.js

    r1431 r1432  
    668668                                        var ad = r['account']; 
    669669                                                group = __self.groups.get(ad['gid']); 
     670                                         
    670671                                        if (!L.isNull(group)){ 
    671672                                                group.accounts.update([ad]); 
     
    684685                }, 
    685686                accountRemove: function(accountid, callback){ 
     687                        var account = this.findAccount(accountid); 
     688                        if (L.isNull(account)){ return; } 
     689                        var group = this.groups.get(account.groupid); 
     690 
    686691                        var __self = this; 
    687692                        this.ajax({ 
     
    690695                        }, function(r){ 
    691696                                if (!L.isNull(r) && r['deldate']>0){ 
    692                                         __self.onAccountRemoved(accountid); 
     697                                        group.accounts.remove(accountid); 
     698                                        if (group.accounts.count() == 0){ 
     699                                                __self.groups.remove(group.id); 
     700                                                __self.onGroupRemoved(group.id); 
     701                                        }else{ 
     702                                                __self.onAccountRemoved(accountid); 
     703                                        } 
    693704                                }                                
    694705                                NS.life(callback); 
Note: See TracChangeset for help on using the changeset viewer.