Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 31, 2018
1 parent b6e9e0e commit 96c73a1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
34 changes: 17 additions & 17 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -739,6 +739,21 @@ function fetch_name_optionals_label($elementtype,$forceload=false)
// To avoid conflicts with external modules. TODO Remove this.
if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label;

// Set array of label of entity
$labelmulticompany=array();
if (!empty($conf->multicompany->enabled))
{
$sql_entity_name='SELECT rowid, label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid in (0,'.$conf->entity.')';
$resql_entity_name=$this->db->query($sql_entity_name);
if ($resql_entity_name)
{
while ($obj = $this->db->fetch_object($resql_entity_name))
{
$labelmulticompany[$obj->rowid]=$obj->label;
}
}
}

// We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management.
dol_syslog("fetch_name_optionals_label elementtype=".$elementtype);

Expand Down Expand Up @@ -778,6 +793,7 @@ function fetch_name_optionals_label($elementtype,$forceload=false)
$this->attribute_langfile[$tab->name]=$tab->langs;
$this->attribute_list[$tab->name]=$tab->list;
$this->attribute_entityid[$tab->name]=$tab->entity;
$this->attribute_entitylabel[$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]);

// New usage
$this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type;
Expand All @@ -795,23 +811,7 @@ function fetch_name_optionals_label($elementtype,$forceload=false)
$this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs;
$this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list;
$this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity;

if (!empty($conf->multicompany->enabled))
{
$sql_entity_name='SELECT label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid='.$tab->entity;
$resql_entity_name=$this->db->query($sql_entity_name);
if ($resql_entity_name)
{
if ($this->db->num_rows($resql_entity_name))
{
if ($obj = $this->db->fetch_object($resql_entity_name))
{
$this->attribute_entitylabel[$tab->name]=$obj->label; // Old usage
$this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=$obj->label;
}
}
}
}
$this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]);

$this->attributes[$tab->elementtype]['loaded']=1;
}
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -1072,11 +1072,11 @@ function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showe
// On recherche les societes
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id;
if (! empty($user->socid)) $sql.= " AND s.rowid = ".$user->socid;
if ($filter) $sql.= " AND (".$filter.")";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status <> 0";
// Add criteria
if ($filterkey && $filterkey != '')
Expand Down
Expand Up @@ -127,6 +127,11 @@ public function __construct($db)
1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
);

// Some keys to add into the overwriting translation tables
/*$this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/

if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled))
{
Expand Down
4 changes: 3 additions & 1 deletion htdocs/societe/class/companypaymentmode.class.php
Expand Up @@ -203,7 +203,9 @@ public function __construct(DoliDB $db)
*/
public function create(User $user, $notrigger = false)
{
return $this->createCommon($user, $notrigger);
$idpayment = $this->createCommon($user, $notrigger);

return $idpayment;
}

/**
Expand Down
1 change: 0 additions & 1 deletion htdocs/societe/class/societe.class.php
Expand Up @@ -1327,7 +1327,6 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='

$result = 1;

// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
}
Expand Down
8 changes: 7 additions & 1 deletion htdocs/stripe/class/stripe.class.php
Expand Up @@ -86,7 +86,7 @@ public function getStripeAccount($mode='StripeTest')
dol_print_error($this->db);
}

dol_syslog("No dedicated Stipe Connect account available for entity".$conf->entity);
dol_syslog("No dedicated Stripe Connect account available for entity ".$conf->entity);
return $key;
}

Expand Down Expand Up @@ -120,6 +120,12 @@ public function customerStripe(Societe $object, $key='', $status=0, $createifnot
{
global $conf, $user;

if (empty($object->id))
{
dol_syslog("customerStripe is called with param object not loaded");
return null;
}

$customer = null;

$sql = "SELECT sa.key_account as key_account, sa.entity"; // key_account is cus_....
Expand Down

0 comments on commit 96c73a1

Please sign in to comment.