[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [websites/jointhegame-kde-org] protected: estimate paymets feature
From:       Emil Sedgh <emilsedgh () kde ! org>
Date:       2011-10-20 9:11:16
Message-ID: 20111020091116.0CA8DA60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 448cbeb8c93ac1bd015097da22d396706bce6a30 by Emil Sedgh.
Committed on 20/10/2011 at 11:09.
Pushed by esedgh into branch 'master'.

estimate paymets feature

M  +12   -1    protected/controllers/PaymentController.php
M  +4    -0    protected/models/Member.php
M  +4    -0    protected/views/payment/admin.php
A  +50   -0    protected/views/payment/estimate.php

http://commits.kde.org/websites/jointhegame-kde-org/448cbeb8c93ac1bd015097da22d396706bce6a30


diff --git a/protected/controllers/PaymentController.php \
b/protected/controllers/PaymentController.php index f5a9221..e7ad3e9 100644
--- a/protected/controllers/PaymentController.php
+++ b/protected/controllers/PaymentController.php
@@ -4,7 +4,7 @@ Class PaymentController Extends Controller {
 		return Array(
 			array(
 				'allow',
-				'actions' => array('admin', 'create', 'update', 'delete'),
+				'actions' => array('admin', 'create', 'update', 'delete', 'estimate'),
 				'roles' => array('admin')
 			),
 
@@ -66,4 +66,15 @@ Class PaymentController Extends Controller {
 		$payment = Payment::model()->findByPK($_GET['id']);
 		$payment->delete();
 	}
+
+	public function actionEstimate() {
+		if($_GET['date']) {
+			$members = Member::model()->findAll(Array(
+				'condition' => 'number > 0'
+			));
+		} else
+			$members = Array();
+
+		$this->render('estimate', Array('members' => $members, 'date' => $_GET['date']));
+	}
 }
\ No newline at end of file
diff --git a/protected/models/Member.php b/protected/models/Member.php
index 63053d3..392a25d 100644
--- a/protected/models/Member.php
+++ b/protected/models/Member.php
@@ -122,4 +122,8 @@ Class Member Extends CActiveRecord {
 
 		return time() + ((Int)($remainingAmount / $dailyAverage)*86400);
 	}
+
+	public function getLastPaymentAmount() {
+		return $this->lastPayment->amount;
+	}
 }
\ No newline at end of file
diff --git a/protected/views/payment/admin.php b/protected/views/payment/admin.php
index c31a41d..61b23e2 100644
--- a/protected/views/payment/admin.php
+++ b/protected/views/payment/admin.php
@@ -5,6 +5,10 @@
 <a href="<?php echo Controller::createUrl('/paypal/recurringprofiles');?>">
 	<?php echo Yii::t('payment', 'View all automatic payments');?>
 </a>
+<br />
+<a href="<?php echo Controller::createUrl('/payment/estimate');?>">
+	<?php echo Yii::t('payment', 'Estimate payments');?>
+</a>
 <hr />
 <br />
 
diff --git a/protected/views/payment/estimate.php \
b/protected/views/payment/estimate.php new file mode 100644
index 0000000..7f306df
--- /dev/null
+++ b/protected/views/payment/estimate.php
@@ -0,0 +1,50 @@
+<?php
+echo CHtml::label(Yii::t('payment', 'Please select a date'), 'date');
+
+$this->beginWidget('CActiveForm', array('method' => 'get'));
+	$this->widget('zii.widgets.jui.CJuiDatePicker', Array(
+		'id' => 'date',
+		'name' => 'date',
+		'value' => $date
+	));
+
+	echo CHtml::submitButton();
+$this->endWidget();
+
+if($members) {
+	$total = 0;
+	$expectedToPay = Array();
+
+	foreach($members as $member) {
+		if(($member->nextPaymentDate > time()) && ($member->nextPaymentDate < $date)) {
+			$total += $member->lastPaymentAmount;
+			$expectedToPay[] = $member;
+		}
+	}
+
+	echo '<br /><h1>'.Yii::t('payment', 'We estimate :amount euros to be payed by \
:date. Below, is a detailed list of expected payments.', Array( +		':amount' => \
Yii::app()->format->formatNumber($total), +		':date' => \
Yii::app()->format->formatDate(strtotime($date)) +	)).'</h1><br />';
+
+	if(!$columns) {
+		$columns = Array(
+			'fullName',
+			'nextPaymentDate:date',
+			'lastPaymentAmount:number'
+		);
+	}
+
+	$this->widget('zii.widgets.grid.CGridView', array(
+		'cssFile' => False,
+		'dataProvider' => New CArrayDataProvider($expectedToPay, Array(
+			'pagination' => False,
+			'sort' => Array(
+				'attributes' => array('fullName', 'nextPaymentDate', 'lastPaymentAmount'),
+				'defaultOrder' => 'nextPaymentDate'
+			)
+
+		)),
+		'columns' => $columns
+	));
+}
\ No newline at end of file


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic