Exemple #1
0
/**
 * Ensures that data from any request is limited to float values
 *
 * Apply to any string or array taken from a get or post request, or from a
 * cookie.
 * @param   mixed   $input    The input string or array
 * @return  mixed             The float or array thereof
 * @author  Reto Kohli <*****@*****.**>
 */
function contrexx_input2float($input)
{
    if (is_array($input)) {
        $arr = array();
        foreach ($input as $i => $_input) {
            $arr[$i] = contrexx_input2float($_input);
        }
        return $arr;
    }
    return floatval($input);
}
 /**
  * Store the count discounts after editing
  * @return    boolean             True on success, false otherwise
  * @author    Reto Kohli <*****@*****.**>
  */
 function store_discount_count()
 {
     if (!isset($_POST['discountId'])) {
         return true;
     }
     $discountId = intval($_POST['discountId']);
     $discountGroupName = contrexx_input2raw($_POST['discountGroupName']);
     $discountGroupUnit = contrexx_input2raw($_POST['discountGroupUnit']);
     $arrDiscountCount = contrexx_input2int($_POST['discountCount']);
     $arrDiscountRate = contrexx_input2float($_POST['discountRate']);
     return Discount::storeDiscountCount($discountId, $discountGroupName, $discountGroupUnit, $arrDiscountCount, $arrDiscountRate);
 }