Exemplo n.º 1
1
 /**
  * Class constructor.
  */
 public function __construct(ProjectService $projectService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('id', 'create-report');
     /*
      * Create an array with possible periods. This will trigger a date but display a period (semester)
      */
     $semesterOptions = [];
     foreach ($projectService->parseYearRange() as $year) {
         /*
          * Use the Report object to parse the data
          */
         $report = new Report();
         $report->setDatePeriod(\DateTime::createFromFormat('Y-m-d', $year . '-03-01'));
         $semesterOptions[$year . '-1'] = $report->parseName();
         $report->setDatePeriod(\DateTime::createFromFormat('Y-m-d', $year . '-09-01'));
         $semesterOptions[$year . '-2'] = $report->parseName();
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'period', 'options' => ['label' => _("txt-report-period"), 'help-block' => _("txt-report-period-explanation"), 'value_options' => $semesterOptions], 'attributes' => ['class' => "form-control", 'id' => "period"]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'item', 'options' => ['label' => _("txt-document-name"), 'help-block' => _("txt-document-name-explanation")], 'attributes' => ['placeholder' => _("txt-please-give-a-document-name")]]);
     $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => "txt-file", "help-block" => _("txt-file-requirements")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-create")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }