diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 15d985db6bf..2e299740290 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1199,9 +1199,10 @@ class Facture extends CommonInvoice * @param int $notooltip 1=Disable tooltip * @param int $addlinktonotes 1=Add link to notes * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $target Target of link ('', '_self', '_blank', '_parent', '_backoffice', ...) * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '') { global $langs, $conf, $user, $form; @@ -1254,7 +1255,7 @@ class Facture extends CommonInvoice if ($moretitle) $label.=' - '.$moretitle; } - $linkclose=''; + $linkclose=($target?' target="'.$target.'"':''); if (empty($notooltip) && $user->rights->facture->lire) { if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) @@ -2720,7 +2721,7 @@ class Facture extends CommonInvoice // Check parameters if ($type < 0) return -1; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -2929,7 +2930,7 @@ class Facture extends CommonInvoice return -3; } } - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index c81a365bfbc..db86d5e8b58 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1021,8 +1021,6 @@ function pricejs(amount, mode) { var main_rounding_unit = global->MAIN_MAX_DECIMALS_UNIT; ?>; var main_rounding_tot = global->MAIN_MAX_DECIMALS_TOT; ?>; - console.log(amount); - if (mode == 'MU') return amount.toFixed(main_rounding_unit); if (mode == 'MT') return amount.toFixed(main_rounding_tot); return 'Bad value for parameter mode'; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a0020ec1f41..e4dde53e9e7 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -42,11 +42,7 @@ $desc = GETPOST('desc', 'alpha'); $pay = GETPOST('pay', 'alpha'); $amountofpayment = price2num(GETPOST('amount', 'alpha')); -$placeid = 0; // $placeid is id of invoice - -$invoice = new Facture($db); -$ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); -if ($ret > 0) $placeid = $invoice->id; +$invoiceid = GETPOST('invoiceid', 'int'); $paycode = $pay; if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility @@ -62,6 +58,21 @@ $codes = $db->fetch_array($resql); $paiementid=$codes[0]; +$invoice = new Facture($db); +if ($invoiceid > 0) +{ + $ret = $invoice->fetch($invoiceid); +} +else +{ + $ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); +} +if ($ret > 0) +{ + $placeid = $invoice->id; +} + + /* * Actions */ @@ -81,8 +92,14 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice = new Facture($db); $invoice->fetch($placeid); - if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); - else $invoice->validate($user); + if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") + { + $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); + } + else + { + $invoice->validate($user); + } // Add the payment $payment=new Paiement($db); @@ -96,10 +113,9 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - - if ($amountofpayment == $invoice->getRemainToPay()) + if ($invoice->getRemainToPay() == 0) { - $invoice->set_paid($user); + $result = $invoice->set_paid($user); } } @@ -248,6 +264,11 @@ if ($action == "order" and $placeid != 0) { $invoice->fetch($placeid); } + +/* + * View + */ + ?>