';
@@ -541,3 +435,3 @@
- print '';
-
- if ($i % 2 == 0) {
+
+ if ($i % 2 == 0)
+ {
@@ -545,2 +439,4 @@
- } else {
- print "\n".'';
+ }
+ else
+ {
+ print "\n".'';
@@ -554,3 +450,4 @@
- if ($i % 2 == 1) {
- print "\n".''."\n";
- print "\n".'
';
+ if ($i % 2 == 1)
+ {
+ print "\n".'';
@@ -561,2 +458,3 @@
-if (!($id > 0)) {
- print dol_get_fiche_end();
+if (!$id)
+{
+ dol_fiche_end();
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_commande.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_commande.php
@@ -27 +26,0 @@
-// Load Dolibarr environment
@@ -44,3 +43,2 @@
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
+if (!empty($user->socid)) $socid = $user->socid;
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -50,0 +49,2 @@
+$mesg = '';
+
@@ -52,3 +52,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -56,3 +56 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -62,7 +60,3 @@
-if (!$sortorder) {
- $sortorder = "DESC";
-}
-if (!$sortfield) {
- $sortfield = "c.date_commande";
-}
-$search_month = GETPOST('search_month', 'int');
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "c.date_commande";
+$search_month = GETPOST('search_month', 'alpha');
@@ -76,3 +69,0 @@
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
-
-
@@ -89 +80,2 @@
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
@@ -97,3 +89 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -103 +93,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -107 +98 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -110,20 +101,16 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -133,7 +120,8 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
-
-
- if ($user->hasRight('commande', 'lire')) {
+ print '';
+ print '
';
+
+ dol_fiche_end();
+
+
+ if ($user->rights->commande->lire)
+ {
@@ -142,5 +130,2 @@
- $sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty,";
- $sql .= " c.date_livraison as delivery_date";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= ", sc.fk_soc, sc.fk_user ";
- }
+ $sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty";
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
@@ -150,3 +135 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- }
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -156,13 +139,7 @@
- $sql .= " AND d.fk_product = ".((int) $product->id);
- if (!empty($search_month)) {
- $sql .= ' AND MONTH(c.date_commande) IN ('.$db->sanitize($search_month).')';
- }
- if (!empty($search_year)) {
- $sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')';
- }
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND c.fk_soc = ".((int) $socid);
- }
+ $sql .= " AND d.fk_product =".$product->id;
+ if (!empty($search_month))
+ $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')';
+ if (!empty($search_year))
+ $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')';
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid) $sql .= " AND c.fk_soc = ".$socid;
@@ -171,12 +148,13 @@
- //Calcul total qty and amount for global if full scan list
- $total_ht = 0;
- $total_qty = 0;
-
- // Count total nb of records
- $totalofrecords = '';
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
- $result = $db->query($sql);
- $totalofrecords = $db->num_rows($result);
- }
-
- $sql .= $db->plimit($limit + 1, $offset);
+ //Calcul total qty and amount for global if full scan list
+ $total_ht = 0;
+ $total_qty = 0;
+
+ // Count total nb of records
+ $totalofrecords = '';
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
+ $result = $db->query($sql);
+ $totalofrecords = $db->num_rows($result);
+ }
+
+ $sql .= $db->plimit($limit + 1, $offset);
@@ -185 +163,2 @@
- if ($result) {
+ if ($result)
+ {
@@ -188,30 +167,18 @@
- $option = '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
-
- print '
";
- print "
";
- print '';
- } else {
+ print '';
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ print ' ';
+ print ''.$total_qty.' ';
+ print ''.price($total_ht).' ';
+ print ' ';
+ print "
";
+ print "
";
+ print '';
+ } else {
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_commande_fournisseur.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_commande_fournisseur.php
@@ -42 +42 @@
-if (!empty($user->socid)) {
+if (!empty($user->socid))
@@ -44 +44 @@
-}
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -47 +47 @@
-$hookmanager->initHooks(array('productstatssupplierorder'));
+$hookmanager->initHooks(array('productstatssupplyorder'));
@@ -52,3 +52,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST('sortfield', 'alpha');
+$sortorder = GETPOST('sortorder', 'alpha');
@@ -56,3 +56 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -62 +60 @@
-if (!$sortorder) {
+if (!$sortorder)
@@ -64,2 +62 @@
-}
-if (!$sortfield) {
+if (!$sortfield)
@@ -67,2 +64 @@
-}
-$search_month = GETPOST('search_month', 'int');
+$search_month = GETPOST('search_month', 'alpha');
@@ -76,2 +71,0 @@
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
-
@@ -97 +91 @@
- if ($reshook < 0) {
+ if ($reshook < 0)
@@ -99 +92,0 @@
- }
@@ -103 +96,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -107 +101 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -110,4 +104,2 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -117,4 +109,2 @@
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
@@ -124,6 +114,6 @@
- print '';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -133,7 +123,8 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
-
-
- if ($user->hasRight('fournisseur', 'commande', 'lire')) {
+ print '';
+ print '
';
+
+ dol_fiche_end();
+
+
+ if ($user->rights->fournisseur->commande->lire)
+ {
@@ -142,3 +133,2 @@
- $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty,";
- $sql .= " c.date_livraison as delivery_date";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty";
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -146 +135,0 @@
- }
@@ -150 +139 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -152 +140,0 @@
- }
@@ -154 +142 @@
- $sql .= " AND c.entity IN (".getEntity('supplier_order').")";
+ $sql .= " AND c.entity = ".$conf->entity;
@@ -156,13 +144,9 @@
- $sql .= " AND d.fk_product = ".((int) $product->id);
- if (!empty($search_month)) {
- $sql .= ' AND MONTH(c.date_commande) IN ('.$db->sanitize($search_month).')';
- }
- if (!empty($search_year)) {
- $sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')';
- }
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND c.fk_soc = ".((int) $socid);
- }
+ $sql .= " AND d.fk_product =".$product->id;
+ if (!empty($search_month))
+ $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')';
+ if (!empty($search_year))
+ $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')';
+ if (!$user->rights->societe->client->voir && !$socid)
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid)
+ $sql .= " AND c.fk_soc = ".$socid;
@@ -177 +161,2 @@
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
@@ -188,11 +173,4 @@
- $option = '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
@@ -201,2 +179 @@
- print ' ';
- if (!empty($sortfield)) {
+ if (!empty($sortfield))
@@ -204,2 +181 @@
- }
- if (!empty($sortorder)) {
+ if (!empty($sortorder))
@@ -207 +182,0 @@
- }
@@ -211,3 +186 @@
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
+ if (!empty($page)) $option .= '&page='.urlencode($page);
@@ -216 +189 @@
- print '';
+ print '
';
@@ -228,2 +201,2 @@
- print '
';
- print '
';
+ print '';
+ print '
';
@@ -235 +207,0 @@
- print_liste_field_titre('DateDeliveryPlanned', $_SERVER['PHP_SELF'], 'c.date_livraison', '', $option, 'align="center"', $sortfield, $sortorder);
@@ -241,2 +213,4 @@
- if ($num > 0) {
- while ($i < min($num, $limit)) {
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
@@ -261,4 +234,0 @@
- // delivery planned date
- print '';
- print dol_print_date($db->jdate($objp->delivery_date), 'dayhour');
- print ' ';
@@ -273,5 +243,2 @@
- if ($num < $limit) {
- print ''.$langs->trans("Total").' ';
- } else {
- print ''.$langs->trans("Totalforthispage").' ';
- }
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
@@ -279,2 +245,0 @@
- // delivery planned date
- print ' ';
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_contrat.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_contrat.php
@@ -26 +25,0 @@
-// Load Dolibarr environment
@@ -41,3 +40,2 @@
-if ($user->socid) {
- $socid = $user->socid;
-}
+if ($user->socid) $socid = $user->socid;
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -47,0 +46,2 @@
+$mesg = '';
+
@@ -49,3 +49,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -53,3 +53 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -59,8 +57,2 @@
-if (!$sortorder) {
- $sortorder = "DESC";
-}
-if (!$sortfield) {
- $sortfield = "c.date_contrat";
-}
-
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "c.date_contrat";
@@ -78 +70,2 @@
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
@@ -86,3 +79 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -92 +83,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -96 +88 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -99,20 +91,16 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -122,4 +110,4 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
+ print '';
+ print '
';
+
+ dol_fiche_end();
@@ -131,4 +119,4 @@
- $sql .= " sum(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,';
- $sql .= " sum(".$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,";
- $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= '".$db->idate($now)."')", 1, 0).') as nb_late,';
- $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,';
+ $sql .= ' sum('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,';
+ $sql .= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,";
+ $sql .= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= '".$db->idate($now)."')", 1, 0).') as nb_late,';
+ $sql .= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,';
@@ -138,3 +126 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- }
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -146,7 +132,3 @@
- $sql .= " AND cd.fk_product = ".((int) $product->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND s.rowid = ".((int) $socid);
- }
+ $sql .= " AND cd.fk_product =".$product->id;
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid) $sql .= " AND s.rowid = ".$socid;
@@ -162 +144,2 @@
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
@@ -170 +153,2 @@
- if ($result) {
+ if ($result)
+ {
@@ -173,29 +157,18 @@
- $option = '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
-
- print ''."\n";
- print ' ';
- if (!empty($sortfield)) {
- print ' ';
- }
- if (!empty($sortorder)) {
- print ' ';
- }
-
- print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
-
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
-
- $i = 0;
- print '';
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
+
+ print '
'."\n";
+
+ if (!empty($sortfield))
+ print ' ';
+ if (!empty($sortorder))
+ print ' ';
+
+ print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
+
+ if (!empty($page)) $option .= '&page='.urlencode($page);
+
+ $i = 0;
+ print '';
@@ -217,2 +190,4 @@
- if ($num > 0) {
- while ($i < min($num, $limit)) {
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
@@ -248 +223,3 @@
- } else {
+ }
+ else
+ {
@@ -253 +230,3 @@
-} else {
+}
+else
+{
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_facture.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_facture.php
@@ -28 +27,0 @@
-// Load Dolibarr environment
@@ -45,3 +44,2 @@
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
+if (!empty($user->socid)) $socid = $user->socid;
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -51,6 +48,0 @@
-$extrafields = new ExtraFields($db);
-
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('facture');
-
-$search_array_options = $extrafields->getOptionalsFromPost('facture', '', 'search_');
@@ -61,3 +53,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -65,3 +57 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -71,2 +61,9 @@
-if (!$sortorder) {
- $sortorder = "DESC";
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "f.datef";
+
+$search_month = GETPOST('search_month', 'alpha');
+$search_year = GETPOST('search_year', 'int');
+
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
+ $search_month = '';
+ $search_year = '';
@@ -74,43 +71 @@
-if (!$sortfield) {
- $sortfield = "f.datef";
-}
-
-$search_date_startday = GETPOSTINT('search_date_startday');
-if (!empty($search_date_startday)) {
- $option .= '&search_date_startday='.$search_date_startday;
-}
-$search_date_startmonth = GETPOSTINT('search_date_startmonth');
-if (!empty($search_date_startmonth)) {
- $option .= '&search_date_startmonth='.$search_date_startmonth;
-}
-$search_date_startyear = GETPOSTINT('search_date_startyear');
-if (!empty($search_date_startyear)) {
- $option .= '&search_date_startyear='.$search_date_startyear;
-}
-$search_date_endday = GETPOSTINT('search_date_endday');
-if (!empty($search_date_endday)) {
- $option .= '&search_date_endday='.$search_date_endday;
-}
-$search_date_endmonth = GETPOSTINT('search_date_endmonth');
-if (!empty($search_date_endmonth)) {
- $option .= '&search_date_endmonth='.$search_date_endmonth;
-}
-$search_date_endyear = GETPOSTINT('search_date_endyear');
-if (!empty($search_date_endyear)) {
- $option .= '&search_date_endyear='.$search_date_endyear;
-}
-$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
-$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
-
-if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
- $search_date_startday = '';
- $search_date_startmonth = '';
- $search_date_startyear = '';
- $search_date_endday = '';
- $search_date_endmonth = '';
- $search_date_endyear = '';
- $search_date_start = '';
- $search_date_end = '';
-}
-
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
+
@@ -129 +84,2 @@
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
@@ -137,3 +93 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -144 +98,2 @@
- if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
+ if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT))
+ {
@@ -148 +103,2 @@
- if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
+ if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE))
+ {
@@ -155 +111,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -159 +116 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -162,3 +119,27 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = '
'.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '
';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
+
+ print "
";
+
+ print '
';
+ print '
';
+
+ dol_fiche_end();
+
+ if ($showmessage && $nboflines > 1)
+ {
+ print '
'.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).' ';
@@ -166,149 +147,61 @@
-
- $linkback = '
'.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '
';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
-
- print "
";
-
- print '
';
- print '
';
-
- print dol_get_fiche_end();
-
- if ($showmessage && $nboflines > 1) {
- print '
'.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).' ';
- } elseif ($user->hasRight('facture', 'lire')) {
- $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
- $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
- $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= ", sc.fk_soc, sc.fk_user ";
- }
- // Add fields from extrafields
- if (!empty($extrafields->attributes['facture']['label'])) {
- foreach ($extrafields->attributes['facture']['label'] as $key => $val) {
- $sql .= ($extrafields->attributes['facture']['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
- }
- }
- // Add fields from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- $sql .= $hookmanager->resPrint;
- $sql = preg_replace('/,\s*$/', '', $sql);
-
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql .= ", ".MAIN_DB_PREFIX."facture as f";
- if (isset($extrafields->attributes['facture']['label']) && is_array($extrafields->attributes['facture']['label']) && count($extrafields->attributes['facture']['label'])) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'facture'."_extrafields as ef on (f.rowid = ef.fk_object)";
- }
- $sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- }
- // Add table from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
- $sql .= $hookmanager->resPrint;
-
- $sql .= " WHERE f.fk_soc = s.rowid";
- $sql .= " AND f.entity IN (".getEntity('invoice').")";
- $sql .= " AND d.fk_facture = f.rowid";
- $sql .= " AND d.fk_product = ".((int) $product->id);
- if ($search_date_start) {
- $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
- }
- if ($search_date_end) {
- $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
- }
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND f.fk_soc = ".((int) $socid);
- }
- // Add where from extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
- // Add where from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- $sql .= $hookmanager->resPrint;
-
- // Add HAVING from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
-
- $sql .= $db->order($sortfield, $sortorder);
-
- // Calcul total qty and amount for global if full scan list
- $total_ht = 0;
- $total_qty = 0;
-
- // Count total nb of records
- $totalofrecords = '';
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
- $result = $db->query($sql);
- $totalofrecords = $db->num_rows($result);
- }
-
- $sql .= $db->plimit($limit + 1, $offset);
-
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
-
- $option .= '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
-
- // Add $param from extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
- // Add $param from hooks
- $parameters = array('param' => &$param);
- $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- $option .= $hookmanager->resPrint;
-
- print '
'."\n";
- print ' ';
- if (!empty($sortfield)) {
- print ' ';
- }
- if (!empty($sortorder)) {
- print ' ';
- }
-
- print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
-
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
-
- print '';
- print '
';
- print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - ';
- print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
- print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-
+ elseif ($user->rights->facture->lire)
+ {
+ $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
+ $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
+ $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
+ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+ $sql .= ", ".MAIN_DB_PREFIX."facture as f";
+ $sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE f.fk_soc = s.rowid";
+ $sql .= " AND f.entity IN (".getEntity('invoice').")";
+ $sql .= " AND d.fk_facture = f.rowid";
+ $sql .= " AND d.fk_product =".$product->id;
+ if (!empty($search_month))
+ $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')';
+ if (!empty($search_year))
+ $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')';
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid) $sql .= " AND f.fk_soc = ".$socid;
+ $sql .= $db->order($sortfield, $sortorder);
+
+ // Calcul total qty and amount for global if full scan list
+ $total_ht = 0;
+ $total_qty = 0;
+
+ // Count total nb of records
+ $totalofrecords = '';
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
+ $result = $db->query($sql);
+ $totalofrecords = $db->num_rows($result);
+ }
+
+ $sql .= $db->plimit($limit + 1, $offset);
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
+
+ print '
'."\n";
+ if (!empty($sortfield))
+ print ' ';
+ if (!empty($sortorder))
+ print ' ';
+
+ print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
+
+ if (!empty($page)) $option .= '&page='.urlencode($page);
+
+ print '';
+ print '
';
+ print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - ';
+ print $langs->trans('Month').': ';
+ print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5);
@@ -317,0 +211 @@
+ print '
';
@@ -320,26 +214,21 @@
- print '
';
-
- $i = 0;
- print '';
- print '
';
- print '';
- print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder);
- print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
- print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder);
- print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder);
- print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
- print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
- print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
- // Hook fields
- $parameters = array('param'=>$option, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
- $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- print " \n";
-
- if ($num > 0) {
- while ($i < min($num, $limit)) {
- $objp = $db->fetch_object($result);
-
- if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
- $objp->qty = -($objp->qty);
- }
+
+ $i = 0;
+ print '';
+ print '
';
+ print '';
+ print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder);
+ print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
+ print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder);
+ print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder);
+ print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
+ print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total", "", $option, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
+ print " \n";
+
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
+ $objp = $db->fetch_object($result);
+
+ if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty = -($objp->qty);
@@ -348,3 +237,3 @@
- $total_qty += $objp->qty;
-
- $invoicestatic->id = $objp->facid;
+ $total_qty += $objp->qty;
+
+ $invoicestatic->id = $objp->facid;
@@ -355,37 +244,30 @@
- print '';
- print '';
- print $invoicestatic->getNomUrl(1);
- print " \n";
- print ''.$societestatic->getNomUrl(1).' ';
- print "".$objp->code_client." \n";
- print '';
- print dol_print_date($db->jdate($objp->datef), 'dayhour')." ";
- print ''.$objp->qty." \n";
- print ''.price($objp->total_ht)." \n";
- print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5, $paiement, $objp->type).' ';
- // Fields from hook
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- print " \n";
- $i++;
- }
- }
- print '';
- if ($num < $limit) {
- print ''.$langs->trans("Total").' ';
- } else {
- print ''.$langs->trans("Totalforthispage").' ';
- }
- print ' ';
- print ''.$total_qty.' ';
- print ''.price($total_ht).' ';
- print ' ';
- print "
";
- print '
';
- print '';
- } else {
- dol_print_error($db);
- }
- $db->free($result);
- }
+ print '';
+ print '';
+ print $invoicestatic->getNomUrl(1);
+ print " \n";
+ print ''.$societestatic->getNomUrl(1).' ';
+ print "".$objp->code_client." \n";
+ print '';
+ print dol_print_date($db->jdate($objp->datef), 'dayhour')." ";
+ print ''.$objp->qty." \n";
+ print ''.price($objp->total_ht)." \n";
+ print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5, $paiement, $objp->type).' ';
+ print " \n";
+ $i++;
+ }
+ }
+ print '';
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ print ' ';
+ print ''.$total_qty.' ';
+ print ''.price($total_ht).' ';
+ print ' ';
+ print "
";
+ print '
';
+ print ' ';
+ } else {
+ dol_print_error($db);
+ }
+ $db->free($result);
+ }
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_facture_fournisseur.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_facture_fournisseur.php
@@ -28 +27,0 @@
-// Load Dolibarr environment
@@ -45,3 +44,2 @@
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
+if (!empty($user->socid)) $socid = $user->socid;
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -50 +48,3 @@
-$hookmanager->initHooks(array('productstatssupplierinvoice'));
+$hookmanager->initHooks(array('productstatssupplyinvoice'));
+
+$mesg = '';
@@ -53,3 +53,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -57,3 +57 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -63,7 +61,3 @@
-if (!$sortorder) {
- $sortorder = "DESC";
-}
-if (!$sortfield) {
- $sortfield = "f.datef";
-}
-$search_month = GETPOST('search_month', 'int');
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "f.datef";
+$search_month = GETPOST('search_month', 'alpha');
@@ -77,3 +70,0 @@
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
-
-
@@ -90 +81,2 @@
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
@@ -98,3 +90 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -104 +94,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -108 +99 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -111,20 +102,16 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- $linkback = '
'.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '
';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -134,7 +121,8 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
-
-
- if ($user->hasRight('fournisseur', 'facture', 'lire')) {
+ print '';
+ print '
';
+
+ dol_fiche_end();
+
+
+ if ($user->rights->fournisseur->facture->lire)
+ {
@@ -143 +131 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -145 +132,0 @@
- }
@@ -149,3 +136 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- }
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -155,13 +140,7 @@
- $sql .= " AND d.fk_product = ".((int) $product->id);
- if (!empty($search_month)) {
- $sql .= ' AND MONTH(f.datef) IN ('.$db->sanitize($search_month).')';
- }
- if (!empty($search_year)) {
- $sql .= ' AND YEAR(f.datef) IN ('.$db->sanitize($search_year).')';
- }
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND f.fk_soc = ".((int) $socid);
- }
+ $sql .= " AND d.fk_product =".$product->id;
+ if (!empty($search_month))
+ $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')';
+ if (!empty($search_year))
+ $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')';
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid) $sql .= " AND f.fk_soc = ".$socid;
@@ -176 +155,2 @@
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
@@ -184 +164,2 @@
- if ($result) {
+ if ($result)
+ {
@@ -187,11 +168,4 @@
- $option .= '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
@@ -200,2 +174 @@
- print ' ';
- if (!empty($sortfield)) {
+ if (!empty($sortfield))
@@ -203,2 +176 @@
- }
- if (!empty($sortorder)) {
+ if (!empty($sortorder))
@@ -206 +177,0 @@
- }
@@ -210,3 +181 @@
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
+ if (!empty($page)) $option .= '&page='.urlencode($page);
@@ -215 +184 @@
- print '';
+ print '
';
@@ -227 +196 @@
- print '
';
+ print '
';
@@ -239,2 +208,4 @@
- if ($num > 0) {
- while ($i < min($num, $limit)) {
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
@@ -249 +220 @@
- $supplierinvoicestatic->libelle = $objp->label; // deprecated
+ $supplierinvoicestatic->libelle = $objp->label;
@@ -263 +234 @@
- print '
';
+ print ' ';
@@ -267 +238 @@
- print ' '.$supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5, $supplierinvoicestatic->getSommePaiement()).' ';
+ print '
'.$supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5).' ';
@@ -273,5 +244,2 @@
- if ($num < $limit) {
- print '
'.$langs->trans("Total").' ';
- } else {
- print '
'.$langs->trans("Totalforthispage").' ';
- }
+ if ($num < $limit) print '
'.$langs->trans("Total").' ';
+ else print '
'.$langs->trans("Totalforthispage").' ';
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_mo.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_mo.php
@@ -3 +3 @@
- * Copyright (C) 2004-2021 Laurent Destailleur
+ * Copyright (C) 2004-2009 Laurent Destailleur
@@ -5 +4,0 @@
- * Copyright (C) 2023 Gauthier VERDOL
@@ -27 +25,0 @@
-// Load Dolibarr environment
@@ -32 +29,0 @@
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -43,3 +40,2 @@
-if ($user->socid) {
- $socid = $user->socid;
-}
+if ($user->socid) $socid = $user->socid;
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -48 +44,3 @@
-$hookmanager->initHooks(array('productstatsmo'));
+$hookmanager->initHooks(array('productstatscontract'));
+
+$mesg = '';
@@ -51,3 +49,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -55,3 +53 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -61,16 +57,2 @@
-if (!$sortorder) {
- $sortorder = "DESC";
-}
-if (!$sortfield) {
- $sortfield = "c.date_valid";
-}
-
-$search_month = GETPOST('search_month', 'int');
-$search_year = GETPOST('search_year', 'int');
-
-if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
- $search_month = '';
- $search_year = '';
-}
-
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "c.date_valid";
@@ -87,3 +69,3 @@
-$formother = new FormOther($db);
-
-if ($id > 0 || !empty($ref)) {
+
+if ($id > 0 || !empty($ref))
+{
@@ -97,3 +79 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -103 +83,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -107 +88 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -110,20 +91,16 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -133,4 +110,4 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
+ print '';
+ print '
';
+
+ dol_fiche_end();
@@ -142,4 +119,4 @@
- $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,';
- $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,';
- $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,';
- $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,';
+ $sql .= ' sum('.$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,';
+ $sql .= ' sum('.$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,';
+ $sql .= ' sum('.$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,';
+ $sql .= ' sum('.$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,';
@@ -152,10 +129,2 @@
- $sql .= " AND cd.fk_product = ".((int) $product->id);
- if (!empty($search_month)) {
- $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')';
- }
- if (!empty($search_year)) {
- $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')';
- }
- if ($socid) {
- $sql .= " AND s.rowid = ".((int) $socid);
- }
+ $sql .= " AND cd.fk_product =".$product->id;
+ if ($socid) $sql .= " AND s.rowid = ".$socid;
@@ -172 +141,2 @@
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
@@ -180 +150,2 @@
- if ($result) {
+ if ($result)
+ {
@@ -183,41 +154,17 @@
- $option = '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
-
- print ''."\n";
- print ' ';
- if (!empty($sortfield)) {
- print ' ';
- }
- if (!empty($sortorder)) {
- print ' ';
- }
-
- print_barre_liste($langs->trans("MOs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
-
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
-
- print '';
-
- $i = 0;
- print '';
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
+
+ print '
'."\n";
+ if (!empty($sortfield))
+ print ' ';
+ if (!empty($sortorder))
+ print ' ';
+
+ print_barre_liste($langs->trans("Mos"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
+
+ if (!empty($page)) $option .= '&page='.urlencode($page);
+
+ $i = 0;
+ print '';
@@ -235 +181,0 @@
- print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "b.status", "", "&id=".$product->id, '', $sortfield, $sortorder, 'right ');
@@ -240,2 +186,4 @@
- if ($num > 0) {
- while ($i < min($num, $limit)) {
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
@@ -246 +193,0 @@
- $motmp->status = $objp->status;
@@ -261 +207,0 @@
- print '
'.$motmp->getLibStatut(2).' ';
@@ -270 +216,3 @@
- } else {
+ }
+ else
+ {
@@ -275 +223,3 @@
-} else {
+}
+else
+{
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_propal.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_propal.php
@@ -27 +26,0 @@
-// Load Dolibarr environment
@@ -44,3 +43 @@
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
+if (!empty($user->socid)) $socid = $user->socid;
@@ -51,0 +49,2 @@
+$mesg = '';
+
@@ -53,3 +52,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST('sortfield', 'alpha');
+$sortorder = GETPOST('sortorder', 'alpha');
@@ -57,3 +56 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -63,8 +60,4 @@
-if (!$sortorder) {
- $sortorder = "DESC";
-}
-if (!$sortfield) {
- $sortfield = "p.datep";
-}
-
-$search_month = GETPOST('search_month', 'int');
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "p.datep";
+
+$search_month = GETPOST('search_month', 'alpha');
@@ -78,3 +70,0 @@
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
-
-
@@ -91 +81,2 @@
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
@@ -95 +86 @@
- $object = $product;
+ $object = $product;
@@ -99,3 +90 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -105 +94,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -109 +99 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -112,20 +102,16 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- $linkback = '
'.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '
';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -135,7 +121,8 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
-
-
- if ($user->hasRight('propal', 'lire')) {
+ print '';
+ print '
';
+
+ dol_fiche_end();
+
+
+ if ($user->rights->propale->lire)
+ {
@@ -145 +132 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -147 +133,0 @@
- }
@@ -151 +137 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -153 +138,0 @@
- }
@@ -157,13 +142,9 @@
- $sql .= " AND d.fk_product = ".((int) $product->id);
- if (!empty($search_month)) {
- $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')';
- }
- if (!empty($search_year)) {
- $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')';
- }
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND p.fk_soc = ".((int) $socid);
- }
+ $sql .= " AND d.fk_product =".$product->id;
+ if (!empty($search_month))
+ $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')';
+ if (!empty($search_year))
+ $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')';
+ if (!$user->rights->societe->client->voir && !$socid)
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid)
+ $sql .= " AND p.fk_soc = ".$socid;
@@ -178 +159,2 @@
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
@@ -186 +168,2 @@
- if ($result) {
+ if ($result)
+ {
@@ -189,11 +172,4 @@
- $option = '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
@@ -202,2 +178 @@
- print ' ';
- if (!empty($sortfield)) {
+ if (!empty($sortfield))
@@ -205,2 +180 @@
- }
- if (!empty($sortorder)) {
+ if (!empty($sortorder))
@@ -208 +181,0 @@
- }
@@ -212,3 +185 @@
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
+ if (!empty($page)) $option .= '&page='.urlencode($page);
@@ -217 +188 @@
- print '';
+ print '
';
@@ -229 +200 @@
- print '
';
+ print '
';
@@ -236 +207 @@
- print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder);
@@ -240,2 +211,4 @@
- if ($num > 0) {
- while ($i < min($num, $limit)) {
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
@@ -256 +229 @@
- print '
'.$societestatic->getNomUrl(1).' ';
+ print ''.$societestatic->getNomUrl(1).' ';
@@ -267,17 +240,14 @@
- print '';
- if ($num < $limit) {
- print ''.$langs->trans("Total").' ';
- } else {
- print ''.$langs->trans("Totalforthispage").' ';
- }
- print ' ';
- print ''.$total_qty.' ';
- print ''.price($total_ht).' ';
- print ' ';
- print "
";
- print '
';
- print '';
- } else {
- dol_print_error($db);
- }
- $db->free($result);
+ print '';
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ print ' ';
+ print ''.$total_qty.' ';
+ print ''.price($total_ht).' ';
+ print ' ';
+ print "
";
+ print '
';
+ print '';
+ } else {
+ dol_print_error($db);
+ }
+ $db->free($result);
--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_supplier_proposal.php
+++ /tmp/dsg/dolibarr/htdocs/product/stats/client_supplier_proposal.php
@@ -27 +26,0 @@
-// Load Dolibarr environment
@@ -44,3 +43,2 @@
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
+if (!empty($user->socid)) $socid = $user->socid;
+$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
@@ -49 +47,3 @@
-$hookmanager->initHooks(array('productstatssupplierpropal'));
+$hookmanager->initHooks(array('productstatspropal'));
+
+$mesg = '';
@@ -52,3 +52,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST('sortfield', 'alpha');
+$sortorder = GETPOST('sortorder', 'alpha');
@@ -56,3 +56 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -62,8 +60,4 @@
-if (!$sortorder) {
- $sortorder = "DESC";
-}
-if (!$sortfield) {
- $sortfield = "p.date_valid";
-}
-
-$search_month = GETPOST('search_month', 'int');
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "p.date_valid";
+
+$search_month = GETPOST('search_month', 'alpha');
@@ -77,3 +70,0 @@
-$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
-
-
@@ -90 +81,2 @@
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
@@ -94 +86 @@
- $object = $product;
+ $object = $product;
@@ -98,3 +90 @@
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -104 +94,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -108 +99 @@
- print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
+ dol_fiche_head($head, 'referers', $titre, -1, $picto);
@@ -111,20 +102,16 @@
- print $hookmanager->resPrint;
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- $linkback = '
'.$langs->trans("BackToList").' ';
-
- $shownav = 1;
- if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
- $shownav = 0;
- }
-
- dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
-
- print '
';
-
- print '
';
- print '
';
-
- $nboflines = show_stats_for_company($product, $socid);
+ print $hookmanager->resPrint;
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $shownav = 1;
+ if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
+
+ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
+
+ print '';
+
+ print '
';
+ print '
';
+
+ $nboflines = show_stats_for_company($product, $socid);
@@ -134,7 +121,8 @@
- print '';
- print '
';
-
- print dol_get_fiche_end();
-
-
- if ($user->hasRight('propal', 'lire')) {
+ print '';
+ print '
';
+
+ dol_fiche_end();
+
+
+ if ($user->rights->propale->lire)
+ {
@@ -144 +132 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -146 +133,0 @@
- }
@@ -150 +137 @@
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->rights->societe->client->voir && !$socid)
@@ -152 +138,0 @@
- }
@@ -156,13 +142,9 @@
- $sql .= " AND d.fk_product = ".((int) $product->id);
- if (!empty($search_month)) {
- $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')';
- }
- if (!empty($search_year)) {
- $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')';
- }
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
- if ($socid) {
- $sql .= " AND p.fk_soc = ".((int) $socid);
- }
+ $sql .= " AND d.fk_product =".$product->id;
+ if (!empty($search_month))
+ $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')';
+ if (!empty($search_year))
+ $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')';
+ if (!$user->rights->societe->client->voir && !$socid)
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($socid)
+ $sql .= " AND p.fk_soc = ".$socid;
@@ -177 +159,2 @@
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+ {
@@ -185 +168,2 @@
- if ($result) {
+ if ($result)
+ {
@@ -188,11 +172,4 @@
- $option = '&id='.$product->id;
-
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $option .= '&limit='.((int) $limit);
- }
- if (!empty($search_month)) {
- $option .= '&search_month='.urlencode($search_month);
- }
- if (!empty($search_year)) {
- $option .= '&search_year='.urlencode($search_year);
- }
+ if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
+ if (!empty($id)) $option .= '&id='.$product->id;
+ if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
+ if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
@@ -201,2 +178 @@
- print ' ';
- if (!empty($sortfield)) {
+ if (!empty($sortfield))
@@ -204,2 +180 @@
- }
- if (!empty($sortorder)) {
+ if (!empty($sortorder))
@@ -207 +181,0 @@
- }
@@ -211,3 +185 @@
- if (!empty($page)) {
- $option .= '&page='.urlencode($page);
- }
+ if (!empty($page)) $option .= '&page='.urlencode($page);
@@ -216 +188 @@
- print '';
+ print '
';
@@ -228 +200 @@
- print '
';
+ print '
';
@@ -235 +207 @@
- print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder);
@@ -239,2 +211,4 @@
- if ($num > 0) {
- while ($i < min($num, $limit)) {
+ if ($num > 0)
+ {
+ while ($i < min($num, $limit))
+ {
@@ -254 +228 @@
- print '
'.$societestatic->getNomUrl(1).' ';
+ print ''.$societestatic->getNomUrl(1).' ';
@@ -265,17 +239,14 @@
- print '';
- if ($num < $limit) {
- print ''.$langs->trans("Total").' ';
- } else {
- print ''.$langs->trans("Totalforthispage").' ';
- }
- print ' ';
- print ''.$total_qty.' ';
- print ''.price($total_ht).' ';
- print ' ';
- print "
";
- print '
';
- print '';
- } else {
- dol_print_error($db);
- }
- $db->free($result);
+ print '';
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ print ' ';
+ print ''.$total_qty.' ';
+ print ''.price($total_ht).' ';
+ print ' ';
+ print "
";
+ print '
';
+ print '';
+ } else {
+ dol_print_error($db);
+ }
+ $db->free($result);