static updateGrills(date, design, color, department, nextDepartment, completed, lost) {
    db.query(
      'UPDATE amounts, ( \
        SELECT ? AS Date, DepartmentID, MatID, MaterialAmount * (? + ?) AS NumMats \
        FROM departments, productmaterials \
          INNER JOIN products ON productmaterials.ProdID = products.ProductID \
        WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
      ) AS temp \
      SET amounts.InStock = amounts.InStock - temp.NumMats \
      WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
      [date, completed, lost, "%"+design+"%", "%"+color+"%", "%"+department+"%"])
    db.query(
      'INSERT INTO amounts (Date, DepID, MatID, InStock, Lost) \
      SELECT * FROM ( \
        SELECT ? AS Date, DepartmentID, MatID, MaterialAmount * ? AS NumMats, 0 \
        FROM departments, productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
        WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
      ) AS temp \
      ON DUPLICATE KEY UPDATE InStock = InStock + temp.NumMats',
      [date, completed, "%"+design+"%", "%"+color+"%", "%"+nextDepartment+"%"])
    if (department === "GrillVelcro" || department === "GrillStickers" || department === "GrillPackaging"){
      db.query(
        'UPDATE amounts, ( \
          SELECT ? AS Date, DepartmentID, MatID \
          FROM departments, productmaterials \
            INNER JOIN products ON productmaterials.ProdID = products.ProductID \
            INNER JOIN materials ON productmaterials.MatID = materials.MaterialID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
            AND ((MaterialName LIKE ? AND MaterialName LIKE ?) OR (MaterialName LIKE ?)) \
        ) AS temp  \
        SET amounts.Lost = amounts.Lost + ? \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, "%"+design+"%", "%"+color+"%", "%"+department+"%", "%"+color+"%", "%plastic%", "%grommet%", lost])
      return db.query( // Pre-production departmentID for Grills is 18.
        'UPDATE amounts, ( \
          SELECT ? AS Date, 18 AS DepartmentID, MatID, MaterialAmount * ? AS NumMats \
          FROM productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND MatID NOT IN ( \
            SELECT MaterialID FROM materials \
            WHERE MaterialName LIKE ? AND MaterialName LIKE ? OR MaterialName LIKE ? \
          ) \
        ) AS temp  \
        SET amounts.InStock = amounts.InStock + temp.NumMats \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, lost, "%"+design+"%", "%"+color+"%", "%"+color+"%", "%plastic%", "%grommet%"])
    } else {
      db.query(
        'UPDATE amounts, ( \
          SELECT ? AS Date, DepartmentID, MatID \
          FROM departments, productmaterials \
            INNER JOIN products ON productmaterials.ProdID = products.ProductID \
            INNER JOIN materials ON productmaterials.MatID = materials.MaterialID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
            AND MaterialName LIKE ? AND MaterialName LIKE ? \
        ) AS temp  \
        SET amounts.Lost = amounts.Lost + ? \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, "%"+design+"%", "%"+color+"%", "%"+department+"%", "%"+color+"%", "%plastic%", lost])
      return db.query( // Pre-production departmentID for Grills is 18.
        'UPDATE amounts, ( \
          SELECT ? AS Date, 18 AS DepartmentID, MatID, MaterialAmount * ? AS NumMats \
          FROM productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND MatID NOT IN ( \
            SELECT MaterialID FROM materials \
            WHERE MaterialName LIKE ? AND MaterialName LIKE ? \
          ) \
        ) AS temp  \
        SET amounts.InStock = amounts.InStock + temp.NumMats \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, lost, "%"+design+"%", "%"+color+"%", "%"+color+"%", "%plastic%"])
    }
  }
// weren't lost back to the pre-production department.
weren't lost back to the pre-production department.
weren ' t lost back to the pre - production department .
static updateGrills(date, design, color, department, nextDepartment, completed, lost) {
    db.query(
      'UPDATE amounts, ( \
        SELECT ? AS Date, DepartmentID, MatID, MaterialAmount * (? + ?) AS NumMats \
        FROM departments, productmaterials \
          INNER JOIN products ON productmaterials.ProdID = products.ProductID \
        WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
      ) AS temp \
      SET amounts.InStock = amounts.InStock - temp.NumMats \
      WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
      [date, completed, lost, "%"+design+"%", "%"+color+"%", "%"+department+"%"])
    db.query(
      'INSERT INTO amounts (Date, DepID, MatID, InStock, Lost) \
      SELECT * FROM ( \
        SELECT ? AS Date, DepartmentID, MatID, MaterialAmount * ? AS NumMats, 0 \
        FROM departments, productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
        WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
      ) AS temp \
      ON DUPLICATE KEY UPDATE InStock = InStock + temp.NumMats',
      [date, completed, "%"+design+"%", "%"+color+"%", "%"+nextDepartment+"%"])
    if (department === "GrillVelcro" || department === "GrillStickers" || department === "GrillPackaging"){
      db.query(
        'UPDATE amounts, ( \
          SELECT ? AS Date, DepartmentID, MatID \
          FROM departments, productmaterials \
            INNER JOIN products ON productmaterials.ProdID = products.ProductID \
            INNER JOIN materials ON productmaterials.MatID = materials.MaterialID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
            AND ((MaterialName LIKE ? AND MaterialName LIKE ?) OR (MaterialName LIKE ?)) \
        ) AS temp  \
        SET amounts.Lost = amounts.Lost + ? \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, "%"+design+"%", "%"+color+"%", "%"+department+"%", "%"+color+"%", "%plastic%", "%grommet%", lost])
      return db.query( 
        'UPDATE amounts, ( \
          SELECT ? AS Date, 18 AS DepartmentID, MatID, MaterialAmount * ? AS NumMats \
          FROM productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND MatID NOT IN ( \
            SELECT MaterialID FROM materials \
            WHERE MaterialName LIKE ? AND MaterialName LIKE ? OR MaterialName LIKE ? \
          ) \
        ) AS temp  \
        SET amounts.InStock = amounts.InStock + temp.NumMats \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, lost, "%"+design+"%", "%"+color+"%", "%"+color+"%", "%plastic%", "%grommet%"])
    } else {
      db.query(
        'UPDATE amounts, ( \
          SELECT ? AS Date, DepartmentID, MatID \
          FROM departments, productmaterials \
            INNER JOIN products ON productmaterials.ProdID = products.ProductID \
            INNER JOIN materials ON productmaterials.MatID = materials.MaterialID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
            AND MaterialName LIKE ? AND MaterialName LIKE ? \
        ) AS temp  \
        SET amounts.Lost = amounts.Lost + ? \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, "%"+design+"%", "%"+color+"%", "%"+department+"%", "%"+color+"%", "%plastic%", lost])
      return db.query( 
        'UPDATE amounts, ( \
          SELECT ? AS Date, 18 AS DepartmentID, MatID, MaterialAmount * ? AS NumMats \
          FROM productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND MatID NOT IN ( \
            SELECT MaterialID FROM materials \
            WHERE MaterialName LIKE ? AND MaterialName LIKE ? \
          ) \
        ) AS temp  \
        SET amounts.InStock = amounts.InStock + temp.NumMats \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID',
        [date, lost, "%"+design+"%", "%"+color+"%", "%"+color+"%", "%plastic%"])
    }
  }
static updateGrills ( date , design , color , department , nextDepartment , completed , lost ) { db . query ( 'UPDATE amounts, ( \
        SELECT ? AS Date, DepartmentID, MatID, MaterialAmount * (? + ?) AS NumMats \
        FROM departments, productmaterials \
          INNER JOIN products ON productmaterials.ProdID = products.ProductID \
        WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
      ) AS temp \
      SET amounts.InStock = amounts.InStock - temp.NumMats \
      WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID' , [ date , completed , lost , "%" + design + "%" , "%" + color + "%" , "%" + department + "%" ] ) db . query ( 'INSERT INTO amounts (Date, DepID, MatID, InStock, Lost) \
      SELECT * FROM ( \
        SELECT ? AS Date, DepartmentID, MatID, MaterialAmount * ? AS NumMats, 0 \
        FROM departments, productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
        WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
      ) AS temp \
      ON DUPLICATE KEY UPDATE InStock = InStock + temp.NumMats' , [ date , completed , "%" + design + "%" , "%" + color + "%" , "%" + nextDepartment + "%" ] ) if ( department === "GrillVelcro" || department === "GrillStickers" || department === "GrillPackaging" ) { db . query ( 'UPDATE amounts, ( \
          SELECT ? AS Date, DepartmentID, MatID \
          FROM departments, productmaterials \
            INNER JOIN products ON productmaterials.ProdID = products.ProductID \
            INNER JOIN materials ON productmaterials.MatID = materials.MaterialID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
            AND ((MaterialName LIKE ? AND MaterialName LIKE ?) OR (MaterialName LIKE ?)) \
        ) AS temp  \
        SET amounts.Lost = amounts.Lost + ? \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID' , [ date , "%" + design + "%" , "%" + color + "%" , "%" + department + "%" , "%" + color + "%" , "%plastic%" , "%grommet%" , lost ] ) return db . query ( 'UPDATE amounts, ( \
          SELECT ? AS Date, 18 AS DepartmentID, MatID, MaterialAmount * ? AS NumMats \
          FROM productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND MatID NOT IN ( \
            SELECT MaterialID FROM materials \
            WHERE MaterialName LIKE ? AND MaterialName LIKE ? OR MaterialName LIKE ? \
          ) \
        ) AS temp  \
        SET amounts.InStock = amounts.InStock + temp.NumMats \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID' , [ date , lost , "%" + design + "%" , "%" + color + "%" , "%" + color + "%" , "%plastic%" , "%grommet%" ] ) } else { db . query ( 'UPDATE amounts, ( \
          SELECT ? AS Date, DepartmentID, MatID \
          FROM departments, productmaterials \
            INNER JOIN products ON productmaterials.ProdID = products.ProductID \
            INNER JOIN materials ON productmaterials.MatID = materials.MaterialID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND DepartmentName LIKE ? \
            AND MaterialName LIKE ? AND MaterialName LIKE ? \
        ) AS temp  \
        SET amounts.Lost = amounts.Lost + ? \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID' , [ date , "%" + design + "%" , "%" + color + "%" , "%" + department + "%" , "%" + color + "%" , "%plastic%" , lost ] ) return db . query ( 'UPDATE amounts, ( \
          SELECT ? AS Date, 18 AS DepartmentID, MatID, MaterialAmount * ? AS NumMats \
          FROM productmaterials INNER JOIN products ON productmaterials.ProdID = products.ProductID \
          WHERE ProductName LIKE ? AND ProductName LIKE ? AND MatID NOT IN ( \
            SELECT MaterialID FROM materials \
            WHERE MaterialName LIKE ? AND MaterialName LIKE ? \
          ) \
        ) AS temp  \
        SET amounts.InStock = amounts.InStock + temp.NumMats \
        WHERE amounts.Date = temp.Date AND amounts.DepID = temp.DepartmentID AND amounts.MatID = temp.MatID' , [ date , lost , "%" + design + "%" , "%" + color + "%" , "%" + color + "%" , "%plastic%" ] ) } }
weren't lost back to the pre-production department.
weren ' t lost back to the pre - production department .
// Pre-production departmentID for Grills is 18. // Pre-production departmentID for Grills is 18.