partner/library/Scores/PagePrint.php

158 lines
4.8 KiB
PHP
Raw Normal View History

2013-10-15 17:30:21 +02:00
<?php
class PagePrint
{
protected $controller = null;
protected $action = null;
protected $pagePRINT = array(
'identite-fiche' => 'siret,id',
'identite-fichepc' => 'siret,id',
'identite-etablissements' => 'siret,id,actif',
'identite-liens' => 'siret,id',
'identite-groupe' => 'siret',
'identite-evenements' => 'siret,id',
'dirigeant-liste' => 'siret,id',
'dirigeant-histo' => 'siret,id',
'finance-synthese' => 'siret,id,typeBilan',
'finance-bilan' => 'siret,id,typeBilan',
'finance-ratios' => 'siret,id,typeBilan,mil',
'finance-liasse' => 'siret,id,unit,date',
'finance-bourse' => 'siret,id',
'finance-banque' => 'siret,id',
'juridique-annonces' => 'siret,id,idAnn,vue,p',
'juridique-infosreg' => 'siret,id',
'juridique-competences' => 'siret,id,type',
'juridique-marques' => 'siret,id,idObject',
'evaluation-indiscore' => 'siret,id',
'evaluation-indiscore2' => 'siret,id',
'evaluation-indiscore3' => 'siret,id',
'evaluation-scoring' => 'siret,id',
'evaluation-valorisation' => 'siret,id',
'pieces-bilans' => 'siret,id',
'pieces-actes' => 'siret,id',
'giant-full' => 'Pays,Type,CompanyId',
'giant-compact' => 'Pays,Type,CompanyId',
'giant-creditrecommendation' => 'Pays,Type,CompanyId',
'surveillance-fichier' => 'nomFic,filtre',
'worldcheck-matchcontent' => 'matchIdentifier',
);
protected $pagePDF = array(
'identite-fiche' => 'siret,id',
'identite-fichepc' => 'siret,id',
'identite-etablissements' => 'siret,id,actif',
'identite-liens' => 'siret,id',
'identite-groupe' => 'siret',
'identite-evenements' => 'siret,id',
'dirigeant-liste' => 'siret,id',
'dirigeant-histo' => 'siret,id',
'finance-synthese' => 'siret,id,typeBilan',
'finance-bilan' => 'siret,id,typeBilan',
'finance-ratios' => 'siret,id,typeBilan,mil',
'finance-liasse' => 'siret,id,unit,date',
'finance-bourse' => 'siret,id',
'finance-banque' => 'siret,id',
'juridique-annonces' => 'siret,id,idAnn,vue,p',
'juridique-infosreg' => 'siret,id',
'juridique-competences' => 'siret,id,type',
'juridique-marques' => 'siret,id,idObject',
'evaluation-indiscore' => 'siret,id',
'evaluation-indiscore2' => 'siret,id',
'evaluation-indiscore3' => 'siret,id',
'evaluation-scoring' => 'siret,id',
'evaluation-valorisation' => 'siret,id',
'pieces-bilans' => 'siret,id',
'pieces-actes' => 'siret,id',
'giant-full' => 'Pays,Type,CompanyId',
'giant-compact' => 'Pays,Type,CompanyId',
'giant-creditrecommendation' => 'Pays,Type,CompanyId',
'worldcheck-matchcontent' => 'matchIdentifier',
);
protected $pageXML = array(
'identite-fiche' => 'siret,id',
'identite-fichepc' => 'siret,id',
'identite-etablissements' => 'siret,id,actif',
'identite-liens' => 'siret,id',
'identite-evenements' => 'siret,id',
'dirigeant-liste' => 'siret,id',
'dirigeant-histo' => 'siret,id',
'finance-synthese' => 'siret,id,typeBilan',
'finance-bilan' => 'siret,id,typeBilan',
'finance-ratios' => 'siret,id,typeBilan,mil',
'finance-liasse' => 'siret,id,unit,date',
'finance-bourse' => 'siret,id',
'finance-banque' => 'siret,id',
'juridique-annonces' => 'siret,id,idAnn,vue,p',
'juridique-infosreg' => 'siret,id',
'juridique-competences' => 'siret,id,type',
'juridique-marques' => 'siret,id,idObject',
'evaluation-indiscore' => 'siret,id',
'evaluation-indiscore2' => 'siret,id',
'evaluation-indiscore3' => 'siret,id',
'evaluation-valorisation' => 'siret,id',
'worldcheck-matchcontent' => 'matchIdentifier',
);
public function __construct($controller, $action)
{
$this->controller = $controller;
$this->action = $action;
}
protected function getTypeElement($type)
{
$element = array();
switch($type){
case 'print':
$element = $this->pagePRINT;
break;
case 'pdf':
$element = $this->pagePDF;
break;
case 'xml':
$element = $this->pageXML;
break;
}
return $element;
}
public function exportable($type)
{
$element = $this->getTypeElement($type);
if (array_key_exists($this->controller.'-'.$this->action, $element)){
return true;
}
return false;
}
public function filename($type, $params = array())
{
$element = $this->getTypeElement($type);
$filename = $this->controller.'-'.$this->action;
$key = $this->controller.'-'.$this->action;
if (array_key_exists($key, $element)){
$part = explode(',', $element[$key]);
foreach( $part as $item ){
if (!empty($params[$item])){
$filename.= '-'.$params[$item];
}
}
}
return $filename;
}
public function objectToXML($object, $params)
{
$serializer = new Scores_Serializer_Adapter_Xml();
try {
$content = $serializer->serialize($object);
$filename = $this->filename('xml', $params);
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->files).'/';
file_put_contents($path.$filename.'.xml', $content);
} catch (Zend_Serializer_Exception $e) {
//Error
}
}
}