Jump to content

Displaying - instead of 0 ???


cp914

Recommended Posts

Quick background... I bought an auction program with plenty of bugs. Todays bug that I can't figure out is that it is displaying a - (dash) when I would prefer it to display 0 (zero) in instances of "total fees due" or in the "fee chart" if it's a flat fee of 0.  0% works fine.

 

The code related to it is spread out on a handful of files but I think it's mostly related to the following.

 

   	
if (is_array($setup_fee))
   	{
   		foreach ($setup_fee as $key => $value)
   		{
   			if ($value['amount'])
   			{
   				if ($value['calc_type'] == 'flat')
   				{
   					$output['amount'] += $value['amount'];
   					$fee_display = $this->display_amount($value['amount'], $this->setts['currency']);
   				}
   				else if ($value['calc_type'] == 'percent')
   				{
   					$output['amount'] += $this->round_number($item_details['start_price'] * $value['amount'] / 100);
   					$fee_display = $value['amount'] . '%';
   				}

   				if ($item_relist)
   				{
   					$output['amount'] = $this->round_number($output['amount'] - $output['amount'] * $this->fee['relist_fee_reduction'] / 100);
   				}

   				$output['display'] .= '<tr class="c1"> '.
   					'	<td width="150" align="right"><b>' . GMSG_SETUP_FEE . ':</b></td> '.
   					'	<td align="left" nowrap colspan="2"><b>' . $fee_display . $value['display'] . '</b></td> '.
   					'</tr> ';

   				## now add the row on the invoices table
   				if ($user_payment_mode == 2 && $add_invoices)
   				{
   					$account_balance += $output['amount'];

   					$tax_settings = $this->tax_amount($output['amount'], $this->setts['currency'], $user_details['user_id'], $this->setts['enable_tax']);			

   					$sql_insert_invoice = $this->query("INSERT INTO " . DB_PREFIX . "invoices
						(user_id, item_id, name, amount, invoice_date, current_balance, can_rollback, tax_amount, tax_rate, tax_calculated, reverse_id) VALUES
						('" . $user_details['user_id'] . "', '" . $item_details['auction_id'] . "', '" . GMSG_SETUP_FEE . "',
						'" . $output['amount'] . "', '" . CURRENT_TIME . "', '" . $account_balance . "', " . $can_rollback . ", '" . $tax_settings['amount'] . "', 
						'" . $tax_settings['tax_rate'] . "', '1', '" . $item_details['reverse_id'] . "')");

   					$sql_update_user_balance = $this->query("UPDATE " . DB_PREFIX . "users SET
						balance='" . $account_balance . "' WHERE user_id='" . $user_details['user_id'] . "'");
   				}
   			}
   		}
   	}

   	foreach ($fees_no_tier as $key => $value)
   	{
   		if ($value[1])
   		{
   			$fee_details = $this->display_fee($key, $user_details, $item_details['category_id'], $item_details['list_in'], $voucher_details, $apply_tax);

  				if ($item_relist)
  				{
  					$fee_details['amount'] = $this->round_number($fee_details['amount'] - $fee_details['amount'] * $this->fee['relist_fee_reduction'] / 100);
  				}

   			$output['amount'] += $fee_details['amount'];

   			if ($fee_details['amount']) ## only do this if there is a fee
   			{
   				$output['display'] .= '<tr class="c1"> '.
   					'	<td width="150" align="right"><b>' . $value[0] . ':</b></td> '.
   					'	<td nowrap colspan="2"><b>' . $fee_details['display'] . '</b></td> '.
   					'</tr> ';


   				## now add the row on the invoices table
   				if ($user_payment_mode == 2 && $add_invoices)
   				{
   					$account_balance += $fee_details['amount'];

   					$tax_settings = $this->tax_amount($fee_details['amount'], $this->setts['currency'], $user_details['user_id'], $this->setts['enable_tax']);			
   					
   					$sql_insert_invoice = $this->query("INSERT INTO " . DB_PREFIX . "invoices
						(user_id, item_id, name, amount, invoice_date, current_balance, can_rollback, tax_amount, tax_rate, tax_calculated, reverse_id) VALUES
						('" . $user_details['user_id'] . "', '" . $item_details['auction_id'] . "', '" . $value[0] . "',
						'" . $fee_details['amount'] . "', '" . CURRENT_TIME . "', '" . $account_balance . "', " . $can_rollback . ", '" . $tax_settings['amount'] . "', 
						'" . $tax_settings['tax_rate'] . "', '1', '" . $item_details['reverse_id'] . "')");

   					$sql_update_user_balance = $this->query("UPDATE " . DB_PREFIX . "users SET
						balance='" . $account_balance . "' WHERE user_id='" . $user_details['user_id'] . "'");
   				}
   			}
    		}
   	}

	$output['display'] .= '<tr class="c5"><td colspan="3"></td></tr><tr class="c2"> '.
  			'	<td width="150" align="right"><b>' . GMSG_TOTAL . ':</b></td> '.
  			'	<td nowrap colspan="2"><b>' . $this->display_amount($output['amount'], $this->setts['currency']) . '</b></td> '.
		'</tr> '.
    		'<tr class="c5"> '.
        	'	<td><img src="themes/' . $this->setts['default_theme'] . '/img/pixel.gif" width="150" height="1"></td> '.
		'	<td colspan="2"><img src="themes/' . $this->setts['default_theme'] . '/img/pixel.gif" width="1" height="1"></td> '.
  			'</tr> ';

   	return $output;
}

 

I'll really really appreciate the help.

Link to comment
Share on other sites

roughly, at any point in the script where it is displaying a value, add an 'if' clause ie psuedo code

if value>0 echo value else echo "0.00"

 

in much of your code the script is concatenating values to text so you need to look thru carefully to find those places ie

 

$display = "some html here" . "some content here " . some value here TA DA . " more content" . "more html"

 

understand?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.