From 133657a8c7db8d18093ca35bea1eff8597cc4bed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Sep 2016 01:25:34 +0200 Subject: [PATCH] Uniformize code --- htdocs/compta/facture.php | 868 ++++++++++-------- htdocs/compta/facture/class/facture.class.php | 2 + htdocs/core/class/html.formmargin.class.php | 2 +- htdocs/core/lib/functions.lib.php | 6 + htdocs/paypal/lib/paypal.lib.php | 2 +- htdocs/theme/eldy/style.css.php | 9 + 6 files changed, 482 insertions(+), 407 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0ef7c830e68..c15d67e127b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -395,10 +395,10 @@ if (empty($reshook)) } } - else if ($action == 'set_ref_client' && $user->rights->facture->creer) + else if ($action == 'setref_client' && $user->rights->facture->creer) { $object->fetch($id); - $object->set_ref_client($_POST['ref_client']); + $object->set_ref_client(GETPOST('ref_client')); } // Classify to validated @@ -2878,11 +2878,61 @@ else if ($id > 0 || ! empty($ref)) // Invoice content - print ''; - $linkback = '' . $langs->trans("BackToList") . ''; - + + + $morehtmlref='
'; + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->facture->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + $object->totalpaye = $totalpaye; // To give a change to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + print '
'; + + print '
'; + // Ref + /* print ''; print ''; + print '';*/ // Type - print ''; print '
' . $langs->trans('Ref') . ''; $morehtmlright = ''; @@ -2946,10 +2996,10 @@ else if ($id > 0 || ! empty($ref)) } print ')'; } - print '
' . $langs->trans('Type') . ''; + print '
' . $langs->trans('Type') . ''; print $object->getLibType(); if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); @@ -2990,7 +3040,7 @@ else if ($id > 0 || ! empty($ref)) $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; print '
' . $langs->trans('Discounts'); - print ''; + print ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); else @@ -3071,7 +3121,7 @@ else if ($id > 0 || ! empty($ref)) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; - print ''; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editinvoicedate') { @@ -3084,327 +3134,8 @@ else if ($id > 0 || ! empty($ref)) } print ''; - // List of payments - - $sign = 1; - if ($object->type == Facture::TYPE_CREDIT_NOTE) - $sign = - 1; - - $nbrows = 8; - $nbcols = 3; - if (! empty($conf->projet->enabled)) - $nbrows ++; - if (! empty($conf->banque->enabled)) { - $nbrows ++; $nbcols++; - } - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) - $nbrows ++; - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) - $nbrows ++; - if ($selleruserevenustamp) - $nbrows ++; - if (! empty($conf->multicurrency->enabled)) $nbrows+=5; - if (! empty($conf->incoterm->enabled)) $nbrows+=1; - - print ''; - - if ($object->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) - { - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print ''; - - if (count($object->tab_previous_situation_invoice) > 0) - { - //List of previous invoices - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $total_prev_ht = $total_prev_ttc = 0; - $var = true; - foreach ($object->tab_previous_situation_invoice as $prev_invoice) - { - $totalpaye = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $var = !$var; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - if (count($object->tab_next_situation_invoice) > 0) - { - //List of next invoices - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $total_next_ht = $total_next_ttc = 0; - - $var = true; - foreach ($object->tab_next_situation_invoice as $next_invoice) - { - $totalpaye = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $var = !$var; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print '
' . $langs->trans('ListOfPreviousSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$prev_invoice->getNomUrl(1).'' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . ''.$prev_invoice->getLibStatut(3, $totalpaye).'
' . price($total_prev_ht) . '' . price($total_prev_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$next_invoice->getNomUrl(1).'' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . ''.$next_invoice->getLibStatut(3, $totalpaye).'
' . price($total_next_ht) . '' . price($total_next_ttc) . ' 
'; - } - - print ''; - - // List of payments already done - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; print ''; - $var = true; - - // Payments already done (from payment on this invoice) - $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; - $sql .= ' c.code as payment_code, c.libelle as payment_label,'; - $sql .= ' pf.amount,'; - $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_paiement as c, ' . MAIN_DB_PREFIX . 'paiement_facture as pf, ' . MAIN_DB_PREFIX . 'paiement as p'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; - $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; - $sql .= ' ORDER BY p.datep, p.tms'; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - - // if ($object->type != 2) - // { - if ($num > 0) - { - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; - $label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label; - print ''; - if (! empty($conf->banque->enabled)) - { - $bankaccountstatic->id = $objp->baid; - $bankaccountstatic->ref = $objp->baref; - $bankaccountstatic->label = $objp->baref; - print ''; - } - print ''; - print ''; - print ''; - $i ++; - } - } else { - print ''; - } - // } - $db->free($result); - } else { - dol_print_error($db); - } - - if ($object->type != Facture::TYPE_CREDIT_NOTE) - { - // Total already paid - print ''; - - $resteapayeraffiche = $resteapayer; - - // Loop on each credit note or deposit amount applied - $creditnoteamount = 0; - $depositamount = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $object->id; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - $invoice = new Facture($db); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $invoice->fetch($obj->fk_facture_source); - print ''; - print ''; - print ''; - $i ++; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) - $creditnoteamount += $obj->amount_ttc; - if ($invoice->type == Facture::TYPE_DEPOSIT) - $depositamount += $obj->amount_ttc; - } - } else { - dol_print_error($db); - } - - // Paye partiellement 'escompte' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat') { - print ''; - $resteapayeraffiche = 0; - } - // Paye partiellement ou Abandon 'badcustomer' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer') { - print ''; - // $resteapayeraffiche=0; - } - // Paye partiellement ou Abandon 'product_returned' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned') { - print ''; - $resteapayeraffiche = 0; - } - // Paye partiellement ou Abandon 'abandon' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon') { - print ''; - $resteapayeraffiche = 0; - } - - // Billed - print ''; - - // Remainder to pay - print ''; - print ''; - print ''; - } - else // Credit note - { - // Total already paid back - print ''; - - // Billed - print ''; - - // Remainder to pay back - print ''; - print ''; - print ''; - - // Sold credit note - // print ''; - // print ''; - } - - print '
' . ($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '' . $langs->trans('Amount') . ' 
'; - $paymentstatic->id=$objp->rowid; - $paymentstatic->datepaye=$db->jdate($objp->dp); - $paymentstatic->ref=$objp->ref; - $paymentstatic->num_paiement=$objp->num_paiement; - $paymentstatic->payment_code=$objp->payment_code; - print $paymentstatic->getNomUrl(1); - print ''.dol_print_date($db->jdate($objp->dp), 'day') . '' . $label . ' ' . $objp->num_paiement . ''; - if ($bankaccountstatic->id) - print $bankaccountstatic->getNomUrl(1, 'transactions'); - print '' . price($sign * $objp->amount) . ' 
' . $langs->trans("None") . '
'; - if ($object->type != Facture::TYPE_DEPOSIT) - print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - else - print $langs->trans('AlreadyPaid'); - print ' :' . price($totalpaye) . ' 
'; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) - print $langs->trans("CreditNote") . ' '; - if ($invoice->type == Facture::TYPE_DEPOSIT) - print $langs->trans("Deposit") . ' '; - print $invoice->getNomUrl(0); - print ' :' . price($obj->amount_ttc) . ''; - print 'rowid . '">' . img_delete() . ''; - print '
'; - print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; - print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; - $text = $langs->trans("HelpAbandonOther"); - if ($object->close_note) - $text .= '

' . $langs->trans("Reason") . ':' . $object->close_note; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1); - print '
' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'; - if ($resteapayeraffiche >= 0) - print $langs->trans('RemainderToPay'); - else - print $langs->trans('ExcessReceived'); - print ' :' . price($resteapayeraffiche) . ' 
'; - print $langs->trans('AlreadyPaidBack'); - print ' :' . price($sign * $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'; - if ($resteapayeraffiche <= 0) - print $langs->trans('RemainderToPayBack'); - else - print $langs->trans('ExcessPaydBack'); - print ' :' . price($sign * $resteapayeraffiche) . ' 
'.$langs->trans('TotalTTC').' :'.price($sign * - // $object->total_ttc).' 
'; - - // Margin Infos - if (! empty($conf->margin->enabled)) - { - print '
'; - $formmargin->displayMarginInfos($object, $object->statut > 0); - } - - print ''; - if (! empty($conf->global->INVOICE_POINTOFTAX_DATE)) { // Date invoice @@ -3414,7 +3145,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editdate_pointoftax') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_pointoftax, 'date_pointoftax'); } else { @@ -3431,7 +3162,7 @@ else if ($id > 0 || ! empty($ref)) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; print ''; - print ''; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editconditions') { @@ -3452,7 +3183,7 @@ else if ($id > 0 || ! empty($ref)) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; print ''; - print ''; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editpaymentterm') { @@ -3476,7 +3207,7 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); @@ -3499,7 +3230,7 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -3516,7 +3247,7 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editmulticurrencyrate') { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { @@ -3533,7 +3264,7 @@ else if ($id > 0 || ! empty($ref)) if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).''; print ''; - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); @@ -3566,7 +3297,7 @@ else if ($id > 0 || ! empty($ref)) print $object->situation_counter; print ''; - print ''; + print ''; $prevsits_total_amount = 0; foreach ($prevsits as $situation) { @@ -3587,7 +3318,7 @@ else if ($id > 0 || ! empty($ref)) print $prevsits[$i]->situation_counter; print ''; - print ''; + print ''; print '- ' . price($prevsits[$i]->total_ht); print ''; print '' . $langs->trans('Currency' . $conf->currency) . ''; @@ -3595,71 +3326,8 @@ else if ($id > 0 || ! empty($ref)) } } - // Amount - print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; - print '' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . ''; - print ''; - - // Amount Local Taxes - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 - { - print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ''; - } - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 - { - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ''; - } - - // Revenue stamp - if ($selleruserevenustamp) // Test company use revenue stamp - { - print ''; - print ''; - if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) - print ''; - print '
'; - print $langs->trans('RevenueStamp'); - print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . '
'; - print ''; - if ($action == 'editrevenuestamp') { - print '
'; - print ''; - print ''; - print $formother->select_revenue_stamp(GETPOST('revenuestamp'), 'revenuestamp', $mysoc->country_code); - // print ''; - print ' '; - print '
'; - } else { - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); - } - print ''; - } - - // Total with tax - print '' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . ''; - - if (!empty($conf->multicurrency->enabled)) - { - // Multicurrency Amount HT - print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; - print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - - // Multicurrency Amount VAT - print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; - print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - - // Multicurrency Amount TTC - print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - } - // Statut + /* print '' . $langs->trans('Status') . ''; print '' . ($object->getLibStatut(4, $totalpaye)) . ''; @@ -3687,7 +3355,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; print ''; - } + }*/ // Incoterms if (!empty($conf->incoterm->enabled)) @@ -3700,7 +3368,7 @@ else if ($id > 0 || ! empty($ref)) else print ' '; print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); @@ -3713,11 +3381,401 @@ else if ($id > 0 || ! empty($ref)) } // Other attributes - $cols = 5; + $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - print '
'; + print ''; + + print ''; + print '
'; + print '
'; + print '
'; + + print ''; + + // Amount + print ''; + print ''; + print ''; + print ''; + + // Amount Local Taxes + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 + { + print ''; + print ''; + } + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 + { + print ''; + print ''; + } + + // Revenue stamp + if ($selleruserevenustamp) // Test company use revenue stamp + { + print ''; + } + + // Total with tax + print ''; + + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + + print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
'; + print ''; + if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) + { + print ''; + } + print '
'; + print $langs->trans('RevenueStamp'); + print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . '
'; + print '
'; + if ($action == 'editrevenuestamp') { + print '
'; + print ''; + print ''; + print $formother->select_revenue_stamp(GETPOST('revenuestamp'), 'revenuestamp', $mysoc->country_code); + // print ''; + print ' '; + print '
'; + } else { + print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + } + print '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'; + + // List of payments + + $sign = 1; + if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1; + $nbrows = 8; + $nbcols = 3; + if (! empty($conf->projet->enabled)) + $nbrows ++; + if (! empty($conf->banque->enabled)) { + $nbrows ++; + $nbcols ++; + } + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) + $nbrows ++; + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) + $nbrows ++; + if ($selleruserevenustamp) + $nbrows ++; + if (! empty($conf->multicurrency->enabled)) + $nbrows += 5; + if (! empty($conf->incoterm->enabled)) + $nbrows += 1; + + if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) + { + if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) + print ''; + + if (count($object->tab_previous_situation_invoice) > 0) { + // List of previous invoices + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $total_prev_ht = $total_prev_ttc = 0; + $var = true; + foreach ($object->tab_previous_situation_invoice as $prev_invoice) { + $totalpaye = $prev_invoice->getSommePaiement(); + $total_prev_ht += $prev_invoice->total_ht; + $total_prev_ttc += $prev_invoice->total_ttc; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = ! $var; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + if (count($object->tab_next_situation_invoice) > 0) { + // List of next invoices + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $total_next_ht = $total_next_ttc = 0; + + $var = true; + foreach ($object->tab_next_situation_invoice as $next_invoice) { + $totalpaye = $next_invoice->getSommePaiement(); + $total_next_ht += $next_invoice->total_ht; + $total_next_ttc += $next_invoice->total_ttc; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = ! $var; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) + print '
' . $langs->trans('ListOfPreviousSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . '' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_prev_ht) . '' . price($total_prev_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . '' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_next_ht) . '' . price($total_next_ttc) . ' 
'; + } + + print ''; + + // List of payments already done + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) { + print ''; + } + print ''; + print ''; + print ''; + + $var = true; + + // Payments already done (from payment on this invoice) + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; + $sql .= ' c.code as payment_code, c.libelle as payment_label,'; + $sql .= ' pf.amount,'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_paiement as c, ' . MAIN_DB_PREFIX . 'paiement_facture as pf, ' . MAIN_DB_PREFIX . 'paiement as p'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; + $sql .= ' ORDER BY p.datep, p.tms'; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + + // if ($object->type != 2) + // { + if ($num > 0) { + while ($i < $num) { + $objp = $db->fetch_object($result); + $var = ! $var; + print ''; + print ''; + $label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label; + print ''; + if (! empty($conf->banque->enabled)) { + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; + print ''; + } + print ''; + print ''; + print ''; + $i ++; + } + } else { + print ''; + } + // } + $db->free($result); + } else { + dol_print_error($db); + } + + if ($object->type != Facture::TYPE_CREDIT_NOTE) { + // Total already paid + print ''; + + $resteapayeraffiche = $resteapayer; + + // Loop on each credit note or deposit amount applied + $creditnoteamount = 0; + $depositamount = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; + $sql .= " WHERE fk_facture = " . $object->id; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $invoice = new Facture($db); + while ($i < $num) { + $obj = $db->fetch_object($resql); + $invoice->fetch($obj->fk_facture_source); + print ''; + print ''; + print ''; + $i ++; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) + $creditnoteamount += $obj->amount_ttc; + if ($invoice->type == Facture::TYPE_DEPOSIT) + $depositamount += $obj->amount_ttc; + } + } else { + dol_print_error($db); + } + + // Paye partiellement 'escompte' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat') { + print ''; + $resteapayeraffiche = 0; + } + // Paye partiellement ou Abandon 'badcustomer' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer') { + print ''; + // $resteapayeraffiche=0; + } + // Paye partiellement ou Abandon 'product_returned' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned') { + print ''; + $resteapayeraffiche = 0; + } + // Paye partiellement ou Abandon 'abandon' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon') { + print ''; + $resteapayeraffiche = 0; + } + + // Billed + print ''; + + // Remainder to pay + print ''; + print ''; + print ''; + } + else // Credit note + { + // Total already paid back + print ''; + + // Billed + print ''; + + // Remainder to pay back + print ''; + print ''; + print ''; + + // Sold credit note + // print ''; + // print ''; + } + + print '
' . ($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '' . $langs->trans('Amount') . ' 
'; + $paymentstatic->id = $objp->rowid; + $paymentstatic->datepaye = $db->jdate($objp->dp); + $paymentstatic->ref = $objp->ref; + $paymentstatic->num_paiement = $objp->num_paiement; + $paymentstatic->payment_code = $objp->payment_code; + print $paymentstatic->getNomUrl(1); + print '' . dol_print_date($db->jdate($objp->dp), 'day') . '' . $label . ' ' . $objp->num_paiement . ''; + if ($bankaccountstatic->id) + print $bankaccountstatic->getNomUrl(1, 'transactions'); + print '' . price($sign * $objp->amount) . ' 
' . $langs->trans("None") . '
'; + if ($object->type != Facture::TYPE_DEPOSIT) + print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); + else + print $langs->trans('AlreadyPaid'); + print ' :' . price($totalpaye) . ' 
'; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) + print $langs->trans("CreditNote") . ' '; + if ($invoice->type == Facture::TYPE_DEPOSIT) + print $langs->trans("Deposit") . ' '; + print $invoice->getNomUrl(0); + print ' :' . price($obj->amount_ttc) . ''; + print 'rowid . '">' . img_delete() . ''; + print '
'; + print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); + print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); + print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); + print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + $text = $langs->trans("HelpAbandonOther"); + if ($object->close_note) + $text .= '

' . $langs->trans("Reason") . ':' . $object->close_note; + print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1); + print '
' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'; + if ($resteapayeraffiche >= 0) + print $langs->trans('RemainderToPay'); + else + print $langs->trans('ExcessReceived'); + print ' :' . price($resteapayeraffiche) . ' 
'; + print $langs->trans('AlreadyPaidBack'); + print ' :' . price($sign * $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'; + if ($resteapayeraffiche <= 0) + print $langs->trans('RemainderToPayBack'); + else + print $langs->trans('ExcessPaydBack'); + print ' :' . price($sign * $resteapayeraffiche) . ' 
'.$langs->trans('TotalTTC').' :'.price($sign * + // $object->total_ttc).' 
'; + + // Margin Infos + if (! empty($conf->margin->enabled)) { + $formmargin->displayMarginInfos($object); + } + + print '
'; + print '
'; + print ''; + + print '

'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 32e6ca242ca..e0ceb287ea9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1516,6 +1516,8 @@ class Facture extends CommonInvoice */ function set_ref_client($ref_client, $notrigger=0) { + global $user; + $error=0; $this->db->begin(); diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 99159f62561..0ac6012f271 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -209,7 +209,7 @@ class FormMargin if (!empty($hidemargininfos)) print ''; } - print ''; + print '
'; print ''; print ''; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6bc46e1dfcf..7c4a19d729b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -986,6 +986,12 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $morehtmlright.=$object->getLibStatut(5,1); } } + elseif ($object->element == 'facture') + { + $tmptxt=$object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5, $object->totalpaye); + $morehtmlright.=$tmptxt; + } else { $tmptxt=$object->getLibStatut(6); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5); diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 6587e25ecb1..1496bb3552e 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -209,7 +209,7 @@ function showPaypalPaymentUrl($type,$ref) $out='

'; $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
'; $url=getPaypalPaymentUrl(0,$type,$ref); - $out.='
'; + $out.='
'; return $out; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d2834a87669..f415b214742 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -580,6 +580,14 @@ div.myavailability { .tablelistofcalendars { margin-top: 25px !important; } +.amountalreadypaid { + color: #008800; + font-weight: bold; +} +.amountremaintopay { + color: #880000; + font-weight: bold; +} /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ .table-responsive { @@ -2833,6 +2841,7 @@ tr.liste_sub_total, tr.liste_sub_total td { border-top-width: px !important; border-top-color: rgb() !important; border-top-style: solid !important; + margin: 0px 0px 0px 0px !important; } .paymenttable tr td:first-child, .margintable tr td:first-child {
'.$langs->trans('Margins').''.$langs->trans('SellingPrice').'