84 global $conf, $langs, $user, $mysoc, $canvas;
87 $tmpobject =
new Product($this->db);
88 if (!empty($id) || !empty($ref)) {
89 $tmpobject->fetch($id, $ref);
91 $this->
object = $tmpobject;
93 foreach ($this->
object as $key => $value) {
94 $this->tpl[$key] = $value;
100 $this->tpl[
'canvas'] = $this->canvas;
103 $this->tpl[
'id'] = $this->id;
106 $this->tpl[
'ref'] = $this->ref;
109 $this->tpl[
'label'] = $this->label;
112 $this->tpl[
'description'] = nl2br($this->
description);
115 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
118 $this->tpl[
'note'] = nl2br($this->note);
120 if ($action ==
'create') {
122 $this->tpl[
'price'] = $this->price;
123 $this->tpl[
'price_min'] = $this->price_min;
124 $this->tpl[
'price_base_type'] = $form->selectPriceBaseType($this->price_base_type,
"price_base_type");
127 $this->tpl[
'tva_tx'] = $form->load_tva(
"tva_tx", -1, $mysoc,
'');
130 if ($action ==
'view') {
133 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
135 $titre = $langs->trans(
"CardProduct".$this->object->type);
141 $this->tpl[
'accountancyBuyCodeKey'] = $form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
142 $this->tpl[
'accountancyBuyCodeVal'] = $form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
145 $this->tpl[
'accountancySellCodeKey'] = $form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
146 $this->tpl[
'accountancySellCodeVal'] = $form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
149 $this->tpl[
'finished'] = $this->
object->finished;
150 $this->tpl[
'ref'] = $this->
object->ref;
151 $this->tpl[
'label'] = $this->
object->label;
152 $this->tpl[
'id'] = $this->
object->id;
153 $this->tpl[
'type'] = $this->
object->type;
154 $this->tpl[
'note'] = $this->
object->note_private;
155 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
158 $this->tpl[
'duration_value'] = $this->
object->duration_value;
160 if ($action ==
'create') {
162 $this->tpl[
'title'] = $langs->trans(
"NewService");
165 if ($action ==
'edit') {
166 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Service').
' : '.$this->
object->ref;
169 if ($action ==
'create' || $action ==
'edit') {
171 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
172 $this->tpl[
'status'] = $form->selectarray(
'statut', $statutarray, $this->object->status);
174 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
175 $this->tpl[
'status_buy'] = $form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
177 $this->tpl[
'description'] = $this->description;
178 $this->tpl[
'note'] = $this->note;
182 $duration_unit =
'<input name="duration_unit" type="radio" value="h"'.($this->object->duration_unit ==
'h' ?
' checked' :
'').
'>'.$langs->trans(
"Hour");
183 $duration_unit .=
' ';
184 $duration_unit .=
'<input name="duration_unit" type="radio" value="d"'.($this->object->duration_unit ==
'd' ?
' checked' :
'').
'>'.$langs->trans(
"Day");
185 $duration_unit .=
' ';
186 $duration_unit .=
'<input name="duration_unit" type="radio" value="w"'.($this->object->duration_unit ==
'w' ?
' checked' :
'').
'>'.$langs->trans(
"Week");
187 $duration_unit .=
' ';
188 $duration_unit .=
'<input name="duration_unit" type="radio" value="m"'.($this->object->duration_unit ==
'm' ?
' checked' :
'').
'>'.$langs->trans(
"Month");
189 $duration_unit .=
' ';
190 $duration_unit .=
'<input name="duration_unit" type="radio" value="y"'.($this->object->duration_unit ==
'y' ?
' checked' :
'').
'>'.$langs->trans(
"Year");
191 $this->tpl[
'duration_unit'] = $duration_unit;
194 if ($action ==
'view') {
196 $this->tpl[
'nblines'] = 4;
197 if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) {
198 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->service->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
203 if ($this->object->duration_value > 1) {
204 $dur = array(
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"Days"),
"w"=>$langs->trans(
"Weeks"),
"m"=>$langs->trans(
"Months"),
"y"=>$langs->trans(
"Years"));
205 } elseif ($this->object->duration_value > 0) {
206 $dur = array(
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"Day"),
"w"=>$langs->trans(
"Week"),
"m"=>$langs->trans(
"Month"),
"y"=>$langs->trans(
"Year"));
208 $this->tpl[
'duration_unit'] = $langs->trans($dur[$this->object->duration_unit]);
222 global $conf, $langs;
224 $this->field_list = array();
226 $sql =
"SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang";
227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_field_list";
228 $sql .=
" WHERE element = '".$this->db->escape($this->fieldListName).
"'";
229 $sql .=
" AND entity = ".$conf->entity;
230 $sql .=
" ORDER BY rang ASC";
232 $resql = $this->db->query($sql);
234 $num = $this->db->num_rows($resql);
238 $fieldlist = array();
240 $obj = $this->db->fetch_object($resql);
242 $fieldlist[
"id"] = $obj->rowid;
243 $fieldlist[
"name"] = $obj->name;
244 $fieldlist[
"alias"] = $obj->alias;
245 $fieldlist[
"title"] = $langs->trans($obj->title);
246 $fieldlist[
"align"] = $obj->align;
247 $fieldlist[
"sort"] = $obj->sort;
248 $fieldlist[
"search"] = $obj->search;
249 $fieldlist[
"visible"] = $obj->visible;
250 $fieldlist[
"enabled"] =
verifCond($obj->enabled);
251 $fieldlist[
"order"] = $obj->rang;
253 array_push($this->field_list, $fieldlist);
257 $this->db->free($resql);