6 public $defaultAction =
'reports';
8 public function actionReports($form_id = null, $csv =
false)
13 $form = isset($form_id)?
FGForms::model()->findByPk($form_id) : null;
18 return $this->exportCSV($form);
21 $this->render(
'reports', array(
28 public function exportCSV($form)
32 if(count($form->formdata))
39 foreach(array_keys($form->formdata[0]->getDisplayData()) as $name) {
40 $csv[0][] = $form->getElementLabel($name);
42 foreach($form->formdata as $fd) {
43 $csv[] = array_merge(array($fd->created_at), array_values($fd->getDisplayData()));
47 Yii::import(
'application.modules.fg.extensions.UrlTransliterate');
48 header(
'Content-type: text/csv');
54 $outstream = fopen(
'php://output',
'w');
55 foreach($csv as $row) {
56 fputcsv($outstream, $row,
',',
'"');
65 throw new CHttpException(404,
'No reports found');
69 public function actionGetMyForms($email)
72 $forms = $model->searchAllForUser($email);
73 $ret =
"<table><tr><th>Name</th><th>Aktion</th></tr>";
74 foreach($forms->getData() as $form):
76 $ret.=
"<tr><td>".$form->name.
"</td><td>";
77 if(count($form->formdata)):
78 $ret.=CHtml::link(
"Report anzeigen",array(Yii::app()->createUrl(
'proxy/fg/admin/reports?form_id='.$form->id.
'&csv=1'))).
'</td>';
80 $ret.=
"<i>keine Reports vorhanden</i></td>";
90 public function actionUpdateCreator($form_id = null, $mail =
''){
91 $form = isset($form_id)?
FGForms::model()->findByPk($form_id) : null;
92 if($form && $mail !=
''){
93 if($form->creator_email ==
'NULL' || $form->creator_email ==
'' || $form->creator_email == null){
94 $form->creator_email = $mail;
97 else echo
"no update";
100 echo
"error:".$form_id.
" ".$mail;