public function atualizar($model, $caminho = false) { $nm = ''; $i = 0; $max = 2; $nothing_uploads = false; if (!is_dir($caminho . $model->itens_id)) { mkdir($caminho . $model->itens_id); } for ($i = 0; $i <= $max; $i++) { $img_add = new ItensMultimidia(); $pic = CUploadedFile::getInstancesByName('ItensMultimidia_' . $i); $pic = isset($pic[0]) ? $pic[0] : null; if (isset($pic)) { $nothing_uploads = true; $nm = md5(date("Ymd h:i:s")) . rand(5, 15) . "." . $model->extensionImg($pic->type); if ($pic->saveAs($caminho . $model->itens_id . DIRECTORY_SEPARATOR . $nm, true)) { $img_add = new ItensMultimidia(); $img_add->itens_multimidia_caminho = $nm; $img_add->itens_id = $model->itens_id; /* Checa a existência do id na tabela multimidia */ $iTM = isset($_POST[md5("alt_id_upload-" . $i)]) ? ItensMultimidia::model()->findByPk($_POST[md5("alt_id_upload-" . $i)]) : NULL; if (isset($iTM) && $iTM->count()) { $img_add = ItensMultimidia::model()->findByPk($_POST[md5("alt_id_upload-" . $i)]); $img_add->itens_multimidia_id = $iTM->itens_multimidia_id; $img_add->itens_multimidia_caminho = base64_decode($_POST["files_actual_" . $i]); $img_add->itens_id = $model->itens_id; } try { $img_add->save(); } catch (CDbException $e) { $transaction->rollback(); $model->addError(null, $e->getMessage()); } } } } if ($nothing_uploads == false) { /* Deleta ou atualiza a tabela multimidia */ for ($i = 0; $i <= $max; $i++) { try { $EXC = isset($_POST["itens_multimidia_excluir_" . $i]) ? ItensMultimidia::model()->deleteByPk(base64_decode($_POST["itens_multimidia_excluir_" . $i])) : ''; isset($_POST["itens_multimidia_excluir_" . $i]) && file_exists($caminho . $model->itens_id . DIRECTORY_SEPARATOR . base64_decode($_POST["files_actual_" . $i])) ? unlink($caminho . $model->itens_id . DIRECTORY_SEPARATOR . base64_decode($_POST["files_actual_" . $i])) : ''; } catch (CDbException $e) { //$transaction->rollback(); echo $e->getMessage(); } } } }
public function actionClear($id) { $this->layout = 'column2'; $model = Itens::model()->find(array('select' => '*', 'condition' => 'itens_id=:itens_id', 'params' => array(':itens_id' => $id))); try { $transaction = Yii::app()->db->beginTransaction(); if (count($model) > 0) { ItensMultimidia::model()->deleteAll(array('condition' => "itens_id = :itens_id", 'params' => array(':itens_id' => $id))); StatusNegocios::model()->deleteAll(array('condition' => "itens_id = :itens_id", 'params' => array(':itens_id' => $id))); // echo Itens::model()->deleteByPk($id); exit; if (Itens::model()->deleteByPk($id)) { $transaction->commit(); } Yii::app()->user->setState('frm_clear', true); $this->redirect(array('admin')); } } catch (CDbException $e) { $transaction->rollback(); //$model->addError(null, $e->getMessage()); } $this->render('index', array('model' => $model)); }
$dataArray = $model_pesq_list->getData(); $arr_data = array(); foreach ($dataArray as $key => $data) { $arr_data[$key]['itens_id'] = $data->itens_id; $arr_data[$key]['itens_atividade'] = $data->itens_atividade; $arr_data[$key]['itens_uf'] = $data->itens_uf; $arr_data[$key]['itens_cidade'] = $data->itens_cidade; $arr_data[$key]['itens_preco'] = $data->itens_preco[0]; $arr_data[$key]['itens_receita_anual'] = $data->itens_receita_anual[0]; $arr_data[$key]['itens_ebitda'] = $data->itens_ebitda[0]; $arr_data[$key]['itens_resultado_operacional'] = $data->itens_resultado_operacional[0]; } $thumb = ""; if (count($arr_data) > 0) { foreach ($arr_data as $key => $values) { $im = ItensMultimidia::infoItensMultimidia($arr_data[$key]['itens_id']); if (!empty($im->itens_multimidia_caminho)) { $thumb = Yii::app()->utils->incluiTracoImg($im->itens_multimidia_caminho); } ?> <div id="box_resultado"> <div id="box_icons"> <?php StatusNegocios::loadStatusNegocios2($arr_data[$key]['itens_id']); ?> </div> <div id="box_img"> <a href="<?php echo "http://" . $_SERVER["HTTP_HOST"] . Yii::app()->baseUrl . "/" . Yii::app()->controller->id . "/view/id/" . $arr_data[$key]['itens_id']; ?>
<?php $im = ItensMultimidia::infoItensMultimidia($model->itens_id); ?> <div class="main_content"> <h1 id="page_title">Negócios à venda <span class="arial_14_normal">O lugar para você comprar e vender negócio!</span> <span class="arial_14_bold" style="float:right;"><a href="<?php echo "http://" . $_SERVER["HTTP_HOST"] . Yii::app()->baseUrl . "/negociosavenda/"; ?> " class="arial_12_normal_2E598A_underline"><< voltar</a></span></h1> <div id="voltar" style="font-size: 14px;"> <?php if (Yii::app()->user->getState('usuario_nome_responsavel') == true) { ?> Seja bem vindo <b><?php echo Yii::app()->user->getState('usuario_nome_responsavel'); ?> </b>! <?php } ?> </div> <div id="box_icons"> <?php StatusNegocios::loadStatusNegocios2($model->itens_id); ?> </div> <div id="box_img_gde"> <?php if (count($im) > 0) { ?>
public function actionClear($id) { $this->layout = 'column2'; $model = Usuario::model()->find(array('select' => '*', 'condition' => 'usuario_id=:usuario_id', 'params' => array(':usuario_id' => $id))); $itens = Itens::model()->findAll(array('select' => '*', 'condition' => 'usuario_id=:usuario_id', 'params' => array(':usuario_id' => $id))); $arr_itens = ''; foreach ($itens as $key => $values) { $arr_itens .= $values->itens_id . ','; } if ($arr_itens) { $arr_itens = substr($arr_itens, 0, -1); } try { $transaction = Yii::app()->db->beginTransaction(); if (count($model) > 0) { $criteria = new CDbCriteria(); if (strlen($arr_itens)) { $criteria->condition = 'itens_id in(' . $arr_itens . ')'; ItensMultimidia::model()->deleteAll($criteria); StatusNegocios::model()->deleteAll($criteria); Itens::model()->deleteAll($criteria); } // echo Itens::model()->deleteByPk($id); exit; if (Usuario::model()->deleteByPk($id)) { $transaction->commit(); } Yii::app()->user->setState('frm_clear', true); $this->redirect(array('admin')); } } catch (CDbException $e) { $transaction->rollback(); //$model->addError(null, $e->getMessage()); } $this->render('index', array('model' => $model)); }
public static function gerarLista($model_pesq) { $list_neg = array(); if (count($model_pesq) > 0) { foreach ($model_pesq as $key => $values) { $list_neg[$key]['status_icons'] = ''; foreach ($values as $key2 => $values2) { if (is_null($values->{$key2})) { $values->{$key2} = ""; } if ($key2 == 'itens_id') { $list_neg[$key]['status_icons'] = StatusNegocios::loadStatusNegocios3($values->{$key2}); $im = ItensMultimidia::infoItensMultimidia($values->{$key2}); if (!empty($im->itens_multimidia_caminho)) { $thumb = Yii::app()->utils->incluiTracoImg($im->itens_multimidia_caminho); } if (count($im) > 0) { $list_neg[$key]['thumb'] = "<a href=\"http://" . $_SERVER["HTTP_HOST"] . Yii::app()->baseUrl . "/" . Yii::app()->controller->id . "/view/id/" . $values->{$key2} . "\"><img src=\"http://" . $_SERVER['HTTP_HOST'] . Yii::app()->baseUrl . "/uploads/" . Yii::app()->params['uploadPathMultimidiaItens'] . $values->{$key2} . "/" . $thumb . "\"></a>"; } else { $list_neg[$key]['thumb'] = "<a href=\"http://" . $_SERVER["HTTP_HOST"] . Yii::app()->baseUrl . "/" . Yii::app()->controller->id . "/view/id/" . $values->{$key2} . "\"><img src=\"http://" . $_SERVER['HTTP_HOST'] . Yii::app()->baseUrl . "/img/icons/thumb_modelo.png\"></a>"; } } else { $list_neg[$key][$key2] = $values->{$key2}; } } } } return json_encode($list_neg); }