Fix: Pb with predefined invoices

This commit is contained in:
Laurent Destailleur 2013-08-06 23:50:12 +02:00
parent cb4b8ffb8a
commit acf3db8512
2 changed files with 38 additions and 28 deletions

View File

@ -26,9 +26,9 @@
/**
* \file htdocs/compta/facture.php
* \ingroup facture
* \brief Page to create/see an invoice
*/
* \ingroup facture
* \brief Page to create/see an invoice
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
@ -1952,9 +1952,9 @@ llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES
/*********************************************************************
*
* Mode creation
*
**********************************************************************/
* Mode creation
*
**********************************************************************/
if ($action == 'create')
{
$facturestatic=new Facture($db);
@ -2048,8 +2048,26 @@ if ($action == 'create')
// Ref
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
// Tiers
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>';
if($soc->id > 0)
{
print '<td colspan="2">';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
}
else
{
print '<td colspan="2">';
print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
print '</td>';
}
print '</tr>'."\n";
// Factures predefinies
if (empty($origin) && empty($originid) && $socid>0)
if (empty($origin) && empty($originid) && $socid > 0)
{
$sql = 'SELECT r.rowid, r.titre, r.total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r';
@ -2084,24 +2102,6 @@ if ($action == 'create')
}
}
// Tiers
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>';
if($soc->id > 0)
{
print '<td colspan="2">';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
}
else
{
print '<td colspan="2">';
print $form->select_company('','socid','s.client = 1 OR s.client = 3',1);
print '</td>';
}
print '</tr>'."\n";
// Type de facture
$facids=$facturestatic->list_replacable_invoices($soc->id);
if ($facids < 0)

View File

@ -106,6 +106,7 @@ if ($action == 'delete' && $user->rights->facture->supprimer)
llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec');
$form = new Form($db);
$companystatic = new Societe($db);
/*
* Create mode
@ -114,7 +115,7 @@ if ($action == 'create')
{
print_fiche_titre($langs->trans("CreateRepeatableInvoice"));
$object = new Facture($db); // Source invoice
$object = new FactureRec($db); // Source invoice
$product_static = new Product($db);
if ($object->fetch($id) > 0)
@ -364,7 +365,13 @@ else
$author = new User($db);
$author->fetch($object->user_author);
dol_fiche_head($head, 'compta', $langs->trans("PredefinedInvoices"),0,'company'); // Add a div
$head=array();
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
$head[$h][1] = $langs->trans("CardBill");
$head[$h][2] = 'card';
dol_fiche_head($head, 'card', $langs->trans("PredefinedInvoices"),0,'bill'); // Add a div
print '<table class="border" width="100%">';
@ -552,7 +559,10 @@ else
print '<td><a href="'.$_SERVER['PHP_SELF'].'?id='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
print '<td><a href="../fiche.php?socid='.$objp->socid.'">'.$objp->nom.'</a></td>';
$companystatic->id=$objp->socid;
$companystatic->name=$objp->nom;
print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>';
print '<td align="right">'.price($objp->total).'</td>'."\n";