Author Topic: formula  (Read 9849 times)

0 Members and 1 Guest are viewing this topic.

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
formula
« on: July 25, 2002, 12:58:26 PM »
Hello

I'm testing the image gellery script and it's working perfect.

I want to use this script to give our customers an overview of our products, up to now I have found a solution for almost everything in your script.

I have added one userdefiendfield where I put in the price of a product. (note: I don't want to make a webshop only a product overview with a price).

Now the problem: I want to show different prices for 2 different usergroups. This is also not a problem but you have to know that to understand the problem. We want to add one price, the other price must be recalculated and by example 10% higher.

I have already tried to make a querie but I don't get the output in the script.
A javascript can also be a solution: by example the JS reads the userdefiendfield value and recalculate the new price, by this I have the problem that JS calculate with a decimal point, so we need the prices serperated by a decimal comma.

I hope someone can give an advice.
Thanks a lot!

Arnoud

P.S. We will buy this script when we have found a solution!

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
formula
« Reply #1 on: July 25, 2002, 01:38:41 PM »
PHP also calculates with decimal point. Simple solution after calculating:

Code: [Select]
$price = str_replace(".", ",", $price);

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
Formula
« Reply #2 on: July 25, 2002, 01:59:19 PM »
Thanks for you fast reaction,

Is there maybe a possibility to make a change in an included php script, that makes a new value by example:

 {price1} database value.
 {price2} value after php formula.

I hope there is.

Thanks a lot

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
formula
« Reply #3 on: July 25, 2002, 02:14:38 PM »
Can you post exactly what you defined in "includes/db_field_definitions.php"?

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
formula
« Reply #4 on: July 25, 2002, 02:24:10 PM »
Of course,

This is what the db_field_definitions.php looks like, here I use different amountprices.

$additional_image_fields['amout1'] = array($lang['amount1'], "text", 1);
$additional_image_fields['price1'] = array($lang['price1'], "text", 1);
$additional_image_fields['amount2'] = array($lang['amount2'], "text", 1);
$additional_image_fields['price2'] = array($lang['price2'], "text", 1);
$additional_image_fields['amount3'] = array($lang['amount3'], "text", 1);
$additional_image_fields['price3'] = array($lang['price3'], "text", 1);

But to make it not to difficult I think it is better to sea firt only the following sense:

$additional_image_fields['price1'] = array($lang['price1'], "text", 1);

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
formula
« Reply #5 on: July 25, 2002, 03:46:56 PM »
Ok, maybe this is what you want.
Open "include/functions.php" and search for this line:

Code: [Select]
$additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;

Replace this line with:

Code: [Select]
if ($key == "price1") {
  if (!empty($image_row['price1'])) {
    $price1 = $image_row['price1'];
     // $price1_2 = $price1 + 10%
    $price1_2 = $price1 + (($price1 / 100) * 10);
 
    $price1 = str_replace(".", ",", $price1);
    $price1_2 = str_replace(".", ",", $price1_2);
  }
  else {
    $price1 = REPLACE_EMPTY;
    $price1_2 = REPLACE_EMPTY;
  }
  $additional_field_array['price1'] = $price1;
  $additional_field_array['price1_2'] = $price1_2;
}
else {
  $additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;
}


Then you can use {price1} and {price1_2} in your template.
Note: You have to enter the prices with decimal point in your Control Panel.

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
Thanks
« Reply #6 on: July 25, 2002, 04:56:13 PM »
Thanks,  :D

It works!

I will ask the responsible person in our company, to order those scripts as soon as possible.

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
Read value
« Reply #7 on: September 24, 2002, 03:22:09 PM »
Hello Jan,

Can I read in the value "amount of next pages. saved in the settings menu" In the above script, functions.php.

I want to use that field for a currency amount instead of the next pages.

How can I read in this value

Thanks a lot, please help me!

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
formula
« Reply #8 on: September 24, 2002, 05:32:23 PM »
Sorry, i don't understand exactly what you mean.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
currency
« Reply #9 on: October 02, 2002, 12:58:02 PM »
Jan,

Code: [Select]
$price1_2 = $price1 + (($price1 * DOLLARCURRENCY) * 1,5);

This is a row out of my functions.php, in this row I want to change the word DOLLARCURRENCY by a value that I can type in, in the setting screen of this script.

Is it by example possible to change the field amountofnextpages in the settings menu, so I type in this field the dollarcurrency?

And how can I read in this value in the script functions.php on the place of the word  DOLLARCURRENCY.

I hope you can understand, it is dificult to explain, but I think there must be a simple solution.

I hope you can help me.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
formula
« Reply #10 on: October 02, 2002, 01:22:49 PM »
Try:

Code: [Select]
global $HTTP_GET_VARS, $HTTP_POST_VARS
if (isset($HTTP_GET_VARS['dollarcurrency']) || isset($HTTP_POST_VARS['dollarcurrency'])) {
  $dollarcurrency = (isset($HTTP_GET_VARS['dollarcurrency'])) ? intval($HTTP_GET_VARS['dollarcurrency']) : intval($HTTP_POST_VARS['dollarcurrency']);
}
else {
  $dollarcurrency = 0; // default value of dollarcurrency
}


The field name on the details page must be "dollarcurrency".

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline arnoud

  • Newbie
  • *
  • Posts: 37
    • View Profile
hmmm
« Reply #11 on: October 02, 2002, 01:35:22 PM »
Must I place the script in the admin\settings.php or something?

How else can I type in the dollar value in a textbox in the setting menu, and use it later in the formula in the functions.php script.

Sorry when I'm not clear enough,

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
formula
« Reply #12 on: October 02, 2002, 01:50:00 PM »
Ok, i hope this is what you need:

Add a new entry to your 4images_settings table in the database. Maybe use phpMyadmin with this query:

Code: [Select]
INSERT INTO 4images_settings (setting_name, setting_value) VALUES ('dollarcurrency', '100');

Then open "admin/settings.php" and add after
Code: [Select]
show_setting_row("gz_compress_level");
this line
Code: [Select]
show_setting_row("dollarcurrency");

Then use in the function show_image() in "includes/functions.php":
Code: [Select]
$config['dollarcurrency']
to use the value from the settings.

Example:
Code: [Select]
$price1_2 = $price1 + (($price1 * $config['dollarcurrency']) * 1,5);

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search