<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(4, new lime_output_color());
$u = Doctrine::getTable('Users')->getUserByPassword("root", "evil");
$reports = Doctrine::getTable('Reports')->getTaskReports();
$t->is(count($reports), 0, '"0" Tasks report available');
$report = new Reports();
$report->setParameters(array('name' => 'annual_stat_collection', 'collection_ref' => 1, 'date_from' => '01-01-2000', 'date_to' => '31-12-2012'));
$report->setUserRef($u->getId());
$report->setName('annual_stat_collection');
$report->setLang('en');
$report->setFormat('pdf');
$report->save();
$reports = Doctrine::getTable('Reports')->getTaskReports();
$t->is(count($reports), 1, '"1" Task report available');
$reports = Doctrine::getTable('Reports')->getUserReport($u->getId());
$t->is(count($reports), 1, '"1" report available for user "' . $u->getGivenName() . '"');
foreach ($reports as $report) {
    $t->is($report->getParameters()->count(), 3, '"3" parameters (collection_ref,date_from,date_to) set for "' . $report->getName() . '"');
}
Beispiel #2
0
 function generateReport()
 {
     $code = $this->generatePass();
     $now = Carbon::Now();
     $clients = isset($_GET["clients"]) ? $_GET["clients"] : null;
     $name = isset($_GET["name"]) ? $_GET["name"] : "";
     $periodFrom = isset($_GET["periodFrom"]) ? $_GET["periodFrom"] : null;
     $periodTo = isset($_GET["periodTo"]) ? $_GET["periodTo"] : null;
     if (is_null($clients)) {
         echo "Nepavyko nuskaityti parametro!";
         return;
     }
     $reports = new Reports();
     $reports->setName($name);
     $reports->setCode($code);
     $reports->setClients($clients);
     $reports->setOwner(9);
     $reports->setPeriod_from($periodFrom);
     $reports->setPeriod_to($periodTo);
     $reports->setAdd_date($now->toDateTimeString());
     $rez = $this->reportsDao->insert($reports);
     if (is_string($rez)) {
         echo "-1";
         return;
     }
     $fullUrl = $this->reportsUrl . $code;
     //$return = '<span style="font-size: 12px; font-weight: bold;">Ataskaitos adresas</span><br /><div class="well well-sm">'.$fullUrl.'</div>';
     $return = '<span style="font-size: 12px; font-weight: bold;">Ataskaitos adresas</span><br /><input type="text" class="form-control" id="exampleInputEmail1" value="' . $fullUrl . '" onclick="this.select(); document.execCommand(\'copy\');">';
     echo $return;
 }
 function find($criteria = null, $order = null, $limit = 1000, $from = 0)
 {
     $result = $this->database->query($this->buildFindQuery($criteria, $order, $limit, $from));
     if (!is_null($result->getError())) {
         return $result->getError();
     }
     $reportss = array();
     while ($row = $result->fetchRow()) {
         $reports = new Reports();
         $value = $row[0];
         $reports->setId($value);
         $value = $row[1];
         $reports->setName($value);
         $value = $row[2];
         $reports->setCode($value);
         $value = $row[3];
         $reports->setClients($value);
         $value = $row[4];
         $reports->setOwner($value);
         $value = $row[5];
         $reports->setPeriod_from($value);
         $value = $row[6];
         $reports->setPeriod_to($value);
         $value = $row[7];
         $reports->setAdd_date($value);
         if ($order != null) {
             array_push($reportss, $reports);
         } else {
             $reportss[$reports->getId()] = $reports;
         }
     }
     return $reportss;
 }