diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index a7de442a4c7..f622cd839fb 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -143,53 +143,53 @@ else if ($action == 'reopen' && $user->rights->facture->creer)
// Delete invoice
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
- $result = $object->fetch($id);
- $result = $object->delete();
- if ($result > 0)
- {
- Header('Location: '.$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- $mesg='
';
print '';
@@ -2801,22 +2825,22 @@ else
print ' ';
- if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
- require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
- require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
- $formcompany= new FormCompany($db);
-
- $blocname = 'contacts';
- $title = $langs->trans('ContactsAddresses');
- include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
- }
-
- if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
- $blocname = 'notes';
- $title = $langs->trans('Notes');
- include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+ $formcompany= new FormCompany($db);
+
+ $blocname = 'contacts';
+ $title = $langs->trans('ContactsAddresses');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ }
+
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ $blocname = 'notes';
+ $title = $langs->trans('Notes');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
@@ -3502,4 +3526,4 @@ else
llxFooter();
$db->close();
-?>
+?>
\ No newline at end of file
diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php
index f29038bf0d3..ab65134c7dc 100644
--- a/htdocs/compta/facture/apercu.php
+++ b/htdocs/compta/facture/apercu.php
@@ -85,9 +85,20 @@ if ($id > 0 || ! empty($ref))
print '';
$rowspan=3;
- // Reference
+ // Ref
print '| '.$langs->trans('Ref').' | '.$object->ref.' | ';
+ // Ref customer
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer');
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print '';
+ print $object->ref_client;
+ print ' | ';
+
// Societe
print '| '.$langs->trans("Company").' | ';
print ''.$soc->getNomUrl(1,'compta').' | ';
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index affa7414dfa..947c7d83cf7 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -161,6 +161,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print ' ';
+ // Ref customer
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer');
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print '';
+ print $object->ref_client;
+ print ' | ';
+
// Customer
print "| ".$langs->trans("Company")." | ";
print ''.$object->client->getNomUrl(1,'compta').' | ';
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index d76b6fc4b2d..0d6edf0db5f 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -169,6 +169,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '';
+ // Ref customer
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer');
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print '';
+ print $object->ref_client;
+ print ' | ';
+
// Company
print '| '.$langs->trans('Company').' | '.$object->thirdparty->getNomUrl(1).' | ';
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 80d6bf6ca53..c2258ea78f8 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -103,6 +103,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '';
+ // Ref customer
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer');
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print '';
+ print $object->ref_client;
+ print ' | ';
+
// Company
print '| '.$langs->trans("Company").' | ';
print ''.$soc->getNomUrl(1,'compta').' | ';
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index 30071268484..ea39525ba6e 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -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.'/core/class/discount.class.php');
-if (!$user->rights->facture->lire)
-accessforbidden();
+if (!$user->rights->facture->lire) accessforbidden();
$langs->load("bills");
$langs->load("banks");
@@ -44,6 +43,8 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
+$object = new Facture($db);
+
/*
* Actions
@@ -51,31 +52,29 @@ if ($user->societe_id > 0)
if ($_GET["action"] == "new")
{
- $fact = new Facture($db);
- if ($fact->fetch($_GET["facid"]))
+ if ($object->fetch($_GET["facid"]))
{
- $result = $fact->demande_prelevement($user);
+ $result = $object->demande_prelevement($user);
if ($result > 0)
{
- Header("Location: prelevement.php?facid=".$fact->id);
+ Header("Location: prelevement.php?facid=".$object->id);
exit;
}
else
{
- $mesg=''.$fact->error.' ';
+ $mesg=''.$object->error.' ';
}
}
}
if ($_GET["action"] == "delete")
{
- $fact = new Facture($db);
- if ($fact->fetch($_GET["facid"]))
+ if ($object->fetch($_GET["facid"]))
{
- $result = $fact->demande_prelevement_delete($user,$_GET["did"]);
+ $result = $object->demande_prelevement_delete($user,$_GET["did"]);
if ($result == 0)
{
- Header("Location: prelevement.php?facid=".$fact->id);
+ Header("Location: prelevement.php?facid=".$object->id);
exit;
}
}
@@ -100,26 +99,25 @@ $form = new Form($db);
if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
{
- $fac = new Facture($db);
- if ($fac->fetch($_REQUEST["facid"], $_REQUEST["ref"]) > 0)
+ if ($object->fetch($_REQUEST["facid"], $_REQUEST["ref"]) > 0)
{
- if ($mesg) print $mesg.' ';
+ dol_htmloutput_mesg($mesg);
$soc = new Societe($db);
- $soc->fetch($fac->socid);
+ $soc->fetch($object->socid);
- $totalpaye = $fac->getSommePaiement();
- $totalcreditnotes = $fac->getSumCreditNotesUsed();
- $totaldeposits = $fac->getSumDepositsUsed();
+ $totalpaye = $object->getSommePaiement();
+ $totalcreditnotes = $object->getSumCreditNotesUsed();
+ $totaldeposits = $object->getSumDepositsUsed();
//print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
// We can also use bcadd to avoid pb with floating points
// 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 = 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;
$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');
$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');
@@ -146,7 +144,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print ' | '.$langs->trans("Ref").' | ';
$morehtmlref='';
$discount=new DiscountAbsolute($db);
- $result=$discount->fetch(0,$fac->id);
+ $result=$discount->fetch(0,$object->id);
if ($result > 0)
{
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
@@ -155,32 +153,43 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
{
dol_print_error('',$discount->error);
}
- print $form->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref);
+ print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print " | ";
- // Third party
+ // Ref customer
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer');
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print '';
+ print $object->ref_client;
+ print ' | ';
+
+ // Third party
print '| '.$langs->trans('Company').' | ';
print ''.$soc->getNomUrl(1,'compta');
- print ' ('.$langs->trans('OtherBills').') | ';
+ print ' ('.$langs->trans('OtherBills').')';
print ' ';
// Type
print '| '.$langs->trans('Type').' | ';
- print $fac->getLibType();
- if ($fac->type == 1)
+ print $object->getLibType();
+ if ($object->type == 1)
{
$facreplaced=new Facture($db);
- $facreplaced->fetch($fac->fk_facture_source);
+ $facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
}
- if ($fac->type == 2)
+ if ($object->type == 2)
{
$facusing=new Facture($db);
- $facusing->fetch($fac->fk_facture_source);
+ $facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
}
- $facidavoir=$fac->getListIdAvoirFromInvoice();
+ $facidavoir=$object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0)
{
print ' ('.$langs->transnoentities("InvoiceHasAvoir");
@@ -210,15 +219,15 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '. ';
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)).'. ';
}
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));
print ' '.$text.'. ';
@@ -236,15 +245,15 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
// Remise dispo de type non avoir
$filter='fk_facture_source IS NULL';
print ' ';
- $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 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));
print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
@@ -256,7 +265,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
// Remise dispo de type avoir
$filter='fk_facture_source IS NOT NULL';
if (! $absolute_discount) print ' ';
- $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").'.';
@@ -267,24 +276,24 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '';
print ' | ';
- if ($fac->type != 2)
+ if ($object->type != 2)
{
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
{
- print dol_print_date($fac->date,'daytext');
+ print dol_print_date($object->date,'daytext');
}
}
else
{
- print dol_print_date($fac->date,'daytext');
+ print dol_print_date($object->date,'daytext');
}
print ' | ';
print ' ';
@@ -294,19 +303,19 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '';
print '';
- if ($fac->type != 2)
+ if ($object->type != 2)
{
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
{
- print dol_print_date($fac->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'));
+ print dol_print_date($object->date_lim_reglement,'daytext');
+ 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
@@ -320,18 +329,18 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '';
print ' | ';
- if ($fac->type != 2)
+ if ($object->type != 2)
{
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
{
- $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
@@ -345,24 +354,24 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print '';
print ' | ';
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
{
- $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 ' | ';
// Montants
print '| '.$langs->trans('AmountHT').' | ';
- print ''.price($fac->total_ht).' | ';
+ print ''.price($object->total_ht).' | ';
print ''.$langs->trans('Currency'.$conf->currency).' | ';
- print '| '.$langs->trans('AmountVAT').' | '.price($fac->total_tva).' | ';
+ print ' | '.$langs->trans('AmountVAT').' | '.price($object->total_tva).' | ';
print ''.$langs->trans('Currency'.$conf->currency).' | ';
// Amount Local Taxes
@@ -371,23 +380,23 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '| '.$langs->transcountry("AmountLT1",$mysoc->country_code).' | ';
- print ''.price($fac->total_localtax1).' | ';
+ print ''.price($object->total_localtax1).' | ';
print ''.$langs->trans("Currency".$conf->currency).' | ';
}
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{
print '| '.$langs->transcountry("AmountLT2",$mysoc->country_code).' | ';
- print ''.price($fac->total_localtax2).' | ';
+ print ''.price($object->total_localtax2).' | ';
print ''.$langs->trans("Currency".$conf->currency).' | ';
}
}
- print '| '.$langs->trans('AmountTTC').' | '.price($fac->total_ttc).' | ';
+ print ' | '.$langs->trans('AmountTTC').' | '.price($object->total_ttc).' | ';
print ''.$langs->trans('Currency'.$conf->currency).' | ';
// Statut
print '| '.$langs->trans('Status').' | ';
- print ''.($fac->getLibStatut(4,$totalpaye)).' | ';
+ print ''.($object->getLibStatut(4,$totalpaye)).' | ';
print '| '.$langs->trans("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 .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$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.traite = 0";
$sql .= " ORDER BY pfd.date_demande DESC";
@@ -427,11 +436,11 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
print "\n | \n";
@@ -497,7 +506,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd,";
$sql.= " ".MAIN_DB_PREFIX."prelevement_bons as pb,";
$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 pb.rowid = pfd.fk_prelevement_bons";
$sql.= " AND pfd.traite = 1";
|