439 } |
444 } |
440 } |
445 } |
441 |
446 |
442 |
447 |
443 |
448 |
444 |
449 /* |
445 function do_recipes($brews) |
450 * Return recipe ingredients as json functions. |
446 { |
451 */ |
447 global $brouwhulp, $db; |
452 function recipe_style($recipe) |
|
453 { |
|
454 global $db; |
|
455 |
|
456 if ($recipe->STYLE->NAME) |
|
457 $sql = "', st_name='" . mysqli_real_escape_string($db, $recipe->STYLE->NAME); |
|
458 if ($recipe->STYLE->STYLE_LETTER) |
|
459 $sql .= "', st_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); |
|
460 if ($recipe->STYLE->STYLE_GUIDE) { |
|
461 if ($recipe->STYLE->STYLE_GUIDE == "Biertypengids Derek Walsh") { |
|
462 $sql .= "', st_guide='BKG 2015"; |
|
463 } else if ($recipe->STYLE->STYLE_GUIDE == "BKG Biertypen") { |
|
464 $sql .= "', st_guide='BKG 2015"; |
|
465 } else { |
|
466 $sql .= "', st_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); |
|
467 } |
|
468 } |
|
469 if ($recipe->STYLE->CATEGORY) |
|
470 $sql .= "', st_category='" . mysqli_real_escape_string($db, $recipe->STYLE->CATEGORY); |
|
471 if ($recipe->STYLE->CATEGORY_NUMBER) |
|
472 $sql .= "', st_category_number='" . floatval($recipe->STYLE->CATEGORY_NUMBER); |
|
473 if ($recipe->STYLE->TYPE) |
|
474 $sql .= "', st_type='" . mysqli_real_escape_string($db, $recipe->STYLE->TYPE); |
|
475 if ($recipe->STYLE->OG_MIN) |
|
476 $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); |
|
477 if ($recipe->STYLE->OG_MAX) |
|
478 $sql .= "', st_og_max='" . floatval($recipe->STYLE->OG_MAX); |
|
479 if ($recipe->STYLE->FG_MIN) |
|
480 $sql .= "', st_fg_min='" . floatval($recipe->STYLE->FG_MIN); |
|
481 if ($recipe->STYLE->FG_MAX) |
|
482 $sql .= "', st_fg_max='" . floatval($recipe->STYLE->FG_MAX); |
|
483 if ($recipe->STYLE->IBU_MIN) |
|
484 $sql .= "', st_ibu_min='" . floatval($recipe->STYLE->IBU_MIN); |
|
485 if ($recipe->STYLE->IBU_MAX) |
|
486 $sql .= "', st_ibu_max='" . floatval($recipe->STYLE->IBU_MAX); |
|
487 if ($recipe->STYLE->COLOR_MIN) { |
|
488 $srm = floatval($recipe->STYLE->COLOR_MIN); |
|
489 $sql .= "', st_color_min='" . srm_to_ebc($srm); |
|
490 } |
|
491 if ($recipe->STYLE->COLOR_MAX) { |
|
492 $srm = floatval($recipe->STYLE->COLOR_MAX); |
|
493 $sql .= "', st_color_max='" . srm_to_ebc($srm); |
|
494 } |
|
495 if ($recipe->STYLE->CARB_MIN) |
|
496 $sql .= "', st_carb_min='" . floatval($recipe->STYLE->CARB_MIN); |
|
497 if ($recipe->STYLE->CARB_MAX) |
|
498 $sql .= "', st_carb_max='" . floatval($recipe->STYLE->CARB_MAX); |
|
499 if ($recipe->STYLE->ABV_MIN) |
|
500 $sql .= "', st_abv_min='" . floatval($recipe->STYLE->ABV_MIN); |
|
501 if ($recipe->STYLE->ABV_MAX) |
|
502 $sql .= "', st_abv_max='" . floatval($recipe->STYLE->ABV_MAX); |
|
503 return $sql; |
|
504 } |
|
505 |
|
506 function recipe_fermentables($recipe) |
|
507 { |
|
508 global $db; |
|
509 global $pCara; |
|
510 global $pSugar; |
|
511 global $batch_size; |
|
512 global $efficiency; |
|
513 global $colorw; |
|
514 global $f_sugars; |
|
515 |
|
516 $fermentables = "["; |
|
517 $comma = FALSE; |
|
518 foreach ($recipe->FERMENTABLES->FERMENTABLE as $fermentable) { |
|
519 if ($comma) |
|
520 $fermentables .= ','; |
|
521 $comma = TRUE; |
|
522 $fermentables .= '{"f_name":"' . mysqli_real_escape_string($db, $fermentable->NAME) . '"'; |
|
523 $fermentables .= ',"f_origin":"' . mysqli_real_escape_string($db, $fermentable->ORIGIN) . '"'; |
|
524 $fermentables .= ',"f_supplier":"' . mysqli_real_escape_string($db, $fermentable->SUPPLIER) . '"'; |
|
525 $famount = floatval($fermentable->AMOUNT); |
|
526 $fermentables .= ',"f_amount":' . $famount; |
|
527 $fermentables .= ',"f_cost":' . floatval($fermentable->COST); |
|
528 $ftype = mysqli_real_escape_string($db, $fermentable->TYPE); |
|
529 $fermentables .= ',"f_type":"' . $ftype . '"'; |
|
530 $fyield = floatval($fermentable->YIELD); |
|
531 $fermentables .= ',"f_yield":' . $fyield; |
|
532 if ($fermentable->COLOR) { |
|
533 $srm = floatval($fermentable->COLOR); |
|
534 $ebc = srm_to_ebc($srm); |
|
535 } else { |
|
536 $srm = 0; |
|
537 $ebc = 0; |
|
538 } |
|
539 $colorw += ($famount * $srm / $batch_size) * 8.34436; /* Kleurwerking */ |
|
540 $fermentables .= ',"f_color":' . $ebc; |
|
541 if ($fermentable->COARSE_FINE_DIFF) |
|
542 $fermentables .= ',"f_coarse_fine_diff":' . floatval($fermentable->COARSE_FINE_DIFF); |
|
543 else |
|
544 $fermentables .= ',"f_coarse_fine_diff":0'; |
|
545 if ($fermentable->MOISTURE) |
|
546 $fmoisture = floatval($fermentable->MOISTURE); |
|
547 else |
|
548 $fmoisture = 0; |
|
549 $fermentables .= ',"f_moisture":' . $fmoisture; |
|
550 if ($fermentable->DIASTATIC_POWER) |
|
551 $fermentables .= ',"f_diastatic_power":' . floatval($fermentable->DIASTATIC_POWER); |
|
552 else |
|
553 $fermentables .= ',"f_diastatic_power":0'; |
|
554 if ($fermentable->PROTEIN) |
|
555 $fermentables .= ',"f_protein":' . floatval($fermentable->PROTEIN); |
|
556 else |
|
557 $fermentables .= ',"f_protein":0'; |
|
558 if ($fermentable->MAX_IN_BATCH) |
|
559 $fermentables .= ',"f_max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); |
|
560 else |
|
561 $fermentables .= ',"f_max_in_batch":100.0'; |
|
562 $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); |
|
563 if ($fermentable->GRAINTYPE) |
|
564 $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); |
|
565 else |
|
566 $fgraintype = "Base"; |
|
567 $fermentables .= ',"f_graintype":"' . $fgraintype . '"'; |
|
568 if ($fermentable->ADDED) |
|
569 $fadded = mysqli_real_escape_string($db, $fermentable->ADDED); |
|
570 else |
|
571 $fadded = "Mash"; |
|
572 $fermentables .= ',"f_added":"'.$fadded.'"'; |
|
573 ($fermentable->ADD_AFTER_BOIL== "TRUE") ? $fermentables .= ',"f_add_after_boil":true' : $fermentables .= ',"f_add_after_boil":false'; |
|
574 ($fermentable->RECOMMEND_MASH== "TRUE") ? $fermentables .= ',"f_recommend_mash":true' : $fermentables .= ',"f_recommend_mash":false'; |
|
575 if ($fermentable->DISSOLVED_PROTEIN) |
|
576 $fermentables .= ',"f_dissolved_protein":' . floatval($fermentable->DISSOLVED_PROTEIN); |
|
577 else |
|
578 $fermentables .= ',"f_dissolved_protein":0'; |
|
579 ($fermentable->ADJUST_TO_TOTAL_100 == "TRUE") ? $fermentables .= ',"f_adjust_to_total_100":true' : $fermentables .= ',"f_adjust_to_total_100":false'; |
|
580 $percent = floatval($fermentable->PERCENTAGE); |
|
581 $fermentables .= ',"f_percentage":' . $percent; |
|
582 if ($fermentable->DI_pH) |
|
583 $fermentables .= ',"f_di_ph":' . floatval($fermentable->DI_pH); |
|
584 else |
|
585 $fermentables .= ',"f_di_ph":0.0'; |
|
586 $fermentables .= "}"; |
|
587 /* Sugars */ |
|
588 $d = $famount * ($fyield / 100) * (1 - $fmoisture / 100); |
|
589 if ($fadded == "Mash") |
|
590 $d = floatval($efficiency) / 100 * $d; |
|
591 $f_sugars += $d; |
|
592 if ($fgraintype == "Crystal") |
|
593 $pCara += $percent; |
|
594 if ($ftype == "Sugar") |
|
595 $pSugar += $percent; |
|
596 } |
|
597 $fermentables .= ']'; |
|
598 return $fermentables; |
|
599 } |
|
600 |
|
601 function recipe_hops($recipe) |
|
602 { |
|
603 global $db; |
|
604 |
|
605 $hops = "["; |
|
606 $comma = FALSE; |
|
607 foreach ($recipe->HOPS->HOP as $hop) { |
|
608 if ($comma) |
|
609 $hops .= ','; |
|
610 $comma = TRUE; |
|
611 $hops .= '{"h_name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; |
|
612 $hops .= ',"h_amount":' . floatval($hop->AMOUNT); |
|
613 $hops .= ',"h_cost":' . floatval($hop->COST); |
|
614 $hops .= ',"h_type":"' . mysqli_real_escape_string($db, $hop->TYPE) . '"'; |
|
615 $hops .= ',"h_form":"' . mysqli_real_escape_string($db, $hop->FORM) . '"'; |
|
616 $hops .= ',"h_useat":"' . mysqli_real_escape_string($db, $hop->USE) . '"'; |
|
617 if ($hop->TIME) |
|
618 $hops .= ',"h_time":' . floatval($hop->TIME); |
|
619 else |
|
620 $hops .= ',"h_time":0'; |
|
621 $hops .= ',"h_alpha":' . floatval($hop->ALPHA); |
|
622 $hops .= ',"h_beta":' . floatval($hop->BETA); |
|
623 $hops .= ',"h_hsi":' . floatval($hop->HSI); |
|
624 $hops .= ',"h_humulene":' . floatval($hop->HUMULENE); |
|
625 $hops .= ',"h_carophyllene":' . floatval($hop->CAROPHYLLENE); |
|
626 $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE); |
|
627 $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE); |
|
628 if ($hop->TOTAL_OIL) |
|
629 $hops .= ',"h_total_oil":' . floatval($hop->TOTAL_OIL); |
|
630 else |
|
631 $hops .= ',"h_total_oil":0'; |
|
632 if ($hop->ORIGIN) |
|
633 $hops .= ',"h_origin":"' . mysqli_real_escape_string($db, $hop->ORIGIN) . '"'; |
|
634 else |
|
635 $hops .= ',"h_origin":""'; |
|
636 $hops .= "}"; |
|
637 } |
|
638 $hops .= ']'; |
|
639 return $hops; |
|
640 } |
|
641 |
|
642 function recipe_miscs($recipe) |
|
643 { |
|
644 global $db; |
|
645 |
|
646 $miscs = "["; |
|
647 $comma = FALSE; |
|
648 foreach ($recipe->MISCS->MISC as $misc) { |
|
649 if ($comma) |
|
650 $miscs .= ','; |
|
651 $comma = TRUE; |
|
652 $mname = mysqli_real_escape_string($db, $misc->NAME); |
|
653 $miscs .= '{"m_name":"' . $mname . '"'; |
|
654 $miscs .= ',"m_amount":' . floatval($misc->AMOUNT); |
|
655 if ($misc->COST) { |
|
656 $miscs .= ',"m_cost":' . floatval($misc->COST); |
|
657 } else { |
|
658 /* Brouwhulp bug, added water agents have no cost field. */ |
|
659 if ($misc->TYPE == "Water agent") { |
|
660 $miscs .= ',"m_cost":'. get_miscs_cost($mname); |
|
661 } else { |
|
662 $miscs .= ',"m_cost":0'; |
|
663 } |
|
664 } |
|
665 $miscs .= ',"m_type":"' . mysqli_real_escape_string($db, $misc->TYPE) . '"'; |
|
666 $miscs .= ',"m_use_use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; |
|
667 ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":true' : $miscs.= ',"m_amount_is_weight":false'; |
|
668 if ($misc->TIME) |
|
669 $miscs .= ',"m_time":' . floatval($misc->TIME); |
|
670 else |
|
671 $miscs .= ',"m_time":0'; |
|
672 $miscs .= "}"; |
|
673 } |
|
674 $miscs .= ']'; |
|
675 return $miscs; |
|
676 } |
|
677 |
|
678 function recipe_yeasts($recipe) |
|
679 { |
|
680 global $db; |
|
681 |
|
682 $yeasts = "["; |
|
683 $comma = FALSE; |
|
684 foreach ($recipe->YEASTS->YEAST as $yeast) { |
|
685 if ($comma) |
|
686 $yeasts .= ','; |
|
687 $comma = TRUE; |
|
688 $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; |
|
689 $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); |
|
690 if ($yeast->COST) |
|
691 $yeasts .= ',"y_cost":' . floatval($yeast->COST); |
|
692 else |
|
693 $yeasts .= ',"y_cost":0'; |
|
694 $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; |
|
695 $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; |
|
696 $yeasts .= ',"y_type":"' . mysqli_real_escape_string($db, $yeast->TYPE) . '"'; |
|
697 $yeasts .= ',"y_form":"' . mysqli_real_escape_string($db, $yeast->FORM) . '"'; |
|
698 ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":true' : $yeasts.= ',"y_amount_is_weight":false'; |
|
699 if ($yeast->ADD_TO_SECONDARY=="FALSE") { |
|
700 $yeasts .= ',"y_use":"Primary"'; |
|
701 $svg = floatval($yeast->ATTENUATION); |
|
702 } else if ($yeast->PRODUCT_ID=="F2") { |
|
703 $yeasts .= ',"y_use":"Bottle"'; |
|
704 } else { |
|
705 $yeasts .= ',"y_use":"Secondary"'; |
|
706 } |
|
707 $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE); |
|
708 $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE); |
|
709 $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION); |
|
710 $yeasts .= "}"; |
|
711 } |
|
712 $yeasts .= ']'; |
|
713 return $yeasts; |
|
714 } |
|
715 |
|
716 function recipe_waters($recipe, $db) |
|
717 { |
|
718 $waters = "["; |
|
719 $comma = FALSE; |
|
720 foreach ($recipe->WATERS->WATER as $water) { |
|
721 if ($comma) |
|
722 $waters .= ','; |
|
723 $comma = TRUE; |
|
724 $waters .= '{"w_name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; |
|
725 $waters .= ',"w_amount":' . floatval($water->AMOUNT); |
|
726 if ($water->CALCIUM) |
|
727 $waters .= ',"w_calcium":' . floatval($water->CALCIUM); |
|
728 if ($water->SULFATE) |
|
729 $waters .= ',"w_sulfate":' . floatval($water->SULFATE); |
|
730 if ($water->CHLORIDE) |
|
731 $waters .= ',"w_chloride":' . floatval($water->CHLORIDE); |
|
732 if ($water->SODIUM) |
|
733 $waters .= ',"w_sodium":' . floatval($water->SODIUM); |
|
734 if ($water->MAGNESIUM) |
|
735 $waters .= ',"w_magnesium":' . floatval($water->MAGNESIUM); |
|
736 if ($water->PH) |
|
737 $waters .= ',"w_ph":' . floatval($water->PH); |
|
738 if ($water->TOTAL_ALKALINITY) |
|
739 $waters .= ',"w_total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); |
|
740 if ($water->COST) |
|
741 $waters .= ',"w_cost":' . floatval($water->COST); |
|
742 else |
|
743 $waters .= ',"w_cost":0.00'; |
|
744 $waters .= "}"; |
|
745 } |
|
746 $waters .= ']'; |
|
747 return $waters; |
|
748 } |
|
749 |
|
750 function recipe_mash_steps($recipe) |
|
751 { |
|
752 global $db; |
|
753 |
|
754 $steps = '['; |
|
755 $comma = FALSE; |
|
756 foreach ($recipe->MASH->MASH_STEPS->MASH_STEP as $step) { |
|
757 if ($comma) |
|
758 $steps .= ','; |
|
759 $comma = TRUE; |
|
760 $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; |
|
761 if ($step->TYPE) |
|
762 $steps .= ',"step_type":"' . $step->TYPE . '"'; |
|
763 if ($step->INFUSE_AMOUNT) |
|
764 $steps .= ',"step_infuse_amount":"' . floatval($step->INFUSE_AMOUNT) . '"'; |
|
765 if ($step->STEP_TEMP) |
|
766 $steps .= ',"step_temp":"' . floatval($step->STEP_TEMP) . '"'; |
|
767 if ($step->STEP_TIME) |
|
768 $steps .= ',"step_time":"' . floatval($step->STEP_TIME) . '"'; |
|
769 if ($step->RAMP_TIME) |
|
770 $steps .= ',"ramp_time":"' . floatval($step->RAMP_TIME) . '"'; |
|
771 if ($step->END_TEMP) |
|
772 $steps .= ',"end_temp":"' . floatval($step->END_TEMP) . '"'; |
|
773 $steps .= "}"; |
|
774 } |
|
775 $steps .= ']'; |
|
776 return $steps; |
|
777 } |
|
778 |
|
779 |
|
780 |
|
781 function do_recipes() |
|
782 { |
|
783 global $brouwhulp, $db, $efficiency, $batch_size, $pCara, $pSugar, $colorw, $f_sugars; |
448 $len_fermentables = 0; |
784 $len_fermentables = 0; |
449 $len_hops = 0; |
785 $len_hops = 0; |
450 $len_miscs = 0; |
786 $len_miscs = 0; |
451 $len_yeasts = 0; |
787 $len_yeasts = 0; |
452 $len_waters = 0; |
788 $len_waters = 0; |
453 $len_mash = 0; |
789 $len_mash = 0; |
454 |
790 |
455 if ($brews) { |
791 echo " Start adding recipes to the database\n"; |
456 echo " Start adding brews to the database\n"; |
792 $sql = "TRUNCATE TABLE recipes;"; |
457 $sql = "TRUNCATE TABLE production;"; |
|
458 } else { |
|
459 echo " Start adding recipes to the database\n"; |
|
460 $sql = "TRUNCATE TABLE recipes;"; |
|
461 } |
|
462 if (! $result = mysqli_query($db, $sql)) { |
793 if (! $result = mysqli_query($db, $sql)) { |
463 printf("Error: %s\n", mysqli_error($db)); |
794 printf("Error: %s\n", mysqli_error($db)); |
464 } |
795 } |
465 |
796 |
466 if ($brews) |
797 $recipes = simplexml_load_file($brouwhulp . '/recipes.xml'); |
467 $recipes = simplexml_load_file($brouwhulp . '/brews.xml'); |
|
468 else |
|
469 $recipes = simplexml_load_file($brouwhulp . '/recipes.xml'); |
|
470 |
798 |
471 foreach ($recipes->RECIPE as $recipe) { |
799 foreach ($recipes->RECIPE as $recipe) { |
472 $f_sugars = 0; |
800 $f_sugars = 0; |
473 $efficiency = 75; |
801 $efficiency = 75; |
474 $batch_size = 20; |
802 $batch_size = 20; |
517 $sql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD); |
842 $sql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD); |
518 if ($recipe->CARBONATION) |
843 if ($recipe->CARBONATION) |
519 $sql .= "', est_carb='" . floatval($recipe->CARBONATION); |
844 $sql .= "', est_carb='" . floatval($recipe->CARBONATION); |
520 |
845 |
521 if ($recipe->STYLE) { |
846 if ($recipe->STYLE) { |
522 if ($recipe->STYLE->NAME) |
847 $sql .= recipe_style($recipe); |
523 $sql .= "', st_name='" . mysqli_real_escape_string($db, $recipe->STYLE->NAME); |
|
524 if ($recipe->STYLE->STYLE_LETTER) |
|
525 $sql .= "', st_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); |
|
526 if ($recipe->STYLE->STYLE_GUIDE) { |
|
527 if ($recipe->STYLE->STYLE_GUIDE == "Biertypengids Derek Walsh") { |
|
528 $sql .= "', st_guide='BKG 2015"; |
|
529 } else if ($recipe->STYLE->STYLE_GUIDE == "BKG Biertypen") { |
|
530 $sql .= "', st_guide='BKG 2015"; |
|
531 } else { |
|
532 $sql .= "', st_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); |
|
533 } |
|
534 } |
|
535 if ($recipe->STYLE->CATEGORY) |
|
536 $sql .= "', st_category='" . mysqli_real_escape_string($db, $recipe->STYLE->CATEGORY); |
|
537 if ($recipe->STYLE->CATEGORY_NUMBER) |
|
538 $sql .= "', st_category_number='" . floatval($recipe->STYLE->CATEGORY_NUMBER); |
|
539 if ($recipe->STYLE->TYPE) |
|
540 $sql .= "', st_type='" . mysqli_real_escape_string($db, $recipe->STYLE->TYPE); |
|
541 if ($recipe->STYLE->OG_MIN) |
|
542 $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); |
|
543 if ($recipe->STYLE->OG_MAX) |
|
544 $sql .= "', st_og_max='" . floatval($recipe->STYLE->OG_MAX); |
|
545 if ($recipe->STYLE->FG_MIN) |
|
546 $sql .= "', st_fg_min='" . floatval($recipe->STYLE->FG_MIN); |
|
547 if ($recipe->STYLE->FG_MAX) |
|
548 $sql .= "', st_fg_max='" . floatval($recipe->STYLE->FG_MAX); |
|
549 if ($recipe->STYLE->IBU_MIN) |
|
550 $sql .= "', st_ibu_min='" . floatval($recipe->STYLE->IBU_MIN); |
|
551 if ($recipe->STYLE->IBU_MAX) |
|
552 $sql .= "', st_ibu_max='" . floatval($recipe->STYLE->IBU_MAX); |
|
553 if ($recipe->STYLE->COLOR_MIN) { |
|
554 $srm = floatval($recipe->STYLE->COLOR_MIN); |
|
555 $sql .= "', st_color_min='" . srm_to_ebc($srm); |
|
556 } |
|
557 if ($recipe->STYLE->COLOR_MAX) { |
|
558 $srm = floatval($recipe->STYLE->COLOR_MAX); |
|
559 $sql .= "', st_color_max='" . srm_to_ebc($srm); |
|
560 } |
|
561 if ($recipe->STYLE->CARB_MIN) |
|
562 $sql .= "', st_carb_min='" . floatval($recipe->STYLE->CARB_MIN); |
|
563 if ($recipe->STYLE->CARB_MAX) |
|
564 $sql .= "', st_carb_max='" . floatval($recipe->STYLE->CARB_MAX); |
|
565 if ($recipe->STYLE->ABV_MIN) |
|
566 $sql .= "', st_abv_min='" . floatval($recipe->STYLE->ABV_MIN); |
|
567 if ($recipe->STYLE->ABV_MAX) |
|
568 $sql .= "', st_abv_max='" . floatval($recipe->STYLE->ABV_MAX); |
|
569 } |
848 } |
570 |
849 |
571 /* |
850 /* |
572 * Put the fermentables in a json array |
851 * Put the fermentables in a json array |
573 */ |
852 */ |
574 if ($recipe->FERMENTABLES) { |
853 if ($recipe->FERMENTABLES) { |
575 $fermentables = "["; |
854 $fermentables = recipe_fermentables($recipe); |
576 $comma = FALSE; |
|
577 foreach ($recipe->FERMENTABLES->FERMENTABLE as $fermentable) { |
|
578 if ($comma) |
|
579 $fermentables .= ','; |
|
580 $comma = TRUE; |
|
581 $fermentables .= '{"f_name":"' . mysqli_real_escape_string($db, $fermentable->NAME) . '"'; |
|
582 $fermentables .= ',"f_origin":"' . mysqli_real_escape_string($db, $fermentable->ORIGIN) . '"'; |
|
583 $fermentables .= ',"f_supplier":"' . mysqli_real_escape_string($db, $fermentable->SUPPLIER) . '"'; |
|
584 $famount = floatval($fermentable->AMOUNT); |
|
585 $fermentables .= ',"f_amount":' . $famount; |
|
586 $fermentables .= ',"f_cost":' . floatval($fermentable->COST); |
|
587 $ftype = mysqli_real_escape_string($db, $fermentable->TYPE); |
|
588 $fermentables .= ',"f_type":"' . $ftype . '"'; |
|
589 $fyield = floatval($fermentable->YIELD); |
|
590 $fermentables .= ',"f_yield":' . $fyield; |
|
591 if ($fermentable->COLOR) { |
|
592 $srm = floatval($fermentable->COLOR); |
|
593 $ebc = srm_to_ebc($srm); |
|
594 } else { |
|
595 $srm = 0; |
|
596 $ebc = 0; |
|
597 } |
|
598 $colorw += ($famount * $srm / $batch_size) * 8.34436; /* Kleurwerking */ |
|
599 $fermentables .= ',"f_color":' . $ebc; |
|
600 if ($fermentable->COARSE_FINE_DIFF) |
|
601 $fermentables .= ',"f_coarse_fine_diff":' . floatval($fermentable->COARSE_FINE_DIFF); |
|
602 else |
|
603 $fermentables .= ',"f_coarse_fine_diff":0'; |
|
604 if ($fermentable->MOISTURE) |
|
605 $fmoisture = floatval($fermentable->MOISTURE); |
|
606 else |
|
607 $fmoisture = 0; |
|
608 $fermentables .= ',"f_moisture":' . $fmoisture; |
|
609 if ($fermentable->DIASTATIC_POWER) |
|
610 $fermentables .= ',"f_diastatic_power":' . floatval($fermentable->DIASTATIC_POWER); |
|
611 else |
|
612 $fermentables .= ',"f_diastatic_power":0'; |
|
613 if ($fermentable->PROTEIN) |
|
614 $fermentables .= ',"f_protein":' . floatval($fermentable->PROTEIN); |
|
615 else |
|
616 $fermentables .= ',"f_protein":0'; |
|
617 if ($fermentable->MAX_IN_BATCH) |
|
618 $fermentables .= ',"f_max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); |
|
619 else |
|
620 $fermentables .= ',"f_max_in_batch":100.0'; |
|
621 $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); |
|
622 if ($fermentable->GRAINTYPE) |
|
623 $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); |
|
624 else |
|
625 $fgraintype = "Base"; |
|
626 $fermentables .= ',"f_graintype":"' . $fgraintype . '"'; |
|
627 if ($fermentable->ADDED) |
|
628 $fadded = mysqli_real_escape_string($db, $fermentable->ADDED); |
|
629 else |
|
630 $fadded = "Mash"; |
|
631 $fermentables .= ',"f_added":"'.$fadded.'"'; |
|
632 ($fermentable->ADD_AFTER_BOIL== "TRUE") ? $fermentables .= ',"f_add_after_boil":true' : $fermentables .= ',"f_add_after_boil":false'; |
|
633 ($fermentable->RECOMMEND_MASH== "TRUE") ? $fermentables .= ',"f_recommend_mash":true' : $fermentables .= ',"f_recommend_mash":false'; |
|
634 if ($fermentable->DISSOLVED_PROTEIN) |
|
635 $fermentables .= ',"f_dissolved_protein":' . floatval($fermentable->DISSOLVED_PROTEIN); |
|
636 else |
|
637 $fermentables .= ',"f_dissolved_protein":0'; |
|
638 ($fermentable->ADJUST_TO_TOTAL_100 == "TRUE") ? $fermentables .= ',"f_adjust_to_total_100":true' : $fermentables .= ',"f_adjust_to_total_100":false'; |
|
639 $percent = floatval($fermentable->PERCENTAGE); |
|
640 $fermentables .= ',"f_percentage":' . $percent; |
|
641 if ($fermentable->DI_pH) |
|
642 $fermentables .= ',"f_di_ph":' . floatval($fermentable->DI_pH); |
|
643 else |
|
644 $fermentables .= ',"f_di_ph":0.0'; |
|
645 $fermentables .= "}"; |
|
646 /* Sugars */ |
|
647 $d = $famount * ($fyield / 100) * (1 - $fmoisture / 100); |
|
648 if ($fadded == "Mash") |
|
649 $d = floatval($efficiency) / 100 * $d; |
|
650 $f_sugars += $d; |
|
651 if ($fgraintype == "Crystal") |
|
652 $pCara += $percent; |
|
653 if ($ftype == "Sugar") |
|
654 $pSugar += $percent; |
|
655 } |
|
656 |
|
657 $fermentables .= ']'; |
|
658 // echo $fermentables . PHP_EOL; |
|
659 $sql .= "', json_fermentables='" . $fermentables; |
855 $sql .= "', json_fermentables='" . $fermentables; |
660 if (strlen($fermentables) > $len_fermentables) |
856 if (strlen($fermentables) > $len_fermentables) |
661 $len_fermentables = strlen($fermentables); |
857 $len_fermentables = strlen($fermentables); |
662 } |
858 } |
663 |
859 |
664 /* |
860 /* |
665 * Put the hops in a json array |
861 * Put the hops in a json array |
666 */ |
862 */ |
667 if ($recipe->HOPS) { |
863 if ($recipe->HOPS) { |
668 $hops = "["; |
864 $hops = recipe_hops($recipe); |
669 $comma = FALSE; |
|
670 foreach ($recipe->HOPS->HOP as $hop) { |
|
671 if ($comma) |
|
672 $hops .= ','; |
|
673 $comma = TRUE; |
|
674 $hops .= '{"h_name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; |
|
675 $hops .= ',"h_amount":' . floatval($hop->AMOUNT); |
|
676 $hops .= ',"h_cost":' . floatval($hop->COST); |
|
677 $hops .= ',"h_type":"' . mysqli_real_escape_string($db, $hop->TYPE) . '"'; |
|
678 $hops .= ',"h_form":"' . mysqli_real_escape_string($db, $hop->FORM) . '"'; |
|
679 $hops .= ',"h_useat":"' . mysqli_real_escape_string($db, $hop->USE) . '"'; |
|
680 if ($hop->TIME) |
|
681 $hops .= ',"h_time":' . floatval($hop->TIME); |
|
682 else |
|
683 $hops .= ',"h_time":0'; |
|
684 $hops .= ',"h_alpha":' . floatval($hop->ALPHA); |
|
685 $hops .= ',"h_beta":' . floatval($hop->BETA); |
|
686 $hops .= ',"h_hsi":' . floatval($hop->HSI); |
|
687 $hops .= ',"h_humulene":' . floatval($hop->HUMULENE); |
|
688 $hops .= ',"h_carophyllene":' . floatval($hop->CAROPHYLLENE); |
|
689 $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE); |
|
690 $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE); |
|
691 if ($hop->TOTAL_OIL) |
|
692 $hops .= ',"h_total_oil":' . floatval($hop->TOTAL_OIL); |
|
693 else |
|
694 $hops .= ',"h_total_oil":0'; |
|
695 if ($hop->ORIGIN) |
|
696 $hops .= ',"h_origin":"' . mysqli_real_escape_string($db, $hop->ORIGIN) . '"'; |
|
697 else |
|
698 $hops .= ',"h_origin":""'; |
|
699 |
|
700 $hops .= "}"; |
|
701 } |
|
702 |
|
703 $hops .= ']'; |
|
704 // echo $hops . PHP_EOL; |
|
705 $sql .= "', json_hops='" . $hops; |
865 $sql .= "', json_hops='" . $hops; |
706 if (strlen($hops) > $len_hops) |
866 if (strlen($hops) > $len_hops) |
707 $len_hops = strlen($hops); |
867 $len_hops = strlen($hops); |
708 } |
868 } |
709 |
869 |
710 /* |
870 /* |
711 * Put the miscs in a json array |
871 * Put the miscs in a json array |
712 */ |
872 */ |
713 if ($recipe->MISCS) { |
873 if ($recipe->MISCS) { |
714 $miscs = "["; |
874 $miscs = recipe_miscs($recipe); |
715 $comma = FALSE; |
|
716 foreach ($recipe->MISCS->MISC as $misc) { |
|
717 if ($comma) |
|
718 $miscs .= ','; |
|
719 $comma = TRUE; |
|
720 $mname = mysqli_real_escape_string($db, $misc->NAME); |
|
721 $miscs .= '{"m_name":"' . $mname . '"'; |
|
722 $miscs .= ',"m_amount":' . floatval($misc->AMOUNT); |
|
723 if ($misc->COST) { |
|
724 $miscs .= ',"m_cost":' . floatval($misc->COST); |
|
725 } else { |
|
726 /* Brouwhulp bug, added water agents have no cost field. */ |
|
727 if ($misc->TYPE == "Water agent") { |
|
728 $miscs .= ',"m_cost":'. get_miscs_cost($mname); |
|
729 } else { |
|
730 $miscs .= ',"m_cost":0'; |
|
731 } |
|
732 } |
|
733 $miscs .= ',"m_type":"' . mysqli_real_escape_string($db, $misc->TYPE) . '"'; |
|
734 $miscs .= ',"m_use_use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; |
|
735 ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":true' : $miscs.= ',"m_amount_is_weight":false'; |
|
736 if ($misc->TIME) |
|
737 $miscs .= ',"m_time":' . floatval($misc->TIME); |
|
738 else |
|
739 $miscs .= ',"m_time":0'; |
|
740 $miscs .= "}"; |
|
741 } |
|
742 |
|
743 $miscs .= ']'; |
|
744 // echo $miscs . PHP_EOL; |
|
745 $sql .= "', json_miscs='" . $miscs; |
875 $sql .= "', json_miscs='" . $miscs; |
746 if (strlen($miscs) > $len_miscs) |
876 if (strlen($miscs) > $len_miscs) |
747 $len_miscs = strlen($miscs); |
877 $len_miscs = strlen($miscs); |
748 } |
878 } |
749 |
879 |
750 /* |
880 /* |
751 * Put the yeasts in a json array |
881 * Put the yeasts in a json array |
752 */ |
882 */ |
753 if ($recipe->YEASTS) { |
883 if ($recipe->YEASTS) { |
754 $yeasts = "["; |
884 $yeasts = recipe_yeasts($recipe); |
755 $comma = FALSE; |
|
756 foreach ($recipe->YEASTS->YEAST as $yeast) { |
|
757 if ($comma) |
|
758 $yeasts .= ','; |
|
759 $comma = TRUE; |
|
760 $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; |
|
761 $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); |
|
762 if ($yeast->COST) |
|
763 $yeasts .= ',"y_cost":' . floatval($yeast->COST); |
|
764 else |
|
765 $yeasts .= ',"y_cost":0'; |
|
766 $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; |
|
767 $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; |
|
768 $yeasts .= ',"y_type":"' . mysqli_real_escape_string($db, $yeast->TYPE) . '"'; |
|
769 $yeasts .= ',"y_form":"' . mysqli_real_escape_string($db, $yeast->FORM) . '"'; |
|
770 ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":true' : $yeasts.= ',"y_amount_is_weight":false'; |
|
771 if ($yeast->ADD_TO_SECONDARY=="FALSE") { |
|
772 $yeasts .= ',"y_use":"Primary"'; |
|
773 $svg = floatval($yeast->ATTENUATION); |
|
774 } else if ($yeast->PRODUCT_ID=="F2") { |
|
775 $yeasts .= ',"y_use":"Bottle"'; |
|
776 } else { |
|
777 $yeasts .= ',"y_use":"Secondary"'; |
|
778 } |
|
779 $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE); |
|
780 $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE); |
|
781 $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION); |
|
782 $yeasts .= "}"; |
|
783 } |
|
784 |
|
785 $yeasts .= ']'; |
|
786 // echo $yeasts . PHP_EOL; |
|
787 $sql .= "', json_yeasts='" . $yeasts; |
885 $sql .= "', json_yeasts='" . $yeasts; |
788 if (strlen($yeasts) > $len_yeasts) |
886 if (strlen($yeasts) > $len_yeasts) |
789 $len_yeasts = strlen($yeasts); |
887 $len_yeasts = strlen($yeasts); |
790 } |
888 } |
791 |
889 |
792 /* |
890 /* |
793 * Put the waters in a json array |
891 * Put the waters in a json array |
794 */ |
892 */ |
795 if ($recipe->WATERS) { |
893 if ($recipe->WATERS) { |
796 $waters = "["; |
894 $waters = recipe_waters($recipe, $db); |
797 $comma = FALSE; |
|
798 foreach ($recipe->WATERS->WATER as $water) { |
|
799 if ($comma) |
|
800 $waters .= ','; |
|
801 $comma = TRUE; |
|
802 $waters .= '{"w_name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; |
|
803 $waters .= ',"w_amount":' . floatval($water->AMOUNT); |
|
804 if ($water->CALCIUM) |
|
805 $waters .= ',"w_calcium":' . floatval($water->CALCIUM); |
|
806 if ($water->SULFATE) |
|
807 $waters .= ',"w_sulfate":' . floatval($water->SULFATE); |
|
808 if ($water->CHLORIDE) |
|
809 $waters .= ',"w_chloride":' . floatval($water->CHLORIDE); |
|
810 if ($water->SODIUM) |
|
811 $waters .= ',"w_sodium":' . floatval($water->SODIUM); |
|
812 if ($water->MAGNESIUM) |
|
813 $waters .= ',"w_magnesium":' . floatval($water->MAGNESIUM); |
|
814 if ($water->PH) |
|
815 $waters .= ',"w_ph":' . floatval($water->PH); |
|
816 if ($water->TOTAL_ALKALINITY) |
|
817 $waters .= ',"w_total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); |
|
818 if ($water->COST) |
|
819 $waters .= ',"w_cost":' . floatval($water->COST); |
|
820 else |
|
821 $waters .= ',"w_cost":0.00'; |
|
822 $waters .= "}"; |
|
823 } |
|
824 |
|
825 $waters .= ']'; |
|
826 // echo $waters . PHP_EOL; |
|
827 $sql .= "', json_waters='" . $waters; |
895 $sql .= "', json_waters='" . $waters; |
828 if (strlen($waters) > $len_waters) |
896 if (strlen($waters) > $len_waters) |
829 $len_waters = strlen($waters); |
897 $len_waters = strlen($waters); |
830 } |
898 } |
831 |
899 |
893 // echo "Mash: " . $len_mash . PHP_EOL; |
939 // echo "Mash: " . $len_mash . PHP_EOL; |
894 } |
940 } |
895 |
941 |
896 |
942 |
897 |
943 |
|
944 function do_brews() |
|
945 { |
|
946 global $brouwhulp, $db, $efficiency, $batch_size, $pCara, $pSugar, $colorw, $f_sugars; |
|
947 $len_fermentables = 0; |
|
948 $len_hops = 0; |
|
949 $len_miscs = 0; |
|
950 $len_yeasts = 0; |
|
951 $len_waters = 0; |
|
952 $len_mash = 0; |
|
953 |
|
954 echo " Start adding brews to the database\n"; |
|
955 $psql = "TRUNCATE TABLE prod_main;"; |
|
956 if (! $presult = mysqli_query($db, $psql)) { |
|
957 printf("Error: %s\n", mysqli_error($db)); |
|
958 } |
|
959 $rsql = "TRUNCATE TABLE prod_recipes;"; |
|
960 if (! $rresult = mysqli_query($db, $rsql)) { |
|
961 printf("Error: %s\n", mysqli_error($db)); |
|
962 } |
|
963 |
|
964 $recipes = simplexml_load_file($brouwhulp . '/brews.xml'); |
|
965 |
|
966 foreach ($recipes->RECIPE as $recipe) { |
|
967 $f_sugars = 0; |
|
968 $efficiency = 75; |
|
969 $batch_size = 20; |
|
970 $boil_size = 22; |
|
971 $pCara = 0; |
|
972 $pSugar = 0; |
|
973 $svg = 77; |
|
974 $colorw = 0; |
|
975 $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); |
|
976 |
|
977 $psql = "INSERT INTO prod_main SET uuid='" . $uuid; // So we can link the records. |
|
978 $rsql = "INSERT INTO prod_recipes SET uuid='" . $uuid; |
|
979 |
|
980 $psql .= "', name='" . mysqli_real_escape_string($db, $recipe->NAME); |
|
981 $rsql .= "', name='" . mysqli_real_escape_string($db, $recipe->NAME); |
|
982 $rsql .= "', locked='0"; |
|
983 |
|
984 if ($recipe->NOTES) |
|
985 $rsql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); |
|
986 else |
|
987 $rsql .= "', notes='"; |
|
988 if ($recipe->TYPE) |
|
989 $rsql .= "', type='" . mysqli_real_escape_string($db, $recipe->TYPE); |
|
990 else |
|
991 $rsql .= "', type='"; |
|
992 if ($recipe->BATCH_SIZE) |
|
993 $batch_size = floatval($recipe->BATCH_SIZE); |
|
994 $rsql .= "', batch_size='" . $batch_size; |
|
995 if ($recipe->BOIL_SIZE) |
|
996 $boil_size = floatval($recipe->BOIL_SIZE); |
|
997 $rsql .= "', boil_size='" . $boil_size; |
|
998 if ($recipe->BOIL_TIME) |
|
999 $rsql .= "', boil_time='" . floatval($recipe->BOIL_TIME); |
|
1000 else |
|
1001 $rsql .= "', boil_time='90"; |
|
1002 if ($recipe->EFFICIENCY) |
|
1003 $efficiency = floatval($recipe->EFFICIENCY); |
|
1004 $rsql .= "', efficiency='" . $efficiency; |
|
1005 /* Don't use $recipe->EST_OG but recalculate it */ |
|
1006 /* Don't use $recipe->EST_FG but recalculate it */ |
|
1007 /* Don't use $recipe->EST_COLOR but recalculate it */ |
|
1008 if ($recipe->COLOR_METHOD) |
|
1009 $rsql .= "', color_method='" . mysqli_real_escape_string($db, $recipe->COLOR_METHOD); |
|
1010 if ($recipe->IBU) |
|
1011 $rsql .= "', est_ibu='" . floatval($recipe->IBU); |
|
1012 if ($recipe->IBU_METHOD) |
|
1013 $rsql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD); |
|
1014 if ($recipe->CARBONATION) |
|
1015 $rsql .= "', est_carb='" . floatval($recipe->CARBONATION); |
|
1016 |
|
1017 if ($recipe->STYLE) { |
|
1018 $rsql .= recipe_style($recipe); |
|
1019 } |
|
1020 |
|
1021 /* |
|
1022 * Put the fermentables in a json array |
|
1023 */ |
|
1024 if ($recipe->FERMENTABLES) { |
|
1025 $fermentables = recipe_fermentables($recipe); |
|
1026 $rsql .= "', json_fermentables='" . $fermentables; |
|
1027 if (strlen($fermentables) > $len_fermentables) |
|
1028 $len_fermentables = strlen($fermentables); |
|
1029 } |
|
1030 |
|
1031 /* |
|
1032 * Put the hops in a json array |
|
1033 */ |
|
1034 if ($recipe->HOPS) { |
|
1035 $hops = recipe_hops($recipe); |
|
1036 $rsql .= "', json_hops='" . $hops; |
|
1037 if (strlen($hops) > $len_hops) |
|
1038 $len_hops = strlen($hops); |
|
1039 } |
|
1040 |
|
1041 /* |
|
1042 * Put the miscs in a json array |
|
1043 */ |
|
1044 if ($recipe->MISCS) { |
|
1045 $miscs = recipe_miscs($recipe); |
|
1046 $rsql .= "', json_miscs='" . $miscs; |
|
1047 if (strlen($miscs) > $len_miscs) |
|
1048 $len_miscs = strlen($miscs); |
|
1049 } |
|
1050 |
|
1051 /* |
|
1052 * Put the yeasts in a json array |
|
1053 */ |
|
1054 if ($recipe->YEASTS) { |
|
1055 $yeasts = recipe_yeasts($recipe); |
|
1056 $rsql .= "', json_yeasts='" . $yeasts; |
|
1057 if (strlen($yeasts) > $len_yeasts) |
|
1058 $len_yeasts = strlen($yeasts); |
|
1059 } |
|
1060 |
|
1061 /* |
|
1062 * Put the waters in a json array |
|
1063 */ |
|
1064 if ($recipe->WATERS) { |
|
1065 $waters = recipe_waters($recipe, $db); |
|
1066 $rsql .= "', json_waters='" . $waters; |
|
1067 if (strlen($waters) > $len_waters) |
|
1068 $len_waters = strlen($waters); |
|
1069 } |
|
1070 |
|
1071 /* |
|
1072 * Put the mash in a json array |
|
1073 */ |
|
1074 if ($recipe->MASH) { |
|
1075 $rsql .= "',mash_sparge_temp='" . floatval($recipe->MASH->SPARGE_TEMP); |
|
1076 $rsql .= "',mash_ph='" . floatval($recipe->MASH->PH); |
|
1077 if ($recipe->MASH->NAME) |
|
1078 $rsql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME); |
|
1079 |
|
1080 if ($recipe->MASH->MASH_STEPS) { |
|
1081 $steps = recipe_mash_steps($recipe); |
|
1082 $rsql .= "', json_mashs='" . $steps; |
|
1083 if (strlen($steps) > $len_mash) |
|
1084 $len_mash = strlen($steps); |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 /* |
|
1089 * Added the calculated values |
|
1090 * OG, FG, color, IBU |
|
1091 */ |
|
1092 $og = estimate_sg($f_sugars, $batch_size); |
|
1093 $rsql .= "', est_og='" . floatval($og); |
|
1094 $fg = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $og); |
|
1095 $rsql .= "', est_fg='" . floatval($fg); |
|
1096 $abv = abvol($og, $fg); |
|
1097 $rsql .= "', est_abv='" . floatval($abv); |
|
1098 $color = kw_to_ebc(mysqli_real_escape_string($db, $recipe->COLOR_METHOD), $colorw); |
|
1099 $rsql .= "', est_color='" . floatval($color); |
|
1100 $rsql .= "';"; |
|
1101 if (! $rresult = mysqli_query($db, $rsql)) { |
|
1102 printf("Error: %s\n", mysqli_error($db)); |
|
1103 } |
|
1104 |
|
1105 if ($recipe->EQUIPMENT) { |
|
1106 $psql .= "', eq_name='" . mysqli_real_escape_string($db, $recipe->EQUIPMENT->NAME); |
|
1107 $psql .= "', eq_boil_size='" . floatval($recipe->EQUIPMENT->BOIL_SIZE); |
|
1108 $psql .= "', eq_batch_size='" . floatval($recipe->EQUIPMENT->BATCH_SIZE); |
|
1109 $psql .= "', eq_tun_volume='" . floatval($recipe->EQUIPMENT->TUN_VOLUME); |
|
1110 $psql .= "', eq_tun_weight='" . floatval($recipe->EQUIPMENT->TUN_WEIGHT); |
|
1111 $psql .= "', eq_tun_specific_heat='" . floatval($recipe->EQUIPMENT->TUN_SPECIFIC_HEAT); |
|
1112 $psql .= "', eq_tun_material='" . mysqli_real_escape_string($db, $recipe->EQUIPMENT->TUN_MATERIAL); |
|
1113 $psql .= "', eq_tun_height='" . floatval($recipe->EQUIPMENT->TUN_HEIGHT); |
|
1114 //$psql .= "', eq_top_up_water='" . floatval($recipe->EQUIPMENT->); |
|
1115 $psql .= "', eq_trub_chiller_loss='" . floatval($recipe->EQUIPMENT->TRUB_CHILLER_LOSS); |
|
1116 $psql .= "', eq_evap_rate='" . floatval($recipe->EQUIPMENT->EVAP_RATE); |
|
1117 $psql .= "', eq_boil_time='" . floatval($recipe->EQUIPMENT->BOIL_TIME); |
|
1118 // eq_calc_boil_volume CALC_BOIL_VOLUME |
|
1119 //$psql .= "', eq_top_up_kettle='" . floatval($recipe->EQUIPMENT->); |
|
1120 $psql .= "', eq_hop_utilization='" . floatval($recipe->EQUIPMENT->HOP_UTILIZATION); |
|
1121 $psql .= "', eq_lauter_volume='" . floatval($recipe->EQUIPMENT->LAUTER_VOLUME); |
|
1122 $psql .= "', eq_lauter_height='" . floatval($recipe->EQUIPMENT->LAUTER_HEIGHT); |
|
1123 $psql .= "', eq_lauter_deadspace='" . floatval($recipe->EQUIPMENT->LAUTER_DEADSPACE); |
|
1124 $psql .= "', eq_kettle_volume='" . floatval($recipe->EQUIPMENT->KETTLE_VOLUME); |
|
1125 $psql .= "', eq_kettle_height='" . floatval($recipe->EQUIPMENT->KETTLE_HEIGHT); |
|
1126 $psql .= "', eq_mash_volume='" . floatval($recipe->EQUIPMENT->MASH_VOLUME); |
|
1127 $psql .= "', eq_efficiency='" . floatval($recipe->EQUIPMENT->EFFICIENCY); |
|
1128 } |
|
1129 |
|
1130 $psql .= "';"; |
|
1131 if (! $presult = mysqli_query($db, $psql)) { |
|
1132 printf("Error: %s\n", mysqli_error($db)); |
|
1133 } |
|
1134 } |
|
1135 } |
|
1136 |
|
1137 |
|
1138 |
898 do_fermentables(); |
1139 do_fermentables(); |
899 do_hops(); |
1140 do_hops(); |
900 do_yeasts(); |
1141 do_yeasts(); |
901 do_miscs(); |
1142 do_miscs(); |
902 do_waters(); |
1143 do_waters(); |
903 do_equipments(); |
1144 do_equipments(); |
904 do_styles(); |
1145 do_styles(); |
905 do_mash(); |
1146 do_mash(); |
906 do_recipes(0); |
1147 do_recipes(); |
907 //do_recipes(1); |
1148 do_brews(); |
908 |
1149 |
909 |
1150 |
910 mysqli_close($db); |
1151 mysqli_close($db); |
911 |
1152 |
912 echo "Finished adding data\n"; |
1153 echo "Finished adding data\n"; |