23 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
41 public $field_list = array();
53 public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
56 $this->dirmodule = $dirmodule;
57 $this->targetmodule = $targetmodule;
58 $this->canvas = $canvas;
61 $this->
name =
"product";
62 $this->definition =
"Product canvas (défaut)";
63 $this->fieldListName =
"product_default";
64 $this->next_prev_filter =
"canvas='product'";
80 global $limit, $offset, $sortfield, $sortorder;
81 global $conf, $langs, $user, $mysoc, $canvas;
82 global
$form, $formproduct;
85 if (!empty($id) || !empty($ref)) {
86 $tmpobject->fetch($id, $ref);
88 $this->
object = $tmpobject;
90 foreach ($this->
object as $key => $value) {
91 $this->tpl[$key] = $value;
97 $this->tpl[
'canvas'] = $this->canvas;
100 $this->tpl[
'id'] = $this->
object->id;
103 $this->tpl[
'ref'] = $this->
object->ref;
106 $this->tpl[
'label'] = $this->
object->label;
109 $this->tpl[
'description'] = nl2br($this->
description);
112 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
115 $this->tpl[
'note'] = nl2br($this->object->note_private);
117 if ($action ==
'create') {
119 $this->tpl[
'price'] = $this->
object->price;
120 $this->tpl[
'price_min'] = $this->
object->price_min;
121 $this->tpl[
'price_base_type'] =
$form->selectPriceBaseType($this->price_base_type,
"price_base_type");
124 $this->tpl[
'tva_tx'] =
$form->load_tva(
"tva_tx", -1, $mysoc,
'');
127 if ($action ==
'view') {
130 $this->tpl[
'showrefnav'] =
$form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
132 $titre = $langs->trans(
"CardProduct".$this->object->type);
138 $this->tpl[
'accountancyBuyCodeKey'] =
$form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
139 $this->tpl[
'accountancyBuyCodeVal'] =
$form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
142 $this->tpl[
'accountancySellCodeKey'] =
$form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
143 $this->tpl[
'accountancySellCodeVal'] =
$form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
146 $this->tpl[
'finished'] = $this->
object->finished;
147 $this->tpl[
'ref'] = $this->
object->ref;
148 $this->tpl[
'label'] = $this->
object->label;
149 $this->tpl[
'id'] = $this->
object->id;
150 $this->tpl[
'type'] = $this->
object->type;
151 $this->tpl[
'note'] = $this->
object->note_private;
152 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
154 if ($action ==
'create') {
156 $this->tpl[
'title'] = $langs->trans(
"NewProduct");
159 if ($action ==
'edit') {
160 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Product').
' : '.$this->
object->ref;
163 if ($action ==
'create' || $action ==
'edit') {
165 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
166 $this->tpl[
'status'] =
$form->selectarray(
'statut', $statutarray, $this->object->status);
168 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
169 $this->tpl[
'status_buy'] =
$form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
171 $this->tpl[
'description'] = $this->
object->description;
172 $this->tpl[
'note'] = $this->
object->note;
175 $statutarray = array(
'1' => $langs->trans(
"Finished"),
'0' => $langs->trans(
"RowMaterial"));
176 $this->tpl[
'finished'] =
$form->selectarray(
'finished', $statutarray, $this->object->finished);
179 $this->tpl[
'weight'] = $this->
object->weight;
180 $this->tpl[
'weight_units'] = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $this->object->weight_units, 0, 2);
183 $this->tpl[
'length'] = $this->
object->length;
184 $this->tpl[
'length_units'] = $formproduct->selectMeasuringUnits(
"length_units",
"size", $this->object->length_units, 0, 2);
187 $this->tpl[
'surface'] = $this->
object->surface;
188 $this->tpl[
'surface_units'] = $formproduct->selectMeasuringUnits(
"surface_units",
"surface", $this->object->surface_units, 0, 2);
191 $this->tpl[
'volume'] = $this->
object->volume;
192 $this->tpl[
'volume_units'] = $formproduct->selectMeasuringUnits(
"volume_units",
"volume", $this->object->volume_units, 0, 2);
195 if ($action ==
'view') {
197 $this->tpl[
'nblines'] = 4;
198 if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) {
199 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->product->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
203 $this->tpl[
'finished'] = $this->
object->getLibFinished();
206 if ($this->object->weight !=
'') {
207 $this->tpl[
'weight'] = $this->
object->weight.
" ".
measuringUnitString(0,
"weight", $this->object->weight_units);
211 if ($this->object->length !=
'') {
212 $this->tpl[
'length'] = $this->
object->length.
" ".
measuringUnitString(0,
"size", $this->object->length_units);
216 if ($this->object->surface !=
'') {
217 $this->tpl[
'surface'] = $this->
object->surface.
" ".
measuringUnitString(0,
"surface", $this->object->surface_units);
221 if ($this->object->volume !=
'') {
222 $this->tpl[
'volume'] = $this->
object->volume.
" ".
measuringUnitString(0,
"volume", $this->object->volume_units);
237 global $conf, $langs;
239 $this->field_list = array();
241 $sql =
"SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang";
242 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_field_list";
243 $sql .=
" WHERE element = '".$this->db->escape($this->fieldListName).
"'";
244 $sql .=
" AND entity = ".$conf->entity;
245 $sql .=
" ORDER BY rang ASC";
253 $fieldlist = array();
255 $obj = $this->
db->fetch_object(
$resql);
257 $fieldlist[
"id"] = $obj->rowid;
258 $fieldlist[
"name"] = $obj->name;
259 $fieldlist[
"alias"] = $obj->alias;
260 $fieldlist[
"title"] = $langs->trans($obj->title);
261 $fieldlist[
"align"] = $obj->align;
262 $fieldlist[
"sort"] = $obj->sort;
263 $fieldlist[
"search"] = $obj->search;
264 $fieldlist[
"visible"] = $obj->visible;
265 $fieldlist[
"enabled"] =
verifCond($obj->enabled);
266 $fieldlist[
"order"] = $obj->rang;
268 array_push($this->field_list, $fieldlist);
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('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formated error messages to output (Used to show messages on html output).
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
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.
$conf db
API class for accounts.