tessera.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. var HttpClient = function() {
  2. this.get = function(aUrl, aCallback) {
  3. var anHttpRequest = new XMLHttpRequest();
  4. anHttpRequest.onreadystatechange = function() {
  5. if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
  6. aCallback(anHttpRequest.responseText);
  7. }
  8. anHttpRequest.open( "GET", aUrl, true );
  9. anHttpRequest.send( null );
  10. }
  11. }
  12. var client = new HttpClient();
  13. client.get('http://bufk.antandros.com.tr:9998/gosteriler', function(response) {
  14. // do something with response
  15. var gosteri_listesi = JSON.parse(response);
  16. for (var i = 0; i < gosteri_listesi.length; i++) {
  17. console.log(gosteri_listesi[i])
  18. var x = document.getElementById("gosteriler");
  19. var option = document.createElement("option");
  20. var tarih = gosteri_listesi[i]["tarih"];
  21. var saat = gosteri_listesi[i]["saat"];
  22. var yer = gosteri_listesi[i]["yer"];
  23. var tarih_pretty = tarih.slice(0,2) + "." + tarih.slice(2,4) + "." + tarih.slice(4,6);
  24. var saat_pretty = saat.slice(0,2) + ":" + saat.slice(2,4);
  25. var gosteri = tarih_pretty + " " + saat_pretty + " " + yer;
  26. option.text = gosteri;
  27. option.value = tarih;
  28. x.add(option);
  29. }
  30. });
  31. var sira = 'ABCDEFGHIJKLMNOPRST';
  32. var x = document.getElementById("sira");
  33. for(var harf in sira) {
  34. var option = document.createElement("option");
  35. option.text = sira[harf];
  36. option.value = sira[harf];
  37. x.add(option);
  38. }
  39. function numaraYukle(select){
  40. var selection = document.getElementById("sira");
  41. if(selection.value==='A'){
  42. for (var i = 1; i < 21; i++) {
  43. var x = document.getElementById('numara');
  44. var option = document.createElement("option");
  45. option.text = i;
  46. option.value = i;
  47. x.add(option);
  48. }
  49. } else if(select.value == 'B') {
  50. for (var i = 1; i < 24; i++) {
  51. var x = document.getElementById('numara');
  52. var option = document.createElement("option");
  53. option.text = i;
  54. option.value = i;
  55. x.add(option);
  56. }
  57. } else if(select.value == 'C') {
  58. for (var i = 1; i < 27; i++) {
  59. var x = document.getElementById('numara');
  60. var option = document.createElement("option");
  61. option.text = i;
  62. option.value = i;
  63. x.add(option);
  64. }
  65. } else if(select.value == 'D') {
  66. for (var i = 1; i < 27; i++) {
  67. var x = document.getElementById('numara');
  68. var option = document.createElement("option");
  69. option.text = i;
  70. option.value = i;
  71. x.add(option);
  72. }
  73. }else if(select.value == 'E') {
  74. for (var i = 1; i < 29; i++) {
  75. var x = document.getElementById('numara');
  76. var option = document.createElement("option");
  77. option.text = i;
  78. option.value = i;
  79. x.add(option);
  80. }
  81. }else if(select.value == 'F') {
  82. for (var i = 1; i < 29; i++) {
  83. var x = document.getElementById('numara');
  84. var option = document.createElement("option");
  85. option.text = i;
  86. option.value = i;
  87. x.add(option);
  88. }
  89. }else if(select.value == 'G') {
  90. for (var i = 1; i < 29; i++) {
  91. var x = document.getElementById('numara');
  92. var option = document.createElement("option");
  93. option.text = i;
  94. option.value = i;
  95. x.add(option);
  96. }
  97. }else if(select.value == 'H') {
  98. for (var i = 1; i < 29; i++) {
  99. var x = document.getElementById('numara');
  100. var option = document.createElement("option");
  101. option.text = i;
  102. option.value = i;
  103. x.add(option);
  104. }
  105. }else if(select.value == 'I') {
  106. for (var i = 1; i < 27; i++) {
  107. var x = document.getElementById('numara');
  108. var option = document.createElement("option");
  109. option.text = i;
  110. option.value = i;
  111. x.add(option);
  112. }
  113. }else if(select.value == 'J') {
  114. for (var i = 1; i < 27; i++) {
  115. var x = document.getElementById('numara');
  116. var option = document.createElement("option");
  117. option.text = i;
  118. option.value = i;
  119. x.add(option);
  120. }
  121. }else if(select.value == 'K') {
  122. for (var i = 1; i < 27; i++) {
  123. var x = document.getElementById('numara');
  124. var option = document.createElement("option");
  125. option.text = i;
  126. option.value = i;
  127. x.add(option);
  128. }
  129. }else if(select.value == 'L') {
  130. for (var i = 1; i < 27; i++) {
  131. var x = document.getElementById('numara');
  132. var option = document.createElement("option");
  133. option.text = i;
  134. option.value = i;
  135. x.add(option);
  136. }
  137. }else if(select.value == 'M') {
  138. for (var i = 1; i < 27; i++) {
  139. var x = document.getElementById('numara');
  140. var option = document.createElement("option");
  141. option.text = i;
  142. option.value = i;
  143. x.add(option);
  144. }
  145. }else if(select.value == 'N') {
  146. for (var i = 1; i < 27; i++) {
  147. var x = document.getElementById('numara');
  148. var option = document.createElement("option");
  149. option.text = i;
  150. option.value = i;
  151. x.add(option);
  152. }
  153. }else if(select.value == 'O') {
  154. for (var i = 1; i < 27; i++) {
  155. var x = document.getElementById('numara');
  156. var option = document.createElement("option");
  157. option.text = i;
  158. option.value = i;
  159. x.add(option);
  160. }
  161. }else if(select.value == 'P') {
  162. for (var i = 1; i < 27; i++) {
  163. var x = document.getElementById('numara');
  164. var option = document.createElement("option");
  165. option.text = i;
  166. option.value = i;
  167. x.add(option);
  168. }
  169. }else if(select.value == 'R') {
  170. for (var i = 1; i < 27; i++) {
  171. var x = document.getElementById('numara');
  172. var option = document.createElement("option");
  173. option.text = i;
  174. option.value = i;
  175. x.add(option);
  176. }
  177. }else if(select.value == 'S') {
  178. for (var i = 1; i < 27; i++) {
  179. var x = document.getElementById('numara');
  180. var option = document.createElement("option");
  181. option.text = i;
  182. option.value = i;
  183. x.add(option);
  184. }
  185. }else if(select.value == 'T') {
  186. for (var i = 1; i < 21; i++) {
  187. var x = document.getElementById('numara');
  188. var option = document.createElement("option");
  189. option.text = i;
  190. option.value = i;
  191. x.add(option);
  192. }
  193. } else{
  194. console.log("error");
  195. }
  196. }
  197. function satisYap() {
  198. var values = {};
  199. var x = document.getElementById("form");
  200. var inputs = x.elements;
  201. var gosteri = inputs[0].value;
  202. var sira = inputs[1].value;
  203. var numara = inputs[2].value;
  204. var kategori = inputs[3].value;
  205. var isim = inputs[4].value;
  206. var eposta = inputs[5].value;
  207. var telefon = inputs[6].value;
  208. var query = "/satis/" + gosteri + "/" + sira.toLowerCase() + numara + "/" + kategori + "/" + isim + "/" + eposta + "/" + telefon;
  209. var client = new HttpClient();
  210. client.get('http://bufk.antandros.com.tr:9998' + query, function(response) {
  211. document.getElementById("uyari").innerHTML = response;
  212. });
  213. }
  214. function rezerveEt() {
  215. var values = {};
  216. var x = document.getElementById("form");
  217. var inputs = x.elements;
  218. var gosteri = inputs[0].value;
  219. var sira = inputs[1].value;
  220. var numara = inputs[2].value;
  221. var kategori = inputs[3].value;
  222. var isim = inputs[4].value;
  223. var eposta = inputs[5].value;
  224. var telefon = inputs[6].value;
  225. var query = "/rezervasyon/" + gosteri + "/" + sira.toLowerCase() + numara + "/" + kategori + "/" + isim + "/" + eposta + "/" + telefon;
  226. var client = new HttpClient();
  227. client.get('http://bufk.antandros.com.tr:9998' + query, function(response) {
  228. document.getElementById("uyari").innerHTML = response;
  229. });
  230. }
  231. function satilanlar() {
  232. var donus = "";
  233. var gosteri_tarihi = document.getElementById("gosteriler").value;
  234. console.log(gosteri_tarihi);
  235. var client = new HttpClient();
  236. client.get('http://bufk.antandros.com.tr:9998/satilanlar/' + gosteri_tarihi, function(response) {
  237. // do something with response
  238. var satilan_biletler = JSON.parse(response);
  239. console.log(satilan_biletler);
  240. var col = [];
  241. for (var i = 0; i < satilan_biletler.length; i++) {
  242. for (var key in satilan_biletler[i]) {
  243. if (col.indexOf(key) === -1) {
  244. col.push(key);
  245. }
  246. }
  247. }
  248. var table = document.createElement("table");
  249. table.className = "table table-striped table-sm"
  250. var tr = table.insertRow(-1); // TABLE ROW.
  251. for (var i = 0; i < col.length; i++) {
  252. var th = document.createElement("th"); // TABLE HEADER.
  253. th.innerHTML = col[i];
  254. tr.appendChild(th);
  255. }
  256. for (var i = 0; i < satilan_biletler.length; i++) {
  257. tr = table.insertRow(-1);
  258. for (var j = 0; j < col.length; j++) {
  259. var tabCell = tr.insertCell(-1);
  260. tabCell.innerHTML = satilan_biletler[i][col[j]];
  261. }
  262. }
  263. var divContainer = document.getElementById("showData");
  264. divContainer.innerHTML = "";
  265. divContainer.appendChild(table);
  266. }
  267. );
  268. console.log(donus);
  269. }
  270. function rezervasyonlar() {
  271. var donus = "";
  272. var gosteri_tarihi = document.getElementById("gosteriler").value;
  273. console.log(gosteri_tarihi);
  274. var client = new HttpClient();
  275. client.get('http://bufk.antandros.com.tr:9998/rezervasyonlar/' + gosteri_tarihi, function(response) {
  276. // do something with response
  277. var rezerve_biletler = JSON.parse(response);
  278. console.log(rezerve_biletler);
  279. var col = [];
  280. for (var i = 0; i < rezerve_biletler.length; i++) {
  281. for (var key in rezerve_biletler[i]) {
  282. if (col.indexOf(key) === -1) {
  283. col.push(key);
  284. }
  285. }
  286. }
  287. var table = document.createElement("table");
  288. table.className = "table table-striped table-sm"
  289. var tr = table.insertRow(-1); // TABLE ROW.
  290. for (var i = 0; i < col.length; i++) {
  291. var th = document.createElement("th"); // TABLE HEADER.
  292. th.innerHTML = col[i];
  293. tr.appendChild(th);
  294. }
  295. for (var i = 0; i < rezerve_biletler.length; i++) {
  296. tr = table.insertRow(-1);
  297. for (var j = 0; j < col.length; j++) {
  298. var tabCell = tr.insertCell(-1);
  299. tabCell.innerHTML = rezerve_biletler[i][col[j]];
  300. }
  301. }
  302. var divContainer = document.getElementById("showData");
  303. divContainer.innerHTML = "";
  304. divContainer.appendChild(table);
  305. }
  306. );
  307. console.log(donus);
  308. }