WIP Edit fields into alternate language

This commit is contained in:
Laurent Destailleur 2020-03-22 19:11:21 +01:00
parent b0f3fba71a
commit 700e384639
4 changed files with 53 additions and 12 deletions

View File

@ -316,6 +316,32 @@ class Form
return $ret;
}
/**
* Output edit in place form
*
* @param string $fieldname Name of the field
* @param object $object Object
* @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field.
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
* @return string HTML code for the edit of alternative language
*/
public function widgetForTranslation($htmlname, $object, $perm, $typeofdata = 'string') {
global $conf, $langs;
$result = '';
if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
$result ='<div class="inline-block field-'.$object->element.'-'.$htmlname.'">';
$s=picto_from_langcode($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
$result .= $s;
$result .= '</div>';
}
return $result;
}
/**
* Output edit in place form
*

View File

@ -1982,5 +1982,5 @@ MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server
FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled
EmailTemplate=Template for email
EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax
PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some text title in your PDF duplicated in 2 different languages in the same generate PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF.
PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF.
FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book.

View File

@ -98,6 +98,13 @@ if (!empty($canvas))
// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
$permissiontoread = $user->rights->societe->lire;
$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->societe->delete || ($permissiontoadd && isset($object->status) && $object->status == 0);
$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
/*
* Actions
@ -1186,7 +1193,7 @@ else
print '<table class="border centpercent">';
// Name, firstname
print '<tr><td class="titlefieldcreate">';
print '<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
if ($object->particulier || $private)
{
print '<span id="TypeName" class="fieldrequired">'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName', 'name').'</span>';
@ -1196,7 +1203,9 @@ else
print '<span id="TypeName" class="fieldrequired">'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0).'</span>';
}
print '</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '').'>';
print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.$object->name.'" autofocus="autofocus"></td>';
print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.$object->name.'" autofocus="autofocus">';
print $form->widgetForTranslation("name", $object, $permissiontoadd);
print '</td>';
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$object->prefix_comm.'"></td>';
@ -1249,7 +1258,7 @@ else
{
// Supplier
print '<tr>';
print '<td>'.$form->editfieldkey('Vendor', 'fournisseur', '', $object, 0, 'string', '', 1).'</td><td>';
print '<td>'.$form->editfieldkey('Vendor', 'fournisseur', '', $object, $permissiontoadd, 'string', '', 1).'</td><td>';
$default = -1;
if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default = 1;
print $form->selectyesno("fournisseur", (GETPOST('fournisseur', 'int') != '' ?GETPOST('fournisseur', 'int') : (GETPOST("type", 'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type", 'alpha') == '' ? 1 : 0));
@ -1261,7 +1270,7 @@ else
print '<td>';
if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
{
print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0);
print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, $permissiontoadd);
}
print '</td><td>';
if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
@ -1279,35 +1288,40 @@ else
}
// Status
print '<tr><td>'.$form->editfieldkey('Status', 'status', '', $object, 0).'</td><td colspan="3">';
print '<tr><td>'.$form->editfieldkey('Status', 'status', '', $object, $permissiontoadd).'</td><td colspan="3">';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
print '</td></tr>';
// Barcode
if (!empty($conf->barcode->enabled))
{
print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, $permissiontoadd).'</td>';
print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.$object->barcode.'">';
print '</td></tr>';
}
// Address
print '<tr><td class="tdtop">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
print '<tr><td class="tdtop">';
print $form->editfieldkey('Address', 'address', '', $object, $permissiontoadd);
print '</td>';
print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.'" wrap="soft">';
print $object->address;
print '</textarea></td></tr>';
print '</textarea>';
print $form->widgetForTranslation("address", $object, $permissiontoadd);
print '</td></tr>';
// Zip / Town
print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, $permissiontoadd).'</td><td>';
print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
print '</td>';
if ($conf->browser->layout == 'phone') print '</tr><tr>';
print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
print '<td>'.$form->editfieldkey('Town', 'town', '', $object, $permissiontoadd).'</td><td>';
print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
print $form->widgetForTranslation("town", $object, $permissiontoadd);
print '</td></tr>';
// Country
print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, $permissiontoadd).'</td><td colspan="3" class="maxwidthonsmartphone">';
print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id));
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td></tr>';

View File

@ -712,6 +712,7 @@ class Societe extends CommonObject
*/
public $multicurrency_code;
/**
* Constructor
*