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(
"ProductsServicesPerPopularity");
117if ((
string) $type ==
'0') {
118 $head[$h][1] = $langs->trans(
"ProductsPerPopularity");
120if ((
string) $type ==
'1') {
121 $head[$h][1] = $langs->trans(
"ServicesPerPopularity");
123$head[$h][2] =
'popularity';
135$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";
137if ($mode ==
'facture') {
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as pd";
139} elseif ($mode ==
'commande') {
140 $textforqty =
'NbOfQtyInOrders';
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as pd";
142} elseif ($mode ==
'propal') {
143 $textforqty =
'NbOfQtyInProposals';
144 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propaldet as pd";
146$sql .=
", ".MAIN_DB_PREFIX.
"product as p";
147$sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
148$sql .=
" AND p.rowid = pd.fk_product";
150 $sql .=
" AND fk_product_type = ".((int) $type);
152$sql .=
" GROUP BY p.rowid, p.label, p.ref, p.fk_product_type, p.tobuy, p.tosell, p.tobatch, p.barcode";
157if (!empty($mode) && $mode !=
'-1') {
158 $result = $db->query($sql);
160 $totalnboflines = $db->num_rows($result);
163 $sql .= $db->order($sortfield, $sortorder);
164 $sql .= $db->plimit($limit + 1, $offset);
166 $resql = $db->query($sql);
168 $num = $db->num_rows($resql);
172 $objp = $db->fetch_object($resql);
174 $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);
175 $infoprod[$objp->rowid][
'nbline'] = $objp->c;
188 'propal' =>
'Proposals',
189 'commande' =>
'Orders',
190 'facture' =>
'Facture'
192$title .=
' '.$form->selectarray(
'mode', $arrayofmode, $mode, 1, 0, 0,
'', 1);
193$title .=
' <input type="submit" class="button small" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
196print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
197print
'<input type="hidden" name="token" value="'.newToken().
'">';
198print
'<input type="hidden" name="mode" value="'.$mode.
'">';
199print
'<input type="hidden" name="type" value="'.$type.
'">';
200print
'<input type="hidden" name="action" value="add">';
202 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
204if ($backtopageforcancel) {
205 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
209print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num, $totalnboflines,
'', 0,
'',
'', -1, 0, 0, 1);
211print
'<table class="noborder centpercent">';
213print
'<tr class="liste_titre">';
215print_liste_field_titre(
'Type', $_SERVER[
"PHP_SELF"],
'p.fk_product_type',
'', $param,
'', $sortfield, $sortorder);
217print_liste_field_titre($textforqty, $_SERVER[
"PHP_SELF"],
'c',
'', $param,
'', $sortfield, $sortorder,
'right ');
220if ($mode && $mode !=
'-1') {
221 foreach ($infoprod as $prodid => $vals) {
224 $sql =
"SELECT label";
225 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
226 $sql .=
" WHERE fk_product = ".((int) $prodid);
227 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
230 $resultp = $db->query($sql);
232 $objtp = $db->fetch_object($resultp);
233 if (!empty($objtp->label)) {
234 $vals[
'label'] = $objtp->label;
239 $tmpproduct->id = $prodid;
240 $tmpproduct->ref = $vals[
'ref'];
241 $tmpproduct->label = $vals[
'label'];
242 $tmpproduct->type = $vals[
'type'];
243 $tmpproduct->status = $vals[
'tosell'];
244 $tmpproduct->status_buy = $vals[
'tobuy'];
245 $tmpproduct->status_batch = $vals[
'tobatch'];
246 $tmpproduct->barcode = $vals[
'barcode'];
250 print $tmpproduct->getNomUrl(1);
254 if ($vals[
'type'] == 1) {
255 $s .=
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"');
257 $s .=
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"');
261 print
'<td>'.dol_escape_htmltag($vals[
'label']).
'</td>';
262 print
'<td class="right">'.$vals[
'nbline'].
'</td>';
267 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 a 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.