Updates to stock variation calculations

I've updated the way stock levels are worked out, opting for more use of datalist filters, rather than looping in php. I've allowed for choosing two different "low stock" level strategies.
FIX: allowPurcahse should check the VariationsStock level
Also included other 3.1 changes made by @nimeso
Merge pull request #1 from jedateach/patch-1

Updates to stock variation calculations