예제 #1
0
function GetPropertyValues($resource, $propname, $propvalue)
{
    $SYSLOG = SYSLOG::getInstance();
    $result = new XajaxResponse();
    $values = $SYSLOG->GetResourcePropertyValues($resource, $propname);
    if (empty($values) || count($values) > 19) {
        $result->assign('propertyvaluedata', 'innerHTML', '<input type="text" size="20" name="propertyvalue" id="propertyvalue"' . (strlen($propvalue) ? ' value="' . $propvalue . '"' : '') . '>');
    } else {
        $options = '<SELECT size="1" name="propertyvalue" id="propertyvalue">';
        $options .= '<OPTION value="">' . trans('- all -') . '</OPTION>';
        foreach ($values as $value) {
            $data = array('resource' => $resource, 'name' => $propname, 'value' => $value);
            $SYSLOG->DecodeMessageData($data);
            $options .= '<OPTION value="' . $value . '"' . (strlen($propvalue) && $propvalue == $value ? ' selected' : '') . '>' . (strlen($data['value']) > 50 ? substr($data['value'], 0, 50) . '...' : $data['value']) . '</OPTION>';
        }
        $options .= '</SELECT>';
        $result->assign('propertyvaluedata', 'innerHTML', $options);
    }
    return $result;
}
예제 #2
0
        if ($DB->GetOne('SELECT id FROM cashregs WHERE name=?', array($registry['name']))) {
            $error['name'] = trans('Registry with specified name already exists!');
        }
    }
    if (isset($registry['users'])) {
        foreach ($registry['users'] as $key => $value) {
            $registry['rights'][] = array('id' => $key, 'rights' => array_sum($value), 'name' => $registry['usernames'][$key]);
        }
    }
    if (!$error) {
        $DB->BeginTrans();
        $args = array('name' => $registry['name'], 'description' => $registry['description'], 'in_' . SYSLOG::getResourceKey(SYSLOG::RES_NUMPLAN) => $registry['in_numberplanid'], 'out_' . SYSLOG::getResourceKey(SYSLOG::RES_NUMPLAN) => $registry['out_numberplanid'], 'disabled' => isset($registry['disabled']) ? 1 : 0, SYSLOG::RES_CASHREG => $registry['id']);
        $DB->Execute('UPDATE cashregs SET name=?, description=?, in_numberplanid=?, out_numberplanid=?, disabled=?
			WHERE id=?', array_values($args));
        if ($SYSLOG) {
            $SYSLOG->AddMessage(SYSLOG::RES_CASHREG, SYSLOG::OPER_UPDATE, $args, array('in_' . SYSLOG::getResourceKey(SYSLOG::RES_NUMPLAN), 'out_' . SYSLOG::getResourceKey(SYSLOG::RES_NUMPLAN)));
            $cashrights = $DB->GetAll('SELECT id, userid FROM cashrights WHERE regid = ?', array($registry['id']));
            if (!empty($cashrights)) {
                foreach ($cashrights as $cashright) {
                    $args = array(SYSLOG::RES_CASHRIGHT => $cashright['id'], SYSLOG::RES_CASHREG => $registry['id'], SYSLOG::RES_USER => $cashright['userid']);
                    $SYSLOG->AddMessage(SYSLOG::RES_CASHRIGHT, SYSLOG::OPER_DELETE, $args);
                }
            }
        }
        $DB->Execute('DELETE FROM cashrights WHERE regid=?', array($registry['id']));
        if ($registry['rights']) {
            foreach ($registry['rights'] as $right) {
                if ($right['rights']) {
                    $args = array(SYSLOG::RES_CASHREG => $id, SYSLOG::RES_USER => $right['id'], 'rights' => $right['rights']);
                    $DB->Execute('INSERT INTO cashrights (regid, userid, rights) VALUES(?, ?, ?)', array_values($args));
                    if ($SYSLOG) {
예제 #3
0
 public static function getInstance($force = false)
 {
     if (self::$syslog == null && ($force || ConfigHelper::checkConfig('phpui.logging'))) {
         self::$syslog = new SYSLOG();
     }
     return self::$syslog;
 }
예제 #4
0
 public function updateNodeField($nodeid, $field, $value)
 {
     $nodeid = (int) $nodeid;
     $field = strtolower($field);
     $error_msg = 0;
     switch ($field) {
         case 'authtype':
             if (!is_numeric($value)) {
                 $error_msg = "Value isn't a number";
             } else {
                 global $SESSIONTYPES;
                 $value = (int) $value;
                 $tmp = 0;
                 foreach ($SESSIONTYPES as $k => $v) {
                     if ($value & $k) {
                         $tmp += $k;
                     }
                 }
                 $value = $tmp;
             }
             break;
         case 'nas':
         case 'halfduplex':
         case 'chkmac':
             $value = $value == 1 ? 1 : 0;
             break;
         default:
             $error_msg = "Unknown field name.";
     }
     $SYSLOG = SYSLOG::getInstance();
     if ($SYSLOG) {
         $args = array(SYSLOG::RES_NODE => $nodeid, 'field' => $field, 'value' => $value);
         $SYSLOG->AddMessage(SYSLOG::RES_NODE, SYSLOG::OPER_UPDATE, $args);
     }
     if (!$error) {
         $this->db->Execute('UPDATE nodes SET ' . $field . ' = ? WHERE id = ?;', array($value, $nodeid));
     } else {
         return $error_msg;
     }
 }
예제 #5
0
파일: noteadd.php 프로젝트: prezeskk/lms
            } else {
                $fullnumber = null;
            }
            $args = array('number' => $note['number'], SYSLOG::RES_NUMPLAN => !empty($note['numberplanid']) ? $note['numberplanid'] : 0, 'type' => DOC_DNOTE, 'cdate' => $cdate, SYSLOG::RES_USER => $AUTH->id, SYSLOG::RES_CUST => $customer['id'], 'name' => $customer['customername'], 'address' => $customer['address'], 'paytime' => $note['paytime'], 'ten' => $customer['ten'], 'ssn' => $customer['ssn'], 'zip' => $customer['zip'], 'city' => $customer['city'], SYSLOG::RES_COUNTRY => $customer['countryid'], SYSLOG::RES_DIV => $customer['divisionid'], 'div_name' => $division['name'] ? $division['name'] : '', 'div_shortname' => $division['shortname'] ? $division['shortname'] : '', 'div_address' => $division['address'] ? $division['address'] : '', 'div_city' => $division['city'] ? $division['city'] : '', 'div_zip' => $division['zip'] ? $division['zip'] : '', 'div_' . SYSLOG::getResourceKey(SYSLOG::RES_COUNTRY) => $division['countryid'] ? $division['countryid'] : 0, 'div_ten' => $division['ten'] ? $division['ten'] : '', 'div_regon' => $division['regon'] ? $division['regon'] : '', 'div_account' => $division['account'] ? $division['account'] : '', 'div_inv_header' => $division['inv_header'] ? $division['inv_header'] : '', 'div_inv_footer' => $division['inv_footer'] ? $division['inv_footer'] : '', 'div_inv_author' => $division['inv_author'] ? $division['inv_author'] : '', 'div_inv_cplace' => $division['inv_cplace'] ? $division['inv_cplace'] : '', 'fullnumber' => $fullnumber);
            $DB->Execute('INSERT INTO documents (number, numberplanid, type,
					cdate, userid, customerid, name, address, paytime,
					ten, ssn, zip, city, countryid, divisionid,
					div_name, div_shortname, div_address, div_city, div_zip, div_countryid,
					div_ten, div_regon, div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber)
					VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
						?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
            $nid = $DB->GetLastInsertID('documents');
            if ($SYSLOG) {
                $args[SYSLOG::RES_DOC] = $nid;
                unset($args[SYSLOG::RES_USER]);
                $SYSLOG->AddMessage(SYSLOG::RES_DOC, SYSLOG::OPER_ADD, $args, array('div_' . SYSLOG::getResourceKey(SYSLOG::RES_COUNTRY)));
            }
            $itemid = 0;
            foreach ($contents as $idx => $item) {
                $itemid++;
                $item['value'] = str_replace(',', '.', $item['value']);
                $args = array(SYSLOG::RES_DOC => $nid, 'itemid' => $itemid, 'value' => $item['value'], 'description' => $item['description']);
                $DB->Execute('INSERT INTO debitnotecontents (docid, itemid, value, description)
					VALUES (?, ?, ?, ?)', array_values($args));
                if ($SYSLOG) {
                    $args[SYSLOG::RES_DNOTECONT] = $DB->GetLastInsertID('debitnotecontents');
                    $args[SYSLOG::RES_CUST] = $customer['id'];
                    $SYSLOG->AddMessage(SYSLOG::RES_DNOTECONT, SYSLOG::OPER_ADD, $args);
                }
                $LMS->AddBalance(array('time' => $cdate, 'value' => $item['value'] * -1, 'taxid' => 0, 'customerid' => $customer['id'], 'comment' => $item['description'], 'docid' => $nid, 'itemid' => $itemid));
            }
예제 #6
0
 public function DeleteNetDev($id)
 {
     $this->db->BeginTrans();
     if ($this->syslog) {
         $netlinks = $this->db->GetAll('SELECT id, src, dst FROM netlinks WHERE src = ? OR dst = ?', array($id, $id));
         if (!empty($netlinks)) {
             foreach ($netlinks as $netlink) {
                 $args = array(SYSLOG::RES_NETLINK => $netlink['id'], 'src_' . SYSLOG::getResourceKey(SYSLOG::RES_NETDEV) => $netlink['src'], 'dst_' . SYSLOG::getResourceKey(SYSLOG::RES_NETDEV) => $netlink['dst']);
                 $this->syslog->AddMessage(SYSLOG::RES_NETLINK, SYSLOG::OPER_DELETE, $args, array('src_' . SYSLOG::getResourceKey(SYSLOG::RES_NETDEV), 'dst_' . SYSLOG::getResourceKey(SYSLOG::RES_NETDEV)));
             }
         }
         $nodes = $this->db->GetCol('SELECT id FROM vnodes WHERE ownerid = 0 AND netdev = ?', array($id));
         if (!empty($nodes)) {
             foreach ($nodes as $node) {
                 $macs = $this->db->GetCol('SELECT id FROM macs WHERE nodeid = ?', array($node));
                 if (!empty($macs)) {
                     foreach ($macs as $mac) {
                         $args = array(SYSLOG::RES_MAC => $mac, SYSLOG::RES_NODE => $node);
                         $this->syslog->AddMessage(SYSLOG::RES_MAC, SYSLOG::OPER_DELETE, $args);
                     }
                 }
                 $args = array(SYSLOG::RES_NODE => $node, SYSLOG::RES_NETDEV => $id);
                 $this->syslog->AddMessage(SYSLOG::RES_NODE, SYSLOG::OPER_DELETE, $args);
             }
         }
         $nodes = $this->db->GetAll('SELECT id, ownerid FROM vnodes WHERE ownerid <> 0 AND netdev = ?', array($id));
         if (!empty($nodes)) {
             foreach ($nodes as $node) {
                 $args = array(SYSLOG::RES_NODE => $node['id'], SYSLOG::RES_CUST => $node['ownerid'], SYSLOG::RES_NETDEV => 0);
                 $this->syslog->AddMessage(SYSLOG::RES_NODE, SYSLOG::OPER_UPDATE, $args);
             }
         }
         $args = array(SYSLOG::RES_NETDEV => $id);
         $this->syslog->AddMessage(SYSLOG::RES_NETDEV, SYSLOG::OPER_DELETE, $args);
     }
     $this->db->Execute('DELETE FROM netlinks WHERE src=? OR dst=?', array($id, $id));
     $this->db->Execute('DELETE FROM nodes WHERE ownerid=0 AND netdev=?', array($id));
     $this->db->Execute('UPDATE nodes SET netdev=0 WHERE netdev=?', array($id));
     $this->db->Execute('DELETE FROM netdevices WHERE id=?', array($id));
     $this->db->CommitTrans();
 }
예제 #7
0
 *  USA.
 *
 *  $Id$
 */
if (!$SYSLOG) {
    $body = trans('Transaction logging is disabled.');
    $SMARTY->assign('body', $body);
    $SMARTY->display('dialog.html');
    die;
}
$type = isset($_GET['type']) ? intval($_GET['type']) : 0;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$date = isset($_GET['date']) ? intval($_GET['date']) : 0;
$resource = array('type' => $type, 'id' => $id);
if (!empty($date)) {
    $resource['date'] = $date;
}
$resource['properties'] = $SYSLOG->GetResourceProperties($resource);
$resource['name'] = SYSLOG::getResourceName($type);
//xdebug_var_dump($resource);
//die;
$trans = $SYSLOG->GetTransactions(array('key' => SYSLOG::getResourceKey($type), 'value' => $id));
if (!empty($trans)) {
    foreach ($trans as $idx => $tran) {
        $SYSLOG->DecodeTransaction($trans[$idx]);
    }
}
$SMARTY->assign('transactions', $trans);
$layout['pagetitle'] = trans('Archived Resource Information');
$SMARTY->assign('resource', $resource);
$SMARTY->display('archive/archiveinfo.html');
예제 #8
0
파일: lms-pna.php 프로젝트: prezeskk/lms
}
// Init database
$DB = null;
try {
    $DB = LMSDB::getInstance();
} catch (Exception $ex) {
    trigger_error($ex->getMessage(), E_USER_WARNING);
    // can't working without database
    die("Fatal error: cannot connect to database!" . PHP_EOL);
}
// Include required files (including sequence is important)
require_once LIB_DIR . DIRECTORY_SEPARATOR . 'common.php';
require_once LIB_DIR . DIRECTORY_SEPARATOR . 'language.php';
include_once LIB_DIR . DIRECTORY_SEPARATOR . 'definitions.php';
require_once LIB_DIR . DIRECTORY_SEPARATOR . 'unstrip.php';
$SYSLOG = SYSLOG::getInstance();
// Initialize Session, Auth and LMS classes
$AUTH = NULL;
$LMS = new LMS($DB, $AUTH, $SYSLOG);
$LMS->ui_lang = $_ui_language;
$LMS->lang = $_language;
define('PNA', 0);
define('CITY', 1);
define('STREET', 2);
define('HOUSE', 3);
define('BOROUGH', 4);
define('DISTRICT', 5);
define('STATE', 6);
$states = array(2 => 'dolnosląskie', 4 => 'kujawsko-pomorskie', 6 => 'lubelskie', 8 => 'lubuskie', 10 => 'łódzkie', 12 => 'małopolskie', 14 => 'mazowieckie', 16 => 'opolskie', 18 => 'podkarpackie', 20 => 'podlaskie', 22 => 'pomorskie', 24 => 'śląskie', 26 => 'świętokrzyskie', 28 => 'warmińsko-mazurskie', 30 => 'wielkopolskie', 32 => 'zachodniopomorskie');
$list = array_key_exists('list', $options) ? $options['list'] : '';
if (preg_match('/^[0-9]+(,[0-9]+)*$/', $list)) {
예제 #9
0
$messagelist = $LMS->GetMessages($customerid);
$eventlist = $LMS->EventSearch(array('customerid' => $customerid), 'date,desc', true);
$customernodes = $LMS->GetCustomerNodes($customerid);
$customernetworks = $LMS->GetCustomerNetworks($customerid, 10);
$customerstats = array('tickets' => $DB->GetRow('SELECT COUNT(*) AS all, SUM(CASE WHEN state < ? THEN 1 ELSE 0 END) AS notresolved
		FROM rttickets WHERE customerid = ?', array(RT_RESOLVED, $customerid)), 'domains' => $DB->GetOne('SELECT COUNT(*) FROM domains WHERE ownerid = ?', array($customerid)), 'accounts' => $DB->GetOne('SELECT COUNT(*) FROM passwd WHERE ownerid = ?', array($customerid)));
$customerdevices = $LMS->GetNetDevList('name,asc', array('ownerid' => intval($customerid)));
unset($customerdevices['total']);
unset($customerdevices['order']);
unset($customerdevices['direction']);
$counter = count($customerdevices);
for ($i = 0; $i < $counter; ++$i) {
    $customerdevices[$i]['ips'] = $LMS->GetNetDevIPs($customerdevices[$i]['id']);
}
if ($SYSLOG && (ConfigHelper::checkConfig('privileges.superuser') || ConfigHelper::checkConfig('privileges.transaction_logs'))) {
    $trans = $SYSLOG->GetTransactions(array('key' => SYSLOG::getResourceKey(SYSLOG::RES_CUST), 'value' => $customerid, 'limit' => 300));
    if (!empty($trans)) {
        foreach ($trans as $idx => $tran) {
            $SYSLOG->DecodeTransaction($trans[$idx]);
        }
    }
    $SMARTY->assign('transactions', $trans);
    $SMARTY->assign('resourcetype', SYSLOG::RES_CUST);
    $SMARTY->assign('resourceid', $customerid);
}
if (!empty($documents)) {
    $SMARTY->assign('docrights', $DB->GetAllByKey('SELECT doctype, rights
        FROM docrights WHERE userid = ? AND rights > 1', 'doctype', array($AUTH->id)));
}
$SMARTY->assign(array('expired' => $expired, 'time' => $SESSION->get('addbt'), 'taxid' => $SESSION->get('addbtax'), 'comment' => $SESSION->get('addbc'), 'sourceid' => $SESSION->get('addsource')));
$SMARTY->assign('sourcelist', $DB->GetAll('SELECT id, name FROM cashsources WHERE deleted = 0 ORDER BY name'));
예제 #10
0
파일: Auth.class.php 프로젝트: prezeskk/lms
 public function __construct(&$DB, &$SESSION)
 {
     self::$auth = $this;
     $this->DB =& $DB;
     $this->SESSION =& $SESSION;
     $this->SYSLOG = SYSLOG::getInstance();
     //$this->_revision = preg_replace('/^.Revision: ([0-9.]+).*/', '\1', $this->_revision);
     $this->_revision = '';
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } else {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $this->ip = str_replace('::ffff:', '', $ip);
     if (isset($_GET['override'])) {
         $loginform = $_GET['loginform'];
     } elseif (isset($_POST['loginform'])) {
         $loginform = $_POST['loginform'];
     }
     $this->SESSION->restore('session_login', $this->login);
     if ($this->login) {
         $this->islogged = TRUE;
     } elseif (isset($loginform)) {
         $this->login = $loginform['login'];
         $this->passwd = $loginform['pwd'];
         writesyslog('Login attempt by ' . $this->login, LOG_INFO);
     } elseif ($this->DB->GetOne('SELECT COUNT(id) FROM users') == 0) {
         $this->islogged = TRUE;
         $this->nousers = TRUE;
         $_GET['m'] = 'useradd';
         return TRUE;
     }
     if ($this->islogged || $this->login && $this->VerifyUser()) {
         $this->SESSION->restore('session_passwdrequiredchange', $this->passwdrequiredchange);
         if (empty($this->last)) {
             $this->SESSION->restore('session_last', $this->last);
             $this->SESSION->restore('session_lastip', $this->lastip);
         }
         $this->logname = $this->logname ? $this->logname : $this->SESSION->get('session_logname');
         $this->id = $this->id ? $this->id : $this->SESSION->get('session_id');
         if (isset($loginform)) {
             $this->DB->Execute('UPDATE users SET lastlogindate=?, lastloginip=? WHERE id=?', array(time(), $this->ip, $this->id));
             writesyslog('User ' . $this->login . ' logged in.', LOG_INFO);
             if ($this->SYSLOG) {
                 $this->SYSLOG->NewTransaction('auth', $this->id);
                 $this->SYSLOG->AddMessage(SYSLOG::RES_USER, SYSLOG::OPER_USERLOGIN, array(SYSLOG::RES_USER => $this->id, 'ip' => $this->ip, 'useragent' => $_SERVER['HTTP_USER_AGENT']));
             }
         }
         $this->SESSION->save('session_id', $this->id);
         $this->SESSION->save('session_login', $this->login);
         $this->SESSION->restore_user_settings();
         $this->SESSION->save('session_logname', $this->logname);
         $this->SESSION->save('session_last', $this->last);
         $this->SESSION->save('session_lastip', $this->lastip);
     } else {
         if (isset($loginform)) {
             if ($this->id) {
                 if (!$this->hostverified) {
                     writesyslog('Bad host (' . $this->ip . ') for ' . $this->login, LOG_WARNING);
                 }
                 if (!$this->passverified) {
                     writesyslog('Bad password for ' . $this->login, LOG_WARNING);
                 }
                 $this->DB->Execute('UPDATE users SET failedlogindate=?, failedloginip=? WHERE id = ?', array(time(), $this->ip, $this->id));
                 if ($this->SYSLOG) {
                     $this->SYSLOG->NewTransaction('auth', $this->id);
                     $this->SYSLOG->AddMessage(SYSLOG::RES_USER, SYSLOG::OPER_USERLOGFAIL, array(SYSLOG::RES_USER => $this->id, 'ip' => $this->ip, 'useragent' => $_SERVER['HTTP_USER_AGENT']));
                 }
             } else {
                 writesyslog('Unknown login ' . $this->login . ' from ' . $this->ip, LOG_WARNING);
             }
         }
         if (!$this->error) {
             $this->error = trans('Please login.');
         }
         $this->LogOut();
     }
 }
예제 #11
0
    public function AddInvoice($invoice)
    {
        $currtime = time();
        $cdate = $invoice['invoice']['cdate'] ? $invoice['invoice']['cdate'] : $currtime;
        $sdate = $invoice['invoice']['sdate'] ? $invoice['invoice']['sdate'] : $currtime;
        $number = $invoice['invoice']['number'];
        $type = $invoice['invoice']['type'];
        if ($invoice['invoice']['numberplanid']) {
            $fullnumber = docnumber(array('number' => $number, 'template' => $this->db->GetOne('SELECT template FROM numberplans WHERE id = ?', array($invoice['invoice']['numberplanid'])), 'cdate' => $cdate));
        } else {
            $fullnumber = null;
        }
        $division = $this->db->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
				account, inv_header, inv_footer, inv_author, inv_cplace
				FROM divisions WHERE id = ? ;', array($invoice['customer']['divisionid']));
        $args = array('number' => $number, SYSLOG::RES_NUMPLAN => $invoice['invoice']['numberplanid'] ? $invoice['invoice']['numberplanid'] : 0, 'type' => $type, 'cdate' => $cdate, 'sdate' => $sdate, 'paytime' => $invoice['invoice']['paytime'], 'paytype' => $invoice['invoice']['paytype'], SYSLOG::RES_USER => $this->auth->id, SYSLOG::RES_CUST => $invoice['customer']['id'], 'customername' => $invoice['customer']['customername'], 'address' => $invoice['customer']['address'], 'ten' => $invoice['customer']['ten'], 'ssn' => $invoice['customer']['ssn'], 'zip' => $invoice['customer']['zip'], 'city' => $invoice['customer']['city'], SYSLOG::RES_COUNTRY => $invoice['customer']['countryid'], SYSLOG::RES_DIV => $invoice['customer']['divisionid'], 'div_name' => $division['name'] ? $division['name'] : '', 'div_shortname' => $division['shortname'] ? $division['shortname'] : '', 'div_address' => $division['address'] ? $division['address'] : '', 'div_city' => $division['city'] ? $division['city'] : '', 'div_zip' => $division['zip'] ? $division['zip'] : '', 'div_' . SYSLOG::getResourceKey(SYSLOG::RES_COUNTRY) => $division['countryid'] ? $division['countryid'] : 0, 'div_ten' => $division['ten'] ? $division['ten'] : '', 'div_regon' => $division['regon'] ? $division['regon'] : '', 'div_account' => $division['account'] ? $division['account'] : '', 'div_inv_header' => $division['inv_header'] ? $division['inv_header'] : '', 'div_inv_footer' => $division['inv_footer'] ? $division['inv_footer'] : '', 'div_inv_author' => $division['inv_author'] ? $division['inv_author'] : '', 'div_inv_cplace' => $division['inv_cplace'] ? $division['inv_cplace'] : '', 'fullnumber' => $fullnumber);
        $this->db->Execute('INSERT INTO documents (number, numberplanid, type,
			cdate, sdate, paytime, paytype, userid, customerid, name, address,
			ten, ssn, zip, city, countryid, divisionid,
			div_name, div_shortname, div_address, div_city, div_zip, div_countryid, div_ten, div_regon,
			div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber)
			VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
        $iid = $this->db->GetLastInsertID('documents');
        if ($this->syslog) {
            unset($args[SYSLOG::RES_USER]);
            $args[SYSLOG::RES_DOC] = $iid;
            $this->syslog->AddMessage(SYSLOG::RES_DOC, SYSLOG::OPER_ADD, $args, array('div_' . SYSLOG::getResourceKey(SYSLOG::RES_COUNTRY)));
        }
        $itemid = 0;
        foreach ($invoice['contents'] as $idx => $item) {
            $itemid++;
            $item['valuebrutto'] = str_replace(',', '.', $item['valuebrutto']);
            $item['count'] = str_replace(',', '.', $item['count']);
            $item['discount'] = str_replace(',', '.', $item['discount']);
            $item['pdiscount'] = str_replace(',', '.', $item['pdiscount']);
            $item['vdiscount'] = str_replace(',', '.', $item['vdiscount']);
            $item['taxid'] = isset($item['taxid']) ? $item['taxid'] : 0;
            $args = array(SYSLOG::RES_DOC => $iid, 'itemid' => $itemid, 'value' => $item['valuebrutto'], SYSLOG::RES_TAX => $item['taxid'], 'prodid' => $item['prodid'], 'content' => $item['jm'], 'count' => $item['count'], 'pdiscount' => $item['pdiscount'], 'vdiscount' => $item['vdiscount'], 'description' => $item['name'], SYSLOG::RES_TARIFF => $item['tariffid']);
            $this->db->Execute('INSERT INTO invoicecontents (docid, itemid,
				value, taxid, prodid, content, count, pdiscount, vdiscount, description, tariffid)
				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
            if ($this->syslog) {
                $args[SYSLOG::RES_CUST] = $invoice['customer']['id'];
                $this->syslog->AddMessage(SYSLOG::RES_INVOICECONT, SYSLOG::OPER_ADD, $args);
            }
            if ($type != DOC_INVOICE_PRO) {
                $this->AddBalance(array('time' => $cdate, 'value' => $item['valuebrutto'] * $item['count'] * -1, 'taxid' => $item['taxid'], 'customerid' => $invoice['customer']['id'], 'comment' => $item['name'], 'docid' => $iid, 'itemid' => $itemid));
            }
        }
        return $iid;
    }