<?php

/**
 * Seguro_BoletoController
 * 
 * @author Renato - 16/08/2010
 */

class Seguro_BoletoController extends Zend_Controller_Action {
	
	/**
	 * Abre um formulario ajax para edicao do numero do boleto
	 * 
	 * @author Renato - 16/08/2010
	 */
	public function editarAction() {
		$this->getHelper('layout')->disableLayout();
		
		if ($this->getRequest()->getParam('id_proposta')) {
			$PropostaBoleto = new Seguro_Model_PropostaBoleto();
			$this->view->nu_boleto = $PropostaBoleto->getNumeroBoleto($this->getRequest()->getParam('id_proposta'));
			$this->view->id_proposta = $this->getRequest()->getParam('id_proposta');
		}
	}
	
	/**
	 * Salva o novo numero do boleto
	 * 
	 * @author Renato - 16/08/2010
	 */
	public function salvarAction() {
		$this->getHelper('ViewRenderer')->setNoRender();
		$this->getHelper('layout')->disableLayout();

		$PropostaBoleto = new Seguro_Model_PropostaBoleto();
		$status = $PropostaBoleto->setNumeroBoleto($this->getRequest()->getParam('id_proposta'), $this->getRequest()->getParam('nu_boleto'));
		
		$this->getResponse()->setBody(Zend_Json::encode(array(
			'status' => $status,
			'message' => $PropostaBoleto->getMessages()
		)));
	}
	
	/**
	 * Deleta um boleto
	 * 
	 * @author Renato - 16/08/2010
	 */
	public function deletarAction() {
		$this->getHelper('ViewRenderer')->setNoRender();
		$this->getHelper('layout')->disableLayout();

		$PropostaBoleto = new Seguro_Model_PropostaBoleto();
		$PropostaBoleto->deleteNumeroBoleto($this->getRequest()->getParam('id_proposta'));

		$this->getResponse()->setBody(Zend_Json::encode(array('id_proposta' => $this->getRequest()->getParam('id_proposta'))));
	}

}

