23 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39 public $field_list = array();
40 public $list_datas = array();
51 public function __construct($db, $targetmodule, $canvas, $card)
54 $this->targetmodule = $targetmodule;
55 $this->canvas = $canvas;
58 $this->module =
"service";
59 $this->
name =
"service";
60 $this->definition =
"Services canvas";
61 $this->fieldListName =
"product_service";
62 $this->next_prev_filter =
"canvas='service'";
78 global $limit, $offset, $sortfield, $sortorder;
79 global $conf, $langs, $user, $mysoc, $canvas;
80 global $form, $formproduct;
83 if (!empty($id) || !empty($ref)) $tmpobject->fetch($id, $ref);
84 $this->
object = $tmpobject;
88 foreach ($this->
object as $key => $value)
90 $this->tpl[$key] = $value;
96 $this->tpl[
'canvas'] = $this->canvas;
99 $this->tpl[
'id'] = $this->id;
102 $this->tpl[
'ref'] = $this->ref;
105 $this->tpl[
'label'] = $this->label;
108 $this->tpl[
'description'] = nl2br($this->
description);
111 $this->tpl[
'status'] = $this->
object->getLibStatut(2);
114 $this->tpl[
'note'] = nl2br($this->
note);
116 if ($action ==
'create')
119 $this->tpl[
'price'] = $this->price;
120 $this->tpl[
'price_min'] = $this->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')
131 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'ref',
'', 1,
'ref');
133 $titre = $langs->trans(
"CardProduct".$this->object->type);
139 $this->tpl[
'accountancyBuyCodeKey'] = $form->editfieldkey(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
140 $this->tpl[
'accountancyBuyCodeVal'] = $form->editfieldval(
"ProductAccountancyBuyCode",
'productaccountancycodesell', $this->accountancy_code_sell, $this, $user->rights->produit->creer);
143 $this->tpl[
'accountancySellCodeKey'] = $form->editfieldkey(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
144 $this->tpl[
'accountancySellCodeVal'] = $form->editfieldval(
"ProductAccountancySellCode",
'productaccountancycodebuy', $this->accountancy_code_buy, $this, $user->rights->produit->creer);
147 $this->tpl[
'finished'] = $this->
object->finished;
148 $this->tpl[
'ref'] = $this->
object->ref;
149 $this->tpl[
'label'] = $this->
object->label;
150 $this->tpl[
'id'] = $this->
object->id;
151 $this->tpl[
'type'] = $this->
object->type;
152 $this->tpl[
'note'] = $this->
object->note;
153 $this->tpl[
'seuil_stock_alerte'] = $this->
object->seuil_stock_alerte;
156 $this->tpl[
'duration_value'] = $this->
object->duration_value;
158 if ($action ==
'create')
161 $this->tpl[
'title'] = $langs->trans(
"NewService");
164 if ($action ==
'edit')
166 $this->tpl[
'title'] = $langs->trans(
'Modify').
' '.$langs->trans(
'Service').
' : '.$this->
object->ref;
169 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')
198 $this->tpl[
'nblines'] = 4;
199 if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity]))
201 $this->tpl[
'photos'] = $this->
object->show_photos(
'product', $conf->service->multidir_output[$this->object->entity], 1, 1, 0, 0, 0, 80);
205 if ($this->object->duration_value > 1)
207 $dur = array(
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"Days"),
"w"=>$langs->trans(
"Weeks"),
"m"=>$langs->trans(
"Months"),
"y"=>$langs->trans(
"Years"));
208 } elseif ($this->object->duration_value > 0)
210 $dur = array(
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"Day"),
"w"=>$langs->trans(
"Week"),
"m"=>$langs->trans(
"Month"),
"y"=>$langs->trans(
"Year"));
212 $this->tpl[
'duration_unit'] = $langs->trans($dur[$this->object->duration_unit]);
217 if ($action ==
'list')
219 $this->
LoadListDatas($limit, $offset, $sortfield, $sortorder);
231 global $conf, $langs;
233 $this->field_list = array();
235 $sql =
"SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang";
236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_field_list";
237 $sql .=
" WHERE element = '".$this->db->escape($this->fieldListName).
"'";
238 $sql .=
" AND entity = ".$conf->entity;
239 $sql .=
" ORDER BY rang ASC";
249 $fieldlist = array();
251 $obj = $this->
db->fetch_object(
$resql);
253 $fieldlist[
"id"] = $obj->rowid;
254 $fieldlist[
"name"] = $obj->name;
255 $fieldlist[
"alias"] = $obj->alias;
256 $fieldlist[
"title"] = $langs->trans($obj->title);
257 $fieldlist[
"align"] = $obj->align;
258 $fieldlist[
"sort"] = $obj->sort;
259 $fieldlist[
"search"] = $obj->search;
260 $fieldlist[
"visible"] = $obj->visible;
261 $fieldlist[
"enabled"] =
verifCond($obj->enabled);
262 $fieldlist[
"order"] = $obj->rang;
264 array_push($this->field_list, $fieldlist);
288 global $search_categ, $sall, $sref, $search_barcode, $snom, $catid;
292 $sql =
'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,';
293 $sql .=
' p.fk_product_type, p.tms as datem,';
294 $sql .=
' p.duration, p.tosell as statut, p.seuil_stock_alerte';
295 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
297 if ($search_categ) $sql .=
", ".MAIN_DB_PREFIX.
"categorie_product as cp";
298 if (
GETPOST(
"fourn_id",
'int') > 0)
300 $fourn_id =
GETPOST(
"fourn_id",
'int');
301 $sql .=
", ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp";
303 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
304 if ($search_categ) $sql .=
" AND p.rowid = cp.fk_product";
307 $sql .=
" AND (p.ref LIKE '%".$this->db->escape($sall).
"%' OR p.label LIKE '%".$this->
db->escape($sall).
"%' OR p.description LIKE '%".$this->
db->escape($sall).
"%' OR p.note LIKE '%".$this->
db->escape($sall).
"%')";
309 if ($sref) $sql .=
" AND p.ref LIKE '%".$sref.
"%'";
310 if ($search_barcode) $sql .=
" AND p.barcode LIKE '%".$search_barcode.
"%'";
311 if ($snom) $sql .=
" AND p.label LIKE '%".$this->db->escape($snom).
"%'";
312 if (isset($_GET[
"tosell"]) &&
dol_strlen($_GET[
"tosell"]) > 0)
314 $sql .=
" AND p.tosell = ".$this->db->escape($_GET[
"tosell"]);
316 if (isset($_GET[
"canvas"]) &&
dol_strlen($_GET[
"canvas"]) > 0)
318 $sql .=
" AND p.canvas = '".$this->db->escape($_GET[
"canvas"]).
"'";
322 $sql .=
" AND cp.fk_categorie = ".$catid;
326 $sql .=
" AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".$fourn_id;
331 $sql .=
" AND cp.fk_categorie = ".$this->db->escape($search_categ);
333 $sql .= $this->
db->order($sortfield, $sortorder);
334 $sql .= $this->
db->plimit($limit + 1, $offset);
336 $this->list_datas = array();
344 while ($i < min($num, $limit))
347 $obj = $this->
db->fetch_object(
$resql);
349 $datas[
"id"] = $obj->rowid;
350 $datas[
"ref"] = $obj->ref;
351 $datas[
"label"] = $obj->label;
352 $datas[
"barcode"] = $obj->barcode;
353 $datas[
"statut"] = $obj->statut;
355 array_push($this->list_datas, $datas);
verifCond($strRights)
Verify if condition in string is ok or not.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class with controller methods for product canvas.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
getFieldList()
Fetch field list.
Class to manage products or services.
get_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Get formated error messages to output (Used to show messages on html output).
const TYPE_SERVICE
Service.
assign_values(&$action, $id=0, $ref= '')
Assign custom values for canvas (for example into this->tpl to be used by templates) ...
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
__construct($db, $targetmodule, $canvas, $card)
Constructor.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.
LoadListDatas($limit, $offset, $sortfield, $sortorder)
Fetch datas list and save into ->list_datas.
product_prepare_head($object)
Prepare array with list of tabs.
if(!empty($search_group)) natural_search(array("g.nom"g note