FIX error reported by scrutinizer
This commit is contained in:
parent
eaa548124b
commit
c8d98dbfdc
@ -76,19 +76,17 @@ if ($action == 'add') {
|
|||||||
|
|
||||||
$res = $object->create($user);
|
$res = $object->create($user);
|
||||||
|
|
||||||
if ($res == 0) {
|
if ($res == - 3) {
|
||||||
} else {
|
$error = 1;
|
||||||
if ($res == - 3) {
|
$action = "create";
|
||||||
$error = 1;
|
}
|
||||||
$action = "create";
|
if ($res == - 4) {
|
||||||
}
|
$error = 2;
|
||||||
if ($res == - 4) {
|
$action = "create";
|
||||||
$error = 2;
|
|
||||||
$action = "create";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Header("Location: account.php");
|
header("Location: account.php");
|
||||||
|
exit;
|
||||||
} else if ($action == 'edit') {
|
} else if ($action == 'edit') {
|
||||||
if (! GETPOST('cancel', 'alpha')) {
|
if (! GETPOST('cancel', 'alpha')) {
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
@ -134,7 +132,8 @@ if ($action == 'add') {
|
|||||||
$result = $object->delete($user);
|
$result = $object->delete($user);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
Header("Location: account.php");
|
header("Location: account.php");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,6 @@ class FormAdvTargetEmailing extends Form
|
|||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,52 +87,53 @@ class FormAdvTargetEmailing extends Form
|
|||||||
function multiselectCountry($htmlname = 'country_id', $selected_array=array()) {
|
function multiselectCountry($htmlname = 'country_id', $selected_array=array()) {
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$langs->load ( "dict" );
|
$langs->load("dict");
|
||||||
|
$maxlength = 0;
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
$countryArray = array ();
|
$countryArray = array();
|
||||||
$label = array ();
|
$label = array ();
|
||||||
|
|
||||||
$options_array = array ();
|
$options_array = array();
|
||||||
|
|
||||||
$sql = "SELECT rowid, code as code_iso, label";
|
$sql = "SELECT rowid, code as code_iso, label";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_country";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "c_country";
|
||||||
$sql .= " WHERE active = 1 AND code<>''";
|
$sql .= " WHERE active = 1 AND code<>''";
|
||||||
$sql .= " ORDER BY code ASC";
|
$sql .= " ORDER BY code ASC";
|
||||||
|
|
||||||
dol_syslog ( get_class ( $this ) . "::select_country sql=" . $sql );
|
dol_syslog(get_class($this) . "::select_country sql=" . $sql);
|
||||||
$resql = $this->db->query ( $sql );
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
|
||||||
$num = $this->db->num_rows ( $resql );
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num) {
|
if ($num) {
|
||||||
$foundselected = false;
|
$foundselected = false;
|
||||||
|
|
||||||
while ( $i < $num ) {
|
while ($i < $num) {
|
||||||
$obj = $this->db->fetch_object ( $resql );
|
$obj = $this->db->fetch_object ( $resql );
|
||||||
$countryArray [$i] ['rowid'] = $obj->rowid;
|
$countryArray [$i] ['rowid'] = $obj->rowid;
|
||||||
$countryArray [$i] ['code_iso'] = $obj->code_iso;
|
$countryArray [$i] ['code_iso'] = $obj->code_iso;
|
||||||
$countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) : ($obj->label != '-' ? $obj->label : ''));
|
$countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso ) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) : ($obj->label != '-' ? $obj->label : ''));
|
||||||
$label [$i] = $countryArray [$i] ['label'];
|
$label[$i] = $countryArray[$i]['label'];
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
array_multisort ( $label, SORT_ASC, $countryArray );
|
array_multisort($label, SORT_ASC, $countryArray);
|
||||||
|
|
||||||
foreach ( $countryArray as $row ) {
|
foreach ($countryArray as $row) {
|
||||||
$label = dol_trunc ( $row ['label'], $maxlength, 'middle' );
|
$label = dol_trunc($row['label'], $maxlength, 'middle');
|
||||||
if ($row ['code_iso'])
|
if ($row['code_iso'])
|
||||||
$label .= ' (' . $row ['code_iso'] . ')';
|
$label .= ' (' . $row['code_iso'] . ')';
|
||||||
|
|
||||||
$options_array [$row ['rowid']] = $label;
|
$options_array[$row['rowid']] = $label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error ( $this->db );
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array );
|
return $this->advMultiselectarray($htmlname, $options_array, $selected_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,7 +150,7 @@ class FormAdvTargetEmailing extends Form
|
|||||||
|
|
||||||
$options_array = array ();
|
$options_array = array ();
|
||||||
|
|
||||||
|
$sql_usr = '';
|
||||||
$sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
|
$sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
|
||||||
$sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
|
$sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
|
||||||
$sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")";
|
$sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")";
|
||||||
@ -197,10 +196,10 @@ class FormAdvTargetEmailing extends Form
|
|||||||
foreach ($langs_available as $key => $value)
|
foreach ($langs_available as $key => $value)
|
||||||
{
|
{
|
||||||
$label = $value;
|
$label = $value;
|
||||||
$options_array [$key] = $label;
|
$options_array[$key] = $label;
|
||||||
}
|
}
|
||||||
asort($options_array);
|
asort($options_array);
|
||||||
return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array );
|
return $this->advMultiselectarray($htmlname, $options_array, $selected_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,16 +246,18 @@ class FormAdvTargetEmailing extends Form
|
|||||||
$sql .= ' WHERE ' . $InfoFieldList [3];
|
$sql .= ' WHERE ' . $InfoFieldList [3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! empty ( $InfoFieldList [1] ) && $key == 'ts_payeur') {
|
if (! empty($InfoFieldList[1])) {
|
||||||
$sql .= " ORDER BY nom";
|
$sql .= " ORDER BY nom";
|
||||||
}
|
}
|
||||||
// $sql.= ' WHERE entity = '.$conf->entity;
|
// $sql.= ' WHERE entity = '.$conf->entity;
|
||||||
|
|
||||||
dol_syslog ( get_class ( $this ) . "::".__METHOD__,LOG_DEBUG);
|
$options_array = array();
|
||||||
$resql = $this->db->query ( $sql );
|
|
||||||
|
dol_syslog(get_class($this) . "::".__METHOD__,LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
|
||||||
$num = $this->db->num_rows ( $resql );
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num) {
|
if ($num) {
|
||||||
while ( $i < $num ) {
|
while ( $i < $num ) {
|
||||||
@ -270,15 +271,15 @@ class FormAdvTargetEmailing extends Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array );
|
return $this->advMultiselectarray($htmlname, $options_array, $selected_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return combo list with people title
|
* Return combo list with people title
|
||||||
*
|
*
|
||||||
* @param string $htmlname Name of HTML select combo field
|
* @param string $htmlname Name of HTML select combo field
|
||||||
* @param array $selected_array array
|
* @param array $selected_array Array
|
||||||
* @return string HTML combo
|
* @return string HTML combo
|
||||||
*/
|
*/
|
||||||
function multiselectCivility($htmlname='civilite_id',$selected_array = array())
|
function multiselectCivility($htmlname='civilite_id',$selected_array = array())
|
||||||
{
|
{
|
||||||
@ -357,23 +358,21 @@ class FormAdvTargetEmailing extends Form
|
|||||||
|
|
||||||
// Find if keys is in selected array value
|
// Find if keys is in selected array value
|
||||||
if (is_array($selected_array) && count($selected_array)>0) {
|
if (is_array($selected_array) && count($selected_array)>0) {
|
||||||
$intersect_array = array_intersect_key ( $options_array, array_flip ( $selected_array ) );
|
$intersect_array = array_intersect_key($options_array, array_flip($selected_array));
|
||||||
} else {
|
} else {
|
||||||
$intersect_array=array();
|
$intersect_array=array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count ( $options_array ) > 0) {
|
if (count($options_array) > 0) {
|
||||||
foreach ( $options_array as $keyoption => $valoption ) {
|
foreach ($options_array as $keyoption => $valoption) {
|
||||||
// If key is in intersect table then it have to e selected
|
// If key is in intersect table then it have to e selected
|
||||||
if (count ( $intersect_array ) > 0) {
|
$selected = '';
|
||||||
|
if (count ( $intersect_array ) > 0) {
|
||||||
if (array_key_exists ( $keyoption, $intersect_array )) {
|
if (array_key_exists ( $keyoption, $intersect_array )) {
|
||||||
$selected = ' selected="selected" ';
|
$selected = ' selected="selected"';
|
||||||
} else {
|
|
||||||
$selected = '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$return .= '<option' . $selected . ' value="' . $keyoption . '">' . $valoption . '</option>';
|
||||||
$return .= '<option ' . $selected . ' value="' . $keyoption . '">' . $valoption . '</option>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ class mailing_advthirdparties extends MailingTargets
|
|||||||
*
|
*
|
||||||
* @param int $mailing_id Id of mailing. No need to use it.
|
* @param int $mailing_id Id of mailing. No need to use it.
|
||||||
* @param array $socid Array of id soc to add
|
* @param array $socid Array of id soc to add
|
||||||
* @param int $type_of_target define in advtargetemailing.class.php
|
* @param int $type_of_target Defined in advtargetemailing.class.php
|
||||||
* @param array $contactid Array of contact id to add
|
* @param array $contactid Array of contact id to add
|
||||||
* @return int <0 if error, number of emails added if ok
|
* @return int <0 if error, number of emails added if ok
|
||||||
*/
|
*/
|
||||||
@ -73,47 +73,45 @@ class mailing_advthirdparties extends MailingTargets
|
|||||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
||||||
$sql.= " AND s.rowid IN (".implode(',',$socid).")";
|
$sql.= " AND s.rowid IN (".implode(',',$socid).")";
|
||||||
$sql.= " ORDER BY email";
|
$sql.= " ORDER BY email";
|
||||||
}
|
|
||||||
|
|
||||||
|
// Stock recipients emails into targets table
|
||||||
dol_syslog(get_class($this)."::add_to_target societe sql=".$sql, LOG_DEBUG);
|
$result=$this->db->query($sql);
|
||||||
// Stock recipients emails into targets table
|
if ($result)
|
||||||
$result=$this->db->query($sql);
|
{
|
||||||
if ($result)
|
$num = $this->db->num_rows($result);
|
||||||
{
|
$i = 0;
|
||||||
$num = $this->db->num_rows($result);
|
|
||||||
$i = 0;
|
dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG);
|
$old = '';
|
||||||
|
while ($i < $num)
|
||||||
$old = '';
|
{
|
||||||
while ($i < $num)
|
$obj = $this->db->fetch_object($result);
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
if (!array_key_exists($obj->email, $cibles)) {
|
||||||
if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
|
$cibles[$obj->email] = array(
|
||||||
if (!array_key_exists($obj->email, $cibles)) {
|
'email' => $obj->email,
|
||||||
$cibles[$obj->email] = array(
|
'fk_contact' => $obj->fk_contact,
|
||||||
'email' => $obj->email,
|
'name' => $obj->name,
|
||||||
'fk_contact' => $obj->fk_contact,
|
'firstname' => $obj->firstname,
|
||||||
'name' => $obj->name,
|
'other' => '',
|
||||||
'firstname' => $obj->firstname,
|
'source_url' => $this->url($obj->id,'thirdparty'),
|
||||||
'other' => '',
|
'source_id' => $obj->id,
|
||||||
'source_url' => $this->url($obj->id,'thirdparty'),
|
'source_type' => 'thirdparty'
|
||||||
'source_id' => $obj->id,
|
);
|
||||||
'source_type' => 'thirdparty'
|
}
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
$i++;
|
||||||
|
}
|
||||||
$i++;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
else
|
dol_syslog($this->db->error());
|
||||||
{
|
$this->error=$this->db->error();
|
||||||
dol_syslog($this->db->error());
|
return -1;
|
||||||
$this->error=$this->db->error();
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,47 +129,45 @@ class mailing_advthirdparties extends MailingTargets
|
|||||||
$sql.= " AND socp.fk_soc IN (".implode(',',$socid).")";
|
$sql.= " AND socp.fk_soc IN (".implode(',',$socid).")";
|
||||||
}
|
}
|
||||||
$sql.= " ORDER BY email";
|
$sql.= " ORDER BY email";
|
||||||
}
|
|
||||||
|
// Stock recipients emails into targets table
|
||||||
|
$result=$this->db->query($sql);
|
||||||
dol_syslog(get_class($this)."::add_to_target contact sql=".$sql);
|
if ($result)
|
||||||
// Stock recipients emails into targets table
|
{
|
||||||
$result=$this->db->query($sql);
|
$num = $this->db->num_rows($result);
|
||||||
if ($result)
|
$i = 0;
|
||||||
{
|
|
||||||
$num = $this->db->num_rows($result);
|
dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found");
|
||||||
$i = 0;
|
|
||||||
|
$old = '';
|
||||||
dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found");
|
while ($i < $num)
|
||||||
|
{
|
||||||
$old = '';
|
$obj = $this->db->fetch_object($result);
|
||||||
while ($i < $num)
|
|
||||||
{
|
if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
|
||||||
$obj = $this->db->fetch_object($result);
|
if (!array_key_exists($obj->email, $cibles)) {
|
||||||
|
$cibles[$obj->email] = array(
|
||||||
if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
|
'email' => $obj->email,
|
||||||
if (!array_key_exists($obj->email, $cibles)) {
|
'fk_contact' =>$obj->id,
|
||||||
$cibles[$obj->email] = array(
|
'lastname' => $obj->lastname,
|
||||||
'email' => $obj->email,
|
'firstname' => $obj->firstname,
|
||||||
'fk_contact' =>$obj->id,
|
'other' => '',
|
||||||
'lastname' => $obj->lastname,
|
'source_url' => $this->url($obj->id,'contact'),
|
||||||
'firstname' => $obj->firstname,
|
'source_id' => $obj->id,
|
||||||
'other' => '',
|
'source_type' => 'contact'
|
||||||
'source_url' => $this->url($obj->id,'contact'),
|
);
|
||||||
'source_id' => $obj->id,
|
}
|
||||||
'source_type' => 'contact'
|
}
|
||||||
);
|
|
||||||
}
|
$i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$i++;
|
else
|
||||||
}
|
{
|
||||||
}
|
dol_syslog($this->db->error());
|
||||||
else
|
$this->error=$this->db->error();
|
||||||
{
|
return -1;
|
||||||
dol_syslog($this->db->error());
|
}
|
||||||
$this->error=$this->db->error();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3041,6 +3041,7 @@ class Product extends CommonObject
|
|||||||
function get_sousproduits_arbo()
|
function get_sousproduits_arbo()
|
||||||
{
|
{
|
||||||
//$parent = $this->getParent();
|
//$parent = $this->getParent();
|
||||||
|
$parent=array();
|
||||||
$parent[$this->label]=array(0 => $this->id);
|
$parent[$this->label]=array(0 => $this->id);
|
||||||
|
|
||||||
foreach($parent as $key => $value) // key=label, value[0]=id
|
foreach($parent as $key => $value) // key=label, value[0]=id
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user