Skip to main content
título editado
Link
Luciano Braga
  • 192
  • 1
  • 3
  • 14

Cake PHP - Formulário na view index.ctp

adicionou 9124 caracteres ao conteúdo
Fonte Link
Luciano Braga
  • 192
  • 1
  • 3
  • 14

index.ctpADD

<div class="row">

    <div class="col-md-3">
        <div class="actions">
            <div class="panel panel-default">
                <div class="panel-heading">Ações</div>
                    <div class="panel-body">
                        <ul class="nav nav-pills nav-stacked">
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Compra'), array('action' => 'add'), array('escape' => false)); ?></li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Formas Pagamentos'), array('controller' => 'forma_pagamentos', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Forma Pagamento'), array('controller' => 'forma_pagamentos', 'action' => 'add'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Fornecedores'), array('controller' => 'suppliers', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Novo Fornecedor'), array('controller' => 'suppliers', 'action' => 'add'), array('escape' => false)); ?> </li>
                        </ul>
                    </div><!-- end body -->
            </div><!-- end panel -->
        </div><!-- end actions -->

        <?php echo $this->element('side_totaliza_compras'); ?>
    </div><!-- end col md 3 -->

    <div class="col-md-9">
        <div class="table-responsive">
            <table cellpadding="0" cellspacing="0" class="table table-striped">
                <thead>
                    <tr>
                        <th><?php echo $this->Paginator->sort('supplier_fantasia', 'Fornecedor'); ?></th>
                        <th><?php echo $this->Paginator->sort('data', 'Pedido'); ?></th>
                        <th><?php echo $this->Paginator->sort('entrega', 'Entrega'); ?></th>
                        <th><?php echo $this->Paginator->sort('forma_pagamento_id', 'Tipo'); ?></th>
                        <th><?php echo $this->Paginator->sort('data_pagamento', 'Vencimento'); ?></th>
                        <th><?php echo $this->Paginator->sort('valor'); ?></th>
                        <th><?php echo $this->Paginator->sort('status'); ?></th>
                        <th class="actions"></th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($compras as $compra): ?>
                    <tr>
                        <td>
                            <?php echo $this->Html->link($compra['Supplier']['fantasia'], array('controller' => 'suppliers', 'action' => 'view', $compra['Supplier']['id'])); ?>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                
                                $dataAtual = date('d/m/Y');
                                $dataEntrega = $this->Locale->date($compra['Compra']['entrega']);
                                $diferencaEntrega = $this->Math->diferencaDeDatas($dataAtual, $dataEntrega, 'dias');

                                if ($dataAtual >= $dataEntrega) {
                                    $entregaIcon = 'glyphicon-home';
                                    $entregaColor = 'label label-primary';
                                } else {
                                    $entregaIcon = 'glyphicon-road';
                                    $entregaColor = 'label label-warning';
                                }
                            ?>
                            <!-- <span class="label <?php echo $entregaColor; ?>"><?php echo ( $entregaIcon == "glyphicon-home" ? '' : $diferencaEntrega ); ?> <span class="glyphicon <?php echo $entregaIcon; ?>"></span></span> -->
                            <?php echo h($this->Locale->date($compra['Compra']['entrega'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                $formaPagamento = $compra['FormaPagamento']['id'];

                                switch ($formaPagamento) {
                                    case 1:
                                        $formaPagamentoClass = 'label-danger';
                                        break;

                                    case 2:
                                        $formaPagamentoClass = 'label-info';
                                        break;
                                    
                                    default:
                                        $formaPagamentoClass = 'label-default';
                                        break;
                                }
                            ?>
                            <span class="label <?php echo $formaPagamentoClass; ?>">
                            <?php echo $compra['FormaPagamento']['descricao']; ?>
                            </span>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data_pagamento'])); ?>&nbsp;</td>
                        <td><?php echo h($compra['Compra']['valor']); ?>&nbsp;</td>
                        <td>
                            <?php
                            $statusPedido = $compra['Compra']['status'];
                            switch ($statusPedido) {
                                case 1:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-warning';
                                    $statusPedidoTitle = 'Pedido Realizado.';
                                    break;

                                case 2:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-primary';
                                    $statusPedidoTitle = 'Pedido Entregue.';
                                    break;

                                case 3:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-success';
                                    $statusPedidoTitle = 'Pedido Entregue e Pago.';
                                    break;
                                
                                default:
                                    $statusPedidoIcon = 'glyphicon-asterisk';
                                    $statusPedidoLabel = 'label-default';
                                    $statusPedidoTitle = 'Status não Informado.';
                                    break;
                            }
                            ?>
                            <span title="<?php echo $statusPedidoTitle; ?>" class="label <?php echo $statusPedidoLabel; ?>"><span class="glyphicon <?php echo $statusPedidoIcon; ?>"></span></span>
                            <?php //echo h($compra['Compra']['status']); ?>&nbsp;</td>
                        <td class="actions">
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-search"></span>', array('action' => 'view', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-edit"></span>', array('action' => 'edit', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Form->postLink('<span class="glyphicon glyphicon-remove"></span>', array('action' => 'delete', $compra['Compra']['id']), array('escape' => false), __('Are you sure you want to delete # %s?', $compra['Compra']['id'])); ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <p>
            <small><?php echo $this->Paginator->counter(array('format' => __('Página {:page} de {:pages}, mostrando {:current} registros de um total de {:count}, começando no registro {:start}, terminando em {:end}')));?></small>
        </p>

        <?php
        $params = $this->Paginator->params();
        if ($params['pageCount'] > 1) {
        ?>
        <ul class="pagination pagination-sm">
            <?php
                echo $this->Paginator->prev('&larr; Anterior', array('class' => 'prev','tag' => 'li','escape' => false), '<a onclick="return false;">&larr; Anterior</a>', array('class' => 'prev disabled','tag' => 'li','escape' => false));
                echo $this->Paginator->numbers(array('separator' => '','tag' => 'li','currentClass' => 'active','currentTag' => 'a'));
                echo $this->Paginator->next('Próxima &rarr;', array('class' => 'Próxima','tag' => 'li','escape' => false), '<a onclick="return false;">Next &rarr;</a>', array('class' => 'next disabled','tag' => 'li','escape' => false));
            ?>
        </ul>
        <?php } ?>

    </div> <!-- end col md 9 -->
</div><!-- end row -->
public function add() {
    if ($this->request->is('post')) {
        $this->Compra->create();
        if ($this->Compra->save($this->request->data)) {
            $this->Session->setFlash(__('The compra has been saved.'), 'default', array('class' => 'alert alert-success'));
            return $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The compra could not be saved. Please, try again.'), 'default', array('class' => 'alert alert-danger'));
        }
    }
    $formaPagamentos = $this->Compra->FormaPagamento->find('list', array('fields' => array('FormaPagamento.descricao')));
    $suppliers = $this->Compra->Supplier->find('list', array('fields' => array('Supplier.fantasia')));
    $this->set(compact('formaPagamentos', 'suppliers'));
}

ADD.CTPIndex

<div class="compras form">
  public function <divindex() class="col-md-9">{
        <?php echo $this->Form>Compra->create('Compra', array('role' => 'form')); ?>

           >recursive <div= class="form-group">0;
                <?php echo $this->Form>Paginator->input('valor',>settings = array('class''limit' => 'form-control'20, 'placeholder''order' => 'Valor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data', array('class' => 'form-control', 'placeholder''Compra.data' => 'Data''DESC'));?>
            </div>
            <div class="form-group">
                <?php echoif ($this->Form>request->input('entrega', array>is('class' => 'form-control', 'placeholder' => 'Entrega''requested'));?>
            </div>
            <div class="form-group">{
                <?php echoreturn $this->Form->input('forma_pagamento_id', array>paginate('class' => 'form-control', 'placeholder' => 'Forma de Pagamento', 'label' => 'Forma de Pagamento'));?>
            </div>
           } <divelse class="form-group">{
                <?php echo $this->Form->input('data_pagamento', array>set('type' => 'text', 'class' => 'form-control''compras', 'placeholder' => 'Data Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form>Paginator->input('supplier_id', array>paginate('class' => 'form-control', 'placeholder' => 'Fornecedor', 'label' => 'Fornecedor'));?>
            </div>}
            <div class="form-group">
                <?php$formaPagamentos echo= $this->Form>Compra->input>FormaPagamento->find('status''list', array('options''fields' => array(0 => '[Informe o Status]', 1 => 'Pedido Realizado', 2 => 'Pedido Entregue', 3 => 'Pedido entregue e Pago''FormaPagamento.descricao'), 'class' => 'form-control', 'placeholder' => 'Status do Pagamento'));?>
            </div>
            <div class="form-group">
                <?php$suppliers echo= $this->Form>Compra->input>Supplier->find('obs''list', array('class' => 'form-control', 'placeholder''fields' => 'Observações..array('Supplier.'fantasia')));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->submit>set(__compact('Submit')'formaPagamentos', array('class' => 'btn btn-default''suppliers')); ?>
            </div>

        <?php echo $this->Form->end() ?>

    </div><!-- end col md 12 -->
</div><!-- end row -->}

Modal com Formulário na view index

ComprasController.phpformulario no modal

<div class="modal-body">
        <?php echo $this->Form->create('Compra', array('action' => 'add', 'role' => 'form')); ?>

            <div class="form-group">
                <?php echo $this->Form->input('valor', array('class' => 'form-control', 'placeholder' => 'Valor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data', array('class' => 'form-control', 'placeholder' => 'Data'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('entrega', array('class' => 'form-control', 'placeholder' => 'Entrega'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('forma_pagamento_id', array('class' => 'form-control', 'placeholder' => 'Forma de Pagamento', 'label' => 'Forma de Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data_pagamento', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Data Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('supplier_id', array('class' => 'form-control', 'placeholder' => 'Fornecedor', 'label' => 'Fornecedor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('status', array('options' => array(0 => '[Informe o Status]', 1 => 'Pedido Realizado', 2 => 'Pedido Entregue', 3 => 'Pedido entregue e Pago'), 'class' => 'form-control', 'placeholder' => 'Status do Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('obs', array('class' => 'form-control', 'placeholder' => 'Observações...'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->submit(__('Submit'), array('class' => 'btn btn-default')); ?>
            </div>

        <?php echo $this->Form->end() ?>
  </div>

index.ctp

<div class="row">

    <div class="col-md-3">
        <div class="actions">
            <div class="panel panel-default">
                <div class="panel-heading">Ações</div>
                    <div class="panel-body">
                        <ul class="nav nav-pills nav-stacked">
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Compra'), array('action' => 'add'), array('escape' => false)); ?></li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Formas Pagamentos'), array('controller' => 'forma_pagamentos', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Forma Pagamento'), array('controller' => 'forma_pagamentos', 'action' => 'add'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Fornecedores'), array('controller' => 'suppliers', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Novo Fornecedor'), array('controller' => 'suppliers', 'action' => 'add'), array('escape' => false)); ?> </li>
                        </ul>
                    </div><!-- end body -->
            </div><!-- end panel -->
        </div><!-- end actions -->

        <?php echo $this->element('side_totaliza_compras'); ?>
    </div><!-- end col md 3 -->

    <div class="col-md-9">
        <div class="table-responsive">
            <table cellpadding="0" cellspacing="0" class="table table-striped">
                <thead>
                    <tr>
                        <th><?php echo $this->Paginator->sort('supplier_fantasia', 'Fornecedor'); ?></th>
                        <th><?php echo $this->Paginator->sort('data', 'Pedido'); ?></th>
                        <th><?php echo $this->Paginator->sort('entrega', 'Entrega'); ?></th>
                        <th><?php echo $this->Paginator->sort('forma_pagamento_id', 'Tipo'); ?></th>
                        <th><?php echo $this->Paginator->sort('data_pagamento', 'Vencimento'); ?></th>
                        <th><?php echo $this->Paginator->sort('valor'); ?></th>
                        <th><?php echo $this->Paginator->sort('status'); ?></th>
                        <th class="actions"></th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($compras as $compra): ?>
                    <tr>
                        <td>
                            <?php echo $this->Html->link($compra['Supplier']['fantasia'], array('controller' => 'suppliers', 'action' => 'view', $compra['Supplier']['id'])); ?>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                
                                $dataAtual = date('d/m/Y');
                                $dataEntrega = $this->Locale->date($compra['Compra']['entrega']);
                                $diferencaEntrega = $this->Math->diferencaDeDatas($dataAtual, $dataEntrega, 'dias');

                                if ($dataAtual >= $dataEntrega) {
                                    $entregaIcon = 'glyphicon-home';
                                    $entregaColor = 'label label-primary';
                                } else {
                                    $entregaIcon = 'glyphicon-road';
                                    $entregaColor = 'label label-warning';
                                }
                            ?>
                            <!-- <span class="label <?php echo $entregaColor; ?>"><?php echo ( $entregaIcon == "glyphicon-home" ? '' : $diferencaEntrega ); ?> <span class="glyphicon <?php echo $entregaIcon; ?>"></span></span> -->
                            <?php echo h($this->Locale->date($compra['Compra']['entrega'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                $formaPagamento = $compra['FormaPagamento']['id'];

                                switch ($formaPagamento) {
                                    case 1:
                                        $formaPagamentoClass = 'label-danger';
                                        break;

                                    case 2:
                                        $formaPagamentoClass = 'label-info';
                                        break;
                                    
                                    default:
                                        $formaPagamentoClass = 'label-default';
                                        break;
                                }
                            ?>
                            <span class="label <?php echo $formaPagamentoClass; ?>">
                            <?php echo $compra['FormaPagamento']['descricao']; ?>
                            </span>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data_pagamento'])); ?>&nbsp;</td>
                        <td><?php echo h($compra['Compra']['valor']); ?>&nbsp;</td>
                        <td>
                            <?php
                            $statusPedido = $compra['Compra']['status'];
                            switch ($statusPedido) {
                                case 1:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-warning';
                                    $statusPedidoTitle = 'Pedido Realizado.';
                                    break;

                                case 2:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-primary';
                                    $statusPedidoTitle = 'Pedido Entregue.';
                                    break;

                                case 3:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-success';
                                    $statusPedidoTitle = 'Pedido Entregue e Pago.';
                                    break;
                                
                                default:
                                    $statusPedidoIcon = 'glyphicon-asterisk';
                                    $statusPedidoLabel = 'label-default';
                                    $statusPedidoTitle = 'Status não Informado.';
                                    break;
                            }
                            ?>
                            <span title="<?php echo $statusPedidoTitle; ?>" class="label <?php echo $statusPedidoLabel; ?>"><span class="glyphicon <?php echo $statusPedidoIcon; ?>"></span></span>
                            <?php //echo h($compra['Compra']['status']); ?>&nbsp;</td>
                        <td class="actions">
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-search"></span>', array('action' => 'view', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-edit"></span>', array('action' => 'edit', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Form->postLink('<span class="glyphicon glyphicon-remove"></span>', array('action' => 'delete', $compra['Compra']['id']), array('escape' => false), __('Are you sure you want to delete # %s?', $compra['Compra']['id'])); ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <p>
            <small><?php echo $this->Paginator->counter(array('format' => __('Página {:page} de {:pages}, mostrando {:current} registros de um total de {:count}, começando no registro {:start}, terminando em {:end}')));?></small>
        </p>

        <?php
        $params = $this->Paginator->params();
        if ($params['pageCount'] > 1) {
        ?>
        <ul class="pagination pagination-sm">
            <?php
                echo $this->Paginator->prev('&larr; Anterior', array('class' => 'prev','tag' => 'li','escape' => false), '<a onclick="return false;">&larr; Anterior</a>', array('class' => 'prev disabled','tag' => 'li','escape' => false));
                echo $this->Paginator->numbers(array('separator' => '','tag' => 'li','currentClass' => 'active','currentTag' => 'a'));
                echo $this->Paginator->next('Próxima &rarr;', array('class' => 'Próxima','tag' => 'li','escape' => false), '<a onclick="return false;">Next &rarr;</a>', array('class' => 'next disabled','tag' => 'li','escape' => false));
            ?>
        </ul>
        <?php } ?>

    </div> <!-- end col md 9 -->
</div><!-- end row -->

ADD.CTP

<div class="compras form">
    <div class="col-md-9">
        <?php echo $this->Form->create('Compra', array('role' => 'form')); ?>

            <div class="form-group">
                <?php echo $this->Form->input('valor', array('class' => 'form-control', 'placeholder' => 'Valor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data', array('class' => 'form-control', 'placeholder' => 'Data'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('entrega', array('class' => 'form-control', 'placeholder' => 'Entrega'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('forma_pagamento_id', array('class' => 'form-control', 'placeholder' => 'Forma de Pagamento', 'label' => 'Forma de Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data_pagamento', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Data Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('supplier_id', array('class' => 'form-control', 'placeholder' => 'Fornecedor', 'label' => 'Fornecedor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('status', array('options' => array(0 => '[Informe o Status]', 1 => 'Pedido Realizado', 2 => 'Pedido Entregue', 3 => 'Pedido entregue e Pago'), 'class' => 'form-control', 'placeholder' => 'Status do Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('obs', array('class' => 'form-control', 'placeholder' => 'Observações...'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->submit(__('Submit'), array('class' => 'btn btn-default')); ?>
            </div>

        <?php echo $this->Form->end() ?>

    </div><!-- end col md 12 -->
</div><!-- end row -->

Modal com Formulário na view index

ComprasController.php

ADD

public function add() {
    if ($this->request->is('post')) {
        $this->Compra->create();
        if ($this->Compra->save($this->request->data)) {
            $this->Session->setFlash(__('The compra has been saved.'), 'default', array('class' => 'alert alert-success'));
            return $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The compra could not be saved. Please, try again.'), 'default', array('class' => 'alert alert-danger'));
        }
    }
    $formaPagamentos = $this->Compra->FormaPagamento->find('list', array('fields' => array('FormaPagamento.descricao')));
    $suppliers = $this->Compra->Supplier->find('list', array('fields' => array('Supplier.fantasia')));
    $this->set(compact('formaPagamentos', 'suppliers'));
}

Index

public function index() {
    $this->Compra->recursive = 0;
    $this->Paginator->settings = array('limit' => 20, 'order' => array('Compra.data' => 'DESC'));
    
    if ($this->request->is('requested')) {
        return $this->paginate();
    } else {
        $this->set('compras', $this->Paginator->paginate());
    }

    $formaPagamentos = $this->Compra->FormaPagamento->find('list', array('fields' => array('FormaPagamento.descricao')));
    $suppliers = $this->Compra->Supplier->find('list', array('fields' => array('Supplier.fantasia')));
    $this->set(compact('formaPagamentos', 'suppliers'));
    
}

formulario no modal

<div class="modal-body">
        <?php echo $this->Form->create('Compra', array('action' => 'add', 'role' => 'form')); ?>

            <div class="form-group">
                <?php echo $this->Form->input('valor', array('class' => 'form-control', 'placeholder' => 'Valor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data', array('class' => 'form-control', 'placeholder' => 'Data'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('entrega', array('class' => 'form-control', 'placeholder' => 'Entrega'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('forma_pagamento_id', array('class' => 'form-control', 'placeholder' => 'Forma de Pagamento', 'label' => 'Forma de Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data_pagamento', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Data Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('supplier_id', array('class' => 'form-control', 'placeholder' => 'Fornecedor', 'label' => 'Fornecedor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('status', array('options' => array(0 => '[Informe o Status]', 1 => 'Pedido Realizado', 2 => 'Pedido Entregue', 3 => 'Pedido entregue e Pago'), 'class' => 'form-control', 'placeholder' => 'Status do Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('obs', array('class' => 'form-control', 'placeholder' => 'Observações...'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->submit(__('Submit'), array('class' => 'btn btn-default')); ?>
            </div>

        <?php echo $this->Form->end() ?>
  </div>
adicionou 9124 caracteres ao conteúdo
Fonte Link
Luciano Braga
  • 192
  • 1
  • 3
  • 14

index.ctp

<div class="row">

    <div class="col-md-3">
        <div class="actions">
            <div class="panel panel-default">
                <div class="panel-heading">Ações</div>
                    <div class="panel-body">
                        <ul class="nav nav-pills nav-stacked">
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Compra'), array('action' => 'add'), array('escape' => false)); ?></li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Formas Pagamentos'), array('controller' => 'forma_pagamentos', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Forma Pagamento'), array('controller' => 'forma_pagamentos', 'action' => 'add'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Fornecedores'), array('controller' => 'suppliers', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Novo Fornecedor'), array('controller' => 'suppliers', 'action' => 'add'), array('escape' => false)); ?> </li>
                        </ul>
                    </div><!-- end body -->
            </div><!-- end panel -->
        </div><!-- end actions -->

        <?php echo $this->element('side_totaliza_compras'); ?>
    </div><!-- end col md 3 -->

    <div class="col-md-9">
        <div class="table-responsive">
            <table cellpadding="0" cellspacing="0" class="table table-striped">
                <thead>
                    <tr>
                        <th><?php echo $this->Paginator->sort('supplier_fantasia', 'Fornecedor'); ?></th>
                        <th><?php echo $this->Paginator->sort('data', 'Pedido'); ?></th>
                        <th><?php echo $this->Paginator->sort('entrega', 'Entrega'); ?></th>
                        <th><?php echo $this->Paginator->sort('forma_pagamento_id', 'Tipo'); ?></th>
                        <th><?php echo $this->Paginator->sort('data_pagamento', 'Vencimento'); ?></th>
                        <th><?php echo $this->Paginator->sort('valor'); ?></th>
                        <th><?php echo $this->Paginator->sort('status'); ?></th>
                        <th class="actions"></th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($compras as $compra): ?>
                    <tr>
                        <td>
                            <?php echo $this->Html->link($compra['Supplier']['fantasia'], array('controller' => 'suppliers', 'action' => 'view', $compra['Supplier']['id'])); ?>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                
                                $dataAtual = date('d/m/Y');
                                $dataEntrega = $this->Locale->date($compra['Compra']['entrega']);
                                $diferencaEntrega = $this->Math->diferencaDeDatas($dataAtual, $dataEntrega, 'dias');

                                if ($dataAtual >= $dataEntrega) {
                                    $entregaIcon = 'glyphicon-home';
                                    $entregaColor = 'label label-primary';
                                } else {
                                    $entregaIcon = 'glyphicon-road';
                                    $entregaColor = 'label label-warning';
                                }
                            ?>
                            <!-- <span class="label <?php echo $entregaColor; ?>"><?php echo ( $entregaIcon == "glyphicon-home" ? '' : $diferencaEntrega ); ?> <span class="glyphicon <?php echo $entregaIcon; ?>"></span></span> -->
                            <?php echo h($this->Locale->date($compra['Compra']['entrega'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                $formaPagamento = $compra['FormaPagamento']['id'];

                                switch ($formaPagamento) {
                                    case 1:
                                        $formaPagamentoClass = 'label-danger';
                                        break;

                                    case 2:
                                        $formaPagamentoClass = 'label-info';
                                        break;
                                    
                                    default:
                                        $formaPagamentoClass = 'label-default';
                                        break;
                                }
                            ?>
                            <span class="label <?php echo $formaPagamentoClass; ?>">
                            <?php echo $compra['FormaPagamento']['descricao']; ?>
                            </span>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data_pagamento'])); ?>&nbsp;</td>
                        <td><?php echo h($compra['Compra']['valor']); ?>&nbsp;</td>
                        <td>
                            <?php
                            $statusPedido = $compra['Compra']['status'];
                            switch ($statusPedido) {
                                case 1:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-warning';
                                    $statusPedidoTitle = 'Pedido Realizado.';
                                    break;

                                case 2:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-primary';
                                    $statusPedidoTitle = 'Pedido Entregue.';
                                    break;

                                case 3:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-success';
                                    $statusPedidoTitle = 'Pedido Entregue e Pago.';
                                    break;
                                
                                default:
                                    $statusPedidoIcon = 'glyphicon-asterisk';
                                    $statusPedidoLabel = 'label-default';
                                    $statusPedidoTitle = 'Status não Informado.';
                                    break;
                            }
                            ?>
                            <span title="<?php echo $statusPedidoTitle; ?>" class="label <?php echo $statusPedidoLabel; ?>"><span class="glyphicon <?php echo $statusPedidoIcon; ?>"></span></span>
                            <?php //echo h($compra['Compra']['status']); ?>&nbsp;</td>
                        <td class="actions">
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-search"></span>', array('action' => 'view', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-edit"></span>', array('action' => 'edit', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Form->postLink('<span class="glyphicon glyphicon-remove"></span>', array('action' => 'delete', $compra['Compra']['id']), array('escape' => false), __('Are you sure you want to delete # %s?', $compra['Compra']['id'])); ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <p>
            <small><?php echo $this->Paginator->counter(array('format' => __('Página {:page} de {:pages}, mostrando {:current} registros de um total de {:count}, começando no registro {:start}, terminando em {:end}')));?></small>
        </p>

        <?php
        $params = $this->Paginator->params();
        if ($params['pageCount'] > 1) {
        ?>
        <ul class="pagination pagination-sm">
            <?php
                echo $this->Paginator->prev('&larr; Anterior', array('class' => 'prev','tag' => 'li','escape' => false), '<a onclick="return false;">&larr; Anterior</a>', array('class' => 'prev disabled','tag' => 'li','escape' => false));
                echo $this->Paginator->numbers(array('separator' => '','tag' => 'li','currentClass' => 'active','currentTag' => 'a'));
                echo $this->Paginator->next('Próxima &rarr;', array('class' => 'Próxima','tag' => 'li','escape' => false), '<a onclick="return false;">Next &rarr;</a>', array('class' => 'next disabled','tag' => 'li','escape' => false));
            ?>
        </ul>
        <?php } ?>

    </div> <!-- end col md 9 -->
</div><!-- end row -->

ADD.CTP

<div class="compras form">
    <div class="col-md-9">
        <?php echo $this->Form->create('Compra', array('role' => 'form')); ?>

            <div class="form-group">
                <?php echo $this->Form->input('valor', array('class' => 'form-control', 'placeholder' => 'Valor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data', array('class' => 'form-control', 'placeholder' => 'Data'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('entrega', array('class' => 'form-control', 'placeholder' => 'Entrega'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('forma_pagamento_id', array('class' => 'form-control', 'placeholder' => 'Forma de Pagamento', 'label' => 'Forma de Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data_pagamento', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Data Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('supplier_id', array('class' => 'form-control', 'placeholder' => 'Fornecedor', 'label' => 'Fornecedor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('status', array('options' => array(0 => '[Informe o Status]', 1 => 'Pedido Realizado', 2 => 'Pedido Entregue', 3 => 'Pedido entregue e Pago'), 'class' => 'form-control', 'placeholder' => 'Status do Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('obs', array('class' => 'form-control', 'placeholder' => 'Observações...'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->submit(__('Submit'), array('class' => 'btn btn-default')); ?>
            </div>

        <?php echo $this->Form->end() ?>

    </div><!-- end col md 12 -->
</div><!-- end row -->

Modal com Formulário na view index

ComprasController.php

index.ctp

<div class="row">

    <div class="col-md-3">
        <div class="actions">
            <div class="panel panel-default">
                <div class="panel-heading">Ações</div>
                    <div class="panel-body">
                        <ul class="nav nav-pills nav-stacked">
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Compra'), array('action' => 'add'), array('escape' => false)); ?></li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Formas Pagamentos'), array('controller' => 'forma_pagamentos', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Nova Forma Pagamento'), array('controller' => 'forma_pagamentos', 'action' => 'add'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-list"></span>&nbsp;&nbsp;Fornecedores'), array('controller' => 'suppliers', 'action' => 'index'), array('escape' => false)); ?> </li>
                            <li><?php echo $this->Html->link(__('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Novo Fornecedor'), array('controller' => 'suppliers', 'action' => 'add'), array('escape' => false)); ?> </li>
                        </ul>
                    </div><!-- end body -->
            </div><!-- end panel -->
        </div><!-- end actions -->

        <?php echo $this->element('side_totaliza_compras'); ?>
    </div><!-- end col md 3 -->

    <div class="col-md-9">
        <div class="table-responsive">
            <table cellpadding="0" cellspacing="0" class="table table-striped">
                <thead>
                    <tr>
                        <th><?php echo $this->Paginator->sort('supplier_fantasia', 'Fornecedor'); ?></th>
                        <th><?php echo $this->Paginator->sort('data', 'Pedido'); ?></th>
                        <th><?php echo $this->Paginator->sort('entrega', 'Entrega'); ?></th>
                        <th><?php echo $this->Paginator->sort('forma_pagamento_id', 'Tipo'); ?></th>
                        <th><?php echo $this->Paginator->sort('data_pagamento', 'Vencimento'); ?></th>
                        <th><?php echo $this->Paginator->sort('valor'); ?></th>
                        <th><?php echo $this->Paginator->sort('status'); ?></th>
                        <th class="actions"></th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($compras as $compra): ?>
                    <tr>
                        <td>
                            <?php echo $this->Html->link($compra['Supplier']['fantasia'], array('controller' => 'suppliers', 'action' => 'view', $compra['Supplier']['id'])); ?>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                
                                $dataAtual = date('d/m/Y');
                                $dataEntrega = $this->Locale->date($compra['Compra']['entrega']);
                                $diferencaEntrega = $this->Math->diferencaDeDatas($dataAtual, $dataEntrega, 'dias');

                                if ($dataAtual >= $dataEntrega) {
                                    $entregaIcon = 'glyphicon-home';
                                    $entregaColor = 'label label-primary';
                                } else {
                                    $entregaIcon = 'glyphicon-road';
                                    $entregaColor = 'label label-warning';
                                }
                            ?>
                            <!-- <span class="label <?php echo $entregaColor; ?>"><?php echo ( $entregaIcon == "glyphicon-home" ? '' : $diferencaEntrega ); ?> <span class="glyphicon <?php echo $entregaIcon; ?>"></span></span> -->
                            <?php echo h($this->Locale->date($compra['Compra']['entrega'])); ?>&nbsp;</td>
                        <td>
                            <?php
                                $formaPagamento = $compra['FormaPagamento']['id'];

                                switch ($formaPagamento) {
                                    case 1:
                                        $formaPagamentoClass = 'label-danger';
                                        break;

                                    case 2:
                                        $formaPagamentoClass = 'label-info';
                                        break;
                                    
                                    default:
                                        $formaPagamentoClass = 'label-default';
                                        break;
                                }
                            ?>
                            <span class="label <?php echo $formaPagamentoClass; ?>">
                            <?php echo $compra['FormaPagamento']['descricao']; ?>
                            </span>
                        </td>
                        <td><?php echo h($this->Locale->date($compra['Compra']['data_pagamento'])); ?>&nbsp;</td>
                        <td><?php echo h($compra['Compra']['valor']); ?>&nbsp;</td>
                        <td>
                            <?php
                            $statusPedido = $compra['Compra']['status'];
                            switch ($statusPedido) {
                                case 1:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-warning';
                                    $statusPedidoTitle = 'Pedido Realizado.';
                                    break;

                                case 2:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-primary';
                                    $statusPedidoTitle = 'Pedido Entregue.';
                                    break;

                                case 3:
                                    $statusPedidoIcon = 'glyphicon-ok';
                                    $statusPedidoLabel = 'label-success';
                                    $statusPedidoTitle = 'Pedido Entregue e Pago.';
                                    break;
                                
                                default:
                                    $statusPedidoIcon = 'glyphicon-asterisk';
                                    $statusPedidoLabel = 'label-default';
                                    $statusPedidoTitle = 'Status não Informado.';
                                    break;
                            }
                            ?>
                            <span title="<?php echo $statusPedidoTitle; ?>" class="label <?php echo $statusPedidoLabel; ?>"><span class="glyphicon <?php echo $statusPedidoIcon; ?>"></span></span>
                            <?php //echo h($compra['Compra']['status']); ?>&nbsp;</td>
                        <td class="actions">
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-search"></span>', array('action' => 'view', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Html->link('<span class="glyphicon glyphicon-edit"></span>', array('action' => 'edit', $compra['Compra']['id']), array('escape' => false)); ?>
                            <?php echo $this->Form->postLink('<span class="glyphicon glyphicon-remove"></span>', array('action' => 'delete', $compra['Compra']['id']), array('escape' => false), __('Are you sure you want to delete # %s?', $compra['Compra']['id'])); ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <p>
            <small><?php echo $this->Paginator->counter(array('format' => __('Página {:page} de {:pages}, mostrando {:current} registros de um total de {:count}, começando no registro {:start}, terminando em {:end}')));?></small>
        </p>

        <?php
        $params = $this->Paginator->params();
        if ($params['pageCount'] > 1) {
        ?>
        <ul class="pagination pagination-sm">
            <?php
                echo $this->Paginator->prev('&larr; Anterior', array('class' => 'prev','tag' => 'li','escape' => false), '<a onclick="return false;">&larr; Anterior</a>', array('class' => 'prev disabled','tag' => 'li','escape' => false));
                echo $this->Paginator->numbers(array('separator' => '','tag' => 'li','currentClass' => 'active','currentTag' => 'a'));
                echo $this->Paginator->next('Próxima &rarr;', array('class' => 'Próxima','tag' => 'li','escape' => false), '<a onclick="return false;">Next &rarr;</a>', array('class' => 'next disabled','tag' => 'li','escape' => false));
            ?>
        </ul>
        <?php } ?>

    </div> <!-- end col md 9 -->
</div><!-- end row -->

ADD.CTP

<div class="compras form">
    <div class="col-md-9">
        <?php echo $this->Form->create('Compra', array('role' => 'form')); ?>

            <div class="form-group">
                <?php echo $this->Form->input('valor', array('class' => 'form-control', 'placeholder' => 'Valor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data', array('class' => 'form-control', 'placeholder' => 'Data'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('entrega', array('class' => 'form-control', 'placeholder' => 'Entrega'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('forma_pagamento_id', array('class' => 'form-control', 'placeholder' => 'Forma de Pagamento', 'label' => 'Forma de Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('data_pagamento', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Data Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('supplier_id', array('class' => 'form-control', 'placeholder' => 'Fornecedor', 'label' => 'Fornecedor'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('status', array('options' => array(0 => '[Informe o Status]', 1 => 'Pedido Realizado', 2 => 'Pedido Entregue', 3 => 'Pedido entregue e Pago'), 'class' => 'form-control', 'placeholder' => 'Status do Pagamento'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->input('obs', array('class' => 'form-control', 'placeholder' => 'Observações...'));?>
            </div>
            <div class="form-group">
                <?php echo $this->Form->submit(__('Submit'), array('class' => 'btn btn-default')); ?>
            </div>

        <?php echo $this->Form->end() ?>

    </div><!-- end col md 12 -->
</div><!-- end row -->

Modal com Formulário na view index

ComprasController.php

removeu 73 caracteres do conteúdo; tags editadas
Fonte Link
rray
  • 67,7mil
  • 21
  • 116
  • 285
Carregando
tags editadas; título editado
Link
Luciano Braga
  • 192
  • 1
  • 3
  • 14
Carregando
Fonte Link
Luciano Braga
  • 192
  • 1
  • 3
  • 14
Carregando