23 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
44 public $price_base_type;
45 public $accountancy_code_sell;
46 public $accountancy_code_buy;
47 public $fieldListName;
48 public $next_prev_filter;
57 public $field_list = array();
67 public $errors = array();
79 public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
82 $this->dirmodule = $dirmodule;
83 $this->targetmodule = $targetmodule;
84 $this->canvas = $canvas;
87 $this->
name =
"product";
88 $this->definition =
"Product canvas (default)";
89 $this->fieldListName =
"product_default";
90 $this->next_prev_filter =
"canvas='product'";
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);
262 global $conf, $langs;
264 $this->field_list = array();
266 $sql =
"SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang";
267 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_field_list";
268 $sql .=
" WHERE element = '".$this->db->escape($this->fieldListName).
"'";
269 $sql .=
" AND entity = ".$conf->entity;
270 $sql .=
" ORDER BY rang ASC";
272 $resql = $this->db->query(
$sql);
274 $num = $this->db->num_rows($resql);
278 $fieldlist = array();
280 $obj = $this->db->fetch_object($resql);
282 $fieldlist[
"id"] = $obj->rowid;
283 $fieldlist[
"name"] = $obj->name;
284 $fieldlist[
"alias"] = $obj->alias;
285 $fieldlist[
"title"] = $langs->trans($obj->title);
286 $fieldlist[
"align"] = $obj->align;
287 $fieldlist[
"sort"] = $obj->sort;
288 $fieldlist[
"search"] = $obj->search;
289 $fieldlist[
"visible"] = $obj->visible;
290 $fieldlist[
"enabled"] =
verifCond($obj->enabled);
291 $fieldlist[
"order"] = $obj->rang;
293 array_push($this->field_list, $fieldlist);
297 $this->db->free($resql);
Class with controller methods for product canvas.
getFieldListCanvas()
Fetch field list.
__construct($db, $dirmodule, $targetmodule, $canvas, $card)
Constructor.
assign_values(&$action, $id=0, $ref='')
Assign custom values for canvas (for example into this->tpl to be used by templates)
Class to manage products or services.
const TYPE_SERVICE
Service.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formatted error messages to output (Used to show messages on html output).
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
$conf db name
Only used if Module[ID]Name translation string is not found.