コード例 #1
0
 /**
 	 @param string $p_name	The name of the category
 	 @return boolean	Success
 */
 public function createCategory($p_name)
 {
     try {
         $this->r_cloudBankServer->beginTransaction();
         $this->createOrUpdateLedgerAccount($p_name, CloudBankConsts::LedgerAccountType_Category);
         $this->r_cloudBankServer->commitTransaction();
     } catch (Exception $v_exception) {
         Debug::Singleton()->log(var_export($v_exception, true));
         throw $v_exception;
     }
     return true;
 }
コード例 #2
0
ファイル: Util.php プロジェクト: psagi/cloudbank
 public static function ParseCSVLine($p_line)
 {
     Debug::Singleton()->log("Util::ParseCSVLine({$p_line})");
     $v_line = preg_replace('/,/', ',_', $p_line);
     /* ugly workaround to make the first character of the fields
        non-vulnerable */
     Debug::Singleton()->log("Util::ParseCSVLine(): \$v_line = {$v_line}");
     $v_csv_record_arr = str_getcsv($v_line);
     foreach ($v_csv_record_arr as &$v_field) {
         $v_field = preg_replace('/^_/', '', $v_field);
     }
     return $v_csv_record_arr;
 }
コード例 #3
0
ファイル: CloudBankServer.php プロジェクト: psagi/cloudbank
 public function execQuery($p_sQL, $p_bindArray = NULL)
 {
     $v_statement = $this->r_dBConnection->prepare($p_sQL);
     Debug::Singleton()->log('CloudBankServer::execQuery(): $v_statement = ' . var_export($v_statement, true));
     Debug::Singleton()->log('CloudBankServer::execQuery(): $p_bindArray = ' . var_export($p_bindArray, true));
     self::BindValues($v_statement, $p_bindArray);
     Debug::Singleton()->log('CloudBankServer::execQuery(): $v_statement = ' . var_export($v_statement, true));
     $v_isSuccess = $v_statement->execute();
     Debug::Singleton()->log('CloudBankServer::execQuery(): $v_isSuccess = ' . ($v_isSuccess ? 'true' : 'false'));
     $v_resultSet = $v_statement->fetchAll();
     Debug::Singleton()->log('CloudBankServer::execQuery(): $v_resultSet = ' . var_export($v_resultSet, true));
     return $v_resultSet;
 }
コード例 #4
0
ファイル: StatementService.php プロジェクト: psagi/cloudbank
 /**
 	 @param Statement $p_statement http://pety.dynu.net/CloudBank/StatementService
 	 @return boolean	Success
 */
 public function importStatement($p_statement)
 {
     Debug::Singleton()->log('importStatement(' . var_export($p_statement, true) . ')');
     $this->assertTableIsEmpty();
     $this->r_cloudBankServer->beginTransaction();
     $v_line_no = 0;
     foreach ($p_statement->StatementLine as $v_statement_line) {
         ++$v_line_no;
         Debug::Singleton()->log("importStatement: {$v_line_no}: {$v_statement_line}");
         $v_statement_item_arr = Util::ParseCSVLine($v_statement_line);
         Debug::Singleton()->log("importStatement: {$v_line_no}: " . var_export($v_statement_item_arr, true));
         if (count($v_statement_item_arr) == 0) {
             continue;
         }
         $this->assertStatementItemIsValid($v_statement_item_arr, $v_line_no, $v_statement_line);
         $this->createStatementItem($v_statement_item_arr);
     }
     $this->r_cloudBankServer->commitTransaction();
     return true;
 }
コード例 #5
0
ファイル: SchemaDef.php プロジェクト: psagi/cloudbank
 private static function CheckStrLength($p_str, $p_minLen, $p_maxLen)
 {
     Debug::Singleton()->log("SchemaDef::CheckStrLength({$p_str}, {$p_minLen}, {$p_maxLen})");
     $v_length = mb_strlen($p_str, 'UTF-8');
     Debug::Singleton()->log("SchemaDef::CheckStrLength(): \$v_length = {$v_length}");
     Debug::Singleton()->log("SchemaDef::CheckStrLength(): mb_internal_encoding() = " . mb_internal_encoding());
     return $v_length >= $p_minLen && $v_length <= $p_maxLen;
 }
コード例 #6
0
ファイル: EventService.php プロジェクト: psagi/cloudbank
    private function assertSameAsCurrent($p_accountID, $p_oldEvent)
    {
        Debug::Singleton()->log('assertSameAsCurrent(' . var_export($p_accountID, true) . ', ' . var_export($p_oldEvent, true) . ')');
        $v_currentEvent = $this->r_cloudBankServer->execQuery('
		  SELECT
		     date, description, other_ledger_account_id, amount,
		     statement_item_id, is_cleared
		  FROM account_events
		  WHERE ledger_account_id = :account_id AND id = :id
	       ', array(':account_id' => $p_accountID, ':id' => $p_oldEvent['id']));
        $v_mapping = array('date' => 'date', 'description' => 'description', 'other_account_id' => 'other_ledger_account_id', 'amount' => 'amount', 'is_cleared' => 'is_cleared');
        if (isset($p_oldEvent['statement_item_id'])) {
            $v_mapping['is_cleared'] = 'is_cleared';
        }
        if (!CloudBankServer::IsEqual($p_oldEvent, $v_currentEvent[0], $v_mapping)) {
            throw new Exception("The event to be modified ({$p_oldEvent['id']}) does not " . "exist or has been modified by another session. Please try " . "again.");
        }
    }