Use Of Extension Csvexport

Dear all,

I would like to use the extension csvexport. http://www.yiiframework.com/extension/csvexport/

I have a server inventory application.

controller: ServerController

model: Server

view: server with export.php

I would like to create a view with urls to csv exports like, servername and status or servername and backup (yes or no).

For each export I need a certain url, because this export should be possible via click on a link and also be started automatically from a job control software.

But how do I integrate this extension?

my server/export.php


<?php

/* @var $this ServerController */

/* @var $dataProvider CActiveDataProvider */


$this->breadcrumbs=array(

    	'Server Export',

);


?>


<h1>Server Export</h1>


Export servername and backup

Export servername and status

I don“t know:

my models/Server.php




class Server extends CActiveRecord

{

        const BACKUP_TRUE=0;

        const BACKUP_FALSE=1;

        

        public $fidOs_search;

        public $fidEnvironment_search;

        

	/**

	 * Returns the static model of the specified AR class.

	 * @param string $className active record class name.

	 * @return Server the static model class

	 */

	public static function model($className=__CLASS__)

	{

		return parent::model($className);

	}


	/**

	 * @return string the associated database table name

	 */

	public function tableName()

	{

		return 'server';

	}


	/**

	 * @return array validation rules for model attributes.

	 */

	public function rules()

	{

                // NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('id_server', 'required'),

                        array('id_server', 'unique'),

                        //array('fid_arch', 'numerical', 'integerOnly'=>true),

			//array('is_virtual', 'integerOnly'=>true),

			array('id_server', 'length', 'max'=>50),

                        array('is_virtual, maintenance', 'length', 'max'=>1),

                        array('backup, fid_environment, fid_os, os_version', 'length', 'max'=>50),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('fidEnvironment_search, fidOs_search, is_virtual', 'safe', 'on'=>'search'),

		);

	}


	/**

	 * @return array relational rules.

	 */

	public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

                    'fidEnvironment' => array(self::BELONGS_TO, 'Environment', 'fid_environment'),

                    'fidOs' => array(self::BELONGS_TO, 'Operatingsystem', 'fid_os'),

                );

	}


	/**

	 * @return array customized attribute labels (name=>label)

	 */

	public function attributeLabels()

	{

		return array(

                    'backup' => 'Backup',

                    'id_server' => 'Hostname',

                    'fid_environment' => 'Umgebung',

                    'fidEnvironment_search' => 'Umgebung',

                    'fid_os' => 'Betriebssystem',

                    'fidOs_search' => 'Betriebssystem',

                    'is_virtual' => 'virtueller Server',

                    'maintenance' => 'in Wartung',

                    'os_version' => 'Betriebssystemversion',

			

		);

	}


	/**

	 * Retrieves a list of models based on the current search/filter conditions.

	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.

	 */

	public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;

                $criteria->with = array( 'fidOs','fidEnvironment' );

                $criteria->compare('backup',$this->backup,true);

                $criteria->compare('fidEnvironment.environment', $this->fidEnvironment_search, true );

		$criteria->compare('fidOs.os_name', $this->fidOs_search, true );

                $criteria->compare('id_server',$this->id_server,true);

		$criteria->compare('is_virtual',$this->is_virtual);

                $criteria->compare('maintenance',$this->maintenance,true);

		

		

		//return new CActiveDataProvider($this, array(

		//	'criteria'=>$criteria,

		//));

                

                // Damit auch nach Betriebssystem sortiert werden kann.

                return new CActiveDataProvider( $this, array(

                'criteria'=>$criteria,

                    'sort'=>array(

                        'attributes'=>array(

                            'fidOs_search'=>array(

                                'asc'=>'fidOs.os_name',

                                'desc'=>'fidOs.os_name DESC',

                            ),

                            'fidEnvironment_search'=>array(

                                'asc'=>'fidEnvironment.environment',

                                'desc'=>'fidEnvironment.environment DESC',

                            ),

                            '*',

                        ),

                    ),

                ));

	}

        

        //export to csv files

        public function export()

        {

            

        }

        

        /**

        * Retrieves a list of backup types

        * @return array an array of available backup types.

        */

        public function getBackupOptions()

        {

            return array(

                self::BACKUP_TRUE=>'ja',

                self::BACKUP_FALSE=>'nein',

            );

        }

        

        /**

         * Umwandlung nach Boolean fuer die Checkbox

         */

        public function convertToBooleans() {

            $attributes = array('is_virtual');

            array_map(array($this, 'convertAttributeToBoolean'), $attributes);

        }

        

        /**

         * Umwandlung nach Boolean fuer die Checkbox

         */

        public function convertAttributeToBoolean($attr) {

            $this->$attr = ($this->$attr == 'Y') ? true : false;

        }

           

}



controllers/ServerContoller.php


        

	public function actionExport()

	{

		$model=new Server('export');

		$model->unsetAttributes();  // clear any default values

		if(isset($_GET['Server']))

			$model->attributes=$_GET['Server'];


		$this->render('export',array(

			'model'=>$model,

		));

	}



Best regards

Andreas