30 require
'../main.inc.php';
31 require_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');
43 if (!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');
51 if (empty($page) || $page == -1) {
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
64 restrictedArea($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");
92 if ((
string) $type ==
'1') {
93 $title = $langs->trans(
"ListServiceByPopularity");
95 if ((
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";
131 if ($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";
151 if (!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;
181 $arrayofmode = array(
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").
'">';
190 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
191 print
'<input type="hidden" name="token" value="'.newToken().
'">';
192 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
193 print
'<input type="hidden" name="type" value="'.$type.
'">';
194 print
'<input type="hidden" name="action" value="add">';
196 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
198 if ($backtopageforcancel) {
199 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
203 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num, $totalnboflines,
'', 0,
'',
'', -1, 0, 0, 1);
205 print
'<table class="noborder centpercent">';
207 print
'<tr class="liste_titre">';
209 print_liste_field_titre(
'Type', $_SERVER[
"PHP_SELF"],
'p.fk_product_type',
'', $param,
'', $sortfield, $sortorder);
211 print_liste_field_titre($textforqty, $_SERVER[
"PHP_SELF"],
'c',
'', $param,
'', $sortfield, $sortorder,
'right ');
214 if ($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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.