Skip to content
Snippets Groups Projects
Commit 51098c12 authored by Florian Henry's avatar Florian Henry
Browse files

Add standard extrafield type :

	- mail
	- phone
	- price
parent e8ab2494
No related branches found
No related tags found
No related merge requests found
......@@ -2135,7 +2135,10 @@ abstract class CommonObject
$this->array_options[$key] = null;
}
break;
}
case 'price':
$this->array_options[$key] = price2num($this->array_options[$key]);
break;
}
}
$this->db->begin();
......
......@@ -53,7 +53,10 @@ class ExtraFields
'double'=>'Float',
'date'=>'Date',
'datetime'=>'DateAndTime',
'boolean'=>'Boolean'
'boolean'=>'Boolean',
'price'=>'ExtrafieldPrice',
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail'
);
/**
......@@ -139,6 +142,15 @@ class ExtraFields
if ($type=='boolean') {
$typedb='int';
$lengthdb='1';
} elseif($type=='price') {
$typedb='double';
$lengthdb='24,8';
} elseif($type=='phone') {
$typedb='varchar';
$lengthdb='20';
}elseif($type=='mail') {
$typedb='varchar';
$lengthdb='128';
} else {
$typedb=$type;
$lengthdb=$length;
......@@ -312,9 +324,18 @@ class ExtraFields
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
if ($type=='boolean') {
if ($type=='boolean') {
$typedb='int';
$lengthdb='1';
} elseif($type=='price') {
$typedb='double';
$lengthdb='24,8';
} elseif($type=='phone') {
$typedb='varchar';
$lengthdb='20';
}elseif($type=='mail') {
$typedb='varchar';
$lengthdb='128';
} else {
$typedb=$type;
$lengthdb=$length;
......@@ -533,23 +554,23 @@ class ExtraFields
$newsize=$tmp[0];
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
}
else if (in_array($type,array('int','double')))
elseif (in_array($type,array('int','double')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
}
else if ($type == 'varchar')
elseif ($type == 'varchar')
{
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
}
else if ($type == 'text')
elseif ($type == 'text')
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('options_'.$key,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100);
$out=$doleditor->Create(1);
}
else if ($type == 'boolean')
elseif ($type == 'boolean')
{
$checked='';
if (!empty($value)) {
......@@ -559,6 +580,18 @@ class ExtraFields
}
$out='<input type="checkbox" name="options_'.$key.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'mail')
{
$out='<input type="text" name="options_'.$key.'" size="32" value="'.$value.'">';
}
elseif ($type == 'phone')
{
$out='<input type="text" name="options_'.$key.'" size="20" value="'.$value.'">';
}
elseif ($type == 'price')
{
$out='<input type="text" name="options_'.$key.'" size="6" value="'.price($value).'"> '.getCurrencySymbol($conf->currency);
}
// Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
......@@ -575,7 +608,8 @@ class ExtraFields
*/
function showOutputField($key,$value,$moreparam='')
{
global $conf;
$label=$this->attribute_label[$key];
$type=$this->attribute_type[$key];
$size=$this->attribute_size[$key];
......@@ -601,6 +635,18 @@ class ExtraFields
$checked=' checked="checked" ';
}
$value='<input type="checkbox" '.$checked.' '.($moreparam?$moreparam:'').' readonly="readonly">';
}
elseif ($type == 'mail')
{
$value=dol_print_email($value);
}
elseif ($type == 'phone')
{
$value=dol_print_phone($value);
}
elseif ($type == 'price')
{
$value=price($value).' '.getCurrencySymbol($conf->currency);
}
else
{
......
......@@ -23,6 +23,8 @@
function init_typeoffields(type)
{
var size = jQuery("#size");
var unique = jQuery("#unique");
var required = jQuery("#required");
if (type == 'date') { size.val('').attr('disabled','disabled'); }
else if (type == 'datetime') { size.val('').attr('disabled','disabled'); }
else if (type == 'double') { size.val('24,8').removeAttr('disabled'); }
......@@ -30,6 +32,7 @@
else if (type == 'text') { size.val('2000').removeAttr('disabled'); }
else if (type == 'varchar') { size.val('255').removeAttr('disabled'); }
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');}
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');}
else size.val('').attr('disabled','disabled');
}
init_typeoffields();
......
......@@ -17,7 +17,7 @@
*/
?>
<!-- BEGIN PHP TEMPLATE admin_extrafields.tpl.php -->
<!-- BEGIN PHP TEMPLATE admin_extrafields_add.tpl.php -->
<script type="text/javascript">
jQuery(document).ready(function() {
function init_typeoffields(type)
......@@ -32,6 +32,7 @@
else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.attr('disabled','disabled').removeAttr('checked'); }
else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); }
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');}
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');}
else size.val('').attr('disabled','disabled');
}
init_typeoffields('');
......
......@@ -17,7 +17,7 @@
*/
?>
<!-- BEGIN PHP TEMPLATE admin_extrafields.tpl.php -->
<!-- BEGIN PHP TEMPLATE admin_extrafields_edit.tpl.php -->
<script type="text/javascript">
jQuery(document).ready(function() {
function init_typeoffields(type)
......@@ -32,6 +32,7 @@
else if (type == 'text') { size.removeAttr('disabled'); unique.attr('disabled','disabled').removeAttr('checked'); }
else if (type == 'varchar') { size.removeAttr('disabled'); }
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');}
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');}
else size.val('').attr('disabled','disabled');
}
init_typeoffields(jQuery("#type").val());
......
......@@ -352,6 +352,9 @@ Float=Float
DateAndTime=Date and hour
Unique=Unique
Boolean=Boolean (Checkbox)
ExtrafieldPhone = Phone
ExtrafieldPrice = Price
ExtrafieldMail = Email
LibraryToBuildPDF=Library used to build PDF
WarningUsingFPDF=Warning: Your <b>conf.php</b> contains directive <b>dolibarr_pdf_force_fpdf=1</b>. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.<br>To solve this and have a full support of PDF generation, please download <a href="http://www.tcpdf.org/" target="_blank">TCPDF library</a>, then comment or remove the line <b>$dolibarr_pdf_force_fpdf=1</b>, and add instead <b>$dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir'</b>
LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:<br>1 : local tax apply on products and services without vat (vat is not applied on local tax)<br>2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)<br>3 : local tax apply on products without vat (vat is not applied on local tax)<br>4 : local tax apply on products before vat (vat is calculated on amount + localtax)<br>5 : local tax apply on services without vat (vat is not applied on local tax)<br>6 : local tax apply on services before vat (vat is calculated on amount + localtax)
......
......@@ -347,6 +347,9 @@ Int=Numérique entier
Float=Décimal
DateAndTime=Date et heure
Boolean=Booleen (Checkbox)
ExtrafieldPhone = Téléphone
ExtrafieldPrice = Prix
ExtrafieldMail = Email
LibraryToBuildPDF=Bibliothèque utilisée pour la génération des PDF
WarningUsingFPDF=Attention: Votre fichier <b>conf.php</b> contient la directive <b>dolibarr_pdf_force_fpdf=1</b>. Cela signifie que vous utilisez la librairie FPDF pour générer vos fichiers PDF. Cette librairie est ancienne et ne couvre pas de nombreuses fonctionnalitée (Unicode, transparence des images, langues cyrillic, arabes ou asiatiques...), aussi vous pouvez rencontrez des problèmes durant la génération des PDF.<br>Pour résoudre cela et avoir un support complet de PDF, vous pouvez télécharger la <a href="http://www.tcpdf.org/" target="_blank">librairie TCPDF</a> puis commenter ou supprimer la ligne <b>$dolibarr_pdf_force_fpdf=1</b>, et ajouter à la place <b>$dolibarr_lib_TCPDF_PATH='chemin_vers_TCPDF'</b>
LocalTaxDesc=Certains pays appliquent 2 voir 3 taux sur chaque ligne de facture. Si c'est le cas, choisissez le type du deuxième et troisième taux et sa valeur. Les types possibles sont:<br>1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)<br>3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)<br>4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)<br>5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment