<?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>Adicionar Produto</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;?>/saveproduct" id="form_validator">

        <div class="form-row">
          <div class="form-group col-md-1">
              <label for="inputStatus">Status</label>
              <input type="text" readonly class="form-control" value="Ativo">
            </div>

            <div class="form-group col-md-5" id="validate_name">
              <label for="inputStatus">Descrição do produto (*)</label>
              <input type="text" class="form-control" name="name" data-rules="required">
            </div>

            <div class="form-group col-md-4" id="provider">
              <label for="inputStatus">Fornecedor (*)</label>
              <select name="provider" class="form-control">
                <?php foreach($providers as $provider): ?>
                  <option value="<?= $provider['id'] ?>" ><?= $provider['company_name']; ?></option>
                <?php endforeach; ?>
              </select>
              <div class="pro_error"></div>
            </div>

            <div class="form-group col-md-2" id="validate_group">
              <label for="inputStatus">Grupo (*)</label>
              <select name="group" class="form-control">
                <option value="0">Selecionar</option>
                <?php foreach($groups as $group): ?>
                  <option value="<?= $group['id'] ?>" ><?= $group['name']; ?></option>
                <?php endforeach; ?>
              </select>
              <div class="gro_error"></div>
            </div>

        </div>

        <div class="form-row">
          <div class="form-group col-md-2" id="validate_unity">
              <label for="inputStatus">Unidade (*)</label>
              <select name="unity" class="form-control">
                <option value="0">Selecionar</option>
                <?php foreach($units as $unit): ?>
                  <option value="<?= $unit['id'] ?>" ><?= $unit['name']; ?></option>
                <?php endforeach; ?>
              </select>
              <div class="uni_error"></div>
            </div>

            <div class="form-group col-md-2" id="presentation">
              <label for="inputStatus">Apresentação (*)</label>
              <select name="presentation" class="form-control">
                <option value="0">Selecionar</option>
                <?php foreach($presentations as $presentation): ?>
                  <option value="<?= $presentation['id'] ?>" ><?= $presentation['name']; ?></option>
                <?php endforeach; ?>
              </select>
              <div class="pre_error"></div>
            </div>

            <div class="form-group col-md-2">
              <label for="inputStatus">Estoque</label>
              <input type="text" class="form-control" name="amount" readonly id="amount">
            </div>

            <div class="form-group col-md-2" >
              <label for="inputStatus">Preço de custo</label>
              <input type="text" class="form-control" readonly id="cost_price" value="000">
            </div>

            <div class="form-group col-md-2" >
              <label for="inputPriceSale">Preço de venda</label>
              <input type="text" class="form-control" name="price" id="price">
            </div>

            <div class="form-group col-md-2" >
              <label for="value_comission">% comissão</label>
              <input type="text" class="form-control" name="value_comission" id="value_comission">
            </div>

            <div class="form-group col-md-4">
              <label for="inputStatus">Observação</label>
              <textarea name="note" class="form-control" rows="6"></textarea>
            </div>
        </div> 

        <div class="button">
          <button type="submit" class="btn btn-success">Salvar</button>
          <a href="<?=$base;?>/products" class="btn btn-info">Voltar</a>
        </div>
        
      </form>
    </div>
    <script src="<?=$base;?>/assets/js/products.js"></script>
  </div>  		
</div>
<!-- /.content-system -->

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