32require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
43$langs->loadLangs(array(
'commande',
'propal',
'bills',
'other',
'products'));
45$backtopage =
GETPOST(
'backtopage',
'alpha');
46$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
48$type =
GETPOST(
'type',
'intcomma');
52if (!empty($user->socid)) {
53 $socid = $user->socid;
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
70$offset = $limit * $page;
74restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'');
85if ($type ===
"" || $type ===
"-1") {
86 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
87 $title = $langs->trans(
"ProductsAndServices");
88} elseif ($type ==
'0') {
89 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
91 $title = $langs->trans(
"Products");
93 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
95 $title = $langs->trans(
"Services");
98llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-popuprop');
108 $param .=
'&type='.urlencode($type);
111 $param .=
'&mode='.urlencode($mode);
114$param .= ($type ===
'' ?
'' :
'&type='.((int) $type));
115$massactionbutton =
'';
117$nbtotalofrecords = $langs->trans(
"Statistics");
120$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/list.php?&mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'common' ? 2 : 1), array(
'morecss' =>
'reposition'));
121$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', DOL_URL_ROOT.
'/product/list.php?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
122$newcardbutton .= dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.
'/product/stats/index.php?id=all'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', 2, array(
'morecss' =>
'reposition'));
126 $perm = ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'));
128 $perm = $user->hasRight(
'service',
'creer');
130 $perm = $user->hasRight(
'produit',
'creer');
134 $params[
'forcenohideoftext'] = 1;
136$newcardbutton .= dolGetButtonTitleSeparator();
138 $label =
'NewProduct';
139 $newcardbutton .= dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/card.php?action=create&type=0',
'', (
int) $perm, $params);
142 $label =
'NewService';
143 $newcardbutton .= dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/card.php?action=create&type=1',
'', (
int) $perm, $params);
146print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
153$head[$h][0] = DOL_URL_ROOT.
'/product/stats/index.php'.($type !=
'' ?
'?type='.((int) $type) :
'');
154$head[$h][1] = $langs->trans(
"Chart");
155$head[$h][2] =
'chart';
158$head[$h][0] = DOL_URL_ROOT.
'/product/stats/popuprop.php'.($type !=
'' ?
'?type='.((int) $type) :
'');
159$head[$h][1] = $langs->trans(
"ProductsServicesPerPopularity");
160if ((
string) $type ==
'0') {
161 $head[$h][1] = $langs->trans(
"ProductsPerPopularity");
163if ((
string) $type ==
'1') {
164 $head[$h][1] = $langs->trans(
"ServicesPerPopularity");
166$head[$h][2] =
'popularity';
178$sql =
"SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, p.tobuy, p.tosell, p.tobatch, p.barcode, SUM(pd.qty) as c";
180if ($mode ==
'facture') {
181 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as pd";
182} elseif ($mode ==
'commande') {
183 $textforqty =
'NbOfQtyInOrders';
184 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as pd";
185} elseif ($mode ==
'propal') {
186 $textforqty =
'NbOfQtyInProposals';
187 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propaldet as pd";
189$sql .=
", ".MAIN_DB_PREFIX.
"product as p";
190$sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
191$sql .=
" AND p.rowid = pd.fk_product";
192if ($type !==
'' && $type !==
'-1') {
193 $sql .=
" AND p.fk_product_type = ".((int) $type);
195$sql .=
" GROUP BY p.rowid, p.label, p.ref, p.fk_product_type, p.tobuy, p.tosell, p.tobatch, p.barcode";
200if (!empty($mode) && $mode !=
'-1') {
201 $result =
$db->query($sql);
203 $totalnboflines =
$db->num_rows($result);
206 $sql .=
$db->order($sortfield.
', rowid', $sortorder);
207 $sql .=
$db->plimit($limit + 1, $offset);
209 $resql =
$db->query($sql);
211 $num =
$db->num_rows($resql);
215 $objp =
$db->fetch_object($resql);
217 $infoprod[$objp->rowid] = array(
'type' => $objp->type,
'ref' => $objp->ref,
'label' => $objp->label,
'tobuy' => $objp->tobuy,
'tosell' => $objp->tobuy,
'tobatch' => $objp->tobatch,
'barcode' => $objp->barcode);
218 $infoprod[$objp->rowid][
'nbline'] = $objp->c;
233 'propal' =>
'Proposals',
234 'commande' =>
'Orders',
235 'facture' =>
'Facture'
237$title .=
' '.$form->selectarray(
'mode', $arrayofmode, $mode, 1, 0, 0,
'', 1);
238$title .=
' <input type="submit" class="button smallpaddingimp" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
241print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
242print
'<input type="hidden" name="token" value="'.newToken().
'">';
243print
'<input type="hidden" name="mode" value="'.$mode.
'">';
244print
'<input type="hidden" name="type" value="'.$type.
'">';
245print
'<input type="hidden" name="action" value="add">';
247 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
249if ($backtopageforcancel) {
250 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
254print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num, $totalnboflines,
'', 0,
'',
'', -1, 0, 0, 1);
256print
'<table class="noborder centpercent">';
258print
'<tr class="liste_titre">';
260print_liste_field_titre(
'Type', $_SERVER[
"PHP_SELF"],
'p.fk_product_type',
'', $param,
'', $sortfield, $sortorder,
'center ');
262print_liste_field_titre($textforqty, $_SERVER[
"PHP_SELF"],
'c',
'', $param,
'', $sortfield, $sortorder,
'right ');
265if ($mode && $mode !=
'-1') {
266 foreach ($infoprod as $prodid => $vals) {
269 $sql =
"SELECT label";
270 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
271 $sql .=
" WHERE fk_product = ".((int) $prodid);
272 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
275 $resultp =
$db->query($sql);
277 $objtp =
$db->fetch_object($resultp);
278 if (!empty($objtp->label)) {
279 $vals[
'label'] = $objtp->label;
284 $tmpproduct->id = (int) $prodid;
285 $tmpproduct->ref = $vals[
'ref'];
286 $tmpproduct->label = $vals[
'label'];
287 $tmpproduct->type = $vals[
'type'];
288 $tmpproduct->status = $vals[
'tosell'];
289 $tmpproduct->status_buy = $vals[
'tobuy'];
290 $tmpproduct->status_batch = $vals[
'tobatch'];
291 $tmpproduct->barcode = $vals[
'barcode'];
297 print $tmpproduct->getNomUrl(1);
301 print
'<td class="center">';
303 if ($vals[
'type'] == 1) {
304 $s .=
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"');
306 $s .=
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"');
310 print
'<td>'.dol_escape_htmltag($vals[
'label']).
'</td>';
311 print
'<td class="right">'.$vals[
'nbline'].
'</td>';
315 if (count($infoprod) == 0) {
316 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
319 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"SelectTheTypeOfObjectToAnalyze").
'</span></td></tr>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.