~katiekitty/+junk/solidstate

« back to all changes in this revision

Viewing changes to solidstate/branches/v0.5 Alpha/widgets/PurchasableTermSelectWidget.class.php

  • Committer: root
  • Date: 2010-01-13 07:44:31 UTC
  • Revision ID: root@ds3-vamp.cs-monitor.cz.cc-20100113074431-kt8ceoeznpjg22x7
Reviving the project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * PurchasableTermSelectWidget.class.php
 
4
 *
 
5
 * This file contains the definition of the PurchasableTermSelectWidget class.  
 
6
 *
 
7
 * @package SolidWorks
 
8
 * @author John Diamond <jdiamond@solid-state.org>
 
9
 * @copyright John Diamond <jdiamond@solid-state.org>
 
10
 * @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
 
11
 */
 
12
 
 
13
/**
 
14
 * PurchasableTermSelectWidget
 
15
 *
 
16
 * @package SolidWorks
 
17
 * @author John Diamond <jdiamond@solid-state.org>
 
18
 */
 
19
class PurchasableTermSelectWidget extends SelectWidget
 
20
{
 
21
  /**
 
22
   * @var PurchasableDBO The Purchasable to display terms for
 
23
   */
 
24
  protected $purchasable = null;
 
25
 
 
26
  /**
 
27
   * Get Data
 
28
   *
 
29
   * @param array $config Field configuration
 
30
   * @return array value => description
 
31
   */
 
32
  function getData()
 
33
  {
 
34
    global $conf;
 
35
    $cs = $conf['locale']['currency_symbol'];
 
36
 
 
37
    $terms = array();
 
38
    foreach( $this->purchasable->getPricing( "Recurring" ) as $price )
 
39
      {
 
40
        $terms[$price->getID()] =
 
41
          sprintf( "%d [MONTHS] - %s%01.2f", 
 
42
                   $price->getTermLength(), 
 
43
                   $cs, 
 
44
                   $price->getPrice() );
 
45
 
 
46
      }
 
47
 
 
48
    return $terms;
 
49
  }
 
50
 
 
51
  /**
 
52
   * Set Purchasable DBO
 
53
   *
 
54
   * @param PurchasableDBO The purchasable to display terms for
 
55
   */
 
56
  function setPurchasable( PurchasableDBO $purchasable ) 
 
57
  { 
 
58
    $this->purchasable = $purchasable; 
 
59
  }
 
60
}
 
61
?>
 
 
b'\\ No newline at end of file'