308 ] |
308 ] |
309 }) |
309 }) |
310 }; |
310 }; |
311 |
311 |
312 // Inline hops editor |
312 // Inline hops editor |
|
313 var editHop = function (data) { |
|
314 var hopSource = { |
|
315 localdata: data.hops, |
|
316 datatype: "local", |
|
317 datafields: [ |
|
318 { name: 'h_name', type: 'string' }, |
|
319 { name: 'h_origin', type: 'string' }, |
|
320 { name: 'h_amount', type: 'float' }, |
|
321 { name: 'h_cost', type: 'float' }, |
|
322 { name: 'h_type', type: 'string' }, |
|
323 { name: 'h_form', type: 'string' }, |
|
324 { name: 'h_useat', type: 'string' }, |
|
325 { name: 'h_time', type: 'float' }, |
|
326 { name: 'h_alpha', type: 'float' }, |
|
327 { name: 'h_beta', type: 'float' }, |
|
328 { name: 'h_hsi', type: 'float' }, |
|
329 { name: 'h_humulene', type: 'float' }, |
|
330 { name: 'h_carophyllene', type: 'float' }, |
|
331 { name: 'h_cohumulone', type: 'float' }, |
|
332 { name: 'h_myrcene', type: 'float' }, |
|
333 { name: 'h_total_oil', type: 'float' } |
|
334 ], |
|
335 addrow: function (rowid, rowdata, position, commit) { |
|
336 commit(true); |
|
337 }, |
|
338 deleterow: function (rowid, commit) { |
|
339 commit(true); |
|
340 } |
|
341 }; |
|
342 var hopAdapter = new $.jqx.dataAdapter(hopSource); |
|
343 // dropdownlist datasource from inventory_hops |
|
344 var hopUrl = "gethopsources.php"; |
|
345 var hopInvSource = { |
|
346 datatype: "json", |
|
347 datafields: [ |
|
348 { name: 'record', type: 'number' }, |
|
349 { name: 'name', type: 'string' }, |
|
350 { name: 'origin', type: 'string' }, |
|
351 { name: 'type', type: 'string' }, |
|
352 { name: 'alpha', type: 'float' }, |
|
353 { name: 'beta', type: 'float' }, |
|
354 { name: 'humulene', type: 'float' }, |
|
355 { name: 'caryophyllene', type: 'float' }, |
|
356 { name: 'cohumulone', type: 'float' }, |
|
357 { name: 'myrcene', type: 'float' }, |
|
358 { name: 'hsi', type: 'float' }, |
|
359 { name: 'useat', type: 'string' }, |
|
360 { name: 'form', type: 'string' }, |
|
361 { name: 'total_oil', type: 'float' }, |
|
362 { name: 'cost', type: 'float' } |
|
363 ], |
|
364 url: hopUrl, |
|
365 async: true |
|
366 }; |
|
367 var hoplist = new $.jqx.dataAdapter(hopInvSource); |
|
368 |
|
369 $("#hopGrid").jqxGrid({ |
|
370 width: 960, |
|
371 height: 400, |
|
372 source: hopAdapter, |
|
373 theme: theme, |
|
374 selectionmode: 'singlerow', |
|
375 editmode: 'selectedrow', |
|
376 editable: true, |
|
377 localization: getLocalization(), |
|
378 showtoolbar: true, |
|
379 rendertoolbar: function (toolbar) { |
|
380 var me = this; |
|
381 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
382 toolbar.append(container); |
|
383 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
|
384 container.append('<input style="float: left; margin-left: 230px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
|
385 // add hop from dropdownlist. |
|
386 $("#haddrowbutton").jqxDropDownList({ |
|
387 placeHolder: "Kies hop:", |
|
388 theme: theme, |
|
389 source: hoplist, |
|
390 displayMember: "name", |
|
391 width: 150, |
|
392 height: 27, |
|
393 dropDownWidth: 300 |
|
394 }); |
|
395 $("#haddrowbutton").on('select', function (event) { |
|
396 if (event.args) { |
|
397 var index = event.args.index; |
|
398 var datarecord = hoplist.records[index]; |
|
399 var row = {}; |
|
400 row["h_name"] = datarecord.name; |
|
401 row["h_origin"] = datarecord.origin; |
|
402 row["h_amount"] = 0; |
|
403 row["h_cost"] = datarecord.cost; |
|
404 row["h_type"] = datarecord.type; |
|
405 row["h_form"] = datarecord.form; |
|
406 row["h_useat"] = datarecord.useat; |
|
407 row["h_time"] = 0; |
|
408 row["h_alpha"] = datarecord.alpha; |
|
409 row["h_beta"] = datarecord.beta; |
|
410 row["h_hsi"] = datarecord.hsi; |
|
411 row["h_humulene"] = datarecord.humulene; |
|
412 row["h_carophyllene"] = datarecord.carophyllene; |
|
413 row["h_cohumulone"] = datarecord.cohumulone; |
|
414 row["h_myrcene"] = datarecord.myrcene; |
|
415 row["h_total_oil"] = datarecord.total_oil; |
|
416 var commit = $("#hopGrid").jqxGrid('addrow', null, row); |
|
417 } |
|
418 }); |
|
419 |
|
420 // delete selected hop. |
|
421 $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
422 $("#hdeleterowbutton").on('click', function () { |
|
423 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); |
|
424 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; |
|
425 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
426 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
|
427 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
|
428 } |
|
429 }); |
|
430 }, |
|
431 columns: [ |
|
432 { text: 'Hop', editable: false, datafield: 'h_name' }, |
|
433 { text: 'Type', editable: false, width: 100, datafield: 'h_type' }, |
|
434 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
|
435 { text: 'Beta', datafield: 'h_beta', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
|
436 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
|
437 columntype: 'numberinput', |
|
438 validation: function (cell, value) { |
|
439 if (value < 0 || value > 100000000000 ) { |
|
440 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
441 } |
|
442 return true; |
|
443 } |
|
444 }, |
|
445 { text: 'Tijd', datafield: 'h_time', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
|
446 columntype: 'numberinput', |
|
447 validation: function (cell, value) { |
|
448 if (value < 0 || value > 100000000000 ) { |
|
449 return { result: false, message: "De tijd moet 0-~ zijn" }; |
|
450 } |
|
451 return true; |
|
452 } |
|
453 } |
|
454 ] |
|
455 }) |
|
456 }; |
|
457 |
313 |
458 |
314 // Inline miscs editor |
459 // Inline miscs editor |
315 |
460 |
316 // Inline yeasts editor |
461 // Inline yeasts editor |
317 |
462 |