|
@@ -14,13 +14,17 @@ select t.* from (SELECT t1.st_stockbill_itemsid detailid,
|
|
|
t1.price,
|
|
|
t1.amount,
|
|
|
t2.packageqty,
|
|
|
- t1.remarks
|
|
|
+ t1.remarks,
|
|
|
+ t7.agentnum,
|
|
|
+ t9.enterprisename
|
|
|
FROM st_stockbill_items t1
|
|
|
left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
|
|
|
LEFT JOIN plm_unit t3 ON t3.unitid = t2.unitid AND t3.siteid = t2.siteid
|
|
|
LEFT JOIN st_stockbill t4 ON t4.st_stockbillid = t1.st_stockbillid AND t4.siteid = t1.siteid
|
|
|
left join sa_order t8 on t8.sa_orderid=t1.sa_orderid and t8.siteid=t1.siteid
|
|
|
left join plm_itemextend t6 on t2.siteid = t6.siteid and t2.itemid = t6.itemid
|
|
|
+ left join sa_agents t7 on t7.sys_enterpriseid=t8.sys_enterpriseid and t7.siteid=t8.siteid
|
|
|
+ left join sys_enterprise t9 on t9.sys_enterpriseid=t8.sys_enterpriseid and t9.siteid=t8.siteid
|
|
|
where t4.rb=1 and t1.siteid = $siteid$ and t4.sys_enterpriseid in (select sys_enterpriseid from sys_enterprise_tradefield where sa_saleareaid in $sa_saleareaids$)
|
|
|
union all
|
|
|
SELECT t1.st_stockbill_itemsid detailid,
|
|
@@ -39,11 +43,15 @@ SELECT t1.st_stockbill_itemsid detailid,
|
|
|
t1.price,
|
|
|
t1.amount,
|
|
|
t2.packageqty,
|
|
|
- t1.remarks
|
|
|
+ t1.remarks,
|
|
|
+ t7.agentnum,
|
|
|
+ t9.enterprisename
|
|
|
FROM st_stockbill_items t1
|
|
|
left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
|
|
|
LEFT JOIN plm_unit t3 ON t3.unitid = t2.unitid AND t3.siteid = t2.siteid
|
|
|
LEFT JOIN st_stockbill t4 ON t4.st_stockbillid = t1.st_stockbillid AND t4.siteid = t1.siteid
|
|
|
left join sa_order t8 on t8.sa_orderid=t1.sa_orderid and t8.siteid=t1.siteid
|
|
|
left join plm_itemextend t6 on t2.siteid = t6.siteid and t2.itemid = t6.itemid
|
|
|
+ left join sa_agents t7 on t7.sys_enterpriseid=t8.sys_enterpriseid and t7.siteid=t8.siteid
|
|
|
+ left join sys_enterprise t9 on t9.sys_enterpriseid=t8.sys_enterpriseid and t9.siteid=t8.siteid
|
|
|
where t4.rb=0 and t1.siteid = $siteid$ and t4.sys_enterpriseid in (select sys_enterpriseid from sys_enterprise_tradefield where sa_saleareaid in $sa_saleareaids$)) t where $where$
|