Browse Source

Task # 104: Check if module invoice is active and user has creation
permissions. Move creation invoice to action bar into customer card

simnandez 12 years ago
parent
commit
caef97dc08

+ 9 - 4
htdocs/comm/fiche.php

@@ -504,7 +504,7 @@ if ($id > 0)
 				$sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
 			
 				$resql2=$db->query($sql2);
-				$num2 = $db->num_rows($resql2);
+				$orders2invoice = $db->num_rows($resql2);
 				$db->free($resql2);
 				
 				print '<table class="noborder" width="100%">';
@@ -512,8 +512,8 @@ if ($id > 0)
 				print '<tr class="liste_titre">';
 				print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td>';
 				print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
-				if($num2 > 0) print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').'</a></td>';
-				else print '<td width="20px" align="right"><a href="#">'.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'</a></td>';
+				//if($num2 > 0) print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').'</a></td>';
+				//else print '<td width="20px" align="right"><a href="#">'.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'</a></td>';
 				print '</tr></table></td>';
 				print '</tr>';
 			}
@@ -777,12 +777,17 @@ if ($id > 0)
 			if ($user->rights->facture->creer)
 			{
 				$langs->load("bills");
+				
+				if($orders2invoice > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a>';
+				else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a>';
+				
 				if ($object->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
 				else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
+							
 			}
 			else
 			{
-				print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
+				print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a>';
 			}
 		}
 	}

+ 14 - 1
htdocs/commande/liste.php

@@ -328,7 +328,20 @@ if ($resql)
 		print '<td>';
 		print $companystatic->getNomUrl(1,'customer');
 		print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$companystatic->id.'">';
-		print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->nom,'object_bill').'</a>';
+		
+		// If module invoices enabled and user with invoice creation permissions
+		if (! empty($conf->facture->enabled))
+		{
+			if ($user->rights->facture->creer)
+			{
+		
+				if (($objp->fk_statut > 0 && $objp->fk_statut < 3) || ($objp->fk_statut == 3 && $objp->facturee == 0))
+				{
+			
+					print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->nom,'object_bill').'</a>';
+				}
+			}
+		}
 		print '</td>';
 
 		print '<td>'.$objp->ref_client.'</td>';

+ 0 - 2
htdocs/core/menus/standard/eldy.lib.php

@@ -953,8 +953,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
                 $langs->load("orders");
                 if (! empty($conf->facture->enabled)) $newmenu->add("/commande/liste.php?leftmenu=orders&amp;viewstatut=-3", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
                 //                  if ($leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire);
-				// Does this link is required now we have link into "Orders to bill" list ?
-     			//if ($leftmenu=="orders") $newmenu->add("/commande/customer.php", $langs->trans("GenerateBill"), 1, $user->rights->commande->lire);
             }
 
             // Donations

+ 3 - 1
htdocs/langs/ca_ES/orders.lang

@@ -141,8 +141,10 @@ OrderSource6=Revistes
 QtyOrdered=Qt. demanda
 AddDeliveryCostLine=Afegir una línia de despeses de ports indicant el pes de la comanda
 SetDemandReason=Indicar origen de la comanda
-CreateInvoiceForThisCustomer=Crear una factura a partir de diverses comandes d'aquest client
+CreateInvoiceForThisCustomer=Facturar comandes
+NoOrdersToInvoice=Sense comandes facturables
 CloseProcessedOrdersAutomatically=Classificar automàticament com "Processades" les comandes seleccionades.
+MenuOrdersToBill2=Comandes facturables
 
 # Document models
 PDFEinsteinDescription=Model de comanda complet (logo...)

+ 4 - 2
htdocs/langs/en_US/orders.lang

@@ -155,5 +155,7 @@ OrderByEMail=EMail
 OrderByWWW=Online
 OrderByPhone=Phone
 
-CreateInvoiceForThisCustomer=Create an invoice for several orders of this customer
-CloseProcessedOrdersAutomatically=Classify "Processed" all selected orders. 
+CreateInvoiceForThisCustomer=Bill orders
+NoOrdersToInvoice=No orders billable
+CloseProcessedOrdersAutomatically=Classify "Processed" all selected orders. 
+MenuOrdersToBill2=Billables orders

+ 3 - 1
htdocs/langs/es_ES/orders.lang

@@ -141,8 +141,10 @@ OrderSource6=Revistas
 QtyOrdered=Cant. pedida
 AddDeliveryCostLine=Añadir una línea de gastos de portes indicando el peso del pedido
 SetDemandReason=Indicar origen del pedido
-CreateInvoiceForThisCustomer=Crear una factura a partir de varios pedidos de este cliente
+CreateInvoiceForThisCustomer=Facturar pedidos
+NoOrdersToInvoice=Sin pedidos facturables
 CloseProcessedOrdersAutomatically=Clasificar automáticamente como "Procesados" los pedidos seleccionados.
+MenuOrdersToBill2=Pedidos facturables
 
 # Document models
 PDFEinsteinDescription=Modelo de pedido completo (logo...)

+ 4 - 2
htdocs/langs/fr_FR/orders.lang

@@ -156,5 +156,7 @@ OrderByEMail=EMail
 OrderByWWW=En ligne
 OrderByPhone=Téléphone
 
-CreateInvoiceForThisCustomer=Créer une facture à partir de plusieurs commande de ce client
-CloseProcessedOrdersAutomatically=Classer automatiquement à "Traitées" les commandes sélectionnées.
+CreateInvoiceForThisCustomer=Facturer commandes
+NoOrdersToInvoice=Pas de commandes facturables
+CloseProcessedOrdersAutomatically=Classer automatiquement à "Traitées" les commandes sélectionnées.
+MenuOrdersToBill2=Commandes facturables