23 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39 public $field_list = array();
57 public function __construct($db, $targetmodule, $canvas, $card)
60 $this->targetmodule = $targetmodule;
61 $this->canvas = $canvas;
64 $this->module =
"service";
65 $this->
name =
"service";
66 $this->definition =
"Services canvas";
67 $this->fieldListName =
"product_service";
68 $this->next_prev_filter =
"canvas='service'";
84 global $limit, $offset, $sortfield, $sortorder;
85 global $conf, $langs, $user, $mysoc, $canvas;
86 global
$form, $formproduct;
89 if (!empty($id) || !empty($ref)) {
90 $tmpobject->fetch($id, $ref);
92 $this->
object = $tmpobject;
94 foreach ($this->
object as $key => $value) {
95 $this->tpl[$key] = $value;
101 $this->tpl[
'canvas'] = $this->canvas;
104 $this->tpl[
'id'] = $this->id;
107 $this->tpl[
'ref'] = $this->ref;
110 $this->tpl[
'label'] = $this->label;
113 $this->tpl[
'description'] = nl2br($this->
description);
116 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
119 $this->tpl[
'note'] = nl2br($this->note);
121 if ($action ==
'create') {
123 $this->tpl[
'price'] = $this->price;
124 $this->tpl[
'price_min'] = $this->price_min;
125 $this->tpl[
'price_base_type'] =
$form->selectPriceBaseType($this->price_base_type,
"price_base_type");
128 $this->tpl[
'tva_tx'] =
$form->load_tva(
"tva_tx", -1, $mysoc,
'');
131 if ($action ==
'view') {
134 $this->tpl[
'showrefnav'] =
$form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
136 $titre = $langs->trans(
"CardProduct".$this->object->type);
142 $this->tpl[
'accountancyBuyCodeKey'] =
$form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
143 $this->tpl[
'accountancyBuyCodeVal'] =
$form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
146 $this->tpl[
'accountancySellCodeKey'] =
$form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
147 $this->tpl[
'accountancySellCodeVal'] =
$form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
150 $this->tpl[
'finished'] = $this->
object->finished;
151 $this->tpl[
'ref'] = $this->
object->ref;
152 $this->tpl[
'label'] = $this->
object->label;
153 $this->tpl[
'id'] = $this->
object->id;
154 $this->tpl[
'type'] = $this->
object->type;
155 $this->tpl[
'note'] = $this->
object->note;
156 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
159 $this->tpl[
'duration_value'] = $this->
object->duration_value;
161 if ($action ==
'create') {
163 $this->tpl[
'title'] = $langs->trans(
"NewService");
166 if ($action ==
'edit') {
167 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Service').
' : '.$this->
object->ref;
170 if ($action ==
'create' || $action ==
'edit') {
172 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
173 $this->tpl[
'status'] =
$form->selectarray(
'statut', $statutarray, $this->object->status);
175 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
176 $this->tpl[
'status_buy'] =
$form->selectarray(
'statut_buy', $statutarray, $this->object->status_buy);
178 $this->tpl[
'description'] = $this->description;
179 $this->tpl[
'note'] = $this->note;
183 $duration_unit =
'<input name="duration_unit" type="radio" value="h"'.($this->object->duration_unit ==
'h' ?
' checked' :
'').
'>'.$langs->trans(
"Hour");
184 $duration_unit .=
' ';
185 $duration_unit .=
'<input name="duration_unit" type="radio" value="d"'.($this->object->duration_unit ==
'd' ?
' checked' :
'').
'>'.$langs->trans(
"Day");
186 $duration_unit .=
' ';
187 $duration_unit .=
'<input name="duration_unit" type="radio" value="w"'.($this->object->duration_unit ==
'w' ?
' checked' :
'').
'>'.$langs->trans(
"Week");
188 $duration_unit .=
' ';
189 $duration_unit .=
'<input name="duration_unit" type="radio" value="m"'.($this->object->duration_unit ==
'm' ?
' checked' :
'').
'>'.$langs->trans(
"Month");
190 $duration_unit .=
' ';
191 $duration_unit .=
'<input name="duration_unit" type="radio" value="y"'.($this->object->duration_unit ==
'y' ?
' checked' :
'').
'>'.$langs->trans(
"Year");
192 $this->tpl[
'duration_unit'] = $duration_unit;
195 if ($action ==
'view') {
197 $this->tpl[
'nblines'] = 4;
198 if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) {
199 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->service->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
204 if ($this->object->duration_value > 1) {
205 $dur = array(
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"Days"),
"w"=>$langs->trans(
"Weeks"),
"m"=>$langs->trans(
"Months"),
"y"=>$langs->trans(
"Years"));
206 } elseif ($this->object->duration_value > 0) {
207 $dur = array(
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"Day"),
"w"=>$langs->trans(
"Week"),
"m"=>$langs->trans(
"Month"),
"y"=>$langs->trans(
"Year"));
209 $this->tpl[
'duration_unit'] = $langs->trans($dur[$this->object->duration_unit]);
223 global $conf, $langs;
225 $this->field_list = array();
227 $sql =
"SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang";
228 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_field_list";
229 $sql .=
" WHERE element = '".$this->db->escape($this->fieldListName).
"'";
230 $sql .=
" AND entity = ".$conf->entity;
231 $sql .=
" ORDER BY rang ASC";
239 $fieldlist = array();
241 $obj = $this->
db->fetch_object(
$resql);
243 $fieldlist[
"id"] = $obj->rowid;
244 $fieldlist[
"name"] = $obj->name;
245 $fieldlist[
"alias"] = $obj->alias;
246 $fieldlist[
"title"] = $langs->trans($obj->title);
247 $fieldlist[
"align"] = $obj->align;
248 $fieldlist[
"sort"] = $obj->sort;
249 $fieldlist[
"search"] = $obj->search;
250 $fieldlist[
"visible"] = $obj->visible;
251 $fieldlist[
"enabled"] =
verifCond($obj->enabled);
252 $fieldlist[
"order"] = $obj->rang;
254 array_push($this->field_list, $fieldlist);
Class with controller methods for product canvas.
getFieldListCanvas()
Fetch field list.
assign_values(&$action, $id=0, $ref='')
Assign custom values for canvas (for example into this->tpl to be used by templates)
__construct($db, $targetmodule, $canvas, $card)
Constructor.
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.