Example #1
0
 public function editar($id)
 {
     $data = array();
     $data['ACAO'] = 'Edição';
     $data['des_tipoatributo'] = 'disabled="disabled"';
     $data['readonly'] = 'readonly';
     $res = $this->ProdutoM->get(array("codproduto" => $id), TRUE);
     if ($res) {
         foreach ($res as $chave => $valor) {
             $data[$chave] = $valor;
         }
     } else {
         show_error('Não foram encontrados dados.', 500, 'Ops, erro encontrado.');
     }
     if (empty($res->codtipoatributo)) {
         $sku = $this->SkuM->getPorProdutoSimples($id);
         $data["quantidade"] = $sku->quantidade;
     }
     $data['valorproduto'] = modificaNumericValor($res->valorproduto);
     $data['valorpromocional'] = modificaNumericValor($res->valorpromocional);
     $data['peso'] = modificaNumericPeso($res->peso);
     $data['altura'] = modificaNumericPeso($res->altura);
     $data['largura'] = modificaNumericPeso($res->largura);
     $data['comprimento'] = modificaNumericPeso($res->comprimento);
     setURL($data, 'produto');
     $tipo = $this->TipoAtributoM->get(array(), FALSE, 0, FALSE);
     foreach ($tipo as $t) {
         $data['BLC_TIPOATRIBUTOS'][] = array("CODTIPOATRIBUTO" => $t->codtipoatributo, "NOME" => $t->nometipoatributo, "sel_codtipoatributo" => $t->codtipoatributo == $res->codtipoatributo ? 'selected="selected"' : null);
     }
     //ARMAZENA OS DEPARTAMENTOS VINCULADO
     $aDepartamentosVinculados = array();
     $depVinc = $this->ProdDepM->get(array("dp.codproduto" => $id));
     if ($depVinc) {
         foreach ($depVinc as $depv) {
             array_push($aDepartamentosVinculados, $depv->codprodutodepartamento);
         }
     }
     /**
      * BUSCA DEPARTAMENTOS PAI
      */
     $depPai = $this->DepartamentoM->get(array("d.coddepartamentopai IS NULL" => NULL), FALSE, 0, FALSE);
     if ($depPai) {
         foreach ($depPai as $dp) {
             //DEFINE OS ELEMENTOS DO FILHO - INÍCIO
             $aFilhos = array();
             $deFilhos = $this->DepartamentoM->get(array("d.coddepartamentopai" => $dp->codepartamento), FALSE, 0, FALSE);
             if ($deFilhos) {
                 foreach ($deFilhos as $df) {
                     $aFilhos[] = array("CODDEPARTAMENTOFILHO" => $df->codepartamento, "NOMEDEPARTAMENTOFILHO" => $df->nomedepartamento, "CODDEPARTAMENTOPAI" => $df->coddepartamentopai, "chk_departamentofilho" => in_array($df->codepartamento, $aDepartamentosVinculados) ? 'checked="checked"' : null);
                 }
             }
             //DEFINE OS ELEMENTOS DO FILHO - FIM
             //DEFINE OS ELEMENTOS DO PAI
             $data['BLC_DEPARTAMENTOPAI'][] = array("CODDEPARTAMENTO" => $dp->codepartamento, "NOMEDEPARTAMENTO" => $dp->nomedepartamento, "BLC_DEPARTAMENTOFILHO" => $aFilhos, "chk_departamentopai" => in_array($dp->codepartamento, $aDepartamentosVinculados) ? 'checked="checked"' : null);
         }
     }
     $this->parser->parse('painel/produto_form', $data);
 }
 public function editar($id)
 {
     $data = array();
     $data['ACAO'] = 'Edição';
     $res = $this->FaixaCepFreteGratisM->get(array("codfaixacepfretegratis" => $id), TRUE);
     if ($res) {
         foreach ($res as $chave => $valor) {
             $data[$chave] = $valor;
         }
         $data['chk_habilitafaixacepfretegratis'] = $res->habilitafaixacepfretegratis == 'S' ? 'checked="checked"' : null;
         $data['pesoinicialfaixacepfretegratis'] = modificaNumericPeso($res->pesoinicialfaixacepfretegratis);
         $data['pesofinalfaixacepfretegratis'] = modificaNumericPeso($res->pesofinalfaixacepfretegratis);
         $data['valorminimofaixacepfretegratis'] = modificaNumericValor($res->valorminimofaixacepfretegratis);
     } else {
         show_error('Não foram encontrados dados.', 500, 'Ops, erro encontrado.');
     }
     $this->setURL($data, $res->codformaentrega);
     $this->parser->parse('painel/faixacepfretegratis_form', $data);
 }
 public function editar($id)
 {
     $data = array();
     $data['ACAO'] = 'Edição';
     $res = $this->PrecoEntregaM->get(array("codfaixaprecoformaentrega" => $id), TRUE);
     if ($res) {
         foreach ($res as $chave => $valor) {
             $data[$chave] = $valor;
         }
         $data["cepinicialfaixaprecoformaentrega"] = str_pad($res->cepinicialfaixaprecoformaentrega, 8, "0", STR_PAD_LEFT);
         $data["cepfinalfaixaprecoformaentrega"] = str_pad($res->cepfinalfaixaprecoformaentrega, 8, "0", STR_PAD_LEFT);
         $data['pesoinicialfaixaprecoformaentrega'] = modificaNumericPeso($res->pesoinicialfaixaprecoformaentrega);
         $data['pesofinalfaixaprecoformaentrega'] = modificaNumericPeso($res->pesofinalfaixaprecoformaentrega);
         $data['valorfaixaprecoformaentrega'] = modificaNumericValor($res->valorfaixaprecoformaentrega);
     } else {
         show_error('Não foram encontrados dados.', 500, 'Ops, erro encontrado.');
     }
     $this->setURL($data, $res->codformaentrega);
     $this->parser->parse('painel/precoentrega_form', $data);
 }