admin_functions.js 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  1. var oldImageData = null;
  2. var step = 0;
  3. var temps = null;
  4. function forgotpass() {
  5. $('#forgotFRM').show();
  6. }
  7. function setOrderState(id,state) {
  8. if (id!=='' && state!=='') {
  9. $.post('/admin/orders/set/',{id: id, state: state},function(resp) {});
  10. }
  11. else {
  12. return false;
  13. }
  14. }
  15. function validateForm(frm,cropper,cropper2) {
  16. var inputError = false;
  17. var selector = frm+' input[data-validate]';
  18. $(selector).each(function() {
  19. if ($(this).val()=='') {
  20. inputError = true;
  21. $(this).addClass('field-error');
  22. }
  23. else {
  24. $(this).removeClass('field-error');
  25. }
  26. });
  27. if ($('#user_pass1').val()!='') {
  28. if ($('#user_pass1').val()!='' && $('#user_pass2').val()=='') {
  29. $('#user_pass1').addClass('field-error');
  30. $('#user_pass2').addClass('field-error');
  31. inputError = true;
  32. }
  33. else {
  34. $('#user_pass1').removeClass('field-error');
  35. $('#user_pass2').removeClass('field-error');
  36. }
  37. }
  38. if (!inputError) {
  39. /*if (cropper!=='' && cropper!==null) {
  40. var imageData = $(cropper).cropit('export');
  41. if (imageData) $('#tempContainer').val(imageData);
  42. }
  43. if (cropper2!=='' && cropper2!==null) {
  44. var imageData2 = $(cropper2).cropit('export');
  45. if (imageData2) $('#tempContainer2').val(imageData2);
  46. }*/
  47. $(frm).submit();
  48. }
  49. }
  50. function validateUser(frm,cropper,cropper2) {
  51. var inputError = false;
  52. var selector = frm+' input[data-validate]';
  53. $(selector).each(function() {
  54. if ($(this).val()=='') {
  55. inputError = true;
  56. $(this).addClass('field-error');
  57. }
  58. else {
  59. $(this).removeClass('field-error');
  60. }
  61. });
  62. if ($('#user_pass1').val()!='') {
  63. if ($('#user_pass1').val()!='' && $('#user_pass2').val()=='') {
  64. $('#user_pass1').addClass('field-error');
  65. $('#user_pass2').addClass('field-error');
  66. inputError = true;
  67. }
  68. else {
  69. $('#user_pass1').removeClass('field-error');
  70. $('#user_pass2').removeClass('field-error');
  71. }
  72. }
  73. if (!inputError) {
  74. var tableSelected = $('#mytable_hotels_selected').dataTable();
  75. var data = tableSelected.fnGetData(); // array of rows
  76. var names = [];
  77. var id = '';
  78. for (var i = 0; i < data.length; i++) {
  79. console.log(data[i][0]);
  80. id = $(data[i][0]).attr('data-id');
  81. names.push(id);
  82. }
  83. $('#selectedHotels').val(names);
  84. /*if (cropper!=='' && cropper!==null) {
  85. var imageData = $(cropper).cropit('export');
  86. if (imageData) $('#tempContainer').val(imageData);
  87. }
  88. if (cropper2!=='' && cropper2!==null) {
  89. var imageData2 = $(cropper2).cropit('export');
  90. if (imageData2) $('#tempContainer2').val(imageData2);
  91. }*/
  92. $(frm).submit();
  93. }
  94. }
  95. function setModuleRoleStatus(roleID,moduleID) {
  96. if (roleID!=='' && moduleID!=='') {
  97. var request = {
  98. roleID: roleID,
  99. moduleID: moduleID
  100. };
  101. $.post('/admin/roles/set',request,function(data) {
  102. return true;
  103. });
  104. }
  105. else {
  106. return false;
  107. }
  108. }
  109. function setUserState(userid) {
  110. if (userid!='') {
  111. var request = {
  112. user_id: userid
  113. };
  114. $.post('/admin/users/set',request,function(data) {
  115. return true;
  116. });
  117. }
  118. else {
  119. return false;
  120. }
  121. }
  122. function setUserDefaultMailer(userid) {
  123. if (userid!='') {
  124. var request = {
  125. user_id: userid
  126. };
  127. $.post('/admin/users/setdefaultmailer',request,function(data) {
  128. return true;
  129. });
  130. }
  131. else {
  132. return false;
  133. }
  134. }
  135. function updateTranslate(obj) {
  136. var code = obj.attr('data-lang-code');
  137. var key = obj.attr('data-lang-key');
  138. var text = obj.val();
  139. var hash = '#'+key;
  140. var request = {
  141. code: code,
  142. key: key,
  143. text: text
  144. };
  145. $.post('/admin/translator/set/',request,function(data) {
  146. obj.next('span').removeClass('hideme');
  147. setTimeout(function() {
  148. obj.next('span').addClass('hideme');
  149. },1000);
  150. });
  151. }
  152. function deleteGaleryItem(designID,galeryID) {
  153. var request = {
  154. id: designID,
  155. galery_id: galeryID
  156. };
  157. $.post('/admin/galery/delete/',request,function(data) {
  158. $('#galery').html(data);
  159. });
  160. }
  161. function changeMainDesign(designID,galeryID,obj) {
  162. var request = {
  163. id: designID,
  164. galery_id: galeryID
  165. };
  166. $.post('/admin/galery/set/',request,function(data) {
  167. $('#galery').html(data);
  168. });
  169. }
  170. function changePriceMode(obj) {
  171. var objValue = $(obj).attr('id');
  172. if (objValue!='') {
  173. if (objValue==='normal_price_selector') {
  174. $('#product_offer_price').attr('disabled','true');
  175. $('#product_price').removeAttr('disabled');
  176. }
  177. else {
  178. $('#product_offer_price').removeAttr('disabled');
  179. $('#product_price').attr('disabled','true');
  180. }
  181. }
  182. }
  183. function add_product_option(obj) {
  184. var pid = $(obj).attr('data-pid');
  185. $.get('/admin/products/newoption/?pid='+pid,function(data) {
  186. //$('#product_options_list').append(data);
  187. document.location.reload();
  188. });
  189. }
  190. function save_product_option(oid,tags) {
  191. var option_name_hash = '#option_name_'+oid;
  192. //var option_values_hash = '#option_options_'+oid;
  193. $.post('/admin/products/saveoption',{oid: oid, option_name: $(option_name_hash).val(), option_values: tags},function(data) {
  194. $('#variants_list').html(data);
  195. $('input[type="checkbox"]').iCheck({
  196. checkboxClass: 'icheckbox_flat-blue',
  197. radioClass: 'iradio_flat-blue'
  198. });
  199. });
  200. }
  201. function save_variation(obj) {
  202. if (obj) {
  203. var variation_id = $(obj).attr('data-id');
  204. var variation_data_type = $(obj).attr('name');
  205. var variation_data = $(obj).val();
  206. $.post('/admin/products/savevariation',{variation_id: variation_id, variation_data_type: variation_data_type, variation_data: variation_data},function(data) {
  207. });
  208. }
  209. else {
  210. return false;
  211. }
  212. }
  213. function set_variation_status(obj,state) {
  214. if (obj) {
  215. var variation_id = $(obj).attr('data-id');
  216. var variation_data_type = $(obj).attr('name');
  217. var variation_data = state;
  218. $.post('/admin/products/savevariation',{variation_id: variation_id, variation_data_type: variation_data_type, variation_data: variation_data},function(data) {
  219. });
  220. }
  221. }
  222. function delete_product_option(obj) {
  223. if (obj) {
  224. var option_id = $(obj).attr('data-oid');
  225. $.post('/admin/products/deleteoption',{option_id: option_id},function(data) {
  226. //alert(data);
  227. $(obj).parent('div').parent('div').remove('.row');
  228. $('#variants_list').html(data);
  229. $('input[type="checkbox"]').iCheck({
  230. checkboxClass: 'icheckbox_flat-blue',
  231. radioClass: 'iradio_flat-blue'
  232. });
  233. });
  234. }
  235. }
  236. function add_new_product_meta(obj) {
  237. var key = $('#new_meta_key').val();
  238. var value = $('#new_meta_value').val();
  239. var pid = $(obj).attr('data-pid');
  240. $.post('/admin/products/addmeta',{meta_key: key, meta_value: value, meta_pid: pid},function(data) {
  241. $('#product_meta_list').html(data);
  242. $('#new_meta_key').val('');
  243. $('#new_meta_value').val('');
  244. });
  245. }
  246. function delete_product_meta(obj) {
  247. var mid = $(obj).attr('data-mid');
  248. var pid = $(obj).attr('data-pid');
  249. $.post('/admin/products/deletemeta',{meta_id: mid, meta_pid: pid},function(data) {
  250. $('#product_meta_list').html(data);
  251. });
  252. }
  253. function save_product_meta_data(obj) {
  254. var mid = $(obj).attr('data-mid');
  255. var tipus = $(obj).attr('name');
  256. var data = $(obj).val();
  257. $.post('/admin/products/savemeta',{meta_id: mid, meta_field: tipus, meta_data: data},function(data) {
  258. });
  259. }
  260. function saveBannerImage() {
  261. validateForm('#bannerEditor',null,null);
  262. }
  263. function setLendingStatus(status) {
  264. $('#lending_status').val(status);
  265. return true;
  266. }
  267. function save_todo(param_type,param_value,todo_id) {
  268. var datum = $('#todo_date').val();
  269. var szoveg = $('#todo_text').val();
  270. if (szoveg!='') {
  271. if (param_type==='user') {
  272. $.post('/admin/todo/add',{todo_date: datum, todo_text: szoveg, todo_user_id: param_value, todo_id: todo_id},function(result) {
  273. window.location.reload();
  274. });
  275. }
  276. else {
  277. $.post('/admin/todo/add',{todo_date: datum, todo_text: szoveg, todo_lending_id: param_value, todo_id: todo_id},function(result) {
  278. window.location.reload();
  279. });
  280. }
  281. }
  282. }
  283. function delete_todo(todo_id) {
  284. $.post('/admin/todo/delete',{todo_id: todo_id},function(result) {
  285. window.location.reload();
  286. });
  287. }
  288. function update_input(obj,destination) {
  289. var objVal = $(obj).val();
  290. var objFilter = $(obj).attr('data-filter');
  291. if (objFilter!='') {
  292. objVal = Math.round(eval(objFilter));
  293. }
  294. $(destination).val(objVal);
  295. return true;
  296. }
  297. function finish_todo(obj) {
  298. var objID = $(obj).attr('data-id');
  299. var objState = $(obj).is(':checked');
  300. $.post('/admin/todo/finish',{todo_id: objID, state: objState},function(result) {});
  301. }
  302. function next_block() {
  303. var probe = step+1;
  304. var last = step;
  305. var next_hash = '#step_'+probe;
  306. var last_hash = '#step_'+last;
  307. var obj = $(next_hash);
  308. if (obj.length) {
  309. step++;
  310. $(obj).removeClass('inactive-list').addClass('active-list');
  311. $(last_hash).removeClass('active-list').addClass('inactive-list');
  312. $('.nextBtn').removeAttr('disabled');
  313. $('.prevBtn').removeAttr('disabled');
  314. check_for_prev_next();
  315. }
  316. else {
  317. $('.nextBtn').attr('disabled','true');
  318. }
  319. }
  320. function prev_block() {
  321. var probe = step-1;
  322. var last = step;
  323. var next_hash = '#step_'+probe;
  324. var last_hash = '#step_'+last;
  325. var obj = $(next_hash);
  326. if (obj.length) {
  327. step--;
  328. $(obj).removeClass('inactive-list').addClass('active-list');
  329. $(last_hash).removeClass('active-list').addClass('inactive-list');
  330. $('.nextBtn').removeAttr('disabled');
  331. $('.prevBtn').removeAttr('disabled');
  332. check_for_prev_next();
  333. }
  334. else {
  335. $('.prevBtn').attr('disabled','true');
  336. }
  337. }
  338. function check_for_prev_next() {
  339. var probe = step+1;
  340. var last = step;
  341. var next_hash = '#step_'+probe;
  342. var last_hash = '#step_'+last;
  343. var obj = $(next_hash);
  344. if (obj.length) {
  345. $('.nextBtn').removeAttr('disabled');
  346. }
  347. else {
  348. $('.nextBtn').attr('disabled','true');
  349. }
  350. probe = step-1;
  351. last = step;
  352. next_hash = '#step_'+probe;
  353. last_hash = '#step_'+last;
  354. obj = $(next_hash);
  355. if (obj.length) {
  356. $('.prevBtn').removeAttr('disabled');
  357. }
  358. else {
  359. $('.prevBtn').attr('disabled','true');
  360. }
  361. }
  362. function show_works_add() {
  363. $('#workEditor').slideDown('fast');
  364. }
  365. function update_field(obj,table,field,id,key,currency) {
  366. var new_value = $(obj).val();
  367. $.post('/admin/updater/save',{
  368. table: table,
  369. field: field,
  370. id: id,
  371. value: new_value,
  372. key: key,
  373. currency: currency
  374. },function(result){
  375. $(obj).parent('td').removeClass('in-edit');
  376. $(obj).parent('td').html(result);
  377. });
  378. }
  379. function simple_update_field(obj,table,field,id,key,category) {
  380. var new_value = $(obj).val();
  381. $.post('/admin/factors/save',{
  382. table: table,
  383. field: field,
  384. id: id,
  385. value: new_value,
  386. key: key,
  387. category: category
  388. },function(result){});
  389. }
  390. function update_multiple_field(obj,table,field,id,key,currency) {
  391. var new_value = $(obj).val();
  392. $.post('/admin/multiupdater/save',{
  393. table: table,
  394. field: field,
  395. id: id,
  396. value: new_value,
  397. key: key,
  398. currency: currency
  399. },function(result){
  400. $(obj).parent('td').removeClass('in-edit');
  401. $(obj).parent('td').html(result);
  402. });
  403. }
  404. function update_field_by_object(obj,recolor,reload) {
  405. var new_value = $(obj).val();
  406. var id = $(obj).attr('data-id');
  407. var key = $(obj).attr('data-key');
  408. var table = $(obj).attr('data-table');
  409. var field = $(obj).attr('name');
  410. var is_radio = $(obj).attr('type');
  411. if ($(obj).parent('button').hasClass('radiobtn')) {
  412. if ($(obj).parent('button').children('i').hasClass('fa-dot-circle-o')) {
  413. new_value = '1';
  414. if (recolor==='true') {
  415. $(obj).parent('button').parent('td').parent('tr').removeClass('uj-elem');
  416. }
  417. }
  418. else {
  419. new_value = '2';
  420. if (recolor==='true') {
  421. $(obj).parent('button').parent('td').parent('tr').addClass('uj-elem');
  422. }
  423. }
  424. }
  425. $.post('/admin/updater/save/',{
  426. table: table,
  427. field: field,
  428. id: id,
  429. value: new_value,
  430. key: key
  431. },function(result) {
  432. if (reload==='true') {
  433. window.location.reload();
  434. }
  435. });
  436. }
  437. function update_bill_image(id,obj) {
  438. var filename = $('.uploadedFile').val();
  439. $.post('/admin/bills/updatefile/',{
  440. id: id,
  441. filename: filename
  442. },function(response){
  443. window.location.reload();
  444. });
  445. }
  446. function update_bill(id,obj) {
  447. var filename = $('.uploadedFile').val();
  448. $.post('/admin/costlist/updatebill/',{
  449. id: id,
  450. filename: filename
  451. },function(response){
  452. window.location.reload();
  453. });
  454. }
  455. function update_rajz_image(id,obj) {
  456. var filename = $('.uploadedFile').val();
  457. if (filename!=='') {
  458. $.post('/admin/rajzok/updatefile/',{
  459. id: id,
  460. filename: filename
  461. },function(response){
  462. window.location.reload();
  463. });
  464. }
  465. }
  466. function update_document(id,obj) {
  467. var filename = $('.uploadedFile').val();
  468. $.post('/admin/beszerzes/updatedoc/',{
  469. id: id,
  470. filename: filename
  471. },function(response){
  472. window.location.reload();
  473. });
  474. }
  475. function show_partner_add() {
  476. $('#partnerEditor').toggle('fast');
  477. }
  478. function show_client_add() {
  479. $('#clientEditor').toggle('fast');
  480. }
  481. function show_bill_add() {
  482. $('#editor_form').slideDown('fast');
  483. }
  484. function show_rajz_add() {
  485. $('#editor_form').toggle('fast');
  486. }
  487. function show_beszerzes_add() {
  488. $('#editor_form').toggle();
  489. $('#beszerzesEditor').slideDown('fast');
  490. $('#beszer_uploader').slideDown('fast');
  491. }
  492. function show_group_add(group) {
  493. if (group!=='') {
  494. $('#'+group).toggle('fast');
  495. }
  496. else {
  497. return false;
  498. }
  499. }
  500. function export_xlsx() {
  501. $.post('/admin/costlist/export',function(response) {
  502. window.location=response;
  503. });
  504. }
  505. function export_gyartas_xlsx() {
  506. $.post('/admin/gyartas/export',function(response) {
  507. window.location=response;
  508. });
  509. }
  510. function remove_filter() {
  511. window.location='/admin/costlist/clear';
  512. }
  513. function assign_partner(obj) {
  514. var base_id = $(obj).attr('data-base-id');
  515. var dest_id = $(obj).val();
  516. if (window.confirm('Figyelem! Valóban egyesíteni kívánja a két partnert?')) {
  517. $.post('/admin/partners/assign/',{
  518. base_id: base_id,
  519. dest_id: dest_id
  520. },function(response) {
  521. window.location.reload();
  522. });
  523. }
  524. }
  525. function assign_client(obj) {
  526. var base_id = $(obj).attr('data-base-id');
  527. var dest_id = $(obj).val();
  528. if (window.confirm('Figyelem! Valóban egyesíteni kívánja a két ügyfelet?')) {
  529. $.post('/admin/clients/assign/',{
  530. base_id: base_id,
  531. dest_id: dest_id
  532. },function(response) {
  533. window.location.reload();
  534. });
  535. }
  536. }
  537. function change_currency(obj) {
  538. var actual_currency = $(obj).val();
  539. $.post('/admin/costlist/setcurrency/',{
  540. currency: actual_currency
  541. },function(response){
  542. $('.currency').html(actual_currency);
  543. if (actual_currency!=='HUF') {
  544. $('#arfolyam').show();
  545. $('#egyseg_arfolyam').show();
  546. }
  547. else {
  548. $('#arfolyam').hide();
  549. $('#egyseg_arfolyam').hide();
  550. }
  551. });
  552. }
  553. function set_currency_field(obj) {
  554. var new_value = $(obj).val();
  555. var id = $(obj).attr('data-id');
  556. var key = $(obj).attr('data-key');
  557. var table = $(obj).attr('data-table');
  558. var field = $(obj).attr('name');
  559. $.post('/admin/updater/save',{
  560. table: table,
  561. field: field,
  562. id: id,
  563. value: new_value,
  564. key: key
  565. },function(result){});
  566. }
  567. function radiobtn_set_state(obj) {
  568. var state = $(obj).val();
  569. var on_state = $(obj).attr('data-on-value');
  570. var off_state = $(obj).attr('data-off-value');
  571. var default_state = $(obj).attr('data-default-value');
  572. var on_icon = $(obj).attr('data-on-icon');
  573. var off_icon = $(obj).attr('data-off-icon');
  574. var default_icon = $(obj).attr('data-default-icon');
  575. if (state===default_state) {
  576. $(obj).val(default_state);
  577. $(obj).children('span').html(default_state);
  578. $(obj).children('i').attr('class','fa');
  579. $(obj).children('i').addClass(default_icon);
  580. $(obj).children('input[type=hidden]').val(default_state);
  581. }
  582. else if (state===on_state) {
  583. $(obj).val(on_state);
  584. $(obj).children('span').html(on_state);
  585. $(obj).children('i').attr('class','fa');
  586. $(obj).children('i').addClass(on_icon);
  587. $(obj).children('input[type=hidden]').val(on_state);
  588. }
  589. else if (state===off_state) {
  590. $(obj).val(off_state);
  591. $(obj).children('span').html(off_state);
  592. $(obj).children('i').attr('class','fa');
  593. $(obj).children('i').addClass(off_icon);
  594. $(obj).children('input[type=hidden]').val(off_state);
  595. }
  596. }
  597. function checkbtn_set_state(obj) {
  598. var state = $(obj).val();
  599. var on_state = $(obj).attr('data-on-value');
  600. var off_state = $(obj).attr('data-off-value');
  601. var default_state = $(obj).attr('data-default-value');
  602. var on_icon = $(obj).attr('data-on-icon');
  603. var off_icon = $(obj).attr('data-off-icon');
  604. var default_icon = $(obj).attr('data-default-icon');
  605. if (state===default_state) {
  606. $(obj).val(default_state);
  607. $(obj).children('span').html(default_state);
  608. $(obj).children('i').attr('class','fa');
  609. $(obj).children('i').addClass(default_icon);
  610. }
  611. else if (state===on_state) {
  612. $(obj).val(on_state);
  613. $(obj).children('span').html(on_state);
  614. $(obj).children('i').attr('class','fa');
  615. $(obj).children('i').addClass(on_icon);
  616. }
  617. else if (state===off_state) {
  618. $(obj).val(off_state);
  619. $(obj).children('span').html(off_state);
  620. $(obj).children('i').attr('class','fa');
  621. $(obj).children('i').addClass(off_icon);
  622. }
  623. else {
  624. $(obj).val(default_state);
  625. $(obj).children('span').html(default_state);
  626. $(obj).children('i').attr('class','fa');
  627. $(obj).children('i').addClass(default_icon);
  628. }
  629. }
  630. function checkbtn_change_state(obj) {
  631. var active_state = $(obj).attr('value');
  632. var on_state = $(obj).attr('data-on-value');
  633. var off_state = $(obj).attr('data-off-value');
  634. var default_state = $(obj).attr('data-default-value');
  635. var on_icon = $(obj).attr('data-on-icon');
  636. var off_icon = $(obj).attr('data-off-icon');
  637. var default_icon = $(obj).attr('data-default-icon');
  638. if (active_state===default_state || active_state==='') {
  639. $(obj).val(on_state);
  640. $(obj).children('span').html(on_state);
  641. $(obj).children('i').attr('class','fa');
  642. $(obj).children('i').addClass(on_icon);
  643. $(obj).children('input[type=hidden]').val(on_state);
  644. }
  645. else if (active_state===on_state) {
  646. $(obj).val(off_state);
  647. $(obj).children('span').html(off_state);
  648. $(obj).children('i').attr('class','fa');
  649. $(obj).children('i').addClass(off_icon);
  650. $(obj).children('input[type=hidden]').val(off_state);
  651. }
  652. else if (active_state===off_state) {
  653. $(obj).val(default_state);
  654. $(obj).children('span').html(default_state);
  655. $(obj).children('i').attr('class','fa');
  656. $(obj).children('i').addClass(default_icon);
  657. $(obj).children('input[type=hidden]').val(default_state);
  658. }
  659. }
  660. function radiobtn_change_state(obj,event_trigger,reloader) {
  661. var active_state = $(obj).val();
  662. var on_state = $(obj).attr('data-on-value');
  663. var off_state = $(obj).attr('data-off-value');
  664. var default_state = $(obj).attr('data-default-value');
  665. var on_icon = $(obj).attr('data-on-icon');
  666. var off_icon = $(obj).attr('data-off-icon');
  667. var default_icon = $(obj).attr('data-default-icon');
  668. if (active_state===on_state) {
  669. $(obj).val(off_state);
  670. $(obj).children('span').html(off_state);
  671. $(obj).children('i').attr('class','fa');
  672. $(obj).children('i').addClass(off_icon);
  673. $(obj).children('input[type=hidden]').val(off_state);
  674. $(obj).removeClass('btn-success');
  675. $(obj).addClass('btn-info');
  676. }
  677. else if (active_state===off_state) {
  678. $(obj).val(on_state);
  679. $(obj).children('span').html(on_state);
  680. $(obj).children('i').attr('class','fa');
  681. $(obj).children('i').addClass(on_icon);
  682. $(obj).children('input[type=hidden]').val(on_state);
  683. $(obj).removeClass('btn-info');
  684. $(obj).addClass('btn-success');
  685. }
  686. if (event_trigger===true) {
  687. $(obj).children('input[type=hidden]').trigger('change');
  688. }
  689. }
  690. function set_currency_field(obj) {
  691. }
  692. function show_partner_details(partner_details,obj) {
  693. if ($(partner_details).css('display')==='block') {
  694. $('.partner-details').hide();
  695. }
  696. else {
  697. $('.partner-details').hide();
  698. $(partner_details).show();
  699. }
  700. }
  701. function show_client_details(client_details,obj) {
  702. if ($(client_details).css('display')==='block') {
  703. $('.client-details').hide();
  704. }
  705. else {
  706. $('.client-details').hide();
  707. $(client_details).show();
  708. }
  709. }
  710. function editable(obj,update_parts) {
  711. if (!$(obj).hasClass('in-edit')) {
  712. $(obj).addClass('in-edit');
  713. var actual_value = $(obj).html();
  714. console.log(actual_value);
  715. var currency = $(obj).attr('data-currency');
  716. if (currency==='true') {
  717. actual_value = actual_value.replace(",- Ft","");
  718. actual_value = actual_value.replace(" ","");
  719. }
  720. var field_name = $(obj).attr('data-field');
  721. var table_name = $(obj).attr('data-table');
  722. var row_id = $(obj).attr('data-id');
  723. var key = $(obj).attr('data-key');
  724. if (update_parts==true) {
  725. $(obj).html('<input style="width: 100%;" type="text" name="'+field_name+'" id="'+field_name+'" value="'+actual_value+'" class="form-control edit" onblur="javascript: update_field($(this),\''+table_name+'\',\''+field_name+'\',\''+row_id+'\',\''+key+'\',\''+currency+'\'); window.location=\'/admin/rendelesek/\';">');
  726. }
  727. else {
  728. $(obj).html('<input style="width: 100%;" type="text" name="'+field_name+'" id="'+field_name+'" value="'+actual_value+'" class="form-control edit" onblur="javascript: update_field($(this),\''+table_name+'\',\''+field_name+'\',\''+row_id+'\',\''+key+'\',\''+currency+'\');">');
  729. }
  730. $('#'+field_name).focus();
  731. }
  732. }
  733. function multiple_editable(obj) {
  734. if (!$(obj).hasClass('in-edit')) {
  735. $(obj).addClass('in-edit');
  736. var actual_value = $(obj).html();
  737. console.log(actual_value);
  738. var currency = $(obj).attr('data-currency');
  739. if (currency==='true') {
  740. actual_value = actual_value.replace(",- Ft","");
  741. actual_value = actual_value.replace(" ","");
  742. }
  743. var field_name = $(obj).attr('data-field');
  744. var table_name = $(obj).attr('data-table');
  745. var row_id = $(obj).attr('data-id');
  746. var key = $(obj).attr('data-key');
  747. $(obj).html('<input type="text" name="'+field_name+'" id="'+field_name+'" value="'+actual_value+'" class="form-control edit" onblur="update_multiple_field($(this),\''+table_name+'\',\''+field_name+'\',\''+row_id+'\',\''+key+'\',\''+currency+'\')">');
  748. $('#'+field_name).focus();
  749. }
  750. }
  751. function open_upload(obj) {
  752. $(obj).parent('div').children('.myuploader').click();
  753. }
  754. function start_upload(obj) {
  755. var input = obj;
  756. var files = input.files;
  757. var data = new FormData();
  758. var id = $(obj).attr('data-id');
  759. $.each(files, function(key, value) {
  760. data.append(key, value);
  761. });
  762. data.append('id',id);
  763. var old = $(obj).parent('div').children('.uploder').html();
  764. $(obj).parent('div').children('.uploder').html('<i class="fa fa-circle-o-notch fa-spin"></i>');
  765. $.ajax({
  766. url: '/admin/bills/updatefile/',
  767. type: 'POST',
  768. data: data,
  769. cache: false,
  770. processData: false,
  771. contentType: false,
  772. success: function(resp) {
  773. $(obj).parent('div').children('.uploder').html('<i class="fa fa-check"></i>');
  774. $(obj).parent('div').children('.bill-image').attr('href',resp);
  775. $(obj).parent('div').children('.bill-image').children('button').children('i').attr('class','fa fa-eye');
  776. var clearIcon = setInterval(function() {
  777. $(obj).parent('div').children('.uploder').html(old);
  778. clearInterval(clearIcon);
  779. },3000);
  780. }
  781. });
  782. }
  783. function start_upload_rajz(obj) {
  784. var input = obj;
  785. var files = input.files;
  786. var data = new FormData();
  787. var id = $(obj).attr('data-id');
  788. $.each(files, function(key, value) {
  789. data.append(key, value);
  790. });
  791. data.append('id',id);
  792. var old = $(obj).parent('div').children('.uploder').html();
  793. $(obj).parent('div').children('.uploder').html('<i class="fa fa-circle-o-notch fa-spin"></i>');
  794. $.ajax({
  795. url: '/admin/rajzok/updatefile/',
  796. type: 'POST',
  797. data: data,
  798. cache: false,
  799. processData: false,
  800. contentType: false,
  801. success: function(resp) {
  802. $(obj).parent('div').children('.uploder').html('<i class="fa fa-check"></i>');
  803. $(obj).parent('div').children('.bill-image').attr('href',resp);
  804. var clearIcon = setInterval(function() {
  805. $(obj).parent('div').children('.uploder').html(old);
  806. clearInterval(clearIcon);
  807. },3000);
  808. }
  809. });
  810. }
  811. function start_upload_document(obj) {
  812. var input = obj;
  813. var files = input.files;
  814. var data = new FormData();
  815. var id = $(obj).attr('data-id');
  816. $.each(files, function(key, value) {
  817. data.append(key, value);
  818. });
  819. data.append('id',id);
  820. data.append('MAX_FILE_SIZE','90000000');
  821. var old = $(obj).parent('div').children('.uploder').html();
  822. $(obj).parent('div').children('.uploder').html('<i class="fa fa-circle-o-notch fa-spin"></i>');
  823. $.ajax({
  824. url: '/admin/sales/updatefile/',
  825. type: 'POST',
  826. data: data,
  827. cache: false,
  828. processData: false,
  829. contentType: false,
  830. success: function(resp) {
  831. $(obj).parent('div').children('.uploder').html('<i class="fa fa-check"></i>');
  832. $(obj).parent('div').children('.bill-image').attr('href',resp);
  833. var clearIcon = setInterval(function() {
  834. $(obj).parent('div').children('.uploder').html(old);
  835. clearInterval(clearIcon);
  836. },3000);
  837. }
  838. });
  839. }
  840. function start_upload_techno(obj) {
  841. var input = obj;
  842. var files = input.files;
  843. var data = new FormData();
  844. var id = $(obj).attr('data-id');
  845. $.each(files, function(key, value) {
  846. data.append(key, value);
  847. });
  848. data.append('id',id);
  849. var old = $(obj).parent('div').children('.uploder').html();
  850. $(obj).parent('div').children('.uploder').html('<i class="fa fa-circle-o-notch fa-spin"></i>');
  851. $.ajax({
  852. url: '/admin/techno/updatefile/',
  853. type: 'POST',
  854. data: data,
  855. cache: false,
  856. processData: false,
  857. contentType: false,
  858. success: function(resp) {
  859. $(obj).parent('div').children('.uploder').html('<i class="fa fa-check"></i>');
  860. $(obj).parent('div').children('.bill-image').attr('href',resp);
  861. var clearIcon = setInterval(function() {
  862. $(obj).parent('div').children('.uploder').html(old);
  863. clearInterval(clearIcon);
  864. },3000);
  865. }
  866. });
  867. }
  868. function start_upload_beszer(obj) {
  869. var input = obj;
  870. var files = input.files;
  871. var data = new FormData();
  872. var id = $(obj).attr('data-id');
  873. $.each(files, function(key, value) {
  874. data.append(key, value);
  875. });
  876. data.append('id',id);
  877. var old = $(obj).parent('div').children('.uploder').html();
  878. $(obj).parent('div').children('.uploder').html('<i class="fa fa-circle-o-notch fa-spin"></i>');
  879. $.ajax({
  880. url: '/admin/beszerzes/updatedoc/',
  881. type: 'POST',
  882. data: data,
  883. cache: false,
  884. processData: false,
  885. contentType: false,
  886. success: function(resp) {
  887. $(obj).parent('div').children('.uploder').html('<i class="fa fa-check"></i>');
  888. $(obj).parent('div').children('.bill-image').attr('href',resp);
  889. var clearIcon = setInterval(function() {
  890. $(obj).parent('div').children('.uploder').html(old);
  891. clearInterval(clearIcon);
  892. },3000);
  893. }
  894. });
  895. }
  896. function show_bill(e,obj) {
  897. e.preventDefault();
  898. $(obj).orangeBox('create');
  899. }
  900. function scroll_left(obj) {
  901. $('#scroller').scrollLeft($('#scroller').scrollLeft()-100);
  902. }
  903. function scroll_right() {
  904. $('#scroller').scrollLeft($('#scroller').scrollLeft()+100);
  905. }
  906. function set_kategoria_state() {
  907. var act = $('#cost_type_id').val();
  908. if (act==='9' || act==='11') {
  909. $('#cost_category_id').val('');
  910. $('#cost_category_id').attr('disabled','true');
  911. }
  912. else {
  913. $('#cost_category_id').removeAttr('disabled');
  914. }
  915. }
  916. function set_filters_partner(obj) {
  917. var values = $(obj).val();
  918. if (values!==null) {
  919. $('#clients_filter').hide();
  920. temps = $('#filter_forras').children('optgroup[label="bevétel"]');
  921. $('#filter_forras').children('optgroup[label="bevétel"]').remove();
  922. $(".mypayment").select2({placeholder: 'Válasszon fizetési módot!'});
  923. }
  924. else {
  925. $('#clients_filter').show();
  926. $('#filter_forras').prepend(temps);
  927. $(".mypayment").select2({placeholder: 'Válasszon fizetési módot!'});
  928. }
  929. }
  930. function set_filters_client(obj) {
  931. var values = $(obj).val();
  932. if (values!==null) {
  933. $('#partners_filter').hide();
  934. temps = $('#filter_forras').children('optgroup[label="kiadás"]');
  935. $('#filter_forras').children('optgroup[label="kiadás"]').remove();
  936. $(".mypayment").select2({placeholder: 'Válasszon fizetési módot!'});
  937. }
  938. else {
  939. $('#partners_filter').show();
  940. $('#filter_forras').append(temps);
  941. $(".mypayment").select2({placeholder: 'Válasszon fizetési módot!'});
  942. }
  943. }
  944. function client_text(obj) {
  945. var value = $(obj).val();
  946. if (value!=='' && value!=='undefined' && value!==null) {
  947. $('#cost_partner').attr('disabled','true');
  948. $('#cost_type_id').children('option[value=7]').hide();
  949. $('#cost_type_id').children('option[value="12"]').hide();
  950. $('#cost_type_id').children('option[value="44"]').hide();
  951. $('#cost_category_id').attr('disabled','true');
  952. }
  953. else {
  954. $('#cost_partner').removeAttr('disabled');
  955. $('#cost_type_id').children('option[value=7]').show();
  956. $('#cost_type_id').children('option[value="12"]').show();
  957. $('#cost_type_id').children('option[value="44"]').show();
  958. $('#cost_category_id').removeAttr('disabled');
  959. }
  960. }
  961. function partner_text(obj) {
  962. var value = $(obj).val();
  963. if (value!=='' && value!=='undefined' && value!==null) {
  964. $('#cost_client').attr('disabled','true');
  965. $('#cost_type_id').children('option[value="9"]').hide();
  966. $('#cost_type_id').children('option[value="11"]').hide();
  967. }
  968. else {
  969. $('#cost_client').removeAttr('disabled');
  970. $('#cost_type_id').children('option[value="9"]').show();
  971. $('#cost_type_id').children('option[value="11"]').show();
  972. }
  973. }
  974. function set_egyseg_forall() {
  975. var egyseg = $('#rajz_egyseg :selected').html();
  976. $('#rajz_min_rendeles').next('span').html(egyseg);
  977. $('#rajz_alert').next('span').html(egyseg);
  978. }
  979. function add_alkatresz(obj,reszegyseg,altipus) {
  980. $.post('/admin/gyartas/addalkatresz/',{
  981. reszegyseg: reszegyseg,
  982. altipus: altipus
  983. },function(resp) {
  984. window.location.reload();
  985. });
  986. }
  987. function add_altipus(obj,reszegyseg) {
  988. $.post('/admin/gyartas/addaltipus/',{
  989. reszegyseg: reszegyseg
  990. },function(resp) {
  991. window.location.reload();
  992. });
  993. }
  994. function add_reszegyseg(obj) {
  995. $.post('/admin/gyartas/addreszegyseg/',{},function(resp) {
  996. window.location.reload();
  997. });
  998. }
  999. function allocate_parts(id) {
  1000. window.location='/admin/rendelesek/allocate/?id='+id;
  1001. // $.post('/admin/rendelesek/allocate/',{
  1002. // id: id
  1003. // },function(response) {
  1004. // window.location.reload();
  1005. // });
  1006. }
  1007. function get_gep_data(gep) {
  1008. $.post('/admin/gyartas/gepinfo/',{gep: gep},function(response) {
  1009. $('#dialog').html(response);
  1010. $('.wrapper').addClass('blur');
  1011. $('#dialog').modal({
  1012. escapeClose: true,
  1013. clickClose: true,
  1014. showClose: true
  1015. });
  1016. });
  1017. }
  1018. function get_cikknev_data(obj,target) {
  1019. $.post('/admin/autocomplete/getcikknev/',{value: $(obj).val()},function(resp) {
  1020. if (resp=='') {
  1021. $(target).removeAttr('disabled');
  1022. }
  1023. else {
  1024. $(target).val(resp);
  1025. $(target).attr('disabled','true');
  1026. }
  1027. });
  1028. }
  1029. function get_cikkszam_data(obj,target) {
  1030. $.post('/admin/autocomplete/getcikkszam/',{value: $(obj).val()},function(resp) {
  1031. if (resp=='') {
  1032. $(target).removeAttr('disabled');
  1033. }
  1034. else {
  1035. $(target).val(resp);
  1036. $(target).attr('disabled','true');
  1037. }
  1038. });
  1039. }
  1040. function set_admin_email_notifications(obj,id) {
  1041. $.post('/admin/admins/notifications/',{id: id},function(resp) {});
  1042. }
  1043. function add_new_referens() {
  1044. $.get('/admin/ertekeles/referenskereses',function(resp) {
  1045. $('#dialog').html(resp);
  1046. $('.wrapper').addClass('blur');
  1047. $('#dialog').modal({
  1048. escapeClose: true,
  1049. clickClose: true,
  1050. showClose: true
  1051. });
  1052. $(".select2").select2({
  1053. dropdownParent: $('#dialog')
  1054. });
  1055. });
  1056. }
  1057. function add_new_iroda() {
  1058. $.get('/admin/irodak/irodakereses',function(resp) {
  1059. $('#dialog').html(resp);
  1060. $('.wrapper').addClass('blur');
  1061. $('#dialog').modal({
  1062. escapeClose: true,
  1063. clickClose: true,
  1064. showClose: true
  1065. });
  1066. $(".select2").select2({
  1067. dropdownParent: $('#dialog')
  1068. });
  1069. });
  1070. }
  1071. function setIrodaState(id) {
  1072. $.get('/admin/irodak/setstate/?id='+id,function(resp) {
  1073. });
  1074. }
  1075. function add_agent_to_db(id) {
  1076. $.get('/admin/ertekeles/addreferens/?id='+id,function(resp) {
  1077. window.location='/admin/ertekeles/edit/?id='+resp;
  1078. });
  1079. }
  1080. function add_iroda_to_db(id) {
  1081. $.get('/admin/irodak/addiroda/?id='+id,function(resp) {
  1082. window.location='/admin/irodak/edit/?id='+resp;
  1083. });
  1084. }
  1085. function isNumber(evt) {
  1086. evt = (evt) ? evt : window.event;
  1087. var charCode = (evt.which) ? evt.which : evt.keyCode;
  1088. if (charCode==46) {
  1089. return true;
  1090. }
  1091. else {
  1092. if (charCode > 31 && (charCode < 48 || charCode > 57)) {
  1093. return false;
  1094. }
  1095. return true;
  1096. }
  1097. }
  1098. function loadEvents(groupID) {
  1099. if (groupID!=='') {
  1100. $.get('/api/loadevents/?groupid=' + groupID,function(resp) {
  1101. $('#parent_event').html(resp);
  1102. });
  1103. }
  1104. }
  1105. function loadMenu(eventID) {
  1106. if (eventID!=='') {
  1107. $.get('/api/loadmenus/?eventid=' + eventID,function(resp) {
  1108. $('#parent_menu').html(resp);
  1109. });
  1110. }
  1111. }
  1112. function loadProds(groupID) {
  1113. if (groupID!=='') {
  1114. $.get('/api/loadprods/?groupid=' + groupID,function(resp) {
  1115. $('#parent_prods').html(resp);
  1116. });
  1117. }
  1118. }
  1119. function loadMenuDetails(obj) {
  1120. var label = $(obj).find(':selected').data('label');
  1121. var description = $(obj).find(':selected').data('description');
  1122. var price = $(obj).find(':selected').data('price');
  1123. console.log(label, description, price);
  1124. $('#box_title').val(label);
  1125. $('#box_subtitle').val(description);
  1126. $('#box_price').val(price);
  1127. }
  1128. $(document).ready(function() {
  1129. $('.checkbtn').each(function() {
  1130. //checkbtn_set_state($(this));
  1131. });
  1132. if (active_page.indexOf('beszerzes')==-1) {
  1133. $('.radiobtn').each(function() {
  1134. radiobtn_set_state($(this));
  1135. });
  1136. }
  1137. $('#page_content').trumbowyg({
  1138. btnsDef: {
  1139. image: {
  1140. dropdown: ['insertImage', 'upload'],
  1141. ico: 'insertImage'
  1142. }
  1143. },
  1144. btns: [
  1145. ['viewHTML'],
  1146. ['formatting'],
  1147. ['foreColor', 'backColor'],
  1148. ['strong', 'em', 'del'],
  1149. ['superscript', 'subscript'],
  1150. ['link'],
  1151. ['image'],
  1152. ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
  1153. ['unorderedList', 'orderedList'],
  1154. ['horizontalRule'],
  1155. ['removeformat'],
  1156. ['fullscreen']
  1157. ],
  1158. plugins: {
  1159. upload: {
  1160. serverPath: '/upload.php',
  1161. fileFieldName: 'image',
  1162. urlPropertyName: 'data.link'
  1163. }
  1164. }
  1165. });
  1166. $('#page_content_en').trumbowyg({
  1167. btnsDef: {
  1168. image: {
  1169. dropdown: ['insertImage', 'upload'],
  1170. ico: 'insertImage'
  1171. }
  1172. },
  1173. btns: [
  1174. ['viewHTML'],
  1175. ['formatting'],
  1176. ['foreColor', 'backColor'],
  1177. ['strong', 'em', 'del'],
  1178. ['superscript', 'subscript'],
  1179. ['link'],
  1180. ['image'],
  1181. ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
  1182. ['unorderedList', 'orderedList'],
  1183. ['horizontalRule'],
  1184. ['removeformat'],
  1185. ['fullscreen']
  1186. ],
  1187. plugins: {
  1188. upload: {
  1189. serverPath: '/upload.php',
  1190. fileFieldName: 'image',
  1191. urlPropertyName: 'data.link'
  1192. }
  1193. }
  1194. });
  1195. $('#battle_start').datetimepicker();
  1196. $('#battle_end').datetimepicker();
  1197. check_for_prev_next();
  1198. $('#dialog').on($.modal.BEFORE_CLOSE,function(event,modal) {
  1199. $('.wrapper').removeClass('blur');
  1200. });
  1201. $('.roles').on('click',function(event) {
  1202. var roleID = $(this).attr('data-role-id');
  1203. var moduleID = $(this).attr('data-module-id');
  1204. setModuleRoleStatus(roleID,moduleID);
  1205. });
  1206. $('.states').on('ifChecked',function(event) {
  1207. var userID = $(this).val();
  1208. setUserState(userID);
  1209. });
  1210. $('.states').on('ifUnchecked',function(event) {
  1211. var userID = $(this).val();
  1212. setUserState(userID);
  1213. });
  1214. $('.galery-image-item').on('mouseover',function() {
  1215. $(this).children('.minimal').show();
  1216. $(this).children('.deleter').show();
  1217. });
  1218. $('.galery-image-item').on('mouseout',function() {
  1219. $(this).children('.minimal').hide();
  1220. $(this).children('.deleter').hide();
  1221. });
  1222. $('.variation_status').on('ifChecked',function(event) {
  1223. set_variation_status($(this),true);
  1224. });
  1225. $('.variation_status').on('ifUnchecked',function(event) {
  1226. set_variation_status($(this),false);
  1227. });
  1228. $('.szuro').on('click',function() {
  1229. var filter = '.'+$(this).val();
  1230. $('.all').hide();
  1231. $(filter).show();
  1232. });
  1233. $('.editable').on("click",function() {
  1234. if (!$(this).hasClass('in-edit')) {
  1235. $(this).addClass('in-edit');
  1236. var actual_value = $(this).html();
  1237. var currency = $(this).attr('data-currency');
  1238. if (currency==='true') {
  1239. actual_value = actual_value.replace(",- Ft","");
  1240. actual_value = actual_value.replace(" ","");
  1241. }
  1242. var field_name = $(this).attr('data-field');
  1243. var table_name = $(this).attr('data-table');
  1244. var row_id = $(this).attr('data-id');
  1245. var key = $(this).attr('data-key');
  1246. $(this).html('<input type="text" name="'+field_name+'" id="'+field_name+'" value="'+actual_value+'" class="form-control edit" onblur="update_field($(this),\''+table_name+'\',\''+field_name+'\',\''+row_id+'\',\''+key+'\',\''+currency+'\')">');
  1247. $('#'+field_name).focus();
  1248. }
  1249. });
  1250. $(".select2").select2();
  1251. $(".mypartner").select2({placeholder: 'Válasszon partnert!'});
  1252. $(".fmachines").select2({placeholder: 'Válasszon gépet!'});
  1253. $(".fparts").select2({placeholder: 'Válasszon részegységet!'});
  1254. $(".myclient").select2({placeholder: 'Válasszon ügyfelet!'});
  1255. $(".mypayment").select2({placeholder: 'Válasszon fizetési módot!'});
  1256. $(".mycategory").select2({placeholder: 'Válasszon kategóriát!'});
  1257. $('.datepicker').datepicker({
  1258. autoclose: true
  1259. });
  1260. $('#cost_partner').autocomplete({
  1261. source: function(request,response) {
  1262. $.ajax({
  1263. url: '/admin/autocomplete/search/',
  1264. dataType: "jsonp",
  1265. data: {
  1266. term: request.term
  1267. },
  1268. success: function(data) {
  1269. response(data);
  1270. }
  1271. });
  1272. },
  1273. minLength: 1
  1274. });
  1275. $('#cost_client').autocomplete({
  1276. source: function(request,response) {
  1277. $.ajax({
  1278. url: '/admin/autocomplete/search_client/',
  1279. dataType: "jsonp",
  1280. data: {
  1281. term: request.term
  1282. },
  1283. success: function(data) {
  1284. response(data);
  1285. }
  1286. });
  1287. },
  1288. minLength: 1
  1289. });
  1290. $('.rendeles_ugyfel').autocomplete({
  1291. source: function(request,response) {
  1292. $.ajax({
  1293. url: '/admin/autocomplete/search_client/',
  1294. dataType: "jsonp",
  1295. data: {
  1296. term: request.term
  1297. },
  1298. success: function(data) {
  1299. response(data);
  1300. }
  1301. });
  1302. },
  1303. minLength: 1
  1304. });
  1305. $('#filter_bill_number').autocomplete({
  1306. source: function(request,response) {
  1307. $.ajax({
  1308. url: '/admin/autobill/search/',
  1309. dataType: "jsonp",
  1310. data: {
  1311. term: request.term
  1312. },
  1313. success: function(data) {
  1314. response(data);
  1315. }
  1316. });
  1317. },
  1318. minLength: 1
  1319. });
  1320. $('#cost_bill_number').autocomplete({
  1321. source: function(request,response) {
  1322. $.ajax({
  1323. url: '/admin/autobill/search/',
  1324. dataType: "jsonp",
  1325. data: {
  1326. term: request.term
  1327. },
  1328. success: function(data) {
  1329. response(data);
  1330. }
  1331. });
  1332. },
  1333. minLength: 1
  1334. });
  1335. $('#beszer_beepites_cikkszam').autocomplete({
  1336. source: function(request,response) {
  1337. $.ajax({
  1338. url: '/admin/autocikkszam/search/',
  1339. dataType: "jsonp",
  1340. data: {
  1341. term: request.term
  1342. },
  1343. success: function(data) {
  1344. response(data);
  1345. }
  1346. });
  1347. },
  1348. minLength: 1
  1349. });
  1350. $('#filter_comment').autocomplete({
  1351. source: function(request,response) {
  1352. $.ajax({
  1353. url: '/admin/autocomment/search/',
  1354. dataType: "jsonp",
  1355. data: {
  1356. term: request.term
  1357. },
  1358. success: function(data) {
  1359. response(data);
  1360. }
  1361. });
  1362. },
  1363. minLength: 1
  1364. });
  1365. $('#cost_egyseg_cikkszam').autocomplete({
  1366. source: function(request,response) {
  1367. $.ajax({
  1368. url: '/admin/autocomplete/cikkszam/',
  1369. dataType: "jsonp",
  1370. data: {
  1371. term: request.term
  1372. },
  1373. success: function(data) {
  1374. response(data);
  1375. }
  1376. });
  1377. },
  1378. minLength: 1
  1379. });
  1380. $('#cost_egyseg_nev').autocomplete({
  1381. source: function(request,response) {
  1382. $.ajax({
  1383. url: '/admin/autocomplete/cikknev/',
  1384. dataType: "jsonp",
  1385. data: {
  1386. term: request.term
  1387. },
  1388. success: function(data) {
  1389. response(data);
  1390. }
  1391. });
  1392. },
  1393. minLength: 1
  1394. });
  1395. $('#beszer_termek').autocomplete({
  1396. source: function(request,response) {
  1397. $.ajax({
  1398. url: '/admin/autotermek/search/',
  1399. dataType: "jsonp",
  1400. data: {
  1401. term: request.term
  1402. },
  1403. success: function(data) {
  1404. response(data);
  1405. }
  1406. });
  1407. },
  1408. minLength: 1
  1409. });
  1410. $('#beszer_anyagminoseg').autocomplete({
  1411. source: function(request,response) {
  1412. $.ajax({
  1413. url: '/admin/autominoseg/search/',
  1414. dataType: "jsonp",
  1415. data: {
  1416. term: request.term
  1417. },
  1418. success: function(data) {
  1419. response(data);
  1420. }
  1421. });
  1422. },
  1423. minLength: 1
  1424. });
  1425. $('#beszer_egyseg').autocomplete({
  1426. source: function(request,response) {
  1427. $.ajax({
  1428. url: '/admin/autoegyseg/search/',
  1429. dataType: "jsonp",
  1430. data: {
  1431. term: request.term
  1432. },
  1433. success: function(data) {
  1434. response(data);
  1435. }
  1436. });
  1437. },
  1438. minLength: 1
  1439. });
  1440. $('#beszer_kategoria').autocomplete({
  1441. source: function(request,response) {
  1442. $.ajax({
  1443. url: '/admin/autokategoria/search/',
  1444. dataType: "jsonp",
  1445. data: {
  1446. term: request.term
  1447. },
  1448. success: function(data) {
  1449. response(data);
  1450. }
  1451. });
  1452. },
  1453. minLength: 1
  1454. });
  1455. $('.uploadMe').on('click',function() {
  1456. //$.post('/admin/bills/updatefile',{id: },function(response) {});
  1457. });
  1458. var msg_timer = setTimeout(function() {
  1459. $('.callout-success').hide();
  1460. },3000);
  1461. $('#mytable').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1462. $('#mytable2').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1463. $('#mytable3').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1464. $('#mytable_tech').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1465. $('#mytable_rendelesek').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1466. //$('#mytable4').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1467. //$('#mytable5').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1468. $('#mytable6').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1469. $('#mytable7').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1470. $('#mytablex').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1471. $('#mytablex').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1472. $('#mytable_s1').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1473. $('#mytable_s2').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1474. $('#mytable_s3').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1475. $('#mytable_s4').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1476. //$('#mytable_hotels_forselect').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1477. //$('#mytable_hotels_selected').wrap('<div style="overflow-x: scroll;" id="scroller"></div>');
  1478. $('.main-header').swipe({
  1479. swipe: function(event, direction, distance, duration, fingerCount, fingerData) {
  1480. if ($('.skin-black').hasClass('sidebar-collapse')) {
  1481. $('.skin-black').removeClass('sidebar-collapse');
  1482. $('#fogantyu').css('left','0px');
  1483. }
  1484. else {
  1485. $('.skin-black').addClass('sidebar-collapse');
  1486. $('#fogantyu').css('left','230px');
  1487. }
  1488. if ($('.skin-black').hasClass('sidebar-open')) {
  1489. $('.skin-black').removeClass('sidebar-open');
  1490. }
  1491. else {
  1492. $('.skin-black').addClass('sidebar-open');
  1493. }
  1494. }
  1495. });
  1496. $('.main-sidebar').swipe({
  1497. swipe: function(event, direction, distance, duration, fingerCount, fingerData) {
  1498. if ($('.skin-black').hasClass('sidebar-collapse')) {
  1499. $('.skin-black').removeClass('sidebar-collapse');
  1500. $('#fogantyu').css('left','0px');
  1501. }
  1502. else {
  1503. $('.skin-black').addClass('sidebar-collapse');
  1504. $('#fogantyu').css('left','230px');
  1505. }
  1506. if ($('.skin-black').hasClass('sidebar-open')) {
  1507. $('.skin-black').removeClass('sidebar-open');
  1508. }
  1509. else {
  1510. $('.skin-black').addClass('sidebar-open');
  1511. }
  1512. }
  1513. });
  1514. $('#fogantyu').swipe({
  1515. swipe: function(event, direction, distance, duration, fingerCount, fingerData) {
  1516. if ($('.skin-black').hasClass('sidebar-collapse')) {
  1517. $('.skin-black').removeClass('sidebar-collapse');
  1518. $('#fogantyu').css('left','0px');
  1519. }
  1520. else {
  1521. $('.skin-black').addClass('sidebar-collapse');
  1522. $('#fogantyu').css('left','230px');
  1523. }
  1524. if ($('.skin-black').hasClass('sidebar-open')) {
  1525. $('.skin-black').removeClass('sidebar-open');
  1526. }
  1527. else {
  1528. $('.skin-black').addClass('sidebar-open');
  1529. }
  1530. }
  1531. });
  1532. if (screen.width<767) {
  1533. $('#coll-hack').addClass('collapsed-box');
  1534. $('#coll-sign').removeClass('fa-minus');
  1535. $('#coll-sign').addClass('fa-plus');
  1536. }
  1537. });
  1538. $(window).resize(function() {
  1539. if (screen.width<767) {
  1540. $('#coll-hack').addClass('collapsed-box');
  1541. $('#coll-sign').removeClass('fa-minus');
  1542. $('#coll-sign').addClass('fa-plus');
  1543. }
  1544. else {
  1545. $('#coll-hack').removeClass('collapsed-box');
  1546. $('#coll-sign').removeClass('fa-plus');
  1547. $('#coll-sign').addClass('fa-minus');
  1548. }
  1549. });