31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35$langs->loadLangs(array(
'commande',
'propal',
'bills',
'other',
'products'));
37$backtopage =
GETPOST(
'backtopage',
'alpha');
38$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
40$type =
GETPOST(
'type',
'intcomma');
44if (!empty($user->socid)) {
45 $socid = $user->socid;
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52if (empty($page) || $page == -1) {
61$offset = $limit * $page;
65restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'');
77 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
79 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
81$title = $langs->trans(
"Statistics");
84llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-popuprop');
90$title = $langs->trans(
"ListProductServiceByPopularity");
91if ((
string) $type ==
'1') {
92 $title = $langs->trans(
"ListServiceByPopularity");
94if ((
string) $type ==
'0') {
95 $title = $langs->trans(
"ListProductByPopularity");
99 $param .=
'&type='.urlencode($type);
102 $param .=
'&mode='.urlencode($mode);
109$head[$h][0] = DOL_URL_ROOT.
'/product/stats/card.php?id=all';
110$head[$h][1] = $langs->trans(
"Chart");
111$head[$h][2] =
'chart';
114$head[$h][0] = DOL_URL_ROOT.
'/product/popuprop.php';
115$head[$h][1] = $langs->trans(
"ProductsServicesPerPopularity");
116if ((
string) $type ==
'0') {
117 $head[$h][1] = $langs->trans(
"ProductsPerPopularity");
119if ((
string) $type ==
'1') {
120 $head[$h][1] = $langs->trans(
"ServicesPerPopularity");
122$head[$h][2] =
'popularity';
134$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";
136if ($mode ==
'facture') {
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as pd";
138} elseif ($mode ==
'commande') {
139 $textforqty =
'NbOfQtyInOrders';
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as pd";
141} elseif ($mode ==
'propal') {
142 $textforqty =
'NbOfQtyInProposals';
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propaldet as pd";
145$sql .=
", ".MAIN_DB_PREFIX.
"product as p";
146$sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
147$sql .=
" AND p.rowid = pd.fk_product";
149 $sql .=
" AND fk_product_type = ".((int) $type);
151$sql .=
" GROUP BY p.rowid, p.label, p.ref, p.fk_product_type, p.tobuy, p.tosell, p.tobatch, p.barcode";
156if (!empty($mode) && $mode !=
'-1') {
157 $result = $db->query($sql);
159 $totalnboflines = $db->num_rows($result);
162 $sql .= $db->order($sortfield, $sortorder);
163 $sql .= $db->plimit($limit + 1, $offset);
165 $resql = $db->query($sql);
167 $num = $db->num_rows($resql);
171 $objp = $db->fetch_object($resql);
173 $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);
174 $infoprod[$objp->rowid][
'nbline'] = $objp->c;
187 'propal' =>
'Proposals',
188 'commande' =>
'Orders',
189 'facture' =>
'Facture'
191$title .=
' '.$form->selectarray(
'mode', $arrayofmode, $mode, 1, 0, 0,
'', 1);
192$title .=
' <input type="submit" class="button small" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
195print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
196print
'<input type="hidden" name="token" value="'.newToken().
'">';
197print
'<input type="hidden" name="mode" value="'.$mode.
'">';
198print
'<input type="hidden" name="type" value="'.$type.
'">';
199print
'<input type="hidden" name="action" value="add">';
201 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
203if ($backtopageforcancel) {
204 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
208print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num, $totalnboflines,
'', 0,
'',
'', -1, 0, 0, 1);
210print
'<table class="noborder centpercent">';
212print
'<tr class="liste_titre">';
214print_liste_field_titre(
'Type', $_SERVER[
"PHP_SELF"],
'p.fk_product_type',
'', $param,
'', $sortfield, $sortorder);
216print_liste_field_titre($textforqty, $_SERVER[
"PHP_SELF"],
'c',
'', $param,
'', $sortfield, $sortorder,
'right ');
219if ($mode && $mode !=
'-1') {
220 foreach ($infoprod as $prodid => $vals) {
223 $sql =
"SELECT label";
224 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
225 $sql .=
" WHERE fk_product = ".((int) $prodid);
226 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
229 $resultp = $db->query($sql);
231 $objtp = $db->fetch_object($resultp);
232 if (!empty($objtp->label)) {
233 $vals[
'label'] = $objtp->label;
238 $tmpproduct->id = $prodid;
239 $tmpproduct->ref = $vals[
'ref'];
240 $tmpproduct->label = $vals[
'label'];
241 $tmpproduct->type = $vals[
'type'];
242 $tmpproduct->status = $vals[
'tosell'];
243 $tmpproduct->status_buy = $vals[
'tobuy'];
244 $tmpproduct->status_batch = $vals[
'tobatch'];
245 $tmpproduct->barcode = $vals[
'barcode'];
249 print $tmpproduct->getNomUrl(1);
253 if ($vals[
'type'] == 1) {
254 $s .=
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"');
256 $s .=
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"');
260 print
'<td>'.dol_escape_htmltag($vals[
'label']).
'</td>';
261 print
'<td class="right">'.$vals[
'nbline'].
'</td>';
265 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"SelectTheTypeOfObjectToAnalyze").
'</span></td></tr>';
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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)
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $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, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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...
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.