29if (! defined(
'CSRFCHECK_WITH_TOKEN')) {
30 define(
'CSRFCHECK_WITH_TOKEN',
'1');
34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
50$langs->loadLangs(array(
'orders',
'bills',
'companies'));
54$action =
GETPOST(
'action',
'aZ09');
55$backtopage =
GETPOST(
'backtopage',
'alpha');
56$splitamounts =
GETPOST(
'splitamounts',
'array');
61if ($user->socid > 0) {
62 $socid = $user->socid;
66if ($user->socid > 0) {
69$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
71$permissiontocreate = ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer'));
77if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage)) {
78 header(
"Location: ".$backtopage);
82if ($action ==
'confirm_split_more' && $permissiontocreate) {
86 $res = $discount->fetch($remid);
89 setEventMessages($langs->trans(
"ErrorFailedToLoadDiscount"),
null,
'errors');
90 } elseif ($discount->fk_soc != $socid) {
95 if (empty($splitamounts)) {
97 setEventMessages($langs->trans(
"TotalOfDiscountMustEqualsOriginal"),
null,
'errors');
101 foreach ($splitamounts as $key => $value) {
102 $totalsplitted += (float) $value;
104 if ($totalsplitted != (
float) $discount->amount_ttc) {
106 setEventMessages($langs->trans(
"TotalOfDiscountMustEqualsOriginal"),
null,
'errors');
113 foreach ($splitamounts as $key => $value) {
114 if ((
float) $value == 0) {
119 $newdiscount->fk_facture_source = $discount->fk_facture_source;
120 $newdiscount->fk_facture = $discount->fk_facture;
121 $newdiscount->fk_facture_line = $discount->fk_facture_line;
122 $newdiscount->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
123 $newdiscount->fk_invoice_supplier = $discount->fk_invoice_supplier;
124 $newdiscount->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
125 if ($discount->description ==
'(CREDIT_NOTE)' || $discount->description ==
'(DEPOSIT)') {
126 $newdiscount->description = $discount->description;
128 $newdiscount->description = $discount->description.
' (1)';
130 $newdiscount->fk_user = $discount->fk_user;
131 $newdiscount->fk_soc = $discount->fk_soc;
132 $newdiscount->socid = $discount->socid;
133 $newdiscount->discount_type = $discount->discount_type;
134 $newdiscount->datec = $discount->datec;
135 $newdiscount->tva_tx = $discount->tva_tx;
136 $newdiscount->vat_src_code = $discount->vat_src_code;
137 $newdiscount->amount_ttc =
price2num($value);
138 $newdiscount->amount_ht =
price2num($newdiscount->amount_ttc / (1 + $newdiscount->tva_tx / 100),
'MT');
139 $newdiscount->amount_tva =
price2num($newdiscount->amount_ttc - $newdiscount->amount_ht);
140 $newdiscount->multicurrency_amount_ttc = (float) $value * ($discount->multicurrency_amount_ttc / $discount->amount_ttc);
141 $newdiscount->multicurrency_amount_ht =
price2num($newdiscount->multicurrency_amount_ttc / (1 + $newdiscount->tva_tx / 100),
'MT');
142 $newdiscount->multicurrency_amount_tva =
price2num($newdiscount->multicurrency_amount_ttc - $newdiscount->multicurrency_amount_ht);
144 $newdiscountID = $newdiscount->create($user);
145 if (!$newdiscountID) {
151 $discount->fk_facture_source = 0;
152 $discount->fk_invoice_supplier_source = 0;
153 $res = $discount->delete($user);
156 $query = [
'id' =>
$id,
'backtopage' => $backtopage];
157 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], $query));
168if ($action ==
'confirm_split' &&
GETPOST(
"confirm",
"alpha") ==
'yes' && $permissiontocreate) {
169 $amount_ttc_1 =
GETPOST(
'amount_ttc_1',
'alpha');
170 $amount_ttc_1 =
price2num($amount_ttc_1);
171 $amount_ttc_2 =
GETPOST(
'amount_ttc_2',
'alpha');
172 $amount_ttc_2 =
price2num($amount_ttc_2);
177 $res = $discount->fetch($remid);
180 setEventMessages($langs->trans(
"ErrorFailedToLoadDiscount"),
null,
'errors');
181 } elseif ($discount->fk_soc != $socid) {
186 if (!$error &&
price2num((
float) $amount_ttc_1 + (
float) $amount_ttc_2,
'MT') != $discount->amount_ttc) {
188 setEventMessages($langs->trans(
"TotalOfTwoDiscountMustEqualsOriginal"),
null,
'errors');
190 if (!$error && $discount->fk_facture_line) {
192 setEventMessages($langs->trans(
"ErrorCantSplitAUsedDiscount"),
null,
'errors');
197 $newdiscount1->fk_facture_source = $discount->fk_facture_source;
198 $newdiscount2->fk_facture_source = $discount->fk_facture_source;
199 $newdiscount1->fk_facture = $discount->fk_facture;
200 $newdiscount2->fk_facture = $discount->fk_facture;
201 $newdiscount1->fk_facture_line = $discount->fk_facture_line;
202 $newdiscount2->fk_facture_line = $discount->fk_facture_line;
203 $newdiscount1->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
204 $newdiscount2->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
205 $newdiscount1->fk_invoice_supplier = $discount->fk_invoice_supplier;
206 $newdiscount2->fk_invoice_supplier = $discount->fk_invoice_supplier;
207 $newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
208 $newdiscount2->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
209 if ($discount->description ==
'(CREDIT_NOTE)' || $discount->description ==
'(DEPOSIT)') {
210 $newdiscount1->description = $discount->description;
211 $newdiscount2->description = $discount->description;
213 $newdiscount1->description = $discount->description.
' (1)';
214 $newdiscount2->description = $discount->description.
' (2)';
217 $newdiscount1->fk_user = $discount->fk_user;
218 $newdiscount2->fk_user = $discount->fk_user;
219 $newdiscount1->fk_soc = $discount->fk_soc;
220 $newdiscount1->socid = $discount->socid;
221 $newdiscount2->fk_soc = $discount->fk_soc;
222 $newdiscount2->socid = $discount->socid;
223 $newdiscount1->discount_type = $discount->discount_type;
224 $newdiscount2->discount_type = $discount->discount_type;
225 $newdiscount1->datec = $discount->datec;
226 $newdiscount2->datec = $discount->datec;
227 $newdiscount1->tva_tx = $discount->tva_tx;
228 $newdiscount2->tva_tx = $discount->tva_tx;
229 $newdiscount1->vat_src_code = $discount->vat_src_code;
230 $newdiscount2->vat_src_code = $discount->vat_src_code;
231 $newdiscount1->amount_ttc = $amount_ttc_1;
232 $newdiscount2->amount_ttc =
price2num($discount->amount_ttc - $newdiscount1->amount_ttc);
233 $newdiscount1->amount_ht =
price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100),
'MT');
234 $newdiscount2->amount_ht =
price2num($newdiscount2->amount_ttc / (1 + $newdiscount2->tva_tx / 100),
'MT');
235 $newdiscount1->amount_tva =
price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht);
236 $newdiscount2->amount_tva =
price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht);
238 $newdiscount1->multicurrency_amount_ttc = (float) $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc);
239 $newdiscount2->multicurrency_amount_ttc =
price2num($discount->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ttc);
240 $newdiscount1->multicurrency_amount_ht =
price2num($newdiscount1->multicurrency_amount_ttc / (1 + $newdiscount1->tva_tx / 100),
'MT');
241 $newdiscount2->multicurrency_amount_ht =
price2num($newdiscount2->multicurrency_amount_ttc / (1 + $newdiscount2->tva_tx / 100),
'MT');
242 $newdiscount1->multicurrency_amount_tva =
price2num($newdiscount1->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ht);
243 $newdiscount2->multicurrency_amount_tva =
price2num($newdiscount2->multicurrency_amount_ttc - $newdiscount2->multicurrency_amount_ht);
247 $discount->fk_facture_source = 0;
249 $discount->fk_invoice_supplier_source = 0;
250 $res = $discount->delete($user);
251 $newid1 = $newdiscount1->create($user);
252 $newid2 = $newdiscount2->create($user);
253 if ($res > 0 && $newid1 > 0 && $newid2 > 0) {
255 $query = [
'id' =>
$id,
'backtopage' => $backtopage];
256 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], $query));
264if ($action ==
'setremise' && $permissiontocreate) {
266 $desc =
GETPOST(
'desc',
'alpha');
267 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
268 $discount_type = GETPOSTISSET(
'discount_type') ?
GETPOST(
'discount_type',
'alpha') : 0;
269 $price_base_type =
GETPOST(
'price_base_type',
'alpha');
274 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReasonDiscount")),
null,
'errors');
281 $discountid = $soc->set_remise_except((
float) $amount, $user, $desc, $tva_tx, $discount_type, $price_base_type);
283 if ($discountid > 0) {
284 if (!empty($backtopage)) {
285 header(
"Location: ".$backtopage.
'&discountid='.((
int) $discountid));
288 header(
"Location: remx.php?id=".((
int) $id));
297 setEventMessages($langs->trans(
"ErrorFieldFormat", $langs->transnoentitiesnoconv(
"AmountHT")),
null,
'errors');
301if (
GETPOST(
'action',
'aZ09') ==
'confirm_remove' &&
GETPOST(
"confirm") ==
'yes' && $permissiontocreate) {
305 $result = $discount->fetch(
GETPOSTINT(
"remid"));
306 if ($result > 0 && $discount->fk_soc == $socid) {
307 $result = $discount->delete($user);
315 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
328$form =
new Form($db);
329$facturestatic =
new Facture($db);
331$tmpuser =
new User($db);
333llxHeader(
'', $langs->trans(
"GlobalDiscount"));
341 $isSupplier =
$object->fournisseur == 1;
347 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
348 print
'<input type="hidden" name="token" value="'.newToken().
'">';
349 print
'<input type="hidden" name="action" value="setremise">';
350 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
352 print
dol_get_fiche_head($head,
'absolutediscount', $langs->trans(
"ThirdParty"), -1,
'company');
354 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
356 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
358 print
'<div class="fichecenter">';
360 print
'<div class="underbanner clearboth"></div>';
362 if (!$isCustomer && !$isSupplier) {
363 print
'<p class="opacitymedium">'.$langs->trans(
'ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').
'</p>';
375 print
'<div class="div-table-responsive-no-min">';
376 print
'<table class="border centpercent tableforfield borderbottom">';
379 $remise_all = $remise_user = 0;
380 $sql =
"SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
381 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
382 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
383 $sql .=
" AND rc.entity = ".((int) $conf->entity);
384 $sql .=
" AND discount_type = 0";
385 $sql .=
" AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
386 $sql .=
" GROUP BY rc.fk_user";
387 $resql = $db->query($sql);
389 while ($obj = $db->fetch_object($resql)) {
390 $remise_all += (!empty($obj->amount) ? $obj->amount : 0);
391 if (!empty($obj->fk_user) && $obj->fk_user == $user->id) {
392 $remise_user += (!empty($obj->amount) ? $obj->amount : 0);
399 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"CustomerAbsoluteDiscountAllUsers").
'</td>';
400 print
'<td class="amount">'.price($remise_all, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT");
401 if (empty($user->fk_soc)) {
402 print $form->textwithpicto(
'', $langs->trans(
"CustomerAbsoluteDiscountMy").
': '.
price($remise_user, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT"));
409 $remise_all = $remise_user = 0;
410 $sql =
"SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
411 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
412 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
413 $sql .=
" AND rc.entity = ".((int) $conf->entity);
414 $sql .=
" AND discount_type = 1";
415 $sql .=
" AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)";
416 $sql .=
" GROUP BY rc.fk_user";
417 $resql = $db->query($sql);
419 while ($obj = $db->fetch_object($resql)) {
420 $remise_all += (!empty($obj->amount) ? $obj->amount : 0);
421 if (!empty($obj->fk_user) && $obj->fk_user == $user->id) {
422 $remise_user += (!empty($obj->amount) ? $obj->amount : 0);
429 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"SupplierAbsoluteDiscountAllUsers").
'</td>';
430 print
'<td class="amount">'.price($remise_all, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT");
431 if (empty($user->fk_soc)) {
432 print $form->textwithpicto(
'', $langs->trans(
"SupplierAbsoluteDiscountMy").
' : '.
price($remise_user, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT"));
445 if ($action ==
'create_remise') {
446 if ($user->hasRight(
'societe',
'creer')) {
449 $discount_type = GETPOSTISSET(
'discount_type') ?
GETPOST(
'discount_type',
'alpha') : 0;
450 if ($isCustomer && $isSupplier) {
451 $discounttypelabel = $discount_type == 1 ?
'NewSupplierGlobalDiscount' :
'NewClientGlobalDiscount';
453 $discounttypelabel =
'NewGlobalDiscount';
458 if ($isSupplier && $discount_type == 1) {
459 print
'<input type="hidden" name="discount_type" value="1" />';
461 print
'<input type="hidden" name="discount_type" value="0" />';
467 print
'<div class="div-table-responsive-no-min">';
468 print
'<table class="border centpercent">';
477 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Amount").
'</td>';
478 print
'<td><input type="text" size="5" name="amount" value="'.price2num(
GETPOST(
"amount")).
'" autofocus>';
479 print
'<span class="hideonsmartphone"> '.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
482 print
'<tr><td class="titlefield">'.$langs->trans(
"PriceBase").
'</td>';
484 print $form->selectPriceBaseType(
GETPOST(
"price_base_type"),
"price_base_type");
488 print
'<tr><td>'.$langs->trans(
"VAT").
'</td>';
490 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);
492 print
'<tr><td class="fieldrequired" >'.$langs->trans(
"NoteReason").
'</td>';
493 print
'<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST(
'desc',
'alphanohtml').
'"></td></tr>';
501 if ($user->hasRight(
'societe',
'creer')) {
502 print
'<div class="center">';
503 print
'<input type="submit" class="button" name="submit" value="'.$langs->trans(
"AddGlobalDiscount").
'">';
504 if (!empty($backtopage)) {
505 print
' ';
506 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
518 if ($action ==
'remove') {
519 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&remid='.
GETPOST(
'remid'), $langs->trans(
'RemoveDiscount'), $langs->trans(
'ConfirmRemoveDiscount'),
'confirm_remove',
'', 0, 1);
527 if ($isCustomer && !$isSupplier) {
528 $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());
529 } elseif (!$isCustomer && $isSupplier) {
530 $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());
535 print
load_fiche_titre($langs->trans(
"DiscountStillRemaining"), $newcardbutton);
538 $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());
540 print
'<div class="fichecenter">';
541 print
'<div class="fichehalfleft fichehalfleft-lg">';
542 print
load_fiche_titre($langs->trans(
"CustomerDiscounts"), $newcardbutton,
'');
545 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
546 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
547 $sql .=
" rc.datec as dc, rc.description,";
548 $sql .=
" rc.fk_facture_source,";
549 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
550 $sql .=
" fa.ref as ref, fa.type as type";
551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
552 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
553 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
554 $sql .=
" AND rc.entity = ".((int) $conf->entity);
555 $sql .=
" AND u.rowid = rc.fk_user";
556 $sql .=
" AND rc.discount_type = 0";
557 $sql .=
" AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)";
558 $sql .=
" ORDER BY rc.datec DESC";
560 $resql = $db->query($sql);
562 print
'<div class="div-table-responsive-no-min">';
563 print
'<table class="noborder centpercent">';
564 print
'<tr class="liste_titre">';
565 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
566 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
567 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
568 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
570 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
572 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
573 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
575 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
577 print
'<td width="100" class="center">'.$langs->trans(
"DiscountOfferedBy").
'</td>';
578 print
'<td width="50"> </td>';
581 $showconfirminfo = array();
584 $num = $db->num_rows($resql);
587 $obj = $db->fetch_object($resql);
589 $tmpuser->id = $obj->user_id;
590 $tmpuser->login = $obj->login;
591 $tmpuser->firstname = $obj->firstname;
592 $tmpuser->lastname = $obj->lastname;
593 $tmpuser->photo = $obj->photo;
594 $tmpuser->status = $obj->status;
596 print
'<tr class="oddeven">';
598 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour',
'tzuserrel').
'</td>';
600 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
601 print
'<td class="tdoverflowmax100">';
602 $facturestatic->id = $obj->fk_facture_source;
603 $facturestatic->ref = $obj->ref;
604 $facturestatic->type = $obj->type;
605 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
607 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
608 print
'<td class="tdoverflowmax100">';
609 $facturestatic->id = $obj->fk_facture_source;
610 $facturestatic->ref = $obj->ref;
611 $facturestatic->type = $obj->type;
612 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
614 } elseif (preg_match(
'/\(EXCESS RECEIVED\)/', $obj->description)) {
615 print
'<td class="tdoverflowmax100">';
616 $facturestatic->id = $obj->fk_facture_source;
617 $facturestatic->ref = $obj->ref;
618 $facturestatic->type = $obj->type;
619 print preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
622 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
627 print
'<td class="nowrap"><span class="opacitymedium">'.$langs->trans(
"NotConsumed").
'</span></td>';
629 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
632 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
634 print
'<td class="right nowraponall">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
635 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
637 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
639 print
'<td class="tdoverflowmax100">';
641 print $tmpuser->getNomUrl(-1);
644 if ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer')) {
645 print
'<td class="center nowraponall">';
646 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>';
647 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>';
650 print
'<td> </td>';
654 if ($action ==
'split' &&
GETPOST(
'remid') == $obj->rowid) {
655 $showconfirminfo[
'rowid'] = $obj->rowid;
656 $showconfirminfo[
'amount_ttc'] = $obj->amount_ttc;
665 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
671 if (count($showconfirminfo)) {
673 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].
'" id="formsplit" data-totaltosplit="'.$showconfirminfo[
'amount_ttc'].
'" data-remaintosplit="0">';
676 print
'<input type="hidden" name="action" value="confirm_split_more">';
677 print
'<input type="hidden" name="token" value="'.newToken().
'">';
679 print
'<div class="div-table-responsive-no-min">';
680 print
'<table class="valid centpercent">';
684 print
'<tr class="validtitre">';
685 print
'<td class="validtitre" colspan="4">'.img_picto(
'',
'split',
'', 0, 0, 0,
'',
'paddingright').
' '.$langs->trans(
'SplitDiscountTitle').
'</td>';
688 print
'<tr class="valid">';
689 print
'<td class="" colspan="4">'.$langs->trans(
'TypeAmountOfEachNewDiscountSplit').
'</td>';
693 if (empty($splitamounts)) {
694 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
695 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
696 $remaintosplit = (float) $showconfirminfo[
'amount_ttc'] - ((
float) $amount1 + (float) $amount2);
698 print
'<tr class="valid splitline" id="splitline-1">';
699 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 1:</td>';
700 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[1]" value="'.$amount1.
'"></td>';
701 print
'<td class="right delsplitline"></td>';
702 print
'<td class="right"></td>';
705 print
'<tr class="valid splitline" id="splitline-2">';
706 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 2:</td>';
707 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[2]" value="'.$amount2.
'"></td>';
708 print
'<td class="right delsplitline"></td>';
709 print
'<td class="right"></td>';
712 $nbSplitLines = count($splitamounts);
713 $remaintosplit = $showconfirminfo[
'amount_ttc'];
714 foreach ($splitamounts as $numero => $value) {
715 $remaintosplit -= (float) $value;
716 print
'<tr class="valid splitline" id="splitline-'.$numero.
'">';
717 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' '.$numero.
':</td>';
718 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['.$numero.
']" value="'.$splitamounts[$numero].
'"></td>';
719 print
'<td class="right delsplitline"></td>';
720 print
'<td class="right"></td>';
725 print
'<tr class="valid">';
726 print
'<td class="right"></td>';
727 print
'<td class="right"><span class="fas fa-plus-circle" id="splitaddline" style="cursor:pointer;"></span></td>';
728 print
'<td class="right"></td>';
731 print
'<tr class="valid">';
732 print
'<td colspan="3"> </td>';
736 print
'<tr class="valid">';
737 print
'<td class="right bold">'.$langs->trans(
'RemainToSplit').
':</td>';
738 print
'<td class="right"><span id="remaintosplit">'.price($remaintosplit).
'</span> '.$conf->currency.
'</td>';
739 print
'<td class="right"></td>';
742 print
'<tr class="valid">';
743 print
'<td class="right bold"></td>';
744 print
'<td class="right"><input type="submit" class="button valignmiddle confirmvalidatebutton small nomarginright"></td>';
745 print
'<td class="right"></td>';
754 <script nonce=
"<?php print getNonce(); ?>" type=
"text/javascript">
755 $(document).ready(
function () {
757 let formsplit = $(
'#formsplit');
758 let totaltosplit = formsplit.data(
'totaltosplit');
760 function calcRemainToPay(){
761 let items = formsplit.find(
'.splitinput');
762 let remaintosplit = totaltosplit;
764 items.each(
function(e){
765 var itemvalue = parseFloat($(
this).val().replace(
',',
'.'));
766 if (isNaN(itemvalue)) {
769 remaintosplit -= itemvalue;
772 let remaintosplitval = remaintosplit.toFixed(2);
773 console.log(remaintosplitval);
774 formsplit.data(
'remaintosplit', remaintosplitval);
775 formsplit.find(
'#remaintosplit').html(remaintosplitval.replace(
'.',
','));
776 formsplit.find(
'input[type=submit]').prop(
'disabled',
true);
777 if (remaintosplit == 0) {
778 formsplit.find(
'input[type=submit]').prop(
'disabled',
false);
783 $(document).on(
'click',
'#splitaddline',
function(){
784 let splitlines = formsplit.find(
'.splitline');
785 let numlines = splitlines.length;
786 let nextNum = numlines + 1;
787 let newInputValue = formsplit.data(
'remaintosplit');
788 $(
'#splitline-'+numlines).find(
'.delsplitline').html(
'');
789 var splitTemplate =
'<tr class="splitline" id="splitline-'+ nextNum +
'">';
790 splitTemplate +=
'<td class="right bold"><?php echo $langs->trans('AmountTTC
'); ?> '+ nextNum +
':</td>';
791 splitTemplate +=
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['+ nextNum +
']" value="'+ parseFloat(newInputValue) +
'"></td>';
792 splitTemplate +=
'<td class="right delsplitline"><span class="fas fa-trash icon-delsplitline" data-splitline="'+ nextNum +
'" style="cursor:pointer;"></span></td>';
793 splitTemplate +=
'<td class="right"></td>';
794 splitTemplate +=
'</tr>';
795 $(
'#splitline-'+numlines).after(splitTemplate);
800 $(document).on(
'change',
'.splitinput',
function(){
805 $(document).on(
'click',
'.icon-delsplitline',
function(){
806 let num = parseInt($(
this).data(
'splitline'));
807 let numBefore = num - 1;
809 $(
'#splitline-'+numBefore).find(
'.delsplitline').html(
'<span class="fas fa-trash icon-delsplitline" data-splitline="'+ numBefore +
'"></span>');
811 $(
'#splitline-'+num).remove();
818 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
819 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
820 $formquestion = array(
821 'text' => $langs->trans(
'TypeAmountOfEachNewDiscount'),
822 0 => array(
'type' =>
'text',
'name' =>
'amount_ttc_1',
'label' => $langs->trans(
"AmountTTC").
' 1',
'value' => $amount1,
'size' =>
'5'),
823 1 => array(
'type' =>
'text',
'name' =>
'amount_ttc_2',
'label' => $langs->trans(
"AmountTTC").
' 2',
'value' => $amount2,
'size' =>
'5')
825 $langs->load(
"dict");
826 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);
836 $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());
838 print
'<div class="fichehalfright fichehalfright-lg">';
839 print
load_fiche_titre($langs->trans(
"SupplierDiscounts"), $newcardbutton,
'');
845 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
846 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
847 $sql .=
" rc.datec as dc, rc.description,";
848 $sql .=
" rc.fk_invoice_supplier_source,";
849 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
850 $sql .=
" fa.ref, fa.type as type";
851 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
852 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
853 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
854 $sql .=
" AND rc.entity = ".((int) $conf->entity);
855 $sql .=
" AND u.rowid = rc.fk_user";
856 $sql .=
" AND rc.discount_type = 1";
857 $sql .=
" AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)";
858 $sql .=
" ORDER BY rc.datec DESC";
860 $resql = $db->query($sql);
862 print
'<div class="div-table-responsive-no-min">';
863 print
'<table class="noborder centpercent">';
864 print
'<tr class="liste_titre">';
865 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
866 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
867 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
868 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
870 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
872 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
873 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
875 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
877 print
'<td width="100" class="center">'.$langs->trans(
"DiscountOfferedBy").
'</td>';
878 print
'<td width="50"> </td>';
881 $showconfirminfo = array();
884 $num = $db->num_rows($resql);
887 $obj = $db->fetch_object($resql);
889 $tmpuser->id = $obj->user_id;
890 $tmpuser->login = $obj->login;
891 $tmpuser->firstname = $obj->firstname;
892 $tmpuser->lastname = $obj->lastname;
893 $tmpuser->photo = $obj->photo;
894 $tmpuser->status = $obj->status;
896 print
'<tr class="oddeven">';
897 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour',
'tzuserrel').
'</td>';
898 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
899 print
'<td class="tdoverflowmax100">';
900 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
901 $facturefournstatic->ref = $obj->ref;
902 $facturefournstatic->type = $obj->type;
903 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
905 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
906 print
'<td class="tdoverflowmax100">';
907 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
908 $facturefournstatic->ref = $obj->ref;
909 $facturefournstatic->type = $obj->type;
910 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
912 } elseif (preg_match(
'/\(EXCESS PAID\)/', $obj->description)) {
913 print
'<td class="tdoverflowmax100">';
914 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
915 $facturefournstatic->ref = $obj->ref;
916 $facturefournstatic->type = $obj->type;
917 print preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
920 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
924 print
'<td class="nowrap"><span class="opacitymedium">'.$langs->trans(
"NotConsumed").
'</span></td>';
925 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
927 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
929 print
'<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
930 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
932 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
934 print
'<td class="tdoverflowmax100">';
935 print $tmpuser->getNomUrl(-1);
938 if ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer')) {
939 print
'<td class="center nowraponall">';
940 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>';
941 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>';
944 print
'<td> </td>';
948 if ($action ==
'split' &&
GETPOST(
'remid') == $obj->rowid) {
949 $showconfirminfo[
'rowid'] = $obj->rowid;
950 $showconfirminfo[
'amount_ttc'] = $obj->amount_ttc;
959 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
965 if (count($showconfirminfo)) {
967 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].
'" id="formsplit" data-totaltosplit="'.$showconfirminfo[
'amount_ttc'].
'" data-remaintosplit="0">';
970 print
'<input type="hidden" name="action" value="confirm_split_more">';
971 print
'<input type="hidden" name="token" value="'.newToken().
'">';
973 print
'<div class="div-table-responsive-no-min">';
974 print
'<table class="valid centpercent">';
978 print
'<tr class="validtitre">';
979 print
'<td class="validtitre" colspan="4">'.img_picto(
'',
'split',
'', 0, 0, 0,
'',
'paddingright').
' '.$langs->trans(
'SplitDiscountTitle').
'</td>';
982 print
'<tr class="valid">';
983 print
'<td class="" colspan="4">'.$langs->trans(
'TypeAmountOfEachNewDiscountSplit').
'</td>';
987 if (empty($splitamounts)) {
988 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
989 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
990 $remaintosplit = (float) $showconfirminfo[
'amount_ttc'] - ((
float) $amount1 + (float) $amount2);
992 print
'<tr class="valid splitline" id="splitline-1">';
993 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 1:</td>';
994 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[1]" value="'.$amount1.
'"></td>';
995 print
'<td class="right delsplitline"></td>';
996 print
'<td class="right"></td>';
999 print
'<tr class="valid splitline" id="splitline-2">';
1000 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 2:</td>';
1001 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[2]" value="'.$amount2.
'"></td>';
1002 print
'<td class="right delsplitline"></td>';
1003 print
'<td class="right"></td>';
1006 $nbSplitLines = count($splitamounts);
1007 $remaintosplit = $showconfirminfo[
'amount_ttc'];
1008 foreach ($splitamounts as $numero => $value) {
1009 $remaintosplit -= (float) $value;
1010 print
'<tr class="valid splitline" id="splitline-'.$numero.
'">';
1011 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' '.$numero.
':</td>';
1012 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['.$numero.
']" value="'.$splitamounts[$numero].
'"></td>';
1013 print
'<td class="right delsplitline"></td>';
1014 print
'<td class="right"></td>';
1019 print
'<tr class="valid">';
1020 print
'<td class="right"></td>';
1021 print
'<td class="right"><span class="fas fa-plus-circle" id="splitaddline" style="cursor:pointer;"></span></td>';
1022 print
'<td class="right"></td>';
1025 print
'<tr class="valid">';
1026 print
'<td colspan="3"> </td>';
1030 print
'<tr class="valid">';
1031 print
'<td class="right bold">'.$langs->trans(
'RemainToSplit').
':</td>';
1032 print
'<td class="right"><span id="remaintosplit">'.price($remaintosplit).
'</span> '.$conf->currency.
'</td>';
1033 print
'<td class="right"></td>';
1036 print
'<tr class="valid">';
1037 print
'<td class="right bold"></td>';
1038 print
'<td class="right"><input type="submit" class="button valignmiddle confirmvalidatebutton small nomarginright"></td>';
1039 print
'<td class="right"></td>';
1048 <script nonce=
"<?php print getNonce(); ?>" type=
"text/javascript">
1049 $(document).ready(
function () {
1051 let formsplit = $(
'#formsplit');
1052 let totaltosplit = formsplit.data(
'totaltosplit');
1054 function calcRemainToPay(){
1055 let items = formsplit.find(
'.splitinput');
1056 let remaintosplit = totaltosplit;
1058 items.each(
function(e){
1059 var itemvalue = parseFloat($(
this).val().replace(
',',
'.'));
1060 if (isNaN(itemvalue)) {
1063 remaintosplit -= itemvalue;
1066 let remaintosplitval = remaintosplit.toFixed(2);
1067 console.log(remaintosplitval);
1068 formsplit.data(
'remaintosplit', remaintosplitval);
1069 formsplit.find(
'#remaintosplit').html(remaintosplitval.replace(
'.',
','));
1070 formsplit.find(
'input[type=submit]').prop(
'disabled',
true);
1071 if (remaintosplit == 0) {
1072 formsplit.find(
'input[type=submit]').prop(
'disabled',
false);
1077 $(document).on(
'click',
'#splitaddline',
function(){
1078 let splitlines = formsplit.find(
'.splitline');
1079 let numlines = splitlines.length;
1080 let nextNum = numlines + 1;
1081 let newInputValue = formsplit.data(
'remaintosplit');
1082 $(
'#splitline-'+numlines).find(
'.delsplitline').html(
'');
1083 var splitTemplate =
'<tr class="splitline" id="splitline-'+ nextNum +
'">';
1084 splitTemplate +=
'<td class="right bold"><?php echo $langs->trans('AmountTTC
'); ?> '+ nextNum +
':</td>';
1085 splitTemplate +=
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['+ nextNum +
']" value="'+ parseFloat(newInputValue) +
'"></td>';
1086 splitTemplate +=
'<td class="right delsplitline"><span class="fas fa-trash icon-delsplitline" data-splitline="'+ nextNum +
'" style="cursor:pointer;"></span></td>';
1087 splitTemplate +=
'<td class="right"></td>';
1088 splitTemplate +=
'</tr>';
1089 $(
'#splitline-'+numlines).after(splitTemplate);
1094 $(document).on(
'change',
'.splitinput',
function(){
1099 $(document).on(
'click',
'.icon-delsplitline',
function(){
1100 let num = parseInt($(
this).data(
'splitline'));
1101 let numBefore = num - 1;
1102 if (numBefore > 2) {
1103 $(
'#splitline-'+numBefore).find(
'.delsplitline').html(
'<span class="fas fa-trash icon-delsplitline" data-splitline="'+ numBefore +
'"></span>');
1105 $(
'#splitline-'+num).remove();
1112 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
1113 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
1114 $formquestion = array(
1115 'text' => $langs->trans(
'TypeAmountOfEachNewDiscount'),
1116 0 => array(
'type' =>
'text',
'name' =>
'amount_ttc_1',
'label' => $langs->trans(
"AmountTTC").
' 1',
'value' => $amount1,
'size' =>
'5'),
1117 1 => array(
'type' =>
'text',
'name' =>
'amount_ttc_2',
'label' => $langs->trans(
"AmountTTC").
' 2',
'value' => $amount2,
'size' =>
'5')
1119 $langs->load(
"dict");
1120 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);
1133 print
'<div class="clearboth"></div><br><br>';
1143 print
'<div class="fichecenter">';
1144 print
'<div class="fichehalfleft fichehalfleft-lg">';
1149 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1150 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1151 $sql .=
" rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,";
1152 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1153 $sql .=
" f.rowid as invoiceid, f.ref,";
1154 $sql .=
" fa.ref as invoice_source_ref, fa.type as type";
1155 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
1156 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
1157 $sql .=
" , ".MAIN_DB_PREFIX.
"facturedet as fc";
1158 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1159 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
1160 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1161 $sql .=
" AND rc.fk_facture_line = fc.rowid";
1162 $sql .=
" AND fc.fk_facture = f.rowid";
1163 $sql .=
" AND rc.fk_user = u.rowid";
1164 $sql .=
" AND rc.discount_type = 0";
1165 $sql .=
" ORDER BY dc DESC";
1168 $sql2 =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1169 $sql2 .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1170 $sql2 .=
" rc.datec as dc, rc.description, rc.fk_facture, rc.fk_facture_source,";
1171 $sql2 .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1172 $sql2 .=
" f.rowid as invoiceid, f.ref,";
1173 $sql2 .=
" fa.ref as invoice_source_ref, fa.type as type";
1174 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
1175 $sql2 .=
" , ".MAIN_DB_PREFIX.
"user as u";
1176 $sql2 .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1177 $sql2 .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
1178 $sql2 .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1179 $sql2 .=
" AND rc.fk_facture = f.rowid";
1180 $sql2 .=
" AND rc.fk_user = u.rowid";
1181 $sql2 .=
" AND rc.discount_type = 0";
1182 $sql2 .=
" ORDER BY dc DESC";
1184 $resql = $db->query($sql);
1187 $resql2 = $db->query($sql2);
1190 print
'<div class="div-table-responsive-no-min">';
1191 print
'<table class="noborder centpercent">';
1192 print
'<tr class="liste_titre">';
1193 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
1194 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
1195 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
1196 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
1198 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
1200 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
1201 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
1203 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
1205 print
'<td width="100" class="center">'.$langs->trans(
"Author").
'</td>';
1206 print
'<td width="50"> </td>';
1209 $tab_sqlobj = array();
1210 $tab_sqlobjOrder = array();
1211 $num = $db->num_rows($resql);
1213 for ($i = 0; $i < $num; $i++) {
1214 $sqlobj = $db->fetch_object($resql);
1215 $tab_sqlobj[] = $sqlobj;
1216 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1221 $num = $db->num_rows($resql2);
1222 for ($i = 0; $i < $num; $i++) {
1223 $sqlobj = $db->fetch_object($resql2);
1224 $tab_sqlobj[] = $sqlobj;
1225 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1228 $array1_sort_order = SORT_DESC;
1229 array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj);
1231 $num = count($tab_sqlobj);
1235 $obj = array_shift($tab_sqlobj);
1237 $tmpuser->id = $obj->user_id;
1238 $tmpuser->login = $obj->login;
1239 $tmpuser->firstname = $obj->firstname;
1240 $tmpuser->lastname = $obj->lastname;
1241 $tmpuser->photo = $obj->photo;
1242 $tmpuser->status = $obj->status;
1244 print
'<tr class="oddeven">';
1245 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour').
'</td>';
1246 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
1247 print
'<td class="tdoverflowmax100">';
1248 $facturestatic->id = $obj->fk_facture_source;
1249 $facturestatic->ref = $obj->invoice_source_ref;
1250 $facturestatic->type = $obj->type;
1251 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1253 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
1254 print
'<td class="tdoverflowmax100">';
1255 $facturestatic->id = $obj->fk_facture_source;
1256 $facturestatic->ref = $obj->invoice_source_ref;
1257 $facturestatic->type = $obj->type;
1258 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1260 } elseif (preg_match(
'/\(EXCESS RECEIVED\)/', $obj->description)) {
1261 print
'<td class="tdoverflowmax100">';
1262 $facturestatic->id = $obj->fk_facture_source;
1263 $facturestatic->ref = $obj->invoice_source_ref;
1264 $facturestatic->type = $obj->type;
1265 print preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"Invoice"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1268 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
1272 print
'<td class="left nowrap">';
1273 if ($obj->invoiceid) {
1274 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->invoiceid.
'">'.
img_object($langs->trans(
"ShowBill"),
'bill').
' '.$obj->ref.
'</a>';
1277 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
1279 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
1281 print
'<td class="right nowraponall">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
1282 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
1284 print
'<td class="right">'.price($obj->multicurrency_amount_ttc).
'</td>';
1286 print
'<td class="tdoverflowmax100">';
1287 print $tmpuser->getNomUrl(-1);
1290 print
'<td> </td>';
1299 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1312 print
'<div class="fichehalfright fichehalfright-lg">';
1317 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1318 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1319 $sql .=
" rc.datec as dc, rc.description, rc.fk_invoice_supplier_line,";
1320 $sql .=
" rc.fk_invoice_supplier_source,";
1321 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1322 $sql .=
" f.rowid as invoiceid, f.ref as ref,";
1323 $sql .=
" fa.ref as invoice_source_ref, fa.type as type";
1324 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
1325 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
1326 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn_det as fc";
1327 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1328 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
1329 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1330 $sql .=
" AND rc.fk_invoice_supplier_line = fc.rowid";
1331 $sql .=
" AND fc.fk_facture_fourn = f.rowid";
1332 $sql .=
" AND rc.fk_user = u.rowid";
1333 $sql .=
" AND rc.discount_type = 1";
1334 $sql .=
" ORDER BY dc DESC";
1337 $sql2 =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1338 $sql2 .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1339 $sql2 .=
" rc.datec as dc, rc.description, rc.fk_invoice_supplier,";
1340 $sql2 .=
" rc.fk_invoice_supplier_source,";
1341 $sql2 .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1342 $sql2 .=
" f.rowid as invoiceid, f.ref as ref,";
1343 $sql2 .=
" fa.ref as invoice_source_ref, fa.type as type";
1344 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
1345 $sql2 .=
" , ".MAIN_DB_PREFIX.
"user as u";
1346 $sql2 .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1347 $sql2 .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
1348 $sql2 .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1349 $sql2 .=
" AND rc.fk_invoice_supplier = f.rowid";
1350 $sql2 .=
" AND rc.fk_user = u.rowid";
1351 $sql2 .=
" AND rc.discount_type = 1";
1352 $sql2 .=
" ORDER BY dc DESC";
1354 $resql = $db->query($sql);
1357 $resql2 = $db->query($sql2);
1360 print
'<div class="div-table-responsive-no-min">';
1361 print
'<table class="noborder centpercent">';
1362 print
'<tr class="liste_titre">';
1363 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
1364 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
1365 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
1366 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
1368 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
1370 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
1371 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
1373 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
1375 print
'<td width="100" class="center">'.$langs->trans(
"Author").
'</td>';
1376 print
'<td width="50"> </td>';
1379 $tab_sqlobj = array();
1380 $tab_sqlobjOrder = array();
1381 $num = $db->num_rows($resql);
1383 for ($i = 0; $i < $num; $i++) {
1384 $sqlobj = $db->fetch_object($resql);
1385 $tab_sqlobj[] = $sqlobj;
1386 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1391 $num = $db->num_rows($resql2);
1392 for ($i = 0; $i < $num; $i++) {
1393 $sqlobj = $db->fetch_object($resql2);
1394 $tab_sqlobj[] = $sqlobj;
1395 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1398 $array1_sort_order = SORT_DESC;
1399 array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj);
1401 $num = count($tab_sqlobj);
1405 $obj = array_shift($tab_sqlobj);
1407 $tmpuser->id = $obj->user_id;
1408 $tmpuser->login = $obj->login;
1409 $tmpuser->firstname = $obj->firstname;
1410 $tmpuser->lastname = $obj->lastname;
1411 $tmpuser->photo = $obj->photo;
1412 $tmpuser->status = $obj->status;
1414 print
'<tr class="oddeven">';
1415 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour').
'</td>';
1416 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
1417 print
'<td class="tdoverflowmax100">';
1418 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1419 $facturefournstatic->ref = $obj->invoice_source_ref;
1420 $facturefournstatic->type = $obj->type;
1421 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1423 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
1424 print
'<td class="tdoverflowmax100">';
1425 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1426 $facturefournstatic->ref = $obj->invoice_source_ref;
1427 $facturefournstatic->type = $obj->type;
1428 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1430 } elseif (preg_match(
'/\(EXCESS PAID\)/', $obj->description)) {
1431 print
'<td class="tdoverflowmax100">';
1432 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1433 $facturefournstatic->ref = $obj->invoice_source_ref;
1434 $facturefournstatic->type = $obj->type;
1435 print preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"Invoice"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1438 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
1442 print
'<td class="left nowrap">';
1443 if ($obj->invoiceid) {
1444 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$obj->invoiceid.
'">'.
img_object($langs->trans(
"ShowBill"),
'bill').
' '.$obj->ref.
'</a>';
1447 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
1449 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
1451 print
'<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
1452 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
1454 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
1456 print
'<td class="tdoverflowmax100">';
1457 print $tmpuser->getNomUrl(-1);
1460 print
'<td> </td>';
1470 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)
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
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'.
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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, $mode=0)
Check permissions of a user to show a page and an object.