diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/REST/functions.php b/REST/functions.php index d6b6efb4..8389ea98 100644 --- a/REST/functions.php +++ b/REST/functions.php @@ -202,7 +202,7 @@ function createCostDocumentFromInvoice($record) $doc->doc_symbol = $inv->document_no; $doc->revision = 1; - $doc->category_id = 'revision_note'; + $doc->category_id = 'invoice'; $doc->status = '2'; $doc->transaction_type = '1'; $doc->document_type = 'k'; diff --git a/config.php b/config.php index 22f2286b..6b6b09a4 100755 --- a/config.php +++ b/config.php @@ -1,5 +1,6 @@ false, 'admin_export_only' => false, 'allow_pop_inbound' => true, @@ -8,15 +9,15 @@ $sugar_config = array( 'common_ml_dir' => '', 'create_default_user' => false, 'currency' => '', - 'dashlet_display_row_options' => - array( + 'dashlet_display_row_options' => + array ( 0 => '1', 1 => '3', 2 => '5', 3 => '10', ), - 'date_formats' => - array( + 'date_formats' => + array ( 'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010', @@ -28,15 +29,16 @@ $sugar_config = array( 'm.d.Y' => '12.23.2010', ), 'datef' => 'm/d/Y', - 'dbconfig' => array( + 'dbconfig' => + array ( 'db_host_name' => 'localhost', 'db_user_name' => 'root', 'db_password' => '5z#JaL', 'db_name' => 'sugarcrm', 'db_type' => 'mysql', ), - 'dbconfigoption' => - array( + 'dbconfigoption' => + array ( 'persistent' => true, 'autofree' => false, 'debug' => 0, @@ -47,94 +49,94 @@ $sugar_config = array( ), 'default_action' => 'index', 'default_charset' => 'UTF-8', - 'default_currencies' => - array( - 'AUD' => - array( + 'default_currencies' => + array ( + 'AUD' => + array ( 'name' => 'Australian Dollars', 'iso4217' => 'AUD', 'symbol' => '$', ), - 'BRL' => - array( + 'BRL' => + array ( 'name' => 'Brazilian Reais', 'iso4217' => 'BRL', 'symbol' => 'R$', ), - 'GBP' => - array( + 'GBP' => + array ( 'name' => 'British Pounds', 'iso4217' => 'GBP', 'symbol' => 'ÂŁ', ), - 'CAD' => - array( + 'CAD' => + array ( 'name' => 'Canadian Dollars', 'iso4217' => 'CAD', 'symbol' => '$', ), - 'CNY' => - array( + 'CNY' => + array ( 'name' => 'Chinese Yuan', 'iso4217' => 'CNY', 'symbol' => '¥', ), - 'EUR' => - array( + 'EUR' => + array ( 'name' => 'Euro', 'iso4217' => 'EUR', 'symbol' => '€', ), - 'HKD' => - array( + 'HKD' => + array ( 'name' => 'Hong Kong Dollars', 'iso4217' => 'HKD', 'symbol' => '$', ), - 'INR' => - array( + 'INR' => + array ( 'name' => 'Indian Rupees', 'iso4217' => 'INR', 'symbol' => '₨', ), - 'KRW' => - array( + 'KRW' => + array ( 'name' => 'Korean Won', 'iso4217' => 'KRW', 'symbol' => 'â‚©', ), - 'YEN' => - array( + 'YEN' => + array ( 'name' => 'Japanese Yen', 'iso4217' => 'JPY', 'symbol' => 'ÂĄ', ), - 'MXM' => - array( + 'MXM' => + array ( 'name' => 'Mexican Pesos', 'iso4217' => 'MXM', 'symbol' => '$', ), - 'SGD' => - array( + 'SGD' => + array ( 'name' => 'Singaporean Dollars', 'iso4217' => 'SGD', 'symbol' => '$', ), - 'CHF' => - array( + 'CHF' => + array ( 'name' => 'Swiss Franc', 'iso4217' => 'CHF', 'symbol' => 'SFr.', ), - 'THB' => - array( + 'THB' => + array ( 'name' => 'Thai Baht', 'iso4217' => 'THB', 'symbol' => '฿', ), - 'USD' => - array( + 'USD' => + array ( 'name' => 'US Dollars', 'iso4217' => 'USD', 'symbol' => '$', @@ -158,8 +160,8 @@ $sugar_config = array( 'default_navigation_paradigm' => 'm', 'default_number_grouping_seperator' => ',', 'default_password' => '', - 'default_permissions' => - array( + 'default_permissions' => + array ( 'dir_mode' => 1528, 'file_mode' => 432, 'user' => '', @@ -189,25 +191,25 @@ $sugar_config = array( 'googleClientId' => '751962231483-1pnk4heu9rc6mc38lb8sjfc6lo2qfqcn.apps.googleusercontent.com', 'googleClientSecret' => 'C6vjyBug2W2h7JefuMnlO-4j', 'googleRedirectUri' => 'http://system.saas-systems.pl/index.php?module=Users&action=googleLogin', - 'googleScopes' => - array( + 'googleScopes' => + array ( 0 => 'https://www.googleapis.com/auth/calendar', 1 => 'https://www.googleapis.com/auth/userinfo.email', 2 => 'https://www.googleapis.com/auth/userinfo.profile', ), 'history_max_viewed' => 50, 'host_name' => 'https://crm.twinpol.com', - 'http_referer' => - array( - 'actions' => - array( + 'http_referer' => + array ( + 'actions' => + array ( 0 => 'saveInvoice', ), 'weak' => true, - 'list' => - array( - 0 => 'saas-systems.pl', - 1 => 'b2b-meritum.ddns.net', + 'list' => + array ( + 0 => 'crm.twinpol.com', + 1 => 'accounts.google.com', 2 => 'crm-meritum.ddns.net', 3 => '83.3.222.246', ), @@ -218,8 +220,8 @@ $sugar_config = array( 'installer_locked' => true, 'js_custom_version' => 1, 'js_lang_version' => 7, - 'languages' => - array( + 'languages' => + array ( 'pl_pl' => 'Polski', 'en_us' => 'English (US)', ), @@ -232,11 +234,11 @@ $sugar_config = array( 'log_dir' => '.', 'log_file' => 'sugarcrm.log', 'log_memory_usage' => false, - 'logger' => - array( + 'logger' => + array ( 'level' => 'off', - 'file' => - array( + 'file' => + array ( 'ext' => '.log', 'name' => 'sugarcrm', 'dateFormat' => '%c', @@ -247,8 +249,8 @@ $sugar_config = array( ), 'max_dashlets_homepage' => '15', 'other_group_tab_displayed' => true, - 'passwordsetting' => - array( + 'passwordsetting' => + array ( 'SystemGeneratedPasswordON' => '1', 'generatepasswordtmpl' => '33583ffa-c047-382e-35da-4e54c412cb94', 'lostpasswordtmpl' => '33bd20d2-916c-1029-54ae-4e54c406c303', @@ -267,11 +269,11 @@ $sugar_config = array( ), 'portal_view' => 'single_user', 'require_accounts' => true, - 'resource_management' => - array( + 'resource_management' => + array ( 'special_query_limit' => 50000, - 'special_query_modules' => - array( + 'special_query_modules' => + array ( 0 => 'Reports', 1 => 'Export', 2 => 'Import', @@ -297,8 +299,8 @@ $sugar_config = array( 'stack_trace_errors' => false, 'sugar_version' => '6.0.4', 'sugarbeet' => 0, - 'time_formats' => - array( + 'time_formats' => + array ( 'H:i' => '23:00', 'h:ia' => '11:00pm', 'h:iA' => '11:00PM', @@ -311,8 +313,8 @@ $sugar_config = array( 'tracker_max_display_length' => 15, 'translation_string_prefix' => false, 'unique_key' => '2b00a93f1188f2ede3ecc6e98ecbab1c', - 'upload_badext' => - array( + 'upload_badext' => + array ( 0 => 'php', 1 => 'php3', 2 => 'php4', @@ -335,11 +337,4 @@ $sugar_config = array( 'vcal_time' => '2', 'verify_client_ip' => false, ); - - -if ($_SERVER['HTTP_HOST'] == 'localhost:8080') { - $sugar_config['dbconfig']['db_host_name'] = 'twinpol-mysql56'; - $sugar_config['dbconfig']['db_user_name'] = 'root'; - $sugar_config['dbconfig']['db_password'] = 'rootpassword'; -} - +?> diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php index f3aabea8..14b579a5 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php @@ -8,7 +8,7 @@ DELETE FROM ecommerce_invoices_products WHERE invoice_id IN ( DELETE FROM ecommerce_invoices WHERE origin='amazon b2b' AND register_date LIKE '2025-04-%'; */ -$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/04-2025.csv'; +$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv'; $handle = fopen($filename, 'r'); if ($handle === false) { die('Cannot open file: ' . $filename); diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/amazonWZ.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/amazonWZ.php index a2054f35..b89a55e6 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/amazonWZ.php +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/amazonWZ.php @@ -1,6 +1,6 @@ parent_address_city = 'Obrowo'; $invoice->type = 'normal'; - $date = '30.04.2025'; + $date = '31.05.2025'; $invoice->register_date = $date; $invoice->sell_date = $date; $invoice->validtill_date = $date; diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php index 8b569cf0..28cc8051 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php @@ -69,6 +69,7 @@ function getInvoices($source, $date, $type) $query .= " AND i.type='$type'"; } $query .= " ORDER BY i.register_date"; + $result = $db->query($query); $invoices = array(); while ($row = $db->fetchByAssoc($result)) { @@ -129,6 +130,20 @@ function exportToRewizor($source, $date, $type) $i['corrected_document_no'] = $fv['document_no']; $i['corrected_register_date'] = date("Ymd000000",strtotime(date('d.m.Y', strtotime($fv['register_date'])))); } + $i['vats'] = array(); + foreach ($i['products'] as $p) { + if (!isset($i['vats'][$p['vat_value']])) { + $i['vats'][$p['vat_value']] = array( + 'netto' => 0, + 'brutto' => 0, + 'vat' => 0, + ); + } + $i['vats'][$p['vat_value']]['netto'] += $p['price_netto'] * $p['quantity']; + $i['vats'][$p['vat_value']]['brutto'] += $p['price_brutto'] * $p['quantity']; + $i['vats'][$p['vat_value']]['vat'] += ($p['price_brutto'] - $p['price_netto']) * $p['quantity']; + $i['vats'][$p['vat_value']]['vat_value'] = $p['vat_value']; + } } $smarty->assign("data", $invoices); diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importBaselinkerInvoices.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importBaselinkerInvoices.php index f2199bf9..ecff635b 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importBaselinkerInvoices.php +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/importBaselinkerInvoices.php @@ -6,7 +6,6 @@ // FVKOR Polska - 17314 // FVKOR domyślna - 7689 - /* DELETE p FROM ecommerce_invoices_products p @@ -21,7 +20,7 @@ function importFV($seriesId) $IMPORT_START_ID = 1531694; - $dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'allegro' AND type = 'normal' AND series_id = '$seriesId' ORDER BY id DESC LIMIT 1"); + $dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'allegro' AND type = 'normal' AND series_id = '$seriesId' ORDER BY CAST(id AS UNSIGNED) DESC LIMIT 1"); $lastImportId = $db->fetchByAssoc($dbRes)['id']; if ($lastImportId == null) { $lastImportId = $IMPORT_START_ID; @@ -30,6 +29,7 @@ function importFV($seriesId) } $invoicesRes = loadInvoices($baselinker_config['token'], $lastImportId, $seriesId); + $invoices = $invoicesRes->invoices; usort($invoices, function ($a, $b) { @@ -205,7 +205,11 @@ function getInvoiceSource($token, $orderId) curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiParams)); $res = json_decode(curl_exec($curl)); - return $res->orders[0]->order_source; + if ($res->orders[0]->order_source != '') { + return $res->orders[0]->order_source; + } else { + return 'allegro'; //default + } } function getCorrectTotals($invoice) { diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl index c0c3eec1..b7e457e0 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl @@ -1,4 +1,4 @@ -[INFO] +[INFO] "1.05.4",0,1250,"Subiekt GT","GT","SubTest","Firma przykładowa systemu InsERT GT","Wrocław","54-445","Bławatkowa 25/3","111-111-11-11","MAG","Główny","Magazyn główny",,1,20170101000000,20170331000000,"Kowalski Jan",20170804155934,"Polska","PL",,0 {foreach from=$data item=i name=loop} @@ -6,7 +6,10 @@ "FS",1,0,0,"{$i.document_no}","FS","{$i.document_no}",,,"{$i.order_no}",,"{$i.parent_hash}","{$i.parent_short_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$i.parent_nip}","Sprzedaż",,"Obrowo","{$i.register_date}","{$i.sell_date}","{$i.register_date}",1,0,,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,,,,"{$i.sell_date}",{$i.total_brutto},{$i.total_brutto},0,0,0,0,"",,,,,"PLN",,"",,,,0,,0,,,,,"",, [ZAWARTOSC] - "23",23,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 + {foreach from=$i.vats item=vat name=vatloop} + "{$vat.vat_value}",{$vat.vat_value},{$vat.netto},{$vat.vat},{$vat.brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 + {/foreach} + {/foreach} diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl index f48e1792..b80ff8ff 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl @@ -1,4 +1,3 @@ - [INFO] "1.05.4",0,1250,"Subiekt GT","GT","SubTest","Firma przykładowa systemu InsERT GT","Wrocław","54-445","Bławatkowa 25/3","111-111-11-11","MAG","Główny","Magazyn główny",,1,20170101000000,20170331000000,"Kowalski Jan",20170804155934,"Polska","PL",,0 @@ -7,7 +6,10 @@ "KFS",1,0,0,"{$i.document_no}","FS","{$i.document_no}","{$i.corrected_document_no}","{$i.corrected_register_date}","{$i.order_no}",,"{$i.parent_hash}","{$i.parent_short_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$i.parent_nip}","Sprzedaż",,"Obrowo","{$i.register_date}","{$i.sell_date}","{$i.register_date}",1,0,,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,,,,"{$i.sell_date}",{$i.total_brutto},{$i.total_brutto},0,0,0,0,"",,,,,"PLN",,"",,,,0,,0,,,,,"",, [ZAWARTOSC] - "23",23,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 + {foreach from=$i.vats item=vat name=vatloop} + "{$vat.vat_value}",{$vat.vat_value},{$vat.netto},{$vat.vat},{$vat.brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 + {/foreach} + {/foreach} diff --git a/modules/EcmReports/ReportStocksDoc.php b/modules/EcmReports/ReportStocksDoc.php index 145adc6e..01b8a753 100644 --- a/modules/EcmReports/ReportStocksDoc.php +++ b/modules/EcmReports/ReportStocksDoc.php @@ -50,7 +50,7 @@ $i=0; $total_quantity=0; $total_value=0; while ($tmp2 = $db->fetchByAssoc($r1)) { - $r = $db->query("select * from ecmstockoperations where product_id='" . $tmp2['id'] . "' ".$add_where." and in_id is null and used=0 and type=0 order by counter asc"); + $r = $db->query("select * from ecmstockoperations where product_id='" . $tmp2['id'] . "' ".$add_where." and in_id is null and used=0 and type=0 and deleted=0 order by counter asc"); $l = 0; if ($r->num_rows > 0) { $docs[$i]['unit_id'] = $app_list_strings['ecmproducts_unit_dom'][$tmp2['unit_id']]; @@ -63,8 +63,9 @@ while ($tmp2 = $db->fetchByAssoc($r1)) { $i++; } while ($tmp = $db->fetchByAssoc($r)) { - + var_dump($tmp); $ii = $db->query( "select * from ecmstockoperations where in_id='" . $tmp['id'] ."' and type=1"); + echo "select * from ecmstockoperations where in_id='" . $tmp['id'] ."' and type=1"; if ($ii->num_rows > 0) { // licz ilość dla użytych $quantity_tmp = $tmp['quantity']; diff --git a/modules/EcmReports/RewizorGT/PurchaseCreator.php b/modules/EcmReports/RewizorGT/PurchaseCreator.php index c37f4208..226a94cc 100644 --- a/modules/EcmReports/RewizorGT/PurchaseCreator.php +++ b/modules/EcmReports/RewizorGT/PurchaseCreator.php @@ -14,8 +14,7 @@ class PurchaseCreator{ } public function getPurchases($type){ - //$query = "SELECT * FROM documents WHERE id='790f2a4d-28d7-e135-9be2-68408ca7279a'"; - //$query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0"; + $query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0"; if ($type == "new") { $query .= " and exported = 0"; } diff --git a/modules/EcmStockDocCorrects/Save.php b/modules/EcmStockDocCorrects/Save.php index 9a11a113..953e35a1 100755 --- a/modules/EcmStockDocCorrects/Save.php +++ b/modules/EcmStockDocCorrects/Save.php @@ -136,6 +136,7 @@ $return_id = $focus->id; $focus->ecommerce_invoices = $json->decode(htmlspecialchars_decode($_POST['ecommerce_invoices'])); if (isset($focus->ecommerce_invoices) && count($focus->ecommerce_invoices) > 0) { $db = $GLOBALS['db']; + $q = "UPDATE ecommerce_invoices SET ecmstockdoccorrect_id = '$return_id' WHERE id IN ('" . implode("','", $focus->ecommerce_invoices) . "')"; $db->query("UPDATE ecommerce_invoices SET ecmstockdoccorrect_id = '$return_id' WHERE id IN ('" . implode("','", $focus->ecommerce_invoices) . "')"); }