we need a stored procedure + trigger to do the following. attached is the table layout
trigger on update user_trans when
approve changes from 0 to 1 or paypal_approve changes from 0 to 1 or google_approve changes from 0 to 1
use this function below
if user_trans.ship_type=0 or user_trans.ship_type=2
select count(item_no) from trans_info where trans_id= {trans_id that has changed from user_trans]
if count=1 then
select a.item_no,[login to view URL],[login to view URL] from trans_info as a, product_list as b where a.trans_id={the trans_id} and a.item_no=b.item_no
if item is chinaSource=1 and usSource=0 then
insert into transPrintCat trans_id, usprint=0, cnprint=1, singleItem=1
if item is usSource=1 and chinaSource=0 then
insert into transPrintCat trans_id, usprint=1, cnprint=0, singleItem=1
if 1 item is usSource=1 and chinaSource=1 then
insert into transPrintCat trans_id, usprint=1, cnprint=0, singleItem=2
else
if count > 1
select a.item_no,[login to view URL],[login to view URL] from trans_info as a, product_list as b where a.trans_id={the trans_id} and a.item_no=b.item_no
if all item are chinaSource=1 and usSource=0 then
insert into transPrintCat trans_id, usprint=0, cnprint=1, singleItem=0
if 1 item is usSource=1 then
insert into transPrintCat trans_id, usprint=1, cnprint=0, singleItem=0
else
select count(a.item_no) from trans_info where trans_id=?
if count=1
insert into transPrintCat trans_id, usprint=1, cnprint=0, singleItem=1
if count>1
insert into transPrintCat trans_id, usprint=1, cnprint=0, singleItem=0