NEW: supplier credit notes: remove MAIN_FEATURES_LEVEL

This commit is contained in:
Marc de Lima Lucio 2018-03-05 10:58:19 +01:00
parent 451d943927
commit 6a4a3c9e82
6 changed files with 196 additions and 217 deletions

View File

@ -109,10 +109,6 @@ if ($socid > 0)
$isCustomer = $object->client == 1 || $object->client == 3;
$isSupplier = $object->fournisseur == 1;
$displayCustomer = $conf->global->MAIN_FEATURES_LEVEL <= 0 || $isCustomer;
$displaySupplier = $conf->global->MAIN_FEATURES_LEVEL > 0 && $isSupplier;
print '<form method="POST" action="remise.php?id='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -127,7 +123,7 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>';
if(! $displayCustomer && ! $displaySupplier) {
if(! $isCustomer && ! $isSupplier) {
print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
dol_fiche_end();
@ -141,13 +137,13 @@ if ($socid > 0)
print '<table class="border centpercent">';
if($displayCustomer) {
if($isCustomer) {
// Customer discount
print '<tr><td class="titlefield">';
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
}
if($displaySupplier) {
if($isSupplier) {
// Supplier discount
print '<tr><td class="titlefield">';
print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
@ -160,17 +156,17 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>';
if($conf->global->MAIN_FEATURES_LEVEL <= 0 || ($isCustomer && ! $isSupplier)) {
if($isCustomer && ! $isSupplier) {
print '<input type="hidden" name="discount_type" value="0" />';
}
if($conf->global->MAIN_FEATURES_LEVEL > 0 && (! $isCustomer && $isSupplier)) {
if(! $isCustomer && $isSupplier) {
print '<input type="hidden" name="discount_type" value="1" />';
}
print '<table class="border centpercent">';
if($conf->global->MAIN_FEATURES_LEVEL > 0 && $isCustomer && $isSupplier) {
if($isCustomer && $isSupplier) {
// Discount type
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>';
print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
@ -205,8 +201,8 @@ if ($socid > 0)
print '<br>';
if($displayCustomer) {
if($displaySupplier) {
if($isCustomer) {
if($isSupplier) {
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
@ -263,8 +259,8 @@ if ($socid > 0)
}
}
if($displaySupplier) {
if($displayCustomer) {
if($isSupplier) {
if($isCustomer) {
print '</div>'; // class="fichehalfleft"
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
@ -321,7 +317,7 @@ if ($socid > 0)
dol_print_error($db);
}
if($displayCustomer) {
if($isCustomer) {
print '</div>'; // class="ficheaddleft"
print '</div>'; // class="fichehalfright"
print '</div>'; // class="fichecenter"

View File

@ -238,9 +238,6 @@ if ($socid > 0)
$isCustomer = $object->client == 1 || $object->client == 3;
$isSupplier = $object->fournisseur == 1;
$displayCustomer = $conf->global->MAIN_FEATURES_LEVEL <= 0 || $isCustomer;
$displaySupplier = $conf->global->MAIN_FEATURES_LEVEL > 0 && $isSupplier;
/*
* Display tabs
*/
@ -259,7 +256,7 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>';
if(! $displayCustomer && ! $displaySupplier) {
if(! $isCustomer && ! $isSupplier) {
print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
dol_fiche_end();
@ -274,7 +271,7 @@ if ($socid > 0)
print '<table class="border centpercent">';
if($displayCustomer) { // Calcul avoirs client en cours
if($isCustomer) { // Calcul avoirs client en cours
$remise_all=$remise_user=0;
$sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
@ -305,7 +302,7 @@ if ($socid > 0)
}
}
if($displaySupplier) {
if($isSupplier) {
// Calcul avoirs fournisseur en cours
$remise_all=$remise_user=0;
$sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
@ -349,16 +346,16 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>';
if($conf->global->MAIN_FEATURES_LEVEL <= 0 || ($isCustomer && ! $isSupplier)) {
if($isCustomer && ! $isSupplier) {
print '<input type="hidden" name="discount_type" value="0" />';
}
if($conf->global->MAIN_FEATURES_LEVEL > 0 && (! $isCustomer && $isSupplier)) {
if(! $isCustomer && $isSupplier) {
print '<input type="hidden" name="discount_type" value="1" />';
}
print '<table class="border" width="100%">';
if($conf->global->MAIN_FEATURES_LEVEL > 0 && $isCustomer && $isSupplier) {
if($isCustomer && $isSupplier) {
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>';
print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
@ -408,8 +405,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountStillRemaining"));
if($displayCustomer) {
if($displaySupplier) {
if($isCustomer) {
if($isSupplier) {
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
@ -541,8 +538,8 @@ if ($socid > 0)
}
}
if($displaySupplier) {
if($displayCustomer) {
if($isSupplier) {
if($isCustomer) {
print '</div>'; // class="fichehalfleft"
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
@ -677,7 +674,7 @@ if ($socid > 0)
dol_print_error($db);
}
if($displayCustomer) {
if($isCustomer) {
print '</div>'; // class="ficheaddleft"
print '</div>'; // class="fichehalfright"
print '</div>'; // class="fichecenter"
@ -692,8 +689,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountAlreadyCounted"));
if($displayCustomer) {
if($displaySupplier) {
if($isCustomer) {
if($isSupplier) {
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
@ -843,8 +840,8 @@ if ($socid > 0)
}
}
if($displaySupplier) {
if($displayCustomer) {
if($isSupplier) {
if($isCustomer) {
print '</div>'; // class="fichehalfleft"
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
@ -994,7 +991,7 @@ if ($socid > 0)
dol_print_error($db);
}
if($displayCustomer) {
if($isCustomer) {
print '</div>'; // class="ficheaddleft"
print '</div>'; // class="fichehalfright"
print '</div>'; // class="fichecenter"

View File

@ -258,40 +258,38 @@ if ($object->id > 0)
print "</td>";
print '</tr>';
if($conf->global->MAIN_FEATURES_LEVEL > 0) {
// Relative discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td>'.($object->remise_supplier_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>':'').'</td>';
print '</tr>';
// Absolute discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td class="nowrap">';
print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td>';
print '<td>';
$amount_discount=$object->getAvailableDiscounts('', '', 0, 1);
if ($amount_discount < 0) dol_print_error($db,$object->error);
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).'</a>';
//else print $langs->trans("DiscountNone");
print '</td>';
print '</tr>';
// Relative discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td>'.($object->remise_supplier_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>':'').'</td>';
print '</tr>';
// Absolute discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td class="nowrap">';
print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td>';
print '<td>';
$amount_discount=$object->getAvailableDiscounts('', '', 0, 1);
if ($amount_discount < 0) dol_print_error($db,$object->error);
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).'</a>';
//else print $langs->trans("DiscountNone");
print '</td>';
print '</tr>';
print '<tr class="nowrap">';
print '<td>';

View File

@ -1479,7 +1479,7 @@ if ($action=='create')
}
print '</td>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0)
if ($societe->id > 0)
{
// Discounts for third party
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
@ -1874,32 +1874,29 @@ elseif (! empty($object->id))
print '<td>'.$author->getNomUrl(1, '', 0, 0, 0).'</td>';
print '</tr>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
// Relative and absolute discounts
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
}
$absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
$absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
$thirdparty = $societe;
$discount_type = 1;
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
// Relative and absolute discounts
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
}
$absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
$absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
$thirdparty = $societe;
$discount_type = 1;
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
// Conditions de reglement par defaut
$langs->load('bills');
print '<tr><td class="nowrap">';

View File

@ -1848,74 +1848,71 @@ if ($action == 'create')
if (empty($origin))
{
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Need to fix reports of standard accounting module to manage supplier credit note
if ($societe->id > 0)
{
if ($societe->id > 0)
{
// Credit note
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
{
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
if (! $optionsav) $tmp.=' disabled';
$tmp.= '> ';
// Show credit note options only if we checked credit note
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
if (! jQuery("#radio_creditnote").is(":checked"))
{
jQuery("#credit_note_options").hide();
}
jQuery("#radio_creditnote").click(function() {
jQuery("#credit_note_options").show();
});
jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
jQuery("#credit_note_options").hide();
});
});
</script>';
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
// $text.='<input type="text" value="">';
$text .= '<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
if (! $optionsav)
$text .= ' disabled';
$text .= '>';
if ($optionsav) {
$text .= '<option value="-1"></option>';
$text .= $optionsav;
} else {
$text .= '<option value="-1">' . $langs->trans("NoInvoiceToCorrect") . '</option>';
}
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
print '<div id="credit_note_options" class="clearboth">';
print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>';
print '</div></div>';
}
}
else
// Credit note
if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
{
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
$text = $tmp.$langs->trans("InvoiceAvoir") . ' ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') ';
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
if (! $optionsav) $tmp.=' disabled';
$tmp.= '> ';
// Show credit note options only if we checked credit note
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
if (! jQuery("#radio_creditnote").is(":checked"))
{
jQuery("#credit_note_options").hide();
}
jQuery("#radio_creditnote").click(function() {
jQuery("#credit_note_options").show();
});
jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
jQuery("#credit_note_options").hide();
});
});
</script>';
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
// $text.='<input type="text" value="">';
$text .= '<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
if (! $optionsav)
$text .= ' disabled';
$text .= '>';
if ($optionsav) {
$text .= '<option value="-1"></option>';
$text .= $optionsav;
} else {
$text .= '<option value="-1">' . $langs->trans("NoInvoiceToCorrect") . '</option>';
}
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</div></div>' . "\n";
print '<div id="credit_note_options" class="clearboth">';
print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>';
print '</div></div>';
}
}
else
{
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
$text = $tmp.$langs->trans("InvoiceAvoir") . ' ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') ';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</div></div>' . "\n";
}
}
print '</div>';
print '</td></tr>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0)
if ($societe->id > 0)
{
// Discounts for third party
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
@ -2411,18 +2408,17 @@ else
}
print '</td></tr>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
// Relative and absolute discounts
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
print '</td><td>';
$thirdparty = $societe;
$discount_type = 1;
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
// Relative and absolute discounts
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
print '</td><td>';
print '</td></tr>';
}
$thirdparty = $societe;
$discount_type = 1;
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
// Label
print '<tr>';
@ -2782,41 +2778,39 @@ else
$creditnoteamount = 0;
$depositamount = 0;
if($conf->global->MAIN_FEATURES_LEVEL > 0) {
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql .= " re.description, re.fk_invoice_supplier_source";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
$sql .= " WHERE fk_invoice_supplier = " . $object->id;
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$invoice = new FactureFournisseur($db);
while ($i < $num) {
$obj = $db->fetch_object($resql);
$invoice->fetch($obj->fk_invoice_supplier_source);
print '<tr><td colspan="' . $nbcols . '" align="right">';
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
print $langs->trans("CreditNote") . ' ';
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
print $langs->trans("Deposit") . ' ';
print $invoice->getNomUrl(0);
print ' :</td>';
print '<td align="right">' . price($obj->amount_ttc) . '</td>';
print '<td align="right">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&action=unlinkdiscount&discountid=' . $obj->rowid . '">' . img_delete() . '</a>';
print '</td></tr>';
$i ++;
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
$creditnoteamount += $obj->amount_ttc;
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
$depositamount += $obj->amount_ttc;
}
} else {
dol_print_error($db);
}
}
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql .= " re.description, re.fk_invoice_supplier_source";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
$sql .= " WHERE fk_invoice_supplier = " . $object->id;
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$invoice = new FactureFournisseur($db);
while ($i < $num) {
$obj = $db->fetch_object($resql);
$invoice->fetch($obj->fk_invoice_supplier_source);
print '<tr><td colspan="' . $nbcols . '" align="right">';
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
print $langs->trans("CreditNote") . ' ';
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
print $langs->trans("Deposit") . ' ';
print $invoice->getNomUrl(0);
print ' :</td>';
print '<td align="right">' . price($obj->amount_ttc) . '</td>';
print '<td align="right">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&action=unlinkdiscount&discountid=' . $obj->rowid . '">' . img_delete() . '</a>';
print '</td></tr>';
$i ++;
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
$creditnoteamount += $obj->amount_ttc;
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
$depositamount += $obj->amount_ttc;
}
} else {
dol_print_error($db);
}
// Paye partiellement 'escompte'
if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'discount_vat') {
@ -3029,7 +3023,7 @@ else
}
// Reverse back money or convert to reduction
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD)) {
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD) {
// For credit note only
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0)
{

View File

@ -1050,7 +1050,7 @@ if ($action == 'create')
}
print '</tr>' . "\n";
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $soc->id > 0)
if ($soc->id > 0)
{
// Discounts for third party
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
@ -1404,32 +1404,29 @@ if ($action == 'create')
print '<table class="border" width="100%">';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
// Relative and absolute discounts
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
}
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
$thirdparty = $soc;
$discount_type = 1;
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
// Relative and absolute discounts
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
}
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
$thirdparty = $soc;
$discount_type = 1;
$backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print '</td></tr>';
// Payment term
print '<tr><td class="titlefield">';
print '<table class="nobordernopadding" width="100%"><tr><td>';