Revize 268
Přidáno uživatelem Tomáš Dulík před více než 15 roky(ů)
freenetis/trunk/kohana/application/controllers/accounts.php | ||
---|---|---|
* [date_time] => 2008-03-25 05:40
|
||
* [comment] => Rozpis polozek uvedenv soupisu prevodu
|
||
* [name] => CESKA POSTA, S.P.
|
||
* [account_nr] => 160987123/0300
|
||
* [account_nr] => 160987123
|
||
* [account_bank_nr] = 0300
|
||
* [typ] => Příchozí platba
|
||
* [variable_symbol] => 9081000001
|
||
* [constant_symbol] => 998
|
||
... | ... | |
* 2. get the credit account of the member
|
||
* 3. find or create the source bank account
|
||
* 4. create the money_transfers record
|
||
$data stdClass
|
||
*/
|
||
|
||
// init the parsed_account instance by looking it in database
|
||
|
||
/**
|
||
* @var int $bank_acc_enum_id je id enum typu "bankovni ucet". Je static, aby se nemuselo
|
||
* v databazi hledat pri kazdem dalsim nactenem radku z vypisu
|
||
*/
|
||
static $bank_acc_enum_id;
|
||
if (!isset($bank_acc_enum_id)) { // pokud jeste neni nastaveno (pri 1. volani callback funkce)
|
||
$enum_type_bank=new Enum_type_Model();
|
||
$bank_acc_enum_id=$enum_type->find_by_value("bank")->id; // tak si toto id nastav
|
||
}
|
||
// ******************** Tady si vytvorime instance parsovaneho uctu: ******************
|
||
if (!isset($this->parsed_account)) { // tato promenna bude nastavena pouze pokud se parsuje ucet zvoleny v gridu uzivatelem
|
||
if (isset($data->parsed_account_nr) && isset($data->parsed_account_bank_nr)) {
|
||
// jinak parsovany ucet dopredu nezname, muze byt ale v parsovanem vypisu (pokud neni transparentni)
|
||
$acc_model=$this->parsed_account=new Account_Model();
|
||
$bank_acc_model=new Bank_account_Model();
|
||
$parsed_acc=$this->parsed_account=new Account_Model();
|
||
$parsed_bank_acc=new Bank_account_Model();
|
||
|
||
$bank_acc_model=$bank_acc_model->find_by_account_nr_and_bank_nr($data->parsed_account_nr, $data->parsed_account_bank_nr);
|
||
if (!$bank_acc_model->id) { // parsovany ucet neexistuje?
|
||
// tak si ho vytvorime
|
||
$acc_model->name="Účet $data->parsed_account_nr/$data->parsed_account_bank_nr";
|
||
$acc_model->member_id=1;
|
||
$enum_type=new Enum_type_Model();
|
||
$enum_type_bank=$enum_type->find_by_value("bank");
|
||
$acc_model->type_id=$enum_type_bank->id;
|
||
$acc_model->save();
|
||
$this->parsed_account=$acc_model;
|
||
$parsed_bank_acc=$parsed_bank_acc->find_by_account_nr_and_bank_nr($data->parsed_account_nr, $data->parsed_account_bank_nr);
|
||
if (!$parsed_bank_acc->id) { // parsovany ucet zatim neexistuje?
|
||
// tak si ho vytvorime
|
||
$parsed_acc->name="Bankovni ucet $data->parsed_account_nr/$data->parsed_account_bank_nr";
|
||
$parsed_acc->member_id=1;
|
||
$parsed_acc->type_id=$bank_acc_enum_id;
|
||
$parsed_acc->save();
|
||
$this->parsed_account=$parsed_acc;
|
||
|
||
$bank_acc_model->account_id=$acc_model->id;
|
||
$bank_acc_model->account_nr=$data->parsed_account_nr;
|
||
$bank_acc_model->bank_nr=$data->parsed_account_bank_nr;
|
||
$bank_acc_model->save();
|
||
$parsed_bank_acc->account_id=$parsed_acc->id;
|
||
$parsed_bank_acc->account_nr=$data->parsed_account_nr;
|
||
$parsed_bank_acc->bank_nr=$data->parsed_account_bank_nr;
|
||
$parsed_bank_acc->save();
|
||
$this->parsed_bank_account=$parsed_bank_acc;
|
||
} else { // parsovany bankovni ucet existuje
|
||
$this->parsed_bank_acc=$parsed_bank_acc;
|
||
$this->parsed_account=$parsed_acc=$parsed_bank_acc->account;
|
||
}
|
||
} else { // if (isset($data->parsed_account_nr) && isset($data->parsed_account_bank_nr
|
||
$this->session->set_flash('message', url_lang::lang('texts.The parsed account is unknown.'));
|
||
return;
|
||
}
|
||
} else { // if (!isset($this->parsed_account)... = parsovany ucet uz zname
|
||
$acc_model=$this->parsed_account;
|
||
$bank_acc_model=$acc_model->bank;
|
||
} else { // if (!isset($this->parsed_account)... = parsovany ucet uz zname, jen si ho ulozim do kratsich promennych :-)
|
||
$parsed_acc=$this->parsed_account;
|
||
$parsed_bank_acc=$this->parsed_bank_account;
|
||
}
|
||
// init the source and destination members and account to "unknown" (objects with empty values)
|
||
// init the source and destination members and account to "unknown" (objects with empty values)
|
||
|
||
// Zkusim najit majitele uctu - uvedl u teto platby jako variabilni symbol (VS) svoje member_id ?
|
||
$acc_owner=new Member_Model($data->variable_symbol);
|
||
if ($acc_owner->id)
|
||
$member_id=$acc_owner->id;
|
||
else // pokud takove member_id v databazi nemame, zkusime, zda jako VS nezadal telefonni cislo
|
||
$member_id=$acc_owner->get_member_by_phone($data->variable_symbol);
|
||
|
||
// Tady si vytvorime instanci uctu clena (nebo dodavatele) z prave nacteneho vypisu:
|
||
|
||
$bank_acc=new Bank_account_Model();
|
||
$bank_acc=$bank_acc->find_by_account_nr_and_bank_nr($data->account_nr, $data->account_bank_nr);
|
||
|
||
if ($bank_acc->id) { // ucet existuje?
|
||
$acc=$bank_acc->account;
|
||
} else { // tak si ho vytvorime
|
||
$acc->name="Bankovni ucet $data->account_nr/$data->account_bank_nr";
|
||
$acc->member_id=$member_id;
|
||
$acc->type_id=$bank_acc_enum_id;
|
||
$acc->save();
|
||
|
||
$bank_acc->account_id=$acc->id;
|
||
$bank_acc->account_nr=$data->account_nr;
|
||
$bank_acc->bank_nr=$data->account_bank_nr;
|
||
$bank_acc->save();
|
||
}
|
||
|
||
|
||
$dst_member=$src_member=new Member_Model();
|
||
$dst_account=$src_account=new Account_Model(); // double-entry accounts
|
||
$src_bank_account=new Bank_account_Model();
|
||
... | ... | |
echo"parse - start: ".($start=microtime(true))."<p>\n";
|
||
|
||
//$parser->set_callback(array($this, "print_row"));
|
||
$parser->set_callback(array($this, "store_transfer"));
|
||
$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($account_id)) $this->parsed_account=new Account_Model($account_id);
|
||
if (isset($account_id)) {
|
||
$this->parsed_account=new Account_Model($account_id);
|
||
$this->parsed_bank_account = $this->parsed_account->find_related_bank_account();
|
||
}
|
||
|
||
//print_r ($parser);
|
||
echo "<table border=1>\n";
|
Také k dispozici: Unified diff
Ulozena rozdelana prace v accounts, at muzu jit na WC :-)