<?php
include 'header.php';
include 'erpc_gp_colaborador_toolbar.php';
include_once 'connect.php';

if(isset($_GET['id'])){
    $id = base64_decode($_GET['id']);
    $consulta = "select  colab.*
                        ,date_format(dt_ultimo_exame, '%d/%m/%Y') dt_ultimo
                        ,date_format(dt_aso_admissional, '%d/%m/%Y') dt_aso
                        ,date_format(dt_proximo_exame, '%d/%m/%Y') dt_proximo
                        ,funcoes.ds_funcao 
                        ,municipios.ds_municipio
                        ,municipios.ds_uf
                        ,ds_banco
                    from erpc_gp_colaboradores colab
                        LEFT JOIN erpc_gp_funcoes funcoes 
                    		ON colab.id_funcao = funcoes.id
                        LEFT JOIN erpc_municipios municipios
                            ON colab.id_municipio = municipios.id
                        LEFT JOIN erpc_financeiro_bancos bancos
                            ON colab.id_banco = bancos.id
                	where   colab.id = $id
                            and colab.st_ativo = 1;";
                    
    $result = mysqli_query($conexao, $consulta);
    if(mysqli_num_rows($result)>0){
        
        $colaborador = mysqli_fetch_array($result);
        
    }
    
}









?>

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <!-- li role="presentation" class="active"><a href="#form1" aria-controls="form1" role="tab" data-toggle="tab">Dados Cadastrais</a></li-->
  <!--
  <li role="presentation"><a href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Form #2</a></li>
  <li role="presentation"><a href="#form3" aria-controls="form3" role="tab" data-toggle="tab">Form #3</a></li>
  <li role="presentation"><a href="#form4" aria-controls="form4" role="tab" data-toggle="tab">Form #4</a></li>
  -->
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="form1">
<form id=validate_custom method=POST action="erpc_gp_colaborador_ws.php">
  <div class=block>
    <div class=header>
      <h2>Editar Colaborador:</h2>
    </div>


    <div class="content controls">
		<div class=form-row>
          <div class=col-md-2><label>ID</label></div>
          <div class=col-md-2><input readonly name="id" value="<?= $colaborador['id']; ?>"/> </div>
        </div>
      	<div class=form-row>
          <div class=col-md-2><label>Nome</label></div>
          <div class=col-md-6><input name="ds_nome" maxlength=50 value="<?= sgcws_attr($colaborador['ds_nome']); ?>" class="validate[required] nouppercase"/> </div>
        </div>
        <div class=form-row>
          <div class=col-md-2><label>Nacionalidade</label></div>
          <div class=col-md-6><input name="ds_nacionalidade" maxlength=50 value="<?= sgcws_attr($colaborador['ds_nacionalidade']); ?>" class="nouppercase"/> </div>
        </div>
        <div class="form-row">
          <div class="col-md-2"><label>Função</label></div>
          <div class="col-md-2">
            <div class="input-group">
              <input requerid type="text" id="id_funcao" name="id_funcao" class="form-control" value="<?= $colaborador['id_funcao']; ?>" />
              <div class="input-group-addon">
                <a href="erpc_gp_funcoes_helper.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="input[name='id_funcao']" data-description="input[name='ds_funcao']" data-title="Selecione:" >
                <span class="fa fa-search"></span></a>
              </div>
            </div>
          </div>
          <div class="col-md-4"><input readonly name="ds_funcao" value="<?= sgcws_attr($colaborador['ds_funcao']); ?>" id="ds_funcao"/></div>
        </div>
        <div class=form-row>
          <div class=col-md-2><label>Telefone:</label></div>
          <div class=col-md-6><input name="ds_telefone" maxlength=255 value="<?= sgcws_attr($colaborador['ds_telefone']); ?>" class="nouppercase"/> </div>
        </div>
		<div class="form-row">
          <div class="col-md-2">
            <label>CPF</label>
          </div>
          <div class="col-md-4">
            <input type="number" maxlength="11" id="ds_cpf" name="ds_cpf" class="form-control" value="<?= sgcws_attr($colaborador['ds_cpf']); ?>" />
          </div>
        </div>
        <div class="form-row">
          <div class="col-md-2">
            <label>RG</label>
          </div>
          <div class="col-md-4">
            <input type="number" maxlength="11" id="ds_rg" name="ds_rg" class="form-control" value="<?= sgcws_attr($colaborador['ds_rg']); ?>" />
          </div>
        </div>
        <div class=form-row>
          <div class=col-md-2><label>CTPS</label></div>
          <div class=col-md-6><input name="ds_ctps" maxlength=255 value="<?= sgcws_attr($colaborador['ds_ctps']); ?>" class="nouppercase"/> </div>
        </div>
        <div class=form-row>
          <div class=col-md-2><label>CTPS Série</label></div>
          <div class=col-md-6><input name="ds_ctps_serie" maxlength=255 value="<?= sgcws_attr($colaborador['ds_ctps_serie']); ?>" class="nouppercase"/> </div>
        </div>
        <div class="form-row">
          <div class="col-md-2">
            <label>CEP</label>
          </div>
          <div class="col-md-4">
            <input type="text" size="8" maxlength=08 name="ds_cep" class="mask_cep" value="<?= sgcws_attr($colaborador['ds_cep']); ?>" />
          </div>
        </div>
        <div class="form-row">
          <div class="col-md-2">
            <label>Endereço</label>
          </div>
          <div class="col-md-4">
            <input type="text" id="ds_endereco" name="ds_endereco" class="form-control getCep_ds_logradouro" value="<?= sgcws_attr($colaborador['ds_endereco']); ?>" />
          </div>
    
          <div class="col-md-2">
            <label>Número</label>
          </div>
          <div class="col-md-4">
            <input type="text" id="ds_numero" name="ds_numero" class="form-control " value="<?= sgcws_attr($colaborador['ds_numero']); ?>" />
          </div> 
        </div>
        <div class="form-row">
          <div class="col-md-2">
            <label>Bairro</label>
          </div>
          <div class="col-md-10">
            <input type="text" id="ds_bairro" name="ds_bairro" class="form-control getCep_ds_bairro" value="<?= sgcws_attr($colaborador['ds_bairro']); ?>" />
          </div>
        </div>
        <div class="form-row">
          <div class="col-md-2"><label>Município</label></div>
          <div class="col-md-2">
            <div class="input-group">
              <input required id="id_municipio" name="id_municipio" value="<?=sgcws_attr($colaborador['id_municipio']); ?>" class="getCep_id_municipio" />
    
              <div class="input-group-addon">
                <a href="erpc_municipios_helper.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="input[name='id_municipio']" data-description="input[name='ds_municipio']" data-title="Selecione:">
                <span class="fa fa-search"></span></a>
              </div>
            </div>
          </div>
          <div class="col-md-4"><input readonly name="ds_municipio" id="ds_municipio" value="<?= sgcws_attr($colaborador['ds_municipio']); ?>" class="getCep_ds_municipio" /></div>
        </div>
        <div class="form-row">
          <div class="col-md-2">
            <label>UF</label>
          </div>
          <div class="col-md-2">
            <input type="text" id="ds_uf" name="ds_uf" class="form-control getCep_ds_uf" value="<?= sgcws_attr($colaborador['ds_uf']); ?>" />
          </div>
        </div>
        <div class=form-row>
			<div class="col-md-2"><label>Data Último Exame</label></div>
			<div class="col-md-6"><input required type=text data-mask="00/00/0000" name="dt_ultimo_exame" id="dt_ultimo_exame" value="<?= sgcws_attr($colaborador['dt_ultimo']); ?>" class="datepicker" /></div>
		</div>
        <div class=form-row>
			<div class="col-md-2"><label>Data Aso Admissional</label></div>
			<div class="col-md-6"><input required type=text data-mask="00/00/0000" name="dt_aso_admissional" id="dt_aso_admissional" value="<?= sgcws_attr($colaborador['dt_aso']); ?>" class="datepicker" /></div>
		</div>
        <div class=form-row>
			<div class="col-md-2"><label>Data Próximo Exame</label></div>
			<div class="col-md-6"><input required type=text data-mask="00/00/0000" name="dt_proximo_exame" id="dt_proximo_exame" value="<?= sgcws_attr($colaborador['dt_proximo']); ?>" class="datepicker" /></div>
		</div>
      	<div class=form-row>
          <div class=col-md-2><label>PIS</label></div>
          <div class=col-md-6><input name="ds_pis" maxlength=255 value="<?= sgcws_attr($colaborador['ds_pis']); ?>" class="nouppercase"/> </div>
        </div>
        <div class="form-row">
          <div class="col-md-2"><label>Banco</label></div>
          <div class="col-md-2">
            <div class="input-group">
              <input required class="form-control" type="number" value="<?= sgcws_attr($colaborador['id_banco']); ?>" name="id_banco" id="id_banco" maxlenght="8">
              <div class="input-group-addon">
              <a href="erpc_financeiro_bancos_helper.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-parameter="" data-value="#id_banco" data-description="#ds_banco" data-title="Selecione:">
              <span class="fa fa-search"></span></a>
            </div>
            </div>
          </div>
          <div class="col-md-4"><input name="ds_banco" id="ds_banco" value="<?= sgcws_attr($colaborador['ds_banco']); ?>" readonly></div>
        </div>
      	<div class=form-row>
          <div class=col-md-2><label>Conta</label></div>
          <div class=col-md-6><input name="ds_conta" maxlength=255 value="<?= sgcws_attr($colaborador['ds_conta']); ?>" class="nouppercase"/> </div>
        </div>
        <div class=form-row>
          <div class=col-md-2><label>Observação</label></div>
          <div class=col-md-6><input name="ds_observacao" maxlength=255 value="<?= sgcws_attr($colaborador['ds_observacao']); ?>" class="nouppercase"/> </div>
        </div>
        <div class=form-row>
          <div class=col-md-2><label>SCORE</label></div>
          <div class=col-md-2><input type=number step="1" name="id_score" value="<?= sgcws_attr($colaborador['id_score']); ?>" maxlength=10 class="nouppercase"/> </div>
        </div>
        <div class="form-row">
          <div class=col-md-2><label>Valor Hora</label></div>
          <div class=col-md-2><input name="vl_hora" id="vl_hora" type="number" value="<?= sgcws_attr($colaborador['vl_valor_hora']); ?>" step="0.01" data-number-to-fixed="2" class="currency"/></div>   
        </div>
        <div class="form-row">
            <div class="col-md-2"><label>Exame Laboratorial</label></div>
            <div class="col-md-5">
              <div class="checked inline"><label> <input type=radio required name=st_exame_laboratorial value="1" <?php if($colaborador['st_exame_laboratorial'] == 1){echo "checked"; } ?>/> Sim </label></div>
              <div class="checked inline"><label> <input type=radio required name=st_exame_laboratorial value="0" <?php if($colaborador['st_exame_laboratorial'] == 0){echo "checked"; } ?>/> Não </label></div>
            </div>
        </div>
        <div class="form-row">
            <div class="col-md-2"><label>Filhos</label></div>
            <div class="col-md-5">
              <div class="checked inline"><label> <input type=radio required name=st_filhos value="1" <?php if($colaborador['$st_filhos'] == 1){echo "checked"; } ?>/> Sim </label></div>
              <div class="checked inline"><label> <input type=radio required name=st_filhos value="0" <?php if($colaborador['$st_filhos'] == 0){echo "checked"; } ?>> Não </label></div>
            </div>
        </div>
      </div>
  	  <!-- Elementos
      <div class=form-row>
        <div class=col-md-3>Select:</div>
        <div class=col-md-9> <select name=s_example class="validate[required] form-control"> <option value></option> <option value=1>Andorra</option> <option value=2>Antarctica</option> <option value=3>Ukraine</option> </select>            <span class=help-block>Required</span> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Checkbox:</div>
        <div class=col-md-9>
          <div class=checkbox-inline> <label> <input type=checkbox class="validate[required] form-control" name=vcheck value="1"/> Enabled </label>              </div>
          <div class=checkbox-inline> <label> <input name=vcheck value=0 type=checkbox disabled=disabled class="validate[required]"/> Disabled </label>              </div>
        </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Radio:</div>
        <div class=col-md-9>
          <div class=checkbox-inline> <label> <input type=radio class=validate[required] name=vradio value="1"/> Enabled </label> </div>
          <div class=checkbox-inline> <label> <input type=radio disabled=disabled class=validate[required] name=vradio value="0"/> Disabled </label>              </div>
        </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Datepicker:</div>
        <div class=col-md-9> <input class="validate[required] datepicker form-control" /> <span class=help-block>Required</span> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Group required:</div>
        <div class=col-md-9> <input class="validate[groupRequired[payments]] form-control" name=credit id=credit /> <span class=help-block>Any of group fields must be filled</span>            </div>
      </div>
      <div class=form-row>
        <div class=col-md-3></div>
        <div class=col-md-9> <input class="validate[groupRequired[payments]] form-control" name=paypal id=paypal /> <span class=help-block>Any of group fields must be filled</span>            </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Condition required:</div>
        <div class=col-md-9> <input name=creditcard id=creditcard placeholder="Credit card"/> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3></div>
        <div class=col-md-9> <input class="validate[condRequired[creditcard]] form-control" id=ccv name=ccv placeholder="CCV" />
          <span
            class=help-block>This field is required if "Credit card" field is filled</span>
        </div>

      </div>
	  -->
	<!-- modal do helper -->
    <div class="row-clear">&nbsp;</div>
    <div class="modal modal-white modal-draggable fade" id="helper-modal-div" tabindex="-1" role="dialog" aria-labelledby="helper-modal-label" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="helper-modal-label">Helper</h4>
          </div>
          <div class="modal-body">
            Aguarde ...
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" id="modalCancel">Cancelar</button>
            <button type="button" class="btn btn-primary" data-dismiss="modal" id="modalOk" disabled="disabled">Selecionar</button>
          </div>
        </div>
      </div>
    </div>
    
    <div class=footer>
      <div class="side pull-right">
        <div class=btn-group>
		        <button class="btn btn-default" type="button" onClick="window.history.go(-1)" value="Voltar">Voltar</button>
            <button class="btn btn-success" type="submit" value="editar" onClick="$('#validate_custom').validationEngine('hide');" name="editar">Editar</button>
		    </div>
      </div>
    </div>

  </div> <!-- Block -->
</form>

  </div>

</div>


<?php
include 'footer.php';
?>
<script type="text/javascript">
jQuery(document).ready(function(){

    $("#dt_inicio").mask("99/99/9999");
    $("#dt_final").mask("99/99/9999");

		// basic chart
		var flash = [[0, 2], [1, 6], [2,3], [3, 8], [4, 5], [5, 13], [6, 8]];
		var html5 = [[0, 5], [1, 4], [2,4], [3, 1], [4, 9], [5, 10], [6, 13]];

		function showTooltip(x, y, contents) {
			jQuery('<div id="tooltip" class="tooltipflot">' + contents + '</div>').css( {
				position: 'absolute',
				display: 'none',
				top: y + 5,
				left: x + 5
			}).appendTo("body").fadeIn(200);
		}


		var plot = jQuery.plot(jQuery("#chartplace2"),
			   [ { data: flash, label: "Flash(x)", color: "#fb6409"}, { data: html5, label: "HTML5(x)", color: "#8cb840"} ], {
				   series: {
					   lines: { show: true, fill: true, fillColor: { colors: [ { opacity: 0.05 }, { opacity: 0.15 } ] } },
					   points: { show: true }
				   },
				   legend: { position: 'nw'},
				   grid: { hoverable: true, clickable: true, borderColor: '#ccc', borderWidth: 1, labelMargin: 10 },
				   yaxis: { min: 0, max: 15 }
				 });

		var previousPoint = null;
		jQuery("#chartplace2").bind("plothover", function (event, pos, item) {
			jQuery("#x").text(pos.x.toFixed(2));
			jQuery("#y").text(pos.y.toFixed(2));

			if(item) {
				if (previousPoint != item.dataIndex) {
					previousPoint = item.dataIndex;

					jQuery("#tooltip").remove();
					var x = item.datapoint[0].toFixed(2),
					y = item.datapoint[1].toFixed(2);

					showTooltip(item.pageX, item.pageY,
									item.series.label + " of " + x + " = " + y);
				}

			} else {
			   jQuery("#tooltip").remove();
			   previousPoint = null;
			}

		});

		jQuery("#chartplace2").bind("plotclick", function (event, pos, item) {
			if (item) {
				jQuery("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
				plot.highlight(item.series, item.datapoint);
			}
		});


		// bar graph
		var d2 = [];
		for (var i = 0; i <= 10; i += 1)
			d2.push([i, parseInt(Math.random() * 30)]);

		var stack = 0, bars = true, lines = false, steps = false;
		jQuery.plot(jQuery("#bargraph2"), [ d2 ], {
			series: {
				stack: stack,
				lines: { show: lines, fill: true, steps: steps },
				bars: { show: bars, barWidth: 0.6 }
			},
			grid: { hoverable: true, clickable: true, borderColor: '#bbb', borderWidth: 1, labelMargin: 10 },
			colors: ["#8cb840"]
		});

		// calendar
		jQuery('#calendar').datepicker();



});
</script>
<script type="text/javascript" src="js\busca_CEP.js"></script>