30if (! defined(
'CSRFCHECK_WITH_TOKEN')) {
31 define(
'CSRFCHECK_WITH_TOKEN',
'1');
35require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
51$langs->loadLangs(array(
'orders',
'bills',
'companies'));
55$action =
GETPOST(
'action',
'aZ09');
56$backtopage =
GETPOST(
'backtopage',
'alpha');
57$splitamounts =
GETPOST(
'splitamounts',
'array');
62if ($user->socid > 0) {
63 $socid = $user->socid;
67if ($user->socid > 0) {
70$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
72$permissiontocreate = ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer'));
78if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage)) {
79 header(
"Location: ".$backtopage);
83if ($action ==
'confirm_split_more' && $permissiontocreate) {
87 $res = $discount->fetch($remid);
90 setEventMessages($langs->trans(
"ErrorFailedToLoadDiscount"),
null,
'errors');
91 } elseif ($discount->fk_soc != $socid) {
96 if (empty($splitamounts)) {
98 setEventMessages($langs->trans(
"TotalOfDiscountMustEqualsOriginal"),
null,
'errors');
102 foreach ($splitamounts as $key => $value) {
103 $totalsplitted += (float) $value;
105 if ($totalsplitted != (
float) $discount->amount_ttc) {
107 setEventMessages($langs->trans(
"TotalOfDiscountMustEqualsOriginal"),
null,
'errors');
114 foreach ($splitamounts as $key => $value) {
115 if ((
float) $value == 0) {
120 $newdiscount->fk_facture_source = $discount->fk_facture_source;
121 $newdiscount->fk_facture = $discount->fk_facture;
122 $newdiscount->fk_facture_line = $discount->fk_facture_line;
123 $newdiscount->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
124 $newdiscount->fk_invoice_supplier = $discount->fk_invoice_supplier;
125 $newdiscount->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
126 if ($discount->description ==
'(CREDIT_NOTE)' || $discount->description ==
'(DEPOSIT)') {
127 $newdiscount->description = $discount->description;
129 $newdiscount->description = $discount->description.
' (1)';
131 $newdiscount->fk_user = $discount->fk_user;
132 $newdiscount->fk_soc = $discount->fk_soc;
133 $newdiscount->socid = $discount->socid;
134 $newdiscount->discount_type = $discount->discount_type;
135 $newdiscount->datec = $discount->datec;
136 $newdiscount->tva_tx = $discount->tva_tx;
137 $newdiscount->localtax1_tx = $discount->localtax1_tx;
138 $newdiscount->localtax1_type = $discount->localtax1_type;
139 $newdiscount->localtax2_tx = $discount->localtax2_tx;
140 $newdiscount->localtax2_type = $discount->localtax2_type;
141 $newdiscount->vat_src_code = $discount->vat_src_code;
142 $newdiscount->amount_ttc =
price2num($value);
145 $newdiscount->generateFromAmount($newdiscount->amount_ttc, 1, $newdiscount->tva_tx, $newdiscount->localtax1_tx, $newdiscount->localtax2_tx, $newdiscount->localtax1_type, $newdiscount->localtax2_type);
147 $newdiscount->multicurrency_amount_ttc = (float) $value * ($discount->multicurrency_amount_ttc / $discount->amount_ttc);
148 $newdiscount->multicurrency_amount_ht =
price2num($newdiscount->multicurrency_amount_ttc / (1 + $newdiscount->tva_tx / 100),
'MT');
149 $newdiscount->multicurrency_amount_tva =
price2num($newdiscount->multicurrency_amount_ttc - $newdiscount->multicurrency_amount_ht);
151 $newdiscountID = $newdiscount->create($user);
152 if (!$newdiscountID) {
158 $discount->fk_facture_source = 0;
159 $discount->fk_invoice_supplier_source = 0;
160 $res = $discount->delete($user);
163 $query = [
'id' =>
$id,
'backtopage' => $backtopage];
164 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], $query));
175if ($action ==
'confirm_split' &&
GETPOST(
"confirm",
"alpha") ==
'yes' && $permissiontocreate) {
176 $amount_ttc_1 =
GETPOST(
'amount_ttc_1',
'alpha');
177 $amount_ttc_1 =
price2num($amount_ttc_1);
178 $amount_ttc_2 =
GETPOST(
'amount_ttc_2',
'alpha');
179 $amount_ttc_2 =
price2num($amount_ttc_2);
184 $res = $discount->fetch($remid);
187 setEventMessages($langs->trans(
"ErrorFailedToLoadDiscount"),
null,
'errors');
188 } elseif ($discount->fk_soc != $socid) {
193 if (!$error &&
price2num((
float) $amount_ttc_1 + (
float) $amount_ttc_2,
'MT') != $discount->amount_ttc) {
195 setEventMessages($langs->trans(
"TotalOfTwoDiscountMustEqualsOriginal"),
null,
'errors');
197 if (!$error && $discount->fk_facture_line) {
199 setEventMessages($langs->trans(
"ErrorCantSplitAUsedDiscount"),
null,
'errors');
203 $newDiscounts = $discount->splitAmount((
float) $amount_ttc_1, (
float) $amount_ttc_2);
204 $newdiscount1 = $newDiscounts[0];
205 $newdiscount2 = $newDiscounts[1];
209 $discount->fk_facture_source = 0;
211 $discount->fk_invoice_supplier_source = 0;
212 $res = $discount->delete($user);
213 $newid1 = $newdiscount1->create($user);
214 $newid2 = $newdiscount2->create($user);
215 if ($res > 0 && $newid1 > 0 && $newid2 > 0) {
217 $query = [
'id' =>
$id,
'backtopage' => $backtopage];
218 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], $query));
226if ($action ==
'setremise' && $permissiontocreate) {
228 $desc =
GETPOST(
'desc',
'alpha');
229 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
231 $price_base_type =
GETPOST(
'price_base_type',
'alpha');
236 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReasonDiscount")),
null,
'errors');
243 $discountid = $soc->set_remise_except((
float) $amount, $user, $desc, $tva_tx, $discount_type, $price_base_type);
245 if ($discountid > 0) {
246 if (!empty($backtopage)) {
247 header(
"Location: ".$backtopage.
'&discountid='.((
int) $discountid));
250 header(
"Location: remx.php?id=".((
int) $id));
259 setEventMessages($langs->trans(
"ErrorFieldFormat", $langs->transnoentitiesnoconv(
"AmountHT")),
null,
'errors');
263if (
GETPOST(
'action',
'aZ09') ==
'confirm_remove' &&
GETPOST(
"confirm") ==
'yes' && $permissiontocreate) {
267 $result = $discount->fetch(
GETPOSTINT(
"remid"));
268 if ($result > 0 && $discount->fk_soc == $socid) {
269 $result = $discount->delete($user);
277 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
295llxHeader(
'', $langs->trans(
"GlobalDiscount"));
303 $isSupplier =
$object->fournisseur == 1;
309 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
310 print
'<input type="hidden" name="token" value="'.newToken().
'">';
311 print
'<input type="hidden" name="action" value="setremise">';
312 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
314 print
dol_get_fiche_head($head,
'absolutediscount', $langs->trans(
"ThirdParty"), -1,
'company');
316 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
318 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
320 print
'<div class="fichecenter">';
322 print
'<div class="underbanner clearboth"></div>';
324 if (!$isCustomer && !$isSupplier) {
325 print
'<p class="opacitymedium">'.$langs->trans(
'ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').
'</p>';
337 print
'<div class="div-table-responsive-no-min">';
338 print
'<table class="border centpercent tableforfield borderbottom">';
341 $remise_all = $remise_user = 0;
342 $sql =
"SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
343 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
344 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
345 $sql .=
" AND rc.entity = ".((int)
$conf->entity);
346 $sql .=
" AND discount_type = 0";
347 $sql .=
" AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
348 $sql .=
" GROUP BY rc.fk_user";
349 $resql =
$db->query($sql);
351 while ($obj =
$db->fetch_object($resql)) {
352 $remise_all += (!empty($obj->amount) ? $obj->amount : 0);
353 if (!empty($obj->fk_user) && $obj->fk_user == $user->id) {
354 $remise_user += (!empty($obj->amount) ? $obj->amount : 0);
361 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"CustomerAbsoluteDiscountAllUsers").
'</td>';
362 print
'<td class="amount">'.price($remise_all, 1, $langs, 1, -1, -1,
$conf->currency).
' '.$langs->trans(
"HT");
363 if (empty($user->fk_soc)) {
364 print $form->textwithpicto(
'', $langs->trans(
"CustomerAbsoluteDiscountMy").
': '.
price($remise_user, 1, $langs, 1, -1, -1,
$conf->currency).
' '.$langs->trans(
"HT"));
371 $remise_all = $remise_user = 0;
372 $sql =
"SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
373 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
374 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
375 $sql .=
" AND rc.entity = ".((int)
$conf->entity);
376 $sql .=
" AND discount_type = 1";
377 $sql .=
" AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)";
378 $sql .=
" GROUP BY rc.fk_user";
379 $resql =
$db->query($sql);
381 while ($obj =
$db->fetch_object($resql)) {
382 $remise_all += (!empty($obj->amount) ? $obj->amount : 0);
383 if (!empty($obj->fk_user) && $obj->fk_user == $user->id) {
384 $remise_user += (!empty($obj->amount) ? $obj->amount : 0);
391 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"SupplierAbsoluteDiscountAllUsers").
'</td>';
392 print
'<td class="amount">'.price($remise_all, 1, $langs, 1, -1, -1,
$conf->currency).
' '.$langs->trans(
"HT");
393 if (empty($user->fk_soc)) {
394 print $form->textwithpicto(
'', $langs->trans(
"SupplierAbsoluteDiscountMy").
' : '.
price($remise_user, 1, $langs, 1, -1, -1,
$conf->currency).
' '.$langs->trans(
"HT"));
407 if ($action ==
'create_remise') {
408 if ($user->hasRight(
'societe',
'creer')) {
412 if ($isCustomer && $isSupplier) {
413 $discounttypelabel = $discount_type == 1 ?
'NewSupplierGlobalDiscount' :
'NewClientGlobalDiscount';
415 $discounttypelabel =
'NewGlobalDiscount';
420 if ($isSupplier && $discount_type == 1) {
421 print
'<input type="hidden" name="discount_type" value="1" />';
423 print
'<input type="hidden" name="discount_type" value="0" />';
429 print
'<div class="div-table-responsive-no-min">';
430 print
'<table class="border centpercent">';
439 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Amount").
'</td>';
440 print
'<td><input type="text" size="5" name="amount" value="'.price2num(
GETPOST(
"amount")).
'" autofocus>';
441 print
'<span class="hideonsmartphone"> '.$langs->trans(
"Currency".
$conf->currency).
'</span></td></tr>';
444 print
'<tr><td class="titlefield">'.$langs->trans(
"PriceBase").
'</td>';
446 print $form->selectPriceBaseType(
GETPOST(
"price_base_type"),
"price_base_type");
450 print
'<tr><td>'.$langs->trans(
"VAT").
'</td>';
452 print $form->load_tva(
'tva_tx', (
GETPOSTISSET(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') :
getDolGlobalString(
'MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS', 0)),
$mysoc,
$object, 0, 0,
'', false, 1);
454 print
'<tr><td class="fieldrequired" >'.$langs->trans(
"NoteReason").
'</td>';
455 print
'<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST(
'desc',
'alphanohtml').
'"></td></tr>';
463 if ($user->hasRight(
'societe',
'creer')) {
464 print
'<div class="center">';
465 print
'<input type="submit" class="button" name="submit" value="'.$langs->trans(
"AddGlobalDiscount").
'">';
466 if (!empty($backtopage)) {
467 print
' ';
468 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
480 if ($action ==
'remove') {
481 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&remid='.
GETPOST(
'remid'), $langs->trans(
'RemoveDiscount'), $langs->trans(
'ConfirmRemoveDiscount'),
'confirm_remove',
'', 0, 1);
489 if ($isCustomer && !$isSupplier) {
490 $newcardbutton =
dolGetButtonTitle($langs->trans(
"NewGlobalDiscount"),
'',
'fa fa-plus-circle', $_SERVER[
'PHP_SELF'].
'?action=create_remise&id='.
$id.
'&discount_type=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'&token='.
newToken());
491 } elseif (!$isCustomer && $isSupplier) {
492 $newcardbutton =
dolGetButtonTitle($langs->trans(
"NewGlobalDiscount"),
'',
'fa fa-plus-circle', $_SERVER[
'PHP_SELF'].
'?action=create_remise&id='.
$id.
'&discount_type=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'&token='.
newToken());
497 print
load_fiche_titre($langs->trans(
"DiscountStillRemaining"), $newcardbutton);
500 $newcardbutton =
dolGetButtonTitle($langs->trans(
"NewClientGlobalDiscount"),
'',
'fa fa-plus-circle', $_SERVER[
'PHP_SELF'].
'?action=create_remise&id='.
$id.
'&discount_type=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'&token='.
newToken());
502 print
'<div class="fichecenter">';
503 print
'<div class="fichehalfleft fichehalfleft-lg">';
504 print
load_fiche_titre($langs->trans(
"CustomerDiscounts"), $newcardbutton,
'');
507 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
508 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
509 $sql .=
" rc.datec as dc, rc.description,";
510 $sql .=
" rc.fk_facture_source,";
511 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
512 $sql .=
" fa.ref as ref, fa.type as type";
513 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
514 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
515 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
516 $sql .=
" AND rc.entity = ".((int)
$conf->entity);
517 $sql .=
" AND u.rowid = rc.fk_user";
518 $sql .=
" AND rc.discount_type = 0";
519 $sql .=
" AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)";
520 $sql .=
" ORDER BY rc.datec DESC";
522 $resql =
$db->query($sql);
524 print
'<div class="div-table-responsive-no-min">';
525 print
'<table class="noborder centpercent">';
526 print
'<tr class="liste_titre">';
527 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
528 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
529 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
530 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
532 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
534 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
535 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
537 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
539 print
'<td width="100" class="center">'.$langs->trans(
"DiscountOfferedBy").
'</td>';
540 print
'<td width="50"> </td>';
543 $showconfirminfo = array();
546 $num =
$db->num_rows($resql);
549 $obj =
$db->fetch_object($resql);
551 $tmpuser->id = $obj->user_id;
552 $tmpuser->login = $obj->login;
553 $tmpuser->firstname = $obj->firstname;
554 $tmpuser->lastname = $obj->lastname;
555 $tmpuser->photo = $obj->photo;
556 $tmpuser->status = $obj->status;
558 print
'<tr class="oddeven">';
560 print
'<td>'.dol_print_date(
$db->jdate($obj->dc),
'dayhour',
'tzuserrel').
'</td>';
562 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
563 print
'<td class="tdoverflowmax100">';
564 $facturestatic->id = $obj->fk_facture_source;
565 $facturestatic->ref = $obj->ref;
566 $facturestatic->type = $obj->type;
567 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
569 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
570 print
'<td class="tdoverflowmax100">';
571 $facturestatic->id = $obj->fk_facture_source;
572 $facturestatic->ref = $obj->ref;
573 $facturestatic->type = $obj->type;
574 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
576 } elseif (preg_match(
'/\(EXCESS RECEIVED\)/', $obj->description)) {
577 print
'<td class="tdoverflowmax100">';
578 $facturestatic->id = $obj->fk_facture_source;
579 $facturestatic->ref = $obj->ref;
580 $facturestatic->type = $obj->type;
581 print preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
584 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
589 print
'<td class="nowrap"><span class="opacitymedium">'.$langs->trans(
"NotConsumed").
'</span></td>';
591 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
594 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
596 print
'<td class="right nowraponall">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
597 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
599 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
601 print
'<td class="tdoverflowmax100">';
603 print $tmpuser->getNomUrl(-1);
606 if ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer')) {
607 print
'<td class="center nowraponall">';
608 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=split&token='.
newToken().
'&remid='.$obj->rowid.($backtopage ?
'&backtopage='.urlencode($backtopage) :
'').
'">'.
img_split($langs->trans(
"SplitDiscount")).
'</a>';
609 print
'<a class="reposition marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=remove&token='.
newToken().
'&remid='.$obj->rowid.($backtopage ?
'&backtopage='.urlencode($backtopage) :
'').
'">'.
img_delete($langs->trans(
"RemoveDiscount")).
'</a>';
612 print
'<td> </td>';
616 if ($action ==
'split' &&
GETPOST(
'remid') == $obj->rowid) {
617 $showconfirminfo[
'rowid'] = $obj->rowid;
618 $showconfirminfo[
'amount_ttc'] = $obj->amount_ttc;
627 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
633 if (count($showconfirminfo)) {
635 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].
'" id="formsplit" data-totaltosplit="'.$showconfirminfo[
'amount_ttc'].
'" data-remaintosplit="0">';
638 print
'<input type="hidden" name="action" value="confirm_split_more">';
639 print
'<input type="hidden" name="token" value="'.newToken().
'">';
641 print
'<div class="div-table-responsive-no-min">';
642 print
'<table class="valid centpercent">';
646 print
'<tr class="validtitre">';
647 print
'<td class="validtitre" colspan="4">'.img_picto(
'',
'split',
'', 0, 0, 0,
'',
'paddingright').
' '.$langs->trans(
'SplitDiscountTitle').
'</td>';
650 print
'<tr class="valid">';
651 print
'<td class="" colspan="4">'.$langs->trans(
'TypeAmountOfEachNewDiscountSplit').
'</td>';
655 if (empty($splitamounts)) {
656 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
657 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
658 $remaintosplit = (float) $showconfirminfo[
'amount_ttc'] - ((
float) $amount1 + (float) $amount2);
660 print
'<tr class="valid splitline" id="splitline-1">';
661 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 1:</td>';
662 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[1]" value="'.$amount1.
'"></td>';
663 print
'<td class="right delsplitline"></td>';
664 print
'<td class="right"></td>';
667 print
'<tr class="valid splitline" id="splitline-2">';
668 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 2:</td>';
669 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[2]" value="'.$amount2.
'"></td>';
670 print
'<td class="right delsplitline"></td>';
671 print
'<td class="right"></td>';
674 $nbSplitLines = count($splitamounts);
675 $remaintosplit = $showconfirminfo[
'amount_ttc'];
676 foreach ($splitamounts as $numero => $value) {
677 $remaintosplit -= (float) $value;
678 print
'<tr class="valid splitline" id="splitline-'.$numero.
'">';
679 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' '.$numero.
':</td>';
680 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['.$numero.
']" value="'.$splitamounts[$numero].
'"></td>';
681 print
'<td class="right delsplitline"></td>';
682 print
'<td class="right"></td>';
687 print
'<tr class="valid">';
688 print
'<td class="right"></td>';
689 print
'<td class="right"><span class="fas fa-plus-circle" id="splitaddline" style="cursor:pointer;"></span></td>';
690 print
'<td class="right"></td>';
693 print
'<tr class="valid">';
694 print
'<td colspan="3"> </td>';
698 print
'<tr class="valid">';
699 print
'<td class="right bold">'.$langs->trans(
'RemainToSplit').
':</td>';
700 print
'<td class="right"><span id="remaintosplit">'.price($remaintosplit).
'</span> '.
$conf->currency.
'</td>';
701 print
'<td class="right"></td>';
704 print
'<tr class="valid">';
705 print
'<td class="right bold"></td>';
706 print
'<td class="right"><input type="submit" class="button valignmiddle confirmvalidatebutton small nomarginright"></td>';
707 print
'<td class="right"></td>';
716 <script nonce=
"<?php print getNonce(); ?>" type=
"text/javascript">
717 $(document).ready(
function () {
719 let formsplit = $(
'#formsplit');
720 let totaltosplit = formsplit.data(
'totaltosplit');
722 function calcRemainToPay(){
723 let items = formsplit.find(
'.splitinput');
724 let remaintosplit = totaltosplit;
726 items.each(
function(e){
727 var itemvalue = parseFloat($(
this).val().replace(
',',
'.'));
728 if (isNaN(itemvalue)) {
731 remaintosplit -= itemvalue;
734 let remaintosplitval = remaintosplit.toFixed(2);
735 console.log(remaintosplitval);
736 formsplit.data(
'remaintosplit', remaintosplitval);
737 formsplit.find(
'#remaintosplit').html(remaintosplitval.replace(
'.',
','));
738 formsplit.find(
'input[type=submit]').prop(
'disabled',
true);
739 if (remaintosplit == 0) {
740 formsplit.find(
'input[type=submit]').prop(
'disabled',
false);
745 $(document).on(
'click',
'#splitaddline',
function(){
746 let splitlines = formsplit.find(
'.splitline');
747 let numlines = splitlines.length;
748 let nextNum = numlines + 1;
749 let newInputValue = formsplit.data(
'remaintosplit');
750 $(
'#splitline-'+numlines).find(
'.delsplitline').html(
'');
751 var splitTemplate =
'<tr class="splitline" id="splitline-'+ nextNum +
'">';
752 splitTemplate +=
'<td class="right bold"><?php echo $langs->trans('AmountTTC
'); ?> '+ nextNum +
':</td>';
753 splitTemplate +=
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['+ nextNum +
']" value="'+ parseFloat(newInputValue) +
'"></td>';
754 splitTemplate +=
'<td class="right delsplitline"><span class="fas fa-trash icon-delsplitline" data-splitline="'+ nextNum +
'" style="cursor:pointer;"></span></td>';
755 splitTemplate +=
'<td class="right"></td>';
756 splitTemplate +=
'</tr>';
757 $(
'#splitline-'+numlines).after(splitTemplate);
762 $(document).on(
'change',
'.splitinput',
function(){
767 $(document).on(
'click',
'.icon-delsplitline',
function(){
768 let num = parseInt($(
this).data(
'splitline'));
769 let numBefore = num - 1;
771 $(
'#splitline-'+numBefore).find(
'.delsplitline').html(
'<span class="fas fa-trash icon-delsplitline" data-splitline="'+ numBefore +
'"></span>');
773 $(
'#splitline-'+num).remove();
780 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
781 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
782 $formquestion = array(
783 'text' => $langs->trans(
'TypeAmountOfEachNewDiscount'),
784 0 => array(
'type' =>
'text',
'name' =>
'amount_ttc_1',
'label' => $langs->trans(
"AmountTTC").
' 1',
'value' => $amount1,
'size' =>
'5'),
785 1 => array(
'type' =>
'text',
'name' =>
'amount_ttc_2',
'label' => $langs->trans(
"AmountTTC").
' 2',
'value' => $amount2,
'size' =>
'5')
787 $langs->load(
"dict");
788 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].($backtopage ?
'&backtopage='.urlencode($backtopage) :
''), $langs->trans(
'SplitDiscount'), $langs->trans(
'ConfirmSplitDiscount',
price($showconfirminfo[
'amount_ttc']), $langs->transnoentities(
"Currency".
$conf->currency)),
'confirm_split', $formquestion,
'', 0);
798 $newcardbutton =
dolGetButtonTitle($langs->trans(
"NewSupplierGlobalDiscount"),
'',
'fa fa-plus-circle', $_SERVER[
'PHP_SELF'].
'?action=create_remise&id='.
$id.
'&discount_type=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'&token='.
newToken());
800 print
'<div class="fichehalfright fichehalfright-lg">';
801 print
load_fiche_titre($langs->trans(
"SupplierDiscounts"), $newcardbutton,
'');
807 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
808 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
809 $sql .=
" rc.datec as dc, rc.description,";
810 $sql .=
" rc.fk_invoice_supplier_source,";
811 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
812 $sql .=
" fa.ref, fa.type as type";
813 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
814 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
815 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
816 $sql .=
" AND rc.entity = ".((int)
$conf->entity);
817 $sql .=
" AND u.rowid = rc.fk_user";
818 $sql .=
" AND rc.discount_type = 1";
819 $sql .=
" AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)";
820 $sql .=
" ORDER BY rc.datec DESC";
822 $resql =
$db->query($sql);
824 print
'<div class="div-table-responsive-no-min">';
825 print
'<table class="noborder centpercent">';
826 print
'<tr class="liste_titre">';
827 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
828 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
829 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
830 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
832 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
834 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
835 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
837 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
839 print
'<td width="100" class="center">'.$langs->trans(
"DiscountOfferedBy").
'</td>';
840 print
'<td width="50"> </td>';
843 $showconfirminfo = array();
846 $num =
$db->num_rows($resql);
849 $obj =
$db->fetch_object($resql);
851 $tmpuser->id = $obj->user_id;
852 $tmpuser->login = $obj->login;
853 $tmpuser->firstname = $obj->firstname;
854 $tmpuser->lastname = $obj->lastname;
855 $tmpuser->photo = $obj->photo;
856 $tmpuser->status = $obj->status;
858 print
'<tr class="oddeven">';
859 print
'<td>'.dol_print_date(
$db->jdate($obj->dc),
'dayhour',
'tzuserrel').
'</td>';
860 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
861 print
'<td class="tdoverflowmax100">';
862 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
863 $facturefournstatic->ref = $obj->ref;
864 $facturefournstatic->type = $obj->type;
865 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
867 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
868 print
'<td class="tdoverflowmax100">';
869 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
870 $facturefournstatic->ref = $obj->ref;
871 $facturefournstatic->type = $obj->type;
872 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
874 } elseif (preg_match(
'/\(EXCESS PAID\)/', $obj->description)) {
875 print
'<td class="tdoverflowmax100">';
876 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
877 $facturefournstatic->ref = $obj->ref;
878 $facturefournstatic->type = $obj->type;
879 print preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
882 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
886 print
'<td class="nowrap"><span class="opacitymedium">'.$langs->trans(
"NotConsumed").
'</span></td>';
887 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
889 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
891 print
'<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
892 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
894 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
896 print
'<td class="tdoverflowmax100">';
897 print $tmpuser->getNomUrl(-1);
900 if ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer')) {
901 print
'<td class="center nowraponall">';
902 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=split&token='.
newToken().
'&remid='.$obj->rowid.($backtopage ?
'&backtopage='.urlencode($backtopage) :
'').
'">'.
img_split($langs->trans(
"SplitDiscount")).
'</a>';
903 print
'<a class="reposition marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=remove&token='.
newToken().
'&remid='.$obj->rowid.($backtopage ?
'&backtopage='.urlencode($backtopage) :
'').
'">'.
img_delete($langs->trans(
"RemoveDiscount")).
'</a>';
906 print
'<td> </td>';
910 if ($action ==
'split' &&
GETPOST(
'remid') == $obj->rowid) {
911 $showconfirminfo[
'rowid'] = $obj->rowid;
912 $showconfirminfo[
'amount_ttc'] = $obj->amount_ttc;
921 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
927 if (count($showconfirminfo)) {
929 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].
'" id="formsplit" data-totaltosplit="'.$showconfirminfo[
'amount_ttc'].
'" data-remaintosplit="0">';
932 print
'<input type="hidden" name="action" value="confirm_split_more">';
933 print
'<input type="hidden" name="token" value="'.newToken().
'">';
935 print
'<div class="div-table-responsive-no-min">';
936 print
'<table class="valid centpercent">';
940 print
'<tr class="validtitre">';
941 print
'<td class="validtitre" colspan="4">'.img_picto(
'',
'split',
'', 0, 0, 0,
'',
'paddingright').
' '.$langs->trans(
'SplitDiscountTitle').
'</td>';
944 print
'<tr class="valid">';
945 print
'<td class="" colspan="4">'.$langs->trans(
'TypeAmountOfEachNewDiscountSplit').
'</td>';
949 if (empty($splitamounts)) {
950 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
951 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
952 $remaintosplit = (float) $showconfirminfo[
'amount_ttc'] - ((
float) $amount1 + (float) $amount2);
954 print
'<tr class="valid splitline" id="splitline-1">';
955 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 1:</td>';
956 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[1]" value="'.$amount1.
'"></td>';
957 print
'<td class="right delsplitline"></td>';
958 print
'<td class="right"></td>';
961 print
'<tr class="valid splitline" id="splitline-2">';
962 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 2:</td>';
963 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[2]" value="'.$amount2.
'"></td>';
964 print
'<td class="right delsplitline"></td>';
965 print
'<td class="right"></td>';
968 $nbSplitLines = count($splitamounts);
969 $remaintosplit = $showconfirminfo[
'amount_ttc'];
970 foreach ($splitamounts as $numero => $value) {
971 $remaintosplit -= (float) $value;
972 print
'<tr class="valid splitline" id="splitline-'.$numero.
'">';
973 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' '.$numero.
':</td>';
974 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['.$numero.
']" value="'.$splitamounts[$numero].
'"></td>';
975 print
'<td class="right delsplitline"></td>';
976 print
'<td class="right"></td>';
981 print
'<tr class="valid">';
982 print
'<td class="right"></td>';
983 print
'<td class="right"><span class="fas fa-plus-circle" id="splitaddline" style="cursor:pointer;"></span></td>';
984 print
'<td class="right"></td>';
987 print
'<tr class="valid">';
988 print
'<td colspan="3"> </td>';
992 print
'<tr class="valid">';
993 print
'<td class="right bold">'.$langs->trans(
'RemainToSplit').
':</td>';
994 print
'<td class="right"><span id="remaintosplit">'.price($remaintosplit).
'</span> '.
$conf->currency.
'</td>';
995 print
'<td class="right"></td>';
998 print
'<tr class="valid">';
999 print
'<td class="right bold"></td>';
1000 print
'<td class="right"><input type="submit" class="button valignmiddle confirmvalidatebutton small nomarginright"></td>';
1001 print
'<td class="right"></td>';
1010 <script nonce=
"<?php print getNonce(); ?>" type=
"text/javascript">
1011 $(document).ready(
function () {
1013 let formsplit = $(
'#formsplit');
1014 let totaltosplit = formsplit.data(
'totaltosplit');
1016 function calcRemainToPay(){
1017 let items = formsplit.find(
'.splitinput');
1018 let remaintosplit = totaltosplit;
1020 items.each(
function(e){
1021 var itemvalue = parseFloat($(
this).val().replace(
',',
'.'));
1022 if (isNaN(itemvalue)) {
1025 remaintosplit -= itemvalue;
1028 let remaintosplitval = remaintosplit.toFixed(2);
1029 console.log(remaintosplitval);
1030 formsplit.data(
'remaintosplit', remaintosplitval);
1031 formsplit.find(
'#remaintosplit').html(remaintosplitval.replace(
'.',
','));
1032 formsplit.find(
'input[type=submit]').prop(
'disabled',
true);
1033 if (remaintosplit == 0) {
1034 formsplit.find(
'input[type=submit]').prop(
'disabled',
false);
1039 $(document).on(
'click',
'#splitaddline',
function(){
1040 let splitlines = formsplit.find(
'.splitline');
1041 let numlines = splitlines.length;
1042 let nextNum = numlines + 1;
1043 let newInputValue = formsplit.data(
'remaintosplit');
1044 $(
'#splitline-'+numlines).find(
'.delsplitline').html(
'');
1045 var splitTemplate =
'<tr class="splitline" id="splitline-'+ nextNum +
'">';
1046 splitTemplate +=
'<td class="right bold"><?php echo $langs->trans('AmountTTC
'); ?> '+ nextNum +
':</td>';
1047 splitTemplate +=
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['+ nextNum +
']" value="'+ parseFloat(newInputValue) +
'"></td>';
1048 splitTemplate +=
'<td class="right delsplitline"><span class="fas fa-trash icon-delsplitline" data-splitline="'+ nextNum +
'" style="cursor:pointer;"></span></td>';
1049 splitTemplate +=
'<td class="right"></td>';
1050 splitTemplate +=
'</tr>';
1051 $(
'#splitline-'+numlines).after(splitTemplate);
1056 $(document).on(
'change',
'.splitinput',
function(){
1061 $(document).on(
'click',
'.icon-delsplitline',
function(){
1062 let num = parseInt($(
this).data(
'splitline'));
1063 let numBefore = num - 1;
1064 if (numBefore > 2) {
1065 $(
'#splitline-'+numBefore).find(
'.delsplitline').html(
'<span class="fas fa-trash icon-delsplitline" data-splitline="'+ numBefore +
'"></span>');
1067 $(
'#splitline-'+num).remove();
1074 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
1075 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
1076 $formquestion = array(
1077 'text' => $langs->trans(
'TypeAmountOfEachNewDiscount'),
1078 0 => array(
'type' =>
'text',
'name' =>
'amount_ttc_1',
'label' => $langs->trans(
"AmountTTC").
' 1',
'value' => $amount1,
'size' =>
'5'),
1079 1 => array(
'type' =>
'text',
'name' =>
'amount_ttc_2',
'label' => $langs->trans(
"AmountTTC").
' 2',
'value' => $amount2,
'size' =>
'5')
1081 $langs->load(
"dict");
1082 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].($backtopage ?
'&backtopage='.urlencode($backtopage) :
''), $langs->trans(
'SplitDiscount'), $langs->trans(
'ConfirmSplitDiscount',
price($showconfirminfo[
'amount_ttc']), $langs->transnoentities(
"Currency".
$conf->currency)),
'confirm_split', $formquestion, 0, 0);
1095 print
'<div class="clearboth"></div><br><br>';
1105 print
'<div class="fichecenter">';
1106 print
'<div class="fichehalfleft fichehalfleft-lg">';
1111 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1112 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1113 $sql .=
" rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,";
1114 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1115 $sql .=
" f.rowid as invoiceid, f.ref,";
1116 $sql .=
" fa.ref as invoice_source_ref, fa.type as type";
1117 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
1118 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
1119 $sql .=
" , ".MAIN_DB_PREFIX.
"facturedet as fc";
1120 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1121 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
1122 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1123 $sql .=
" AND rc.fk_facture_line = fc.rowid";
1124 $sql .=
" AND fc.fk_facture = f.rowid";
1125 $sql .=
" AND rc.fk_user = u.rowid";
1126 $sql .=
" AND rc.discount_type = 0";
1127 $sql .=
" ORDER BY dc DESC";
1130 $sql2 =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1131 $sql2 .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1132 $sql2 .=
" rc.datec as dc, rc.description, rc.fk_facture, rc.fk_facture_source,";
1133 $sql2 .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1134 $sql2 .=
" f.rowid as invoiceid, f.ref,";
1135 $sql2 .=
" fa.ref as invoice_source_ref, fa.type as type";
1136 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
1137 $sql2 .=
" , ".MAIN_DB_PREFIX.
"user as u";
1138 $sql2 .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1139 $sql2 .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
1140 $sql2 .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1141 $sql2 .=
" AND rc.fk_facture = f.rowid";
1142 $sql2 .=
" AND rc.fk_user = u.rowid";
1143 $sql2 .=
" AND rc.discount_type = 0";
1144 $sql2 .=
" ORDER BY dc DESC";
1146 $resql =
$db->query($sql);
1149 $resql2 =
$db->query($sql2);
1152 print
'<div class="div-table-responsive-no-min">';
1153 print
'<table class="noborder centpercent">';
1154 print
'<tr class="liste_titre">';
1155 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
1156 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
1157 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
1158 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
1160 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
1162 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
1163 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
1165 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
1167 print
'<td width="100" class="center">'.$langs->trans(
"Author").
'</td>';
1168 print
'<td width="50"> </td>';
1171 $tab_sqlobj = array();
1172 $tab_sqlobjOrder = array();
1173 $num =
$db->num_rows($resql);
1175 for ($i = 0; $i < $num; $i++) {
1176 $fetched_obj =
$db->fetch_object($resql);
1177 $tab_sqlobj[] = $fetched_obj;
1178 $tab_sqlobjOrder[] =
$db->jdate($fetched_obj->dc);
1183 $num =
$db->num_rows($resql2);
1184 for ($i = 0; $i < $num; $i++) {
1185 $fetched_obj =
$db->fetch_object($resql2);
1186 $tab_sqlobj[] = $fetched_obj;
1187 $tab_sqlobjOrder[] =
$db->jdate($fetched_obj->dc);
1190 $array1_sort_order = SORT_DESC;
1191 array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj);
1193 $num = count($tab_sqlobj);
1197 $obj = array_shift($tab_sqlobj);
1199 $tmpuser->id = $obj->user_id;
1200 $tmpuser->login = $obj->login;
1201 $tmpuser->firstname = $obj->firstname;
1202 $tmpuser->lastname = $obj->lastname;
1203 $tmpuser->photo = $obj->photo;
1204 $tmpuser->status = $obj->status;
1206 print
'<tr class="oddeven">';
1207 print
'<td>'.dol_print_date(
$db->jdate($obj->dc),
'dayhour').
'</td>';
1208 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
1209 print
'<td class="tdoverflowmax100">';
1210 $facturestatic->id = $obj->fk_facture_source;
1211 $facturestatic->ref = $obj->invoice_source_ref;
1212 $facturestatic->type = $obj->type;
1213 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1215 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
1216 print
'<td class="tdoverflowmax100">';
1217 $facturestatic->id = $obj->fk_facture_source;
1218 $facturestatic->ref = $obj->invoice_source_ref;
1219 $facturestatic->type = $obj->type;
1220 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1222 } elseif (preg_match(
'/\(EXCESS RECEIVED\)/', $obj->description)) {
1223 print
'<td class="tdoverflowmax100">';
1224 $facturestatic->id = $obj->fk_facture_source;
1225 $facturestatic->ref = $obj->invoice_source_ref;
1226 $facturestatic->type = $obj->type;
1227 print preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"Invoice"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1230 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
1234 print
'<td class="left nowrap">';
1235 if ($obj->invoiceid) {
1236 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->invoiceid.
'">'.
img_object($langs->trans(
"ShowBill"),
'bill').
' '.$obj->ref.
'</a>';
1239 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
1241 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
1243 print
'<td class="right nowraponall">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
1244 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
1246 print
'<td class="right">'.price($obj->multicurrency_amount_ttc).
'</td>';
1248 print
'<td class="tdoverflowmax100">';
1249 print $tmpuser->getNomUrl(-1);
1252 print
'<td> </td>';
1261 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1274 print
'<div class="fichehalfright fichehalfright-lg">';
1279 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1280 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1281 $sql .=
" rc.datec as dc, rc.description, rc.fk_invoice_supplier_line,";
1282 $sql .=
" rc.fk_invoice_supplier_source,";
1283 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1284 $sql .=
" f.rowid as invoiceid, f.ref as ref,";
1285 $sql .=
" fa.ref as invoice_source_ref, fa.type as type";
1286 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
1287 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
1288 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn_det as fc";
1289 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1290 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
1291 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1292 $sql .=
" AND rc.fk_invoice_supplier_line = fc.rowid";
1293 $sql .=
" AND fc.fk_facture_fourn = f.rowid";
1294 $sql .=
" AND rc.fk_user = u.rowid";
1295 $sql .=
" AND rc.discount_type = 1";
1296 $sql .=
" ORDER BY dc DESC";
1299 $sql2 =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1300 $sql2 .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1301 $sql2 .=
" rc.datec as dc, rc.description, rc.fk_invoice_supplier,";
1302 $sql2 .=
" rc.fk_invoice_supplier_source,";
1303 $sql2 .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1304 $sql2 .=
" f.rowid as invoiceid, f.ref as ref,";
1305 $sql2 .=
" fa.ref as invoice_source_ref, fa.type as type";
1306 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
1307 $sql2 .=
" , ".MAIN_DB_PREFIX.
"user as u";
1308 $sql2 .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1309 $sql2 .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
1310 $sql2 .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1311 $sql2 .=
" AND rc.fk_invoice_supplier = f.rowid";
1312 $sql2 .=
" AND rc.fk_user = u.rowid";
1313 $sql2 .=
" AND rc.discount_type = 1";
1314 $sql2 .=
" ORDER BY dc DESC";
1316 $resql =
$db->query($sql);
1319 $resql2 =
$db->query($sql2);
1322 print
'<div class="div-table-responsive-no-min">';
1323 print
'<table class="noborder centpercent">';
1324 print
'<tr class="liste_titre">';
1325 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
1326 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
1327 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
1328 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
1330 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
1332 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
1333 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
1335 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
1337 print
'<td width="100" class="center">'.$langs->trans(
"Author").
'</td>';
1338 print
'<td width="50"> </td>';
1341 $tab_sqlobj = array();
1342 $tab_sqlobjOrder = array();
1343 $num =
$db->num_rows($resql);
1345 for ($i = 0; $i < $num; $i++) {
1346 $fetched_obj =
$db->fetch_object($resql);
1347 $tab_sqlobj[] = $fetched_obj;
1348 $tab_sqlobjOrder[] =
$db->jdate($fetched_obj->dc);
1353 $num =
$db->num_rows($resql2);
1354 for ($i = 0; $i < $num; $i++) {
1355 $fetched_obj =
$db->fetch_object($resql2);
1356 $tab_sqlobj[] = $fetched_obj;
1357 $tab_sqlobjOrder[] =
$db->jdate($fetched_obj->dc);
1360 $array1_sort_order = SORT_DESC;
1361 array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj);
1363 $num = count($tab_sqlobj);
1367 $obj = array_shift($tab_sqlobj);
1369 $tmpuser->id = $obj->user_id;
1370 $tmpuser->login = $obj->login;
1371 $tmpuser->firstname = $obj->firstname;
1372 $tmpuser->lastname = $obj->lastname;
1373 $tmpuser->photo = $obj->photo;
1374 $tmpuser->status = $obj->status;
1376 print
'<tr class="oddeven">';
1377 print
'<td>'.dol_print_date(
$db->jdate($obj->dc),
'dayhour').
'</td>';
1378 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
1379 print
'<td class="tdoverflowmax100">';
1380 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1381 $facturefournstatic->ref = $obj->invoice_source_ref;
1382 $facturefournstatic->type = $obj->type;
1383 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1385 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
1386 print
'<td class="tdoverflowmax100">';
1387 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1388 $facturefournstatic->ref = $obj->invoice_source_ref;
1389 $facturefournstatic->type = $obj->type;
1390 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1392 } elseif (preg_match(
'/\(EXCESS PAID\)/', $obj->description)) {
1393 print
'<td class="tdoverflowmax100">';
1394 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1395 $facturefournstatic->ref = $obj->invoice_source_ref;
1396 $facturefournstatic->type = $obj->type;
1397 print preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"Invoice"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1400 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
1404 print
'<td class="left nowrap">';
1405 if ($obj->invoiceid) {
1406 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$obj->invoiceid.
'">'.
img_object($langs->trans(
"ShowBill"),
'bill').
' '.$obj->ref.
'</a>';
1409 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
1411 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
1413 print
'<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
1414 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
1416 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
1418 print
'<td class="tdoverflowmax100">';
1419 print $tmpuser->getNomUrl(-1);
1422 print
'<td> </td>';
1432 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage absolute discounts.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.