浏览代码

Fix statistics on products

Laurent Destailleur 8 年之前
父节点
当前提交
b92980c6ff
共有 2 个文件被更改,包括 28 次插入18 次删除
  1. 5 3
      htdocs/langs/en_US/products.lang
  2. 23 15
      htdocs/product/index.php

+ 5 - 3
htdocs/langs/en_US/products.lang

@@ -25,11 +25,13 @@ ProductAccountancySellCode=Accountancy code (sale)
 ProductOrService=Product or Service
 ProductsAndServices=Products and Services
 ProductsOrServices=Products or Services
-ProductsOnSell=Product for sale or for purchase
+ProductsOnSaleOnly=Products for sale only
+ProductsOnPurchaseOnly=Product for purchase only
 ProductsNotOnSell=Product not for sale and not for purchase
 ProductsOnSellAndOnBuy=Products for sale and for purchase
-ServicesOnSell=Services for sale or for purchase
-ServicesNotOnSell=Services not for sale
+ServicesOnSaleOnly=Services for sale only
+ServicesOnPurchaseOnly=Services for purchase only
+ServicesNotOnSell=Services not for sale and not for purchase
 ServicesOnSellAndOnBuy=Services for sale and for purchase
 LastModifiedProductsAndServices=Latest %s modified products/services
 LastRecordedProducts=Latest %s recorded products

+ 23 - 15
htdocs/product/index.php

@@ -84,7 +84,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
     {
     	$listofsearchfields['search_product']=array('text'=>'ProductOrService');
     }
-    
+
     if (count($listofsearchfields))
     {
     	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
@@ -100,7 +100,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
     		print '</tr>';
     		$i++;
     	}
-    	print '</table>';	
+    	print '</table>';
     	print '</form>';
     	print '<br>';
     }
@@ -111,7 +111,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
  * Number of products and/or services
  */
 $prodser = array();
-$prodser[0][0]=$prodser[0][1]=$prodser[1][0]=$prodser[1][1]=0;
+$prodser[0][0]=$prodser[0][1]=$prodser[0][2]=$prodser[0][3]=0;
+$prodser[1][0]=$prodser[1][1]=$prodser[1][2]=$prodser[1][3]=0;
 
 $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
 $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
@@ -120,9 +121,10 @@ $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
 $result = $db->query($sql);
 while ($objp = $db->fetch_object($result))
 {
-	$status=2;
-	if (! $objp->tosell && ! $objp->tobuy) $status=0;	// To sell OR to buy
-	if ((! $objp->tosell && $objp->tobuy) || ($objp->tosell && ! $objp->tobuy)) $status=1;
+	$status=3;
+	if (! $objp->tosell && ! $objp->tobuy) $status=0;	// Not on sale, not on purchase
+	if ($objp->tosell && ! $objp->tobuy) $status=1;     // On sale only
+	if (! $objp->tosell && $objp->tobuy) $status=2;     // On purchase only
 	$prodser[$objp->fk_product_type][$status]=$objp->total;
 }
 
@@ -134,10 +136,13 @@ if (! empty($conf->product->enabled))
 	$statProducts.= '<td><a href="list.php?type=0&amp;tosell=0&amp;tobuy=0">'.$langs->trans("ProductsNotOnSell").'</a></td><td align="right">'.round($prodser[0][0]).'</td>';
 	$statProducts.= "</tr>";
 	$statProducts.= '<tr class="oddeven">';
-	$statProducts.= '<td><a href="list.php?type=0">'.$langs->trans("ProductsOnSell").'</a></td><td align="right">'.round($prodser[0][1]).'</td>';
+	$statProducts.= '<td><a href="list.php?type=0">'.$langs->trans("ProductsOnSaleOnly").'</a></td><td align="right">'.round($prodser[0][1]).'</td>';
+	$statProducts.= "</tr>";
+	$statProducts.= '<tr class="oddeven">';
+	$statProducts.= '<td><a href="list.php?type=0">'.$langs->trans("ProductsOnPurchaseOnly").'</a></td><td align="right">'.round($prodser[0][2]).'</td>';
 	$statProducts.= "</tr>";
 	$statProducts.= '<tr class="oddeven">';
-	$statProducts.= '<td><a href="list.php?type=0&amp;tosell=1&amp;tobuy=1">'.$langs->trans("ProductsOnSellAndOnBuy").'</a></td><td align="right">'.round($prodser[0][2]).'</td>';
+	$statProducts.= '<td><a href="list.php?type=0&amp;tosell=1&amp;tobuy=1">'.$langs->trans("ProductsOnSellAndOnBuy").'</a></td><td align="right">'.round($prodser[0][3]).'</td>';
 	$statProducts.= "</tr>";
 
 }
@@ -147,10 +152,13 @@ if (! empty($conf->service->enabled))
 	$statServices.= '<td><a href="list.php?type=1&amp;tosell=0&amp;tobuy=0">'.$langs->trans("ServicesNotOnSell").'</a></td><td align="right">'.round($prodser[1][0]).'</td>';
 	$statServices.= "</tr>";
 	$statServices.= '<tr class="oddeven">';
-	$statServices.= '<td><a href="list.php?type=1">'.$langs->trans("ServicesOnSell").'</a></td><td align="right">'.round($prodser[1][1]).'</td>';
+	$statServices.= '<td><a href="list.php?type=1">'.$langs->trans("ServicesOnSaleOnly").'</a></td><td align="right">'.round($prodser[1][1]).'</td>';
+	$statServices.= "</tr>";
+	$statServices.= '<tr class="oddeven">';
+	$statServices.= '<td><a href="list.php?type=1">'.$langs->trans("ServicesOnPurchaseOnly").'</a></td><td align="right">'.round($prodser[1][2]).'</td>';
 	$statServices.= "</tr>";
 	$statServices.= '<tr class="oddeven">';
-	$statServices.= '<td><a href="list.php?type=1&amp;tosell=1&amp;tobuy=1">'.$langs->trans("ServicesOnSellAndOnBuy").'</a></td><td align="right">'.round($prodser[1][2]).'</td>';
+	$statServices.= '<td><a href="list.php?type=1&amp;tosell=1&amp;tobuy=1">'.$langs->trans("ServicesOnSellAndOnBuy").'</a></td><td align="right">'.round($prodser[1][3]).'</td>';
 	$statServices.= "</tr>";
 
 }
@@ -220,7 +228,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
 			while ($i < $num)
 			{
 				$obj = $db->fetch_object($result);
-				
+
 				print '<tr $bc[$var]><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
 				$total+=$obj->nb;
 				$i++;
@@ -292,7 +300,7 @@ if ($result)
 				}
 			}
 
-			
+
 			print '<tr class="oddeven">';
 			print '<td class="nowrap">';
 			$product_static->id=$objp->rowid;
@@ -419,7 +427,7 @@ function activitytrim($product_type)
 		$i = 0;
 
 		$var=true;
-		
+
 		while ($i < $num)
 		{
 			$objp = $db->fetch_object($result);
@@ -427,7 +435,7 @@ function activitytrim($product_type)
 			{
 				if ($trim1+$trim2+$trim3+$trim4 > 0)
 				{
-				    
+
 					print '<tr class="oddeven"><td align=left>'.$tmpyear.'</td>';
 					print '<td align=right>'.price($trim1).'</td>';
 					print '<td align=right>'.price($trim2).'</td>';
@@ -461,7 +469,7 @@ function activitytrim($product_type)
 		}
 		if ($trim1+$trim2+$trim3+$trim4 > 0)
 		{
-		    
+
 			print '<tr class="oddeven"><td align=left>'.$tmpyear.'</td>';
 			print '<td align=right>'.price($trim1).'</td>';
 			print '<td align=right>'.price($trim2).'</td>';