Initial Commit
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
class Zend_Controller_Action_Helper_Docsmaker extends Zend_Controller_Action_Helper_Abstract
|
||||
{
|
||||
protected $_dataHelper;
|
||||
protected $_formatDataHelper;
|
||||
protected $_globalFunction;
|
||||
protected $_genericModel;
|
||||
protected $_view;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->_dataHelper = $this->getActionController()->getHelper('ExtractData');
|
||||
$this->_formatDataHelper = $this->getActionController()->getHelper('FormatData');
|
||||
$this->_globalFunction = $this->getActionController()->getHelper('Globalfunction');
|
||||
$this->_view = null;
|
||||
}
|
||||
|
||||
public function direct()
|
||||
{
|
||||
}
|
||||
|
||||
public function reportAttivita(Zend_View &$view, $dati, $mode = 'I', $autoprint = false, $returnHtml = false)
|
||||
{
|
||||
|
||||
$this->_view = $view;
|
||||
$preOutputScript = "";
|
||||
|
||||
if (!$this->_view) {
|
||||
throw new Zend_Exception("Errore view non presente");
|
||||
}
|
||||
|
||||
if (!$dati) {
|
||||
throw new Zend_Exception("Errore dati non ricevuti");
|
||||
}
|
||||
|
||||
/********************************************* Calcolo dei dati necessari **********************************************/
|
||||
|
||||
$totali = array_merge($dati['ElencoLicenze']);
|
||||
end($totali);
|
||||
$this->_view->lastRigaKey = key($totali);
|
||||
|
||||
//$stringa_periodo = ($data[0] === $data[1]) ? 'del ' . $this->_formatDataHelper->direct($data[0], 'd/m/Y') : 'dal ' . $this->_formatDataHelper->direct($data[0], 'd/m/Y') . ' al ' . $this->_formatDataHelper->direct($data[1], 'd/m/Y');
|
||||
|
||||
$this->_view->assign(array(
|
||||
'Data' => $dati['Data'],
|
||||
'Periodo' => $dati['Periodo'],
|
||||
'ElencoLicenze' => $dati['ElencoLicenze'],
|
||||
'TotaliAttivazioni' => $dati['TotaliAttivazioni'],
|
||||
'TotaleFe' => $dati['TotaleFe'],
|
||||
'Rivenditore' => $dati['Rivenditore']
|
||||
));
|
||||
|
||||
$this->_view->setScriptPath(APPLICATION_PATH . "/modules/default/views/scripts/");
|
||||
|
||||
$filename = 'Report ' . str_replace('/', '', $dati['Periodo']) . ' - ' . $dati['Rivenditore']['RagioneSociale'];
|
||||
|
||||
if ($mode == 'F') {
|
||||
$preOutputScript = APPLICATION_PATH . "/../public/doctmp/";
|
||||
}
|
||||
|
||||
$this->getResponse()->setBody('');
|
||||
$html = $this->_view->render('index/print/reportattivita.phtml');
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4',
|
||||
'margin_top' => 38, 'margin_right' => 10, 'margin_bottom' => 5, 'margin_left' => 10,
|
||||
'margin_header' => 5, 'margin_footer' => 5]);
|
||||
$mpdf->setAutoTopMargin = 'stretch';
|
||||
$mpdf->setAutoBottomMargin = 'stretch';
|
||||
$mpdf->keep_table_proportions = true;
|
||||
|
||||
$mpdf->SetTitle($filename);
|
||||
$mpdf->SetAuthor("Adriatica Sistemi soc. coop.");
|
||||
$mpdf->SetDisplayMode('fullpage');
|
||||
|
||||
//Funzione che avvia la stampa direttamente
|
||||
if ($autoprint == 'true') {
|
||||
$mpdf->SetJS('this.print();');
|
||||
}
|
||||
|
||||
if (!$returnHtml) {
|
||||
$mpdf->WriteHTML($html);
|
||||
//Il Mode 'S' restituisce il contenuto del file che codifico in base64 e lo retituisco
|
||||
if ($mode == 'S') {
|
||||
$res = array();
|
||||
$res['filename'] = $filename . ".pdf";
|
||||
$res['filecontent'] = $mpdf->Output($preOutputScript . $filename . ".pdf", $mode);
|
||||
return $res;
|
||||
} else {
|
||||
//Gestione per gli altri mode 'I' o 'F' o 'D'
|
||||
$mpdf->Output($preOutputScript . $filename . ".pdf", $mode);
|
||||
$res = array();
|
||||
$res['filename'] = $filename . ".pdf";
|
||||
$res['path'] = $preOutputScript;
|
||||
$res['completeFilePath'] = $preOutputScript . $filename . '.pdf';
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function reportAttivitaAdmin(Zend_View &$view, $dati, $mode = 'I', $autoprint = false, $returnHtml = false)
|
||||
{
|
||||
|
||||
$this->_view = $view;
|
||||
$preOutputScript = "";
|
||||
|
||||
if (!$this->_view) {
|
||||
throw new Zend_Exception("Errore view non presente");
|
||||
}
|
||||
|
||||
if (!$dati) {
|
||||
throw new Zend_Exception("Errore dati non ricevuti");
|
||||
}
|
||||
|
||||
/********************************************* Calcolo dei dati necessari **********************************************/
|
||||
|
||||
$tmp = $dati['ElencoRivenditori'];
|
||||
end($tmp);
|
||||
$this->_view->lastRigaKey = key($tmp);
|
||||
|
||||
$this->_view->assign(array(
|
||||
'Data' => $dati['Data'],
|
||||
'Periodo' => $dati['Periodo'],
|
||||
'ElencoAttivita' => $dati['ElencoAttivita']
|
||||
));
|
||||
|
||||
$this->_view->setScriptPath(APPLICATION_PATH . "/modules/default/views/scripts/");
|
||||
|
||||
$filename = 'Report Riepilogo per Attività ' . str_replace('/', '-', $dati['Periodo']);
|
||||
|
||||
if ($mode == 'F') {
|
||||
$preOutputScript = APPLICATION_PATH . "/../public/doctmp/";
|
||||
}
|
||||
|
||||
$this->getResponse()->setBody('');
|
||||
$html = $this->_view->render('index/print/reportattivitaadmin.phtml');
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4',
|
||||
'margin_top' => 28, 'margin_right' => 10, 'margin_bottom' => 5, 'margin_left' => 10,
|
||||
'margin_header' => 5, 'margin_footer' => 5]);
|
||||
$mpdf->setAutoTopMargin = 'stretch';
|
||||
$mpdf->setAutoBottomMargin = 'stretch';
|
||||
$mpdf->keep_table_proportions = true;
|
||||
|
||||
$mpdf->SetTitle($filename);
|
||||
$mpdf->SetAuthor("Adriatica Sistemi soc. coop.");
|
||||
$mpdf->SetDisplayMode('fullpage');
|
||||
|
||||
//Funzione che avvia la stampa direttamente
|
||||
if ($autoprint == 'true') {
|
||||
$mpdf->SetJS('this.print();');
|
||||
}
|
||||
|
||||
if (!$returnHtml) {
|
||||
$mpdf->WriteHTML($html);
|
||||
//Il Mode 'S' restituisce il contenuto del file che codifico in base64 e lo retituisco
|
||||
if ($mode == 'S') {
|
||||
$res = array();
|
||||
$res['filename'] = $filename . ".pdf";
|
||||
$res['filecontent'] = $mpdf->Output($preOutputScript . $filename . ".pdf", $mode);
|
||||
return $res;
|
||||
} else {
|
||||
//Gestione per gli altri mode 'I' o 'F' o 'D'
|
||||
$mpdf->Output($preOutputScript . $filename . ".pdf", $mode);
|
||||
$res = array();
|
||||
$res['filename'] = $filename . ".pdf";
|
||||
$res['path'] = $preOutputScript;
|
||||
$res['completeFilePath'] = $preOutputScript . $filename . '.pdf';
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user