/**
  * Export des echantillons issus de la recherche en xls
  */
 public function actionExportXls()
 {
     $model = new Echantillon('search');
     $model->unsetAttributes();
     if (isset($_GET['Echantillon'])) {
         $model->attributes = $_GET['Echantillon'];
     }
     // reprend les critères de la dernière recherche
     $dataprovider = new CActiveDataProvider('Echantillon', array('criteria' => $_SESSION['criteria'], 'pagination' => array('pageSize' => CommonTools::XLS_EXPORT_NB)));
     // supprime la pagination pour exporter l'ensemble des echantillons
     //	$echantillons = $dataprovider->data;
     $data = array(1 => array_keys($model->attributeExportedLabels()));
     setlocale(LC_ALL, 'fr_FR.UTF-8');
     $nb = 0;
     foreach ($dataprovider->data as $ech) {
         $line = array();
         foreach (array_keys($model->attributeExportedLabels()) as $attribute) {
             if ($attribute != 'notes') {
                 if ($ech->{$attribute} != null && !empty($ech->{$attribute})) {
                     $line[] = trim(iconv('UTF-8', 'ASCII//TRANSLIT', $ech->{$attribute}));
                     // solution la moins pire qui ne fait pas bugge les accents mais les convertit en caractere generique
                 } else {
                     $line[] = "-";
                 }
             } else {
                 foreach ($ech->{$attribute} as $noteValue) {
                     $line[] = trim(iconv('UTF-8', 'ASCII//TRANSLIT', $noteValue->CLE . ' : ' . $noteValue->VALEUR));
                 }
             }
         }
         $data[] = $line;
     }
     Yii::import('application.extensions.phpexcel.JPhpExcel');
     $xls = new JPhpExcel('UTF-8', true, 'Sample list');
     $xls->addArray($data);
     $xls->generateXML('sample list');
 }
Example #2
0
<?php

/* @var $this SearchEchantillonController */
/* @var $data Echantillon */
?>

<div class='view'>
<?php 
foreach (Echantillon::Model()->attributeExportedLabels() as $attribute => $value) {
    ?>
<b><?php 
    echo CHtml::encode($data->getAttributeLabel($attribute));
    ?>
:</b>
<?php 
    if ($attribute == 'biobank_id') {
        echo CHtml::encode(Biobank::Model()->findByPk($data->{$attribute})->identifier);
        ?>
		<?php 
    } elseif ($attribute == 'notes') {
        foreach ($data->notes as $note) {
            if ($note->VALEUR != null && !empty($note->VALEUR)) {
                echo CHtml::encode($note->CLE . ' : ' . $note->VALEUR);
                ?>
<br><?php 
            }
        }
    } elseif ($attribute == "storage_conditions") {
        echo CHtml::encode($data->getLiteralStorageCondition());
    } elseif ($attribute == "gender") {
        $genderList = $data->getArrayGender();