VbzCart/queries/qryStk lines remaining

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< VbzCart‎ | queries
Revision as of 22:56, 29 November 2009 by Woozle (talk | contribs) (another used-by)
Jump to navigation Jump to search

Details

  • Returns:
  1. REDIRECT Template:l/vc/table actually in stock, which is actually different things:
    • "forSale": items which are visible as "in stock" to customers
    • "forShip": items which are available for shipping
    • items neither for shipping nor for sale (probably some kind of recordkeeping purpose)
  • Requires: stk_items, stk_places
  • Used by:
  1. REDIRECT Template:l/vc/query, qryStk_lines_remaining_byBin

SQL

<mysql>CREATE OR REPLACE VIEW v_stk_lines_remaining AS

 SELECT
   st.ID,
   st.ID_Bin,
   st.ID_Item,
   IF(sb.isForSale,st.Qty,0) AS QtyForSale,
   IF(sb.isForShip,st.Qty,0) AS QtyForShip,
   st.Qty AS QtyExisting,
   st.CatNum,
   st.WhenAdded,
   st.WhenChanged,
   st.WhenCounted,
   st.Notes,
   sb.ID_Place,
   sp.Name AS WhName
   FROM
     (
       stk_items AS st
       LEFT JOIN stk_bins AS sb
         ON sb.ID=st.ID_Bin
      )
      LEFT JOIN stk_places AS sp
        ON sb.ID_Place=sp.ID
   WHERE (st.WhenRemoved IS NULL) AND (sb.WhenVoided IS NULL) AND (st.Qty <> 0);</mysql>