New: Extra fields support int type.
This commit is contained in:
parent
6c0698d6ee
commit
988dc29f15
@ -44,6 +44,7 @@ For users:
|
|||||||
- New: Value of data into charts are visible on mouse hover.
|
- New: Value of data into charts are visible on mouse hover.
|
||||||
- New: Import wizard can import contacts.
|
- New: Import wizard can import contacts.
|
||||||
- New: Install process is now two times faster.
|
- New: Install process is now two times faster.
|
||||||
|
- New: Extra fields support int type.
|
||||||
- Fix: Can use POS module with several concurrent users.
|
- Fix: Can use POS module with several concurrent users.
|
||||||
|
|
||||||
For developers:
|
For developers:
|
||||||
|
|||||||
@ -21,17 +21,27 @@
|
|||||||
* \brief Code for actions on extrafields admin pages
|
* \brief Code for actions on extrafields admin pages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$maxsizestring=255;
|
||||||
|
$maxsizeint=10;
|
||||||
|
|
||||||
// Add attribute
|
// Add attribute
|
||||||
if ($action == 'add')
|
if ($action == 'add')
|
||||||
{
|
{
|
||||||
if ($_POST["button"] != $langs->trans("Cancel"))
|
if ($_POST["button"] != $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
// Check values
|
// Check values
|
||||||
if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
|
if (GETPOST('type')=='varchar' && GETPOST('size') > $maxsizestring)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
|
$mesg=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
|
||||||
|
$action = 'create';
|
||||||
|
}
|
||||||
|
if (GETPOST('type')=='int' && GETPOST('size') > $maxsizeint)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$langs->load("errors");
|
||||||
|
$mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,11 +79,18 @@ if ($action == 'update')
|
|||||||
if ($_POST["button"] != $langs->trans("Cancel"))
|
if ($_POST["button"] != $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
// Check values
|
// Check values
|
||||||
if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
|
if (GETPOST('type')=='varchar' && GETPOST('size') > $maxsizestring)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
|
$mesg=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
|
||||||
|
$action = 'edit';
|
||||||
|
}
|
||||||
|
if (GETPOST('type')=='int' && GETPOST('size') > $maxsizeint)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$langs->load("errors");
|
||||||
|
$mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
|
||||||
$action = 'edit';
|
$action = 'edit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -185,6 +185,8 @@ class CMailFile
|
|||||||
$this->addr_bcc = $addr_bcc;
|
$this->addr_bcc = $addr_bcc;
|
||||||
$this->deliveryreceipt = $deliveryreceipt;
|
$this->deliveryreceipt = $deliveryreceipt;
|
||||||
$smtp_headers = $this->write_smtpheaders();
|
$smtp_headers = $this->write_smtpheaders();
|
||||||
|
// TODO ? Add 'Date: ' . date("r") . "\r\n"; before X-Mailer
|
||||||
|
// TODO ? Add 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; before X-Mailer
|
||||||
|
|
||||||
// Define mime_headers
|
// Define mime_headers
|
||||||
$mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list);
|
$mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list);
|
||||||
@ -219,16 +221,15 @@ class CMailFile
|
|||||||
$files_encoded = $this->write_files($filename_list,$mimetype_list,$mimefilename_list);
|
$files_encoded = $this->write_files($filename_list,$mimetype_list,$mimefilename_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We now define $this->headers et $this->message
|
// We now define $this->headers and $this->message
|
||||||
$this->headers = $smtp_headers . $mime_headers;
|
$this->headers = $smtp_headers . $mime_headers;
|
||||||
|
|
||||||
$this->message = $text_body . $images_encoded . $files_encoded;
|
|
||||||
$this->message.= "--" . $this->mixed_boundary . "--" . $this->eol;
|
|
||||||
|
|
||||||
// On nettoie le header pour qu'il ne se termine pas par un retour chariot.
|
// On nettoie le header pour qu'il ne se termine pas par un retour chariot.
|
||||||
// Ceci evite aussi les lignes vides en fin qui peuvent etre interpretees
|
// Ceci evite aussi les lignes vides en fin qui peuvent etre interpretees
|
||||||
// comme des injections mail par les serveurs de messagerie.
|
// comme des injections mail par les serveurs de messagerie.
|
||||||
//$this->headers = preg_replace("/([\r\n]+)$/i","",$this->headers);
|
$this->headers = preg_replace("/([\r\n]+)$/i","",$this->headers);
|
||||||
|
|
||||||
|
$this->message = $text_body . $images_encoded . $files_encoded;
|
||||||
|
$this->message.= "--" . $this->mixed_boundary . "--" . $this->eol;
|
||||||
}
|
}
|
||||||
else if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
|
else if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1778,14 +1778,45 @@ abstract class CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add/Update extra fields
|
* Add/Update all extra fields values for the current object.
|
||||||
|
* All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd')
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function insertExtraFields()
|
function insertExtraFields()
|
||||||
{
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
if (count($this->array_options) > 0)
|
if (count($this->array_options) > 0)
|
||||||
{
|
{
|
||||||
|
// Check parameters
|
||||||
|
$langs->load('admin');
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||||
|
$extrafields = new ExtraFields($this->db);
|
||||||
|
$optionsArray = $extrafields->fetch_name_optionals_label($this->elementType);
|
||||||
|
|
||||||
|
foreach($this->array_options as $key => $value)
|
||||||
|
{
|
||||||
|
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||||
|
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||||
|
$attributeSize = $extrafields->attribute_size[$attributeKey];
|
||||||
|
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||||
|
switch ($attributeType)
|
||||||
|
{
|
||||||
|
case 'int':
|
||||||
|
if (!is_numeric($value) && $value!='')
|
||||||
|
{
|
||||||
|
$error++; $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
elseif ($value=='')
|
||||||
|
{
|
||||||
|
$this->array_options[$key] = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||||
|
|||||||
@ -27,8 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class ExtraFields
|
* Class to manage standard extra fields
|
||||||
* \brief Class to manage standard extra fields
|
|
||||||
*/
|
*/
|
||||||
class ExtraFields
|
class ExtraFields
|
||||||
{
|
{
|
||||||
@ -46,11 +45,11 @@ class ExtraFields
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function ExtraFields($DB)
|
function ExtraFields($db)
|
||||||
{
|
{
|
||||||
$this->db = $DB ;
|
$this->db = $db;
|
||||||
$this->error = array();
|
$this->error = array();
|
||||||
$this->attribute_type = array();
|
$this->attribute_type = array();
|
||||||
$this->attribute_label = array();
|
$this->attribute_label = array();
|
||||||
@ -60,6 +59,7 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new extra field parameter
|
* Add a new extra field parameter
|
||||||
|
*
|
||||||
* @param attrname code of attribute
|
* @param attrname code of attribute
|
||||||
* @param label label of attribute
|
* @param label label of attribute
|
||||||
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
|
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
|
||||||
@ -88,6 +88,7 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new optionnal attribute
|
* Add a new optionnal attribute
|
||||||
|
*
|
||||||
* @param attrname code of attribute
|
* @param attrname code of attribute
|
||||||
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
|
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
|
||||||
* @param length Size/length of attribute
|
* @param length Size/length of attribute
|
||||||
@ -129,6 +130,7 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add description of a new optionnal attribute
|
* Add description of a new optionnal attribute
|
||||||
|
*
|
||||||
* @param attrname code of attribute
|
* @param attrname code of attribute
|
||||||
* @param label label of attribute
|
* @param label label of attribute
|
||||||
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
|
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
|
||||||
@ -172,6 +174,7 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an optionnal attribute
|
* Delete an optionnal attribute
|
||||||
|
*
|
||||||
* @param attrname Code of attribute to delete
|
* @param attrname Code of attribute to delete
|
||||||
* @param elementtype Element type ('member', 'product', 'company', ...)
|
* @param elementtype Element type ('member', 'product', 'company', ...)
|
||||||
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
|
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
|
||||||
@ -211,6 +214,7 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete description of an optionnal attribute
|
* Delete description of an optionnal attribute
|
||||||
|
*
|
||||||
* @param attrname Code of attribute to delete
|
* @param attrname Code of attribute to delete
|
||||||
* @param elementtype Element type ('member', 'product', 'company', ...)
|
* @param elementtype Element type ('member', 'product', 'company', ...)
|
||||||
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
|
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
|
||||||
@ -246,6 +250,7 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify type of a personalized attribute
|
* Modify type of a personalized attribute
|
||||||
|
*
|
||||||
* @param attrname name of attribute
|
* @param attrname name of attribute
|
||||||
* @param type type of attribute
|
* @param type type of attribute
|
||||||
* @param length length of attribute
|
* @param length length of attribute
|
||||||
@ -288,11 +293,12 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify description of personalized attribute
|
* Modify description of personalized attribute
|
||||||
* @param attrname name of attribute
|
*
|
||||||
* @param label label of attribute
|
* @param string $attrname Name of attribute
|
||||||
* @param type type of attribute
|
* @param string $label Label of attribute
|
||||||
* @param length length of attribute
|
* @param string $type Type of attribute
|
||||||
* @param elementtype Element type ('member', 'product', 'company', ...)
|
* @param int $length Length of attribute
|
||||||
|
* @param string $elementtype Element type ('member', 'product', 'company', ...)
|
||||||
*/
|
*/
|
||||||
function update_label($attrname,$label,$type,$size,$elementtype='member')
|
function update_label($attrname,$label,$type,$size,$elementtype='member')
|
||||||
{
|
{
|
||||||
@ -350,6 +356,8 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load array of labels
|
* Load array of labels
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function fetch_optionals()
|
function fetch_optionals()
|
||||||
{
|
{
|
||||||
@ -359,6 +367,9 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load array this->attribute_label
|
* Load array this->attribute_label
|
||||||
|
*
|
||||||
|
* @param string $elementtype Type of element
|
||||||
|
* @return array Array of attributes for all extra fields
|
||||||
*/
|
*/
|
||||||
function fetch_name_optionals_label($elementtype='member')
|
function fetch_name_optionals_label($elementtype='member')
|
||||||
{
|
{
|
||||||
@ -429,7 +440,11 @@ class ExtraFields
|
|||||||
if ($showsize > 48) $showsize=48;
|
if ($showsize > 48) $showsize=48;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'varchar')
|
if ($type == 'int')
|
||||||
|
{
|
||||||
|
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
||||||
|
}
|
||||||
|
else if ($type == 'varchar')
|
||||||
{
|
{
|
||||||
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$size.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
@ -446,8 +461,10 @@ class ExtraFields
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML string to put an output field into a page
|
* Return HTML string to put an output field into a page
|
||||||
* @param key Key of attribute
|
*
|
||||||
* @param value Value to show
|
* @param string $key Key of attribute
|
||||||
|
* @param string $value Value to show
|
||||||
|
* @return string Formated value
|
||||||
*/
|
*/
|
||||||
function showOutputField($key,$value,$moreparam='')
|
function showOutputField($key,$value,$moreparam='')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -855,6 +855,7 @@ MAIN_PROXY_USER=Login to use the proxy server
|
|||||||
MAIN_PROXY_PASS=Password to use the proxy server
|
MAIN_PROXY_PASS=Password to use the proxy server
|
||||||
DefineHereComplementaryAttributes=Define here all atributes, not already available by default, and that you want to be supported for %s.
|
DefineHereComplementaryAttributes=Define here all atributes, not already available by default, and that you want to be supported for %s.
|
||||||
ExtraFields=Complementary attributes
|
ExtraFields=Complementary attributes
|
||||||
|
ExtraFieldHasWrongValue=Attribut %s has a wrong value.
|
||||||
SendingMailSetup=Setup of sendings by email
|
SendingMailSetup=Setup of sendings by email
|
||||||
SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must conatins option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba).
|
SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must conatins option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba).
|
||||||
PathToDocuments=Path to documents
|
PathToDocuments=Path to documents
|
||||||
|
|||||||
@ -51,6 +51,8 @@ ErrorPartialFile=File not received completely by server.
|
|||||||
ErrorNoTmpDir=Temporary directy %s does not exists.
|
ErrorNoTmpDir=Temporary directy %s does not exists.
|
||||||
ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin.
|
ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin.
|
||||||
ErrorFileSizeTooLarge=File size is too large.
|
ErrorFileSizeTooLarge=File size is too large.
|
||||||
|
ErrorSizeTooLongForIntType=Size too long for int type (%s digits maximum)
|
||||||
|
ErrorSizeTooLongForVarcharType=Size too long for string type (%s chars maximum)
|
||||||
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
|
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
|
||||||
ErrorNoAccountancyModuleLoaded=No accountancy module activated
|
ErrorNoAccountancyModuleLoaded=No accountancy module activated
|
||||||
ErrorExportDuplicateProfil=This profil name already exists for this export set.
|
ErrorExportDuplicateProfil=This profil name already exists for this export set.
|
||||||
|
|||||||
@ -863,6 +863,7 @@ MAIN_PROXY_USER=Login pour passer le serveur proxy mandataire
|
|||||||
MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire
|
MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire
|
||||||
DefineHereComplementaryAttributes=Definissez ici la liste des attributs supplémentaire, non disponible en standard, et que vous voulez voir gérez sur les %s.
|
DefineHereComplementaryAttributes=Definissez ici la liste des attributs supplémentaire, non disponible en standard, et que vous voulez voir gérez sur les %s.
|
||||||
ExtraFields=Attributs suplémentaires
|
ExtraFields=Attributs suplémentaires
|
||||||
|
ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte.
|
||||||
SendingMailSetup=Configuration de l'envoi par mail
|
SendingMailSetup=Configuration de l'envoi par mail
|
||||||
SendmailOptionNotComplete=Attention, sur certains systèmes Linux, avec cette méthode d'envoi, pour pouvoir envoyer des mails en votre nom, la configuration d'exécution de sendmail doit contenir l'option <b>-ba</b> (paramètre <b>mail.force_extra_parameters</b> dans le fichier <b>php.ini</b>). Si certains de vos destinataires ne reçoivent pas de message, essayer de modifer ce paramètre PHP avec <b>mail.force_extra_parameters = -ba</b>.
|
SendmailOptionNotComplete=Attention, sur certains systèmes Linux, avec cette méthode d'envoi, pour pouvoir envoyer des mails en votre nom, la configuration d'exécution de sendmail doit contenir l'option <b>-ba</b> (paramètre <b>mail.force_extra_parameters</b> dans le fichier <b>php.ini</b>). Si certains de vos destinataires ne reçoivent pas de message, essayer de modifer ce paramètre PHP avec <b>mail.force_extra_parameters = -ba</b>.
|
||||||
PathToDocuments= Chemin d'accès aux documents
|
PathToDocuments= Chemin d'accès aux documents
|
||||||
|
|||||||
@ -52,6 +52,8 @@ ErrorPartialFile=Fichier non reçu intégralement par le serveur.
|
|||||||
ErrorNoTmpDir=Répertoire temporaire de réception %s inexistant.
|
ErrorNoTmpDir=Répertoire temporaire de réception %s inexistant.
|
||||||
ErrorUploadBlockedByAddon=Upload bloqué par un plugin PHP/Apache.
|
ErrorUploadBlockedByAddon=Upload bloqué par un plugin PHP/Apache.
|
||||||
ErrorFileSizeTooLarge=La taille du fichier est trop grande.
|
ErrorFileSizeTooLarge=La taille du fichier est trop grande.
|
||||||
|
ErrorSizeTooLongForIntType=Longueur de champ trop longue pour le type int (%s chiffres maximum)
|
||||||
|
ErrorSizeTooLongForVarcharType=Longueur de champ trop longue pour le type chaine (%s caractères maximum)
|
||||||
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux.
|
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux.
|
||||||
ErrorNoAccountancyModuleLoaded=Aucun module de comptabilité activé
|
ErrorNoAccountancyModuleLoaded=Aucun module de comptabilité activé
|
||||||
ErrorExportDuplicateProfil=Ce nom de profil existe déjà pour ce lot d'export.
|
ErrorExportDuplicateProfil=Ce nom de profil existe déjà pour ce lot d'export.
|
||||||
|
|||||||
@ -208,7 +208,7 @@ if ($_GET["attrname"] && $action == 'edit')
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user