<?php
namespace Manage\Src\Lib;

use Dever;

class Log
{
    /**
     * 记录后台操作日志
     *
     * @return string
     */
    public static function add($project, $table, $info, $tid)
    {
        $admin = Dever::load('manage/auth.data');

        $data['操作'] = $info['method'];
        $data['操作人'] = $admin['username'] . '-' . $admin['id'];
        $data['操作IP'] = Dever::ip();
        $data['操作时间'] = date('Y-m-d H:i:s');
        $data['数据ID'] = $tid;
        //$data['old'] = Dever::load($project . '/' . $table . '-one', $tid);
        $data += $info['input'];

        $param['add_project'] = $project;
        $param['add_table'] = $table;
        $param['add_info'] = base64_encode(Dever::table($data));
        $param['add_admin'] = $admin['id'];
        $param['add_tid'] = $tid;
        return Dever::load('manage/log-insert', $param);
    }
}
