29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33 $langs->loadLangs(array(
'commande',
'propal',
'bills',
'other'));
35 $backtopage =
GETPOST(
'backtopage',
'alpha');
36 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
42 if (!empty($user->socid)) $socid = $user->socid;
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
"sortfield",
'alpha');
47 $sortorder =
GETPOST(
"sortorder",
'alpha');
49 if (empty($page) || $page == -1) { $page = 0; }
50 if (!$sortfield) $sortfield =
"c";
51 if (!$sortorder) $sortorder =
"DESC";
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
57 $staticproduct =
new Product($db);
64 $form =
new Form($db);
68 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
69 } elseif ($type ==
'1') {
70 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
72 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
74 $title = $langs->trans(
"Statistics");
83 $title = $langs->trans(
"ListProductServiceByPopularity");
84 if ((
string) $type ==
'1') {
85 $title = $langs->trans(
"ListServiceByPopularity");
87 if ((
string) $type ==
'0') {
88 $title = $langs->trans(
"ListProductByPopularity");
91 if ($type !=
'') $param .=
'&type='.urlencode($type);
92 if ($mode !=
'') $param .=
'&mode='.urlencode($mode);
97 $head[$h][0] = DOL_URL_ROOT.
'/product/stats/card.php?id=all';
98 $head[$h][1] = $langs->trans(
"Chart");
99 $head[$h][2] =
'chart';
102 $head[$h][0] = DOL_URL_ROOT.
'/product/popuprop.php';
103 $head[$h][1] = $langs->trans(
"ProductsPerPopularity");
104 $head[$h][2] =
'popularity';
116 $sql =
"SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, SUM(pd.qty) as c";
118 if ($mode ==
'facture') {
119 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as pd";
120 } elseif ($mode ==
'commande') {
121 $textforqty =
'NbOfQtyInOrders';
122 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commandedet as pd";
123 } elseif ($mode ==
'propal') {
124 $textforqty =
'NbOfQtyInProposals';
125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propaldet as pd";
127 $sql .=
", ".MAIN_DB_PREFIX.
"product as p";
128 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
129 $sql .=
" AND p.rowid = pd.fk_product";
131 $sql .=
" AND fk_product_type = ".$type;
133 $sql .=
" GROUP BY p.rowid, p.label, p.ref, p.fk_product_type";
135 if (!empty($mode) && $mode !=
'-1') {
136 $result = $db->query($sql);
139 $totalnboflines = $db->num_rows($result);
142 $sql .= $db->order($sortfield, $sortorder);
143 $sql .= $db->plimit($limit + 1, $offset);
145 $resql = $db->query($sql);
148 $num = $db->num_rows(
$resql);
153 $objp = $db->fetch_object(
$resql);
155 $infoprod[$objp->rowid] = array(
'type'=>$objp->type,
'ref'=>$objp->ref,
'label'=>$objp->label);
156 $infoprod[$objp->rowid][
'nbline'] = $objp->c;
168 $arrayofmode = array(
169 'propal' =>
'Proposals',
170 'commande' =>
'Orders',
171 'facture' =>
'Facture'
173 $title .=
' '.$form->selectarray(
'mode', $arrayofmode, $mode, 1);
174 $title .=
' <input type="submit" class="button" name="refresh" value="'.$langs->trans(
"Refresh").
'">';
177 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
178 print '<input type="hidden" name="token" value="'.newToken().
'">';
179 print '<input type="hidden" name="mode" value="'.$mode.
'">';
180 print '<input type="hidden" name="type" value="'.$type.
'">';
181 print '<input type="hidden" name="action" value="add">';
182 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
183 if ($backtopageforcancel)
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
186 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num, $totalnboflines,
'', 0,
'',
'', -1, 0, 0, 1);
188 print '<table class="noborder centpercent">';
190 print "<tr class=\"liste_titre\">";
197 if ($mode && $mode !=
'-1') {
198 foreach ($infoprod as $prodid => $vals)
201 if (!empty($conf->global->MAIN_MULTILANGS))
203 $sql =
"SELECT label";
204 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
205 $sql .=
" WHERE fk_product=".$prodid;
206 $sql .=
" AND lang='".$db->escape($langs->getDefaultLang()).
"'";
209 $resultp = $db->query($sql);
212 $objtp = $db->fetch_object($resultp);
213 if (!empty($objtp->label)) $vals[
'label'] = $objtp->label;
218 print '<td><a href="'.DOL_URL_ROOT.
'/product/stats/card.php?id='.$prodid.
'">';
219 if ($vals[
'type'] == 1)
print img_object($langs->trans(
"ShowService"),
"service");
222 print $vals[
'ref'].
'</a></td>';
224 if ($vals[
'type'] == 1) print $langs->trans(
"Service");
225 else print $langs->trans(
"Product");
227 print
'<td>'.$vals[
'label'].
'</td>';
228 print
'<td class="right">'.$vals[
'nbline'].
'</td>';
233 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"SelectTheTypeOfObjectToAnalyze").
'</span></td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage products or services.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.