Merge branch 'pre-stable' into stable
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 CSS: improve appareance card and gestion_title on small screens OTP : get options XML : improve invoice appearance XMLReader : correct VAT order Bug 2458: Si on envoie un email depuis Linux , le return-path doit être spécifié ...
This commit is contained in:
commit
1ddfe09c5f
21 changed files with 2498 additions and 5674 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -101,4 +101,3 @@ define ("DEBUGNOALYSS",0);
|
|||
// For POSTFIX, when sending email from NOALYSS via sendmail an extra parameter is needed
|
||||
// for the Return-Path, the [FROM] will be replaced by the Sendmail_Core->from value
|
||||
//define("MAIL_EXTRA_PARAM","-f [FROM]")
|
||||
|
||||
|
|
|
|||
|
|
@ -369,16 +369,16 @@ define("ARROWUP","⇧");
|
|||
// 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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>';
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,42 @@ class Sendmail_Core
|
|||
*/
|
||||
function compose()
|
||||
{
|
||||
$this->verify();
|
||||
$this->header="";
|
||||
$this->content="";
|
||||
|
||||
// a random hash will be necessary to send mixed content
|
||||
$separator = md5(time());
|
||||
|
||||
// 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')
|
||||
$this->phpmailer->setFrom($this->from);
|
||||
|
||||
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;
|
||||
|
||||
$this->content .= "--" . $separator . "--";
|
||||
$this->supplemental_param= str_replace("[FROM]", $this->from, $this->supplemental_param);
|
||||
$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();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -270,17 +243,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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
if ( DEBUGNOALYSS > 1) { echo "code attendu",$authenticator->code();}
|
||||
echo '</p>';
|
||||
|
||||
|
||||
printf('<img src="data:image/png;base64,%s">', base64_encode($result->getString()));
|
||||
|
||||
} catch (Exception $exc) {
|
||||
record_log($e);
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>
|
||||
<?=_('IPhone')?>
|
||||
|
||||
</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>
|
||||
|
||||
</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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue