Topic: ASK Codeflow workorder
Where is flow code for workorder when 'add workorder' ? i mean about stock_moves table, where can i find the code when 'add workorder' insert data to stock_moves table? thanks
It's much more fun, when you can discuss your problems with others...
You are not logged in. Please login or register.
FrontAccounting forum → Manufactoring → ASK Codeflow workorder
Where is flow code for workorder when 'add workorder' ? i mean about stock_moves table, where can i find the code when 'add workorder' insert data to stock_moves table? thanks
function add_stock_move()
in
includes/db/inventory_db.inc
function add_stock_move()
in
includes/db/inventory_db.inc
which line sir on work_order_entry.php who call function of add_stock_move from inventory_db.inc ?
In file manufacturing/work_order_entry.php lines 264-266:
$id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'),
$_POST['stock_id'], $_POST['type'], $_POST['date_'],
$_POST['RequDate'], $_POST['memo_'], input_num('Costs'), $_POST['cr_acc'], input_num('Labour'), $_POST['cr_lab_acc']);
function add_work_order() above is defined in 3 files in manufacturing/includes/db folder =>
work_orders_db.inc,
work_orders_quick_db.inc and
work_order_issues_db.inc
all of which get added when manufacturing/manufacturing_db.inc is included - this will cause only the first occurrence of the function definition to be taken, viz., from work_orders_db.inc unless the preferred one is included earlier!
Search for the add_stock_move function call in any of them and work your way through.
thanks sir, honesty this is my real problem, why this code isnt working? its look like 2 db_query in one function isnt allowed
function add_stock_move($type, $stock_id, $trans_no, $location,
$date_, $reference, $quantity, $std_cost, $person_id=0, $show_or_hide=1,
$price=0, $discount_percent=0, $error_msg="")
{
$date = date2sql($date_);
$bomqty = "SELECT bom_quantity from ".TB_PREF."stock_master WHERE stock_id=".db_escape($stock_id);
$result = db_query($bomqty, "Error");
if (db_num_rows($bomqty)==1)
{
$row = db_fetch_row($result)
return $row[0];
} $nope = $row[0];
$sql = "INSERT INTO ".TB_PREF."stock_moves (stock_id, trans_no, type, loc_code,
tran_date, person_id, reference, qty, standard_cost, visible, price,
discount_percent) VALUES (".db_escape($stock_id)
.", ".db_escape($trans_no).", ".db_escape($type)
.", ".db_escape($location).", '$date', "
.db_escape($person_id).", ".db_escape($reference).", "
.db_escape($quantity).", ".db_escape($std_cost).","
.db_escape($show_or_hide).", "
.db_escape($price).", ".db_escape($nope).")";
if ($error_msg == "")
$error_msg = "The stock movement record cannot be inserted";
db_query($sql, $error_msg);
return db_insert_id();
}
What version of PHP / MySQL are you using?
Some of the later PHP versions expect that the first $result must be a resultset and not a boolean (false) for the next db_num_rows to work.
Try the function by just displaying the sqls and not executing them and then try to manually execute the sqls in phpmyadmin and you will see the error that arises.
Hello Maulana
There is an error in your code.
if (db_num_rows($bomqty)==1)
you should test db_num_rows on $result and NOT $bomqty.
/Joe
my version is PHP 5.5 and MySQL 5.6, is any problem with that? or should i use another version of XAMPP?
but sir, my screen on work_order_entry.php is blank,its because of two db_query, when i delete db_query, my screen back to normal
and i already change to $result
The variable $nope is just the first record if it passes the initial single record if check when the second sql is attempted. Otherwise if there is only 1 record, the second sql will not be attempted at all. This variable is sought to fill in the discount_percent field.
What are you trying to do?
What happens if there are no results from the first sql? You will be assigning null to a not null field or boolean false to a integer field. The following may work after the initial single record if check fails.
$nope = ($row[0] ? $row[0] : 0);
This is the main problem right now, blank. with this problem, i cant even see the form for test a modification code
http://s25.postimg.org/xk6fplz2n/blankerror.png
what i trying to do is make modification about BoM Material, i want to make a BoM can produce more than one product.
so the idea is make additional column in stock_master named bom_quantity, then on add_stock_move function i want to make $quantity * bom_quantity
why i use discount_percent field? it's just a test for make sql statement SELECT for get bom_quantity with the same stock_id
Check which statement is causing the blank by commenting out your code block and then working in.
Is your test case passing into the initial if code block at all? If so, it will just return (that's what your code directs) without doing anything since there is just 1 record.
its on db_fetch_row($result) line, is something wrong with that?
for the if code block, i just trying like get_location_name function, i think maybe it works
but before it i try using without if statement and still like this
The syntax is correct. The next statement is returning from the function with an array of fields from the first sql instead of an integer that should be the last insert id of the second sql. The calling script is expecting an integer in return.
is there any solution? or should i change my idea of this flow?
Your flow is wrong.
There must be a stock transfer when you use a BoM to manufacture - whether it is one or more products. In your flow, you are preventing any stock transfer in the second sql if there is only one product - if the $nope is actually one or more products made.
@joe, how is this implemented in FA for now? Should he use kits in manufacture?
I haven't been followed this in detail. Please give me som time to have a look. It is easy to produce some wrong code.
Joe
@joe: I did not mean this code. I meant:
How is the work flow managed in FA when a single BoM is used to produce a set of products and not just one product.
How does the system handle the stock moves then?
@maulana
Please set the variable, $go_debug to 1 in config.php to trap any errors.
Immediately I can not find any errors.
Joe
@apmuthu
It is a bit too complicated to describe the workorder flow here. Let us just assume that the code works in the core. If you try to modify this, you are often on your own and should have some professional skill in programming.
Joe
@joe:
Just wanted to know if such a feature exists!
And if so, what are the menu click and entry sequences to achieve it.
Not the code behind it.
I can only say, that the BOM is always used as a base when the assembly/manufacturing is done.
When manufacturing, the stock is first handled when you produce the items.
Joe
give me some time for make another way to make it
FrontAccounting forum → Manufactoring → ASK Codeflow workorder
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 4 official extensions. Copyright © 2003–2009 PunBB.