Merge pull request #19059 from FHenry/fix_introduced_scrutinizer

fix: scrutinizer
This commit is contained in:
Laurent Destailleur 2021-10-21 22:52:20 +02:00 committed by GitHub
commit 6c870bb3d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 57 additions and 156 deletions

View File

@ -214,7 +214,7 @@ if ($action == 'validatehistory') {
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
$facture_static->type = $objp->ftype;
$facture_static->datef = $objp->datef;
$facture_static->date = $objp->datef;
$facture_static_det->id = $objp->rowid;
$facture_static_det->total_ht = $objp->total_ht;

View File

@ -559,7 +559,7 @@ if ($result) {
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
$facture_static->type = $objp->ftype;
$facture_static->datef = $objp->datef;
$facture_static->date = $objp->datef;
$facture_static_det->id = $objp->rowid;
$facture_static_det->total_ht = $objp->total_ht;

View File

@ -728,8 +728,6 @@ class Categorie extends CommonObject
}
}
// Call trigger
$this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger
$result = $this->call_trigger('CATEGORY_LINK', $user);
@ -755,6 +753,8 @@ class Categorie extends CommonObject
}
return -1;
}
return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -810,6 +810,8 @@ class Categorie extends CommonObject
$this->error = $this->db->lasterror();
return -1;
}
return 0;
}
/**

View File

@ -770,7 +770,7 @@ if ($type == Categorie::TYPE_CONTACT) {
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
if (count($contacts) > 0) {
if (is_array($contacts) && count($contacts) > 0) {
$i = 0;
foreach ($contacts as $key => $contact) {
$i++;

View File

@ -1494,13 +1494,13 @@ if ($action == 'create' && $usercancreate) {
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
$availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0));
$availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
$shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
$warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
$dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : '';
$dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ? -1 : '';
$date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : '');
if (empty($date_delivery)) {
@ -1526,7 +1526,7 @@ if ($action == 'create' && $usercancreate) {
$cond_reglement_id = $soc->cond_reglement_id;
$mode_reglement_id = $soc->mode_reglement_id;
$fk_account = $soc->fk_account;
$availability_id = $soc->availability_id;
$availability_id = 0;
$shipping_method_id = $soc->shipping_method_id;
$warehouse_id = $soc->warehouse_id;
$demand_reason_id = $soc->demand_reason_id;

View File

@ -303,8 +303,8 @@ class FactureRec extends CommonInvoice
$sql .= ", ".((int) $facsrc->socid);
$sql .= ", ".((int) $conf->entity);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".(!empty($facsrc->amount) ? ((float) $facsrc->amount) : '0');
$sql .= ", ".(!empty($facsrc->remise) ? ((float) $this->remise) : '0');
$sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0');
$sql .= ", ".(!empty($facsrc->remise_absolue) ? ((float) $this->remise_absolue) : '0');
$sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ", ".(!empty($this->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL");

View File

@ -6488,7 +6488,7 @@ abstract class CommonObject
$out = '';
$type = '';
$isDependList=0;
$isDependList = 0;
$param = array();
$param['options'] = array();
$reg = array();
@ -6796,7 +6796,7 @@ abstract class CommonObject
if (!empty($InfoFieldList[3]) && $parentField) {
$parent = $parentName.':'.$obj->{$parentField};
$isDependList=1;
$isDependList = 1;
}
$out .= '<option value="'.$obj->rowid.'"';
@ -6951,7 +6951,7 @@ abstract class CommonObject
if (!empty($InfoFieldList[3]) && $parentField) {
$parent = $parentName.':'.$obj->{$parentField};
$isDependList=1;
$isDependList = 1;
}
$data[$obj->rowid] = $labeltoshow;
@ -9485,7 +9485,7 @@ abstract class CommonObject
}
$error = 0;
$ok=0;
$ok = 0;
// Process
foreach ($to_del as $del) {
@ -9497,7 +9497,7 @@ abstract class CommonObject
$this->errors = $c->errors;
break;
} else {
$ok+=$result;
$ok += $result;
}
}
}
@ -9510,7 +9510,7 @@ abstract class CommonObject
$this->errors = $c->errors;
break;
} else {
$ok+=$result;
$ok += $result;
}
}
}

View File

@ -51,6 +51,11 @@ abstract class CommonObjectLine extends CommonObject
*/
public $fk_unit;
public $date_debut_prevue;
public $date_debut_reel;
public $date_fin_prevue;
public $date_fin_reel;
/**
* Constructor

View File

@ -250,6 +250,8 @@ class ExtraFields
return -1;
}
$result = 0;
if ($type == 'separate') {
$unique = 0;
$required = 0;
@ -1978,10 +1980,10 @@ class ExtraFields
{
global $conf, $langs;
if ($display_type=='card') {
$tagtype='tr';
$tagtype_dyn='td';
} elseif ($display_type=='line') {
$tagtype='tr';
$tagtype_dyn='td';
if ($display_type=='line') {
$tagtype='div';
$tagtype_dyn='span';
$colspan=0;

View File

@ -157,6 +157,8 @@ class FormMail extends Form
public $lines_model;
public $withoptiononeemailperrecipient;
/**
* Constructor

View File

@ -46,6 +46,8 @@
*/
function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '')
{
global $conf;
if (empty($minLength)) {
$minLength = 1;
}

View File

@ -383,7 +383,7 @@ class ConferenceOrBooth extends ActionComm
$error = 0;
// Protection
if ($this->status == self::STATUS_VALIDATED) {
if ($this->status == self::STATUS_CONFIRMED) {
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
return 0;
}
@ -412,44 +412,8 @@ class ConferenceOrBooth extends ActionComm
// End call triggers
}
if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorbooth/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorbooth/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->eventorganization->dir_output.'/conferenceorbooth/'.$oldref;
$dirdest = $conf->eventorganization->dir_output.'/conferenceorbooth/'.$newref;
if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorbooth/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
$dirdest = $fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
}
}
}
}
// Set new ref and current status
if (!$error) {
$this->ref = $num;
$this->status = self::STATUS_CONFIRMED;
}

View File

@ -982,28 +982,6 @@ class ConferenceOrBoothAttendee extends CommonObject
$this->initAsSpecimenCommon();
}
/**
* Create an array of lines
*
* @return array|int array of lines if OK, <0 if KO
*/
public function getLinesArray()
{
$this->lines = array();
$objectline = new ConferenceOrBoothAttendeeLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorboothattendee = '.((int) $this->id)));
if (is_numeric($result)) {
$this->error = $this->error;
$this->errors = $this->errors;
return $result;
} else {
$this->lines = $result;
return $this->lines;
}
}
/**
* Returns the reference to the following non used object depending on the active numbering module.
*

View File

@ -590,58 +590,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print dol_get_fiche_end();
/*
* Lines
*/
if (!empty($object->table_element_line)) {
// Show object lines
$result = $object->getLinesArray();
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="page_y" value="">
<input type="hidden" name="id" value="' . $object->id.'">
';
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '<table id="tablelines" class="noborder noshadow" width="100%">';
}
if (!empty($object->lines)) {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
}
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
if ($action != 'editline') {
// Add products/services form
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
$object->formAddObjectLine(1, $mysoc, $soc);
}
}
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '</table>';
}
print '</div>';
print "</form>\n";
}
// Buttons for actions
if ($action != 'presend' && $action != 'editline') {

View File

@ -127,6 +127,7 @@ function conferenceorboothProjectPrepareHead($object)
$head[$h][2] = 'conferenceorbooth';
// Enable caching of conf or booth count attendees
$nbAttendees = 0;
$nbConferenceOrBooth= 0;
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_conferenceorbooth_project_'.$object->id;
$dataretrieved = dol_getcache($cachekey);

View File

@ -871,7 +871,7 @@ class Productcustomerprice extends CommonObject
$resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate);
if ($result < 0) {
$error++;
$this->error = $prodsocpriceupd->error;
$this->error = $prodsocpricenew->error;
}
}
}

View File

@ -1601,19 +1601,23 @@ class Project extends CommonObject
foreach (array('internal', 'external') as $source) {
$tab = $origin_project->liste_contact(-1, $source);
foreach ($tab as $contacttoadd) {
$clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'], $notrigger);
if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
$this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
$error++;
} else {
if ($clone_project->error != '') {
$this->error .= $clone_project->error;
if (is_array($tab) && count($tab)>0) {
foreach ($tab as $contacttoadd) {
$clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'], $notrigger);
if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
$this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
$error++;
} else {
if ($clone_project->error != '') {
$this->error .= $clone_project->error;
$error++;
}
}
}
} elseif ($tab < 0) {
$this->error .= $origin_project->error;
$error++;
}
}
}
@ -1660,7 +1664,7 @@ class Project extends CommonObject
foreach ($tasksarray as $tasktoclone) {
$result_clone = $taskstatic->createFromClone($user, $tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false);
if ($result_clone <= 0) {
$this->error .= $result_clone->error;
$this->error .= $taskstatic->error;
$error++;
} else {
$new_task_id = $result_clone;
@ -1714,6 +1718,7 @@ class Project extends CommonObject
global $user, $langs, $conf;
$error = 0;
$result = 0;
$taskstatic = new Task($this->db);

View File

@ -94,7 +94,7 @@ if ($action == 'addcontact') {
foreach ($task_array as $task) {
$task_already_affected=false;
$personsLinked = $task->liste_contact(-1, $source);
if (!is_array($personsLinked) && coun($personsLinked) < 0) {
if (!is_array($personsLinked) && count($personsLinked) < 0) {
setEventMessage($object->error, 'errors');
} else {
foreach ($personsLinked as $person) {

View File

@ -404,8 +404,8 @@ if ($id > 0 || !empty($ref)) {
// Third party
print '<td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
if ($projectstatic->societe->id) {
print $projectstatic->societe->getNomUrl(1);
if ($projectstatic->thirdparty->id) {
print $projectstatic->thirdparty->getNomUrl(1);
} else {
print '&nbsp;';
}

View File

@ -326,22 +326,14 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$text = $langs->trans('SellingPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>';
if ($object->price_base_type == 'TTC') {
print '<input name="price" size="10" value="'.price($object->price_ttc).'">';
} else {
print '<input name="price" size="10" value="'.price($object->price).'">';
}
print '<input name="price" size="10" value="'.GETPOST('price', 'int').'">';
print '</td></tr>';
// Price minimum
print '<tr><td>';
$text = $langs->trans('MinPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
if ($object->price_base_type == 'TTC') {
print '<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).'">';
} else {
print '<td><input name="price_min" size="10" value="'.price($object->price_min).'">';
}
print '<td><input name="price_min" size="10" value="'.GETPOST('price_min', 'int').'">';
print '</td></tr>';
// Update all child soc