<?php
/**
 * Created by PhpStorm.
 * User: pejot
 * Date: 2015-03-08
 * Time: 22:39
 */
global $ankieta;
global $data;
global $page;
global $generator;
$ankieta->writeGap();

$ankieta->writeGap();
//$ankieta->writeHeader("REKRUT");
//$ankieta->writeGap();

//[^uncheckById(["P2","P3","P4","P5"])^]
//[^showOrClean(input,["P2","P3","P4","P5","P6"])^]
//[^clean(["P2","P3","P4","P5","P6"])^]
//[^showOrClean($("input[name=P1]"),["P2"])^]

$wiekPr=$ankieta->getValue("WIEKPR");
$wiekLabs=$ankieta->getLabels("WIEKPR");
$wiekLab=explode("-",$wiekLabs[$wiekPr]);
$wiekMin=$wiekLab[0];
$wiekMax=$wiekLab[1];

/* @var Ankieta $ankieta */

$ankieta->setDictAnswerTranslation("PL","OTHER","Proszę wpisać jaka: ");

$answers=array();
$answers[1]="Brolio [^uncheckById(['S5m_99'])^]";
$answers[2]="Kujawski z pierwszego tłoczenia (butelka plastikowa) [^uncheckById(['S5m_99'])^]";
$answers[3]="Kujawski 3 ziarna (butelka szklana) [^uncheckById(['S5m_99'])^]";
$answers[4]="Kujawski z ziołami (np. z czosnkiem, bazylią, pomidorami) [^uncheckById(['S5m_99'])^]";
$answers[5]="Kujawski tłoczony na zimno (butelka szklana) [^uncheckById(['S5m_99'])^]";
$answers[6]="Mazowiecki Mosso [^uncheckById(['S5m_99'])^]";
$answers[7]="Marlibo [^uncheckById(['S5m_99'])^]";
$answers[8]="Oleo [^uncheckById(['S5m_99'])^]";
$answers[9]="Oliwier [^uncheckById(['S5m_99'])^]";
$answers[10]="Polski [^uncheckById(['S5m_99'])^]";
$answers[11]=" Popularny [^uncheckById(['S5m_99'])^]";
$answers[12]="Bartek uniwersalny [^uncheckById(['S5m_99'])^]";
$answers[13]="Vita D’or [^uncheckById(['S5m_99'])^]";
$answers[14]="Wielkopolski [^uncheckById(['S5m_99'])^]";
$answers[15]="Wyborny [^uncheckById(['S5m_99'])^]";
$answers[16]="Beskidzki [^uncheckById(['S5m_99'])^]";
if ($generator==false) {
    shuffleAssoc($answers);
}
$answers[17]="inna marka oleju [-OTHER-] [^uncheckById(['S5m_99'])^]";
$answers[99]="nie ma na liście takiej marki [^uncheckById(['S5m_1','S5m_2','S5m_3','S5m_4','S5m_5','S5m_6','S5m_7','S5m_8','S5m_9','S5m_10','S5m_11','S5m_12','S5m_13','S5m_14','S5m_15','S5m_16','S5m_17'])^]";
$ankieta->writeCheckbox('S5m','Czy na poniższej liście jest wymieniona marka oleju, której nigdy by Pani nie kupiła?',$answers,true,@clean($data['S5m'],NULL),'NUMERIC','');




?>

<script type="text/javascript">

    $(document).ready(function() {
       disableButtons("[name=" + "WIEK" + "]");
    });

    function preSubmit() {
        var ret=checkMinMax('S3');
        if (ret) {enableButtons("[name=" + "WIEK" + "]");}

    }

    function checkMinMax(id) {
        var el = $("input[id='" + id +"']");
        var value=parseFloat(el.val(),10);
        if (value <<?php print $wiekMin;?> || value ><?php print $wiekMax;?>) {
            console.log('bad value ',value);
            el.val('');

            return false;
        }
        return true;
    }

    function recodeAge() {
        console.log('recodeAge');
        var el = $("input[id='" + "S3" +"']");
        var value=parseFloat(el.val(),10);
        if (value<18) {selectRadio('WIEK',0);}
        if (value>=18 && value <=24) {selectRadio('WIEK',1);}
        if (value>=25 && value <=29) {selectRadio('WIEK',2);}
        if (value>=30 && value <=39) {selectRadio('WIEK',3);}
        if (value>=40 && value <=60) {selectRadio('WIEK',4);}
        if (value>=61) {selectRadio('WIEK',6);}
    }


    function doLogicS11(id) {
        console.log('doLogocS11');
        $("input[name='" + 'S6[]' +"']").each(function() {
            var idx=parseFloat($(this).val(),10);
            if ($(this).prop('checked')) {
                console.log('S6_' + idx + ' checked');
                hideCheckboxElement('S11_' + idx);
            } else {
                unHideCheckboxElement('S11_' + idx);
            }
        });

    }

</script>