Merge remote-tracking branch 'origin/3.5' into develop
Conflicts: htdocs/compta/facture.php
This commit is contained in:
commit
caf1eba4e2
@ -486,14 +486,21 @@ else if ($action == 'confirm_canceled' && $confirm == 'yes') {
|
|||||||
// Convertir en reduc
|
// Convertir en reduc
|
||||||
else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
|
else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
$object->fetch_lines();
|
$object->fetch_lines();
|
||||||
|
|
||||||
if (empty($object->paye)) // protection against multiple submit
|
// Check if there is already a discount (protection to avoid duplicate creation when resubmit post)
|
||||||
|
$discountcheck=new DiscountAbsolute($db);
|
||||||
|
$result=$discountcheck->fetch(0,$object->id);
|
||||||
|
|
||||||
|
$canconvert=0;
|
||||||
|
if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc)
|
||||||
|
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
|
||||||
|
if ($canconvert)
|
||||||
{
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
// Boucle sur chaque taux de tva
|
// Boucle sur chaque taux de tva
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($object->lines as $line) {
|
foreach ($object->lines as $line) {
|
||||||
@ -1745,9 +1752,10 @@ if ($action == 'update_extras') {
|
|||||||
$action = 'edit_extras';
|
$action = 'edit_extras';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
@ -1941,10 +1949,12 @@ if ($action == 'create')
|
|||||||
$options .= '</option>';
|
$options .= '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$facids = $facturestatic->list_qualified_avoir_invoices($soc->id);
|
// Show link for credit note
|
||||||
if ($facids < 0) {
|
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
|
||||||
dol_print_error($db, $facturestatic);
|
if ($facids < 0)
|
||||||
exit();
|
{
|
||||||
|
dol_print_error($db,$facturestatic);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
$optionsav = "";
|
$optionsav = "";
|
||||||
$newinvoice_static = new Facture($db);
|
$newinvoice_static = new Facture($db);
|
||||||
@ -3277,10 +3287,11 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reopen a standard paid invoice
|
// Reopen a standard paid invoice
|
||||||
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && ($object->statut == Facture::TYPE_CREDIT_NOTE || $object->statut == Facture::TYPE_DEPOSIT) && $user->rights->facture->creer) // A paid
|
if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)
|
||||||
// invoice
|
|| ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id))
|
||||||
// (partially or
|
|| ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)))
|
||||||
// completely)
|
&& ($object->statut == 2 || $object->statut == 3)
|
||||||
|
&& $user->rights->facture->creer) // A paid invoice (partially or completely)
|
||||||
{
|
{
|
||||||
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
|
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
|
||||||
{
|
{
|
||||||
@ -3339,30 +3350,47 @@ if ($action == 'create')
|
|||||||
// Reverse back money or convert to reduction
|
// Reverse back money or convert to reduction
|
||||||
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
|
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
|
||||||
// For credit note only
|
// For credit note only
|
||||||
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) {
|
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement)
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid=' . $object->id . '&action=create">' . $langs->trans('DoPaymentBack') . '</a></div>';
|
{
|
||||||
|
if ($resteapayer == 0)
|
||||||
|
{
|
||||||
|
print '<div class="inline-block divButAction"><span class="butActionRefused" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPaymentBack').'</span></div>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&action=create">'.$langs->trans('DoPaymentBack').'</a></div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For credit note
|
// For credit note
|
||||||
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0) {
|
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?facid=' . $object->id . '&action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?facid=' . $object->id . '&action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
|
||||||
}
|
}
|
||||||
// For deposit invoice
|
// For deposit invoice
|
||||||
if ($object->type == Facture::TYPE_DEPOSIT && $object->statut == 2 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id)) {
|
if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id))
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?facid=' . $object->id . '&action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
|
{
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classify paid (if not deposit and not credit note. Such invoice are "converted")
|
// Classify paid
|
||||||
if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) {
|
if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?facid=' . $object->id . '&action=paid">' . $langs->trans('ClassifyPaid') . '</a></div>';
|
|| ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid">'.$langs->trans('ClassifyPaid').'</a></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classify 'closed not completely paid' (possible si validee et pas encore classee payee)
|
// Classify 'closed not completely paid' (possible si validee et pas encore classee payee)
|
||||||
if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $user->rights->facture->paiement) {
|
if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $user->rights->facture->paiement)
|
||||||
if ($totalpaye > 0 || $totalcreditnotes > 0) {
|
{
|
||||||
|
if ($totalpaye > 0 || $totalcreditnotes > 0)
|
||||||
|
{
|
||||||
// If one payment or one credit note was linked to this invoice
|
// If one payment or one credit note was linked to this invoice
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?facid=' . $object->id . '&action=paid">' . $langs->trans('ClassifyPaidPartially') . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?facid=' . $object->id . '&action=paid">' . $langs->trans('ClassifyPaidPartially') . '</a></div>';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if ($objectidnext) {
|
if ($objectidnext) {
|
||||||
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('ClassifyCanceled') . '</span></div>';
|
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('ClassifyCanceled') . '</span></div>';
|
||||||
} else {
|
} else {
|
||||||
@ -3372,19 +3400,23 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clone
|
// Clone
|
||||||
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $user->rights->facture->creer) {
|
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $user->rights->facture->creer)
|
||||||
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?facid=' . $object->id . '&action=clone&object=invoice">' . $langs->trans("ToClone") . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?facid=' . $object->id . '&action=clone&object=invoice">' . $langs->trans("ToClone") . '</a></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone as predefined
|
// Clone as predefined
|
||||||
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $user->rights->facture->creer) {
|
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $user->rights->facture->creer)
|
||||||
if (! $objectidnext) {
|
{
|
||||||
|
if (! $objectidnext)
|
||||||
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="facture/fiche-rec.php?facid=' . $object->id . '&action=create">' . $langs->trans("ChangeIntoRepeatableInvoice") . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="facture/fiche-rec.php?facid=' . $object->id . '&action=create">' . $langs->trans("ChangeIntoRepeatableInvoice") . '</a></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($user->rights->facture->supprimer) {
|
if ($user->rights->facture->supprimer)
|
||||||
|
{
|
||||||
if (! $object->is_erasable()) {
|
if (! $object->is_erasable()) {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecauseNotErasable") . '">' . $langs->trans('Delete') . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecauseNotErasable") . '">' . $langs->trans('Delete') . '</a></div>';
|
||||||
} else if ($objectidnext) {
|
} else if ($objectidnext) {
|
||||||
@ -3403,7 +3435,8 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
if ($action != 'prerelance' && $action != 'presend') {
|
if ($action != 'prerelance' && $action != 'presend')
|
||||||
|
{
|
||||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
print '<a name="builddoc"></a>'; // ancre
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user