Merge branch '260416-correction' into pre-stable

* 260416-correction:
  SMTPMail Sendmail_Core: align blind_copy and reply_to
  Unit test : test changes 10.2
  Sendmail : email not fully compliant, replace code with PHPMailer
  Manage_Table get array with all errors
  compute.php log exception
  translation
  Improve usage in command line
  Noalyss_debug.js available if debug level > 0
  Improve 2FA : show expected code, improve explanation
  Redirect properly if not config.inc.php file
  CARD: show only count of available cards in the SELECT
  Manage_Table in case of exception, check that $S5 exists before throwing message
  Mantis 0002461: Ajouter une colonne TVA dans la section ARTICLE
  Appearance : improve responsive appearance for dashboard element
  CSS: improve appareance card and gestion_title  on small screens
This commit is contained in:
sparkyx 2026-04-30 17:00:50 +02:00
commit a35ee8ef2a
20 changed files with 2500 additions and 5673 deletions

View file

@ -42,6 +42,23 @@ MaintenanceMode("block.html");
$http=new HttpInput();
//------------------------------------------------
// refresh code from otp-link.php
//------------------------------------------------
if ($http->post("action","string","xx")=="qr_refresh") {
try {
$authenticator = new \Noalyss\OTP();
$secret=$http->post("secret");
echo $authenticator->compute_code($secret);
} catch (Exception $exc) {
record_log($exc);
}
return;
}
// TVA id or TVA code
$t=$http->get("t");
// string qcode card

View file

@ -1233,10 +1233,30 @@ div.topmenu {
position:absolute;
text-align:left;
z-index:1;
width:480px;
width:30rem;
width:100%;
height:auto;
}
@media (min-width: 576px) {
}
/* MeDium */
@media (min-width: 768px) {
#add_todo_list , div.add_todo_list{
}
}
/* LarGe */
@media (min-width: 992px) {
#add_todo_list , div.add_todo_list {
width:480px;
width:30rem;
}
}
/* eXtraLarge */
@media (min-width: 1200px) {
}
div.welcome {
}
@ -3072,7 +3092,6 @@ span.warning {
}
li.tab_row_selected {
display:block;
width:96%;
background: #C2E3FC; /* Old browsers */
background: -moz-linear-gradient(top, #C2E3FC 0%, #6393c1 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#C2E3FC), color-stop(100%,#6393c1)); /* Chrome,Safari4+ */
@ -3171,6 +3190,9 @@ margin-left: 2px;
border-color: #879ed4;
border-width: 1px;
border-style: solid;
border-radius: 10px;
padding: 20px 15px 15px 20px;
margin: 20px 15px 15px 15px;
}
span.tab_row {
font-style: italic;

View file

@ -134,8 +134,8 @@
* </ul>
*/
if (! file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php') )
// -- if there is not config.inc.php file then redirect to install.php
if ( ! file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php') )
{
echo <<<EOF
@ -143,9 +143,6 @@ if (! file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config
window.location="install.php";
</script>
EOF;
header("Location: install.php");
exit(0);
}

View file

@ -2180,7 +2180,7 @@ function view_action(ag_id, dossier, modify) {
}
var code_html = getNodeText(html[0]);
code_html = unescape_xml(code_html);
var pos = fixed_position(0, 50) + ";width:90%;left:5%;z-index:"+layer+";";
var pos = "position:absolute;"+"top : "+calcy(50)+"px;"+"z-index:"+layer;
add_div({
id: id,
cssclass: "inner_box",

View file

@ -53,7 +53,9 @@ function todo_list_show(p_id)
todo_div.style.top = (posY + offsetY) + 'px';
todo_div.style.left = (posX + offsetX + 20) + 'px';
if (document.viewport.getWidth()> 970) {
todo_div.style.left = (posX + offsetX + 20) + 'px';
}
var answer = req.responseXML;
var tl_id = answer.getElementsByTagName('tl_id');

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -532,33 +532,40 @@ abstract class XML_Reader
*/
$pdf->setFont("DejaVu", "B", 12);
$pdf->SetTextColor(0,0,127);
$pdf->write_cell(60, 4, _("Articles"));
$pdf->write_cell(50, 4, _("Articles"));
$pdf->line_new(6);
$pdf->SetTextColor(0,0,0);
$pdf->setFont("DejaVu", "", 7);
$result = $this->get_invoiceLine();
$pdf->write_cell(50, 4, _("Code"), border: 'B');
$pdf->write_cell(60, 4, _("Description"), border: 'B');
$pdf->write_cell(40, 4, _("Code"), border: 'B');
$pdf->write_cell(50, 4, _("Description"), border: 'B');
$pdf->write_cell(20, 4, _("TVA"), border: 'B', align: 'R');
$pdf->write_cell(20, 4, _("Prix unitaire"), border: 'B', align: 'R');
$pdf->write_cell(20, 4, _("Quantité"), border: 'B', align: 'R');
$pdf->write_cell(20, 4, _("Montant HT"), border: 'B', align: 'R');
$pdf->write_cell(20, 4, _("TVAC"), border: 'B', align: 'R');
$pdf->line_new();
$nb_inline = count($result);
for ($i = 0; $i < $nb_inline; $i++)
{
if ( $result[$i]['description'] == '') {
$pdf->write_multi(110, 4, $result[$i]['name']);
$pdf->write_multi(90, 4, $result[$i]['name']);
}else {
$pdf->write_multi(50, 4, $result[$i]['name']);
$pdf->write_multi(60, 4, $result[$i]['description']);
$pdf->write_multi(40, 4, $result[$i]['name']);
$pdf->write_multi(50, 4, $result[$i]['description']);
}
$pdf->write_cell(20, 4, $result[$i]['tva_percent'], align: 'R');
//$pdf->write_cell(5, 4, $result[$i]['tva_id']);
$pdf->write_cell(20, 4, $result[$i]['unit_price'], align: 'R');
$pdf->write_cell(20, 4, $result[$i]['quantity'], align: 'R');
$pdf->write_cell(20, 4, nbm($result[$i]['amount']), align: 'R');
/// @var $t (float) amount VAT included
$t= bcmul($result[$i]['amount'],
bcdiv($result[$i]['tva_percent'],100,4),4);
$t=bcadd($result[$i]["amount"],$t,4);
$t=round($t,2);
$pdf->write_cell(20, 4, nbm($t), align: 'R');
$pdf->line_new();
}
$pdf->line_new(10);

View file

@ -369,16 +369,16 @@ define("ARROWUP","&#8679;");
// Url of NOALYSS (http://...)
//
if (!defined("NOALYSS_URL")) {
if ( isset ( $_SERVER)) {
$protocol = "http";
if (isset ($_SERVER['REQUEST_SCHEME'])) {
$protocol = $_SERVER['REQUEST_SCHEME'];
}
$base = $protocol . '://' .
$_SERVER['SERVER_NAME'] .
":" . $_SERVER['SERVER_PORT'] .
dirname($_SERVER['PHP_SELF']);
define("NOALYSS_URL", $base);
if ( isset ( $_SERVER['SERVER_NAME'])) {
$protocol = "http";
if (isset ($_SERVER['REQUEST_SCHEME'])) {
$protocol = $_SERVER['REQUEST_SCHEME'];
}
$base = $protocol . '://' .
$_SERVER['SERVER_NAME'] .
":" . $_SERVER['SERVER_PORT'] .
dirname($_SERVER['PHP_SELF']);
define("NOALYSS_URL", $base);
}else {
define("NOALYSS_URL","command-line");
}

View file

@ -35,7 +35,7 @@ global $g_user, $g_failed;
*/
/* var categorie ISelect select card category */
$categorie = new ISelect('cat');
$categorie->value = $cn->make_array("select fd_id,fd_label||' ('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id)::text||')' from fiche_def order by fd_label");
$categorie->value = $cn->make_array("select fd_id,fd_label||' ('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id and f_enable='1')::text||')' from fiche_def order by fd_label");
$categorie->selected = $http->get('cat','number',0);
// var $str_categorie string

View file

@ -2785,7 +2785,7 @@ EOF;
echo js_include('noalyss_checkbox.js');
echo js_include('tinymce/tinymce.min.js');
if (DEBUGNOALYSS > 1) {
if (DEBUGNOALYSS > 0) {
echo js_include('noalyss_debug.js');
}
echo '<script src="export.php?loadjs=message" type="text/javascript" charset="utf-8"></script>';

View file

@ -175,6 +175,13 @@ class Manage_Table_SQL
$this->cssclass="inner_box";
}
/**
* @brief returns an array of errors : key= column name
* @return type
*/
function get_aerror() {
return $this->aerror;
}
function setCssClass($p_class) {
$this->cssclass=$p_class;
}
@ -1355,7 +1362,7 @@ function check()
$root->appendChild($s2);
$root->appendChild($s3);
$root->appendChild($s4);
$root->appendChild($s5);
if ( isset($s5) ) $root->appendChild($s5);
$xml->appendChild($root);
}
return $xml;

View file

@ -23,7 +23,8 @@
*@brief API for sending email
*/
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
/**
*@class Sendmail_Core
*@brief API for sending email
@ -43,19 +44,35 @@ class Sendmail_Core
protected $subject;
protected $message;
protected $from;
protected $content;
protected $header;
protected $format;
protected $header; //!< unused
protected $format; //!< PLAIN or HTML, message format
protected $supplemental_header; //!< $supplemental_header(string) supplemental header to add
protected $supplemental_param; //!< $supplemental_param (string) 5th parameter for mail()
// for postfix, it should be "-f {$this->from}" for the Return-Path
protected $phpmailer; //!< PHPMailer object;
protected $blind_copy; //!< email of blind copy (list of emails separated by comma)
protected $reply_to; //!< reply to
function __construct()
{
$this->format='PLAIN';
$this->supplemental_header="";
$this->supplemental_param=MAIL_EXTRA_PARAM;
$this->phpmailer = new PHPMailer;
$this->phpmailer->CharSet = PHPMailer::CHARSET_UTF8;
//$this->phpmailer->SMTPDebug = SMTP::DEBUG_CLIENT;
$this->phpmailer->SMTPDebug = SMTP::DEBUG_OFF;
$this->phpmailer->isSendmail(true);
$this->phpmailer->XMailer = "noalyss-email";
$this->phpmailer->Host = "localhost";
$this->phpmailer->Port = "25";
$this->phpmailer->Username = "";
$this->phpmailer->Password = "";
$this->phpmailer->SMTPAuth = false;
$this->afile=[];
}
public function getSupplemental_param()
{
@ -67,8 +84,18 @@ class Sendmail_Core
$this->supplemental_param = $supplemental_param;
return $this;
}
public function getPhpmailer()
{
return $this->phpmailer;
}
public function getSupplemental_header()
public function setPhpmailer($phpmailer)
{
$this->phpmailer = $phpmailer;
return $this;
}
public function getSupplemental_header()
{
return $this->supplemental_header;
}
@ -172,96 +199,44 @@ class Sendmail_Core
*/
function compose()
{
$this->verify();
$this->header="";
$this->content="";
// a random hash will be necessary to send mixed content
$separator = md5(time());
$this->phpmailer->setFrom($this->from);
// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;
// main header (multipart mandatory)
$this->header = "From: " . $this->from . $eol;
$this->header .= "Reply-To: " . $this->from . $eol;
$this->header .= "MIME-Version: 1.0" . $eol;
$this->header .= $this->add_supplemental_header();
if ($this->format == 'PLAIN')
if ( $this->format == "HTML")
{
$this->header .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" ;
// message PLAIN
$this->content .= "--" . $separator . $eol;
$this->content .= "Content-Type: text/plain; charset=UTF-8" . $eol;
$this->content .= "Content-Transfer-Encoding: 8bit" . $eol.$eol ;
$this->content .= $this->message . $eol ;
} elseif ($this->format == 'HTML') {
$separator_second=md5(rand());
$this->header .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" .$eol ;
// message PLAIN
$this->content .= "--" . $separator . $eol;
$this->content .= "Content-Type: multipart/alternative; boundary=\"" . $separator_second . "\"".$eol ;
$this->content.= "--$separator_second".$eol;
$this->content .= "Content-Type: text/plain; charset=UTF-8; format=flowed".$eol;
$this->content .= "Content-Transfer-Encoding: 8bit" . $eol.$eol ;
$this->content .= strip_tags($this->message) . $eol ;
$this->content.=$eol;
$this->content.=$eol;
$this->content.=$eol;
// message HTML
$this->content .= "--" . $separator_second.$eol;
$this->content .= "Content-Type: text/html; charset=UTF-8" . $eol;
$this->content .= "Content-Transfer-Encoding: 8bit" . $eol.$eol ;
$this->content .=<<<eof
<!DOCTYPE html>{$eol}
<html>{$eol}
<head>{$eol}
<meta http-equiv="content-type" content="text/html; charset=UTF-8">{$eol}
</head>{$eol}
<body>
{$eol}
{$eol}
{$eol}
eof;
$this->content .= $this->message. $eol ;
$this->content .=" </body> </html>".$eol;
$this->content .= "--" . $separator_second."--" . $eol;
}else {
throw new \Exception('SC172 : unknow format ');
$this->phpmailer->Body = $this->message;
$this->phpmailer->AltBody = \strip_tags($this->message);
$this->phpmailer->isHTML(true);
}
else
{
$this->phpmailer->Body = $this->message;
$this->phpmailer->isHTML(false);
}
$this->phpmailer->Subject = $this->subject;
$nb_file=count($this->afile);
for ($i=0;$i<$nb_file;$i++)
{
$this->phpmailer->addAttachment($this->afile[$i]->full_name);
}
if ( ! empty($this->afile ) )
$a_email = explode(',', $this->mailto);
foreach ($a_email as $item)
{
// attachment
for ($i = 0; $i < count($this->afile); $i++)
{
$file = $this->afile[$i];
$file_size = filesize($file->full_name);
$mimetype=( $file->type=="")?mime_content_type($file->full_name):$file->type;
$handle = fopen($file->full_name, "r");
if ( $handle == false ){
\record_log("SC159 ".var_export($file,true));
throw new Exception ('SC159 email not send file not added'.$file->full_name);
}
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$this->content .= "--" . $separator . $eol;
$this->content .= "Content-Type: " . $mimetype . "; name=\"" . $file->filename . "\"" . $eol;
$this->content .= "Content-Disposition: attachment; filename=\"" . $file->filename . "\"" . $eol;
$this->content .= "Content-Transfer-Encoding: base64" . $eol;
$this->content.=$eol;
$this->content .= $content . $eol ;
}
$this->phpmailer->addAddress($item);
}
if ( empty ($this->afile) ) $this->content.=$eol;
$a_blind_copy=explode(",",$this->blind_copy??"");
$nb_blind_copy=count($a_blind_copy);
for ($i=0;$i<$nb_blind_copy;$i++)
{
$this->phpmailer->addBCC($a_blind_copy[$i]);
}
if ( ! empty ($this->reply_to)) {
$this->phpmailer->addReplyTo($this->reply_to);
}
$this->phpmailer->preSend();
$this->content .= "--" . $separator . "--";
$this->supplemental_param= str_replace("[FROM]", $this->from, $this->supplemental_param);
}
/**
@ -270,17 +245,6 @@ eof;
*/
function send()
{
try {
$this->verify();
} catch (Exception $e) {
throw $e;
}
$encoded_subject = mb_encode_mimeheader( $this->subject, 'UTF-8', 'B');
if (!mail($this->mailto,$encoded_subject, $this->content,$this->header,$this->supplemental_param))
{
throw new Exception('send failed');
}
$this->phpmailer->send();
}
}

View file

@ -90,11 +90,16 @@ class SMTPMail
}
/**
* @param mixed $blind_copy
* @param string $blind_copy list of emails BCC separated by a comma
*/
public function setBlindCopy($blind_copy): SMTPMail
{
$this->phpmailer->addBCC($this->blind_copy);
$a_blind_copy=explode(",",$blind_copy??"");
$nb_blind_copy=count($a_blind_copy);
for ($i=0;$i<$nb_blind_copy;$i++)
{
$this->phpmailer->addBCC($a_blind_copy[$i]);
}
return $this;
}

View file

@ -118,9 +118,15 @@ form {
width:70%;
margin-left:15%;
}
#otp_code_span {
font-size:160%;
color:navy;
background-color:white;
padding:0.8rem;
}
</style>
<img id="logo_id" src="image/logo10000.png" >
<div class="content">
<div class="content" style="display:flex;flex-direction: row;justify-content: space-evenly;">
<?php
use Endroid\QrCode\Color\Color;
use Endroid\QrCode\Encoding\Encoding;
@ -180,10 +186,45 @@ try {
);
$result = $writer->write($qrCode);
echo '<div style="margin:4rem">';
echo '<div id="otp_qrcode" >';
// generate the QRCode
echo '<h1>',_("Scanner ceci avec votre application OTP"),'</h1>';
?>
<?php
echo '<p>';
echo _("Scanner ce QRCode avec votre application OTP afin de l'ajouter");
echo '</p>';
echo '<p>';
echo _("Dans votre application OTP vous devez avoir ce nombre ");
?>
<span id="otp_code_span">
<?=$authenticator->compute_code($secret)?>
</span>
<?php
echo '</p>';
?>
<?php
printf('<img src="data:image/png;base64,%s">', base64_encode($result->getString()));
} catch (Exception $exc) {
record_log($e);
return;
}
?>
</div>
<div id="otp_install">
<h1><?=_("Installation d'une application OTP")?></h1>
<p>
<?=_("Si vous n'en avez pas installé sur votre smartphone ou PC, voici notre sélection")?>
</p>
<h2>
<?=_("Android")?>
</h2>
<ol>
<li>
<a href="https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp" target="_blank">FreeOTP (libre)</a>
@ -195,22 +236,43 @@ try {
<a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target="_blank">Google Authenticator</a>
</li>
</ol>
<?php
echo '<p>';
echo _("Scanner ce QRCode avec votre application OTP afin de l'ajouter");
<h2>
<?=_('IPhone')?>
if ( DEBUGNOALYSS > 1) { echo "code attendu",$authenticator->code();}
echo '</p>';
</h2>
<ol>
<li>
<a href="https://apps.apple.com/fr/app/freeotp-authenticator/id872559395" target="_blank">FreeOTP (libre)</a>
</li>
</ol>
<h2>
PC
</h2>
<p>
<?=_("Article à propos de otpclient")?>
<a href="https://blog.apps.education.fr/articles/otpclient-un-client-otp-sur-gnulinux-tres-utile2023-01-08t165554043z">
OTPClient , un outil très utile sous PC
</a>
<br/>
<?=_('Debian , Ubuntu,...')?>
<code>
apt install otpclient
</code>
</p>
<ol>
<li>
<a href="https://github.com/paolostivanin/OTPClient" target="_blank">Site OTPClient </a>
printf('<img src="data:image/png;base64,%s">', base64_encode($result->getString()));
} catch (Exception $exc) {
record_log($e);
return;
}
?>
</li>
</ol>
</div>
</div>
<script>
function refresh_code() {
new Ajax.Updater("otp_code_span","compute.php",{parameters:{secret:"<?=$secret?>",action:"qr_refresh"}});
}
setInterval(refresh_code, 500);
</script>

View file

@ -146,8 +146,9 @@ class Ajax_MiscTest extends TestCase
);
$_REQUEST = $_POST = $_GET = $query;
ob_start();
require NOALYSS_HOME . '/fid.php';
include NOALYSS_HOME . '/fid.php';
$content = ob_get_contents();
ob_end_clean();
@ -155,10 +156,41 @@ class Ajax_MiscTest extends TestCase
{"flabel":"e_march4_label","name":"Inserted by PHPUNIT-Ajax_MiscTest:createCard_MA1 ","ftva_id":"e_march4_tva_id","tva_id":"210A","fPrice_sale":"e_march4_price","sell":"0","fPrice_purchase":"e_march4_price","buy":"0","answer":"ok"}
EOF;
$this->assertEquals($expected, $content, "Incorrect answer");
$this->assertEquals($expected, $content, "Incorrect answer $content");
// clean card
$this->cleanCard($fiche->id);
}
public function testComputeQRCODE()
{
$_POST['secret']="QJPJXHOJ77B76WYEFURCSHRMVI7JC7FBRJA2QH34T4SXANVQUDYA";
$_POST['action']="qr_refresh";
ob_start();
include NOALYSS_HOME."/compute.php";
$x= ob_get_contents();
ob_end_clean();
$this->assertTrue($x==floatval($x),"Invalid return $x");
}
public function testCompute1()
{
$_POST=$_REQUEST=$_GET=array (
'gDossier' => DOSSIER,
'c'=>'PORA',
't'=>1,
'p'=>600,
'q'=>1,
'n'=>0,
'other_tax_id' => -1
);
ob_start();
include NOALYSS_HOME."/compute.php";
$content = ob_get_contents();
ob_end_clean();
$expected='{"ctl":0,"htva":600,"tva":126,"tvac":"726.0000","other_tax":0}'."\n";
$this->assertEquals($expected, $content, "Incorrect answer $content");
}
}

View file

@ -194,17 +194,6 @@ class Acc_DocumentTest extends TestCase {
// return array([1], [2], [3]);
// }
/**
* @testdox description of the test
* @covers Acc_Balance::summary_add
* @depend Acc_Balance::summary_init
* @backupGlobals enabled
* @dataProvider dataExample
* @global $g_connection
*/
function testFunction() {
}
/**
* @testdox Test the standard invoice, check file
* @covers Document::generate

View file

@ -128,7 +128,7 @@ class Acc_TVATest extends TestCase
return array(
['S',true,null]
,['Z',true,null]
,['A',false,""]
,['A',true,""]
,['K',true,"XX"]
);
}
@ -159,7 +159,7 @@ class Acc_TVATest extends TestCase
if ( $result != $check)
{
print "Error for $peppopl_code\n";
print_r($tva_rate_mtable->aerror);
print_r($tva_rate_mtable->get_aerror());
$this->display_error($tva_rate_mtable);
}
}

View file

@ -49,6 +49,9 @@ class FacturXTest extends TestCase {
function testBuild_Data() {
$cn=\Dossier::connect();
$facturx=new \Noalyss\XMLDocument\FacturX($cn);
$data=$facturx->get_data() ;
$this->assertTrue($data == []
," Build Data fails : get null value");
}
@ -137,6 +140,6 @@ class FacturXTest extends TestCase {
$customer=$facturx->get_data()['customer'];
$a_error = $facturx->check_customer_data($customer['card_id']);
print_r($a_error);
$this->assertTrue(count($a_error)==6, "nb of error incorrect ,expected 6, received = ".print_r($a_error,true));
$this->assertTrue(count($a_error)==5, "nb of error incorrect (JR_INTERNAL=V000002),expected 5, received = ".print_r($a_error,true));
}
}

View file

@ -50,6 +50,7 @@ class InvoiceUBL21Test extends TestCase {
function testBuild_Data() {
$cn = \Dossier::connect();
$ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn);
$this->assertTrue($ublinvoice21->get_data()==[],"Data is not empty");
}
/**
@ -170,6 +171,6 @@ class InvoiceUBL21Test extends TestCase {
$ublinvoice21->build_data(2);
$customer = $ublinvoice21->get_data()['customer'];
$a_error=$ublinvoice21->check_customer_data($customer['card_id']);
$this->assertTrue(count($a_error) ==6 , " nb of errors incorrect ".print_r($a_error,true));
$this->assertTrue(count($a_error) ==7 , " nb of errors incorrect ".print_r($a_error,true));
}
}