} 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)); }
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) {
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(); }
* 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');
$listdata['page'] = $page; $listdata['user'] = $user; $listdata['users'] = $DB->GetAllByKey('SELECT id, login FROM users ORDER BY login', 'id'); $listdata['resourcetype'] = $resourcetype; $listdata['resourceid'] = $resourceid; $listdata['propertyname'] = $propertyname; $listdata['propertyvalue'] = $propertyvalue; $listdata['datefrom'] = $datefrom; $listdata['dateto'] = $dateto; if ($SYSLOG) { $args = array('limit' => $limit + 1); if (!empty($user)) { $args['userid'] = $user; } if (!empty($resourcetype)) { $args['key'] = SYSLOG::getResourceKey($resourcetype); $args['value'] = $resourceid; } if (!empty($datefrom)) { $args['datefrom'] = $datefrom; } if (!empty($dateto)) { $args['dateto'] = $dateto; } $args['offset'] = $page * $limit; if (!empty($propertyname)) { $args['propname'] = $propertyname; if (strlen($propertyvalue)) { $args['propvalue'] = $propertyvalue; } }
$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'));
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; }