Revize 440
Přidáno uživatelem Tomáš Dulík před asi 15 roky(ů)
freenetis/trunk/kohana/application/controllers/import.php | ||
---|---|---|
// problem: session doesn't work inside ORM class
|
||
//$this->session->set('log', 0);
|
||
|
||
$parser=new Parser_Ebanka();
|
||
//$this->profiler = new Profiler;
|
||
$mem=memory_get_usage();
|
||
$start=microtime(true);
|
||
$parser=new Parser_Ebanka();
|
||
|
||
echo "Memory usage=".($mem=memory_get_usage()). "<p>\n";
|
||
echo"parse - start: ".($start=microtime(true))."<p>\n";
|
||
|
||
//$parser->set_callback(array($this, "print_row"));
|
||
$parser->set_callback(array($this, "store_transfer_ebanka"));
|
||
// pokud z gridu dostáváme $account_id, pak si ho uložíme pro potřeby callback funkce
|
||
if (isset($bank_account_id))
|
||
$this->parsed_bank_acc=new Bank_account_Model($bank_account_id);
|
||
|
||
//print_r ($parser);
|
||
|
||
// $parser->parse("c:/txt/unart/ucto/vypisy/2007/09.html");
|
||
//$parser->parse("http://www.rb.cz/firemni-finance/transparentni-ucty/?root=firemni-finance&item1=transparentni-ucty&tr_acc=vypis&account_number=184932848");
|
||
if (empty($url)) $url="/var/www/freenetis-import/08.html.htm";
|
||
try {
|
||
$duplicity_err='';
|
||
$parser->parse($url);
|
||
} catch (Duplicity_Exception $ex) {
|
||
// v případě duplicity commitujeme vše do výskytu duplicity a hned skončíme
|
||
echo "Končíme, právě importovaný záznam má již v databázi duplicitní záznam:<br/>\n";
|
||
echo "<table border=1>";
|
||
$first=true; $header="";
|
||
foreach ($ex->duplicity as $dup) {
|
||
echo "<tr>\n"; $data="";
|
||
foreach ($dup as $key=>$val) {
|
||
if ($first)
|
||
$header.="<th>$key</th>";
|
||
$data.="<td>$val</td>";
|
||
}
|
||
if ($first) {
|
||
echo $header;
|
||
echo "</tr>\n";
|
||
$first=false;
|
||
}
|
||
echo $data;
|
||
echo "</tr>\n";
|
||
|
||
}
|
||
$duplicity=new View('table_n_columns');
|
||
$duplicity->set('table_data', $ex->duplicity);
|
||
$duplicity_err = "Končíme, právě importovaný záznam má již v databázi duplicitní záznam:\n"
|
||
.$duplicity;
|
||
}
|
||
//$parser->parse("http://localhost/2007.html");
|
||
//$parser->parse("c:/txt/unart/ucto/vypisy/2007/2007.html");
|
||
echo "<table border=1>\n";
|
||
foreach ($this->stats as $key=>$value)
|
||
echo "<tr><td>$key</td><td>$value</td></tr>";
|
||
echo "</table>\n";
|
||
$results = new View('table_2_columns');
|
||
$results->set('table_data', $this->stats);
|
||
if (!isset($this->stats->time_deposits)) $this->stats->time_deposits=0;
|
||
if (!isset($this->stats->time_deposits_drawn)) $this->stats->time_deposits_drawn=0;
|
||
if (!isset($this->stats->invoices)) $this->stats->invoices=0;
|
||
if (!isset($this->stats->interests)) $this->stats->interests=0;
|
||
if (!isset($this->stats->bank_fees)) $this->stats->bank_fees=0;
|
||
if (!isset($this->stats->member_fees)) $this->stats->member_fees=0;
|
||
|
||
$outp="Bank. poplatky = ". $this->stats->bank_fees;
|
||
$outp.="<br/>\nVýdaje = ". ($this->stats->bank_fees + $this->stats->invoices + $this->stats->time_deposits_drawn);
|
||
$outp.="<br/>\nPříjmy = ". ($this->stats->interests + $this->stats->member_fees + $this->stats->time_deposits);
|
||
$outp.="<br/>\nImport script memory consumption=".(memory_get_usage()-$mem)."<p>\n";
|
||
$outp.="Import script time consumption: ".(microtime(true)-$start)."<p>\n";
|
||
|
||
echo "Bank. poplatky = ". $this->stats->bank_fees;
|
||
echo "<br/>\nVýdaje = ". ($this->stats->bank_fees + $this->stats->invoices + $this->stats->time_deposits_drawn);
|
||
echo "<br/>\nPříjmy = ". ($this->stats->interests + $this->stats->member_fees + $this->stats->time_deposits);
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$title=url_lang::lang('texts.Bank transfers import results');
|
||
$view->header->title = $title;
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->content = new View('show_all');
|
||
$view->content->table = $duplicity_err . "Statistiky:". $results. $outp;
|
||
$view->content->link_back = html::anchor(url_lang::base().'bank_accounts/show_all', url_lang::lang('texts.Back to bank accounts'));
|
||
$view->content->headline = $title;
|
||
$view->footer = new View('base/footer');
|
||
$view->render(TRUE);
|
||
|
||
echo "<br/>\nMemory usage=".(memory_get_usage()-$mem)."<p>\n";
|
||
echo"parse - end: ".(microtime(true)-$start)."<p>\n";
|
||
//print_r($this);
|
||
//die("OK");
|
||
echo html::anchor(url_lang::base().'bank_accounts/show_all', url_lang::lang('texts.Back to bank accounts'));
|
||
// enable logging of database items
|
||
//$this->session->set('log', 1);
|
||
}
|
freenetis/trunk/kohana/application/views/table_n_columns.php | ||
---|---|---|
<?php
|
||
echo "<table class=\"main\" cellspacing=\"0\">\n";
|
||
$first=true; $header="";
|
||
foreach ($table_data as $row) {
|
||
echo " <tr>";
|
||
$data="";
|
||
foreach ($row as $col_name=>$val) {
|
||
if ($first)
|
||
$header.="<th>$col_name</th>";
|
||
$data.="<td>$val</td>";
|
||
}
|
||
if ($first) {
|
||
echo $header . "</tr>\n";
|
||
$first=false;
|
||
}
|
||
echo $data . "</tr>\n";
|
||
}
|
||
echo "\n</table><br/>\n"
|
||
?>
|
||
freenetis/trunk/kohana/application/views/table_2_columns.php | ||
---|---|---|
<?php
|
||
echo "<table class=\"extended\" cellspacing=\"0\">\n";
|
||
foreach ($table_data as $key=>$value)
|
||
echo " <tr><th>$key</th><td>$value</td></tr>";
|
||
echo "</table>\n<br/>\n";
|
||
?>
|
||
Také k dispozici: Unified diff
Do funkce importu dodelany views pro peknejsi vystup...v pristi revizi to jeste trochu vylepsim, ted se musim venovat rodine.