<?php include_once "../../class/Carrega.class.php"; if (!empty($_POST['new'])) { $object = new Alimentos(); $object->alimento = $_POST['new']; if ($object->InserirAlimentos()) { echo "<div class='alert alert-success alert-dismissable'>\n <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>\n <h4>\t<i class='icon fa fa-check'></i> Alerta!</h4>\n Alimento cadastrado com sucesso!!\n </div>"; } else { echo "<div class='alert alert-danger alert-dismissable'>\n <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>\n <h4><i class='icon fa fa-ban'></i> Alerta!</h4>\n Erro no cadastro!!\n </div>"; } }
<div class="box-body"> <div class="form-group"> <dl class="dl-horizontal"> <dt>Dia:</dt> <dd><?php echo $comp->dia; ?> </dd> <dt>Data:</dt> <dd><?php echo date('d/m/Y', strtotime($comp->data)); ?> </dd> <dt>Alimentos:</dt> <dd><?php $label = new Alimentos(); $label->labelAlimentos($comp->alimento); ?> </dd> </dl> <form action="EditCardapioObj.php" method="post"> <input type="hidden" name="id" value="<?php echo $id; ?> "/> <div class="col-lg-6 col-xs-12"> <button type="submit" name="retornar" value="retornar" class="btn bg-maroon btn-flat btn-block margin" formaction="ViewCardapiosObj.php"><i class="fa fa-edit"></i> Retornar para lista </button> </div> <div class="col-lg-6 col-xs-12"> <button type="submit" name="editar" value="editar" class="btn btn-warning btn-flat btn-block margin"><i class="fa fa-edit"></i> Editar </button> </div>
<section class="content"> <div class="row"> <!-- left column --> <!-- right column --> <div class="col-lg-12"> <!-- Horizontal Form --> <div class="box box-success"> <div class="box-header with-border"> <h3 class="box-title">Cadastro de alimentos</h3> </div><!-- /.box-header --> <!-- form start --> <?php $id = $_POST["id"]; if (isset($_POST["editar"])) { $edit = new Alimentos(); $comp = $edit->EditarAlimentos($id); if ($edit != null) { ?> <form class="form-horizontal" id="form" method="post" action="CrudAlimento.php"> <div class="box-body"> <div class="form-group"> <label for="dia" class="col-sm-2 control-label">Alimento:</label> <div class="col-sm-10"> <input type="text" name="alimento" class="form-control" placeholder="Digite o alimento aqui" value="<?php echo $comp->alimento; ?> " required> </div> </div> </div><!-- /.box-body -->
<div class="box box-info"> <div class="box-header"> <h3 class="box-title">Listagem de alimentos</h3> <a class="btn btn-info btn-flat pull-right" href="ViewAlimentosObj.php" title="Atualizar resultados" data-toggle="tooltip" data-placement="left"><i class="fa fa-refresh"></i></a> </div><!-- /.box-header --> <div class="box-body"> <table id="dataT" class="table table-bordered table-hover"> <thead> <tr> <th>Alimento</th> <th>Opções</th> </tr> </thead> <tbody> <?php $listar = new Alimentos(); $list = $listar->ListarAlimentos(); if ($list != null) { foreach ($list as $line) { ?> <tr class="odd gradeX"> <form name="view" action="EditAlimentoObj.php" method="post"> <td><?php echo $line->alimento; ?> </td> <td> <input type='hidden' name='id' value='<?php echo $line->id; ?> '>
<?php include_once "../../class/Carrega.class.php"; if (isset($_POST['enviar'])) { $object = new Alimentos(); $object->alimento = $_POST['alimento']; $object->InserirAlimentos(); header("Location:ViewAlimentosObj.php"); } else { if (isset($_POST['atualizar'])) { $object = new Alimentos(); $object->id = $_POST['id']; $object->alimento = $_POST['alimento']; $object->AtualizarAlimentos(); header("Location:ViewAlimentosObj.php"); } else { if (isset($_POST['excluir'])) { $object = new Alimentos(); $object->id = $_POST['id']; $object->ExcluirAlimentos(); header("Location:ViewAlimentosObj.php"); } } }