diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index d2d22d74e3c..bcbdf18c213 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -57,7 +57,9 @@ if ($action == 'add' && !empty($permissiontoadd)) { } } else { if (!GETPOSTISSET($key)) { - continue; // The field was not submited to be edited + if ($key != 'lang' || !GETPOSTISSET($key.'object')) { + continue; // The field was not submited to be edited + } } } // Ignore special fields @@ -87,7 +89,11 @@ if ($action == 'add' && !empty($permissiontoadd)) { $tmparraykey = array_keys($object->param_list); $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2'); } else { - $value = GETPOST($key, 'alphanohtml'); + if ($key == 'lang') { + $value = GETPOST($key.'object', 'aZ09'); + } else { + $value = GETPOST($key, 'alphanohtml'); + } } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { $value = ''; // This is an implicit foreign key field @@ -161,7 +167,9 @@ if ($action == 'update' && !empty($permissiontoadd)) { } } else { if (!GETPOSTISSET($key)) { - continue; // The field was not submited to be edited + if ($key != 'lang' || !GETPOSTISSET($key.'object')) { + continue; // The field was not submited to be edited + } } } // Ignore special fields @@ -199,7 +207,11 @@ if ($action == 'update' && !empty($permissiontoadd)) { } elseif ($object->fields[$key]['type'] == 'reference') { $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2'); } else { - $value = GETPOST($key, 'alpha'); + if ($key == 'lang') { + $value = GETPOST($key.'object', 'aZ09'); + } else { + $value = GETPOST($key, 'alphanohtml'); + } } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') { $value = ''; // This is an implicit foreign key field diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index cd07c0b8191..a0e83c6eb5e 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -79,13 +79,20 @@ foreach ($object->fields as $key => $val) { $value = (GETPOST($key) == 'on' ? 1 : 0); } elseif ($val['type'] == 'price') { $value = price2num(GETPOST($key)); + } elseif ($key == 'lang') { + $value = GETPOST($key.'object', 'aZ09'); } else { $value = GETPOST($key, 'alphanohtml'); } if (!empty($val['noteditable'])) { print $object->showOutputField($val, $key, $value, '', '', '', 0); } else { - print $object->showInputField($val, $key, $value, '', '', '', 0); + if ($key == 'lang') { + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($value, $key.'object', 0, null, 1, 0, 0, 'minwidth300', 2); + } else { + print $object->showInputField($val, $key, $value, '', '', '', 0); + } } print ''; print ''; diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 9670271d1a4..a3d70117fea 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -79,6 +79,8 @@ foreach ($object->fields as $key => $val) { $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key; } elseif ($val['type'] == 'price') { $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key); + } elseif ($key == 'lang') { + $value = GETPOSTISSET($key.'object', 'aZ09')?GETPOST($key.'object', 'aZ09'):$object->lang; } else { $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; } @@ -86,7 +88,12 @@ foreach ($object->fields as $key => $val) { if ($val['noteditable']) { print $object->showOutputField($val, $key, $value, '', '', '', 0); } else { - print $object->showInputField($val, $key, $value, '', '', '', 0); + if ($key == 'lang') { + print img_picto('', 'language', 'class="pictofixedwidth"'); + print $formadmin->select_language($value, $key.'object', 0, null, 1, 0, 0, 'minwidth300', 2); + } else { + print $object->showInputField($val, $key, $value, '', '', '', 0); + } } print ''; print ''; diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index f9da77c5894..b58d0526356 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -81,7 +81,14 @@ foreach ($object->fields as $key => $val) { if (in_array($val['type'], array('text', 'html'))) { print '
'; diff --git a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql index 65c8add25c4..5bb4a0ea648 100644 --- a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql +++ b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql @@ -21,6 +21,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( date_creation datetime NOT NULL, tms timestamp, last_main_doc varchar(255), + lang varchar(6), fk_user_creat integer NOT NULL, fk_user_modif integer, fk_user_valid integer, diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index dacdf57d3a8..f3d6d81aaec 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -114,7 +114,8 @@ class KnowledgeRecord extends CommonObject 'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>3, 'csslist'=>'tdoverflow300'), //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'), 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'GroupOfTicket', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated'),), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Valid'),), + 'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>1), ); public $rowid; public $ref; @@ -130,6 +131,7 @@ class KnowledgeRecord extends CommonObject public $answer; public $url; public $status; + public $lang; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index dbab7ec0528..99e8e97ecc6 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php'; require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php'; @@ -117,6 +118,11 @@ if (empty($reshook)) { $triggermodname = 'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record + // Upadate / add for lang + if (($action == 'update' || $action == 'add') && !empty($permissiontoadd)) { + $object->lang = GETPOSTISSET('langkm', 'aZ09')?GETPOST('langkm', 'aZ09'):$object->lang; + } + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -156,6 +162,7 @@ if ($action == 'confirm_validate') { $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); +$formadmin = new FormAdmin($db); $title = $langs->trans("KnowledgeRecord"); $help_url = ''; @@ -185,6 +192,7 @@ if ($action == 'create') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; @@ -225,6 +233,7 @@ if (($id || $ref) && $action == 'edit') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index e04183baaf8..923213fe479 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -26,6 +26,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -88,7 +89,11 @@ $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alph $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { - $search[$key] = GETPOST('search_'.$key, 'alpha'); + if ($key == "lang") { + $search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : ''; + } else { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); @@ -197,6 +202,7 @@ if (empty($reshook)) { $form = new Form($db); $user_temp = new User($db); +$formadmin = new FormAdmin($db); $now = dol_now(); @@ -455,7 +461,11 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; + if ($key == 'lang') { + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth300', 2); + } else { + print ''; + } } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '