extranet/library/Scores/PagePrint.php

161 lines
4.8 KiB
PHP
Raw Normal View History

<?php
class PagePrint
{
protected $controller = null;
protected $action = null;
protected $pagePRINT = array(
'identite-fiche' => 'siret,id',
2011-07-13 10:06:39 +00:00
'identite-fichepc' => 'siret,id',
'identite-etablissements' => 'siret,id,actif',
'identite-liens' => 'siret,id',
'identite-groupe' => 'siret',
'identite-evenements' => 'siret,id',
2011-07-13 10:06:39 +00:00
'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',
2011-07-13 10:06:39 +00:00
'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',
2011-09-06 08:18:33 +00:00
'pieces-bilans' => 'siret,id',
'pieces-actes' => 'siret,id',
'giant-full' => 'Pays,Type,CompanyId',
'giant-compact' => 'Pays,Type,CompanyId',
'giant-creditrecommendation' => 'Pays,Type,CompanyId',
2012-02-02 10:09:29 +00:00
'surveillance-fichier' => 'nomFic,filtre',
);
protected $pagePDF = array(
'identite-fiche' => 'siret,id',
2011-07-13 10:06:39 +00:00
'identite-fichepc' => 'siret,id',
'identite-etablissements' => 'siret,id,actif',
'identite-liens' => 'siret,id',
'identite-groupe' => 'siret',
'identite-evenements' => 'siret,id',
2011-07-13 10:06:39 +00:00
'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',
2011-07-13 10:06:39 +00:00
'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',
2011-09-06 08:18:33 +00:00
'pieces-bilans' => 'siret,id',
'pieces-actes' => 'siret,id',
'giant-full' => 'Pays,Type,CompanyId',
'giant-compact' => 'Pays,Type,CompanyId',
'giant-creditrecommendation' => 'Pays,Type,CompanyId',
);
protected $pageXML = array(
'identite-fiche' => 'siret,id',
2011-07-13 10:06:39 +00:00
'identite-fichepc' => 'siret,id',
'identite-etablissements' => 'siret,id,actif',
'identite-liens' => 'siret,id',
'identite-evenements' => 'siret,id',
2011-07-13 10:06:39 +00:00
'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',
2011-07-13 10:06:39 +00:00
'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',
);
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;
}
2011-05-24 06:25:58 +00:00
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;
}
2011-05-24 06:25:58 +00:00
public function objectToXML($object, $params)
{
require_once 'XML/Serializer.php';
$options = array (
'addDecl' => TRUE,
'encoding' => 'UTF-8',
'indent' => ' ',
'rootName' => 'root',
'defaultTagName' => 'element',
);
// Instantiate the serializer with the options
$Serializer = new XML_Serializer($options);
// Serialize the data structure
$result = $Serializer->serialize($object);
if($result === true) {
$content = $Serializer->getSerializedData();
$filename = $this->filename('xml', $params);
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->files).'/';
file_put_contents($path.$filename.'.xml', $content);
2011-05-24 06:25:58 +00:00
}
}
}