public function actionPrint($id) { $distributionVouchers = DistributionVoucher::model()->findAll("subdistribution_id = :subdistribution_id", array(":subdistribution_id" => $id)); $criteria = new CDbCriteria(); $criteria_string = "distribution_voucher_id in (0"; foreach ($distributionVouchers as $voucher_type) { $criteria_string = $criteria_string . ", " . $voucher_type->id; } $criteria_string = $criteria_string . ")"; $criteria->addCondition($criteria_string); $vouchers = Voucher::model()->findAll($criteria); Yii::import('application.controllers.VoucherController'); $obj = new VoucherController(""); $html = ''; foreach ($vouchers as $voucher) { $html .= $obj->actionPrint($voucher->id); } return $html; }
public static function editar() { $voucher = new Voucher(); $voucher->selecionarPorId($_GET['id']); if (!empty($_POST)) { if (!empty($_FILES["Event"]["name"]["imagem"])) { $imagem = $_FILES["Event"]["name"]["imagem"]; $imagem = strtolower(str_replace(" ", "-", $_POST['Event']['nome'])) . md5(date('YmdHis')) . '.' . pathinfo($imagem, PATHINFO_EXTENSION); move_uploaded_file($_FILES['Event']['tmp_name']['imagem'], __DIR__ . '/../imagens_evento/' . $imagem); unlink(__DIR__ . '/../imagens_evento/' . $_POST['Event']['imagem_antiga']); } unset($_POST['Event']['imagem_antiga']); foreach ($_POST['Event'] as $atributo => $valor) { $evento->{$atributo} = $valor; } $evento->imagem = $imagem; $idEvento = $evento->salvar(); self::redirecionar(Configuracao::$baseUrl . 'evento/listar' . Configuracao::$extensaoPadrao); } self::$variaveis = array('voucher' => $voucher); self::$corpo = "editar"; self::renderizar(self::$viewController); }