// Create checks
$check = new SI_Check();
foreach ($checks as $number => $data) {
    if ($number == 0) {
        continue;
    }
    //	debug("Going to create check $number for amount ".$data['amount']." with ids ".join(', ', $data['ids']));
    $check->user_id = $data['user_id'];
    $check->number = $number;
    $check->timestamp = $data['timestamp'];
    $check->amount = $data['amount'];
    $check->type = 'CHECK';
    $check->name = $users[$data['user_id']]['first_name'] . ' ' . $users[$data['user_id']]['last_name'];
    $check->address1 = $users[$data['user_id']]['address1'];
    $check->address2 = $users[$data['user_id']]['address2'];
    $check->city = $users[$data['user_id']]['city'];
    $check->state = $users[$data['user_id']]['state'];
    $check->zip = $users[$data['user_id']]['zip'];
    assert_die($check->add(), "Error adding check: " . $check->getLastError());
    assert_die($check->attachCostTransactions($data['ids']), "Error adding cost transactions to check: " . $check->getLastError());
    // Add user transaction
    $ut = new SI_UserTransaction();
    $ut->amount = -$check->amount;
    $ut->description = "Check #" . $check->number;
    $ut->timestamp = $check->timestamp;
    $ut->user_id = $check->user_id;
    assert_die($ut->add(), "Error adding user transaction: " . $ut->getLastError());
    // Update check trans id
    $check->trans_id = $ut->id;
    assert_die($check->update(), "Error updating transaction id for check: " . $check->getLastError());
}
示例#2
0
	function getChecks($id = NULL, $limit = 0, $offset = 0){
		global $db_conn;

		if($id === NULL){
			$id = intval($this->id);
		}else{
			$id = intval($id);
		}

		$limit_sql = '';		
		if($limit > 0 || $offset > 0){
			$limit_sql = " LIMIT $offset, $limit ";
		}

		$check = new SI_Check();
		$result = $check->retrieveSet("WHERE user_id = $id $limit_sql");
		if($result === FALSE){
			$this->error = "SI_User::getChecks(): Error getting checks: ".$check->getLastError();
			return FALSE;
		}

		return $result;
	}
示例#3
0
	}

	foreach($commissions as $com){
		if(in_array($com->com_trans_id, $comm_trans_ids)){
			$total_amount += $com->com_amount;
		}
	}

	if(empty($error_msg)){
		$check->updateFromAssocArray($_POST);
		$check->timestamp = time();
		$check->amount = $total_amount;
		if($check->add() !== FALSE){
			if($check->attachCostTransactions($cost_trans_ids) === FALSE){
				$error_msg .= "Error adding cost transactions to check!";
				debug_message($check->getLastError());
			}

			if($check->attachCommTransactions($comm_trans_ids) === FALSE){
				$error_msg .= "Error adding commission transactions to check!";
				debug_message($check->getLastError());
			}

			// Add user transaction
			if($check->type == 'CHECK'){
				$desc = "Check #".$check->number;
			}elseif($check->type == "EFT"){
				$desc = "Electronic Funds Transfer";
			}
			$ut = new SI_UserTransaction();
			$ut->amount = -$total_amount;
	function _getLinked(){
		$id = intval($this->id);
		if($id <= 0)
			return TRUE;
			
		if($this->_ta == FALSE){
			$ta = new SI_TaskActivity();
			$tas = $ta->retrieveSet("WHERE a.cost_trans_id = $id OR a.com_trans_id = $id");
			if($tas === FALSE){
				$this->error = "Error getting linked task: ".$ta->getLastError();
				return FALSE;	
			}
			if(count($tas) == 1){
				$this->_ta = &$tas[0];
			}
		}
		
		if($this->_check == FALSE){
			$check = new SI_Check();
			$checks = $check->retrieveSet("WHERE trans_id = $id");
			if($checks === FALSE){
				$this->error = "Error getting linked task: ".$check->getLastError();
				return FALSE;	
			}
			if(count($checks) == 1){
				$this->_check = &$checks[0];
			}
		}

		return TRUE;
	}