Clean code
This commit is contained in:
parent
b6e9e0e287
commit
96c73a13f6
@ -739,6 +739,21 @@ class ExtraFields
|
||||
// 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);
|
||||
|
||||
@ -778,6 +793,7 @@ class ExtraFields
|
||||
$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;
|
||||
@ -795,23 +811,7 @@ class ExtraFields
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -1072,11 +1072,11 @@ class Form
|
||||
// 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 != '')
|
||||
|
||||
@ -127,6 +127,11 @@ class modMyModule extends DolibarrModules
|
||||
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))
|
||||
{
|
||||
|
||||
@ -203,7 +203,9 @@ class CompanyPaymentMode extends CommonObject
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->createCommon($user, $notrigger);
|
||||
$idpayment = $this->createCommon($user, $notrigger);
|
||||
|
||||
return $idpayment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1327,7 +1327,6 @@ class Societe extends CommonObject
|
||||
|
||||
$result = 1;
|
||||
|
||||
// Retreive all extrafield
|
||||
// fetch optionals attributes and labels
|
||||
$this->fetch_optionals();
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class Stripe extends CommonObject
|
||||
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;
|
||||
}
|
||||
|
||||
@ -120,6 +120,12 @@ class Stripe extends CommonObject
|
||||
{
|
||||
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_....
|
||||
|
||||
Loading…
Reference in New Issue
Block a user