From f7e5edb0f80a259e133bdcd9141c98b9b769021e Mon Sep 17 00:00:00 2001 From: simnandez Date: Sat, 19 Jan 2013 10:45:57 +0100 Subject: [PATCH] [ task #652 ] Reduce clicks into creaton of orders, invoices, etc. --- htdocs/commande/fiche.php | 62 +++++++++++++++++-------- htdocs/core/menus/standard/eldy.lib.php | 2 +- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 61f52eadc62..bdfa50cbb6d 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -4,7 +4,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) 2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Marcos GarcĂ­a @@ -204,6 +204,13 @@ else if ($action == 'add' && $user->rights->commande->creer) $action='create'; $error++; } + + if ($socid<1) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); + $action='create'; + $error++; + } if (! $error) { @@ -1355,7 +1362,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G dol_htmloutput_mesg($mesg,$mesgs,'error'); $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); + if ($socid>0) $res=$soc->fetch($socid); if (! empty($origin) && ! empty($originid)) { @@ -1450,26 +1457,43 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print ''; // Client - print ''.$langs->trans('Customer').''.$soc->getNomUrl(1).''; + print ''; + print ''.$langs->trans('Customer').''; + if($socid>0) + { + print ''; + print $soc->getNomUrl(1); + print ''; + print ''; + } + else + { + print ''; + print $form->select_company('','socid','s.client = 1',1); + print ''; + } + print ''."\n"; /* * Contact de la commande */ - print "".$langs->trans("DefaultContact").''; - $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); - print ''; - - // Ligne info remises tiers - print ''.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print '. '; - $absolute_discount=$soc->getAvailableDiscounts(); - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print ''; - + if($socid>0) + { + print "".$langs->trans("DefaultContact").''; + $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); + print ''; + + // Ligne info remises tiers + print ''.$langs->trans('Discounts').''; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount=$soc->getAvailableDiscounts(); + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print ''; + } // Date print ''.$langs->trans('Date').''; $form->select_date('','re','','','',"crea_commande",1,1); @@ -1506,7 +1530,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print ''; // Project - if (! empty($conf->projet->enabled)) + if (! empty($conf->projet->enabled) && $socid>0) { print ''.$langs->trans('Project').''; $numprojet=select_projects($soc->id,$projectid); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 13df2dd6dd0..67b6b816ea9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -852,7 +852,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) { $langs->load("orders"); $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); - $newmenu->add("/societe/societe.php?leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer); + $newmenu->add("/commande/fiche.php?action=create&leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer); $newmenu->add("/commande/liste.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire); if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire); if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire);