public function deleteAction()
 {
     if ($this->getRequest()->isPost()) {
         $del = $this->getRequest()->getPost('del');
         if ($del == 'Si') {
             $id = $this->getRequest()->getPost('id');
             $mercaderia = new Application_Model_DbTable_Mercaderia();
             $mercaderia->deleteMercaderia($id);
         }
         $this->_helper->redirector('index');
     } else {
         $id = $this->_getParam('id', 0);
         $mercaderia = new Application_Model_DbTable_Mercaderia();
         $this->view->mercaderia = $mercaderia->getMercaderia($id);
     }
 }
    public function imprimirAction()
    {
        $id = $this->_getParam('id', 0);
        $borrador = $this->_getParam('borrador', 0);
        $objTrans = new Application_Model_DbTable_Transaccion();
        $objDocPri = new Application_Model_DbTable_Documentoprincipal();
        $objDocDest = new Application_Model_DbTable_Documentohasdestinatario();
        $objDest = new Application_Model_DbTable_Destinatario();
        $objTraInv = new Application_Model_DbTable_Inventariohastransaccion();
        $objInv = new Application_Model_DbTable_Inventario();
        $objMer = new Application_Model_DbTable_Mercaderia();
        $objTalla = new Application_Model_DbTable_Talla();
        $objTrpo = new Application_Model_DbTable_Transporte();
        $objPrSec = new Application_Model_DbTable_Principalhassecundario();
        $objDos = new Application_Model_DbTable_Documentosecundario();
        $objCol = new Application_Model_DbTable_Color();
        $arr_trans = $objTrans->getTransaccion($id);
        $arr_doc_pri = $objDocPri->getDocumentoprincipal($arr_trans['dop_id_documento_principal']);
        $arr_doc_dest = $objDocDest->listarRegistros($arr_doc_pri['dop_id_documento_principal']);
        $arr_transporte = $objTrpo->getTransporte($arr_trans['ctr_id_transporte']);
        $arr_doc_pri['dop_fecha'] = $this->getDescFecha(substr(new Zend_Date($arr_doc_pri['dop_fecha'], 'dd/MM/YYYY'), 0, 10));
        $arr_transporte['ctr_fecha_salida'] = $this->getDescFecha(substr(new Zend_Date($arr_transporte['ctr_fecha_salida'], 'dd/MM/YYYY'), 0, 10));
        $arr_transporte['ctr_fecha_llegada'] = $this->getDescFecha(substr(new Zend_Date($arr_transporte['ctr_fecha_llegada'], 'dd/MM/YYYY'), 0, 10));
        foreach ($arr_doc_dest as $doc_dest) {
            $arr = $objDest->getDestinatario($doc_dest->des_id_destinatario);
            if (strtolower($doc_dest->dhdo_tipo) == 'origen') {
                $arr_dest_origen = $arr;
            } else {
                $arr_dest_llegada = $arr;
            }
        }
        $arr_tran_inv = $objTraInv->listarRegistros($id);
        $arr_det = array();
        $ind_det = 0;
        $arr_cod_mer = array();
        foreach ($arr_tran_inv as $tra_inv) {
            $arr_inv = $objInv->getInventario($tra_inv->inv_id_inventario);
            $arr_mer = $objMer->getMercaderia($arr_inv['mer_id_mercaderia']);
            $arr_tall = $objTalla->getRegistro($arr_mer['tal_id_talla']);
            if (!in_array($arr_mer['mer_codigo'], $arr_cod_mer)) {
                $arr_color = $objCol->getColor($arr_mer['col_id_color']);
                array_push($arr_cod_mer, $arr_mer['mer_codigo']);
                $arr_det[$ind_det]['col_nombre'] = $arr_color['col_nombre'];
                $arr_det[$ind_det]['mer_codigo'] = $arr_mer['mer_codigo'];
                $arr_det[$ind_det]['mer_articulo'] = $arr_mer['mer_articulo'];
                $arr_det[$ind_det]['mer_costo'] = $arr_mer['mer_costo'] * $arr_inv['inv_cantidad'];
                $arr_det[$ind_det]['talla'] = array($arr_tall['tal_talla']);
                $arr_det[$ind_det]['inv_cantidad'] = array($arr_inv['inv_cantidad']);
                $ind_det++;
            } else {
                $pos = array_search($arr_mer['mer_codigo'], $arr_cod_mer);
                array_push($arr_det[$pos]['talla'], $arr_tall['tal_talla']);
                array_push($arr_det[$pos]['inv_cantidad'], $arr_inv['inv_cantidad']);
                $arr_det[$pos]['mer_costo'] += $arr_mer['mer_costo'] * $arr_inv['inv_cantidad'];
            }
        }
        $arr_doc_sec = $objPrSec->listarRegistros($arr_doc_pri['dop_id_documento_principal']);
        foreach ($arr_doc_sec as $doc_sec) {
            $arr_dos = $objDos->getDocumentosecundario($doc_sec->dos_id_documento_secundario);
        }
        //$arr_doc_pri['monto_neto']  = $arr_doc_pri['dop_monto_total']-$arr_doc_pri['dop_iva'];
        if ($borrador == 1) {
            $this->view->borrador = "BORRADOR";
        } else {
            $this->view->borrador = "";
        }
        $this->view->arr_trans = $arr_trans;
        $this->view->arr_doc_pri = $arr_doc_pri;
        $this->view->arr_doc_dest = $arr_doc_dest;
        $this->view->arr_dest_ori = $arr_dest_origen;
        $this->view->arr_dest_lle = $arr_dest_llegada;
        $this->view->arr_det = $arr_det;
        $this->view->arr_transporte = $arr_transporte;
        $this->view->arr_dos = $arr_dos;
        ob_start();
        ?>
        <page>
		<?php 
        echo $this->view->render('transaccion/imprimirpdf.phtml');
        ?>
        </page>
		<?php 
        $html = ob_get_clean();
        require_once "html2pdf/html2pdf.class.php";
        $html2pdf = new HTML2PDF('P', 'CARTA', 'es', true, 'ISO-8859-1');
        //$html2pdf->RotatedText(35,190,'W a t e r m a r k   d e m o',45);
        $html2pdf->pdf->SetDisplayMode('fullpage');
        $html2pdf->writeHTML($html, false);
        $this->view->pdf = $html2pdf;
        $this->view->render('transaccion/imprimir.phtml');
    }