Clean code

This commit is contained in:
Laurent Destailleur 2021-04-26 15:44:24 +02:00
parent 87393cee98
commit 14baec95dc
8 changed files with 17 additions and 19 deletions

View File

@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
* @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template * @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
* @param string $filesuffix Suffix to add into file name of generated PDF * @param string $filesuffix Suffix to add into file name of generated PDF
* @param string $paymentbankid Only if payment on this bank account id * @param string $paymentbankid Only if payment on this bank account id
* @param array $thirdpartiesid List of thirdparties id when using filter excludethirdpartiesid or onlythirdpartiesid * @param array $thirdpartiesid List of thirdparties id when using filter=excludethirdpartiesid or filter=onlythirdpartiesid
* @param string $fileprefix Prefix to add into filename of generated PDF * @param string $fileprefix Prefix to add into filename of generated PDF
* @return int Error code * @return int Error code
*/ */

View File

@ -138,8 +138,8 @@ if (!empty($date_start) && !empty($date_end)) {
$sql .= " AND f.datec >= '".$db->idate($date_start)."' AND f.datec <= '".$db->idate($date_end)."'"; $sql .= " AND f.datec >= '".$db->idate($date_start)."' AND f.datec <= '".$db->idate($date_end)."'";
} }
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; $sql .= " AND f.entity IN (".getEntity('invoice', 0).")";
if ($socid) { if ($socid > 0) {
$sql .= " AND f.fk_soc = ".$socid; $sql .= " AND f.fk_soc = ".((int) $socid);
} }
$sql .= " GROUP BY name"; $sql .= " GROUP BY name";
$sql .= ")"; $sql .= ")";
@ -154,8 +154,8 @@ if (!empty($date_start) && !empty($date_end)) {
$sql .= " AND ff.datec >= '".$db->idate($date_start)."' AND ff.datec <= '".$db->idate($date_end)."'"; $sql .= " AND ff.datec >= '".$db->idate($date_start)."' AND ff.datec <= '".$db->idate($date_end)."'";
} }
$sql .= " AND ff.entity = ".$conf->entity; $sql .= " AND ff.entity = ".$conf->entity;
if ($socid) { if ($socid > 0) {
$sql .= " AND f.fk_soc = ".$socid; $sql .= " AND f.fk_soc = ".((int) $socid);
} }
$sql .= " GROUP BY name"; $sql .= " GROUP BY name";
$sql .= ")"; $sql .= ")";

View File

@ -168,9 +168,9 @@ $sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
$sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; $sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= ", ".MAIN_DB_PREFIX."bank as b"; $sql .= ", ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.fk_account = ".$acct->id; $sql .= " WHERE b.fk_account = ".((int) $acct->id);
if ($listofnum) { if ($listofnum) {
$sql .= " AND b.num_releve IN (".$listofnum.")"; $sql .= " AND b.num_releve IN (".$db->sanitize($listofnum, 1).")";
} }
if (!isset($num)) { if (!isset($num)) {
$sql .= " OR b.num_releve is null"; $sql .= " OR b.num_releve is null";

View File

@ -93,6 +93,7 @@ if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$oldemail = 'none'; $oldemail = 'none';
$oldsalerepresentative = '';
$olduid = 0; $olduid = 0;
$oldlang = ''; $oldlang = '';
$total = 0; $total = 0;

View File

@ -25,7 +25,6 @@
* \ingroup mailing * \ingroup mailing
* \brief Script to send a prepared and validated emaling from command line * \brief Script to send a prepared and validated emaling from command line
*/ */
if (!defined('NOSESSION')) { if (!defined('NOSESSION')) {
define('NOSESSION', '1'); define('NOSESSION', '1');
} }
@ -98,7 +97,7 @@ $sql = "SELECT m.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE m.statut IN (1,2)"; $sql .= " WHERE m.statut IN (1,2)";
if ($id != 'all') { if ($id != 'all') {
$sql .= " AND m.rowid= ".$id; $sql .= " AND m.rowid= ".((int) $id);
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
} }
@ -144,7 +143,7 @@ if ($resql) {
} elseif ($conf->global->MAILING_LIMIT_SENDBYCLI > 0 && $max > 0) { } elseif ($conf->global->MAILING_LIMIT_SENDBYCLI > 0 && $max > 0) {
$sql2 .= " LIMIT ".min($conf->global->MAILING_LIMIT_SENDBYCLI, $max); $sql2 .= " LIMIT ".min($conf->global->MAILING_LIMIT_SENDBYCLI, $max);
} elseif ($max > 0) { } elseif ($max > 0) {
$sql2 .= " LIMIT ".$max; $sql2 .= " LIMIT ".((int) $max);
} }
$resql2 = $db->query($sql2); $resql2 = $db->query($sql2);
@ -386,7 +385,7 @@ if ($resql) {
$statut = 3; $statut = 3;
} }
$sqlenddate = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id; $sqlenddate = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".((int) $statut)." WHERE rowid=".((int) $id);
dol_syslog("update global status", LOG_DEBUG); dol_syslog("update global status", LOG_DEBUG);
print "Update status of emailing id ".$id." to ".$statut."\n"; print "Update status of emailing id ".$id." to ".$statut."\n";

View File

@ -111,7 +111,7 @@ while ($tmp != null) {
if ($type == 'all' || $type == 'users') { if ($type == 'all' || $type == 'users') {
// Loop on each record and update the email to null if email into $groupofemails // Loop on each record and update the email to null if email into $groupofemails
$sql = $sql_base."user as u SET u.email = NULL WHERE u.email IN (".$emailsin.");"; $sql = $sql_base."user as u SET u.email = NULL WHERE u.email IN (".$db->sanitize($emailsin, 1).");";
print "Try to update users, "; print "Try to update users, ";
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
@ -122,7 +122,7 @@ while ($tmp != null) {
if ($type == 'all' || $type == 'thirdparties') { if ($type == 'all' || $type == 'thirdparties') {
// Loop on each record and update the email to null if email into $groupofemails // Loop on each record and update the email to null if email into $groupofemails
$sql = $sql_base."societe as s SET s.email = NULL WHERE s.email IN (".$emailsin.");"; $sql = $sql_base."societe as s SET s.email = NULL WHERE s.email IN (".$db->sanitize($emailsin, 1).");";
print "Try to update thirdparties, "; print "Try to update thirdparties, ";
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
@ -134,7 +134,7 @@ while ($tmp != null) {
if ($type == 'all' || $type == 'contacts') { if ($type == 'all' || $type == 'contacts') {
// Loop on each record and update the email to null if email into $groupofemails // Loop on each record and update the email to null if email into $groupofemails
$sql = $sql_base."socpeople as s SET s.email = NULL WHERE s.email IN (".$emailsin.");"; $sql = $sql_base."socpeople as s SET s.email = NULL WHERE s.email IN (".$db->sanitize($emailsin, 1).");";
print "Try to update contacts, "; print "Try to update contacts, ";
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
@ -146,7 +146,7 @@ while ($tmp != null) {
if ($type == 'all' || $type == 'members') { if ($type == 'all' || $type == 'members') {
// Loop on each record and update the email to null if email into $groupofemails // Loop on each record and update the email to null if email into $groupofemails
$sql = $sql_base."adherent as a SET a.email = NULL WHERE a.email IN (".$emailsin.");"; $sql = $sql_base."adherent as a SET a.email = NULL WHERE a.email IN (".$db->sanitize($emailsin, 1).");";
print "Try to update members, "; print "Try to update members, ";
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {

View File

@ -1,7 +1,6 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
/* /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean Heimburger <http://tiaris.eu> * Copyright (C) 2015 Jean Heimburger <http://tiaris.eu>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,7 +1,6 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
/* /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify