# HG changeset patch # User Michiel Broek # Date 1660134778 -7200 # Node ID ca6b3d4f5a97c300fc4b342962f80a18a3b16ea8 # Parent 00e610fc357138ae4fe8d2dbec3e513ebbc21bb7 Removed unused (I hope) database scripts. diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_divides.php --- a/www/includes/db_divides.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,428 +0,0 @@ - false, - 'msg' => 'Ok', -); - -/* - * Server side split batch. Parameters: - * record = original record. - * divide_type = divide moment. - * divide parts = number of divisions - * divide_data = array with { size, factor, part, name, code } where index 0 is original - * - * generate the new records and modify the original record. - * rollback if something goes wrong. - * return ok or error - */ - -if (isset($_POST['record']) && isset($_POST['divide_type']) && isset($_POST['divide_parts']) && isset($_POST['divide_data'])) { - - $record = $_POST['record']; - $divide_parts = $_POST['divide_parts']; - $divide_type = $_POST['divide_type']; - $divide_data = array_reverse($_POST['divide_data'], true); // reverse the array so the master record is last. - - syslog(LOG_NOTICE, "db_divide: record " . $record . " divide_type " . $divide_type . " parts " . $divide_parts); - - foreach ($divide_data as $index => &$split) { - syslog(LOG_NOTICE, "db_divide: index " . $index); - - foreach ($split as $key => &$value) { - syslog(LOG_NOTICE, "db_divide: index " . $index . " key " . $key . " value " . $value); - } - - $result = mysqli_query($link, "SELECT * FROM products WHERE record='" . $record . "'"); - if (! $result) { - syslog(LOG_NOTICE, "db_divide: result: ".mysqli_error($link)); - } - $row = mysqli_fetch_array($result); - $factor = floatval($split['factor']); - - if ($index == 0) { - /* - * Update the main record - */ - $sql = "UPDATE `products` SET "; - $sql .= " brew_sparge_est='" . sprintf("%.1f", $row['brew_sparge_est'] * $factor); - $sql .= "', brew_preboil_volume='" . sprintf("%.1f", $row['brew_preboil_volume'] * $factor); - $sql .= "', brew_aboil_volume='" . sprintf("%.1f", $row['brew_aboil_volume'] * $factor); - $sql .= "', brew_fermenter_volume='" . sprintf("%.1f", $row['brew_fermenter_volume'] * $factor); - $sql .= "', brew_fermenter_extrawater='" . sprintf("%.1f", $row['brew_fermenter_extrawater'] * $factor); - $sql .= "', brew_fermenter_tcloss='" . sprintf("%.1f", $row['brew_fermenter_tcloss'] * $factor); - $sql .= "', package_volume='" . sprintf("%.1f", $row['package_volume'] * $factor); - $sql .= "', package_infuse_amount='" . sprintf("%.1f", $row['package_infuse_amount'] * $factor); - $sql .= "', bottle_amount='" . sprintf("%.1f", $row['bottle_amount'] * $factor); - $sql .= "', bottle_priming_water='" . sprintf("%.3f", $row['bottle_priming_water'] * $factor); - $sql .= "', keg_amount='" . sprintf("%.1f", $row['keg_amount'] * $factor); - $sql .= "', keg_priming_water='" . sprintf("%.3f", $row['keg_priming_water'] * $factor); - $sql .= "', batch_size='" . sprintf("%.2f", $row['batch_size'] * $factor); - $sql .= "', boil_size='" . sprintf("%.2f", $row['boil_size'] * $factor); - $sql .= "', sparge_volume='" . sprintf("%.1f", $row['sparge_volume'] * $factor); - $sql .= "', sparge_acid_amount='" . sprintf("%.5f", $row['sparge_acid_amount'] * $factor); - $sql .= "', w1_amount='" . sprintf("%.2f", $row['w1_amount'] * $factor); - $sql .= "', w2_amount='" . sprintf("%.2f", $row['w2_amount'] * $factor); - $sql .= "', wg_amount='" . sprintf("%.2f", $row['wg_amount'] * $factor); - $sql .= "', prop1_volume='" . sprintf("%.3f", $row['prop1_volume'] * $factor); - $sql .= "', prop2_volume='" . sprintf("%.3f", $row['prop2_volume'] * $factor); - $sql .= "', prop3_volume='" . sprintf("%.3f", $row['prop3_volume'] * $factor); - $sql .= "', prop4_volume='" . sprintf("%.3f", $row['prop4_volume'] * $factor); - $sql .= "', divide_type='" . $divide_type; - $sql .= "', divide_parts='" . $divide_parts; - $sql .= "', divide_part='" . $index; - $sql .= "', divide_size='" . floatval($split['size']); - $sql .= "', divide_factor='". $factor; - // syslog(LOG_NOTICE, "db_divide: index " . $index . " " . $sql); - - } else { - /* - * Insert splitted batches - */ - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql = "INSERT INTO `products` SET "; - $sql .= "name='" . mysqli_real_escape_string($link, $split['name']); - $sql .= "', uuid='" . $uuid; - $sql .= "', code='" . mysqli_real_escape_string($link, $split['code']); - $sql .= "', birth='" . $row['birth']; - $sql .= "', stage='" . $row['stage']; - $sql .= "', notes='" . mysqli_real_escape_string($link, $row['notes']); - $sql .= "', log_brew='" . $row['log_brew']; - $sql .= "', log_fermentation='" . $row['log_fermentation']; - $sql .= "', log_ispindel='" . $row['log_ispindel']; - $sql .= "', log_co2pressure='" . $row['log_co2pressure']; - $sql .= "', inventory_reduced='" . $row['inventory_reduced'];; - $sql .= "', locked='" . $row['locked'];; - // Equipment - $sql .= "', eq_name='" . mysqli_real_escape_string($link, $row['eq_name']); - $sql .= "', eq_boil_size='" . $row['eq_boil_size']; - $sql .= "', eq_batch_size='" . $row['eq_batch_size']; - $sql .= "', eq_tun_volume='" . $row['eq_tun_volume']; - $sql .= "', eq_tun_weight='" . $row['eq_tun_weight']; - $sql .= "', eq_tun_specific_heat='" . $row['eq_tun_specific_heat']; - $sql .= "', eq_tun_material='" . $row['eq_tun_material']; - $sql .= "', eq_tun_height='" . $row['eq_tun_height']; - $sql .= "', eq_top_up_water='" . $row['eq_top_up_water']; - $sql .= "', eq_trub_chiller_loss='" . $row['eq_trub_chiller_loss']; - $sql .= "', eq_evap_rate='" . $row['eq_evap_rate']; - $sql .= "', eq_boil_time='" . $row['eq_boil_time']; - $sql .= "', eq_calc_boil_volume='" . $row['eq_calc_boil_volume']; - $sql .= "', eq_top_up_kettle='" . $row['eq_top_up_kettle']; - $sql .= "', eq_hop_utilization='" . $row['eq_hop_utilization']; - $sql .= "', eq_notes='" . mysqli_real_escape_string($link, $row['eq_notes']); - $sql .= "', eq_lauter_volume='" . $row['eq_lauter_volume']; - $sql .= "', eq_lauter_height='" . $row['eq_lauter_height']; - $sql .= "', eq_lauter_deadspace='" . $row['eq_lauter_deadspace']; - $sql .= "', eq_kettle_volume='" . $row['eq_kettle_volume']; - $sql .= "', eq_kettle_height='" . $row['eq_kettle_height']; - $sql .= "', eq_mash_volume='" . $row['eq_mash_volume']; - $sql .= "', eq_mash_max='" . $row['eq_mash_max']; - $sql .= "', eq_efficiency='" . $row['eq_efficiency']; - // brewdate - if (strlen($row['brew_date_start'])) - $sql .= "', brew_date_start='" . $row['brew_date_start'] . "'"; - else - $sql .= "', brew_date_start=NULL"; - $sql .= ", brew_mash_ph='" . $row['brew_mash_ph']; - $sql .= "', brew_mash_sg='" . $row['brew_mash_sg']; - $sql .= "', brew_mash_efficiency='" . $row['brew_mash_efficiency']; - $sql .= "', brew_sparge_est='" . sprintf("%.1f", $row['brew_sparge_est'] * $factor); - $sql .= "', brew_sparge_ph='" . $row['brew_sparge_ph']; - $sql .= "', brew_preboil_volume='" . sprintf("%.1f", $row['brew_preboil_volume'] * $factor); - $sql .= "', brew_preboil_sg='" . $row['brew_preboil_sg']; - $sql .= "', brew_preboil_ph='" . $row['brew_preboil_ph']; - $sql .= "', brew_preboil_efficiency='" . $row['brew_preboil_efficiency']; - $sql .= "', brew_aboil_volume='" . sprintf("%.1f", $row['brew_aboil_volume'] * $factor); - $sql .= "', brew_aboil_sg='" . $row['brew_aboil_sg']; - $sql .= "', brew_aboil_ph='" . $row['brew_aboil_ph']; - $sql .= "', brew_aboil_efficiency='" . $row['brew_aboil_efficiency']; - $sql .= "', brew_cooling_method='" . $row['brew_cooling_method']; - $sql .= "', brew_cooling_time='" . $row['brew_cooling_time']; - $sql .= "', brew_cooling_to='" . $row['brew_cooling_to']; - $sql .= "', brew_whirlpool9='" . $row['brew_whirlpool9']; - $sql .= "', brew_whirlpool7='" . $row['brew_whirlpool7']; - $sql .= "', brew_whirlpool6='" . $row['brew_whirlpool6']; - $sql .= "', brew_whirlpool2='" . $row['brew_whirlpool2']; - $sql .= "', brew_aeration_time='" . $row['brew_aeration_time']; - $sql .= "', brew_aeration_speed='" . $row['brew_aeration_speed']; - $sql .= "', brew_aeration_type='" . $row['brew_aeration_type']; - $sql .= "', brew_fermenter_volume='" . sprintf("%.1f", $row['brew_fermenter_volume'] * $factor); - $sql .= "', brew_fermenter_extrawater='" . sprintf("%.1f", $row['brew_fermenter_extrawater'] * $factor); - $sql .= "', brew_fermenter_tcloss='" . sprintf("%.1f", $row['brew_fermenter_tcloss'] * $factor); - $sql .= "', brew_fermenter_sg='" . $row['brew_fermenter_sg']; - $sql .= "', brew_fermenter_ibu='" . $row['brew_fermenter_ibu']; - $sql .= "', brew_fermenter_color='" . $row['brew_fermenter_color']; - if (strlen($row['brew_date_end'])) - $sql .= "', brew_date_end='" . $row['brew_date_end'] . "'"; - else - $sql .= "', brew_date_end=NULL"; - $sql .= ", og='" . $row['og']; - $sql .= "', fg='" . $row['fg']; - $sql .= "', primary_start_temp='" . $row['primary_start_temp']; - $sql .= "', primary_max_temp='" . $row['primary_max_temp']; - $sql .= "', primary_end_temp='" . $row['primary_end_temp']; - if (strlen($row['primary_end_date'])) - $sql .= "', primary_end_date='" . $row['primary_end_date'] . "'"; - else - $sql .= "', primary_end_date=NULL"; - $sql .= ", primary_end_sg='" . $row['primary_end_sg']; - $sql .= "', secondary_temp='" . $row['secondary_temp']; - $sql .= "', secondary_end_sg='" . $row['secondary_end_sg']; - if (strlen($row['secondary_end_date'])) - $sql .= "', secondary_end_date='" . $row['secondary_end_date'] . "'"; - else - $sql .= "', secondary_end_date=NULL"; - $sql .= ", tertiary_temp='" . $row['tertiary_temp']; - if (strlen($row['package_date'])) - $sql .= "', package_date='" . $row['package_date'] . "'"; - else - $sql .= "', package_date=NULL"; - $sql .= ", package_volume='" . sprintf("%.1f", $row['package_volume'] * $factor); - $sql .= "', package_infuse_amount='" . sprintf("%.1f", $row['package_infuse_amount'] * $factor); - $sql .= "', package_infuse_abv='" . $row['package_infuse_abv']; - $sql .= "', package_infuse_notes='" . mysqli_real_escape_string($link, $row['package_infuse_notes']); - $sql .= "', package_abv='" . $row['package_abv']; - $sql .= "', package_ph='" . $row['package_ph']; - $sql .= "', bottle_amount='" . sprintf("%.1f", $row['bottle_amount'] * $factor); - $sql .= "', bottle_carbonation='" . $row['bottle_carbonation']; - $sql .= "', bottle_priming_sugar='" . $row['bottle_priming_sugar']; - $sql .= "', bottle_priming_water='" . sprintf("%.3f", $row['bottle_priming_water'] * $factor); - $sql .= "', bottle_priming_amount='" . $row['bottle_priming_amount']; - $sql .= "', bottle_carbonation_temp='" . $row['bottle_carbonation_temp']; - $sql .= "', keg_amount='" . sprintf("%.1f", $row['keg_amount'] * $factor); - $sql .= "', keg_carbonation='" . $row['keg_carbonation']; - $sql .= "', keg_priming_sugar='" . $row['keg_priming_sugar']; - $sql .= "', keg_priming_water='" . sprintf("%.3f", $row['keg_priming_water'] * $factor); - $sql .= "', keg_priming_amount='" . $row['keg_priming_amount']; - $sql .= "', keg_carbonation_temp='" . $row['keg_carbonation_temp']; - $sql .= "', keg_forced_carb='" . $row['keg_forced_carb']; - $sql .= "', keg_pressure='" . $row['keg_pressure']; - $sql .= "', taste_notes='"; - $sql .= "', taste_rate='0"; - $sql .= "', taste_date=NULL"; - $sql .= ", taste_color='"; - $sql .= "', taste_transparency='"; - $sql .= "', taste_head='"; - $sql .= "', taste_aroma='"; - $sql .= "', taste_taste='"; - $sql .= "', taste_mouthfeel='"; - $sql .= "', taste_aftertaste='"; - // Style - $sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']); - $sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']); - $sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']); - $sql .= "', st_type='" . $row['st_type']; - $sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']); - $sql .= "', st_category_number='" . $row['st_category_number']; - $sql .= "', st_og_min='" . $row['st_og_min']; - $sql .= "', st_og_max='" . $row['st_og_max']; - $sql .= "', st_fg_min='" . $row['st_fg_min']; - $sql .= "', st_fg_max='" . $row['st_fg_max']; - $sql .= "', st_ibu_min='" . $row['st_ibu_min']; - $sql .= "', st_ibu_max='" . $row['st_ibu_max']; - $sql .= "', st_color_min='" . $row['st_color_min']; - $sql .= "', st_color_max='" . $row['st_color_max']; - $sql .= "', st_carb_min='" . $row['st_carb_min']; - $sql .= "', st_carb_max='" . $row['st_carb_max']; - $sql .= "', st_abv_min='" . $row['st_abv_min']; - $sql .= "', st_abv_max='" . $row['st_abv_max']; - $sql .= "', type='" . $row['type']; - $sql .= "', batch_size='" . sprintf("%.2f", $row['batch_size'] * $factor); - $sql .= "', boil_size='" . sprintf("%.2f", $row['boil_size'] * $factor); - $sql .= "', boil_time='" . $row['boil_time']; - $sql .= "', efficiency='" . $row['efficiency']; - $sql .= "', est_og='" . $row['est_og']; - $sql .= "', est_og3='" . $row['est_og3']; - $sql .= "', est_fg='" . $row['est_fg']; - $sql .= "', est_abv='" . $row['est_abv']; - $sql .= "', est_carb='" . $row['est_carb']; - $sql .= "', est_color='" . $row['est_color']; - $sql .= "', color_method='" . $row['color_method']; - $sql .= "', est_ibu='" . $row['est_ibu']; - $sql .= "', ibu_method='" . $row['ibu_method']; - $sql .= "', sparge_volume='" . sprintf("%.1f", $row['sparge_volume'] * $factor); - $sql .= "', sparge_acid_amount='" . sprintf("%.5f", $row['sparge_acid_amount'] * $factor); - $sql .= "', sparge_temp='" . $row['sparge_temp']; - $sql .= "', sparge_ph='" . $row['sparge_ph']; - $sql .= "', sparge_source='" . $row['sparge_source']; - $sql .= "', sparge_acid_type='" . $row['sparge_acid_type']; - $sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc']; - $sql .= "', mash_ph='" . $row['mash_ph']; - $sql .= "', mash_name='" . $row['mash_name']; - $sql .= "', calc_acid='" . $row['calc_acid']; - $sql .= "', w1_name='" . mysqli_real_escape_string($link, $row['w1_name']); - $sql .= "', w1_amount='" . sprintf("%.2f", $row['w1_amount'] * $factor); - $sql .= "', w1_calcium='" . $row['w1_calcium']; - $sql .= "', w1_sulfate='" . $row['w1_sulfate']; - $sql .= "', w1_chloride='" . $row['w1_chloride']; - $sql .= "', w1_sodium='" . $row['w1_sodium']; - $sql .= "', w1_magnesium='" . $row['w1_magnesium']; - $sql .= "', w1_total_alkalinity='" . $row['w1_total_alkalinity']; - $sql .= "', w1_ph='" . $row['w1_ph']; - $sql .= "', w1_cost='" . $row['w1_cost']; - $sql .= "', w2_name='" . mysqli_real_escape_string($link, $row['w2_name']); - $sql .= "', w2_amount='" . sprintf("%.2f", $row['w2_amount'] * $factor); - $sql .= "', w2_calcium='" . $row['w2_calcium']; - $sql .= "', w2_sulfate='" . $row['w2_sulfate']; - $sql .= "', w2_chloride='" . $row['w2_chloride']; - $sql .= "', w2_sodium='" . $row['w2_sodium']; - $sql .= "', w2_magnesium='" . $row['w2_magnesium']; - $sql .= "', w2_total_alkalinity='" . $row['w2_total_alkalinity']; - $sql .= "', w2_ph='" . $row['w2_ph']; - $sql .= "', w2_cost='" . $row['w2_cost']; - $sql .= "', wg_amount='" . sprintf("%.2f", $row['wg_amount'] * $factor); - $sql .= "', wg_calcium='" . $row['wg_calcium']; - $sql .= "', wg_sulfate='" . $row['wg_sulfate']; - $sql .= "', wg_chloride='" . $row['wg_chloride']; - $sql .= "', wg_sodium='" . $row['wg_sodium']; - $sql .= "', wg_magnesium='" . $row['wg_magnesium']; - $sql .= "', wg_total_alkalinity='" . $row['wg_total_alkalinity']; - $sql .= "', wg_ph='" . $row['wg_ph']; - $sql .= "', wb_calcium='" . $row['wb_calcium']; - $sql .= "', wb_sulfate='" . $row['wb_sulfate']; - $sql .= "', wb_chloride='" . $row['wb_chloride']; - $sql .= "', wb_sodium='" . $row['wb_sodium']; - $sql .= "', wb_magnesium='" . $row['wb_magnesium']; - $sql .= "', wb_total_alkalinity='" . $row['wb_total_alkalinity']; - $sql .= "', wb_ph='" . $row['wb_ph']; - $sql .= "', wa_acid_name='" . $row['wa_acid_name']; - $sql .= "', wa_acid_perc='" . $row['wa_acid_perc']; - $sql .= "', wa_base_name='" . $row['wa_base_name']; - $sql .= "', starter_enable='" . $row['starter_enable']; - $sql .= "', starter_type='" . $row['starter_type']; - $sql .= "', starter_sg='" . $row['starter_sg']; - $sql .= "', starter_viability='" . $row['starter_viability']; - $sql .= "', prop1_type='" . $row['prop1_type']; - $sql .= "', prop2_type='" . $row['prop2_type']; - $sql .= "', prop3_type='" . $row['prop3_type']; - $sql .= "', prop4_type='" . $row['prop4_type']; - $sql .= "', prop1_volume='" . sprintf("%.3f", $row['prop1_volume'] * $factor); - $sql .= "', prop2_volume='" . sprintf("%.3f", $row['prop2_volume'] * $factor); - $sql .= "', prop3_volume='" . sprintf("%.3f", $row['prop3_volume'] * $factor); - $sql .= "', prop4_volume='" . sprintf("%.3f", $row['prop4_volume'] * $factor); - $sql .= "', divide_type='" . $divide_type; - $sql .= "', divide_parts='" . $divide_parts; - $sql .= "', divide_part='" . $index; - $sql .= "', divide_size='" . floatval($split['size']); - $sql .= "', divide_factor='". $factor; -// syslog(LOG_NOTICE, "db_divide: index " . $index . " " . $sql); - } - - $fermentables = json_decode($row['json_fermentables'], true); - for ($i = 0; $i < count($fermentables); $i++) { - $fermentables[$i]['f_amount'] = sprintf("%.5f", $fermentables[$i]['f_amount'] * $factor); - } - // syslog(LOG_NOTICE, "db_divide: " . str_replace($rescapers,$rreplacements,json_encode($fermentables, JSON_UNESCAPED_UNICODE))); - $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,json_encode($fermentables, JSON_UNESCAPED_UNICODE)); - - $hops = json_decode($row['json_hops'], true); - for ($i = 0; $i < count($hops); $i++) { - $hops[$i]['h_amount'] = sprintf("%.5f", $hops[$i]['h_amount'] * $factor); - } - // syslog(LOG_NOTICE, "db_divide: " . str_replace($rescapers,$rreplacements,json_encode($hops, JSON_UNESCAPED_UNICODE))); - $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,json_encode($hops, JSON_UNESCAPED_UNICODE)); - - $miscs = json_decode($row['json_miscs'], true); - for ($i = 0; $i < count($miscs); $i++) { - $miscs[$i]['m_amount'] = sprintf("%.5f", $miscs[$i]['m_amount'] * $factor); - } - // syslog(LOG_NOTICE, "db_divide: " . str_replace($rescapers,$rreplacements,json_encode($miscs, JSON_UNESCAPED_UNICODE))); - $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,json_encode($miscs, JSON_UNESCAPED_UNICODE)); - - $yeasts = json_decode($row['json_yeasts'], true); - for ($i = 0; $i < count($yeasts); $i++) { - $yeasts[$i]['y_amount'] = sprintf("%.5f", $yeasts[$i]['y_amount'] * $factor); - } - // syslog(LOG_NOTICE, "db_divide: " . str_replace($rescapers,$rreplacements,json_encode($yeasts, JSON_UNESCAPED_UNICODE))); - $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,json_encode($yeasts, JSON_UNESCAPED_UNICODE)); - - $mashs = json_decode($row['json_mashs'], true); - for ($i = 0; $i < count($mashs); $i++) { - $mashs[$i]['step_volume'] = sprintf("%.5f", $mashs[$i]['step_volume'] * $factor); - $mashs[$i]['step_infuse_amount'] = sprintf("%.5f", $mashs[$i]['step_infuse_amount'] * $factor); - } - // syslog(LOG_NOTICE, "db_divide: " . str_replace($rescapers,$rreplacements,json_encode($mashs, JSON_UNESCAPED_UNICODE))); - $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,json_encode($mashs, JSON_UNESCAPED_UNICODE)); - - if ($index == 0) { - $sql .= "' WHERE record='" . $record . "';"; - $result2 = mysqli_query($link, $sql); - if (! $result2) { - syslog(LOG_NOTICE, "db_divide: result: ".mysqli_error($link)); - $response['error'] = true; - $response['msg'] = "Update master result: ".mysqli_error($link); - break; - } else { - syslog(LOG_NOTICE, "db_divide: updated record ".$record." code ".$split['code']); - } - } else { - $sql .= "';"; - $result2 = mysqli_query($link, $sql); - if (! $result2) { - $response['error'] = true; - $response['msg'] = "Insert split record result: ".mysqli_error($link); - syslog(LOG_NOTICE, "db_divide: result: ".mysqli_error($link)); - break; - } else { - $lastid = mysqli_insert_id($link); - syslog(LOG_NOTICE, "db_divide: inserted record ".$lastid." code ".$split['code']); - /* Copy brew log records */ - if ($row['log_brew'] == '1') { - $result3 = mysqli_query($link, "SELECT * FROM log_brews WHERE code='" . $row['code'] . "'"); - if (! $result3) { - syslog(LOG_NOTICE, "db_divide: result3: ".mysqli_error($link)); - } - while ($row3 = mysqli_fetch_array($result3)) { - $sql3 = "INSERT INTO log_brews SET datetime='" . $row3['datetime']; - $sql3 .= "', version='" . $row3['version']; - $sql3 .= "', uuid='" . $uuid; - $sql3 .= "', code='" . mysqli_real_escape_string($link, $split['code']); - $sql3 .= "', name='" . mysqli_real_escape_string($link, $split['name']); - $sql3 .= "', pv_mlt='" . $row3['pv_mlt']; - if (strlen($row3['pv_hlt'])) - $sql3 .= "', pv_hlt='" . $row3['pv_hlt']; - if (strlen($row3['pv_room'])) - $sql3 .= "', pv_room='" . $row3['pv_room']; - $sql3 .= "', sp_mlt='" . $row3['sp_mlt']; - if (strlen($row3['sp_hlt'])) - $sql3 .= "', sp_hlt='" . $row3['sp_hlt']; - $sql3 .= "', pwm_mlt='" . $row3['pwm_mlt']; - if (strlen($row3['pwm_hlt'])) - $sql3 .= "', pwm_hlt='" . $row3['pwm_hlt']; - $sql3 .= "', event='" . $row3['event'] . "';"; - $result4 = mysqli_query($link, $sql3); - if (! $result4) { - syslog(LOG_NOTICE, "db_divide: result4: ".mysqli_error($link)." ".$sql3); - } - } - } - } - } - - } -} else { - syslog(LOG_NOTICE, "db_divide: missing arguments"); - $response['error'] = true; - $response['msg'] = "missing arguments"; -} - -echo json_encode($response); - - -?> diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_inventory_fermentables.php --- a/www/includes/db_inventory_fermentables.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ - false, - 'msg' => 'Ok', -); - -// get data and store in a json array -if (isset($_POST['insert']) || isset($_POST['update'])) { - if (isset($_POST['insert'])) { - $sql = "INSERT INTO `inventory_fermentables` SET "; - } - if (isset($_POST['update'])) { - $sql = "UPDATE `inventory_fermentables` SET "; - } - - if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { - $sql .= "uuid='" . $_POST['uuid']; - } else { - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql .= "uuid='" . $uuid; - } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - $sql .= "', type='" . array_search($_POST['type'], $fermentabletype); - $sql .= "', yield='" . $_POST['yield']; - $sql .= "', color='" . $_POST['color']; - ($_POST['add_after_boil'] == 'true') ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0"; - $sql .= "', origin='" . mysqli_real_escape_string($connect, $_POST['origin']); - $sql .= "', supplier='" . mysqli_real_escape_string($connect, $_POST['supplier']); - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - $sql .= "', coarse_fine_diff='" . $_POST['coarse_fine_diff']; - $sql .= "', moisture='" . $_POST['moisture']; - $sql .= "', diastatic_power='" . $_POST['diastatic_power']; - $sql .= "', protein='" . $_POST['protein']; - $sql .= "', dissolved_protein='" . $_POST['dissolved_protein']; - $sql .= "', max_in_batch='" . $_POST['max_in_batch']; - ($_POST['recommend_mash'] == 'true') ? $sql .= "', recommend_mash='1" : $sql .= "', recommend_mash='0"; - $sql .= "', added='" . array_search($_POST['added'], $added); - ($_POST['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; - $sql .= "', di_ph='" . $_POST['di_ph']; - $sql .= "', acid_to_ph_57='" . $_POST['acid_to_ph_57']; - $sql .= "', graintype='" . array_search($_POST['graintype'], $graintype); - $sql .= "', inventory='" . $_POST['inventory']; - $sql .= "', cost='" . $_POST['cost'] . "'"; - if ($_POST['production_date'] == '') - $sql .= ", production_date=NULL"; - else - $sql .= ", production_date='" . $_POST['production_date'] . "'"; - if ($_POST['tht_date'] == '') - $sql .= ", tht_date=NULL"; - else - $sql .= ", tht_date='" . $_POST['tht_date'] . "'"; - if (isset($_POST['insert'])) { - $sql .= ";"; - } - if (isset($_POST['update'])) { - $sql .= " WHERE record='" . $_POST['record'] . "';"; - } - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_fermentables: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `inventory_fermentables` WHERE record='".$_POST['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_fermentables: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else { - // SELECT COMMAND - $query = "SELECT * FROM inventory_fermentables ORDER BY supplier,name"; - $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $fermentables[] = array( - 'record' => $row['record'], - 'name' => $row['name'], - 'uuid' => $row['uuid'], - 'type' => $fermentabletype[$row['type']], - 'yield' => $row['yield'], - 'color' => $row['color'], - 'add_after_boil' => $row['add_after_boil'], - 'origin' => $row['origin'], - 'supplier' => $row['supplier'], - 'notes' => $row['notes'], - 'coarse_fine_diff' => $row['coarse_fine_diff'], - 'moisture' => $row['moisture'], - 'diastatic_power' => $row['diastatic_power'], - 'protein' => $row['protein'], - 'dissolved_protein' => $row['dissolved_protein'], - 'max_in_batch' => $row['max_in_batch'], - 'recommend_mash' => $row['recommend_mash'], - 'added' => $added[$row['added']], - 'always_on_stock' => $row['always_on_stock'], - 'di_ph' => $row['di_ph'], - 'acid_to_ph_57' => $row['acid_to_ph_57'], - 'graintype' => $graintype[$row['graintype']], - 'inventory' => $row['inventory'], - 'cost' => $row['cost'], - 'production_date' => $row['production_date'], - 'tht_date' => $row['tht_date'] - ); - } - header("Content-type: application/json"); - exit(json_encode($fermentables)); -} - -syslog(LOG_NOTICE, "db_inventory_fermentables: missing arguments"); -$response['error'] = true; -$response['msg'] = "missing arguments"; -echo json_encode($response); - -?> diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_inventory_hops.php --- a/www/includes/db_inventory_hops.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ - false, - 'msg' => 'Ok', -); - -if (isset($_POST['insert']) || isset($_POST['update'])) { - if (isset($_POST['insert'])) { - $sql = "INSERT INTO `inventory_hops` SET "; - } - if (isset($_POST['update'])) { - $sql = "UPDATE `inventory_hops` SET "; - } - - if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { - $sql .= "uuid='" . $_POST['uuid']; - } else { - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql .= "uuid='" . $uuid; - } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - $sql .= "', alpha='" . $_POST['alpha']; - $sql .= "', beta='" . $_POST['beta']; - $sql .= "', humulene='" . $_POST['humulene']; - $sql .= "', caryophyllene='" . $_POST['caryophyllene']; - $sql .= "', cohumulone='" . $_POST['cohumulone']; - $sql .= "', myrcene='" . $_POST['myrcene']; - $sql .= "', hsi='" . $_POST['hsi']; - $sql .= "', type='" . array_search($_POST['type'], $hoptype); - $sql .= "', form='" . array_search($_POST['form'], $hopform); - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - $sql .= "', origin='" . mysqli_real_escape_string($connect, $_POST['origin']); - $sql .= "', substitutes='" . mysqli_real_escape_string($connect, $_POST['substitutes']); - ($_POST['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; - $sql .= "', inventory='" . floatval($_POST['inventory']) / 1000.0; - $sql .= "', cost='" . $_POST['cost'] . "'"; - if ($_POST['production_date'] == '') - $sql .= ", production_date=NULL"; - else - $sql .= ", production_date='" . $_POST['production_date'] . "'"; - if ($_POST['tht_date'] == '') - $sql .= ", tht_date=NULL"; - else - $sql .= ", tht_date='" . $_POST['tht_date'] . "'"; - $sql .= ", total_oil='" . $_POST['total_oil']; - if (isset($_POST['insert'])) { - $sql .= "';"; - } - if (isset($_POST['update'])) { - $sql .= "' WHERE record='" . $_POST['record'] . "';"; - } - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_hops: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `inventory_hops` WHERE record='".$_POST['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_hops: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else { - // SELECT COMMAND - $query = "SELECT * FROM inventory_hops ORDER BY origin,name"; - $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $hops[] = array( - 'record' => $row['record'], - 'name' => $row['name'], - 'uuid' => $row['uuid'], - 'alpha' => $row['alpha'], - 'beta' => $row['beta'], - 'humulene' => $row['humulene'], - 'caryophyllene' => $row['caryophyllene'], - 'cohumulone' => $row['cohumulone'], - 'myrcene' => $row['myrcene'], - 'hsi' => $row['hsi'], - 'type' => $hoptype[$row['type']], - 'form' => $hopform[$row['form']], - 'notes' => $row['notes'], - 'origin' => $row['origin'], - 'substitutes' => $row['substitutes'], - 'always_on_stock' => $row['always_on_stock'], - 'inventory' => floatval($row['inventory']) * 1000.0, - 'cost' => $row['cost'], - 'production_date' => $row['production_date'], - 'tht_date' => $row['tht_date'], - 'total_oil' => $row['total_oil'] - ); - } - header("Content-type: application/json"); - exit(json_encode($hops)); -} - -syslog(LOG_NOTICE, "db_inventory_hops: missing arguments"); -$response['error'] = true; -$response['msg'] = "missing arguments"; -echo json_encode($response); - -?> diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_inventory_miscs.php --- a/www/includes/db_inventory_miscs.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ - false, - 'msg' => 'Ok', -); - -if (isset($_POST['insert']) || isset($_POST['update'])) { - if (isset($_POST['insert'])) { - $sql = "INSERT INTO `inventory_miscs` SET "; - } - if (isset($_POST['update'])) { - $sql = "UPDATE `inventory_miscs` SET "; - } - - if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { - $sql .= "uuid='" . $_POST['uuid']; - } else { - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql .= "uuid='" . $uuid; - } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - $sql .= "', type='" . array_search($_POST['type'], $misctype); - $sql .= "', use_use='" . array_search($_POST['use_use'], $miscuse); - $sql .= "', time='" . $_POST['time']; - ($_POST['amount_is_weight'] == 'true') ? $sql .= "', amount_is_weight='1" : $sql .= "', amount_is_weight='0"; - $sql .= "', use_for='" . mysqli_real_escape_string($connect, $_POST['use_for']); - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - ($_POST['always_on_stock'] == 'true') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; - $sql .= "', inventory='" . floatval($_POST['inventory']) / 1000.0; - $sql .= "', cost='" . $_POST['cost'] . "'"; - if ($_POST['production_date'] == '') - $sql .= ", production_date=NULL"; - else - $sql .= ", production_date='" . $_POST['production_date'] . "'"; - if ($_POST['tht_date'] == '') - $sql .= ", tht_date=NULL"; - else - $sql .= ", tht_date='" . $_POST['tht_date'] . "'"; - - if (isset($_POST['insert'])) { - $sql .= ";"; - } - if (isset($_POST['update'])) { - $sql .= " WHERE record='" . $_POST['record'] . "';"; - } - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_miscs: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `inventory_miscs` WHERE record='".$_POST['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_miscs: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else { - // SELECT COMMAND - $query = "SELECT * FROM inventory_miscs ORDER BY name"; - $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $miscs[] = array( - 'record' => $row['record'], - 'name' => $row['name'], - 'uuid' => $row['uuid'], - 'type' => $misctype[$row['type']], - 'use_use' => $miscuse[$row['use_use']], - 'time' => $row['time'], - 'amount_is_weight' => $row['amount_is_weight'], - 'use_for' => $row['use_for'], - 'notes' => $row['notes'], - 'always_on_stock' => $row['always_on_stock'], - 'inventory' => floatval($row['inventory']) * 1000.0, - 'cost' => $row['cost'], - 'production_date' => $row['production_date'], - 'tht_date' => $row['tht_date'] - ); - } - header("Content-type: application/json"); - exit(json_encode($miscs)); -} - -syslog(LOG_NOTICE, "db_inventory_miscs: missing arguments"); -$response['error'] = true; -$response['msg'] = "missing arguments"; -echo json_encode($response); - -?> diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_inventory_suppliers.php --- a/www/includes/db_inventory_suppliers.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ - false, - 'msg' => 'Ok', -); - -// get data and store in a json array -$query = "SELECT * FROM inventory_suppliers ORDER BY name"; -if (isset($_POST['insert'])) { - // INSERT COMMAND - $sql = "INSERT INTO `inventory_suppliers` SET "; - if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { - $sql .= "uuid='" . $_POST['uuid']; - } else { - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql .= "uuid='" . $uuid; - } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - $sql .= "', address='" . mysqli_real_escape_string($connect, $_POST['address']); - $sql .= "', city='" . mysqli_real_escape_string($connect, $_POST['city']); - $sql .= "', zip='" . mysqli_real_escape_string($connect, $_POST['zip']); - $sql .= "', country='" . mysqli_real_escape_string($connect, $_POST['country']); - $sql .= "', website='" . mysqli_real_escape_string($connect, $_POST['website']); - $sql .= "', email='" . mysqli_real_escape_string($connect, $_POST['email']); - $sql .= "', phone='" . mysqli_real_escape_string($connect, $_POST['phone']); - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - $sql .= "';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_suppliers: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['update'])) { - // UPDATE COMMAND - $sql = "UPDATE `inventory_suppliers` SET uuid='" . $_POST['uuid']; - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - $sql .= "', address='" . mysqli_real_escape_string($connect, $_POST['address']); - $sql .= "', city='" . mysqli_real_escape_string($connect, $_POST['city']); - $sql .= "', zip='" . mysqli_real_escape_string($connect, $_POST['zip']); - $sql .= "', country='" . mysqli_real_escape_string($connect, $_POST['country']); - $sql .= "', website='" . mysqli_real_escape_string($connect, $_POST['website']); - $sql .= "', email='" . mysqli_real_escape_string($connect, $_POST['email']); - $sql .= "', phone='" . mysqli_real_escape_string($connect, $_POST['phone']); - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - $sql .= "' WHERE record='" . $_POST['record'] . "';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_suppliers: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `inventory_suppliers` WHERE record='".$_POST['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_suppliers: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else { - // SELECT COMMAND - $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $suppliers[] = array( - 'record' => $row['record'], - 'uuid' => $row['uuid'], - 'name' => $row['name'], - 'address' => $row['address'], - 'city' => $row['city'], - 'zip' => $row['zip'], - 'country' => $row['country'], - 'website' => $row['website'], - 'email' => $row['email'], - 'phone' => $row['phone'], - 'notes' => $row['notes'] - ); - } - header("Content-type: application/json"); - exit(json_encode($suppliers)); -} - -syslog(LOG_NOTICE, "db_inventory_suppliers: missing arguments"); -$response['error'] = true; -$response['msg'] = "missing arguments"; -echo json_encode($response); - -?> diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_inventory_water.php --- a/www/includes/db_inventory_water.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ - false, - 'msg' => 'Ok', -); - -if (isset($_POST['insert']) || isset($_POST['update'])) { - if (isset($_POST['insert'])) { - $sql = "INSERT INTO `inventory_waters` SET "; - } - if (isset($_POST['update'])) { - $sql = "UPDATE `inventory_waters` SET "; - } - - if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { - $sql .= "uuid='" . $_POST['uuid']; - } else { - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql .= "uuid='" . $uuid; - } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - ($_POST['unlimited_stock'] == 'true') ? $sql .= "', unlimited_stock='1" : $sql .= "', unlimited_stock='0"; - $sql .= "', calcium='" . $_POST['calcium']; - $sql .= "', bicarbonate='" . $_POST['bicarbonate']; - $sql .= "', sulfate='" . $_POST['sulfate']; - $sql .= "', chloride='" . $_POST['chloride']; - $sql .= "', sodium='" . $_POST['sodium']; - $sql .= "', magnesium='" . $_POST['magnesium']; - $sql .= "', ph='" . $_POST['ph']; - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - $sql .= "', total_alkalinity='" . $_POST['total_alkalinity']; - $sql .= "', inventory='" . $_POST['inventory']; - $sql .= "', cost='" . $_POST['cost']; - if (isset($_POST['insert'])) { - $sql .= "';"; - } - if (isset($_POST['update'])) { - $sql .= "' WHERE record='" . $_POST['record'] . "';"; - } - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_waters: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `inventory_waters` WHERE record='".$_POST['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_waters: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else { - // SELECT COMMAND - $query = "SELECT * FROM inventory_waters ORDER BY name"; - $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $waters[] = array( - 'record' => $row['record'], - 'name' => $row['name'], - 'uuid' => $row['uuid'], - 'unlimited_stock' => $row['unlimited_stock'], - 'calcium' => $row['calcium'], - 'bicarbonate' => $row['bicarbonate'], - 'sulfate' => $row['sulfate'], - 'chloride' => $row['chloride'], - 'sodium' => $row['sodium'], - 'magnesium' => $row['magnesium'], - 'ph' => $row['ph'], - 'notes' => $row['notes'], - 'total_alkalinity' => $row['total_alkalinity'], - 'inventory' => $row['inventory'], - 'cost' => $row['cost'] - ); - } - header("Content-type: application/json"); - exit(json_encode($waters)); -} - -syslog(LOG_NOTICE, "db_inventory_water: missing arguments"); -$response['error'] = true; -$response['msg'] = "missing arguments"; -echo json_encode($response); - -?> diff -r 00e610fc3571 -r ca6b3d4f5a97 www/includes/db_inventory_yeasts.php --- a/www/includes/db_inventory_yeasts.php Wed Aug 10 11:43:19 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ - false, - 'msg' => 'Ok', -); - -// get data and store in a json array -if (isset($_POST['insert']) || isset($_POST['update'])) { - if (isset($_POST['insert'])) { - $sql = "INSERT INTO `inventory_yeasts` SET "; - } - if (isset($_POST['update'])) { - $sql = "UPDATE `inventory_yeasts` SET "; - } - - if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { - $sql .= "uuid='" . $_POST['uuid']; - } else { - $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); - $sql .= "uuid='" . $uuid; - } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); - $sql .= "', type='" . array_search($_POST['type'], $yeasttype); - $sql .= "', form='" . array_search($_POST['form'], $yeastform); - $sql .= "', laboratory='" . mysqli_real_escape_string($connect, $_POST['laboratory']); - $sql .= "', product_id='" . mysqli_real_escape_string($connect, $_POST['product_id']); - $sql .= "', short_desc='" . mysqli_real_escape_string($connect, $_POST['short_desc']); - $sql .= "', min_temperature='" . $_POST['min_temperature']; - $sql .= "', max_temperature='" . $_POST['max_temperature']; - $sql .= "', flocculation='" . $_POST['flocculation']; - $sql .= "', attenuation='" . $_POST['attenuation']; - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); - $sql .= "', best_for='" . mysqli_real_escape_string($connect, $_POST['best_for']); - $sql .= "', max_reuse='" . $_POST['max_reuse']; - $sql .= "', cells='" . floatval($_POST['cells']) * 1000000000.0; - $sql .= "', tolerance='" . $_POST['tolerance']; - ($_POST['sta1'] == 'true') ? $sql .= "', sta1='1" : $sql .= "', sta1='0"; - ($_POST['bacteria'] == 'true') ? $sql .= "', bacteria='1" : $sql .= "', bacteria='0"; - ($_POST['harvest_top'] == 'true') ? $sql .= "', harvest_top='1" : $sql .= "', harvest_top='0"; - $sql .= "', harvest_time='" . $_POST['harvest_time']; - $sql .= "', pitch_temperature='" . floatval($_POST['pitch_temperature']); - ($_POST['pofpos'] == 'true') ? $sql .= "', pofpos='1" : $sql .= "', pofpos='0"; - $sql .= "', zymocide='" . $_POST['zymocide']; - $sql .= "', gr_hl_lo='" . $_POST['gr_hl_lo']; - $sql .= "', sg_lo='" . floatval($_POST['sg_lo']); - $sql .= "', gr_hl_hi='" . $_POST['gr_hl_hi']; - $sql .= "', sg_hi='" . floatval($_POST['sg_hi']); - $sql .= "', inventory='" . $_POST['inventory']; - $sql .= "', cost='" . $_POST['cost'] . "'"; - if ($_POST['production_date'] == '') - $sql .= ", production_date=NULL"; - else - $sql .= ", production_date='" . $_POST['production_date'] . "'"; - if ($_POST['tht_date'] == '') - $sql .= ", tht_date=NULL"; - else - $sql .= ", tht_date='" . $_POST['tht_date'] . "'"; - if (isset($_POST['insert'])) { - $sql .= ";"; - } - if (isset($_POST['update'])) { - $sql .= " WHERE record='" . $_POST['record'] . "';"; - } - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else if (isset($_POST['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `inventory_yeasts` WHERE record='".$_POST['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); - $response['error'] = true; - $response['msg'] = "SQL fout: ".mysqli_error($connect); - } - exit(json_encode($response)); - -} else { - // SELECT COMMAND - $query = "SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"; - $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $yeasts[] = array( - 'record' => $row['record'], - 'name' => $row['name'], - 'uuid' => $row['uuid'], - 'type' => $yeasttype[$row['type']], - 'form' => $yeastform[$row['form']], - 'laboratory' => $row['laboratory'], - 'product_id' => $row['product_id'], - 'short_desc' => $row['short_desc'], - 'min_temperature' => $row['min_temperature'], - 'max_temperature' => $row['max_temperature'], - 'flocculation' => $row['flocculation'], - 'attenuation' => $row['attenuation'], - 'notes' => $row['notes'], - 'best_for' => $row['best_for'], - 'max_reuse' => $row['max_reuse'], - 'inventory' => $row['inventory'], - 'cost' => $row['cost'], - 'production_date' => $row['production_date'], - 'tht_date' => $row['tht_date'], - 'cells' => floatval($row['cells']) / 1000000000.0, - 'tolerance' => $row['tolerance'], - 'sta1' => $row['sta1'], - 'bacteria' => $row['bacteria'], - 'harvest_top' => $row['harvest_top'], - 'harvest_time' => $row['harvest_time'], - 'pitch_temperature' => floatval($row['pitch_temperature']), - 'pofpos' => $row['pofpos'], - 'zymocide' => $row['zymocide'], - 'gr_hl_lo' => $row['gr_hl_lo'], - 'sg_lo' => floatval($row['sg_lo']), - 'gr_hl_hi' => $row['gr_hl_hi'], - 'sg_hi' => floatval($row['sg_hi']) - ); - } - header("Content-type: application/json"); - exit(json_encode($yeasts)); -} - -syslog(LOG_NOTICE, "db_inventory_yeasts: missing arguments"); -$response['error'] = true; -$response['msg'] = "missing arguments"; -echo json_encode($response); - -?>