106 global $conf, $langs, $user, $mysoc, $canvas;
107 global $form, $formproduct;
109 $tmpobject =
new Product($this->db);
110 if (!empty($id) || !empty($ref)) {
111 $tmpobject->fetch($id, $ref);
113 $this->
object = $tmpobject;
115 foreach ($this->
object as $key => $value) {
116 $this->tpl[$key] = $value;
122 $this->tpl[
'canvas'] = $this->canvas;
125 $this->tpl[
'id'] = $this->
object->id;
128 $this->tpl[
'ref'] = $this->
object->ref;
131 $this->tpl[
'label'] = $this->
object->label;
134 $this->tpl[
'description'] = nl2br($this->
description);
137 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
140 $this->tpl[
'note'] = $this->
object->note_private;
142 if ($action ==
'create') {
144 $this->tpl[
'price'] = $this->
object->price;
145 $this->tpl[
'price_min'] = $this->
object->price_min;
146 $this->tpl[
'price_base_type'] = $form->selectPriceBaseType($this->price_base_type,
"price_base_type");
149 $this->tpl[
'tva_tx'] = $form->load_tva(
"tva_tx", -1, $mysoc,
'');
152 if ($action ==
'view') {
155 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
157 $titre = $langs->trans(
"CardProduct".$this->object->type);
163 $this->tpl[
'accountancyBuyCodeKey'] = $form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
164 $this->tpl[
'accountancyBuyCodeVal'] = $form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
167 $this->tpl[
'accountancySellCodeKey'] = $form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
168 $this->tpl[
'accountancySellCodeVal'] = $form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
171 $this->tpl[
'finished'] = $this->
object->finished;
172 $this->tpl[
'ref'] = $this->
object->ref;
173 $this->tpl[
'label'] = $this->
object->label;
174 $this->tpl[
'id'] = $this->
object->id;
175 $this->tpl[
'type'] = $this->
object->type;
176 $this->tpl[
'note'] = $this->
object->note_private;
177 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
179 if ($action ==
'create') {
181 $this->tpl[
'title'] = $langs->trans(
"NewProduct");
184 if ($action ==
'edit') {
185 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Product').
' : '.$this->
object->ref;
188 if ($action ==
'create' || $action ==
'edit') {
190 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
191 $this->tpl[
'status'] = $form->selectarray(
'statut', $statutarray, $this->object->status);
193 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
194 $this->tpl[
'status_buy'] = $form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
196 $this->tpl[
'description'] = $this->
object->description;
197 $this->tpl[
'note'] = $this->
object->note_private;
200 $statutarray = array(
'1' => $langs->trans(
"Finished"),
'0' => $langs->trans(
"RowMaterial"));
201 $this->tpl[
'finished'] = $form->selectarray(
'finished', $statutarray, $this->object->finished);
204 $this->tpl[
'weight'] = $this->
object->weight;
205 $this->tpl[
'weight_units'] = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $this->object->weight_units, 0, 2);
208 $this->tpl[
'length'] = $this->
object->length;
209 $this->tpl[
'length_units'] = $formproduct->selectMeasuringUnits(
"length_units",
"size", $this->object->length_units, 0, 2);
212 $this->tpl[
'surface'] = $this->
object->surface;
213 $this->tpl[
'surface_units'] = $formproduct->selectMeasuringUnits(
"surface_units",
"surface", $this->object->surface_units, 0, 2);
216 $this->tpl[
'volume'] = $this->
object->volume;
217 $this->tpl[
'volume_units'] = $formproduct->selectMeasuringUnits(
"volume_units",
"volume", $this->object->volume_units, 0, 2);
220 if ($action ==
'view') {
222 $this->tpl[
'nblines'] = 4;
223 if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) {
224 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->product->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
228 $this->tpl[
'finished'] = $this->
object->getLibFinished();
231 if ($this->object->weight !=
'') {
232 $this->tpl[
'weight'] = $this->
object->weight.
" ".
measuringUnitString(0,
"weight", $this->object->weight_units);
236 if ($this->object->length !=
'') {
237 $this->tpl[
'length'] = $this->
object->length.
" ".
measuringUnitString(0,
"size", $this->object->length_units);
241 if ($this->object->surface !=
'') {
242 $this->tpl[
'surface'] = $this->
object->surface.
" ".
measuringUnitString(0,
"surface", $this->object->surface_units);
246 if ($this->object->volume !=
'') {
247 $this->tpl[
'volume'] = $this->
object->volume.
" ".
measuringUnitString(0,
"volume", $this->object->volume_units);