浏览代码

A function to remove zero at the end of the account

aspangaro 9 年之前
父节点
当前提交
687370071b
共有 1 个文件被更改,包括 28 次插入1 次删除
  1. 28 1
      htdocs/core/lib/accounting.lib.php

+ 28 - 1
htdocs/core/lib/accounting.lib.php

@@ -91,6 +91,33 @@ function accounting_prepare_head(AccountingAccount $object)
 	return $head;
 	return $head;
 }
 }
 
 
+/**
+ * Return accounting account without zero on the right
+ *
+ * @param 	string	$account		Accounting account
+ * @return	string          		String without zero on the right
+ */
+function clean_account($account)
+{
+	global $conf;
+
+	// Clean parameters
+	$i = strlen($account);
+
+	if ($i >= 1) {
+		if (substr($account, -1) == 0) {
+			while ( $i >= 1 ) {
+				$account = substr($account, $i);
+
+				$i --;
+			}
+			return $account;
+		}
+	} else {
+		return $account;
+	}
+}
+
 /**
 /**
  * Return general accounting account with defined length
  * Return general accounting account with defined length
  *
  *
@@ -131,7 +158,7 @@ function length_accountg($account)
  */
  */
 function length_accounta($accounta)
 function length_accounta($accounta)
 {
 {
-	global $conf, $langs;
+	global $conf;
 
 
 	$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
 	$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;