Пример #1
0
 public function render($return = false)
 {
     \GO::setMemoryLimit(512);
     $this->_pdf = new Pdf('L');
     //		$this->_pdf->font_size=8;
     $this->_pdf->title = $this->name();
     if ($this->project) {
         $this->_pdf->title .= ': ' . $this->project->path;
     }
     if (!empty($_REQUEST['startdate'])) {
         $this->_pdf->subtitle = $_REQUEST['startdate'];
         if (!empty($_REQUEST['enddate'])) {
             $this->_pdf->subtitle .= " - " . $_REQUEST['enddate'];
         }
     }
     $this->_pdf->AddPage();
     $this->_addProjects();
     if ($return) {
         return $this->_pdf->Output($this->filename . ".pdf", 'I');
     } else {
         Http::outputDownloadHeaders(new File($this->filename . ".pdf"));
         echo $this->_pdf->Output($this->filename . ".pdf", 'I');
     }
 }
Пример #2
0
 public function actionRemoveDuplicates($params)
 {
     \GO::setMaxExecutionTime(300);
     \GO::setMemoryLimit(1024);
     $this->render('externalHeader');
     $tasklist = \GO\Tasks\Model\Tasklist::model()->findByPk($params['tasklist_id']);
     if (!$tasklist) {
         throw new \GO\Base\Exception\NotFound();
     }
     \GO\Base\Fs\File::setAllowDeletes(false);
     //VERY IMPORTANT:
     \GO\Files\Model\Folder::$deleteInDatabaseOnly = true;
     \GO::session()->closeWriting();
     //close writing otherwise concurrent requests are blocked.
     $checkModels = array("GO\\Tasks\\Model\\Task" => array('name', 'start_time', 'due_time', 'rrule', 'user_id', 'tasklist_id'));
     foreach ($checkModels as $modelName => $checkFields) {
         if (empty($params['model']) || $modelName == $params['model']) {
             echo '<h1>' . \GO::t('removeDuplicates') . '</h1>';
             $checkFieldsStr = 't.' . implode(', t.', $checkFields);
             $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->select('t.id, count(*) AS n, ' . $checkFieldsStr)->group($checkFields)->having('n>1');
             $findParams->getCriteria()->addCondition('tasklist_id', $tasklist->id);
             $stmt1 = \GO::getModel($modelName)->find($findParams);
             echo '<table border="1">';
             echo '<tr><td>ID</th><th>' . implode('</th><th>', $checkFields) . '</th></tr>';
             $count = 0;
             while ($dupModel = $stmt1->fetch()) {
                 $select = 't.id';
                 if (\GO::getModel($modelName)->hasFiles()) {
                     $select .= ', t.files_folder_id';
                 }
                 $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->select($select . ', ' . $checkFieldsStr)->order('id', 'ASC');
                 $findParams->getCriteria()->addCondition('tasklist_id', $tasklist->id);
                 foreach ($checkFields as $field) {
                     $findParams->getCriteria()->addCondition($field, $dupModel->getAttribute($field));
                 }
                 $stmt = \GO::getModel($modelName)->find($findParams);
                 $first = true;
                 while ($model = $stmt->fetch()) {
                     echo '<tr><td>';
                     if (!$first) {
                         echo '<span style="color:red">';
                     }
                     echo $model->id;
                     if (!$first) {
                         echo '</span>';
                     }
                     echo '</th>';
                     foreach ($checkFields as $field) {
                         echo '<td>' . $model->getAttribute($field, 'html') . '</td>';
                     }
                     echo '</tr>';
                     if (!$first) {
                         if (!empty($params['delete'])) {
                             if ($model->hasLinks() && $model->countLinks()) {
                                 echo '<tr><td colspan="99">' . \GO::t('skippedDeleteHasLinks') . '</td></tr>';
                             } elseif (($filesFolder = $model->getFilesFolder(false)) && ($filesFolder->hasFileChildren() || $filesFolder->hasFolderChildren())) {
                                 echo '<tr><td colspan="99">' . \GO::t('skippedDeleteHasFiles') . '</td></tr>';
                             } else {
                                 $model->delete();
                             }
                         }
                         $count++;
                     }
                     $first = false;
                 }
             }
             echo '</table>';
             echo '<p>' . sprintf(\GO::t('foundDuplicates'), $count) . '</p>';
             echo '<br /><br /><a href="' . \GO::url('tasks/tasklist/removeDuplicates', array('delete' => true, 'tasklist_id' => $tasklist->id)) . '">' . \GO::t('clickToDeleteDuplicates') . '</a>';
         }
     }
     $this->render('externalFooter');
 }