Skip to content

Commit

Permalink
Merge branch '20.0up' into 20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarcet committed Oct 10, 2024
2 parents 3697d7f + ee4776d commit f1cd746
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4054,7 +4054,7 @@ public function addline(
* @param double $remise_percent Percentage discount of the line
* @param int $date_start Date de debut de validite du service
* @param int $date_end Date de fin de validite du service
* @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)')
* @param double|string $txtva VAT Rate (Can be '8.5', '8.5 (ABC)')
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param string $price_base_type HT or TTC
Expand Down
6 changes: 5 additions & 1 deletion htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,12 @@ function getBrowserInfo($user_agent)
$version = end($reg);
} elseif (preg_match('/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
// MS products at end
$name = 'lynxlinks';
$name = 'textbrowser';
$version = empty($reg[3]) ? '' : $reg[3];
} elseif (preg_match('/w3m\/([\d\.]+)/i', $user_agent, $reg)) {
// MS products at end
$name = 'textbrowser';
$version = empty($reg[1]) ? '' : $reg[1];
}

if ($tablet) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ function analyseVarsForSqlAndScriptsInjection(&$var, $type, $stopcode = 1)
}

// Set global MAIN_OPTIMIZEFORTEXTBROWSER (must be before login part)
if (GETPOSTINT('textbrowser') || (!empty($conf->browser->name) && $conf->browser->name == 'lynxlinks')) { // If we must enable text browser
if (GETPOSTINT('textbrowser') || (!empty($conf->browser->name) && $conf->browser->name == 'textbrowser')) { // If we must enable text browser
$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 2;
}

Expand Down
29 changes: 24 additions & 5 deletions htdocs/takepos/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,12 @@ function fail($message)
if (!$permissiontoupdateline) {
dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos").' - No permission to updateqty', null, 1);
} else {
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
$vatratecode = $line->tva_tx;
if ($line->vat_src_code) {
$vatratecode .= ' ('.$line->vat_src_code.')';
}

$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $vatratecode, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
}
}
Expand Down Expand Up @@ -1002,12 +1007,18 @@ function fail($message)
// TODO Check also that invoice->ref is (PROV-POS1-2) with 1 = terminal and 2, the invoice ID
}
}

$vatratecode = $line->tva_tx;
if ($line->vat_src_code) {
$vatratecode .= ' ('.$line->vat_src_code.')';
}

if (!$permissiontoupdateline) {
dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos").' - No permission to updateprice', null, 1);
} elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) {
$result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
$result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vatratecode, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
} else {
$result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
$result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vatratecode, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
}
}
Expand Down Expand Up @@ -1050,7 +1061,11 @@ function fail($message)
if (!$permissiontoupdateline) {
dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1);
} else {
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
$vatratecode = $line->tva_tx;
if ($line->vat_src_code) {
$vatratecode .= ' ('.$line->vat_src_code.')';
}
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $vatratecode, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
}
}
Expand All @@ -1060,7 +1075,11 @@ function fail($message)
$invoice->fetch($placeid);
} elseif ($action == 'update_reduction_global' && $user->hasRight('takepos', 'editlines')) {
foreach ($invoice->lines as $line) {
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
$vatratecode = $line->tva_tx;
if ($line->vat_src_code) {
$vatratecode .= ' ('.$line->vat_src_code.')';
}
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $vatratecode, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}

$invoice->fetch($placeid);
Expand Down
18 changes: 13 additions & 5 deletions test/phpunit/FunctionsLibTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public function testGetBrowserInfo()
$this->assertFalse($tmp['tablet']);
$this->assertEquals('classic', $tmp['layout']);

//Internet Explorer 11
// Internet Explorer 11
$user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
$tmp = getBrowserInfo($user_agent);
$this->assertEquals('ie', $tmp['browsername']);
Expand All @@ -542,7 +542,7 @@ public function testGetBrowserInfo()
$this->assertFalse($tmp['tablet']);
$this->assertEquals('classic', $tmp['layout']);

//Internet Explorer 11 bis
// Internet Explorer 11 bis
$user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko';
$tmp = getBrowserInfo($user_agent);
$this->assertEquals('ie', $tmp['browsername']);
Expand All @@ -551,7 +551,7 @@ public function testGetBrowserInfo()
$this->assertFalse($tmp['tablet']);
$this->assertEquals('classic', $tmp['layout']);

//iPad
// iPad
$user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
$tmp = getBrowserInfo($user_agent);
$this->assertEquals('safari', $tmp['browsername']);
Expand All @@ -560,13 +560,21 @@ public function testGetBrowserInfo()
$this->assertEquals('tablet', $tmp['layout']);
$this->assertEquals('iphone', $tmp['phone']);

//Lynx
// Lynx
$user_agent = 'Lynx/2.8.8dev.3 libwww‑FM/2.14 SSL‑MM/1.4.1';
$tmp = getBrowserInfo($user_agent);
$this->assertEquals('lynxlinks', $tmp['browsername']);
$this->assertEquals('textbrowser', $tmp['browsername']);
$this->assertEquals('2.8.8', $tmp['browserversion']);
$this->assertEquals('unknown', $tmp['browseros']);
$this->assertEquals('classic', $tmp['layout']);

// W3M
$user_agent = 'w3m/1.2.3-git123456';
$tmp = getBrowserInfo($user_agent);
$this->assertEquals('textbrowser', $tmp['browsername']);
$this->assertEquals('1.2.3', $tmp['browserversion']);
$this->assertEquals('unknown', $tmp['browseros']);
$this->assertEquals('classic', $tmp['layout']);
}


Expand Down

0 comments on commit f1cd746

Please sign in to comment.