/
traduction.php
268 lines (228 loc) · 9.4 KB
/
traduction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
/* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-2012 Destailleur Laurent <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/product/traduction.php
* \ingroup product
* \brief Page de traduction des produits
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
$langs->load("products");
$langs->load("languages");
// Security check
if (isset($_GET["id"]) || isset($_GET["ref"]))
{
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
}
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
/*
* Actions
*/
// retour a l'affichage des traduction si annulation
if ($_POST["cancel"] == $langs->trans("Cancel"))
{
$_GET["action"] = '';
}
// Validation de l'ajout
if ($_POST["action"] == 'vadd' &&
$_POST["cancel"] != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer))
{
$product = new Product($db);
$product->fetch($_POST["id"]);
$current_lang = $langs->getDefaultLang();
// update de l'objet
if ( $_POST["forcelangprod"] == $current_lang )
{
$product->libelle = $_POST["libelle"];
$product->description = dol_htmlcleanlastbr($_POST["desc"]);
$product->note = dol_htmlcleanlastbr($_POST["note"]);
}
else
{
$product->multilangs[$_POST["forcelangprod"]]["libelle"] = $_POST["libelle"];
$product->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
$product->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]);
}
// sauvegarde en base
if ( $product->setMultiLangs() > 0 )
{
$_GET["action"] = '';
}
else
{
$_GET["action"] = 'add';
$mesg = $product->mesg_error;
}
}
// Validation de l'edition
if ($_POST["action"] == 'vedit' &&
$_POST["cancel"] != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer))
{
$product = new Product($db);
$product->fetch($_POST["id"]);
$current_lang = $langs->getDefaultLang();
foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet
{
if ( $key == $current_lang )
{
$product->libelle = $_POST["libelle-".$key];
$product->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$product->note = dol_htmlcleanlastbr($_POST["note-".$key]);
}
else
{
$product->multilangs[$key]["libelle"] = $_POST["libelle-".$key];
$product->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$product->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]);
}
}
if ( $product->setMultiLangs() > 0 )
{
$_GET["action"] = '';
}
else
{
$_GET["action"] = 'edit';
$mesg = $product->mesg_error;
}
}
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
/*
* View
*/
llxHeader("","",$langs->trans("Translation"));
$form = new Form($db);
$formadmin=new FormAdmin($db);
$head=product_prepare_head($product, $user);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'translation', $titre, 0, $picto);
if ($mesg) print '<div class="error">'.$mesg.'</div>';
print '<table class="border" width="100%">';
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
print $form->showrefnav($product,'ref','',1,'ref');
print '</td>';
print '</tr>';
print '</table>';
if ($_GET["action"] == 'edit')
{
print '<form action="" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
foreach ( $product->multilangs as $key => $value)
{
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$product->multilangs[$key]["libelle"].'"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '</tr>';
print '</table>';
}
print '<br><center>';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
}
else
{
$cnt_trans = 0;
foreach ( $product->multilangs as $key => $value)
{
$cnt_trans++;
$s=picto_from_langcode($key);
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b><br>";
print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$product->multilangs[$key]["libelle"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$product->multilangs[$key]["description"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$product->multilangs[$key]["note"].'</td></tr>';
print '</table>';
}
if (!$cnt_trans ) print '<br>'. $langs->trans('NoTranslation');
}
print "</div>\n";
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '')
if ($user->rights->produit->creer || $user->rights->service->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=add&id='.$product->id.'">'.$langs->trans("Add").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=edit&id='.$product->id.'">'.$langs->trans("Update").'</a>';
}
print "\n</div>\n";
/*
* Form to add a new translation
*/
if ($_GET["action"] == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
{
print '<br>';
print '<form action="" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vadd">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Translation').'</td><td>';
print $formadmin->select_language('','forcelangprod',0,$product->multilangs);
print '</td></tr>';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$doleditor=new DolEditor('desc','','',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$doleditor=new DolEditor('note','','',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '</tr>';
print '</table>';
print '<br><center>';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
print '<br>';
}
llxFooter();
?>