<?php
require_once 'include/ECM/EcmSendPdfButton/EcmSendPdfButton.inc';

class EcmSendPdfButtonController
{

    public function renderButtom ($module, $id)
    {
        $t = new EcmSendPdfButton($module, $id);
        echo $t->showButtom();
    }
    
    public function sendEmailAjaxWithDocument ($module, $id,$adress,$text,$pdf_opt)
    {
       $t = new EcmSendPdfButton($module, $id,$adress);
       $t->generatePdf($pdf_opt);
       $t->setAdress($adress);
       $EcmSysInfo = new EcmSysInfo();
       
       $t->setSubject('Dokument od '.$EcmSysInfo->getShortName());
      //$t->setSubject($pdf_opt);
       $t->setBody($text);
       $t->setAttachment();
       return $t->sendEmail();
    }   
}

switch ($_REQUEST['action']){
    
    case 'DetailView':
        $c=new EcmSendPdfButtonController();
        $c->renderButtom ($_REQUEST['module'], $_REQUEST['record']);
        break;
}
