150 global
$conf, $langs, $user, $mysoc, $canvas;
151 global $form, $formproduct;
153 '@phan-var-force Form $form';
154 '@phan-var-force FormProduct $formproduct';
156 $tmpobject =
new Product($this->db);
157 if (!empty(
$id) || !empty($ref)) {
158 $tmpobject->fetch(
$id, $ref);
160 $this->
object = $tmpobject;
162 foreach ($this->
object as $key => $value) {
163 $this->tpl[$key] = $value;
169 $this->tpl[
'canvas'] = $this->canvas;
172 $this->tpl[
'id'] = $this->
object->id;
175 $this->tpl[
'ref'] = $this->
object->ref;
178 $this->tpl[
'label'] = $this->
object->label;
181 $this->tpl[
'description'] = nl2br($this->
description);
184 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
187 $this->tpl[
'note'] = $this->
object->note_private;
189 if ($action ==
'create') {
191 $this->tpl[
'price'] = $this->
object->price;
192 $this->tpl[
'price_min'] = $this->
object->price_min;
193 $this->tpl[
'price_base_type'] = $form->selectPriceBaseType($this->price_base_type,
"price_base_type");
196 $this->tpl[
'tva_tx'] = $form->load_tva(
"tva_tx", -1, $mysoc,
null);
199 if ($action ==
'view') {
202 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
204 $titre = $langs->trans(
"CardProduct".$this->object->type);
210 $this->tpl[
'accountancyBuyCodeKey'] = $form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
211 $this->tpl[
'accountancyBuyCodeVal'] = $form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
214 $this->tpl[
'accountancySellCodeKey'] = $form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
215 $this->tpl[
'accountancySellCodeVal'] = $form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
218 $this->tpl[
'finished'] = $this->
object->finished;
219 $this->tpl[
'ref'] = $this->
object->ref;
220 $this->tpl[
'label'] = $this->
object->label;
221 $this->tpl[
'id'] = $this->
object->id;
222 $this->tpl[
'type'] = $this->
object->type;
223 $this->tpl[
'note'] = $this->
object->note_private;
224 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
226 if ($action ==
'create') {
228 $this->tpl[
'title'] = $langs->trans(
"NewProduct");
231 if ($action ==
'edit') {
232 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Product').
' : '.$this->
object->ref;
235 if ($action ==
'create' || $action ==
'edit') {
237 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
238 $this->tpl[
'status'] = $form->selectarray(
'statut', $statutarray, $this->object->status);
240 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
241 $this->tpl[
'status_buy'] = $form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
243 $this->tpl[
'description'] = $this->
object->description;
244 $this->tpl[
'note'] = $this->
object->note_private;
247 $statutarray = array(
'1' => $langs->trans(
"Finished"),
'0' => $langs->trans(
"RowMaterial"));
248 $this->tpl[
'finished'] = $form->selectarray(
'finished', $statutarray, $this->object->finished);
251 $this->tpl[
'weight'] = $this->
object->weight;
252 $this->tpl[
'weight_units'] = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $this->object->weight_units, 0, 2);
255 $this->tpl[
'length'] = $this->
object->length;
256 $this->tpl[
'length_units'] = $formproduct->selectMeasuringUnits(
"length_units",
"size", $this->object->length_units, 0, 2);
259 $this->tpl[
'surface'] = $this->
object->surface;
260 $this->tpl[
'surface_units'] = $formproduct->selectMeasuringUnits(
"surface_units",
"surface", $this->object->surface_units, 0, 2);
263 $this->tpl[
'volume'] = $this->
object->volume;
264 $this->tpl[
'volume_units'] = $formproduct->selectMeasuringUnits(
"volume_units",
"volume", $this->object->volume_units, 0, 2);
267 if ($action ==
'view') {
269 $this->tpl[
'nblines'] = 4;
270 if ($this->object->is_photo_available(
$conf->product->multidir_output[$this->object->entity])) {
271 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->product->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
275 $this->tpl[
'finished'] = $this->
object->getLibFinished();
278 if ($this->object->weight !=
'') {
279 $this->tpl[
'weight'] = $this->
object->weight.
" ".
measuringUnitString(0,
"weight", $this->object->weight_units);
283 if ($this->object->length !=
'') {
284 $this->tpl[
'length'] = $this->
object->length.
" ".
measuringUnitString(0,
"size", $this->object->length_units);
288 if ($this->object->surface !=
'') {
289 $this->tpl[
'surface'] = $this->
object->surface.
" ".
measuringUnitString(0,
"surface", $this->object->surface_units);
293 if ($this->object->volume !=
'') {
294 $this->tpl[
'volume'] = $this->
object->volume.
" ".
measuringUnitString(0,
"volume", $this->object->volume_units);
309 global
$conf, $langs;
311 $this->field_list = array();
313 $sql =
"SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang";
314 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_field_list";
315 $sql .=
" WHERE element = '".$this->db->escape($this->fieldListName).
"'";
316 $sql .=
" AND entity = ".$conf->entity;
317 $sql .=
" ORDER BY rang ASC";
319 $resql = $this->db->query($sql);
321 $num = $this->db->num_rows($resql);
325 $fieldlist = array();
327 $obj = $this->db->fetch_object($resql);
329 $fieldlist[
"id"] = $obj->rowid;
330 $fieldlist[
"name"] = $obj->name;
331 $fieldlist[
"alias"] = $obj->alias;
332 $fieldlist[
"title"] = $langs->trans($obj->title);
333 $fieldlist[
"align"] = $obj->align;
334 $fieldlist[
"sort"] = $obj->sort;
335 $fieldlist[
"search"] = $obj->search;
336 $fieldlist[
"visible"] = $obj->visible;
337 $fieldlist[
"enabled"] =
verifCond($obj->enabled);
338 $fieldlist[
"order"] = $obj->rang;
339 array_push($this->field_list, $fieldlist);
343 $this->db->free($resql);