NEW extrafield price with currency
This commit is contained in:
parent
a893ab39c4
commit
9ddf65de63
@ -80,6 +80,7 @@ class ExtraFields
|
|||||||
'datetime'=>'DateAndTime',
|
'datetime'=>'DateAndTime',
|
||||||
'boolean'=>'Boolean',
|
'boolean'=>'Boolean',
|
||||||
'price'=>'ExtrafieldPrice',
|
'price'=>'ExtrafieldPrice',
|
||||||
|
'pricecy'=>'ExtrafieldPriceWithCurrency',
|
||||||
'phone'=>'ExtrafieldPhone',
|
'phone'=>'ExtrafieldPhone',
|
||||||
'mail'=>'ExtrafieldMail',
|
'mail'=>'ExtrafieldMail',
|
||||||
'url'=>'ExtrafieldUrl',
|
'url'=>'ExtrafieldUrl',
|
||||||
@ -113,7 +114,7 @@ class ExtraFields
|
|||||||
*
|
*
|
||||||
* @param string $attrname Code of attribute
|
* @param string $attrname Code of attribute
|
||||||
* @param string $label label of attribute
|
* @param string $label label of attribute
|
||||||
* @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...)
|
* @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price', 'pricecy', 'phone','mail','password','url','select','checkbox','separate',...)
|
||||||
* @param int $pos Position of attribute
|
* @param int $pos Position of attribute
|
||||||
* @param string $size Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma.
|
* @param string $size Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma.
|
||||||
* @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...)
|
* @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...)
|
||||||
@ -182,7 +183,7 @@ class ExtraFields
|
|||||||
* This is a private method. For public method, use addExtraField.
|
* This is a private method. For public method, use addExtraField.
|
||||||
*
|
*
|
||||||
* @param string $attrname code of attribute
|
* @param string $attrname code of attribute
|
||||||
* @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...)
|
* @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','pricecy','phone','mail','password','url','select','checkbox', ...)
|
||||||
* @param string $length Size/length of attribute ('5', '24,8', ...)
|
* @param string $length Size/length of attribute ('5', '24,8', ...)
|
||||||
* @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...)
|
* @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...)
|
||||||
* @param int $unique Is field unique or not
|
* @param int $unique Is field unique or not
|
||||||
@ -217,6 +218,9 @@ class ExtraFields
|
|||||||
} elseif ($type == 'price') {
|
} elseif ($type == 'price') {
|
||||||
$typedb = 'double';
|
$typedb = 'double';
|
||||||
$lengthdb = '24,8';
|
$lengthdb = '24,8';
|
||||||
|
} elseif ($type == 'pricecy') {
|
||||||
|
$typedb = 'varchar';
|
||||||
|
$lengthdb = '64';
|
||||||
} elseif ($type == 'phone') {
|
} elseif ($type == 'phone') {
|
||||||
$typedb = 'varchar';
|
$typedb = 'varchar';
|
||||||
$lengthdb = '20';
|
$lengthdb = '20';
|
||||||
@ -567,6 +571,9 @@ class ExtraFields
|
|||||||
} elseif ($type == 'price') {
|
} elseif ($type == 'price') {
|
||||||
$typedb = 'double';
|
$typedb = 'double';
|
||||||
$lengthdb = '24,8';
|
$lengthdb = '24,8';
|
||||||
|
} elseif ($type == 'pricecy') {
|
||||||
|
$typedb = 'varchar';
|
||||||
|
$lengthdb = '64';
|
||||||
} elseif ($type == 'phone') {
|
} elseif ($type == 'phone') {
|
||||||
$typedb = 'varchar';
|
$typedb = 'varchar';
|
||||||
$lengthdb = '20';
|
$lengthdb = '20';
|
||||||
@ -1089,6 +1096,16 @@ class ExtraFields
|
|||||||
$value = price($value);
|
$value = price($value);
|
||||||
}
|
}
|
||||||
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> '.$langs->getCurrencySymbol($conf->currency);
|
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> '.$langs->getCurrencySymbol($conf->currency);
|
||||||
|
} elseif ($type == 'pricecy') {
|
||||||
|
$currency = $conf->currency;
|
||||||
|
if (!empty($value)) {
|
||||||
|
// $value in memory is a php numeric, we format it into user number format.
|
||||||
|
$pricetmp = explode(':', $value);
|
||||||
|
$currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
|
||||||
|
$value = price($pricetmp[0]);
|
||||||
|
}
|
||||||
|
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> ';
|
||||||
|
$out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.'currency_id');
|
||||||
} elseif ($type == 'double') {
|
} elseif ($type == 'double') {
|
||||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
||||||
$value = price($value);
|
$value = price($value);
|
||||||
@ -1624,6 +1641,17 @@ class ExtraFields
|
|||||||
if ($value || $value == '0') {
|
if ($value || $value == '0') {
|
||||||
$value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).' '.$langs->getCurrencySymbol($conf->currency);
|
$value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).' '.$langs->getCurrencySymbol($conf->currency);
|
||||||
}
|
}
|
||||||
|
} elseif ($type == 'pricecy') {
|
||||||
|
$currency = $conf->currency;
|
||||||
|
if (!empty($value)) {
|
||||||
|
// $value in memory is a php numeric, we format it into user number format.
|
||||||
|
$pricetmp = explode(':', $value);
|
||||||
|
$currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
|
||||||
|
$value = $pricetmp[0];
|
||||||
|
}
|
||||||
|
if ($value || $value == '0') {
|
||||||
|
$value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
|
||||||
|
}
|
||||||
} elseif ($type == 'select') {
|
} elseif ($type == 'select') {
|
||||||
$valstr = (!empty($param['options'][$value]) ? $param['options'][$value] : '');
|
$valstr = (!empty($param['options'][$value]) ? $param['options'][$value] : '');
|
||||||
if (($pos = strpos($valstr, "|")) !== false) {
|
if (($pos = strpos($valstr, "|")) !== false) {
|
||||||
@ -2095,6 +2123,8 @@ class ExtraFields
|
|||||||
} elseif (in_array($key_type, array('price', 'double'))) {
|
} elseif (in_array($key_type, array('price', 'double'))) {
|
||||||
$value_arr = GETPOST("options_".$key, 'alpha');
|
$value_arr = GETPOST("options_".$key, 'alpha');
|
||||||
$value_key = price2num($value_arr);
|
$value_key = price2num($value_arr);
|
||||||
|
} elseif (in_array($key_type, array('pricecy', 'double'))) {
|
||||||
|
$value_key = price2num(GETPOST("options_".$key, 'alpha')).':'.GETPOST("options_".$key."currency_id", 'alpha');
|
||||||
} elseif (in_array($key_type, array('html'))) {
|
} elseif (in_array($key_type, array('html'))) {
|
||||||
$value_key = GETPOST("options_".$key, 'restricthtml');
|
$value_key = GETPOST("options_".$key, 'restricthtml');
|
||||||
} elseif (in_array($key_type, array('text'))) {
|
} elseif (in_array($key_type, array('text'))) {
|
||||||
|
|||||||
@ -97,6 +97,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
|
|||||||
else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
|
else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
|
||||||
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
||||||
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
||||||
|
else if (type == 'pricecurrency') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
||||||
else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
||||||
else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
|
else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
|
||||||
else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
||||||
|
|||||||
@ -96,6 +96,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
|
|||||||
else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
|
else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
|
||||||
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
|
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
|
||||||
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
|
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
|
||||||
|
else if (type == 'pricecy') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
|
||||||
else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
||||||
else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
|
else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
|
||||||
else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
|
||||||
|
|||||||
@ -439,6 +439,7 @@ Unique=Unique
|
|||||||
Boolean=Boolean (one checkbox)
|
Boolean=Boolean (one checkbox)
|
||||||
ExtrafieldPhone = Phone
|
ExtrafieldPhone = Phone
|
||||||
ExtrafieldPrice = Price
|
ExtrafieldPrice = Price
|
||||||
|
ExtrafieldPriceWithCurrency=Price with currency
|
||||||
ExtrafieldMail = Email
|
ExtrafieldMail = Email
|
||||||
ExtrafieldUrl = Url
|
ExtrafieldUrl = Url
|
||||||
ExtrafieldIP = IP
|
ExtrafieldIP = IP
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user