Location: PHPKode > projects > JACR - Just Another Checkbook Register > jacr_0.0.4/jacr-platform/jacr_account.class.php
<?php
require_once('DBConn/table.class.php');

class Jacr_account extends DBTable
{
	protected $accountID;
	var $Transactions;
  public function __construct($accountID=0)
  {
	 
	global $dbname, $dbTablPre, $installMode;
    $this->tablename       =  $dbTablPre.'accounts';
    $this->dbname          = $dbname;
    $this->rows_per_page   = 0;
    
    $this->fieldlist = array(
							 'id' => 				array('int(10) unsigned ', 'NOT NULL', NULL, 'auto_increment'),
							 'currency_id' =>		array( 'int(10) unsigned ', 'NULL', 'NULL', NULL),
							 'title' =>			array('varchar(100)', 'NOT NULL', '\'Account\'', NULL),
							 'description' =>		array('text', NULL, NULL, NULL),
							 'lower_limit' =>		array( 'decimal(20,2)', 'NULL', 'NULL',  NULL),
							 'upper_limit' =>		array( 'decimal(20,2)', 'NULL', 'NULL',  NULL),
							 'last_calc_date' =>	array('date',  'NOT NULL', '\'1000-01-01\'', NULL)
							 );
    $this->pKEY='id';
	if($installMode!=true)
		$this->setAccount($accountID);
  } 	
  
  public function setAccount($accountID){
	  
		#echo "<h1> $accountID </h1>";
	if ($accountID > 0){
		$this->accountID = $accountID;
	  	$this->accountInfo=$this->getRecord($this->accountID);
		return true;
	}
	else{
		$this->accountID = NULL;
		return false;
	}  
  }
  
  public function sellectAccount(){
	  echo '<div id="addNewAccountBox" class="jqmWindow">';
		$this->newAccountForm();
	  echo '
	  </div>
	  <a href="#" id="NewAccountTrigger">Add Account</a>
	  <script type="text/javascript">
	  $().ready(function() {
  		$(\'#addNewAccountBox\').jqm({trigger: \'a#NewAccountTrigger\'});
		})
	  </script>
	  <fieldset><legend>Choose an Account:</legend>
	  <ul>';
	  $list = $this->getData();
	  foreach ($list as $account){
		  echo '<li><span><a href="?a='.$account['id'].'">' .$account['title']. '</a></span></li>';
	  }
	  echo '
	  </ul>
	  </fieldset>';
	  return true;
  }
  
  public function showAccount(){
	  $this->Transactions = new Jacr_transaction($this->accountID);
	  $this->Transactions->showTransactions();	  
  }
  public function newAccountForm()
  {
	  if ( isset( $_POST['addnew'] ) )
		$this->insertRecord( Array( 'title'=> $_POST['title'] ) );
	  echo '
		<fieldset><legend>Create a New Account:</legend>
			<form id="addaccount" action="" method="post">
				<input type="text" name="title" />
				<input type="submit" name="addnew" value="Add New Account" />
			</form>
		</fieldset>';
  }
}
		
?>
Return current item: JACR - Just Another Checkbook Register