<?php

# 后台钩子

/*
 *
 *  public static function test($that){
 *      # $that = (base)$this;
 *      print_r($that->admin);
 *  }
 *  service::add_action('action_name', 'hooks::test');
 */

class hooks{
    
    # 新增和编辑时执行
    public static function Post($that, $id, $post){
        
    }
    
    # 删除时执行
    public static function Delete($that, $id){
        
    }
    
    public static function table_option_plus_th($that, $tid){
        if ($tid == 34){
            $url = $that->get_model_url(array('c' => 'users', 'm' => 'getWxUser'));
            echo '<th></th>';
            echo '<script>function getWxUser(id){ $.post("'.$url.'",  {id: id}, function(ret){ alert(ret); }); }</script>';
        }
    }
    
    public static function table_option_plus_td($that, $tid, $item){
        if ($tid == 34){
            echo '<td><a href="javascript:" onclick="getWxUser('.$item['id'].');" title="重新获取微信会员数据">[获取]</a></td>';
        }
    }

}

# 增加会员操作
service::add_action('table_option_plus_th', 'hooks::table_option_plus_th');
service::add_action('table_option_plus_td', 'hooks::table_option_plus_td');

# service::add_action('formConnectPost', 'hooks::Post');
# service::add_action('formConnectDelete', 'hooks::Delete');
