From 96c5eacf4aa669786b90b4ce6c6930a5dda8fd1b Mon Sep 17 00:00:00 2001 From: simnandez Date: Sat, 12 Jan 2013 09:58:21 +0100 Subject: [PATCH] [ task #652 ] Reduce clicks into creaton of orders, invoices, etc. --- htdocs/compta/facture.php | 164 +++++++++++++----------- htdocs/core/menus/standard/eldy.lib.php | 4 +- 2 files changed, 92 insertions(+), 76 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 75a67be6bff..adecacd40ef 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -5,7 +5,7 @@ * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -1804,7 +1804,7 @@ if ($action == 'create') print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; // Factures predefinies - if (empty($origin) && empty($originid)) + if (empty($origin) && empty($originid) && $socid) { $sql = 'SELECT r.rowid, r.titre, r.total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; @@ -1834,16 +1834,27 @@ if ($action == 'create') $db->free($resql); } else - { + { dol_print_error($db); } } // Tiers - print ''.$langs->trans('Customer').''; - print $soc->getNomUrl(1); - print ''; - print ''; + print ''; + print ''.$langs->trans('Customer').''; + if($socid) + { + print ''; + print $soc->getNomUrl(1); + print ''; + print ''; + } + else + { + print ''; + print $form->select_company('','socid','s.client = 1',1); + print ''; + } print ''."\n"; // Type de facture @@ -1916,72 +1927,77 @@ if ($action == 'create') print $desc; print ''."\n"; } - - // Replacement - print ''; - print ''; - print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); - print $desc; - print ''."\n"; - - // Credit note - print ''; - print ''; - print ''; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; - // $text.=''; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); - print $desc; - print ''."\n"; - - print ''; - print ''; - - // Discounts for third party - print ''.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",''.$soc->remise_client.''); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print ' ('.$langs->trans("EditRelativeDiscount").')'; - print '. '; - print '
'; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",''.price($absolute_discount).'',$langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print ' ('.$langs->trans("EditGlobalDiscounts").')'; - print '.'; - print ''; - + + if ($socid) + { + // Replacement + print ''; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print ''."\n"; + + // Credit note + print ''; + print ''; + print ''; + $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + // $text.=''; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + print $desc; + print ''."\n"; + } + print ''; + print ''; + + if($socid) + { + // Discounts for third party + print ''.$langs->trans('Discounts').''; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",''.$soc->remise_client.''); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print ' ('.$langs->trans("EditRelativeDiscount").')'; + print '. '; + print '
'; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",''.price($absolute_discount).'',$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print ' ('.$langs->trans("EditGlobalDiscounts").')'; + print '.'; + print ''; + } + // Date invoice print ''.$langs->trans('Date').''; $form->select_date($dateinvoice,'','','','',"add",1,1); @@ -1998,7 +2014,7 @@ if ($action == 'create') print ''; // Project - if (! empty($conf->projet->enabled)) + if (! empty($conf->projet->enabled) && $socid) { $langs->load('projects'); print ''.$langs->trans('Project').''; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7fdff999410..51e61dfb6c9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2010 Regis Houssin - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -913,7 +913,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); if (empty($user->societe_id)) { - $newmenu->add("/compta/clients.php?action=facturer&leftmenu=customers_bills",$langs->trans("NewBill"),1,$user->rights->facture->creer); + $newmenu->add("/compta/facture.php?action=create&leftmenu=customers_bills",$langs->trans("NewBill"),1,$user->rights->facture->creer); } $newmenu->add("/compta/facture/fiche-rec.php?leftmenu=customers_bills",$langs->trans("Repeatables"),1,$user->rights->facture->lire);