<?php $render('header', ['loggedUser'=>$loggedUser, 'title'=>$titlePage]); ?>
<?=$render('sidebar', [
  'loggedUser'=>$loggedUser, 
  'pageActive'=>$pageActive,
  'permissions'=>$permissions
]);?>

<!-- Content System -->
<div class="content-wrapper">
  <div class="pages">
    <h3>Cliente: <?= $client['name']; ?></h3>
    <div class="users">
      <!-- Message -->

      <?php if(!empty($error)): ?>
        <div class="alert <?=$error['alertType'];?>" role="alert">
          <?php echo $error['msg']; ?>
        </div>
      <?php endif; ?>

      <!-- /Message -->
      <form method="POST" action="<?= $base; ?>/addfarms" id="form_validator" enctype="multipart/form-data">
        <div class="oculted">
          <span>
            <i>
              <div>
                <input type="hidden" name="type_view" value="add">
                <input type="hidden" name="id_client" value="<?= $client['id']; ?>">
              </div>
            </i>
          </span>
        </div>
        <!-- Dados do usuário -->
        <div class="client-data">
          <h4>Adicionar Fazenda(s)</h4>
          <div class="form-row">
            <div class="form-group col-md-1">
                <label for="inputStatus">Status</label>
                <input type="text" readonly value="Ativo" class="form-control">
              </div>

              <div class="form-group col-md-2" id="farm_name">
                <label for="inputName">Nome da Fazenda (*)</label>
                <input type="text" class="form-control" id="inputName" name="name" data-rules="required" placeholder="Nome da Fazenda" value="<?= (!empty($form))?$form['name']:'' ?>">
              </div>

              <div class="form-group col-md-2" id="insc_state">
                <label for="inputRegistration">Insc. Estadual (*)</label>
                <input type="text" class="form-control" id="inputRegistration" name="state_registration" data-rules="required" placeholder="000000000000" value="<?= (!empty($form))?$form['state_registration']:'' ?>">
              </div>

              <div class="form-group col-md-2">
                <label for="inputResponsible">Responsável</label>
                <input type="text" class="form-control" id="inputResponsible" name="responsible" placeholder="Gerente da Fazenda" value="<?= (!empty($form))?$form['responsible']:'' ?>">
              </div>

              <div class="form-group col-md-2">
                <label for="inputPhone">Fone</label>
                <input type="text" class="form-control" id="inputPhone" name="phone" data-rules="phonecel" placeholder="(00) 00000-0000" value="<?= (!empty($form))?$form['phone']:'' ?>">
            </div>

            <div class="form-group col-md-1">
                <label for="inputState">Estado (*)</label>
                <select class="form-control" name="state">
                  <?php foreach($states as $state): ?>
                    <option value="<?= $state['uf']; ?>"><?= $state['uf']; ?></option>
                  <?php endforeach; ?>
                </select>
            </div>

            <div class="form-group col-md-2">
                <label for="inputCity">Cidade (*)</label>
                <select name="city" class="form-control" id="inputCity">
                  
                </select>
                <div class="errorc"></div>         
            </div>              
          </div>

          <div class="form-row">
            <div class="form-group col-md-4">
                <label for="inputLocation">Localização</label>
                <textarea name="location" id="inputLocation" rows="6" class="form-control"><?= (!empty($form))?$form['location']:'' ?></textarea>
            </div>  

            <div class="form-group col-md-4">
                <label for="script">Roteiro</label>
                <textarea id="script" name="script" class="form-control" rows="6"><?= (!empty($form))?$form['script']:'' ?></textarea>
            </div>    

            <div class="form-group col-md-4">
                <label for="inputNote">Observação</label>
                <textarea class="form-control" id="inputNote" rows="6" name="note"><?= (!empty($form))?$form['note']:'' ?></textarea>
            </div>          
          </div>

          <div class="form-row">
            <div class="form-group col-md-2">
              <label for="inputFile">Anexo (jpeg, jpg, png, pdf)</label>
              <input type="file" name="attachment" class="form-control" id="inputFile">
            </div>
          </div>
        </div>

        <div class="button">
          <button type="submit" class="btn btn-success">Salvar</button>
          <a href="<?= $base; ?>/farms&c=<?= $client['id'] ?>" class="btn btn-info">Voltar</a>
        </div>

      </form>
    </div>
    <script src="<?= $base ?>/assets/js/farms.js"></script>
  </div>  		
</div>
<!-- /.content-system -->

<?=$render('footer');?>