<?php
	/**	
	 * 
	 */	 
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
include_once(PATH_TO_ROOT."CRM/class/class.checkString.php");
	class LoggerX{
		private $db;
		
		function __construct($db) {
			$this->db = $db;	
		}
		
		function Log($area, $changeType, $field, $table, $oldValue, $newValue){
			$sql = "INSERT INTO ".WARPIT_CRM."._logger SET Added = NOW(), 
                    OldValue = '" . StringChecker::Check($oldValue) . "', 
                    NewValue = '" . StringChecker::Check($newValue) . "', 
                    Area = '" . StringChecker::Check($area) . "', 
                    ChangeType = '" . StringChecker::Check($changeType) . "',
                    EditedField = '" . StringChecker::Check($field) . "',
                    EditedTable = '" . StringChecker::Check($table) . "',
                    fileName = '".basename($_SERVER['SCRIPT_NAME'])."',
                    POST = '".StringChecker::Check(json_encode($_POST))."',
                    GET = '".StringChecker::Check(json_encode($_GET))."',
                    SESSION = '".StringChecker::Check(json_encode($_SESSION))."',
                    userType = ".$_SESSION['UserInfo']['user_type']. ",
                    UserId = " . $_SESSION['UserInfo']['id'];
			$this->db->SQLexecute($sql);
		} 
	}
	
?>