30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34$langs->loadLangs(array(
'commande',
'propal',
'bills',
'other',
'products'));
36$backtopage =
GETPOST(
'backtopage',
'alpha');
37$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
43if (!empty($user->socid)) {
44 $socid = $user->socid;
47$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
51if (empty($page) || $page == -1) {
60$offset = $limit * $page;
64restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'');
76 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
77} elseif ($type ==
'1') {
78 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
80 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
82$title = $langs->trans(
"Statistics");
91$title = $langs->trans(
"ListProductServiceByPopularity");
92if ((
string) $type ==
'1') {
93 $title = $langs->trans(
"ListServiceByPopularity");
95if ((
string) $type ==
'0') {
96 $title = $langs->trans(
"ListProductByPopularity");
100 $param .=
'&type='.urlencode($type);
103 $param .=
'&mode='.urlencode($mode);
110$head[$h][0] = DOL_URL_ROOT.
'/product/stats/card.php?id=all';
111$head[$h][1] = $langs->trans(
"Chart");
112$head[$h][2] =
'chart';
115$head[$h][0] = DOL_URL_ROOT.
'/product/popuprop.php';
116$head[$h][1] = $langs->trans(
"ProductsPerPopularity");
117$head[$h][2] =
'popularity';
129$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";
131if ($mode ==
'facture') {
132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as pd";
133} elseif ($mode ==
'commande') {
134 $textforqty =
'NbOfQtyInOrders';
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as pd";
136} elseif ($mode ==
'propal') {
137 $textforqty =
'NbOfQtyInProposals';
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propaldet as pd";
140$sql .=
", ".MAIN_DB_PREFIX.
"product as p";
141$sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
142$sql .=
" AND p.rowid = pd.fk_product";
144 $sql .=
" AND fk_product_type = ".((int) $type);
146$sql .=
" GROUP BY p.rowid, p.label, p.ref, p.fk_product_type, p.tobuy, p.tosell, p.tobatch, p.barcode";
151if (!empty($mode) && $mode !=
'-1') {
152 $result = $db->query($sql);
154 $totalnboflines = $db->num_rows($result);
157 $sql .= $db->order($sortfield, $sortorder);
158 $sql .= $db->plimit($limit + 1, $offset);
160 $resql = $db->query($sql);
162 $num = $db->num_rows($resql);
166 $objp = $db->fetch_object($resql);
168 $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);
169 $infoprod[$objp->rowid][
'nbline'] = $objp->c;
182 'propal' =>
'Proposals',
183 'commande' =>
'Orders',
184 'facture' =>
'Facture'
186$title .=
' '.$form->selectarray(
'mode', $arrayofmode, $mode, 1, 0, 0,
'', 1);
187$title .=
' <input type="submit" class="button small" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
190print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
191print
'<input type="hidden" name="token" value="'.newToken().
'">';
192print
'<input type="hidden" name="mode" value="'.$mode.
'">';
193print
'<input type="hidden" name="type" value="'.$type.
'">';
194print
'<input type="hidden" name="action" value="add">';
196 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
198if ($backtopageforcancel) {
199 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
203print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num, $totalnboflines,
'', 0,
'',
'', -1, 0, 0, 1);
205print
'<table class="noborder centpercent">';
207print
'<tr class="liste_titre">';
209print_liste_field_titre(
'Type', $_SERVER[
"PHP_SELF"],
'p.fk_product_type',
'', $param,
'', $sortfield, $sortorder);
211print_liste_field_titre($textforqty, $_SERVER[
"PHP_SELF"],
'c',
'', $param,
'', $sortfield, $sortorder,
'right ');
214if ($mode && $mode !=
'-1') {
215 foreach ($infoprod as $prodid => $vals) {
218 $sql =
"SELECT label";
219 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
220 $sql .=
" WHERE fk_product = ".((int) $prodid);
221 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
224 $resultp = $db->query($sql);
226 $objtp = $db->fetch_object($resultp);
227 if (!empty($objtp->label)) {
228 $vals[
'label'] = $objtp->label;
233 $tmpproduct->id = $prodid;
234 $tmpproduct->ref = $vals[
'ref'];
235 $tmpproduct->label = $vals[
'label'];
236 $tmpproduct->type = $vals[
'type'];
237 $tmpproduct->status = $vals[
'tosell'];
238 $tmpproduct->status_buy = $vals[
'tobuy'];
239 $tmpproduct->status_batch = $vals[
'tobatch'];
240 $tmpproduct->barcode = $vals[
'barcode'];
244 print $tmpproduct->getNomUrl(1);
248 if ($vals[
'type'] == 1) {
249 $s .=
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"');
251 $s .=
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"');
255 print
'<td>'.dol_escape_htmltag($vals[
'label']).
'</td>';
256 print
'<td class="right">'.$vals[
'nbline'].
'</td>';
261 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()
Empty header.
Class to manage products or services.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $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.
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.