From e9fb0f427c26a24439e1b12fa4e0c9d69aec0b72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 May 2012 02:27:09 +0200 Subject: [PATCH] New: Add customer invoice ref on invoices --- htdocs/compta/facture.php | 274 ++++++++++++++------------ htdocs/compta/facture/apercu.php | 13 +- htdocs/compta/facture/contact.php | 11 ++ htdocs/compta/facture/document.php | 11 ++ htdocs/compta/facture/note.php | 11 ++ htdocs/compta/facture/prelevement.php | 147 +++++++------- 6 files changed, 272 insertions(+), 195 deletions(-) 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='
'.$object->error.'
'; + $result = $object->fetch($id); + $result = $object->delete(); + if ($result > 0) + { + Header('Location: '.$_SERVER["PHP_SELF"]); + exit; + } + else + { + $mesg='
'.$object->error.'
'; } } // Delete line else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - - $result = $object->deleteline($_GET['lineid'], $user); - if ($result > 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); - } - if ($result >= 0) - { - Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); - exit; - } - } - else - { - $mesg='
'.$object->error.'
'; - $action=''; + $object->fetch($id); + $object->fetch_thirdparty(); + + $result = $object->deleteline($_GET['lineid'], $user); + if ($result > 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + } + if ($result >= 0) + { + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); + exit; + } + } + else + { + $mesg='
'.$object->error.'
'; + $action=''; } } @@ -310,18 +310,18 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer) $object->set_ref_client($_POST['ref_client']); } -else if ($action == 'setnote_public' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); +else if ($action == 'setnote_public' && $user->rights->facture->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->facture->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } // Classify to validated @@ -1506,64 +1506,64 @@ else if ($action == 'builddoc') // En get ou en post } } -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - if ($action == 'addcontact' && $user->rights->facture->creer) - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) + if ($action == 'addcontact' && $user->rights->facture->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; - } - else - { - $mesg = '
'.$object->error.'
'; - } - } - } - - // bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->facture->creer) - { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->facture->creer) - { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - dol_print_error($db); - } + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->facture->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->facture->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } } } @@ -2309,6 +2309,30 @@ else print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print ''; + // Ref customer + print ''; + print ''; + if ($action != 'refclient' && $object->brouillon) print ''; + print '
'; + print $langs->trans('RefCustomer'); + print ''.img_edit($langs->trans('Modify')).'
'; + print ''; + print ''; + if ($user->rights->facture->creer && $action == 'refclient') + { + print '
'; + print ''; + print ''; + print ''; + print ' '; + print '
'; + } + else + { + print $object->ref_client; + } + print ''; + // Third party print ''; 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 ''; + // Ref customer + print ''; + print ''; + // Societe print ''; print ''; 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 ''; + // Customer print ""; print ''; 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 ''; + // Company print ''; 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 ''; + // Company print ''; print ''; 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 '"; - // Third party + // Ref customer + print ''; + print ''; + + // Third party print ''; print ''; + print '   ('.$langs->trans('OtherBills').')'; print ''; // Type print ''; print ''; @@ -294,19 +303,19 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"]) print '
'.$langs->trans('Ref').''.$object->ref.'
'; + print ''; + print '
'; + print $langs->trans('RefCustomer'); + print '
'; + print '
'; + print $object->ref_client; + print '
'.$langs->trans("Company").''.$soc->getNomUrl(1,'compta').'
'; + print ''; + print '
'; + print $langs->trans('RefCustomer'); + print '
'; + print '
'; + print $object->ref_client; + print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1,'compta').'
'; + print ''; + print '
'; + print $langs->trans('RefCustomer'); + print '
'; + print '
'; + print $object->ref_client; + print '
'.$langs->trans('Company').''.$object->thirdparty->getNomUrl(1).'
'; + print ''; + print '
'; + print $langs->trans('RefCustomer'); + print '
'; + print '
'; + print $object->ref_client; + print '
'.$langs->trans("Company").''.$soc->getNomUrl(1,'compta').'
'.$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 "
'; + print ''; + print '
'; + print $langs->trans('RefCustomer'); + print '
'; + print '
'; + print $object->ref_client; + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1,'compta'); - print '   ('.$langs->trans('OtherBills').')
'.$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 ''; - if ($fac->type != 2 && $_GET['action'] != 'editinvoicedate' && $fac->brouillon && $user->rights->facture->creer) print ''; + if ($object->type != 2 && $_GET['action'] != 'editinvoicedate' && $object->brouillon && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('Date'); print 'id.'">'.img_edit($langs->trans('SetDate'),1).'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; 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 '
'; - if ($fac->type != 2 && $_GET['action'] != 'editpaymentterm' && $fac->brouillon && $user->rights->facture->creer) print ''; + if ($object->type != 2 && $_GET['action'] != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetDate'),1).'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; 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 ''; - if ($fac->type != 2 && $_GET['action'] != 'editconditions' && $fac->brouillon && $user->rights->facture->creer) print ''; + if ($object->type != 2 && $_GET['action'] != 'editconditions' && $object->brouillon && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; 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 ''; - if ($_GET['action'] != 'editmode' && $fac->brouillon && $user->rights->facture->creer) print ''; + if ($_GET['action'] != 'editmode' && $object->brouillon && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; 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"; // 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) { - print ''.$langs->trans("MakeWithdrawRequest").''; + print ''.$langs->trans("MakeWithdrawRequest").''; } else { @@ -476,7 +485,7 @@ if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"]) print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''; print ' '; print ''; - print ''; + print ''; print img_delete(); print ''; print "\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";