New: Add customer invoice ref on invoices

This commit is contained in:
Laurent Destailleur 2012-05-06 02:27:09 +02:00
parent 7a2bead1bf
commit e9fb0f427c
6 changed files with 272 additions and 195 deletions

View File

@ -2309,6 +2309,30 @@ else
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>'; print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
if ($action != 'refclient' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
if ($user->rights->facture->creer && $action == 'refclient')
{
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_ref_client">';
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$object->ref_client.'">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $object->ref_client;
}
print '</td></tr>';
// Third party // Third party
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%">'; print '<table class="nobordernopadding" width="100%">';

View File

@ -85,9 +85,20 @@ if ($id > 0 || ! empty($ref))
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$rowspan=3; $rowspan=3;
// Reference // Ref
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Societe // Societe
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>';

View File

@ -161,6 +161,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>'; print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Customer // Customer
print "<tr><td>".$langs->trans("Company")."</td>"; print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->client->getNomUrl(1,'compta').'</td></tr>'; print '<td colspan="3">'.$object->client->getNomUrl(1,'compta').'</td></tr>';

View File

@ -169,6 +169,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>'; print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Company // Company
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';

View File

@ -103,6 +103,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>'; print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td>'; print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>'; print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>';

View File

@ -30,8 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
if (!$user->rights->facture->lire) if (!$user->rights->facture->lire) accessforbidden();
accessforbidden();
$langs->load("bills"); $langs->load("bills");
$langs->load("banks"); $langs->load("banks");
@ -44,6 +43,8 @@ if ($user->societe_id > 0)
$socid = $user->societe_id; $socid = $user->societe_id;
} }
$object = new Facture($db);
/* /*
* Actions * Actions
@ -51,31 +52,29 @@ if ($user->societe_id > 0)
if ($_GET["action"] == "new") if ($_GET["action"] == "new")
{ {
$fact = new Facture($db); if ($object->fetch($_GET["facid"]))
if ($fact->fetch($_GET["facid"]))
{ {
$result = $fact->demande_prelevement($user); $result = $object->demande_prelevement($user);
if ($result > 0) if ($result > 0)
{ {
Header("Location: prelevement.php?facid=".$fact->id); Header("Location: prelevement.php?facid=".$object->id);
exit; exit;
} }
else else
{ {
$mesg='<div class="error">'.$fact->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
} }
if ($_GET["action"] == "delete") if ($_GET["action"] == "delete")
{ {
$fact = new Facture($db); if ($object->fetch($_GET["facid"]))
if ($fact->fetch($_GET["facid"]))
{ {
$result = $fact->demande_prelevement_delete($user,$_GET["did"]); $result = $object->demande_prelevement_delete($user,$_GET["did"]);
if ($result == 0) if ($result == 0)
{ {
Header("Location: prelevement.php?facid=".$fact->id); Header("Location: prelevement.php?facid=".$object->id);
exit; exit;
} }
} }
@ -100,26 +99,25 @@ $form = new Form($db);
if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"]) if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
{ {
$fac = new Facture($db); if ($object->fetch($_REQUEST["facid"], $_REQUEST["ref"]) > 0)
if ($fac->fetch($_REQUEST["facid"], $_REQUEST["ref"]) > 0)
{ {
if ($mesg) print $mesg.'<br>'; dol_htmloutput_mesg($mesg);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($fac->socid); $soc->fetch($object->socid);
$totalpaye = $fac->getSommePaiement(); $totalpaye = $object->getSommePaiement();
$totalcreditnotes = $fac->getSumCreditNotesUsed(); $totalcreditnotes = $object->getSumCreditNotesUsed();
$totaldeposits = $fac->getSumDepositsUsed(); $totaldeposits = $object->getSumDepositsUsed();
//print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
// We can also use bcadd to avoid pb with floating points // We can also use bcadd to avoid pb with floating points
// For example print 239.2 - 229.3 - 9.9; does not return 0. // For example print 239.2 - 229.3 - 9.9; does not return 0.
//$resteapayer=bcadd($fac->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
$resteapayer = price2num($fac->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
if ($fac->paye) $resteapayer=0; if ($object->paye) $resteapayer=0;
$resteapayeraffiche=$resteapayer; $resteapayeraffiche=$resteapayer;
$absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
@ -128,12 +126,12 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
$absolute_creditnote=price2num($absolute_creditnote,'MT'); $absolute_creditnote=price2num($absolute_creditnote,'MT');
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($object->user_author)
{ {
$author->fetch($fac->user_author); $author->fetch($object->user_author);
} }
$head = facture_prepare_head($fac); $head = facture_prepare_head($object);
dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'),0,'bill'); dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'),0,'bill');
@ -146,7 +144,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="5">'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="5">';
$morehtmlref=''; $morehtmlref='';
$discount=new DiscountAbsolute($db); $discount=new DiscountAbsolute($db);
$result=$discount->fetch(0,$fac->id); $result=$discount->fetch(0,$object->id);
if ($result > 0) if ($result > 0)
{ {
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
@ -155,32 +153,43 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
{ {
dol_print_error('',$discount->error); dol_print_error('',$discount->error);
} }
print $form->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref); print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print "</td></tr>"; print "</td></tr>";
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Third party // Third party
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta'); print '<td colspan="5">'.$soc->getNomUrl(1,'compta');
print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a>)</td>'; print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$object->socid.'">'.$langs->trans('OtherBills').'</a>)</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 $object->getLibType();
if ($fac->type == 1) if ($object->type == 1)
{ {
$facreplaced=new Facture($db); $facreplaced=new Facture($db);
$facreplaced->fetch($fac->fk_facture_source); $facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
} }
if ($fac->type == 2) if ($object->type == 2)
{ {
$facusing=new Facture($db); $facusing=new Facture($db);
$facusing->fetch($fac->fk_facture_source); $facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
} }
$facidavoir=$fac->getListIdAvoirFromInvoice(); $facidavoir=$object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0) if (count($facidavoir) > 0)
{ {
print ' ('.$langs->transnoentities("InvoiceHasAvoir"); print ' ('.$langs->transnoentities("InvoiceHasAvoir");
@ -210,15 +219,15 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '. '; print '. ';
if ($absolute_discount > 0) if ($absolute_discount > 0)
{ {
if ($fac->statut > 0 || $fac->type == 2 || $fac->type == 3) if ($object->statut > 0 || $object->type == 2 || $object->type == 3)
{ {
if ($fac->statut == 0) if ($object->statut == 0)
{ {
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. '; print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. ';
} }
else else
{ {
if ($fac->statut < 1 || $fac->type == 2 || $fac->type == 3) if ($object->statut < 1 || $object->type == 2 || $object->type == 3)
{ {
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
print '<br>'.$text.'.<br>'; print '<br>'.$text.'.<br>';
@ -236,15 +245,15 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
// Remise dispo de type non avoir // Remise dispo de type non avoir
$filter='fk_facture_source IS NULL'; $filter='fk_facture_source IS NULL';
print '<br>'; print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$fac->id,0,'remise_id',$soc->id,$absolute_discount,$filter,$resteapayer); $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter,$resteapayer);
} }
} }
if ($absolute_creditnote > 0) if ($absolute_creditnote > 0)
{ {
// If validated, we show link "add credit note to payment" // If validated, we show link "add credit note to payment"
if ($fac->statut != 1 || $fac->type == 2 || $fac->type == 3) if ($object->statut != 1 || $object->type == 2 || $object->type == 3)
{ {
if ($fac->statut == 0 && $fac->type != 3) if ($object->statut == 0 && $object->type != 3)
{ {
$text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)); $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse")); print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
@ -256,7 +265,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
// Remise dispo de type avoir // Remise dispo de type avoir
$filter='fk_facture_source IS NOT NULL'; $filter='fk_facture_source IS NOT NULL';
if (! $absolute_discount) print '<br>'; if (! $absolute_discount) print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$fac->id,0,'remise_id_for_payment',$soc->id,$absolute_creditnote,$filter,$resteapayer); $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id,0,'remise_id_for_payment',$soc->id,$absolute_creditnote,$filter,$resteapayer);
} }
} }
if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
@ -267,24 +276,24 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Date'); print $langs->trans('Date');
print '</td>'; print '</td>';
if ($fac->type != 2 && $_GET['action'] != 'editinvoicedate' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>'; if ($object->type != 2 && $_GET['action'] != 'editinvoicedate' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($fac->type != 2) if ($object->type != 2)
{ {
if ($_GET['action'] == 'editinvoicedate') if ($_GET['action'] == 'editinvoicedate')
{ {
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->date,'invoicedate'); $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date,'invoicedate');
} }
else else
{ {
print dol_print_date($fac->date,'daytext'); print dol_print_date($object->date,'daytext');
} }
} }
else else
{ {
print dol_print_date($fac->date,'daytext'); print dol_print_date($object->date,'daytext');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -294,19 +303,19 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateMaxPayment'); print $langs->trans('DateMaxPayment');
print '</td>'; print '</td>';
if ($fac->type != 2 && $_GET['action'] != 'editpaymentterm' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>'; if ($object->type != 2 && $_GET['action'] != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($fac->type != 2) if ($object->type != 2)
{ {
if ($_GET['action'] == 'editpaymentterm') if ($_GET['action'] == 'editpaymentterm')
{ {
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->date_lim_reglement,'paymentterm'); $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date_lim_reglement,'paymentterm');
} }
else else
{ {
print dol_print_date($fac->date_lim_reglement,'daytext'); print dol_print_date($object->date_lim_reglement,'daytext');
if ($fac->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late')); if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! $object->am) print img_warning($langs->trans('Late'));
} }
} }
else else
@ -320,18 +329,18 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort'); print $langs->trans('PaymentConditionsShort');
print '</td>'; print '</td>';
if ($fac->type != 2 && $_GET['action'] != 'editconditions' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; if ($object->type != 2 && $_GET['action'] != 'editconditions' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($fac->type != 2) if ($object->type != 2)
{ {
if ($_GET['action'] == 'editconditions') if ($_GET['action'] == 'editconditions')
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'cond_reglement_id'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
} }
else else
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'none'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'none');
} }
} }
else else
@ -345,24 +354,24 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode'); print $langs->trans('PaymentMode');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editmode' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; if ($_GET['action'] != 'editmode' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode') if ($_GET['action'] == 'editmode')
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'mode_reglement_id'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
} }
else else
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'none'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'none');
} }
print '</td></tr>'; print '</td></tr>';
// 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($object->total_ht).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_tva).'</td>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($object->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>';
// Amount Local Taxes // Amount Local Taxes
@ -371,23 +380,23 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{ {
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>';
print '<td align="right" colspan="2" nowrap>'.price($fac->total_localtax1).'</td>'; print '<td align="right" colspan="2" nowrap>'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
} }
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{ {
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>';
print '<td align="right" colspan="2" nowrap>'.price($fac->total_localtax2).'</td>'; print '<td align="right" colspan="2" nowrap>'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->currency).'</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($object->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->currency).'</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">'.($object->getLibStatut(4,$totalpaye)).'</td></tr>';
print '<tr><td>'.$langs->trans("RIB").'</td><td colspan="5">'; print '<tr><td>'.$langs->trans("RIB").'</td><td colspan="5">';
print $soc->display_rib(); print $soc->display_rib();
@ -409,7 +418,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
$sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE fk_facture = ".$fac->id; $sql .= " WHERE fk_facture = ".$object->id;
$sql .= " AND pfd.fk_user_demande = u.rowid"; $sql .= " AND pfd.fk_user_demande = u.rowid";
$sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.traite = 0";
$sql .= " ORDER BY pfd.date_demande DESC"; $sql .= " ORDER BY pfd.date_demande DESC";
@ -427,11 +436,11 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
// Add a withdraw request // Add a withdraw request
if ($fac->statut > 0 && $fac->paye == 0 && $num == 0) if ($object->statut > 0 && $object->paye == 0 && $num == 0)
{ {
if ($user->rights->prelevement->bons->creer) if ($user->rights->prelevement->bons->creer)
{ {
print '<a class="butAction" href="prelevement.php?facid='.$fac->id.'&amp;action=new">'.$langs->trans("MakeWithdrawRequest").'</a>'; print '<a class="butAction" href="prelevement.php?facid='.$object->id.'&amp;action=new">'.$langs->trans("MakeWithdrawRequest").'</a>';
} }
else else
{ {
@ -476,7 +485,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>'; print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td>'; print '<td>';
print '<a href="prelevement.php?facid='.$fac->id.'&amp;action=delete&amp;did='.$obj->rowid.'">'; print '<a href="prelevement.php?facid='.$object->id.'&amp;action=delete&amp;did='.$obj->rowid.'">';
print img_delete(); print img_delete();
print '</a></td>'; print '</a></td>';
print "</tr>\n"; print "</tr>\n";
@ -497,7 +506,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd,"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd,";
$sql.= " ".MAIN_DB_PREFIX."prelevement_bons as pb,"; $sql.= " ".MAIN_DB_PREFIX."prelevement_bons as pb,";
$sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE fk_facture = ".$fac->id; $sql.= " WHERE fk_facture = ".$object->id;
$sql.= " AND pfd.fk_user_demande = u.rowid"; $sql.= " AND pfd.fk_user_demande = u.rowid";
$sql.= " AND pb.rowid = pfd.fk_prelevement_bons"; $sql.= " AND pb.rowid = pfd.fk_prelevement_bons";
$sql.= " AND pfd.traite = 1"; $sql.= " AND pfd.traite = 1";