107 global $conf, $langs, $user, $mysoc, $canvas;
108 global $form, $formproduct;
110 $tmpobject =
new Product($this->db);
111 if (!empty($id) || !empty($ref)) {
112 $tmpobject->fetch($id, $ref);
114 $this->
object = $tmpobject;
116 foreach ($this->
object as $key => $value) {
117 $this->tpl[$key] = $value;
123 $this->tpl[
'canvas'] = $this->canvas;
126 $this->tpl[
'id'] = $this->
object->id;
129 $this->tpl[
'ref'] = $this->
object->ref;
132 $this->tpl[
'label'] = $this->
object->label;
135 $this->tpl[
'description'] = nl2br($this->
description);
138 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
141 $this->tpl[
'note'] = $this->
object->note_private;
143 if ($action ==
'create') {
145 $this->tpl[
'price'] = $this->
object->price;
146 $this->tpl[
'price_min'] = $this->
object->price_min;
147 $this->tpl[
'price_base_type'] = $form->selectPriceBaseType($this->price_base_type,
"price_base_type");
150 $this->tpl[
'tva_tx'] = $form->load_tva(
"tva_tx", -1, $mysoc,
'');
153 if ($action ==
'view') {
156 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
158 $titre = $langs->trans(
"CardProduct".$this->object->type);
164 $this->tpl[
'accountancyBuyCodeKey'] = $form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
165 $this->tpl[
'accountancyBuyCodeVal'] = $form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
168 $this->tpl[
'accountancySellCodeKey'] = $form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
169 $this->tpl[
'accountancySellCodeVal'] = $form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
172 $this->tpl[
'finished'] = $this->
object->finished;
173 $this->tpl[
'ref'] = $this->
object->ref;
174 $this->tpl[
'label'] = $this->
object->label;
175 $this->tpl[
'id'] = $this->
object->id;
176 $this->tpl[
'type'] = $this->
object->type;
177 $this->tpl[
'note'] = $this->
object->note_private;
178 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
180 if ($action ==
'create') {
182 $this->tpl[
'title'] = $langs->trans(
"NewProduct");
185 if ($action ==
'edit') {
186 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Product').
' : '.$this->
object->ref;
189 if ($action ==
'create' || $action ==
'edit') {
191 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
192 $this->tpl[
'status'] = $form->selectarray(
'statut', $statutarray, $this->object->status);
194 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
195 $this->tpl[
'status_buy'] = $form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
197 $this->tpl[
'description'] = $this->
object->description;
198 $this->tpl[
'note'] = $this->
object->note_private;
201 $statutarray = array(
'1' => $langs->trans(
"Finished"),
'0' => $langs->trans(
"RowMaterial"));
202 $this->tpl[
'finished'] = $form->selectarray(
'finished', $statutarray, $this->object->finished);
205 $this->tpl[
'weight'] = $this->
object->weight;
206 $this->tpl[
'weight_units'] = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $this->object->weight_units, 0, 2);
209 $this->tpl[
'length'] = $this->
object->length;
210 $this->tpl[
'length_units'] = $formproduct->selectMeasuringUnits(
"length_units",
"size", $this->object->length_units, 0, 2);
213 $this->tpl[
'surface'] = $this->
object->surface;
214 $this->tpl[
'surface_units'] = $formproduct->selectMeasuringUnits(
"surface_units",
"surface", $this->object->surface_units, 0, 2);
217 $this->tpl[
'volume'] = $this->
object->volume;
218 $this->tpl[
'volume_units'] = $formproduct->selectMeasuringUnits(
"volume_units",
"volume", $this->object->volume_units, 0, 2);
221 if ($action ==
'view') {
223 $this->tpl[
'nblines'] = 4;
224 if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) {
225 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->product->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
229 $this->tpl[
'finished'] = $this->
object->getLibFinished();
232 if ($this->object->weight !=
'') {
233 $this->tpl[
'weight'] = $this->
object->weight.
" ".
measuringUnitString(0,
"weight", $this->object->weight_units);
237 if ($this->object->length !=
'') {
238 $this->tpl[
'length'] = $this->
object->length.
" ".
measuringUnitString(0,
"size", $this->object->length_units);
242 if ($this->object->surface !=
'') {
243 $this->tpl[
'surface'] = $this->
object->surface.
" ".
measuringUnitString(0,
"surface", $this->object->surface_units);
247 if ($this->object->volume !=
'') {
248 $this->tpl[
'volume'] = $this->
object->volume.
" ".
measuringUnitString(0,
"volume", $this->object->volume_units);