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');
91 if (empty($splitamounts)) {
93 setEventMessages($langs->trans(
"TotalOfDiscountMustEqualsOriginal"),
null,
'errors');
97 foreach ($splitamounts as $key => $value) {
98 $totalsplitted += (float) $value;
100 if ($totalsplitted != (
float) $discount->amount_ttc) {
102 setEventMessages($langs->trans(
"TotalOfDiscountMustEqualsOriginal"),
null,
'errors');
109 foreach ($splitamounts as $key => $value) {
110 if ((
float) $value == 0) {
115 $newdiscount->fk_facture_source = $discount->fk_facture_source;
116 $newdiscount->fk_facture = $discount->fk_facture;
117 $newdiscount->fk_facture_line = $discount->fk_facture_line;
118 $newdiscount->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
119 $newdiscount->fk_invoice_supplier = $discount->fk_invoice_supplier;
120 $newdiscount->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
121 if ($discount->description ==
'(CREDIT_NOTE)' || $discount->description ==
'(DEPOSIT)') {
122 $newdiscount->description = $discount->description;
124 $newdiscount->description = $discount->description.
' (1)';
126 $newdiscount->fk_user = $discount->fk_user;
127 $newdiscount->fk_soc = $discount->fk_soc;
128 $newdiscount->socid = $discount->socid;
129 $newdiscount->discount_type = $discount->discount_type;
130 $newdiscount->datec = $discount->datec;
131 $newdiscount->tva_tx = $discount->tva_tx;
132 $newdiscount->vat_src_code = $discount->vat_src_code;
133 $newdiscount->amount_ttc =
price2num($value);
134 $newdiscount->amount_ht =
price2num($newdiscount->amount_ttc / (1 + $newdiscount->tva_tx / 100),
'MT');
135 $newdiscount->amount_tva =
price2num($newdiscount->amount_ttc - $newdiscount->amount_ht);
136 $newdiscount->multicurrency_amount_ttc = (float) $value * ($discount->multicurrency_amount_ttc / $discount->amount_ttc);
137 $newdiscount->multicurrency_amount_ht =
price2num($newdiscount->multicurrency_amount_ttc / (1 + $newdiscount->tva_tx / 100),
'MT');
138 $newdiscount->multicurrency_amount_tva =
price2num($newdiscount->multicurrency_amount_ttc - $newdiscount->multicurrency_amount_ht);
140 $newdiscountID = $newdiscount->create($user);
141 if (!$newdiscountID) {
147 $discount->fk_facture_source = 0;
148 $discount->fk_invoice_supplier_source = 0;
149 $res = $discount->delete($user);
152 $query = [
'id' =>
$id,
'backtopage' => $backtopage];
153 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], $query));
164if ($action ==
'confirm_split' &&
GETPOST(
"confirm",
"alpha") ==
'yes' && $permissiontocreate) {
165 $amount_ttc_1 =
GETPOST(
'amount_ttc_1',
'alpha');
166 $amount_ttc_1 =
price2num($amount_ttc_1);
167 $amount_ttc_2 =
GETPOST(
'amount_ttc_2',
'alpha');
168 $amount_ttc_2 =
price2num($amount_ttc_2);
173 $res = $discount->fetch($remid);
176 setEventMessages($langs->trans(
"ErrorFailedToLoadDiscount"),
null,
'errors');
178 if (!$error &&
price2num((
float) $amount_ttc_1 + (
float) $amount_ttc_2,
'MT') != $discount->amount_ttc) {
180 setEventMessages($langs->trans(
"TotalOfTwoDiscountMustEqualsOriginal"),
null,
'errors');
182 if (!$error && $discount->fk_facture_line) {
184 setEventMessages($langs->trans(
"ErrorCantSplitAUsedDiscount"),
null,
'errors');
189 $newdiscount1->fk_facture_source = $discount->fk_facture_source;
190 $newdiscount2->fk_facture_source = $discount->fk_facture_source;
191 $newdiscount1->fk_facture = $discount->fk_facture;
192 $newdiscount2->fk_facture = $discount->fk_facture;
193 $newdiscount1->fk_facture_line = $discount->fk_facture_line;
194 $newdiscount2->fk_facture_line = $discount->fk_facture_line;
195 $newdiscount1->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
196 $newdiscount2->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source;
197 $newdiscount1->fk_invoice_supplier = $discount->fk_invoice_supplier;
198 $newdiscount2->fk_invoice_supplier = $discount->fk_invoice_supplier;
199 $newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
200 $newdiscount2->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
201 if ($discount->description ==
'(CREDIT_NOTE)' || $discount->description ==
'(DEPOSIT)') {
202 $newdiscount1->description = $discount->description;
203 $newdiscount2->description = $discount->description;
205 $newdiscount1->description = $discount->description.
' (1)';
206 $newdiscount2->description = $discount->description.
' (2)';
209 $newdiscount1->fk_user = $discount->fk_user;
210 $newdiscount2->fk_user = $discount->fk_user;
211 $newdiscount1->fk_soc = $discount->fk_soc;
212 $newdiscount1->socid = $discount->socid;
213 $newdiscount2->fk_soc = $discount->fk_soc;
214 $newdiscount2->socid = $discount->socid;
215 $newdiscount1->discount_type = $discount->discount_type;
216 $newdiscount2->discount_type = $discount->discount_type;
217 $newdiscount1->datec = $discount->datec;
218 $newdiscount2->datec = $discount->datec;
219 $newdiscount1->tva_tx = $discount->tva_tx;
220 $newdiscount2->tva_tx = $discount->tva_tx;
221 $newdiscount1->vat_src_code = $discount->vat_src_code;
222 $newdiscount2->vat_src_code = $discount->vat_src_code;
223 $newdiscount1->amount_ttc = $amount_ttc_1;
224 $newdiscount2->amount_ttc =
price2num($discount->amount_ttc - $newdiscount1->amount_ttc);
225 $newdiscount1->amount_ht =
price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100),
'MT');
226 $newdiscount2->amount_ht =
price2num($newdiscount2->amount_ttc / (1 + $newdiscount2->tva_tx / 100),
'MT');
227 $newdiscount1->amount_tva =
price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht);
228 $newdiscount2->amount_tva =
price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht);
230 $newdiscount1->multicurrency_amount_ttc = (float) $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc);
231 $newdiscount2->multicurrency_amount_ttc =
price2num($discount->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ttc);
232 $newdiscount1->multicurrency_amount_ht =
price2num($newdiscount1->multicurrency_amount_ttc / (1 + $newdiscount1->tva_tx / 100),
'MT');
233 $newdiscount2->multicurrency_amount_ht =
price2num($newdiscount2->multicurrency_amount_ttc / (1 + $newdiscount2->tva_tx / 100),
'MT');
234 $newdiscount1->multicurrency_amount_tva =
price2num($newdiscount1->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ht);
235 $newdiscount2->multicurrency_amount_tva =
price2num($newdiscount2->multicurrency_amount_ttc - $newdiscount2->multicurrency_amount_ht);
239 $discount->fk_facture_source = 0;
241 $discount->fk_invoice_supplier_source = 0;
242 $res = $discount->delete($user);
243 $newid1 = $newdiscount1->create($user);
244 $newid2 = $newdiscount2->create($user);
245 if ($res > 0 && $newid1 > 0 && $newid2 > 0) {
247 $query = [
'id' =>
$id,
'backtopage' => $backtopage];
248 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], $query));
256if ($action ==
'setremise' && $permissiontocreate) {
258 $desc =
GETPOST(
'desc',
'alpha');
259 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
260 $discount_type = GETPOSTISSET(
'discount_type') ?
GETPOST(
'discount_type',
'alpha') : 0;
261 $price_base_type =
GETPOST(
'price_base_type',
'alpha');
266 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReasonDiscount")),
null,
'errors');
273 $discountid = $soc->set_remise_except((
float) $amount, $user, $desc, $tva_tx, $discount_type, $price_base_type);
275 if ($discountid > 0) {
276 if (!empty($backtopage)) {
277 header(
"Location: ".$backtopage.
'&discountid='.((
int) $discountid));
280 header(
"Location: remx.php?id=".((
int) $id));
289 setEventMessages($langs->trans(
"ErrorFieldFormat", $langs->transnoentitiesnoconv(
"AmountHT")),
null,
'errors');
293if (
GETPOST(
'action',
'aZ09') ==
'confirm_remove' &&
GETPOST(
"confirm") ==
'yes' && $permissiontocreate) {
297 $result = $discount->fetch(
GETPOSTINT(
"remid"));
298 $result = $discount->delete($user);
301 header(
"Location: " .
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
314$form =
new Form($db);
315$facturestatic =
new Facture($db);
317$tmpuser =
new User($db);
319llxHeader(
'', $langs->trans(
"GlobalDiscount"));
327 $isSupplier =
$object->fournisseur == 1;
333 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
334 print
'<input type="hidden" name="token" value="'.newToken().
'">';
335 print
'<input type="hidden" name="action" value="setremise">';
336 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
338 print
dol_get_fiche_head($head,
'absolutediscount', $langs->trans(
"ThirdParty"), -1,
'company');
340 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
342 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
344 print
'<div class="fichecenter">';
346 print
'<div class="underbanner clearboth"></div>';
348 if (!$isCustomer && !$isSupplier) {
349 print
'<p class="opacitymedium">'.$langs->trans(
'ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').
'</p>';
361 print
'<div class="div-table-responsive-no-min">';
362 print
'<table class="border centpercent tableforfield borderbottom">';
365 $remise_all = $remise_user = 0;
366 $sql =
"SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
367 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
368 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
369 $sql .=
" AND rc.entity = ".((int) $conf->entity);
370 $sql .=
" AND discount_type = 0";
371 $sql .=
" AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
372 $sql .=
" GROUP BY rc.fk_user";
373 $resql = $db->query($sql);
375 while ($obj = $db->fetch_object($resql)) {
376 $remise_all += (!empty($obj->amount) ? $obj->amount : 0);
377 if (!empty($obj->fk_user) && $obj->fk_user == $user->id) {
378 $remise_user += (!empty($obj->amount) ? $obj->amount : 0);
385 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"CustomerAbsoluteDiscountAllUsers").
'</td>';
386 print
'<td class="amount">'.price($remise_all, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT");
387 if (empty($user->fk_soc)) {
388 print $form->textwithpicto(
'', $langs->trans(
"CustomerAbsoluteDiscountMy").
': '.
price($remise_user, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT"));
395 $remise_all = $remise_user = 0;
396 $sql =
"SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
397 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
398 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
399 $sql .=
" AND rc.entity = ".((int) $conf->entity);
400 $sql .=
" AND discount_type = 1";
401 $sql .=
" AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)";
402 $sql .=
" GROUP BY rc.fk_user";
403 $resql = $db->query($sql);
405 while ($obj = $db->fetch_object($resql)) {
406 $remise_all += (!empty($obj->amount) ? $obj->amount : 0);
407 if (!empty($obj->fk_user) && $obj->fk_user == $user->id) {
408 $remise_user += (!empty($obj->amount) ? $obj->amount : 0);
415 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"SupplierAbsoluteDiscountAllUsers").
'</td>';
416 print
'<td class="amount">'.price($remise_all, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT");
417 if (empty($user->fk_soc)) {
418 print $form->textwithpicto(
'', $langs->trans(
"SupplierAbsoluteDiscountMy").
' : '.
price($remise_user, 1, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT"));
431 if ($action ==
'create_remise') {
432 if ($user->hasRight(
'societe',
'creer')) {
435 $discount_type = GETPOSTISSET(
'discount_type') ?
GETPOST(
'discount_type',
'alpha') : 0;
436 if ($isCustomer && $isSupplier) {
437 $discounttypelabel = $discount_type == 1 ?
'NewSupplierGlobalDiscount' :
'NewClientGlobalDiscount';
439 $discounttypelabel =
'NewGlobalDiscount';
444 if ($isSupplier && $discount_type == 1) {
445 print
'<input type="hidden" name="discount_type" value="1" />';
447 print
'<input type="hidden" name="discount_type" value="0" />';
453 print
'<div class="div-table-responsive-no-min">';
454 print
'<table class="border centpercent">';
463 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Amount").
'</td>';
464 print
'<td><input type="text" size="5" name="amount" value="'.price2num(
GETPOST(
"amount")).
'" autofocus>';
465 print
'<span class="hideonsmartphone"> '.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
468 print
'<tr><td class="titlefield">'.$langs->trans(
"PriceBase").
'</td>';
470 print $form->selectPriceBaseType(
GETPOST(
"price_base_type"),
"price_base_type");
474 print
'<tr><td>'.$langs->trans(
"VAT").
'</td>';
476 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);
478 print
'<tr><td class="fieldrequired" >'.$langs->trans(
"NoteReason").
'</td>';
479 print
'<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST(
'desc',
'alphanohtml').
'"></td></tr>';
487 if ($user->hasRight(
'societe',
'creer')) {
488 print
'<div class="center">';
489 print
'<input type="submit" class="button" name="submit" value="'.$langs->trans(
"AddGlobalDiscount").
'">';
490 if (!empty($backtopage)) {
491 print
' ';
492 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
504 if ($action ==
'remove') {
505 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&remid='.
GETPOST(
'remid'), $langs->trans(
'RemoveDiscount'), $langs->trans(
'ConfirmRemoveDiscount'),
'confirm_remove',
'', 0, 1);
513 if ($isCustomer && !$isSupplier) {
514 $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());
515 } elseif (!$isCustomer && $isSupplier) {
516 $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());
521 print
load_fiche_titre($langs->trans(
"DiscountStillRemaining"), $newcardbutton);
524 $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());
526 print
'<div class="fichecenter">';
527 print
'<div class="fichehalfleft fichehalfleft-lg">';
528 print
load_fiche_titre($langs->trans(
"CustomerDiscounts"), $newcardbutton,
'');
531 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
532 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
533 $sql .=
" rc.datec as dc, rc.description,";
534 $sql .=
" rc.fk_facture_source,";
535 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
536 $sql .=
" fa.ref as ref, fa.type as type";
537 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
538 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
539 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
540 $sql .=
" AND rc.entity = ".((int) $conf->entity);
541 $sql .=
" AND u.rowid = rc.fk_user";
542 $sql .=
" AND rc.discount_type = 0";
543 $sql .=
" AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)";
544 $sql .=
" ORDER BY rc.datec DESC";
546 $resql = $db->query($sql);
548 print
'<div class="div-table-responsive-no-min">';
549 print
'<table class="noborder centpercent">';
550 print
'<tr class="liste_titre">';
551 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
552 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
553 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
554 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
556 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
558 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
559 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
561 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
563 print
'<td width="100" class="center">'.$langs->trans(
"DiscountOfferedBy").
'</td>';
564 print
'<td width="50"> </td>';
567 $showconfirminfo = array();
570 $num = $db->num_rows($resql);
573 $obj = $db->fetch_object($resql);
575 $tmpuser->id = $obj->user_id;
576 $tmpuser->login = $obj->login;
577 $tmpuser->firstname = $obj->firstname;
578 $tmpuser->lastname = $obj->lastname;
579 $tmpuser->photo = $obj->photo;
580 $tmpuser->status = $obj->status;
582 print
'<tr class="oddeven">';
584 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour',
'tzuserrel').
'</td>';
586 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
587 print
'<td class="tdoverflowmax100">';
588 $facturestatic->id = $obj->fk_facture_source;
589 $facturestatic->ref = $obj->ref;
590 $facturestatic->type = $obj->type;
591 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
593 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
594 print
'<td class="tdoverflowmax100">';
595 $facturestatic->id = $obj->fk_facture_source;
596 $facturestatic->ref = $obj->ref;
597 $facturestatic->type = $obj->type;
598 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
600 } elseif (preg_match(
'/\(EXCESS RECEIVED\)/', $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(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
608 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
613 print
'<td class="nowrap"><span class="opacitymedium">'.$langs->trans(
"NotConsumed").
'</span></td>';
615 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
618 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
620 print
'<td class="right nowraponall">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
621 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
623 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
625 print
'<td class="tdoverflowmax100">';
627 print $tmpuser->getNomUrl(-1);
630 if ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer')) {
631 print
'<td class="center nowraponall">';
632 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>';
633 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>';
636 print
'<td> </td>';
640 if ($action ==
'split' &&
GETPOST(
'remid') == $obj->rowid) {
641 $showconfirminfo[
'rowid'] = $obj->rowid;
642 $showconfirminfo[
'amount_ttc'] = $obj->amount_ttc;
651 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
657 if (count($showconfirminfo)) {
659 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].
'" id="formsplit" data-totaltosplit="'.$showconfirminfo[
'amount_ttc'].
'" data-remaintosplit="0">';
662 print
'<input type="hidden" name="action" value="confirm_split_more">';
663 print
'<input type="hidden" name="token" value="'.newToken().
'">';
665 print
'<div class="div-table-responsive-no-min">';
666 print
'<table class="valid centpercent">';
670 print
'<tr class="validtitre">';
671 print
'<td class="validtitre" colspan="4">'.img_picto(
'',
'split',
'', 0, 0, 0,
'',
'paddingright').
' '.$langs->trans(
'SplitDiscountTitle').
'</td>';
674 print
'<tr class="valid">';
675 print
'<td class="" colspan="4">'.$langs->trans(
'TypeAmountOfEachNewDiscountSplit').
'</td>';
679 if (empty($splitamounts)) {
680 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
681 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
682 $remaintosplit = (float) $showconfirminfo[
'amount_ttc'] - ((
float) $amount1 + (float) $amount2);
684 print
'<tr class="valid splitline" id="splitline-1">';
685 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 1:</td>';
686 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[1]" value="'.$amount1.
'"></td>';
687 print
'<td class="right delsplitline"></td>';
688 print
'<td class="right"></td>';
691 print
'<tr class="valid splitline" id="splitline-2">';
692 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 2:</td>';
693 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[2]" value="'.$amount2.
'"></td>';
694 print
'<td class="right delsplitline"></td>';
695 print
'<td class="right"></td>';
698 $nbSplitLines = count($splitamounts);
699 $remaintosplit = $showconfirminfo[
'amount_ttc'];
700 foreach ($splitamounts as $numero => $value) {
701 $remaintosplit -= (float) $value;
702 print
'<tr class="valid splitline" id="splitline-'.$numero.
'">';
703 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' '.$numero.
':</td>';
704 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['.$numero.
']" value="'.$splitamounts[$numero].
'"></td>';
705 print
'<td class="right delsplitline"></td>';
706 print
'<td class="right"></td>';
711 print
'<tr class="valid">';
712 print
'<td class="right"></td>';
713 print
'<td class="right"><span class="fas fa-plus-circle" id="splitaddline" style="cursor:pointer;"></span></td>';
714 print
'<td class="right"></td>';
717 print
'<tr class="valid">';
718 print
'<td colspan="3"> </td>';
722 print
'<tr class="valid">';
723 print
'<td class="right bold">'.$langs->trans(
'RemainToSplit').
':</td>';
724 print
'<td class="right"><span id="remaintosplit">'.price($remaintosplit).
'</span> '.$conf->currency.
'</td>';
725 print
'<td class="right"></td>';
728 print
'<tr class="valid">';
729 print
'<td class="right bold"></td>';
730 print
'<td class="right"><input type="submit" class="button valignmiddle confirmvalidatebutton small nomarginright"></td>';
731 print
'<td class="right"></td>';
740 <script nonce=
"<?php print getNonce(); ?>" type=
"text/javascript">
741 $(document).ready(
function () {
743 let formsplit = $(
'#formsplit');
744 let totaltosplit = formsplit.data(
'totaltosplit');
746 function calcRemainToPay(){
747 let items = formsplit.find(
'.splitinput');
748 let remaintosplit = totaltosplit;
750 items.each(
function(e){
751 var itemvalue = parseFloat($(
this).val().replace(
',',
'.'));
752 if (isNaN(itemvalue)) {
755 remaintosplit -= itemvalue;
758 let remaintosplitval = remaintosplit.toFixed(2);
759 console.log(remaintosplitval);
760 formsplit.data(
'remaintosplit', remaintosplitval);
761 formsplit.find(
'#remaintosplit').html(remaintosplitval.replace(
'.',
','));
762 formsplit.find(
'input[type=submit]').prop(
'disabled',
true);
763 if (remaintosplit == 0) {
764 formsplit.find(
'input[type=submit]').prop(
'disabled',
false);
769 $(document).on(
'click',
'#splitaddline',
function(){
770 let splitlines = formsplit.find(
'.splitline');
771 let numlines = splitlines.length;
772 let nextNum = numlines + 1;
773 let newInputValue = formsplit.data(
'remaintosplit');
774 $(
'#splitline-'+numlines).find(
'.delsplitline').html(
'');
775 var splitTemplate =
'<tr class="splitline" id="splitline-'+ nextNum +
'">';
776 splitTemplate +=
'<td class="right bold"><?php echo $langs->trans('AmountTTC
'); ?> '+ nextNum +
':</td>';
777 splitTemplate +=
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['+ nextNum +
']" value="'+ parseFloat(newInputValue) +
'"></td>';
778 splitTemplate +=
'<td class="right delsplitline"><span class="fas fa-trash icon-delsplitline" data-splitline="'+ nextNum +
'" style="cursor:pointer;"></span></td>';
779 splitTemplate +=
'<td class="right"></td>';
780 splitTemplate +=
'</tr>';
781 $(
'#splitline-'+numlines).after(splitTemplate);
786 $(document).on(
'change',
'.splitinput',
function(){
791 $(document).on(
'click',
'.icon-delsplitline',
function(){
792 let num = parseInt($(
this).data(
'splitline'));
793 let numBefore = num - 1;
795 $(
'#splitline-'+numBefore).find(
'.delsplitline').html(
'<span class="fas fa-trash icon-delsplitline" data-splitline="'+ numBefore +
'"></span>');
797 $(
'#splitline-'+num).remove();
804 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
805 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
806 $formquestion = array(
807 'text' => $langs->trans(
'TypeAmountOfEachNewDiscount'),
808 0 => array(
'type' =>
'text',
'name' =>
'amount_ttc_1',
'label' => $langs->trans(
"AmountTTC").
' 1',
'value' => $amount1,
'size' =>
'5'),
809 1 => array(
'type' =>
'text',
'name' =>
'amount_ttc_2',
'label' => $langs->trans(
"AmountTTC").
' 2',
'value' => $amount2,
'size' =>
'5')
811 $langs->load(
"dict");
812 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);
822 $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());
824 print
'<div class="fichehalfright fichehalfright-lg">';
825 print
load_fiche_titre($langs->trans(
"SupplierDiscounts"), $newcardbutton,
'');
831 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
832 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
833 $sql .=
" rc.datec as dc, rc.description,";
834 $sql .=
" rc.fk_invoice_supplier_source,";
835 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
836 $sql .=
" fa.ref, fa.type as type";
837 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
838 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
839 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
840 $sql .=
" AND rc.entity = ".((int) $conf->entity);
841 $sql .=
" AND u.rowid = rc.fk_user";
842 $sql .=
" AND rc.discount_type = 1";
843 $sql .=
" AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)";
844 $sql .=
" ORDER BY rc.datec DESC";
846 $resql = $db->query($sql);
848 print
'<div class="div-table-responsive-no-min">';
849 print
'<table class="noborder centpercent">';
850 print
'<tr class="liste_titre">';
851 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
852 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
853 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
854 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
856 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
858 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
859 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
861 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
863 print
'<td width="100" class="center">'.$langs->trans(
"DiscountOfferedBy").
'</td>';
864 print
'<td width="50"> </td>';
867 $showconfirminfo = array();
870 $num = $db->num_rows($resql);
873 $obj = $db->fetch_object($resql);
875 $tmpuser->id = $obj->user_id;
876 $tmpuser->login = $obj->login;
877 $tmpuser->firstname = $obj->firstname;
878 $tmpuser->lastname = $obj->lastname;
879 $tmpuser->photo = $obj->photo;
880 $tmpuser->status = $obj->status;
882 print
'<tr class="oddeven">';
883 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour',
'tzuserrel').
'</td>';
884 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
885 print
'<td class="tdoverflowmax100">';
886 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
887 $facturefournstatic->ref = $obj->ref;
888 $facturefournstatic->type = $obj->type;
889 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
891 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
892 print
'<td class="tdoverflowmax100">';
893 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
894 $facturefournstatic->ref = $obj->ref;
895 $facturefournstatic->type = $obj->type;
896 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
898 } elseif (preg_match(
'/\(EXCESS PAID\)/', $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(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
906 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
910 print
'<td class="nowrap"><span class="opacitymedium">'.$langs->trans(
"NotConsumed").
'</span></td>';
911 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
913 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
915 print
'<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
916 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
918 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
920 print
'<td class="tdoverflowmax100">';
921 print $tmpuser->getNomUrl(-1);
924 if ($user->hasRight(
'societe',
'creer') || $user->hasRight(
'facture',
'creer')) {
925 print
'<td class="center nowraponall">';
926 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>';
927 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>';
930 print
'<td> </td>';
934 if ($action ==
'split' &&
GETPOST(
'remid') == $obj->rowid) {
935 $showconfirminfo[
'rowid'] = $obj->rowid;
936 $showconfirminfo[
'amount_ttc'] = $obj->amount_ttc;
945 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
951 if (count($showconfirminfo)) {
953 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&remid='.$showconfirminfo[
'rowid'].
'" id="formsplit" data-totaltosplit="'.$showconfirminfo[
'amount_ttc'].
'" data-remaintosplit="0">';
956 print
'<input type="hidden" name="action" value="confirm_split_more">';
957 print
'<input type="hidden" name="token" value="'.newToken().
'">';
959 print
'<div class="div-table-responsive-no-min">';
960 print
'<table class="valid centpercent">';
964 print
'<tr class="validtitre">';
965 print
'<td class="validtitre" colspan="4">'.img_picto(
'',
'split',
'', 0, 0, 0,
'',
'paddingright').
' '.$langs->trans(
'SplitDiscountTitle').
'</td>';
968 print
'<tr class="valid">';
969 print
'<td class="" colspan="4">'.$langs->trans(
'TypeAmountOfEachNewDiscountSplit').
'</td>';
973 if (empty($splitamounts)) {
974 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
975 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
976 $remaintosplit = (float) $showconfirminfo[
'amount_ttc'] - ((
float) $amount1 + (float) $amount2);
978 print
'<tr class="valid splitline" id="splitline-1">';
979 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 1:</td>';
980 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[1]" value="'.$amount1.
'"></td>';
981 print
'<td class="right delsplitline"></td>';
982 print
'<td class="right"></td>';
985 print
'<tr class="valid splitline" id="splitline-2">';
986 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' 2:</td>';
987 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts[2]" value="'.$amount2.
'"></td>';
988 print
'<td class="right delsplitline"></td>';
989 print
'<td class="right"></td>';
992 $nbSplitLines = count($splitamounts);
993 $remaintosplit = $showconfirminfo[
'amount_ttc'];
994 foreach ($splitamounts as $numero => $value) {
995 $remaintosplit -= (float) $value;
996 print
'<tr class="valid splitline" id="splitline-'.$numero.
'">';
997 print
'<td class="right bold">'.$langs->trans(
'AmountTTC').
' '.$numero.
':</td>';
998 print
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['.$numero.
']" value="'.$splitamounts[$numero].
'"></td>';
999 print
'<td class="right delsplitline"></td>';
1000 print
'<td class="right"></td>';
1005 print
'<tr class="valid">';
1006 print
'<td class="right"></td>';
1007 print
'<td class="right"><span class="fas fa-plus-circle" id="splitaddline" style="cursor:pointer;"></span></td>';
1008 print
'<td class="right"></td>';
1011 print
'<tr class="valid">';
1012 print
'<td colspan="3"> </td>';
1016 print
'<tr class="valid">';
1017 print
'<td class="right bold">'.$langs->trans(
'RemainToSplit').
':</td>';
1018 print
'<td class="right"><span id="remaintosplit">'.price($remaintosplit).
'</span> '.$conf->currency.
'</td>';
1019 print
'<td class="right"></td>';
1022 print
'<tr class="valid">';
1023 print
'<td class="right bold"></td>';
1024 print
'<td class="right"><input type="submit" class="button valignmiddle confirmvalidatebutton small nomarginright"></td>';
1025 print
'<td class="right"></td>';
1034 <script nonce=
"<?php print getNonce(); ?>" type=
"text/javascript">
1035 $(document).ready(
function () {
1037 let formsplit = $(
'#formsplit');
1038 let totaltosplit = formsplit.data(
'totaltosplit');
1040 function calcRemainToPay(){
1041 let items = formsplit.find(
'.splitinput');
1042 let remaintosplit = totaltosplit;
1044 items.each(
function(e){
1045 var itemvalue = parseFloat($(
this).val().replace(
',',
'.'));
1046 if (isNaN(itemvalue)) {
1049 remaintosplit -= itemvalue;
1052 let remaintosplitval = remaintosplit.toFixed(2);
1053 console.log(remaintosplitval);
1054 formsplit.data(
'remaintosplit', remaintosplitval);
1055 formsplit.find(
'#remaintosplit').html(remaintosplitval.replace(
'.',
','));
1056 formsplit.find(
'input[type=submit]').prop(
'disabled',
true);
1057 if (remaintosplit == 0) {
1058 formsplit.find(
'input[type=submit]').prop(
'disabled',
false);
1063 $(document).on(
'click',
'#splitaddline',
function(){
1064 let splitlines = formsplit.find(
'.splitline');
1065 let numlines = splitlines.length;
1066 let nextNum = numlines + 1;
1067 let newInputValue = formsplit.data(
'remaintosplit');
1068 $(
'#splitline-'+numlines).find(
'.delsplitline').html(
'');
1069 var splitTemplate =
'<tr class="splitline" id="splitline-'+ nextNum +
'">';
1070 splitTemplate +=
'<td class="right bold"><?php echo $langs->trans('AmountTTC
'); ?> '+ nextNum +
':</td>';
1071 splitTemplate +=
'<td class="right"><input type="number" step="any" min="0" class="flat splitinput" name="splitamounts['+ nextNum +
']" value="'+ parseFloat(newInputValue) +
'"></td>';
1072 splitTemplate +=
'<td class="right delsplitline"><span class="fas fa-trash icon-delsplitline" data-splitline="'+ nextNum +
'" style="cursor:pointer;"></span></td>';
1073 splitTemplate +=
'<td class="right"></td>';
1074 splitTemplate +=
'</tr>';
1075 $(
'#splitline-'+numlines).after(splitTemplate);
1080 $(document).on(
'change',
'.splitinput',
function(){
1085 $(document).on(
'click',
'.icon-delsplitline',
function(){
1086 let num = parseInt($(
this).data(
'splitline'));
1087 let numBefore = num - 1;
1088 if (numBefore > 2) {
1089 $(
'#splitline-'+numBefore).find(
'.delsplitline').html(
'<span class="fas fa-trash icon-delsplitline" data-splitline="'+ numBefore +
'"></span>');
1091 $(
'#splitline-'+num).remove();
1098 $amount1 =
price2num($showconfirminfo[
'amount_ttc'] / 2,
'MT');
1099 $amount2 = ($showconfirminfo[
'amount_ttc'] - (float) $amount1);
1100 $formquestion = array(
1101 'text' => $langs->trans(
'TypeAmountOfEachNewDiscount'),
1102 0 => array(
'type' =>
'text',
'name' =>
'amount_ttc_1',
'label' => $langs->trans(
"AmountTTC").
' 1',
'value' => $amount1,
'size' =>
'5'),
1103 1 => array(
'type' =>
'text',
'name' =>
'amount_ttc_2',
'label' => $langs->trans(
"AmountTTC").
' 2',
'value' => $amount2,
'size' =>
'5')
1105 $langs->load(
"dict");
1106 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);
1119 print
'<div class="clearboth"></div><br><br>';
1129 print
'<div class="fichecenter">';
1130 print
'<div class="fichehalfleft fichehalfleft-lg">';
1135 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1136 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1137 $sql .=
" rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,";
1138 $sql .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1139 $sql .=
" f.rowid as invoiceid, f.ref,";
1140 $sql .=
" fa.ref as invoice_source_ref, fa.type as type";
1141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
1142 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
1143 $sql .=
" , ".MAIN_DB_PREFIX.
"facturedet as fc";
1144 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1145 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
1146 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1147 $sql .=
" AND rc.fk_facture_line = fc.rowid";
1148 $sql .=
" AND fc.fk_facture = f.rowid";
1149 $sql .=
" AND rc.fk_user = u.rowid";
1150 $sql .=
" AND rc.discount_type = 0";
1151 $sql .=
" ORDER BY dc DESC";
1154 $sql2 =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1155 $sql2 .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1156 $sql2 .=
" rc.datec as dc, rc.description, rc.fk_facture, rc.fk_facture_source,";
1157 $sql2 .=
" u.login, u.rowid as user_id, u.statut as status, u.firstname, u.lastname, u.photo,";
1158 $sql2 .=
" f.rowid as invoiceid, f.ref,";
1159 $sql2 .=
" fa.ref as invoice_source_ref, fa.type as type";
1160 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
1161 $sql2 .=
" , ".MAIN_DB_PREFIX.
"user as u";
1162 $sql2 .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1163 $sql2 .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as fa ON rc.fk_facture_source = fa.rowid";
1164 $sql2 .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1165 $sql2 .=
" AND rc.fk_facture = f.rowid";
1166 $sql2 .=
" AND rc.fk_user = u.rowid";
1167 $sql2 .=
" AND rc.discount_type = 0";
1168 $sql2 .=
" ORDER BY dc DESC";
1170 $resql = $db->query($sql);
1173 $resql2 = $db->query($sql2);
1176 print
'<div class="div-table-responsive-no-min">';
1177 print
'<table class="noborder centpercent">';
1178 print
'<tr class="liste_titre">';
1179 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
1180 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
1181 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
1182 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
1184 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
1186 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
1187 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
1189 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
1191 print
'<td width="100" class="center">'.$langs->trans(
"Author").
'</td>';
1192 print
'<td width="50"> </td>';
1195 $tab_sqlobj = array();
1196 $tab_sqlobjOrder = array();
1197 $num = $db->num_rows($resql);
1199 for ($i = 0; $i < $num; $i++) {
1200 $sqlobj = $db->fetch_object($resql);
1201 $tab_sqlobj[] = $sqlobj;
1202 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1207 $num = $db->num_rows($resql2);
1208 for ($i = 0; $i < $num; $i++) {
1209 $sqlobj = $db->fetch_object($resql2);
1210 $tab_sqlobj[] = $sqlobj;
1211 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1214 $array1_sort_order = SORT_DESC;
1215 array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj);
1217 $num = count($tab_sqlobj);
1221 $obj = array_shift($tab_sqlobj);
1223 $tmpuser->id = $obj->user_id;
1224 $tmpuser->login = $obj->login;
1225 $tmpuser->firstname = $obj->firstname;
1226 $tmpuser->lastname = $obj->lastname;
1227 $tmpuser->photo = $obj->photo;
1228 $tmpuser->status = $obj->status;
1230 print
'<tr class="oddeven">';
1231 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour').
'</td>';
1232 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
1233 print
'<td class="tdoverflowmax100">';
1234 $facturestatic->id = $obj->fk_facture_source;
1235 $facturestatic->ref = $obj->invoice_source_ref;
1236 $facturestatic->type = $obj->type;
1237 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1239 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
1240 print
'<td class="tdoverflowmax100">';
1241 $facturestatic->id = $obj->fk_facture_source;
1242 $facturestatic->ref = $obj->invoice_source_ref;
1243 $facturestatic->type = $obj->type;
1244 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1246 } elseif (preg_match(
'/\(EXCESS RECEIVED\)/', $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(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"Invoice"), $obj->description).
'<br>'.$facturestatic->getNomURl(1);
1254 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
1258 print
'<td class="left nowrap">';
1259 if ($obj->invoiceid) {
1260 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->invoiceid.
'">'.
img_object($langs->trans(
"ShowBill"),
'bill').
' '.$obj->ref.
'</a>';
1263 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
1265 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
1267 print
'<td class="right nowraponall">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
1268 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
1270 print
'<td class="right">'.price($obj->multicurrency_amount_ttc).
'</td>';
1272 print
'<td class="tdoverflowmax100">';
1273 print $tmpuser->getNomUrl(-1);
1276 print
'<td> </td>';
1285 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1298 print
'<div class="fichehalfright fichehalfright-lg">';
1303 $sql =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1304 $sql .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1305 $sql .=
" rc.datec as dc, rc.description, rc.fk_invoice_supplier_line,";
1306 $sql .=
" rc.fk_invoice_supplier_source,";
1307 $sql .=
" u.login, u.rowid as user_id, u.statut as user_status, u.firstname, u.lastname, u.photo,";
1308 $sql .=
" f.rowid as invoiceid, f.ref as ref,";
1309 $sql .=
" fa.ref as invoice_source_ref, fa.type as type";
1310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
1311 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
1312 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn_det as fc";
1313 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1314 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
1315 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1316 $sql .=
" AND rc.fk_invoice_supplier_line = fc.rowid";
1317 $sql .=
" AND fc.fk_facture_fourn = f.rowid";
1318 $sql .=
" AND rc.fk_user = u.rowid";
1319 $sql .=
" AND rc.discount_type = 1";
1320 $sql .=
" ORDER BY dc DESC";
1323 $sql2 =
"SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
1324 $sql2 .=
" rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
1325 $sql2 .=
" rc.datec as dc, rc.description, rc.fk_invoice_supplier,";
1326 $sql2 .=
" rc.fk_invoice_supplier_source,";
1327 $sql2 .=
" u.login, u.rowid as user_id, u.statut as user_status, u.firstname, u.lastname, u.photo,";
1328 $sql2 .=
" f.rowid as invoiceid, f.ref as ref,";
1329 $sql2 .=
" fa.ref as invoice_source_ref, fa.type as type";
1330 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
1331 $sql2 .=
" , ".MAIN_DB_PREFIX.
"user as u";
1332 $sql2 .=
" , ".MAIN_DB_PREFIX.
"societe_remise_except as rc";
1333 $sql2 .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
1334 $sql2 .=
" WHERE rc.fk_soc = ".((int)
$object->id);
1335 $sql2 .=
" AND rc.fk_invoice_supplier = f.rowid";
1336 $sql2 .=
" AND rc.fk_user = u.rowid";
1337 $sql2 .=
" AND rc.discount_type = 1";
1338 $sql2 .=
" ORDER BY dc DESC";
1340 $resql = $db->query($sql);
1343 $resql2 = $db->query($sql2);
1346 print
'<div class="div-table-responsive-no-min">';
1347 print
'<table class="noborder centpercent">';
1348 print
'<tr class="liste_titre">';
1349 print
'<td class="widthdate">'.$langs->trans(
"Date").
'</td>';
1350 print
'<td>'.$langs->trans(
"ReasonDiscount").
'</td>';
1351 print
'<td class="nowrap">'.$langs->trans(
"ConsumedBy").
'</td>';
1352 print
'<td class="right">'.$langs->trans(
"AmountHT").
'</td>';
1354 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountHT")).
'">'.$langs->trans(
"MulticurrencyAmountHT").
'</td>';
1356 print
'<td class="right">'.$langs->trans(
"VATRate").
'</td>';
1357 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
1359 print
'<td class="right tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"MulticurrencyAmountTTC")).
'">'.$langs->trans(
"MulticurrencyAmountTTC").
'</td>';
1361 print
'<td width="100" class="center">'.$langs->trans(
"Author").
'</td>';
1362 print
'<td width="50"> </td>';
1365 $tab_sqlobj = array();
1366 $tab_sqlobjOrder = array();
1367 $num = $db->num_rows($resql);
1369 for ($i = 0; $i < $num; $i++) {
1370 $sqlobj = $db->fetch_object($resql);
1371 $tab_sqlobj[] = $sqlobj;
1372 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1377 $num = $db->num_rows($resql2);
1378 for ($i = 0; $i < $num; $i++) {
1379 $sqlobj = $db->fetch_object($resql2);
1380 $tab_sqlobj[] = $sqlobj;
1381 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
1384 $array1_sort_order = SORT_DESC;
1385 array_multisort($tab_sqlobjOrder, $array1_sort_order, $tab_sqlobj);
1387 $num = count($tab_sqlobj);
1391 $obj = array_shift($tab_sqlobj);
1393 $tmpuser->id = $obj->user_id;
1394 $tmpuser->login = $obj->login;
1395 $tmpuser->firstname = $obj->firstname;
1396 $tmpuser->lastname = $obj->lastname;
1397 $tmpuser->photo = $obj->photo;
1398 $tmpuser->status = $obj->status;
1400 print
'<tr class="oddeven">';
1401 print
'<td>'.dol_print_date($db->jdate($obj->dc),
'dayhour').
'</td>';
1402 if (preg_match(
'/\(CREDIT_NOTE\)/', $obj->description)) {
1403 print
'<td class="tdoverflowmax100">';
1404 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1405 $facturefournstatic->ref = $obj->invoice_source_ref;
1406 $facturefournstatic->type = $obj->type;
1407 print preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1409 } elseif (preg_match(
'/\(DEPOSIT\)/', $obj->description)) {
1410 print
'<td class="tdoverflowmax100">';
1411 $facturefournstatic->id = $obj->fk_invoice_supplier_source;
1412 $facturefournstatic->ref = $obj->invoice_source_ref;
1413 $facturefournstatic->type = $obj->type;
1414 print preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"InvoiceDeposit"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1416 } elseif (preg_match(
'/\(EXCESS PAID\)/', $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(
'/\(EXCESS PAID\)/', $langs->trans(
"Invoice"), $obj->description).
'<br>'.$facturefournstatic->getNomURl(1);
1424 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->description).
'">';
1428 print
'<td class="left nowrap">';
1429 if ($obj->invoiceid) {
1430 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$obj->invoiceid.
'">'.
img_object($langs->trans(
"ShowBill"),
'bill').
' '.$obj->ref.
'</a>';
1433 print
'<td class="right nowraponall amount">'.price($obj->amount_ht).
'</td>';
1435 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ht).
'</td>';
1437 print
'<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), true).
'</td>';
1438 print
'<td class="right nowraponall amount">'.price($obj->amount_ttc).
'</td>';
1440 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_amount_ttc).
'</td>';
1442 print
'<td class="tdoverflowmax100">';
1443 print $tmpuser->getNomUrl(-1);
1446 print
'<td> </td>';
1456 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.