<?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>Editar Transportadora</h3>
    <div class="users">
      <!-- Message -->

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

      <!-- /Message -->
      <form method="POST" action="<?= $base; ?>/updateshippingcompany" id="form_validator">
        <div class="oculted">
          <span>
            <i>
              <div>
                <input type="hidden" name="type_view" value="edit">
                <input type="hidden" name="id" value="<?= $form['id']; ?>">
              </div>
            </i>
          </span>
        </div>
        <!-- Dados do usuário -->
        <div class="client-data">
          <h4>Dados da Transportadora</h4>
          <div class="form-row">
            <div class="form-group col-md-1">
              <label for="inputStatus">Status</label>
              <select name="status" class="form-control">
                <option value="1" <?= ($form['status'] == 1 )?'selected':''; ?> >Ativo</option>
                <option value="2" <?= ($form['status'] != 1 )?'selected':''; ?> >Inativo</option>
              </select>
            </div>

            <div class="form-group col-md-1">
              <label for="inputTypeClient">Tipo (*)</label>
              <select class="form-control" name="type" id="inputTypeClient">
                  <option value="1" <?= ($form['type'] == 1 )?'selected':''; ?> >PF</option>
                  <option value="2" <?= ($form['type'] != 1 )?'selected':''; ?> >PJ</option>
              </select>
            </div>

            <div class="form-group col-md-2" id="validate_cpf_cnpj">
                <label for="inputCpfCnpj">CPF / CNPJ (*)</label>
                <input type="text" class="form-control" id="cnpj" name="cnpj" data-rules="cnpj" placeholder="00.000.000/0000-00" value="<?= (!empty($form))?$form['cnpj']:'';  ?>">
                <input type="text" class="form-control" id="cpf" name="cpf" data-rules="cpf" placeholder="000.000.000-00" value="<?= (!empty($form))?$form['cpf']:'';  ?>">
            </div>

            <div class="form-group col-md-2" id="validade_state_register">
                <label for="inputBirtDate">Inscrição Estadual</label>
                <input type="text" class="form-control" name="state_registration" id="inputRegistration" maxlength="18" placeholder="5446.5456-45" value="<?= (!empty($form))?$form['state_registration']:'';  ?>">
            </div>

            <div class="form-group col-md-3" id="shippings_company_name">
                <label for="inputName">Razão Social (*)</label>
                <input type="text" class="form-control" id="inputName" name="company_name" data-rules="required"  placeholder="Transportadora xyz LTDA" value="<?= (!empty($form))?$form['company_name']:'';  ?>">
              </div>

            <div class="form-group col-md-3" id="shippings_fantasy_name">
                <label for="inputName">Nome Fantasia (*)</label>
                <input type="text" class="form-control" id="inputName" data-rules="required" name="fantasy_name"  placeholder="Transportadora xyz" value="<?= (!empty($form))?$form['fantasy_name']:'';  ?>">
              </div>
              
            </div>

            <div class="form-row">
              <div class="form-group col-md-2">
                  <label for="inputSecondPhone">Fone Fixo</label>
                  <input type="text" class="form-control" name="second_phone" id="inputSecondPhone" data-rules="phonefix" placeholder="(00) 0000-0000" value="<?= (!empty($form))?$form['second_phone']:'';  ?>">
              </div>

              <div class="form-group col-md-1">
                  <label for="inputCep">CEP</label>
                  <input type="text" class="form-control" id="inputCep" name="cep" placeholder="00000-000" value="<?= (!empty($form))?$form['cep']:'';  ?>">
              </div>

                <div class="form-group col-md-3">
                  <label for="inputPublicPlace">Logradouro</label>
                  <input type="text" class="form-control" id="inputPublicPlace" name="public_place" placeholder="Av. Novo Mundo" value="<?= (!empty($form))?$form['public_place']:'';  ?>">
              </div>

              <div class="form-group col-md-1">
                  <label for="inputState">Estado</label>
                  <select class="form-control" name="state" id="inputState">
                    <?php foreach($states as $state): ?>
                      <option value="<?= $state['uf']; ?>" <?= ($state['uf'] == $form['state'])?'selected':''; ?> ><?= $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">
                    <?php if(!empty($form['city'])): ?>
                      <option value="<?= $form['city'];?>" ><?= $form['city_name'];?></option>
                    <?php endif; ?>
                  </select>
                  <div class="errorc"></div>
              </div>
            </div>

            <div class="form-row">

            <div class="form-group col-md-3">
                <label for="inputNote">Dados bancários</label>
                <textarea class="form-control" id="inputNote" rows="8" name="bank_data" placeholder="Dados bancários..."><?= (!empty($form))?$form['bank_data']:'';  ?></textarea>
            </div>

            <div class="form-group col-md-3">
                <label for="inputNote">Observação</label>
                <textarea class="form-control" id="inputNote" rows="8" name="note" placeholder="Observação sobre a Transportadora..."><?= (!empty($form))?$form['note']:'';  ?></textarea>
            </div>
              
            </div>

            <h4>Dados do contato</h4>
            <div class="form-row">
              <div class="form-group col-md-3">
                <label for="inputName">Nome do Contato</label>
                <input type="text" class="form-control" id="inputName" name="contact_name"  placeholder="Beltrano da Silva" value="<?= (!empty($form))?$form['contact_name']:'';  ?>">
              </div>

              <div class="form-group col-md-2" id="validate_birth_date">
                <label for="inputBirtDate">Data de nascimento</label>
                <input type="text" class="form-control" id="inputBirtDate" name="birthdateShipping" placeholder="00/00/0000" value="<?= (!empty($form))?$form['birth_date']:'';  ?>">
            </div>

            <div class="form-group col-md-3" id="validade_email">
                <label for="inputEmail">E-mail</label>
                <input type="email" class="form-control" id="inputEmail" name="email" data-rules="email" placeholder="email@dominio.com.br" value="<?= (!empty($form))?$form['email']:'';  ?>">
            </div>

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

        <div class="button">
          <button type="submit" class="btn btn-success">Salvar</button>
          <a href="<?= $base; ?>/shippingcompany" class="btn btn-info">Voltar</a>
        </div>  

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

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