PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/soapklient/opdat_vare.php

https://github.com/nielsrune/saldi
PHP | 142 lines | 87 code | 16 blank | 39 comment | 22 complexity | 38b84ea8b29f575e36ce9767bf731b55 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. // #----------------- opdat_vare.php -----ver 3.2.6---- 2012.01.14 ----------
  3. // LICENS
  4. //
  5. // Dette program er fri software. Du kan gendistribuere det og / eller
  6. // modificere det under betingelserne i GNU General Public License (GPL)
  7. // som er udgivet af The Free Software Foundation; enten i version 2
  8. // af denne licens eller en senere version efter eget valg.
  9. // Fra og med version 3.2.2 dog under iagttagelse af fřlgende:
  10. //
  11. // Programmet mĺ ikke uden forudgĺende skriftlig aftale anvendes
  12. // i konkurrence med DANOSOFT ApS eller anden rettighedshaver til programmet.
  13. //
  14. // Programmet er udgivet med haab om at det vil vaere til gavn,
  15. // men UDEN NOGEN FORM FOR REKLAMATIONSRET ELLER GARANTI. Se
  16. // GNU General Public Licensen for flere detaljer.
  17. //
  18. // En dansk oversaettelse af licensen kan laeses her:
  19. // http://www.fundanemt.com/gpl_da.html
  20. //
  21. // Copyright (c) 2004-2012 DANOSOFT ApS
  22. // ----------------------------------------------------------------------
  23. $vare_id=$_GET['vare_id'];
  24. $shop_id=$_GET['shop_id'];
  25. $varenr=$_GET['varenr'];
  26. $beskrivelse=$_GET['beskrivelse'];
  27. #cho "$beskrivelse<br>";
  28. $notes=$_GET['notes'];
  29. $kat_id=explode(chr(9),$_GET['kat_id']);
  30. $parent_kat_id==explode(chr(9),$_GET['parent_kat_id']);
  31. $kat=explode(chr(9),$_GET['kat']);
  32. $parent_kat==explode(chr(9),$_GET['parent_kat']);
  33. $shop_kat_id=explode(chr(9),$_GET['shop_kat_id']);
  34. $parent_shop_kat_id=explode(chr(9),$_GET['parent_shop_kat_id']);
  35. $publiceret=$_GET['publiceret'];
  36. $salgspris=$_GET['salgspris'];
  37. $beholdning=$_GET['beholdning'];
  38. $datotid=date("Y-m-d H:i:s");
  39. #cho count($shop_kat_id)."<br>";
  40. for($i=0;$i<=count($shop_kat_id);$i++) {
  41. #cho $shop_kat_id[$i]."<br>";
  42. }
  43. ($publiceret)?$status=1:$status=0;
  44. $beskrivelse=utf8_decode($beskrivelse);
  45. # $beskrivelse=htmlkod($beskrivelse);
  46. # $notes=htmlkod($notes);
  47. #cho "ID: $vare_id<br>Varenr: $varenr<br>Beskrivelse: $beskrivelse<br>Shop ID: $shop_id<br>";
  48. for ($i=0;$i<count($kategori);$i++) {
  49. #cho "Kategori: $kategori[$i]<br>Shop kat ID: $shop_kat_id[$i]<br>";
  50. }
  51. if ($vare_id&&$varenr&&$beskrivelse) {
  52. include("shop_connect.php");
  53. include("soapfunc.php");
  54. # logon($regnskab,$brugernavn,$adgangskode);
  55. $x=0;
  56. $shop_lang_id[$x]=$language_id;
  57. $q=mysql_query("select languages_id from languages where languages_id != '$language_id'") or die(mysql_error());
  58. while ($r=mysql_fetch_array($q)) {
  59. $x++;
  60. $shop_lang_id[$x]=$r['languages_id'];
  61. }
  62. $shop_lang_antal=$x;
  63. if ($shop_id && $r=mysql_fetch_array(mysql_query("select products_model from products where products_id = '$shop_id'"))){
  64. $products_id=$shop_id;
  65. #cho "produkt_id<br>";
  66. } else {
  67. if (!$r=mysql_fetch_array(mysql_query("select products_id from products where products_model = '$varenr'"))){
  68. mysql_query("insert into products(products_model,products_date_added,products_status) values ('$varenr','$datotid','1')");
  69. $r=mysql_fetch_array(mysql_query("select products_id from products where products_model = '$varenr'"));
  70. $products_id=$r['products_id'];
  71. mysql_query("insert into products_description(products_id,products_viewed,language_id) values ('$products_id','0','$language_id'");
  72. } else $products_id=$r['products_id'];
  73. }
  74. for ($x=1;$x<=$shop_lang_antal;$x++) { #Tjekker om produktbeskrivelser er oprettet i alle sprog og opretter hvis den ikke er.
  75. if (!mysql_fetch_array(mysql_query("select * from products_description where products_id='$products_id' and language_id='$shop_lang_id[$x]'"))) {
  76. mysql_query("insert into products_description(products_id,products_viewed,language_id) values ('$products_id','0','$shop_lang_id[$x]')");
  77. }
  78. }
  79. $fp=fopen("vareopdat.log","a");
  80. fwrite($fp,"update products set products_model='$varenr', products_price='$salgspris',products_quantity='$beholdning',products_tax_class_id='$products_tax_class_id',products_status='$status' where products_id='$products_id'\r\n");
  81. fwrite($fp,"update products_description set products_name='$beskrivelse',products_description,='$notes' where products_id='$products_id' and language_id='$language_id'\r\n");
  82. fclose($fp);
  83. #cho "update products set products_model='$varenr',products_price='$salgspris',products_quantity='$beholdning',products_tax_class_id='$products_tax_class_id' where products_id='$products_id'<br>";
  84. $tmp=mysql_query("update products set products_model='$varenr', products_price='$salgspris',products_quantity='$beholdning',products_tax_class_id='$products_tax_class_id',products_status='$status' where products_id='$products_id'");
  85. if (!$tmp) die('Fejl 1: ' . mysql_error());
  86. #cho "update products_description set products_name='$beskrivelse',products_description,='$notes' where products_id='$products_id' and language_id='$language_id'<br>";
  87. $tmp=mysql_query("update products_description set products_name='$beskrivelse' where products_id='$products_id' and language_id='$language_id'");
  88. if (!$tmp) die('Fejl 2: ' . mysql_error());
  89. for($i=0;$i<count($shop_kat_id);$i++) {
  90. $shop_kat_id[$i]*=1;
  91. #cho "i = $i $shop_kat_id[$i]<br>";
  92. if (!$r=mysql_fetch_array(mysql_query("select * from products_to_categories where categories_id='$shop_kat_id[$i]' and products_id='$products_id'"))){
  93. #cho "insert into products_to_categories(categories_id,products_id) values ('$shop_kat_id[$i]','$products_id')";
  94. $tmp=mysql_query("insert into products_to_categories(categories_id,products_id) values ('$shop_kat_id[$i]','$products_id')");
  95. if (!$tmp) die('Fejl 3: ' . mysql_error());
  96. }
  97. }
  98. #cho "update products_description(products_id='$products_id',products_name='$beskrivelse',products_description,='$notes') where products_id='$products_id' and language_id='$language_id'";
  99. #cho "select * from products_description where products_id = '$products_id' and language_id='$language_id'<br>";
  100. if (!$r=mysql_fetch_array(mysql_query("select * from products_description where products_id = '$products_id' and language_id='$language_id'"))) {
  101. #cho "insert into products_description(products_id,products_viewed) values ('$products_id','0')<br>";
  102. $tmp=mysql_query("insert into products_description (products_id,language_id,products_viewed) values ('$products_id','$language_id','0')");
  103. if (!$tmp) die('Fejl 4: ' . mysql_error());
  104. }
  105. #cho "update products_description set products_id='$products_id',products_name='$beskrivelse',products_description,='$notes' where products_id='$products_id' and language_id='$language_id'";
  106. $tmp=mysql_query("update products_description set products_id='$products_id',products_name='$beskrivelse' where products_id='$products_id' and language_id='$language_id'");
  107. if (!$tmp) die('Fejl 5: ' . mysql_error());
  108. if (!$shop_id) {
  109. include("saldi_connect.php");
  110. # include("soapfunc.php");
  111. list($errorcode,$s_id)=explode(chr(9),logon($regnskab,$brugernavn,$adgangskode));
  112. list($fejl,$svar)=explode(chr(9),singleinsert($s_id,"shop_varer (shop_id,saldi_id) values ('$products_id','$vare_id')"));
  113. logoff($s_id);
  114. }
  115. } else echo "vare ID mangler";
  116. function htmlkod($ord){
  117. $ord=str_replace("ć","&aelig;",$ord);
  118. $ord=str_replace("ř","&oslash;",$ord);
  119. $ord=str_replace("ĺ","&aring;",$ord);
  120. $ord=str_replace("Ć","&Aelig;",$ord);
  121. $ord=str_replace("Ř","&Oslash;",$ord);
  122. $ord=str_replace("Ĺ","&Aring;",$ord);
  123. return($ord);
  124. }
  125. print "<body onload=\"javascript:window.close();\">";
  126. ?>