From e98caea4ed2d17041c73a55bbf074bcf207a047d Mon Sep 17 00:00:00 2001 From: Mika M Date: Mon, 11 Jul 2016 16:13:18 +0300 Subject: [PATCH 1/7] =?UTF-8?q?k=C3=A4ytet=C3=A4=C3=A4n=20samaa=20tietoa?= =?UTF-8?q?=20kuin=20l=C3=A4hett=C3=A4ess=C3=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php b/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php index 3963bb0333..a0e27da0cd 100644 --- a/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php +++ b/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php @@ -158,7 +158,12 @@ $eankoodi = $data['eankoodi']; $keratty = $data['keratty']; - if ($hhv) { + $posten_itemnumberfield = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); + + if (!empty($posten_itemnumberfield)) { + $tuotelisa = "AND tuote.{$posten_itemnumberfield} = '{$eankoodi}'"; + } + elseif ($hhv) { $tuotelisa = "AND tuote.tuoteno = '{$eankoodi}'"; } else { From f5801a02e5b08e90f90145928278be1e09d3af24 Mon Sep 17 00:00:00 2001 From: Mika M Date: Mon, 11 Jul 2016 17:35:37 +0300 Subject: [PATCH 2/7] posten_field-funktio --- inc/functions.inc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/inc/functions.inc b/inc/functions.inc index 55837c8e17..0ede12fe9a 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -27734,12 +27734,7 @@ if (!function_exists('posten_outbounddelivery')) { $_line_i = 1; - $posten_itemnumberfield = "tuoteno"; - $alt_posten_itemnumberfield = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); - - if (!empty($alt_posten_itemnumberfield)) { - $posten_itemnumberfield = $alt_posten_itemnumberfield; - } + $posten_itemnumberfield = posten_field('ItemNumber'); while ($looprow = mysql_fetch_assoc($loopres)) { @@ -33316,3 +33311,28 @@ if (!function_exists('pupesoft_a2ps')) { return $out_file; } } + +if (!function_exists('posten_field')) { + function posten_field($column_name) { + $key = ''; + + switch ($column_name) { + case "ItemNumber": + $key = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); + if (empty($key)) { + $key = 'tuoteno'; + } + break; + case "ProdGroup2": + $key = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ProdGroup2' ", '', '', "selitetark"); + if (empty($key)) { + $key = ''; + } + break; + default: + die(t("Annettu arvo ei ole kŠytšssŠ")); + } + + return $key; + } +} From 8d9ad9774916203fcfb5fd12a71ef4c17ff4b58d Mon Sep 17 00:00:00 2001 From: Mika M Date: Mon, 11 Jul 2016 17:36:14 +0300 Subject: [PATCH 3/7] =?UTF-8?q?k=C3=A4ytet=C3=A4=C3=A4n=20posten=5Ffield-f?= =?UTF-8?q?unktiota?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._kuittaus_ulkoisesta_jarjestelmasta_cron.php | 13 ++----------- synkronoi_tuotteet_ulkoiseen_jarjestelmaan.php | 17 +++-------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php b/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php index a0e27da0cd..552eede37c 100644 --- a/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php +++ b/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php @@ -158,17 +158,8 @@ $eankoodi = $data['eankoodi']; $keratty = $data['keratty']; - $posten_itemnumberfield = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); - - if (!empty($posten_itemnumberfield)) { - $tuotelisa = "AND tuote.{$posten_itemnumberfield} = '{$eankoodi}'"; - } - elseif ($hhv) { - $tuotelisa = "AND tuote.tuoteno = '{$eankoodi}'"; - } - else { - $tuotelisa = "AND tuote.eankoodi = '{$eankoodi}'"; - } + $posten_itemnumberfield = posten_field('ItemNumber'); + $tuotelisa = "AND tuote.{$posten_itemnumberfield} = '{$eankoodi}'"; $query = "SELECT tilausrivi.* FROM tilausrivi diff --git a/synkronoi_tuotteet_ulkoiseen_jarjestelmaan.php b/synkronoi_tuotteet_ulkoiseen_jarjestelmaan.php index 26fb980f92..cdc79ef4f5 100644 --- a/synkronoi_tuotteet_ulkoiseen_jarjestelmaan.php +++ b/synkronoi_tuotteet_ulkoiseen_jarjestelmaan.php @@ -132,24 +132,13 @@ $yksikko = substr($row['yksikko'], 0, 10); $tuoteno = substr($row['tuoteno'], 0, 100); - $posten_itemnumberfield = "tuoteno"; - $alt_posten_itemnumberfield = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); - - if (!empty($alt_posten_itemnumberfield)) { - $posten_itemnumberfield = $alt_posten_itemnumberfield; - } - - $posten_prodgroup2field = ""; - $alt_posten_prodgroup2field = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ProdGroup2' ", '', '', "selitetark"); - - if (!empty($alt_posten_prodgroup2field)) { - $posten_prodgroup2field = utf8_encode($row[$alt_posten_prodgroup2field]); - } + $posten_itemnumberfield = posten_field('ItemNumber'); + $posten_prodgroup2field = posten_field('ProdGroup2'); $line->addChild('ItemNumber', utf8_encode(substr($row[$posten_itemnumberfield], 0, 20))); $line->addChild('ItemName', utf8_encode($nimitys)); $line->addChild('ProdGroup1', utf8_encode($try)); - $line->addChild('ProdGroup2', $posten_prodgroup2field); + $line->addChild('ProdGroup2', utf8_encode($row[$posten_prodgroup2field])); $line->addChild('SalesPrice', ''); $line->addChild('Unit1', utf8_encode($yksikko)); $line->addChild('Unit2', ''); From 14c76e394f85c5e10cb4fea05467c36dafa56504 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 12 Jul 2016 09:18:18 +0300 Subject: [PATCH 4/7] charset --- inc/functions.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inc/functions.inc b/inc/functions.inc index 0ede12fe9a..6322e83657 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -27677,7 +27677,7 @@ if (!function_exists('posten_outbounddelivery')) { $_nimi = substr(trim($looprow['nimi'].' '.$looprow['nimitark']), 0, 50); $_osoite = substr($looprow['osoite'], 0, 50); - + $_postitp = substr($looprow['postitp'], 0, 30); $_maa = substr($looprow['maa'], 0, 10); $_postino = substr($looprow['postino'], 0, 10); @@ -33319,18 +33319,22 @@ if (!function_exists('posten_field')) { switch ($column_name) { case "ItemNumber": $key = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); + if (empty($key)) { $key = 'tuoteno'; } + break; case "ProdGroup2": $key = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ProdGroup2' ", '', '', "selitetark"); + if (empty($key)) { $key = ''; } + break; default: - die(t("Annettu arvo ei ole kŠytšssŠ")); + die(t("Annettu arvo ei ole käytössä")); } return $key; From d893380f24523ee1cd4f2ec520805bd7c1fa5b10 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 12 Jul 2016 09:26:04 +0300 Subject: [PATCH 5/7] turha muuttuja pois --- inc/functions.inc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/inc/functions.inc b/inc/functions.inc index 6322e83657..195cbaeb08 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -33314,19 +33314,18 @@ if (!function_exists('pupesoft_a2ps')) { if (!function_exists('posten_field')) { function posten_field($column_name) { - $key = ''; switch ($column_name) { - case "ItemNumber": - $key = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ItemNumber' ", '', '', "selitetark"); + case 'ItemNumber': + $key = t_avainsana('POSTEN_TKOODI', '', " and avainsana.selite = 'ItemNumber' ", '', '', 'selitetark'); if (empty($key)) { $key = 'tuoteno'; } break; - case "ProdGroup2": - $key = t_avainsana("POSTEN_TKOODI", '', " and avainsana.selite = 'ProdGroup2' ", '', '', "selitetark"); + case 'ProdGroup2': + $key = t_avainsana('POSTEN_TKOODI', '', " and avainsana.selite = 'ProdGroup2' ", '', '', 'selitetark'); if (empty($key)) { $key = ''; @@ -33334,7 +33333,7 @@ if (!function_exists('posten_field')) { break; default: - die(t("Annettu arvo ei ole käytössä")); + die(t('Annettu arvo ei ole käytössä')); } return $key; From a7c9f492dfe13a414d480a443d1a1eedac0b2423 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 12 Jul 2016 09:30:09 +0300 Subject: [PATCH 6/7] muuttuja uudelleennimetty --- kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php b/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php index 552eede37c..b14cde5045 100644 --- a/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php +++ b/kerayksen_kuittaus_ulkoisesta_jarjestelmasta_cron.php @@ -142,8 +142,8 @@ if (!isset($tilausrivit[$tilausrivin_tunnus])) { $tilausrivit[$tilausrivin_tunnus] = array( - 'eankoodi' => mysql_real_escape_string($line->ItemNumber), - 'keratty' => (float) $line->DeliveredQuantity + 'item_number' => mysql_real_escape_string($line->ItemNumber), + 'keratty' => (float) $line->DeliveredQuantity ); } else { @@ -155,11 +155,11 @@ foreach ($tilausrivit as $tilausrivin_tunnus => $data) { - $eankoodi = $data['eankoodi']; - $keratty = $data['keratty']; + $item_number = $data['item_number']; + $keratty = $data['keratty']; $posten_itemnumberfield = posten_field('ItemNumber'); - $tuotelisa = "AND tuote.{$posten_itemnumberfield} = '{$eankoodi}'"; + $tuotelisa = "AND tuote.{$posten_itemnumberfield} = '{$item_number}'"; $query = "SELECT tilausrivi.* FROM tilausrivi From 92b5ad80f8516ced8089f0c4711491023078d892 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 12 Jul 2016 09:36:15 +0300 Subject: [PATCH 7/7] =?UTF-8?q?estet=C3=A4=C3=A4n=20h=C3=A4kit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/functions.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.inc b/inc/functions.inc index 195cbaeb08..241d9c7cd2 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -33336,6 +33336,6 @@ if (!function_exists('posten_field')) { die(t('Annettu arvo ei ole käytössä')); } - return $key; + return mysql_real_escape_string($key); } }