Autofill the MO with data from BOM
This commit is contained in:
parent
be3f0471ff
commit
38aa648363
@ -43,9 +43,12 @@ $action = GETPOST('action', 'alpha');
|
||||
|
||||
$object = new BOM($db);
|
||||
$result=$object->fetch($idbom);
|
||||
if ($result)
|
||||
if ($result > 0)
|
||||
{
|
||||
echo json_encode($result);
|
||||
// We remove properties we don't need in answer
|
||||
unset ($object->fields);
|
||||
unset ($object->db);
|
||||
echo json_encode($object);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -204,16 +203,37 @@ if ($action == 'create')
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
jQuery("#fk_bom").change(function() {
|
||||
console.log("We change value of BOM");
|
||||
/* TODO */
|
||||
jQuery('#fk_bom').change(function() {
|
||||
console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val());
|
||||
|
||||
$.getJSON('<?php echo DOL_URL_ROOT ?>/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) {
|
||||
console.log(data);
|
||||
if (typeof data.rowid != "undefined") {
|
||||
console.log("New BOM loaded, we set values in form");
|
||||
$('#qty').val(data.qty);
|
||||
$("#fk_product").val(data.fk_product);
|
||||
$('#fk_product').trigger('change'); // Notify any JS components that the value changed
|
||||
$('#note_private').val(data.description);
|
||||
$('#note_private').trigger('change'); // Notify any JS components that the value changed
|
||||
if (typeof CKEDITOR != "undefined") {
|
||||
if (typeof CKEDITOR.instances != "undefined") {
|
||||
if (typeof CKEDITOR.instances.note_private != "undefined") {
|
||||
console.log(CKEDITOR.instances.note_private);
|
||||
CKEDITOR.instances.note_private.setData(data.description);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("Failed to get BOM");
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
</script>
|
||||
';
|
||||
<?php
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
Loading…
Reference in New Issue
Block a user