80 global $conf, $langs, $user, $mysoc, $canvas;
81 global $form, $formproduct;
83 $tmpobject =
new Product($this->db);
84 if (!empty($id) || !empty($ref)) {
85 $tmpobject->fetch($id, $ref);
87 $this->
object = $tmpobject;
89 foreach ($this->
object as $key => $value) {
90 $this->tpl[$key] = $value;
96 $this->tpl[
'canvas'] = $this->canvas;
99 $this->tpl[
'id'] = $this->
object->id;
102 $this->tpl[
'ref'] = $this->
object->ref;
105 $this->tpl[
'label'] = $this->
object->label;
108 $this->tpl[
'description'] = nl2br($this->
description);
111 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
114 $this->tpl[
'note'] = $this->
object->note_private;
116 if ($action ==
'create') {
118 $this->tpl[
'price'] = $this->
object->price;
119 $this->tpl[
'price_min'] = $this->
object->price_min;
120 $this->tpl[
'price_base_type'] = $form->selectPriceBaseType($this->price_base_type,
"price_base_type");
123 $this->tpl[
'tva_tx'] = $form->load_tva(
"tva_tx", -1, $mysoc,
'');
126 if ($action ==
'view') {
129 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
131 $titre = $langs->trans(
"CardProduct".$this->object->type);
137 $this->tpl[
'accountancyBuyCodeKey'] = $form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
138 $this->tpl[
'accountancyBuyCodeVal'] = $form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
141 $this->tpl[
'accountancySellCodeKey'] = $form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
142 $this->tpl[
'accountancySellCodeVal'] = $form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
145 $this->tpl[
'finished'] = $this->
object->finished;
146 $this->tpl[
'ref'] = $this->
object->ref;
147 $this->tpl[
'label'] = $this->
object->label;
148 $this->tpl[
'id'] = $this->
object->id;
149 $this->tpl[
'type'] = $this->
object->type;
150 $this->tpl[
'note'] = $this->
object->note_private;
151 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
153 if ($action ==
'create') {
155 $this->tpl[
'title'] = $langs->trans(
"NewProduct");
158 if ($action ==
'edit') {
159 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Product').
' : '.$this->
object->ref;
162 if ($action ==
'create' || $action ==
'edit') {
164 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
165 $this->tpl[
'status'] = $form->selectarray(
'statut', $statutarray, $this->object->status);
167 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
168 $this->tpl[
'status_buy'] = $form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
170 $this->tpl[
'description'] = $this->
object->description;
171 $this->tpl[
'note'] = $this->
object->note_private;
174 $statutarray = array(
'1' => $langs->trans(
"Finished"),
'0' => $langs->trans(
"RowMaterial"));
175 $this->tpl[
'finished'] = $form->selectarray(
'finished', $statutarray, $this->object->finished);
178 $this->tpl[
'weight'] = $this->
object->weight;
179 $this->tpl[
'weight_units'] = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $this->object->weight_units, 0, 2);
182 $this->tpl[
'length'] = $this->
object->length;
183 $this->tpl[
'length_units'] = $formproduct->selectMeasuringUnits(
"length_units",
"size", $this->object->length_units, 0, 2);
186 $this->tpl[
'surface'] = $this->
object->surface;
187 $this->tpl[
'surface_units'] = $formproduct->selectMeasuringUnits(
"surface_units",
"surface", $this->object->surface_units, 0, 2);
190 $this->tpl[
'volume'] = $this->
object->volume;
191 $this->tpl[
'volume_units'] = $formproduct->selectMeasuringUnits(
"volume_units",
"volume", $this->object->volume_units, 0, 2);
194 if ($action ==
'view') {
196 $this->tpl[
'nblines'] = 4;
197 if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) {
198 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->product->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
202 $this->tpl[
'finished'] = $this->
object->getLibFinished();
205 if ($this->object->weight !=
'') {
206 $this->tpl[
'weight'] = $this->
object->weight.
" ".
measuringUnitString(0,
"weight", $this->object->weight_units);
210 if ($this->object->length !=
'') {
211 $this->tpl[
'length'] = $this->
object->length.
" ".
measuringUnitString(0,
"size", $this->object->length_units);
215 if ($this->object->surface !=
'') {
216 $this->tpl[
'surface'] = $this->
object->surface.
" ".
measuringUnitString(0,
"surface", $this->object->surface_units);
220 if ($this->object->volume !=
'') {
221 $this->tpl[
'volume'] = $this->
object->volume.
" ".
measuringUnitString(0,
"volume", $this->object->volume_units);