diff -r 5020feba78ec -r ccd85f0ed96c www/includes/db_product.php --- a/www/includes/db_product.php Sun Jun 02 19:56:44 2019 +0200 +++ b/www/includes/db_product.php Tue Jun 04 16:37:58 2019 +0200 @@ -258,12 +258,23 @@ $sql .= "', prop4_type='" . $_POST['prop4_type']; $sql .= "', prop4_volume='" . $_POST['prop4_volume']; } - syslog(LOG_NOTICE, $sql); +// syslog(LOG_NOTICE, $sql); $fermentables = '['; $comma = FALSE; if (isset($_POST['fermentables'])) { $array = $_POST['fermentables']; + // Sort the array + $added = array(); + $amount = array(); + for ($i = 0; $i < count($array); $i++) { + $added[] = $array[$i]['f_added']; + $amount[] = $array[$i]['f_amount']; + } + array_multisort($added, SORT_ASC, SORT_NUMERIC, + $amount, SORT_DESC, SORT_NUMERIC, + $array); + // Write the sorted array. foreach($array as $key => $item){ /* * Manual encode to json. @@ -304,6 +315,20 @@ $comma = FALSE; if (isset($_POST['hops'])) { $array = $_POST['hops']; + // Sort the array + $useat = array(); + $time = array(); + $amount = array(); + for ($i = 0; $i < count($array); $i++) { + $useat[] = $array[$i]['h_useat']; + $time[] = $array[$i]['h_time']; + $amount[] = $array[$i]['h_amount']; + } + array_multisort($useat, SORT_ASC, SORT_NUMERIC, + $time, SORT_DESC, SORT_NUMERIC, + $amount, SORT_DESC, SORT_NUMERIC, + $array); + // Write the sorted array. foreach($array as $key => $item){ if ($comma) $hops .= ','; @@ -335,6 +360,20 @@ $comma = FALSE; if (isset($_POST['miscs'])) { $array = $_POST['miscs']; + // Sort the array + $use = array(); + $type = array(); + $amount = array(); + for ($i = 0; $i < count($array); $i++) { + $use[] = $array[$i]['m_use_use']; + $type[] = $array[$i]['m_type']; + $amount[] = $array[$i]['m_amount']; + } + array_multisort($use, SORT_ASC, SORT_NUMERIC, + $type, SORT_ASC, SORT_NUMERIC, + $amount, SORT_DESC, SORT_NUMERIC, + $array); + // Write the sorted array. foreach($array as $key => $item){ if ($comma) $miscs .= ','; @@ -357,6 +396,17 @@ $comma = FALSE; if (isset($_POST['yeasts'])) { $array = $_POST['yeasts']; + // Sort the array + $use = array(); + $amount = array(); + for ($i = 0; $i < count($array); $i++) { + $use[] = $array[$i]['y_use']; + $amount[] = $array[$i]['y_amount']; + } + array_multisort($use, SORT_ASC, SORT_NUMERIC, + $amount, SORT_DESC, SORT_NUMERIC, + $array); + // Write the sorted array. foreach($array as $key => $item){ if ($comma) $yeasts .= ','; @@ -387,6 +437,13 @@ $comma = FALSE; if (isset($_POST['mashs'])) { $array = $_POST['mashs']; + // Sort the array + $temp = array(); + for ($i = 0; $i < count($array); $i++) { + $temp[] = $array[$i]['step_temp']; + } + array_multisort($temp, SORT_ASC, SORT_NUMERIC, $array); + // Write the sorted array. foreach($array as $key => $item){ if ($comma) $mashs .= ',';