Fix: Invoice default date to null when creating invoice from contract

This commit is contained in:
Laurent Destailleur 2008-08-07 20:39:35 +00:00
parent bf45b7340a
commit e2a795886e

View File

@ -22,10 +22,10 @@
*/ */
/** /**
\file htdocs/compta/facture.php * \file htdocs/compta/facture.php
\ingroup facture * \ingroup facture
\brief Page de création/visu facture * \brief Page de création/visu facture
\version $Id$ * \version $Id$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
@ -1115,9 +1115,9 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
$formmail = new FormMail($db); $formmail = new FormMail($db);
$attachedfiles=$formmail->get_attached_files(); $attachedfiles=$formmail->get_attached_files();
$filepath = $attachedfiles['paths']; $filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names']; $filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes']; $mimetype = $attachedfiles['mimes'];
// Send mail // Send mail
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
@ -1301,7 +1301,7 @@ if ($_GET['action'] == 'create')
$mode_reglement_id = $soc->mod_reglement; $mode_reglement_id = $soc->mod_reglement;
$remise_percent = $soc->remise_client; $remise_percent = $soc->remise_client;
$remise_absolue = 0; $remise_absolue = 0;
$dateinvoice=$contrat->date_contrat; $dateinvoice=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
} }
else else
{ {
@ -2002,11 +2002,11 @@ else
// Ref client // Ref client
/* /*
\todo \todo
L'info "Reference commande client" est une carac de la commande et non de la facture. L'info "Reference commande client" est une carac de la commande et non de la facture.
Elle devrait donc etre stockée sur l'objet commande lié à la facture et non sur la facture. Elle devrait donc etre stockée sur l'objet commande lié à la facture et non sur la facture.
Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF à 1. Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF à 1.
*/ */
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF)
{ {
print '<tr><td>'; print '<tr><td>';
@ -2318,31 +2318,31 @@ else
// Lit lignes de facture pour déterminer montant // Lit lignes de facture pour déterminer montant
// On s'en sert pas mais ca sert pour debuggage // On s'en sert pas mais ca sert pour debuggage
/* /*
$sql = 'SELECT l.price as price, l.qty, l.rowid, l.tva_taux,'; $sql = 'SELECT l.price as price, l.qty, l.rowid, l.tva_taux,';
$sql .= ' l.remise_percent, l.subprice'; $sql .= ' l.remise_percent, l.subprice';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l '; $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l ';
$sql .= ' WHERE l.fk_facture = '.$fac->id; $sql .= ' WHERE l.fk_facture = '.$fac->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num_lignes = $db->num_rows($resql); $num_lignes = $db->num_rows($resql);
$i=0; $i=0;
$total_lignes_ht=0; $total_lignes_ht=0;
$total_lignes_vat=0; $total_lignes_vat=0;
$total_lignes_ttc=0; $total_lignes_ttc=0;
while ($i < $num_lignes) while ($i < $num_lignes)
{ {
$obj=$db->fetch_object($resql); $obj=$db->fetch_object($resql);
$ligne_ht=($obj->price*$obj->qty); $ligne_ht=($obj->price*$obj->qty);
$ligne_vat=($ligne_ht*$obj->tva_taux/100); $ligne_vat=($ligne_ht*$obj->tva_taux/100);
$ligne_ttc=($ligne_ht+$ligne_vat); $ligne_ttc=($ligne_ht+$ligne_vat);
$total_lignes_ht+=$ligne_ht; $total_lignes_ht+=$ligne_ht;
$total_lignes_vat+=$ligne_vat; $total_lignes_vat+=$ligne_vat;
$total_lignes_ttc+=$ligne_ttc; $total_lignes_ttc+=$ligne_ttc;
$i++; $i++;
} }
} }
*/ */
// Montants // Montants
print '<tr><td>'.$langs->trans('AmountHT').'</td>'; print '<tr><td>'.$langs->trans('AmountHT').'</td>';
@ -2805,8 +2805,8 @@ else
// Reopen a classified invoice // Reopen a classified invoice
if ($fac->statut == 3 && // A abandonned invoice if ($fac->statut == 3 && // A abandonned invoice
$fac->getIdReplacingInvoice() == 0 && // Not replaced by another invoice $fac->getIdReplacingInvoice() == 0 && // Not replaced by another invoice
($fac->close_code == 'badcustomer' || $fac->close_code == 'abandon')) ($fac->close_code == 'badcustomer' || $fac->close_code == 'abandon'))
{ {
if (! $facidnext) if (! $facidnext)
{ {
@ -2846,7 +2846,7 @@ else
$num = $fac->ref; $num = $fac->ref;
} }
$url = $_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=confirm_valid&confirm=yes'; $url = $_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=confirm_valid&confirm=yes';
print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.dol_escape_js($langs->trans('ConfirmValidateBill',$num)).'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"'; print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.dol_escape_js($langs->trans('ConfirmValidateBill',$num)).'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"';
} }
else else
{ {
@ -3304,13 +3304,13 @@ else
{ {
$sql .= ' AND f.total_ttc = \''.addslashes(trim($_GET['search_montant_ttc'])).'\''; $sql .= ' AND f.total_ttc = \''.addslashes(trim($_GET['search_montant_ttc'])).'\'';
} }
if ($month > 0) if ($month > 0)
{ {
if ($year > 0) if ($year > 0)
$sql .= " AND date_format(f.datef, '%Y-%m') = '$year-$month'"; $sql .= " AND date_format(f.datef, '%Y-%m') = '$year-$month'";
else else
$sql .= " AND date_format(f.datef, '%m') = '$month'"; $sql .= " AND date_format(f.datef, '%m') = '$month'";
} }
if ($year > 0) if ($year > 0)
{ {
$sql .= ' AND date_format(f.datef, \'%Y\') = '.$year; $sql .= ' AND date_format(f.datef, \'%Y\') = '.$year;
@ -3358,7 +3358,7 @@ else
print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','','&amp;socid='.$socid.'&amp;month='.$month.'&amp;year=' . $year,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','','&amp;socid='.$socid.'&amp;month='.$month.'&amp;year=' . $year,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','','&amp;socid='.$socid.'&amp;month='.$month.'&amp;year=' . $year,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','','&amp;socid='.$socid.'&amp;month='.$month.'&amp;year=' . $year,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','','&amp;socid='.$socid.'&amp;month='.$month.'&amp;year=' . $year,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','','&amp;socid='.$socid.'&amp;month='.$month.'&amp;year=' . $year,'align="right"',$sortfield,$sortorder);
//print '<td class="liste_titre">&nbsp;</td>'; //print '<td class="liste_titre">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Lignes des champs de filtre // Lignes des champs de filtre
@ -3367,13 +3367,13 @@ else
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET['search_ref'].'">'; print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET['search_ref'].'">';
print '<td class="liste_titre" colspan="1" align="center">'; print '<td class="liste_titre" colspan="1" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
//print '&nbsp;'.$langs->trans('Year').': '; //print '&nbsp;'.$langs->trans('Year').': ';
$max_year = date("Y"); $max_year = date("Y");
$syear = $year; $syear = $year;
//if ($syear == '') $syear = date("Y"); //if ($syear == '') $syear = date("Y");
$html->select_year($syear,'year',1, '', $max_year); $html->select_year($syear,'year',1, '', $max_year);
print '</td>'; print '</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_societe" value="'.$_GET['search_societe'].'">'; print '<input class="flat" type="text" name="search_societe" value="'.$_GET['search_societe'].'">';
print '</td><td class="liste_titre" align="right">'; print '</td><td class="liste_titre" align="right">';
@ -3381,9 +3381,9 @@ else
print '</td><td class="liste_titre" align="right">'; print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET['search_montant_ttc'].'">'; print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET['search_montant_ttc'].'">';
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
print '&nbsp;'; print '&nbsp;';
print '</td>'; print '</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans('Search').'">'; print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans('Search').'">';
print "</td></tr>\n"; print "</td></tr>\n";
@ -3450,8 +3450,8 @@ else
print '<td align="right" nowrap="nowrap">'; print '<td align="right" nowrap="nowrap">';
print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am,$objp->type); print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am,$objp->type);
print "</td>"; print "</td>";
//print "<td>&nbsp;</td>"; //print "<td>&nbsp;</td>";
print "</tr>\n"; print "</tr>\n";
$total+=$objp->total; $total+=$objp->total;
$total_ttc+=$objp->total_ttc; $total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am; $totalrecu+=$objp->am;