Revize 1681
Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)
freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha1.php | ||
---|---|---|
<?php defined('SYSPATH') or die('No direct script access.');
|
||
/*
|
||
* This file is part of open source system FreenetIS
|
||
* and it is released under GPLv3 licence.
|
||
*
|
||
* More info about licence can be found:
|
||
* http://www.gnu.org/licenses/gpl-3.0.html
|
||
*
|
||
* More info about project can be found:
|
||
* http://www.freenetis.org/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* Add message for accepted payments.
|
||
*
|
||
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
|
||
*/
|
||
$upgrade_sql['1.1.0~alpha1'] = array
|
||
(
|
||
// insert new message type
|
||
"INSERT INTO `messages` (`id`, `name`, `text`, `email_text`, `sms_text`, `type`, `self_cancel`, `ignore_whitelist`) VALUES
|
||
(NULL, 'Received payment notice', NULL,
|
||
'Hello {name},<br /><br />Your payment has been accepted into FreenetIS.<br/>Your current balance is: {balance},-',
|
||
'Your payment has been accepted into FreenetIS. Your current balance is: {balance},-',
|
||
8, NULL, 0);"
|
||
);
|
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'email already exists in database' => 'E-mail je již v databázi',
|
||
'e-mail from' => 'E-mail Od',
|
||
'e-mail to' => 'E-mail Komu',
|
||
'empty' => 'Prázdný',
|
||
'empty input' => 'Prázdný vstup',
|
||
'email address' => 'emailová adresa',
|
||
'e-mail "%s" has been sent for %d e-mail addresses' => 'E-mail "%s" byl odeslán pro %d e-mailových adres.',
|
||
... | ... | |
'received member fees' => 'Přijaté členské příspěvky',
|
||
'received' => 'Přijatá',
|
||
'received message' => 'Přijatá zpráva',
|
||
'received payment notice' => 'Oznámení o přijaté platbě',
|
||
'receiver' => 'Příjemce',
|
||
'receiver type' => 'Typ příjemce',
|
||
'recount of device repayments' => 'Přepočítání splátek zařízení',
|
||
... | ... | |
'section' => 'Sekce',
|
||
'sectional' => 'sektorová',
|
||
'send' => 'Odeslat',
|
||
'send e-mail notice about received payment to member' => 'Odeslat členovi e-mailovou zprávu s oznámením o jeho přijaté platbě',
|
||
'send mail warning to users related with invoice' => 'Odeslat upozornění uživatelům spojených s fakturou',
|
||
'send message' => 'Odeslat zprávu',
|
||
'send sms notice about received payment to member' => 'Odeslat členovi SMS zprávu s oznámením o jeho přijaté platbě',
|
||
'select' => 'Vyber',
|
||
'select account type' => 'Vyber typ účtu',
|
||
'select action' => 'Vyber činnost',
|
freenetis/branches/1.1/application/helpers/callback.php | ||
---|---|---|
|
||
if ($message->type == Message_Model::CONTACT_INFORMATION ||
|
||
$message->type == Message_Model::CANCEL_MESSAGE ||
|
||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE)
|
||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE ||
|
||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
|
||
{
|
||
echo ' ';
|
||
}
|
||
... | ... | |
|
||
if ($message->type == Message_Model::CONTACT_INFORMATION ||
|
||
$message->type == Message_Model::CANCEL_MESSAGE ||
|
||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE)
|
||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE ||
|
||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
|
||
{
|
||
echo ' ';
|
||
}
|
||
... | ... | |
{
|
||
$message = new Message_Model($item->id);
|
||
|
||
echo html::anchor(
|
||
url::base().'redirection/?id='.$message->id,
|
||
__('Preview'), array('target' => '_blank')
|
||
);
|
||
if (empty($message->text))
|
||
{
|
||
echo '<span class="red">' . __('Empty') . '</span>';
|
||
}
|
||
else
|
||
{
|
||
echo html::anchor(
|
||
url::base().'redirection/?id='.$message->id,
|
||
__('Preview'), array('target' => '_blank')
|
||
);
|
||
}
|
||
}
|
||
|
||
/**
|
freenetis/branches/1.1/application/models/message.php | ||
---|---|---|
*/
|
||
const UNALLOWED_CONNECTING_PLACE_MESSAGE = 7;
|
||
|
||
/**
|
||
* content of page for unallowed connecting place, depends on allowed subnets
|
||
*/
|
||
const RECEIVED_PAYMENT_NOTICE_MESSAGE = 8;
|
||
|
||
// self-cancel constants
|
||
|
||
/**
|
||
... | ... | |
// return stats array
|
||
return $s;
|
||
}
|
||
|
||
/**
|
||
* Activates accept payment notice to given member
|
||
*
|
||
* @author Ondřej Fibich
|
||
* @param integer $member_id who payed
|
||
* @param integer $user_id Who redirects
|
||
* @param integer $email E-mail state
|
||
* @param integer $sms SMS state
|
||
* @return boolean Notiication made?
|
||
*/
|
||
public static function activate_received_payment_message($member_id, $user_id, $email, $sms)
|
||
{
|
||
// preparation
|
||
$message = ORM::factory('message')->where(array
|
||
(
|
||
'type' => self::RECEIVED_PAYMENT_NOTICE_MESSAGE
|
||
))->find();
|
||
|
||
$uc_model = new Users_contacts_Model();
|
||
|
||
// message do not exists
|
||
if (!$message || !$message->id)
|
||
{
|
||
Log::add('error', 'Payment accepted notice message not exists in messages table');
|
||
return false;
|
||
}
|
||
|
||
// send emails
|
||
if ($email == Notifications_Controller::ACTIVATE)
|
||
{
|
||
// find email addresses of debtors
|
||
$emails = $uc_model->get_contacts_by_member_and_type(
|
||
$member_id, Contact_Model::TYPE_EMAIL, $message->ignore_whitelist
|
||
);
|
||
// send emails for finded emails
|
||
self::send_emails($message, $emails);
|
||
}
|
||
|
||
// send SMS messages
|
||
if ($sms == Notifications_Controller::ACTIVATE)
|
||
{
|
||
// find phone numbers of debtors
|
||
$smss = $uc_model->get_contacts_by_member_and_type(
|
||
$member_id, Contact_Model::TYPE_PHONE, $message->ignore_whitelist
|
||
);
|
||
// send SMS messages for finded phone numbers
|
||
self::send_sms_messages($message, $smss, $user_id);
|
||
}
|
||
|
||
// return stats array
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* Deactivates all redirections of given message.
|
freenetis/branches/1.1/application/controllers/messages.php | ||
---|---|---|
->callback('callback::message_type_field');
|
||
|
||
$grid->callback_field('self_cancel')
|
||
->label(__('sc').' '.help::hint('self_cancel'))
|
||
->label(__('SC').' '.help::hint('self_cancel'))
|
||
->callback('callback::message_self_cancel_field');
|
||
|
||
$grid->callback_field('ignore_whitelist')
|
||
->label(__('iw').' '.help::hint('ignore_whitelist'))
|
||
->label(__('IW').' '.help::hint('ignore_whitelist'))
|
||
->callback('callback::boolean');
|
||
|
||
$grid->callback_field('id')
|
||
... | ... | |
->selected($message->ignore_whitelist);
|
||
}
|
||
|
||
$form->html_textarea('text')
|
||
->label(__('Content of the message for redirection').': '.
|
||
help::hint('content_of_message'))
|
||
->rows(5)
|
||
->cols(100)
|
||
->value($message->text);
|
||
if ($message->type != Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
|
||
{
|
||
$form->html_textarea('text')
|
||
->label(__('Content of the message for redirection').': '.
|
||
help::hint('content_of_message'))
|
||
->rows(5)
|
||
->cols(100)
|
||
->value($message->text);
|
||
}
|
||
|
||
if ($message->type == Message_Model::USER_MESSAGE ||
|
||
$message->type == Message_Model::DEBTOR_MESSAGE ||
|
||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE)
|
||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE ||
|
||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
|
||
{
|
||
$form->html_textarea('email_text')
|
||
->label(__('Content of the message for E-mail').': '.
|
||
... | ... | |
$message->self_cancel = htmlspecialchars($form_data['self_cancel']);
|
||
$message->ignore_whitelist = htmlspecialchars($form_data['ignore_whitelist']);
|
||
}
|
||
$message->text = $form_data['text'];
|
||
|
||
if ($message->type != Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
|
||
{
|
||
$message->text = $form_data['text'];
|
||
}
|
||
|
||
if ($message->type == Message_Model::USER_MESSAGE ||
|
||
$message->type == Message_Model::DEBTOR_MESSAGE ||
|
||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE)
|
||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE ||
|
||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
|
||
{
|
||
// email text
|
||
$email_text = trim($form_data['email_text']);
|
freenetis/branches/1.1/application/controllers/import.php | ||
---|---|---|
->label(__('Clean temporary whitelist').' '.help::hint('clean_temp_whitelist'))
|
||
->checked('checked');
|
||
|
||
$form->checkbox('send_email_notice')
|
||
->value('1')
|
||
->label('Send e-mail notice about received payment to member')
|
||
->checked('checked');
|
||
|
||
$form->checkbox('send_sms_notice')
|
||
->value('1')
|
||
->label('Send SMS notice about received payment to member');
|
||
|
||
$form->submit('Submit');
|
||
|
||
// validation
|
||
... | ... | |
switch ($form_data['type'])
|
||
{
|
||
case self::HTML_RAIFFEISENBANK:
|
||
$this->parse_ebank_account($id, $form->listing->value, $form_data['clean_whitelist']);
|
||
$this->import_ebank(
|
||
$id, $form->listing->value,
|
||
$form_data['clean_whitelist'],
|
||
@$form_data['send_email_notice'] == 1,
|
||
@$form_data['send_sms_notice'] == 1
|
||
);
|
||
break;
|
||
case self::CSV_FIO:
|
||
$this->import_fio($id, $form->listing->value, $form_data['clean_whitelist']);
|
||
$this->import_fio(
|
||
$id, $form->listing->value,
|
||
$form_data['clean_whitelist'],
|
||
@$form_data['send_email_notice'] == 1,
|
||
@$form_data['send_sms_notice'] == 1
|
||
);
|
||
break;
|
||
default:
|
||
break;
|
||
... | ... | |
* @author Jiri Svitak
|
||
* @param string $file_url
|
||
*/
|
||
private function import_fio($bank_account_id, $file_url, $clean_whitelist)
|
||
private function import_fio(
|
||
$bank_account_id, $file_url, $clean_whitelist,
|
||
$send_emails, $send_sms)
|
||
{
|
||
try
|
||
{
|
||
... | ... | |
// save bank listing items
|
||
$stats = FioSaver::save(
|
||
$data, $bank_account_id, $statement->id,
|
||
$this->session->get('user_id')
|
||
$this->session->get('user_id'),
|
||
$send_emails, $send_sms
|
||
);
|
||
|
||
// clean temporary whitelist, members should have payed, now
|
||
... | ... | |
* @param integer $account_id ID of the account whose data will be parsed.
|
||
* @param string $url URL containing the file to parse
|
||
*/
|
||
private function parse_ebank_account($bank_account_id, $url, $clean_whitelist)
|
||
private function import_ebank(
|
||
$bank_account_id, $url, $clean_whitelist,
|
||
$send_emails, $send_sms)
|
||
{
|
||
try
|
||
{
|
||
$db = new Transfer_Model();
|
||
$db->transaction_start();
|
||
|
||
$parser = new Parser_Ebanka();
|
||
$parser = new Parser_Ebanka($send_emails, $send_sms);
|
||
if (isset($bank_account_id))
|
||
{
|
||
$ba = new Bank_account_Model($bank_account_id);
|
freenetis/branches/1.1/application/libraries/importers/Raiffeisenbank/Parser_Ebanka.php | ||
---|---|---|
* @var object
|
||
*/
|
||
protected $result;
|
||
|
||
/**
|
||
* Send SMS notification of received payments
|
||
*
|
||
* @since 1.1
|
||
* @var integer
|
||
*/
|
||
protected $send_sms = Notifications_Controller::KEEP;
|
||
|
||
/**
|
||
* Send e-mail notification of received payments
|
||
*
|
||
* @since 1.1
|
||
* @var integer
|
||
*/
|
||
protected $send_emails = Notifications_Controller::KEEP;
|
||
|
||
/**
|
||
* Construct
|
||
*
|
||
* @param boolean $send_emails Send e-mail notification of received payments?
|
||
* @param boolean $send_sms Send SMS notification of received payments?
|
||
*/
|
||
public function __construct($send_emails, $send_sms)
|
||
{
|
||
if ($send_emails)
|
||
{
|
||
$this->send_emails = Notifications_Controller::ACTIVATE;
|
||
}
|
||
|
||
if ($send_sms)
|
||
{
|
||
$this->send_sms = Notifications_Controller::ACTIVATE;
|
||
}
|
||
}
|
||
|
||
/**
|
||
*
|
||
... | ... | |
//ted uz muzeme ulozit ziskane data do databaze:
|
||
//if (isset($this->callback))
|
||
// call_user_func($this->callback, $res);
|
||
$rb_importer->store_transfer_ebanka($res);
|
||
$rb_importer->store_transfer_ebanka(
|
||
$res, $this->send_emails, $this->send_sms
|
||
);
|
||
|
||
break;
|
||
} // switch
|
||
... | ... | |
case 6: // fee
|
||
$res->fee = $this->get_fee($field, FALSE);
|
||
//if (isset($this->callback)) call_user_func($this->callback, $res);
|
||
$rb_importer->store_transfer_ebanka($res);
|
||
$rb_importer->store_transfer_ebanka(
|
||
$res, $this->send_emails, $this->send_sms
|
||
);
|
||
/**
|
||
* ted uz muzeme ulozit ziskane data do databaze:
|
||
*/
|
freenetis/branches/1.1/application/libraries/importers/Raiffeisenbank/RB_Importer.php | ||
---|---|---|
* specific_symbol => 9876543210
|
||
* amount => 720.00
|
||
* fee => -6.90
|
||
* @param integer $notification_email State of e-mail notification
|
||
* @param integer $notification_sms State of SMS notification
|
||
*
|
||
*/
|
||
public function store_transfer_ebanka($data = null)
|
||
public function store_transfer_ebanka(
|
||
$data = null, $notification_email = Notifications_Controller::KEEP,
|
||
$notification_sms = Notifications_Controller::KEEP)
|
||
{
|
||
// param check
|
||
if (!$data || !is_object($data))
|
||
... | ... | |
$member->id, $id
|
||
);
|
||
}
|
||
|
||
/**
|
||
* Send information about received payment to member
|
||
*
|
||
* @author Ondřej Fibich
|
||
* @since 1.1
|
||
*/
|
||
try
|
||
{
|
||
Message_Model::activate_accepted_payment_message(
|
||
$member->id, self::$user_id,
|
||
$notification_email, $notification_sms
|
||
);
|
||
}
|
||
catch (Exception $e)
|
||
{
|
||
Log::add_exception($e);
|
||
}
|
||
} // if (is_object($member) && $member->id)
|
||
$this->stats->member_fees_nr++;
|
||
$this->stats->member_fees+=$data->amount;
|
freenetis/branches/1.1/application/libraries/importers/Fio/FioSaver.php | ||
---|---|---|
* @param integer $bank_account_id
|
||
* @param integer $bank_statement_id
|
||
* @param integer $user_id
|
||
* @param boolean $send_emails
|
||
* @param boolean $send_sms
|
||
* @return array Stats
|
||
*/
|
||
public static function save($data, $bank_account_id, $bank_statement_id, $user_id)
|
||
public static function save(
|
||
$data, $bank_account_id, $bank_statement_id, $user_id,
|
||
$send_emails, $send_sms)
|
||
{
|
||
if ($send_emails)
|
||
{
|
||
$send_emails = Notifications_Controller::ACTIVATE;
|
||
}
|
||
else
|
||
{
|
||
$send_emails = Notifications_Controller::KEEP;
|
||
}
|
||
|
||
if ($send_sms)
|
||
{
|
||
$send_sms = Notifications_Controller::ACTIVATE;
|
||
}
|
||
else
|
||
{
|
||
$send_sms = Notifications_Controller::KEEP;
|
||
}
|
||
|
||
// preparation of system double-entry accounts
|
||
$suppliers = ORM::factory('account')
|
||
->where('account_attribute_id', Account_attribute_Model::SUPPLIERS)
|
||
... | ... | |
}
|
||
$counter_ba->member_id = $member_id;
|
||
$counter_ba->save_throwable();
|
||
|
||
/**
|
||
* Send information about received payment to member
|
||
*
|
||
* @author Ondřej Fibich
|
||
* @since 1.1
|
||
*/
|
||
try
|
||
{
|
||
Message_Model::activate_accepted_payment_message(
|
||
$member->id, $user_id,
|
||
$send_emails, $send_sms
|
||
);
|
||
}
|
||
catch (Exception $e)
|
||
{
|
||
Log::add_exception($e);
|
||
}
|
||
}
|
||
// member fee stats
|
||
$stats["member_fees"] += abs($item["castka"]);
|
freenetis/branches/1.1/version.php | ||
---|---|---|
* The current version of FreenetIS.
|
||
* This value must be changed by developers in a new release of FreenetIS.
|
||
*/
|
||
define('FREENETIS_VERSION', '1.0.0');
|
||
define('FREENETIS_VERSION', '1.1.0~alpha1');
|
Také k dispozici: Unified diff
Vydani:
- freenetis 1.1.0~alpha1
Novinky:
- #17: upozorneni na prijatou platbu