/** * Initialize the products form */ public function initialize($model = null, $options = array()) { $nome = new Text("nome"); $nome->setLabel("Nome"); $nome->setFilters(array('striptags', 'string')); $nome->setAttribute('class', 'form-control'); $this->add($nome); if (is_null($model)) { $categoria = new Select("parent", Categorias::returnArrayForSelect(), array('using' => array('_id', 'nome'), 'useEmpty' => true, 'emptyText' => 'Nenhuma', 'emptyValue' => '')); $categoria->setLabel("Selecione a categoria pai*"); $categoria->setAttribute('class', 'form-control'); $this->add($categoria); } }
/** * Initialize the products form */ public function initialize($model = null, $options = array()) { $eo = $this->getDI()->getShared('ecommerce_options'); $utilitarios = $this->getDI()->getShared('Utilitarios'); $nome = new Text("nome"); $nome->setAttribute('class', 'form-control'); $this->add($nome); $valor_minimo = new Text('valor_minimo'); $valor_minimo->setLabel('Valor mínimo do pedido'); $valor_minimo->setAttribute('class', 'form-control money'); $this->add($valor_minimo); $ativo = new Select("ativo", array('1' => 'Sim', '2' => 'Não')); $ativo->setAttribute('class', 'form-control'); $this->add($ativo); $opcao = new Select("tipo", array('1' => 'Região', '2' => 'Cidade', '3' => 'Produtos'), array('useEmpty' => true, 'emptyText' => 'Selecione')); $opcao->setAttribute('class', 'form-control tipo-frete'); $opcao->setLabel('Tipo'); $this->add($opcao); $opcao = new Text('cep_inicial'); $opcao->setAttribute('class', 'form-control cep-faixa'); $opcao->setLabel('CEP Inicial'); $this->add($opcao); $opcao = new Text('cep_final'); $opcao->setAttribute('class', 'form-control cep-faixa'); $opcao->setLabel('CEP Final'); $this->add($opcao); $opcao = new Text('produtos'); $opcao->setLabel('Produtos'); $opcao->setAttribute('class', 'form-control frete-produtos'); $opcao->setAttribute('id', 'produtos_relacionados'); $opcao->setAttribute('data-url', $eo->url_base . 'admin/produtos/search'); $arr = array(); if (!is_null($model) && $model->tipo == 3) { $produtos = unserialize($model->produtos); foreach ($produtos as $key => $value) { $produto = $utilitarios->getProduto($value); $arr[$key]['id'] = (string) $produto->_id; $arr[$key]['name'] = $produto->nome; } } $opcao->setAttribute('data-pre', json_encode($arr)); $this->add($opcao); }
/** * Initialize the products form */ public function initialize($model = null, $options = array()) { $ativo = new Select("ativo", array('1' => 'Sim', '0' => 'Não')); $ativo->setAttribute('class', 'form-control'); $this->add($ativo); $nome = new Text("nome"); $nome->setAttribute('class', 'form-control'); $this->add($nome); $codigo = new Text("codigo"); $codigo->setLabel("código"); $codigo->setAttribute('class', 'form-control'); $codigo->setAttribute('readonly', 'true'); if (is_null($model)) { $str = $this->getCodigo(); if (Cupons::count(array('codigo = "' . $str . '"')) == 0) { $codigo->setAttribute('value', $str); } else { $str = $this->getCodigo(); $codigo->setAttribute('value', $str); } } $this->add($codigo); $quantidade = new Numeric("quantidade"); $quantidade->setLabel("quantidade de cupons"); $quantidade->setAttribute('class', 'form-control'); $this->add($quantidade); $quantidade_uso = new Numeric("quantidade_uso"); $quantidade_uso->setLabel("quantas utilização por usuário?"); $quantidade_uso->setAttribute('class', 'form-control'); $this->add($quantidade_uso); $valor = new Text("valor"); $valor->setAttribute('class', 'form-control money'); $this->add($valor); $valor_minimo = new Text("valor_minimo"); $valor_minimo->setLabel('VALOR MíNIMO'); $valor_minimo->setAttribute('class', 'form-control money'); $this->add($valor_minimo); $data_expiracao = new Date("data_expiracao"); $data_expiracao->setLabel('DATA EXPIRAÇÃO'); $data_expiracao->setAttribute('class', 'form-control money'); $this->add($data_expiracao); }
public static function generate($opcoes = array()) { $form = new Form(); //Numero do cartão foreach (self::rules() as $key => $value) { if ($value['type'] == 'text') { $chave = new Text("pagamento[{$key}]"); } else { if ($value['type'] == 'hidden') { $chave = new Hidden("pagamento[{$key}]"); } else { $chave = new Select("pagamento[{$key}]", array('emptyText' => 'Parcelas', 'emptyValue' => '')); } } foreach ($value['attributos'] as $k => $v) { $chave->setAttribute($k, $v); } $form->add($chave); } return $form; }
/** * Initialize the products form */ public function initialize($model = null, $options = array()) { $op = unserialize($model->opcoes); foreach ($op as $key => $value) { $item = new Text('opcoes[' . $key . ']'); $item->setLabel($key); $item->setAttribute('class', 'form-control'); $item->setAttribute('value', $value); $this->add($item); } $ativo = new Select("ativo", array('1' => 'Sim', '0' => 'Não')); $ativo->setAttribute('class', 'form-control'); $this->add($ativo); $valor_minimo = new Text("valor_minimo"); $valor_minimo->setLabel('valor mínimo'); $valor_minimo->setAttribute('class', 'form-control money'); $this->add($valor_minimo); if ($model->id != 3) { $maximo_parcela = new Numeric("maximo_parcela"); $maximo_parcela->setAttribute('class', 'form-control'); $maximo_parcela->setLabel('Maximo de parcelas'); $this->add($maximo_parcela); $valor_minimo_parcela = new Text("valor_minimo_parcela"); $valor_minimo_parcela->setLabel('Valor mínimo parcela'); $valor_minimo_parcela->setAttribute('class', 'form-control money'); $this->add($valor_minimo_parcela); $parcela_sem_juros = new Numeric("parcela_sem_juros"); $parcela_sem_juros->setLabel('parcelas sem juros'); $parcela_sem_juros->setAttribute('class', 'form-control'); $this->add($parcela_sem_juros); $juros_parcela = new Text("juros_parcela"); $juros_parcela->setLabel("juros parcela (% a.m)"); $juros_parcela->setAttribute('class', 'form-control'); $this->add($juros_parcela); } }
private static function setForm() { $form = new Form(); //Numero do cartão foreach (self::rules() as $key => $value) { if ($value['type'] == 'text') { $chave = new Text("pagamento[{$key}]"); } else { if ($value['type'] == 'hidden') { $chave = new Hidden("pagamento[{$key}]"); } else { $arr = array(); if ($key == 'mes') { $arr[''] = 'Mês de vencimento'; for ($i = 1; $i <= 12; $i++) { $arr[$i] = $i; } } else { if ($key == 'ano') { $arr[''] = 'Ano de vencimento'; for ($i = date('Y'); $i <= date('Y', strtotime('+ 20 years')); $i++) { $arr[$i] = $i; } } else { $arr[''] = 'Numero de parcelas'; } } $chave = new Select("pagamento[{$key}]", $arr); } } foreach ($value['attributos'] as $k => $v) { $chave->setAttribute($k, $v); } $form->add($chave); } $html = ''; foreach ($form as $key => $value) { $html .= "<div class='form-group'>" . $value . "</div>"; } return $html; }
/** * Initialize the products form */ public function initialize($entity = null, $options = array()) { $nome = new Text("nome"); $nome->setLabel("Nome"); $nome->setAttribute('class', 'form-control'); $this->add($nome); $categoria = new Select("categoria", Categorias::returnArrayForSelect(), array('using' => array('_id', 'nome'))); $categoria->setLabel("Categoria"); $categoria->setAttribute('class', 'form-control'); $this->add($categoria); #Opçõs setadas dinamicamente $detalhes = unserialize($this->ecommerce_options->produto_options); if (!empty($detalhes)) { foreach ($detalhes as $key => $value) { if ($value['referencia'] != '') { $chave = $key; $chave = new Select("{$value['label']}", $value['referencia']::find(array('order' => 'nome ASC')), array('using' => array('nome', 'nome'), 'useEmpty' => true, 'emptyText' => 'Nenhum ...', 'emptyValue' => null)); $chave->setLabel($value['label']); $chave->setAttribute('class', 'form-control ' . $value['label']); if (isset($obj) && !is_null($obj)) { $chave->setDefault($obj->{$value}['label']); } $this->add($chave); } } } #Caso detalhes do produto esteja habilitado if ($this->ecommerce_options->produto_detalhes == '0') { $valor = new Text("valor"); $valor->setAttribute('class', 'form-control money'); $this->add($valor); $desconto = new Text("desconto"); $desconto->setAttribute('class', 'form-control money'); $this->add($desconto); $estoque = new Numeric("estoque"); $estoque->setAttribute('class', 'form-control'); $estoque->setAttribute('rows', '5'); $this->add($estoque); } $descricao = new TextArea("resumo"); $descricao->setLabel("Descrição Resumida"); $descricao->setAttribute('class', 'form-control'); $descricao->setAttribute('rows', '5'); $this->add($descricao); $descricao = new TextArea("descricao"); $descricao->setLabel("Descrição Completa"); $descricao->setAttribute('class', 'form-control summernote'); $descricao->setAttribute('rows', '10'); $this->add($descricao); $destaque = new Select('destaque', array(0 => 'Não', 1 => 'Sim')); $destaque->setLabel('Destaque'); $destaque->setAttribute('class', 'form-control'); $this->add($destaque); $ativo = new Select('ativo', array(0 => 'Não', 1 => 'Sim')); $ativo->setLabel('Ativo'); $ativo->setAttribute('class', 'form-control'); $this->add($ativo); if ($this->ecommerce_options->produto_cubagem_detalhe == '0') { #Input Estoque $peso = new Numeric("peso"); $peso->setLabel("peso"); $peso->setAttribute('class', 'form-control'); $this->add($peso); #Input Estoque $altura = new Numeric("altura"); $altura->setLabel("altura"); $altura->setAttribute('class', 'form-control'); $this->add($altura); #Input Estoque $largura = new Numeric("largura"); $largura->setLabel("largura"); $largura->setAttribute('class', 'form-control'); $this->add($largura); #Input Estoque $comprimento = new Numeric("comprimento"); $comprimento->setLabel("comprimento"); $comprimento->setAttribute('class', 'form-control'); $this->add($comprimento); } $meta_title = new Text("meta_title"); $meta_title->setLabel("Meta Title"); $meta_title->setAttribute('class', 'form-control'); $this->add($meta_title); $meta_description = new TextArea("meta_description"); $meta_description->setLabel("Meta Description"); $meta_description->setAttribute('class', 'form-control'); $meta_description->setAttribute('rows', '5'); $this->add($meta_description); $meta_keywords = new TextArea("meta_keywords"); $meta_keywords->setLabel("Meta Keywords"); $meta_keywords->setAttribute('class', 'form-control'); $meta_keywords->setAttribute('rows', '5'); $this->add($meta_keywords); }
public function initialize($obj = null, $options = array()) { $detalhes = unserialize($this->ecommerce_options->produto_detalhe_options); foreach ($detalhes as $key => $value) { $chave = $key; $chave = new Select("detalhes[{$value['label']}][]", $value['referencia']::find(array('order' => 'nome ASC')), array('using' => array('nome', 'nome'))); $chave->setLabel($value['label']); $chave->setAttribute('class', 'form-control ' . $value['label']); if (!is_null($obj)) { $chave->setDefault($obj->{$value}['label']); } $this->add($chave); } #Input Valor $valor = new Text("detalhes[valor][]"); $valor->setLabel("valor"); $valor->setAttribute('class', 'form-control money'); if (!is_null($obj)) { $valor->setDefault($obj->valor); } $this->add($valor); #Input desconto $desconto = new Text("detalhes[desconto][]"); $desconto->setLabel("desconto"); $desconto->setAttribute('class', 'form-control money'); if (!is_null($obj)) { $desconto->setDefault($obj->desconto); } $this->add($desconto); #Input Estoque $estoque = new Numeric("detalhes[estoque][]"); $estoque->setLabel("estoque"); $estoque->setAttribute('class', 'form-control'); $this->add($estoque); if (!is_null($obj)) { $estoque->setDefault($obj->estoque); } if ($this->ecommerce_options->produto_cubagem_detalhe == '1') { $peso = new Numeric("detalhes[peso][]"); $peso->setLabel("peso"); $peso->setAttribute('class', 'form-control'); if (!is_null($obj)) { $peso->setDefault($obj->peso); } $this->add($peso); $altura = new Numeric("detalhes[altura][]"); $altura->setLabel("altura"); $altura->setAttribute('class', 'form-control'); $this->add($altura); if (!is_null($obj)) { $altura->setDefault($obj->altura); } $largura = new Numeric("detalhes[largura][]"); $largura->setLabel("largura"); $largura->setAttribute('class', 'form-control'); $this->add($largura); if (!is_null($obj)) { $largura->setDefault($obj->largura); } $comprimento = new Numeric("detalhes[comprimento][]"); $comprimento->setLabel("comprimento"); $comprimento->setAttribute('class', 'form-control'); $this->add($comprimento); if (!is_null($obj)) { $comprimento->setDefault($obj->comprimento); } } if (!is_null($obj)) { $detalhe_id = new hidden("detalhes[detalhe_id][]"); $detalhe_id->setAttribute('class', 'form-control detalhe_id dynamicId'); $detalhe_id->setDefault($obj->detalhe_id); $this->add($detalhe_id); } }