diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index fe73e96e1dd..6cfaa6df2d9 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -26,7 +26,7 @@ * \file htdocs/compta/facture.php * \ingroup facture * \brief Page to create/see an invoice - * \version $Id$ + * \version $Id: facture.php,v 1.839 2011/06/29 15:48:02 grandoc Exp $ */ require('../main.inc.php'); @@ -232,6 +232,14 @@ if ($action == 'valid') } } +if ($action == 'set_thirdparty') +{ + $object->updateObjectField('facture',$id,'fk_soc',$socid); + + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); + exit; +} + if ($action == 'classin') { $object->fetch($id); @@ -2063,10 +2071,24 @@ else print ''; // Third party + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1,'compta'); - print '   ('.$langs->trans('OtherBills').')
'; + if ($conf->global->FACTURE_CHANGE_THIRDPARTY && $action != 'editthirdparty' && $object->brouillon && $user->rights->facture->creer) + print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'
'; + print ''; + if ($action == 'editthirdparty') + { + $html->form_thirdparty($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,'socid'); + } + else + { + print '  '.$soc->getNomUrl(1,'compta'); + print '   ('.$langs->trans('OtherBills').')'; + } + print ''; // Type print ''.$langs->trans('Type').''; @@ -3174,5 +3196,5 @@ else $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/06/29 15:48:02 $ - $Revision: 1.839 $'); ?> diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 771c5b471bc..5f47437f830 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -31,7 +31,7 @@ * \file htdocs/core/class/html.form.class.php * \ingroup core * \brief File of class with all html predefined components - * \version $Id: html.form.class.php,v 1.183 2011/06/29 11:22:36 eldy Exp $ + * \version $Id: html.form.class.php,v 1.184 2011/06/29 15:48:03 grandoc Exp $ */ @@ -2511,6 +2511,42 @@ class Form } } } + +/** + * \brief Affiche formulaire de selection des tiers + * \param page Page + * \param selected Id contact pre-selectionne + * \param htmlname Nom du formulaire select + */ + function form_thirdparty($page, $selected='', $htmlname='socid') + { + global $langs; + + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + $num=$this->select_societes($selected , $htmlname); + print '
'; + } + else + { + if ($selected) + { + require_once(DOL_DOCUMENT_ROOT ."/societe/class/societe.class.php"); + $soc = new Societe($this->db); + $soc->fetch($selected); + print $soc->getNomUrl($langs); + } else { + print " "; + } + } + } /** * \brief Affiche formulaire de selection de l'adresse