Skip to content

Commit

Permalink
Edit format
Browse files Browse the repository at this point in the history
  • Loading branch information
hadimansouri committed Nov 8, 2018
1 parent c6fbdc6 commit 0ce5d1f
Show file tree
Hide file tree
Showing 2 changed files with 260 additions and 265 deletions.
208 changes: 104 additions & 104 deletions src/Bank/Receipt.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of Pluf Framework, a simple PHP Application Framework.
* Copyright (C) 2010-2020 Phoinex Scholars Co. (http://dpq.co.ir)
Expand All @@ -19,16 +20,16 @@

/**
* ساختارهای داده‌ای برای رسید را ایجاد می‌کند.
*
* رسید عبارت است از یک مجموعه از داده‌ها که برای پرداخت به بانک ارسال
*
* رسید عبارت است از یک مجموعه از داده‌ها که برای پرداخت به بانک ارسال
* می‌شود. این رسید زمانی که بانک تایید کند به روز شده و اطلاعات دریافتی
* از بانک نیز به آن اضافه می شود.
*
*
* از رسید در کارهای متفاوتی می‌توان استفاده کرد. برای نمونه پرداخت‌هایی
* که برای خرید یک کالا توسط یک فرد انجام می‌شود در ساختار رسید قرار می‌گیرد.
*
* @author maso
*
* @author maso
*
*/
class Bank_Receipt extends Pluf_Model
{
Expand All @@ -38,107 +39,108 @@ class Bank_Receipt extends Pluf_Model
public $touched = false;

/**
*
* @brief مدل داده‌ای را بارگذاری می‌کند.
*
* تمام فیلدهای مورد نیاز برای این مدل داده‌ای در این متد تعیین شده و به
* صورت کامل ساختار دهی می‌شود.
*
* @see Pluf_Model::init()
*/
function init ()
function init()
{
$this->_a['table'] = 'bank_receipt';
$this->_a['cols'] = array (
/*
* داده‌های عمومی برای یک پرداخت
*/
'id' => array(
'type' => 'Pluf_DB_Field_Sequence',
'blank' => true
),
'secure_id' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 64
),
'amount' => array(
'type' => 'Pluf_DB_Field_Integer',
'blank' => false,
'unique' => false
),
'title' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 50
),
'description' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
'email' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 100
),
'phone' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 100
),
// مسیر را تعیین می‌کند که بعد از تکمیل باید فراخوانی شود
'callbackURL' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
'payRef' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
// مسیری رو تعیین می‌کنه که برای تکمیل خرید باید دنبال کنیم
'callURL' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
'payMeta' => array(
'type' => 'Pluf_DB_Field_Text',
'blank' => false
),
'backend' => array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Bank_Backend',
'blank' => false,
'relate_name' => 'backend'
),
/*
* مالک این پرداخت را تعیین می‌کند. این مالک می‌تواند هر موجودیتی در
* سیستم باشد.
*/
'owner_id' => array(
'type' => 'Pluf_DB_Field_Integer',
'blank' => false,
'verbose' => 'owner ID'
),
'owner_class' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 50
),
'creation_dtime' => array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => 'creation date'
),
'modif_dtime' => array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => 'modification date'
)
'type' => 'Pluf_DB_Field_Sequence',
'blank' => true
),
'secure_id' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 64
),
'amount' => array(
'type' => 'Pluf_DB_Field_Integer',
'blank' => false,
'unique' => false
),
'title' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 50
),
'description' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
'email' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 100
),
'phone' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 100
),
// مسیر را تعیین می‌کند که بعد از تکمیل باید فراخوانی شود
'callbackURL' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),

'payRef' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
// مسیری رو تعیین می‌کنه که برای تکمیل خرید باید دنبال کنیم
'callURL' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => true,
'size' => 200
),
'payMeta' => array(
'type' => 'Pluf_DB_Field_Text',
'blank' => false
),
'backend' => array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Bank_Backend',
'blank' => false,
'relate_name' => 'backend'
),
/*
* مالک این پرداخت را تعیین می‌کند. این مالک می‌تواند هر موجودیتی در
* سیستم باشد.
*/
'owner_id' => array(
'type' => 'Pluf_DB_Field_Integer',
'blank' => false,
'verbose' => 'owner ID'
),
'owner_class' => array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 50
),

'creation_dtime' => array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => 'creation date'
),
'modif_dtime' => array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => 'modification date'
)
);
$this->_a['views'] = array();
}
Expand All @@ -154,7 +156,7 @@ function init ()
* @param $create boolean
* if is true then the new object will be created
*/
function preSave ($create = false)
function preSave($create = false)
{
$this->payMeta = serialize($this->data);
if ($this->id == '') {
Expand All @@ -168,12 +170,10 @@ function preSave ($create = false)
*
* @see Pluf_Model::postSave()
*/
function postSave ($create = false)
function postSave($create = false)
{
if (! is_null($this->callbackURL) &&
strpos($this->callbackURL, '{secure_id}')) {
$this->callbackURL = str_replace('{secure_id}', $this->secure_id,
$this->callbackURL);
if (! is_null($this->callbackURL) && strpos($this->callbackURL, '{secure_id}')) {
$this->callbackURL = str_replace('{secure_id}', $this->secure_id, $this->callbackURL);
$this->update();
}
}
Expand All @@ -183,7 +183,7 @@ function postSave ($create = false)
*
* تمام داده‌هایی که با کلید payMeta ذخیره شده را بازیابی می‌کند.
*/
function restore ()
function restore()
{
$this->data = unserialize($this->payMeta);
}
Expand All @@ -193,7 +193,7 @@ function restore ()
*
* تمام داده‌های ذخیره شده در نشست را پاک می‌کند.
*/
function clear ()
function clear()
{
$this->data = array();
$this->touched = true;
Expand All @@ -212,7 +212,7 @@ function clear ()
* داده مورد نظر. در صورتی که مقدار آن تهی باشد به معنی
* حذف است.
*/
function setMeta ($key, $value = null)
function setMeta($key, $value = null)
{
if (is_null($value)) {
unset($this->data[$key]);
Expand All @@ -229,7 +229,7 @@ function setMeta ($key, $value = null)
* این فراخوانی
* برگردانده خواهد شد.
*/
function getMeta ($key = null, $default = '')
function getMeta($key = null, $default = '')
{
if (is_null($key)) {
return parent::getData();
Expand All @@ -249,8 +249,8 @@ function getMeta ($key = null, $default = '')
*
* @return boolean
*/
function isPayed ()
function isPayed()
{
return !is_null($this->payRef) && (strlen($this->payRef) > 0);
return ! is_null($this->payRef) && (strlen($this->payRef) > 0);
}
}

0 comments on commit 0ce5d1f

Please sign in to comment.