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');
@ -124,7 +124,7 @@ if (($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'ye
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
$result=facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); $result=facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
if ($result > 0) if ($result > 0)
{ {
@ -449,7 +449,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$error=1; $error=1;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
} }
if (! ($_POST['fac_replacement'] > 0)) if (! ($_POST['fac_replacement'] > 0))
{ {
$error=1; $error=1;
@ -496,9 +496,9 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$error=1; $error=1;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
} }
if (! $error) if (! $error)
{ {
// Si facture avoir // Si facture avoir
$datefacture = dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datefacture = dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
@ -554,9 +554,9 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$error=1; $error=1;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
} }
if (! $error) if (! $error)
{ {
// Si facture standard // Si facture standard
$facture->socid = $_POST['socid']; $facture->socid = $_POST['socid'];
@ -573,7 +573,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$facture->amount = $_POST['amount']; $facture->amount = $_POST['amount'];
$facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_absolue = $_POST['remise_absolue'];
$facture->remise_percent = $_POST['remise_percent']; $facture->remise_percent = $_POST['remise_percent'];
if (! $_POST['propalid'] && ! $_POST['commandeid'] && ! $_POST['contratid']) if (! $_POST['propalid'] && ! $_POST['commandeid'] && ! $_POST['contratid'])
{ {
for ($i = 1; $i <= $NBLINES; $i++) for ($i = 1; $i <= $NBLINES; $i++)
@ -591,7 +591,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$facture->add_product($_POST['idprod'.$i],$_POST['qty'.$i],$_POST['remise_percent'.$i],$startday,$endday); $facture->add_product($_POST['idprod'.$i],$_POST['qty'.$i],$_POST['remise_percent'.$i],$startday,$endday);
} }
} }
$facid = $facture->create($user); $facid = $facture->create($user);
} }
else else
@ -603,7 +603,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
{ {
$facture->propalid = $_POST['propalid']; $facture->propalid = $_POST['propalid'];
$facid = $facture->create($user); $facid = $facture->create($user);
if ($facid > 0) if ($facid > 0)
{ {
$prop = New Propal($db); $prop = New Propal($db);
@ -612,7 +612,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++) for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++)
{ {
$desc=($prop->lignes[$i]->desc?$prop->lignes[$i]->desc:$prop->lignes[$i]->libelle); $desc=($prop->lignes[$i]->desc?$prop->lignes[$i]->desc:$prop->lignes[$i]->libelle);
$result = $facture->addline( $result = $facture->addline(
$facid, $facid,
$desc, $desc,
@ -627,7 +627,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$prop->lignes[$i]->info_bits, $prop->lignes[$i]->info_bits,
$prop->lignes[$i]->fk_remise_except $prop->lignes[$i]->fk_remise_except
); );
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
@ -645,7 +645,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$error++; $error++;
} }
} }
/* /*
* Si création depuis commande * Si création depuis commande
*/ */
@ -653,7 +653,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
{ {
$facture->commandeid = $_POST['commandeid']; $facture->commandeid = $_POST['commandeid'];
$facid = $facture->create($user); $facid = $facture->create($user);
if ($facid > 0) if ($facid > 0)
{ {
$comm = New Commande($db); $comm = New Commande($db);
@ -664,7 +664,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
$desc=($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); $desc=($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
$result = $facture->addline( $result = $facture->addline(
$facid, $facid,
$desc, $desc,
@ -679,7 +679,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$lines[$i]->info_bits, $lines[$i]->info_bits,
$lines[$i]->fk_remise_except $lines[$i]->fk_remise_except
); );
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
@ -697,7 +697,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$error++; $error++;
} }
} }
/* /*
* Si création depuis contrat * Si création depuis contrat
*/ */
@ -705,24 +705,24 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
{ {
$facture->contratid = $_POST['contratid']; $facture->contratid = $_POST['contratid'];
$facid = $facture->create($user); $facid = $facture->create($user);
if ($facid > 0) if ($facid > 0)
{ {
$contrat = New Contrat($db); $contrat = New Contrat($db);
if ($contrat->fetch($_POST['contratid']) > 0) if ($contrat->fetch($_POST['contratid']) > 0)
{ {
$lines = $contrat->fetch_lignes(); $lines = $contrat->fetch_lignes();
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
$desc=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle); $desc=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle);
// Plage de dates // Plage de dates
$date_start=$contrat->lignes[$i]->date_debut_prevue; $date_start=$contrat->lignes[$i]->date_debut_prevue;
if ($contrat->lignes[$i]->date_debut_reel) $date_start=$contrat->lignes[$i]->date_debut_reel; if ($contrat->lignes[$i]->date_debut_reel) $date_start=$contrat->lignes[$i]->date_debut_reel;
$date_end=$contrat->lignes[$i]->date_fin_prevue; $date_end=$contrat->lignes[$i]->date_fin_prevue;
if ($contrat->lignes[$i]->date_fin_reel) $date_end=$contrat->lignes[$i]->date_fin_reel; if ($contrat->lignes[$i]->date_fin_reel) $date_end=$contrat->lignes[$i]->date_fin_reel;
$result = $facture->addline( $result = $facture->addline(
$facid, $facid,
$desc, $desc,
@ -737,7 +737,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$lines[$i]->info_bits, $lines[$i]->info_bits,
$lines[$i]->fk_remise_except $lines[$i]->fk_remise_except
); );
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
@ -833,7 +833,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$tva_tx = get_default_tva($mysoc,$fac->client,$prod->tva_tx); $tva_tx = get_default_tva($mysoc,$fac->client,$prod->tva_tx);
$tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx); $tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx);
// On defini prix unitaire // On defini prix unitaire
if ($conf->global->PRODUIT_MULTIPRICES == 1) if ($conf->global->PRODUIT_MULTIPRICES == 1)
{ {
@ -861,7 +861,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU');
} }
} }
$desc = $prod->description; $desc = $prod->description;
$desc.= $prod->description && $_POST['np_desc'] ? "\n" : ""; $desc.= $prod->description && $_POST['np_desc'] ? "\n" : "";
$desc.= $_POST['np_desc']; $desc.= $_POST['np_desc'];
@ -1050,7 +1050,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
if (is_readable($file)) if (is_readable($file))
{ {
$fac->fetch_client(); $fac->fetch_client();
if ($_POST['sendto']) if ($_POST['sendto'])
{ {
// Le destinataire a été fourni via le champ libre // Le destinataire a été fourni via le champ libre
@ -1115,10 +1115,10 @@ 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');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
@ -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
{ {
@ -1524,7 +1524,7 @@ if ($_GET['action'] == 'create')
//print '<input type="hidden" name="remise_absolue" value="'.$propal->remise_absolue.'">'."\n"; //print '<input type="hidden" name="remise_absolue" value="'.$propal->remise_absolue.'">'."\n";
//print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n"; //print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n";
print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<tr><td>'.$langs->trans('Proposal').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.img_object($langs->trans("ShowPropal"),'propal').' '.$propal->ref.'</a></td></tr>'; print '<tr><td>'.$langs->trans('Proposal').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.img_object($langs->trans("ShowPropal"),'propal').' '.$propal->ref.'</a></td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($propal->price).'</td></tr>'; print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($propal->price).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($propal->total_tva)."</td></tr>"; print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($propal->total_tva)."</td></tr>";
@ -1538,7 +1538,7 @@ if ($_GET['action'] == 'create')
//print '<input type="hidden" name="remise_absolue" value="'.$commande->remise_absolue.'">'."\n"; //print '<input type="hidden" name="remise_absolue" value="'.$commande->remise_absolue.'">'."\n";
//print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n"; //print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n";
print '<input type="hidden" name="commandeid" value="'.$commande->id.'">'; print '<input type="hidden" name="commandeid" value="'.$commande->id.'">';
print '<tr><td>'.$langs->trans('Order').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td></tr>'; print '<tr><td>'.$langs->trans('Order').'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($commande->total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($commande->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($commande->total_tva)."</td></tr>"; print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($commande->total_tva)."</td></tr>";
@ -1805,7 +1805,7 @@ else
if ($user->societe_id>0 && $user->societe_id!=$fac->socid) accessforbidden('',0); if ($user->societe_id>0 && $user->societe_id!=$fac->socid) accessforbidden('',0);
$result=$fac->fetch_client(); $result=$fac->fetch_client();
$soc = new Societe($db, $fac->socid); $soc = new Societe($db, $fac->socid);
$soc->fetch($fac->socid); $soc->fetch($fac->socid);
@ -1817,21 +1817,21 @@ else
$resteapayer = $fac->total_ttc - $totalpaye - $totalavoir; $resteapayer = $fac->total_ttc - $totalpaye - $totalavoir;
if ($fac->paye) $resteapayer=0; if ($fac->paye) $resteapayer=0;
$resteapayeraffiche=$resteapayer; $resteapayeraffiche=$resteapayer;
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($fac->user_author)
{ {
$author->id = $fac->user_author; $author->id = $fac->user_author;
$author->fetch(); $author->fetch();
} }
$facidnext=$fac->getIdReplacingInvoice(); $facidnext=$fac->getIdReplacingInvoice();
$head = facture_prepare_head($fac); $head = facture_prepare_head($fac);
dolibarr_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer')); dolibarr_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'));
/* /*
* Confirmation de la conversion de l'avoir en reduc * Confirmation de la conversion de l'avoir en reduc
*/ */
@ -1841,7 +1841,7 @@ else
$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc'); $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc');
print '<br />'; print '<br />';
} }
/* /*
* Confirmation de la suppression de la facture * Confirmation de la suppression de la facture
*/ */
@ -1851,7 +1851,7 @@ else
$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('DeleteBill'),$text,'confirm_delete'); $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('DeleteBill'),$text,'confirm_delete');
print '<br />'; print '<br />';
} }
/* /*
* Confirmation de la validation * Confirmation de la validation
*/ */
@ -1880,7 +1880,7 @@ else
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$text,'confirm_valid'); $html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$text,'confirm_valid');
print '<br />'; print '<br />';
} }
/* /*
* Confirmation du classement payé * Confirmation du classement payé
*/ */
@ -1925,7 +1925,7 @@ else
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ClassifyPayed'),$langs->trans('ConfirmClassifyPayedPartially',$fac->ref),'confirm_payed_partially',$formquestion); $html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ClassifyPayed'),$langs->trans('ConfirmClassifyPayedPartially',$fac->ref),'confirm_payed_partially',$formquestion);
print '<br />'; print '<br />';
} }
/* /*
* Confirmation du classement abandonne * Confirmation du classement abandonne
*/ */
@ -1969,7 +1969,7 @@ else
print '<br />'; print '<br />';
} }
} }
/* /*
* Confirmation de la suppression d'une ligne produit * Confirmation de la suppression d'une ligne produit
*/ */
@ -1978,13 +1978,13 @@ else
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;rowid='.$_GET["rowid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline'); $html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;rowid='.$_GET["rowid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline');
print '<br />'; print '<br />';
} }
/* /*
* Facture * Facture
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference // Reference
print '<tr><td width="20%">'.$langs->trans('Ref').'</td>'; print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
print '<td colspan="5">'.$fac->ref; print '<td colspan="5">'.$fac->ref;
@ -1999,14 +1999,14 @@ else
dolibarr_print_error('',$discount->error); dolibarr_print_error('',$discount->error);
} }
print '</td></tr>'; print '</td></tr>';
// 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>';
@ -2031,12 +2031,12 @@ else
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Tiers Société // Tiers Société
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>'; print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>';
print '</tr>'; print '</tr>';
// Type // Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="5">'; print '<tr><td>'.$langs->trans('Type').'</td><td colspan="5">';
print $fac->getLibType(); print $fac->getLibType();
@ -2074,7 +2074,7 @@ else
print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
} }
print '</td></tr>'; print '</td></tr>';
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">'; print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
@ -2111,17 +2111,17 @@ else
} }
if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print '</td></tr>'; print '</td></tr>';
// Dates // Dates
print '<tr><td>'.$langs->trans('Date').'</td>'; print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="3">'.dolibarr_print_date($fac->date,'daytext').'</td>'; print '<td colspan="3">'.dolibarr_print_date($fac->date,'daytext').'</td>';
$nbrows=8; $nbrows=8;
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++; if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++;
if ($conf->projet->enabled) $nbrows++; if ($conf->projet->enabled) $nbrows++;
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">'; print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
/* /*
* Liste des paiements * Liste des paiements
*/ */
@ -2162,7 +2162,7 @@ else
print '</tr>'; print '</tr>';
$i++; $i++;
} }
// Already payed // Already payed
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td nowrap="nowrap">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td nowrap="nowrap">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
@ -2199,7 +2199,7 @@ else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
// Payé partiellement 'escompte' // Payé partiellement 'escompte'
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'discount_vat') if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'discount_vat')
{ {
@ -2254,9 +2254,9 @@ else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</td></tr>'; print '</td></tr>';
// Date limite reglement // Date limite reglement
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DateMaxPayment').'</td>'; print '<td>'.$langs->trans('DateMaxPayment').'</td>';
@ -2271,7 +2271,7 @@ else
print '&nbsp;'; print '&nbsp;';
} }
print '</td></tr>'; print '</td></tr>';
// Conditions de règlement // Conditions de règlement
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
@ -2314,36 +2314,36 @@ else
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'none'); $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'none');
} }
print '</td></tr>'; print '</td></tr>';
// 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>';
print '<td align="right" colspan="2" nowrap>'.price($fac->total_ht).'</td>'; print '<td align="right" colspan="2" nowrap>'.price($fac->total_ht).'</td>';
@ -2352,11 +2352,11 @@ else
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_ttc).'</td>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans('Status').'</td>'; print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td align="left" colspan="3">'.($fac->getLibStatut(4,$totalpaye)).'</td></tr>'; print '<td align="left" colspan="3">'.($fac->getLibStatut(4,$totalpaye)).'</td></tr>';
// Projet // Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
@ -2443,7 +2443,7 @@ else
{ {
print '<td>'; print '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
// Affiche ligne produit // Affiche ligne produit
$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; $text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
if ($objp->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); if ($objp->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
@ -2465,7 +2465,7 @@ else
{ {
print '<td>'; print '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
if (($objp->info_bits & 2) == 2) if (($objp->info_bits & 2) == 2)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$fac->socid.'">'; print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$fac->socid.'">';
@ -2718,7 +2718,7 @@ else
print '<td align="right">'.$langs->trans('ReductionShort').'</td>'; print '<td align="right">'.$langs->trans('ReductionShort').'</td>';
print '<td colspan="4">&nbsp;</td>'; print '<td colspan="4">&nbsp;</td>';
print '</tr>'; print '</tr>';
print '<form id="addpredefinedproduct" action="'.$_SERVER['PHP_SELF'].'#add" method="post">'; print '<form id="addpredefinedproduct" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">'; print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addligne_predef">'; print '<input type="hidden" name="action" value="addligne_predef">';
@ -2735,9 +2735,9 @@ else
{ {
$html->select_produits('','idprod','',$conf->produit->limit_size); $html->select_produits('','idprod','',$conf->produit->limit_size);
} }
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>'; if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';
// éditeur wysiwyg // éditeur wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{ {
@ -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)
{ {
@ -2817,7 +2817,7 @@ else
print '<span class="butActionRefused" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('ReOpen').'</span>'; print '<span class="butActionRefused" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('ReOpen').'</span>';
} }
} }
// Récurrente // Récurrente
if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0) if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0)
{ {
@ -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
{ {
@ -2855,7 +2855,7 @@ else
print '>'.$langs->trans('Validate').'</a>'; print '>'.$langs->trans('Validate').'</a>';
} }
} }
// Envoyer // Envoyer
if (($fac->statut == 1 || $fac->statut == 2) && $user->rights->facture->envoyer) if (($fac->statut == 1 || $fac->statut == 2) && $user->rights->facture->envoyer)
{ {
@ -2961,8 +2961,8 @@ else
print '</div>'; print '</div>';
} }
} }
if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend') if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend')
{ {
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
@ -3050,7 +3050,7 @@ else
if ($num) if ($num)
{ {
$langs->load("orders"); $langs->load("orders");
$i = 0; $total = 0; $i = 0; $total = 0;
if ($somethingshown) print '<br>'; if ($somethingshown) print '<br>';
$somethingshown=1; $somethingshown=1;
@ -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;
@ -3323,7 +3323,7 @@ else
{ {
$sql .= ' AND (s.nom like \'%'.addslashes($sall).'%\' OR f.facnumber like \'%'.addslashes($sall).'%\' OR f.note like \'%'.addslashes($sall).'%\' OR fd.description like \'%'.addslashes($sall).'%\')'; $sql .= ' AND (s.nom like \'%'.addslashes($sall).'%\' OR f.facnumber like \'%'.addslashes($sall).'%\' OR f.note like \'%'.addslashes($sall).'%\' OR fd.description like \'%'.addslashes($sall).'%\')';
} }
$sql .= ' GROUP BY f.rowid'; $sql .= ' GROUP BY f.rowid';
$sql .= ' ORDER BY '; $sql .= ' ORDER BY ';
@ -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";
@ -3400,11 +3400,11 @@ else
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$facturestatic->id=$objp->facid; $facturestatic->id=$objp->facid;
$facturestatic->ref=$objp->facnumber; $facturestatic->ref=$objp->facnumber;
$facturestatic->type=$objp->type; $facturestatic->type=$objp->type;
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="90" class="nobordernopadding" nowrap="nowrap">'; print '<td width="90" class="nobordernopadding" nowrap="nowrap">';
print $facturestatic->getNomUrl(1); print $facturestatic->getNomUrl(1);
@ -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;