Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2019-11-16 22:24:29 +00:00
parent e7276f9044
commit 1648fc142e
11 changed files with 1108 additions and 1108 deletions

View File

@ -99,9 +99,9 @@ class AdherentType extends CommonObject
public $mail_valid;
/** @var array Array of members */
public $members=array();
public $members = array();
public $multilangs=array();
public $multilangs = array();
/**
@ -127,8 +127,8 @@ class AdherentType extends CommonObject
$current_lang = $langs->getDefaultLang();
$sql = "SELECT lang, label, description, email";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id;
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id;
$result = $this->db->query($sql);
if ($result) {
@ -138,7 +138,7 @@ class AdherentType extends CommonObject
if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales.
{
$this->label = $obj->label;
$this->description = $obj->description;
$this->description = $obj->description;
$this->email = $obj->email;
}
$this->multilangs["$obj->lang"]["label"] = $obj->label;
@ -149,7 +149,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error="Error: ".$this->db->lasterror()." - ".$sql;
$this->error = "Error: ".$this->db->lasterror()." - ".$sql;
return -1;
}
}
@ -171,75 +171,75 @@ class AdherentType extends CommonObject
{
if ($key == $current_lang) {
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id;
$sql.= " AND lang='".$key."'";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id;
$sql .= " AND lang='".$key."'";
$result = $this->db->query($sql);
if ($this->db->num_rows($result)) // if there is already a description line for this language
{
$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2.= " SET ";
$sql2.= " label='".$this->db->escape($this->label)."',";
$sql2.= " description='".$this->db->escape($this->description)."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'";
$sql2 .= " SET ";
$sql2 .= " label='".$this->db->escape($this->label)."',";
$sql2 .= " description='".$this->db->escape($this->description)."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->other)."'";
}
$sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
}
else
{
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email";
}
$sql2.= ")";
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',";
$sql2.= " '".$this->db->escape($this->description)."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'";
$sql2 .= ")";
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
$sql2 .= " '".$this->db->escape($this->description)."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->other)."'";
}
$sql2.= ")";
$sql2 .= ")";
}
dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
if (! $this->db->query($sql2)) {
$this->error=$this->db->lasterror();
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
}
elseif (isset($this->multilangs[$key])) {
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id;
$sql.= " AND lang='".$key."'";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id;
$sql .= " AND lang='".$key."'";
$result = $this->db->query($sql);
if ($this->db->num_rows($result)) // if there is already a description line for this language
{
$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2.= " SET ";
$sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'";
$sql2 .= " SET ";
$sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'";
}
$sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
}
else
{
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email";
}
$sql2.= ")";
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'";
$sql2 .= ")";
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'";
}
$sql2.= ")";
$sql2 .= ")";
}
// We do not save if main fields are empty
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
if (! $this->db->query($sql2)) {
$this->error=$this->db->lasterror();
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
}
@ -272,7 +272,7 @@ class AdherentType extends CommonObject
public function delMultiLangs($langtodelete, $user)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
$sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
$result = $this->db->query($sql);
@ -289,7 +289,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
return -1;
}
@ -306,22 +306,22 @@ class AdherentType extends CommonObject
{
global $langs, $conf;
$error=0;
$error = 0;
$this->statut=(int) $this->statut;
$this->label=trim($this->label);
$this->statut = (int) $this->statut;
$this->label = trim($this->label);
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= " morphy";
$sql.= ", libelle";
$sql.= ", entity";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->morphy)."'";
$sql.= ", '".$this->db->escape($this->label)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
$sql .= " morphy";
$sql .= ", libelle";
$sql .= ", entity";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->morphy)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", ".$conf->entity;
$sql .= ")";
dol_syslog("Adherent_type::create", LOG_DEBUG);
$result = $this->db->query($sql);
@ -336,15 +336,15 @@ class AdherentType extends CommonObject
return -3;
}
if (! $notrigger)
if (!$notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_CREATE', $user);
$result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return $this->id;
@ -358,7 +358,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -375,23 +375,23 @@ class AdherentType extends CommonObject
{
global $langs, $conf, $hookmanager;
$error=0;
$error = 0;
$this->label=trim($this->label);
$this->label = trim($this->label);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET ";
$sql.= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
$sql.= "morphy = '".$this->db->escape($this->morphy) ."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."',";
$sql.= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = ".(integer) $this->db->escape($this->vote).",";
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql.= " WHERE rowid =".$this->id;
$sql .= "SET ";
$sql .= "statut = ".$this->statut.",";
$sql .= "libelle = '".$this->db->escape($this->label)."',";
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
$sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
$sql .= "note = '".$this->db->escape($this->note)."',";
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
$sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql .= " WHERE rowid =".$this->id;
$result = $this->db->query($sql);
if ($result)
@ -399,34 +399,34 @@ class AdherentType extends CommonObject
$this->description = $this->db->escape($this->note);
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) {
if (!empty($conf->global->MAIN_MULTILANGS)) {
if ($this->setMultiLangs($user) < 0) {
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
$this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
return -2;
}
}
$action='update';
$action = 'update';
// Actions on extra fields
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
if (!$error && !$notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_MODIFY', $user);
$result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return 1;
@ -440,7 +440,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -458,13 +458,13 @@ class AdherentType extends CommonObject
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE rowid = ".$this->id;
$sql .= " WHERE rowid = ".$this->id;
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_DELETE', $user);
$result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
// End call triggers
@ -474,7 +474,7 @@ class AdherentType extends CommonObject
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -495,7 +495,7 @@ class AdherentType extends CommonObject
dol_syslog("Adherent_type::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
@ -506,10 +506,10 @@ class AdherentType extends CommonObject
$this->ref = $obj->rowid;
$this->label = $obj->label;
$this->morphy = $obj->morphy;
$this->statut = $obj->status; // deprecated
$this->statut = $obj->status; // deprecated
$this->status = $obj->status;
$this->duration = $obj->duration;
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1);
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
$this->duration_unit = substr($obj->duration, -1);
$this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid;
@ -517,7 +517,7 @@ class AdherentType extends CommonObject
$this->vote = $obj->vote;
// multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) {
if (!empty($conf->global->MAIN_MULTILANGS)) {
$this->getMultiLangs();
}
}
@ -526,7 +526,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -540,15 +540,15 @@ class AdherentType extends CommonObject
public function liste_array()
{
// phpcs:enable
global $conf,$langs;
global $conf, $langs;
$adherenttypes = array();
$sql = "SELECT rowid, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE entity IN (".getEntity('member_type').")";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql .= " WHERE entity IN (".getEntity('member_type').")";
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
@ -585,13 +585,13 @@ class AdherentType extends CommonObject
{
global $conf, $user;
$ret=array();
$ret = array();
$sql = "SELECT a.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.entity IN (".getEntity('member').")";
$sql.= " AND a.fk_adherent_type = ".$this->id;
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql .= " WHERE a.entity IN (".getEntity('member').")";
$sql .= " AND a.fk_adherent_type = ".$this->id;
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -599,31 +599,31 @@ class AdherentType extends CommonObject
{
while ($obj = $this->db->fetch_object($resql))
{
if (! array_key_exists($obj->rowid, $ret))
if (!array_key_exists($obj->rowid, $ret))
{
if ($mode < 2)
{
$memberstatic=new Adherent($this->db);
$memberstatic = new Adherent($this->db);
if ($mode == 1) {
$memberstatic->fetch($obj->rowid, '', '', '', false, false);
} else {
$memberstatic->fetch($obj->rowid);
}
$ret[$obj->rowid]=$memberstatic;
$ret[$obj->rowid] = $memberstatic;
}
else $ret[$obj->rowid]=$obj->rowid;
else $ret[$obj->rowid] = $obj->rowid;
}
}
$this->db->free($resql);
$this->members=$ret;
$this->members = $ret;
return $ret;
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -655,15 +655,15 @@ class AdherentType extends CommonObject
{
global $langs;
$result='';
$label=$langs->trans("ShowTypeCard", $this->label);
$result = '';
$label = $langs->trans("ShowTypeCard", $this->label);
$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label, $maxlen):$this->label);
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
$result .= $linkend;
return $result;
@ -723,10 +723,10 @@ class AdherentType extends CommonObject
{
// phpcs:enable
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==1) $dn=$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
$dn = '';
if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
return $dn;
}
@ -741,27 +741,27 @@ class AdherentType extends CommonObject
public function _load_ldap_info()
{
// phpcs:enable
global $conf,$langs;
global $conf, $langs;
$info=array();
$info = array();
// Object classes
$info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
$info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
// Champs
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
{
$valueofldapfield=array();
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
$valueofldapfield = array();
foreach ($this->members as $key=>$val) // This is array of users for group into dolibarr database.
{
$member=new Adherent($this->db);
$member = new Adherent($this->db);
$member->fetch($val->id, '', '', '', false, false);
$info2 = $member->_load_ldap_info();
$valueofldapfield[] = $member->_load_ldap_dn($info2);
}
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield : '');
}
return $info;
}
@ -780,18 +780,18 @@ class AdherentType extends CommonObject
// Initialise parametres
$this->id = 0;
$this->ref = 'MTSPEC';
$this->specimen=1;
$this->specimen = 1;
$this->label='MEMBERS TYPE SPECIMEN';
$this->note='This is a note';
$this->mail_valid='This is welcome email';
$this->subscription=1;
$this->vote=0;
$this->label = 'MEMBERS TYPE SPECIMEN';
$this->note = 'This is a note';
$this->mail_valid = 'This is welcome email';
$this->subscription = 1;
$this->vote = 0;
$this->statut=1;
$this->statut = 1;
// Members of this member type is just me
$this->members=array(
$this->members = array(
$user->id => $user
);
}
@ -805,7 +805,7 @@ class AdherentType extends CommonObject
{
global $conf;
if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
{
return $this->mail_valid;
}
@ -823,7 +823,7 @@ class AdherentType extends CommonObject
global $conf;
// mail_subscription not defined so never used
if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
{
return $this->mail_subscription;
}
@ -841,7 +841,7 @@ class AdherentType extends CommonObject
global $conf;
// NOTE mail_resiliate not defined so never used
if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
{
return $this->mail_resiliate;
}

View File

@ -78,16 +78,16 @@ class Categories extends DolibarrApi
*/
public function get($id, $include_childs = false)
{
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if ( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@ -126,50 +126,50 @@ class Categories extends DolibarrApi
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
$sql.= ' WHERE t.entity IN ('.getEntity('category').')';
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as t";
$sql .= ' WHERE t.entity IN ('.getEntity('category').')';
if (!empty($type))
{
$sql.= ' AND t.type='.array_search($type, Categories::$TYPES);
$sql .= ' AND t.type='.array_search($type, Categories::$TYPES);
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result)
{
$i=0;
$i = 0;
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$category_static = new Categorie($db);
if($category_static->fetch($obj->rowid)) {
if ($category_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($category_static);
}
$i++;
@ -178,7 +178,7 @@ class Categories extends DolibarrApi
else {
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
if (!count($obj_ret)) {
throw new RestException(404, 'No category found');
}
return $obj_ret;
@ -192,14 +192,14 @@ class Categories extends DolibarrApi
*/
public function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
if (!DolibarrApiAccess::$user->rights->categorie->creer) {
throw new RestException(401);
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
foreach ($request_data as $field => $value) {
$this->category->$field = $value;
}
if ($this->category->create(DolibarrApiAccess::$user) < 0) {
@ -217,20 +217,20 @@ class Categories extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
if (!DolibarrApiAccess::$user->rights->categorie->creer) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ( ! DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
$this->category->$field = $value;
}
@ -253,19 +253,19 @@ class Categories extends DolibarrApi
*/
public function delete($id)
{
if(! DolibarrApiAccess::$user->rights->categorie->supprimer) {
if (!DolibarrApiAccess::$user->rights->categorie->supprimer) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ( ! DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (! $this->category->delete(DolibarrApiAccess::$user)) {
if (!$this->category->delete(DolibarrApiAccess::$user)) {
throw new RestException(401, 'error when delete category');
}
@ -306,21 +306,21 @@ class Categories extends DolibarrApi
throw new RestException(401);
}
if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) {
if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) {
} elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) {
} elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) {
} elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) {
} elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401);
}
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
if( ! is_array($categories)) {
if (!is_array($categories)) {
if ($categories == 0) {
throw new RestException(404, 'No category found for this object');
}
@ -347,37 +347,37 @@ class Categories extends DolibarrApi
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ($type === Categorie::TYPE_PRODUCT) {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
}
$object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401);
}
$object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
}
$object = new Adherent($this->db);
@ -388,7 +388,7 @@ class Categories extends DolibarrApi
if (!empty($object)) {
$result = $object->fetch($object_id);
if ($result > 0) {
$result=$this->category->add_type($object, $type);
$result = $this->category->add_type($object, $type);
if ($result < 0) {
if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
@ -427,37 +427,37 @@ class Categories extends DolibarrApi
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ($type === Categorie::TYPE_PRODUCT) {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
}
$object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401);
}
$object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
}
$object = new Adherent($this->db);
@ -468,7 +468,7 @@ class Categories extends DolibarrApi
if (!empty($object)) {
$result = $object->fetch('', $object_ref);
if ($result > 0) {
$result=$this->category->add_type($object, $type);
$result = $this->category->add_type($object, $type);
if ($result < 0) {
if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
@ -507,37 +507,37 @@ class Categories extends DolibarrApi
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ($type === Categorie::TYPE_PRODUCT) {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
}
$object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401);
}
$object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
}
$object = new Adherent($this->db);
@ -548,7 +548,7 @@ class Categories extends DolibarrApi
if (!empty($object)) {
$result = $object->fetch((int) $object_id);
if ($result > 0) {
$result=$this->category->del_type($object, $type);
$result = $this->category->del_type($object, $type);
if ($result < 0) {
throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
}
@ -585,37 +585,37 @@ class Categories extends DolibarrApi
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
$result = $this->category->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if ($type === Categorie::TYPE_PRODUCT) {
if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) {
throw new RestException(401);
}
$object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) {
if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401);
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401);
}
$object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
}
$object = new Adherent($this->db);
@ -626,7 +626,7 @@ class Categories extends DolibarrApi
if (!empty($object)) {
$result = $object->fetch('', (string) $object_ref);
if ($result > 0) {
$result=$this->category->del_type($object, $type);
$result = $this->category->del_type($object, $type);
if ($result < 0) {
throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
}
@ -736,7 +736,7 @@ class Categories extends DolibarrApi
{
dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
@ -746,11 +746,11 @@ class Categories extends DolibarrApi
}
$result = $this->category->fetch($id);
if (! $result) {
if (!$result) {
throw new RestException(404, 'category not found');
}
if (! DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}

View File

@ -781,18 +781,18 @@ class Categorie extends CommonObject
$objs = array();
$obj = new $this->MAP_OBJ_CLASS[$type]( $this->db );
$obj = new $this->MAP_OBJ_CLASS[$type]($this->db);
$sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type];
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c";
$sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o";
$sql .= " WHERE o.entity IN (" . getEntity($obj->element).")";
$sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type];
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c";
$sql .= ", ".MAIN_DB_PREFIX.$this->MAP_OBJ_TABLE[$type]." as o";
$sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
$sql .= " AND c.fk_categorie = ".$this->id;
$sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid";
$sql .= " AND c.fk_".$this->MAP_CAT_FK[$type]." = o.rowid";
// Protection for external users
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0)
{
$sql.= " AND o.rowid = ".$user->socid;
$sql .= " AND o.rowid = ".$user->socid;
}
if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset);
$sql .= $this->db->order($sortfield, $sortorder);
@ -929,7 +929,7 @@ class Categorie extends CommonObject
$categories[$i]['description'] = $category_static->description;
$categories[$i]['color'] = $category_static->color;
$categories[$i]['socid'] = $category_static->socid;
$categories[$i]['ref_ext'] = $category_static->ref_ext;
$categories[$i]['ref_ext'] = $category_static->ref_ext;
$categories[$i]['visible'] = $category_static->visible;
$categories[$i]['type'] = $category_static->type;
$categories[$i]['entity'] = $category_static->entity;
@ -1569,7 +1569,7 @@ class Categorie extends CommonObject
$sql .= " AND rowid = '".$id."'";
}
$res = $this->db->query($sql);
$res = $this->db->query($sql);
if ($res)
{
while ($rec = $this->db->fetch_array($res))

View File

@ -40,39 +40,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->projet->enabled)) {
if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
$langs->loadLangs(array("contracts","orders","companies","bills","products",'compta'));
$langs->loadLangs(array("contracts", "orders", "companies", "bills", "products", 'compta'));
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$socid = GETPOST('socid', 'int');
$id = GETPOST('id', 'int');
$ref=GETPOST('ref', 'alpha');
$origin=GETPOST('origin', 'alpha');
$originid=GETPOST('originid', 'int');
$ref = GETPOST('ref', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
$datecontrat='';
$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0);
$datecontrat = '';
$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0);
// Security check
if ($user->socid) $socid=$user->socid;
$result=restrictedArea($user, 'contrat', $id);
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'contrat', $id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('contractcard','globalcard'));
$hookmanager->initHooks(array('contractcard', 'globalcard'));
$object = new Contrat($db);
$extrafields = new ExtraFields($db);
// Load object
if ($id > 0 || ! empty($ref) && $action!='add') {
if ($id > 0 || !empty($ref) && $action != 'add') {
$ret = $object->fetch($id, $ref);
if ($ret > 0)
$ret = $object->fetch_thirdparty();
@ -444,8 +444,8 @@ if (empty($reshook))
$error++;
}
$date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
$date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
if (!empty($date_start) && !empty($date_end) && $date_start > $date_end)
{
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
@ -528,46 +528,46 @@ if (empty($reshook))
{
if ($price_base_type != 'HT')
{
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU');
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
}
else
{
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
}
}
$desc=$prod->description;
$desc=dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
$desc = $prod->description;
$desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
$fk_unit = $prod->fk_unit;
}
else
{
$pu_ht=GETPOST('price_ht');
$pu_ht = GETPOST('price_ht');
$price_base_type = 'HT';
$tva_tx=GETPOST('tva_tx')?str_replace('*', '', GETPOST('tva_tx')):0; // tva_tx field may be disabled, so we use vat rate 0
$tva_npr=preg_match('/\*/', GETPOST('tva_tx'))?1:0;
$desc=$product_desc;
$fk_unit= GETPOST('units', 'alpha');
$tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0
$tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0;
$desc = $product_desc;
$fk_unit = GETPOST('units', 'alpha');
}
$localtax1_tx=get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
$localtax2_tx=get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
// ajout prix achat
$fk_fournprice = $_POST['fournprice'];
if ( ! empty($_POST['buying_price']) )
if (!empty($_POST['buying_price']))
$pa_ht = $_POST['buying_price'];
else
$pa_ht = null;
$info_bits=0;
$info_bits = 0;
if ($tva_npr) $info_bits |= 0x01;
if (((! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance))
|| empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && ($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min))))
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance))
|| empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))))
{
$object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
$result = -1 ;
$result = -1;
}
else
{
@ -1239,34 +1239,34 @@ if ($action == 'create')
print "</td></tr>";
// Project
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
$langs->load('projects');
$formproject=new FormProjets($db);
$formproject = new FormProjets($db);
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$formproject->select_projects(($soc->id>0?$soc->id:-1), $projectid, "projectid", 0, 0, 1, 1);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">' . $langs->trans("AddProject") . '</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, "projectid", 0, 0, 1, 1);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
print "</td></tr>";
}
print '<tr><td>'.$langs->trans("NotePublic").'</td><td class="tdtop">';
$doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
$doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
if (empty($user->socid))
{
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td class="tdtop">';
$doleditor=new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
$doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
}
// Other attributes
$parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Other attributes
@ -1389,62 +1389,62 @@ else
// Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='';
if (! empty($modCodeContract->code_auto)) {
$morehtmlref.=$object->ref;
$morehtmlref = '';
if (!empty($modCodeContract->code_auto)) {
$morehtmlref .= $object->ref;
} else {
$morehtmlref.=$form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3);
$morehtmlref.=$form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
$morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3);
$morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
}
$morehtmlref.='<div class="refidno">';
$morehtmlref .= '<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
// Ref supplier
$morehtmlref.='<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
$morehtmlref .= '<br>';
$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)';
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)';
// Project
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify') {
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref.='';
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>';
$morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
@ -1619,7 +1619,7 @@ else
// Quantity
print '<td class="center">'.$objp->qty.'</td>';
// Unit
if($conf->global->PRODUCT_USE_UNITS) print '<td class="left">'.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).'</td>';
if ($conf->global->PRODUCT_USE_UNITS) print '<td class="left">'.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).'</td>';
// Discount
if ($objp->remise_percent > 0)
{
@ -1717,32 +1717,32 @@ else
print '<td>';
if ($objp->fk_product)
{
$productstatic->id=$objp->fk_product;
$productstatic->type=$objp->ptype;
$productstatic->ref=$objp->pref;
$productstatic->entity=$objp->pentity;
$productstatic->id = $objp->fk_product;
$productstatic->type = $objp->ptype;
$productstatic->ref = $objp->pref;
$productstatic->entity = $objp->pentity;
print $productstatic->getNomUrl(1, '', 32);
print $objp->label?' - '.dol_trunc($objp->label, 32):'';
print $objp->label ? ' - '.dol_trunc($objp->label, 32) : '';
print '<br>';
}
else
{
print $objp->label?$objp->label.'<br>':'';
print $objp->label ? $objp->label.'<br>' : '';
}
// editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
$doleditor=new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%');
$nbrows = ROWS_2;
if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
$doleditor = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%');
$doleditor->Create();
print '</td>';
// VAT
print '<td class="right">';
print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1);
print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code ? (' ('.$objp->vat_src_code.')') : ''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1);
print '</td>';
// Price
@ -1767,7 +1767,7 @@ else
// Discount
print '<td class="nowrap right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
if (! empty($usemargins))
if (!empty($usemargins))
{
print '<td class="right">';
if ($objp->fk_product) print '<select id="fournprice" name="fournprice"></select>';
@ -1885,27 +1885,27 @@ else
// Area with status and activation info of line
if ($object->statut > 0)
{
print '<table class="notopnoleftnoright tableforservicepart2'.($cursorline < $nbofservices ?' boxtablenobottom':'').'" width="100%">';
print '<table class="notopnoleftnoright tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).'</td>';
print '<td>'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).'</td>';
print '<td width="30" class="right">';
if ($user->socid == 0)
{
if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline')
{
$tmpaction='activateline';
$tmpactionpicto='play';
$tmpactiontext=$langs->trans("Activate");
$tmpaction = 'activateline';
$tmpactionpicto = 'play';
$tmpactiontext = $langs->trans("Activate");
if ($objp->statut == 4)
{
$tmpaction='unactivateline';
$tmpactionpicto='playstop';
$tmpactiontext=$langs->trans("Disable");
$tmpaction = 'unactivateline';
$tmpactionpicto = 'playstop';
$tmpactiontext = $langs->trans("Disable");
}
if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver))
if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver))
{
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;ligne=' . $object->lines[$cursorline - 1]->id . '&amp;action=' . $tmpaction . '">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;ligne='.$object->lines[$cursorline - 1]->id.'&amp;action='.$tmpaction.'">';
print img_picto($tmpactiontext, $tmpactionpicto);
print '</a>';
}
@ -2060,24 +2060,24 @@ else
// Form to add new line
if ($user->rights->contrat->creer && ($object->statut == 0))
{
$dateSelector=1;
$dateSelector = 1;
print "\n";
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline')?'#add':'#line_'.GETPOST('lineid')).'" method="POST">
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid')).'" method="POST">
<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">
<input type="hidden" name="action" value="'.(($action != 'editline')?'addline':'updateline').'">
<input type="hidden" name="action" value="'.(($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="'.$object->id.'">
';
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines
print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines
// Form to add new line
if ($action != 'editline')
{
$forcetoshowtitlelines=1;
if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts
$forcetoshowtitlelines = 1;
if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts
// Add free products/services
$object->formAddObjectLine(1, $mysoc, $soc);

File diff suppressed because it is too large Load Diff

View File

@ -178,7 +178,7 @@ class Conf
if ($value && preg_match('/^MAIN_MODULE_/', $key))
{
$reg=array();
$reg = array();
// If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key))
{
@ -224,11 +224,11 @@ class Conf
}
// Include other local consts.php files and fetch their values to the corresponding database constants.
if (! empty($this->global->LOCAL_CONSTS_FILES)) {
if (!empty($this->global->LOCAL_CONSTS_FILES)) {
$filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
foreach ($filesList as $file) {
$file=dol_sanitizeFileName($file);
include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars.
$file = dol_sanitizeFileName($file);
include_once DOL_DOCUMENT_ROOT."/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars.
}
}
@ -326,33 +326,33 @@ class Conf
}
// For mycompany storage
$this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
$this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp");
$this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
$this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp");
// For backward compatibility
$this->mycompany->dir_output=$rootfordata."/mycompany";
$this->mycompany->dir_temp=$rootfordata."/mycompany/temp";
$this->mycompany->dir_output = $rootfordata."/mycompany";
$this->mycompany->dir_temp = $rootfordata."/mycompany/temp";
// For admin storage
$this->admin->dir_output=$rootfordata.'/admin';
$this->admin->dir_temp=$rootfordata.'/admin/temp';
$this->admin->dir_output = $rootfordata.'/admin';
$this->admin->dir_temp = $rootfordata.'/admin/temp';
// For user storage
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
// For backward compatibility
$this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp";
$this->user->dir_output = $rootforuser."/users";
$this->user->dir_temp = $rootforuser."/users/temp";
// For usergroup storage
$this->usergroup->dir_output=$rootforuser."/usergroups";
$this->usergroup->dir_temp=$rootforuser."/usergroups/temp";
$this->usergroup->dir_output = $rootforuser."/usergroups";
$this->usergroup->dir_temp = $rootforuser."/usergroups/temp";
// For proposal storage
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
$this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp");
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
$this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp");
// For backward compatibility
$this->propal->dir_output=$rootfordata."/propale";
$this->propal->dir_temp=$rootfordata."/propale/temp";
$this->propal->dir_output = $rootfordata."/propale";
$this->propal->dir_temp = $rootfordata."/propale/temp";
// For bank storage
$this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
@ -361,107 +361,107 @@ class Conf
$this->bank->dir_temp = $rootfordata."/bank/temp";
// For medias storage
$this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
$this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp");
$this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
$this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp");
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
// Sous module bons d'expedition
$this->expedition_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_EXPEDITION)?$this->global->MAIN_SUBMODULE_EXPEDITION:0);
$this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0);
// Sous module bons de livraison
$this->livraison_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_LIVRAISON)?$this->global->MAIN_SUBMODULE_LIVRAISON:0);
$this->livraison_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_LIVRAISON) ? $this->global->MAIN_SUBMODULE_LIVRAISON : 0);
// Module fournisseur
// TODO To split into module supplier_invoice and supplier_order
if (! empty($this->fournisseur))
if (!empty($this->fournisseur))
{
$this->fournisseur->commande=new stdClass();
$this->fournisseur->commande->multidir_output=array($this->entity => $rootfordata."/fournisseur/commande");
$this->fournisseur->commande->multidir_temp =array($this->entity => $rootfordata."/fournisseur/commande/temp");
$this->fournisseur->commande->dir_output=$rootfordata."/fournisseur/commande"; // For backward compatibility
$this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp"; // For backward compatibility
$this->fournisseur->facture=new stdClass();
$this->fournisseur->facture->multidir_output=array($this->entity => $rootfordata."/fournisseur/facture");
$this->fournisseur->facture->multidir_temp =array($this->entity => $rootfordata."/fournisseur/facture/temp");
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture"; // For backward compatibility
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp"; // For backward compatibility
$this->fournisseur->commande = new stdClass();
$this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->fournisseur->commande->multidir_temp = array($this->entity => $rootfordata."/fournisseur/commande/temp");
$this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
$this->fournisseur->commande->dir_temp = $rootfordata."/fournisseur/commande/temp"; // For backward compatibility
$this->fournisseur->facture = new stdClass();
$this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
$this->fournisseur->facture->multidir_temp = array($this->entity => $rootfordata."/fournisseur/facture/temp");
$this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
$this->fournisseur->facture->dir_temp = $rootfordata."/fournisseur/facture/temp"; // For backward compatibility
$this->fournisseur->payment=new stdClass();
$this->fournisseur->payment->multidir_output=array($this->entity => $rootfordata."/fournisseur/payment");
$this->fournisseur->payment->multidir_temp =array($this->entity => $rootfordata."/fournisseur/payment/temp");
$this->fournisseur->payment->dir_output =$rootfordata."/fournisseur/payment"; // For backward compatibility
$this->fournisseur->payment->dir_temp =$rootfordata."/fournisseur/payment/temp"; // For backward compatibility
$this->fournisseur->payment = new stdClass();
$this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
$this->fournisseur->payment->multidir_temp = array($this->entity => $rootfordata."/fournisseur/payment/temp");
$this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
$this->fournisseur->payment->dir_temp = $rootfordata."/fournisseur/payment/temp"; // For backward compatibility
// To prepare split of module vendor(fournisseur) into vendor + supplier_order + supplier_invoice + supplierproposal
if (! empty($this->fournisseur->enabled)) // By default, if module supplier is on, we set new properties
if (!empty($this->fournisseur->enabled)) // By default, if module supplier is on, we set new properties
{
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists
{
$this->supplier_order=new stdClass();
$this->supplier_order->enabled=1;
$this->supplier_order->multidir_output=array($this->entity => $rootfordata."/fournisseur/commande");
$this->supplier_order->multidir_temp =array($this->entity => $rootfordata."/fournisseur/commande/temp");
$this->supplier_order->dir_output=$rootfordata."/fournisseur/commande"; // For backward compatibility
$this->supplier_order->dir_temp=$rootfordata."/fournisseur/commande/temp"; // For backward compatibility
$this->supplier_order = new stdClass();
$this->supplier_order->enabled = 1;
$this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->supplier_order->multidir_temp = array($this->entity => $rootfordata."/fournisseur/commande/temp");
$this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
$this->supplier_order->dir_temp = $rootfordata."/fournisseur/commande/temp"; // For backward compatibility
}
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists
{
$this->supplier_invoice=new stdClass();
$this->supplier_invoice->enabled=1;
$this->supplier_invoice->multidir_output=array($this->entity => $rootfordata."/fournisseur/facture");
$this->supplier_invoice->multidir_temp =array($this->entity => $rootfordata."/fournisseur/facture/temp");
$this->supplier_invoice->dir_output=$rootfordata."/fournisseur/facture"; // For backward compatibility
$this->supplier_invoice->dir_temp=$rootfordata."/fournisseur/facture/temp"; // For backward compatibility
$this->supplier_invoice = new stdClass();
$this->supplier_invoice->enabled = 1;
$this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
$this->supplier_invoice->multidir_temp = array($this->entity => $rootfordata."/fournisseur/facture/temp");
$this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
$this->supplier_invoice->dir_temp = $rootfordata."/fournisseur/facture/temp"; // For backward compatibility
}
}
}
// Module product/service
$this->product->multidir_output=array($this->entity => $rootfordata."/produit");
$this->product->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
$this->service->multidir_output=array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
$this->product->multidir_output = array($this->entity => $rootfordata."/produit");
$this->product->multidir_temp = array($this->entity => $rootfordata."/produit/temp");
$this->service->multidir_output = array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp = array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility
$this->product->dir_output=$rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp";
$this->product->dir_output = $rootfordata."/produit";
$this->product->dir_temp = $rootfordata."/produit/temp";
$this->service->dir_output = $rootfordata."/produit";
$this->service->dir_temp = $rootfordata."/produit/temp";
// Module productbatch
$this->productbatch->multidir_output=array($this->entity => $rootfordata."/produitlot");
$this->productbatch->multidir_temp =array($this->entity => $rootfordata."/produitlot/temp");
$this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot");
$this->productbatch->multidir_temp = array($this->entity => $rootfordata."/produitlot/temp");
// Module contrat
$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
$this->contrat->multidir_temp = array($this->entity => $rootfordata."/contract/temp");
$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
$this->contrat->multidir_temp = array($this->entity => $rootfordata."/contract/temp");
// For backward compatibility
$this->contrat->dir_output=$rootfordata."/contract";
$this->contrat->dir_temp =$rootfordata."/contract/temp";
$this->contrat->dir_output = $rootfordata."/contract";
$this->contrat->dir_temp = $rootfordata."/contract/temp";
// Module bank
$this->bank->dir_output=$rootfordata."/bank";
$this->bank->dir_temp =$rootfordata."/bank/temp";
$this->bank->dir_output = $rootfordata."/bank";
$this->bank->dir_temp = $rootfordata."/bank/temp";
// Set some default values
//$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
$this->global->MAIN_MAIL_USE_MULTI_PART=1;
$this->global->MAIN_MAIL_USE_MULTI_PART = 1;
// societe
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard";
if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum";
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint';
if (empty($conf->global->TICKET_ADDON)) $this->global->TICKET_ADDON='mod_ticket_simple';
if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
if (empty($conf->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple';
// Security
if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask
if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask
// conf->use_javascript_ajax
$this->use_javascript_ajax=1;
if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax=! $this->global->MAIN_DISABLE_JAVASCRIPT;
$this->use_javascript_ajax = 1;
if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
// If no javascript_ajax, Ajax features are disabled.
if (empty($this->use_javascript_ajax))
{
@ -471,231 +471,231 @@ class Conf
unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
}
if (! empty($this->productbatch->enabled))
if (!empty($this->productbatch->enabled))
{
$this->global->STOCK_CALCULATE_ON_BILL=0;
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0;
$this->global->STOCK_CALCULATE_ON_SHIPMENT=1;
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0;
if(empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
$this->global->STOCK_CALCULATE_ON_BILL = 0;
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
if (empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
else {
$this->global->STOCK_CALCULATE_ON_RECEPTION=1;
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE=0;
$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
}
}
// conf->currency
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR';
$this->currency=$this->global->MAIN_MONNAIE;
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE = 'EUR';
$this->currency = $this->global->MAIN_MONNAIE;
if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
// By default, suppliers objects can be linked to all projects
if (! isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
// By default we enable feature to bill time spent
if (! isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1;
if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1;
// MAIN_HTML_TITLE
if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly';
if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
// conf->liste_limit = constante de taille maximale des listes
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25;
$this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT;
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
$this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
// conf->product->limit_size = constante de taille maximale des select de produit
if (! isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE=1000;
$this->product->limit_size=$this->global->PRODUIT_LIMIT_SIZE;
if (!isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE = 1000;
$this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
// conf->theme et $this->css
if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME="eldy";
if (! empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME=$this->global->MAIN_FORCETHEME;
$this->theme=$this->global->MAIN_THEME;
if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy";
if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
$this->theme = $this->global->MAIN_THEME;
$this->css = "/theme/".$this->theme."/style.css.php";
// conf->email_from = email pour envoi par dolibarr des mails automatiques
$this->email_from = "robot@example.com";
if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
// conf->notification->email_from = email pour envoi par Dolibarr des notifications
$this->notification->email_from=$this->email_from;
if (! empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from=$this->global->NOTIFICATION_EMAIL_FROM;
$this->notification->email_from = $this->email_from;
if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
// conf->mailing->email_from = email pour envoi par Dolibarr des mailings
$this->mailing->email_from=$this->email_from;
if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_EMAIL_FROM;
if (! isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID=1;
$this->mailing->email_from = $this->email_from;
if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
// Format for date (used by default when not found or not searched in lang)
$this->format_date_short="%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
$this->format_date_short_java="dd/MM/yyyy"; // Format of day with Java tags
$this->format_hour_short="%H:%M";
$this->format_hour_short_duration="%H:%M";
$this->format_date_text_short="%d %b %Y";
$this->format_date_text="%d %B %Y";
$this->format_date_hour_short="%d/%m/%Y %H:%M";
$this->format_date_hour_sec_short="%d/%m/%Y %H:%M:%S";
$this->format_date_hour_text_short="%d %b %Y %H:%M";
$this->format_date_hour_text="%d %B %Y %H:%M";
$this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
$this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
$this->format_hour_short = "%H:%M";
$this->format_hour_short_duration = "%H:%M";
$this->format_date_text_short = "%d %b %Y";
$this->format_date_text = "%d %B %Y";
$this->format_date_hour_short = "%d/%m/%Y %H:%M";
$this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
$this->format_date_hour_text_short = "%d %b %Y %H:%M";
$this->format_date_hour_text = "%d %B %Y %H:%M";
// Duration of workday
if (! isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY=86400;
if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
// Limites decimales si non definie (peuvent etre egale a 0)
if (! isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT=5;
if (! isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT=2;
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8;
if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT = 2;
if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
// Default pdf option
if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines
if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text
if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
// Default max file size for upload
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
// By default, we propagate contacts
if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
// By default, we do not use the zip town table but the table of third parties
if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0;
if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
// By default, we open card if one found
if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1;
if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
// By default, we show state code in combo list
if (! isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE=1;
if (!isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE = 1;
// Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
if (! isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=1;
if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (! empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (!empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
{
foreach($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL.=",".$key;
foreach ($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
}
// Enable select2
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2';
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
// Timeouts
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10;
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT=30;
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
// Set default variable to calculate VAT as if option tax_mode was 0 (standard)
if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT='invoice';
if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT='invoice';
if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE='payment';
if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE='payment';
if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment';
if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment';
// Delay before warnings
// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
if (isset($this->agenda)) {
$this->adherent->subscription = new stdClass();
$this->adherent->subscription->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60;
$this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60;
}
if (isset($this->agenda)) {
$this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60;
$this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60;
}
if (isset($this->projet))
{
$this->projet->warning_delay=(isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE)?$this->global->MAIN_DELAY_PROJECT_TO_CLOSE:7)*24*60*60;
$this->projet->task = new StdClass();
$this->projet->task->warning_delay=(isset($this->global->MAIN_DELAY_TASKS_TODO)?$this->global->MAIN_DELAY_TASKS_TODO:7)*24*60*60;
$this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 24 * 60 * 60;
$this->projet->task = new StdClass();
$this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 24 * 60 * 60;
}
if (isset($this->commande)) {
$this->commande->client = new stdClass();
$this->commande->fournisseur = new stdClass();
$this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60;
$this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60;
$this->commande->client = new stdClass();
$this->commande->fournisseur = new stdClass();
$this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 24 * 60 * 60;
$this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 24 * 60 * 60;
}
if (isset($this->propal)) {
$this->propal->cloture = new stdClass();
$this->propal->facturation = new stdClass();
$this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60;
$this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60;
$this->propal->cloture = new stdClass();
$this->propal->facturation = new stdClass();
$this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 24 * 60 * 60;
$this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 24 * 60 * 60;
}
if (isset($this->facture)) {
$this->facture->client = new stdClass();
$this->facture->fournisseur = new stdClass();
$this->facture->client->warning_delay=(isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED)?$this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED:0)*24*60*60;
$this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60;
$this->facture->client = new stdClass();
$this->facture->fournisseur = new stdClass();
$this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 24 * 60 * 60;
$this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 24 * 60 * 60;
}
if (isset($this->contrat)) {
$this->contrat->services = new stdClass();
$this->contrat->services->inactifs = new stdClass();
$this->contrat->services->expires = new stdClass();
$this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60;
$this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60;
$this->contrat->services = new stdClass();
$this->contrat->services->inactifs = new stdClass();
$this->contrat->services->expires = new stdClass();
$this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 24 * 60 * 60;
$this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60;
}
if (isset($this->commande)) {
$this->bank->rappro = new stdClass();
$this->bank->cheque = new stdClass();
$this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60;
$this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60;
$this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 24 * 60 * 60;
$this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 24 * 60 * 60;
}
if (isset($this->expensereport)) {
$this->expensereport->approve = new stdClass();
$this->expensereport->approve->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS)?$this->global->MAIN_DELAY_EXPENSEREPORTS:0)*24*60*60;
$this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 24 * 60 * 60;
$this->expensereport->payment = new stdClass();
$this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60;
$this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 24 * 60 * 60;
}
if (isset($this->holiday)) {
$this->holiday->approve = new stdClass();
$this->holiday->approve->warning_delay=(isset($this->global->MAIN_DELAY_HOLIDAYS)?$this->global->MAIN_DELAY_HOLIDAYS:0)*24*60*60;
$this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 24 * 60 * 60;
}
if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
{
$this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
}
// For modules that want to disable top or left menu
if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU;
if (! empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu=$this->global->MAIN_HIDE_LEFT_MENU;
if (!empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT=3;
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
if (! isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT=0;
if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
// Save inconsistent option
if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (! isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
{
$this->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
$this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
}
if (! isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1;
if (!isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1;
if (! isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0;
if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0;
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
if (! isset($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $conf->global->MAIN_FEATURES_LEVEL >= 2) $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
if (!isset($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $conf->global->MAIN_FEATURES_LEVEL >= 2) $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
// For backward compatibility
if (isset($this->product)) $this->produit=$this->product;
if (isset($this->facture)) $this->invoice=$this->facture;
if (isset($this->commande)) $this->order=$this->commande;
if (isset($this->contrat)) $this->contract=$this->contrat;
if (isset($this->categorie)) $this->category=$this->categorie;
if (isset($this->project)) $this->project=$this->projet;
if (isset($this->product)) $this->produit = $this->product;
if (isset($this->facture)) $this->invoice = $this->facture;
if (isset($this->commande)) $this->order = $this->commande;
if (isset($this->contrat)) $this->contract = $this->contrat;
if (isset($this->categorie)) $this->category = $this->categorie;
if (isset($this->project)) $this->project = $this->projet;
// Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled))
{
if (is_object($mc)) $mc->setValues($this);
}
// We init log handlers
if (! empty($this->global->SYSLOG_HANDLERS)) {
if (!empty($this->global->SYSLOG_HANDLERS)) {
$handlers = json_decode($this->global->SYSLOG_HANDLERS);
} else {
$handlers = array();

View File

@ -56,19 +56,19 @@ class FormWebsite
*/
public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0)
{
$out='';
$out = '';
$sql = "SELECT rowid, ref";
$sql.= " FROM ".MAIN_DB_PREFIX."website";
$sql.= " WHERE 1 = 1";
$sql.= " ORDER BY rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."website";
$sql .= " WHERE 1 = 1";
$sql .= " ORDER BY rowid";
$result = $this->db->query($sql);
if ($result)
{
$out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
$out .= '<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($useempty)
{
$out.='<option value="-1">&nbsp;</option>';
$out .= '<option value="-1">&nbsp;</option>';
}
$num = $this->db->num_rows($result);
@ -78,17 +78,17 @@ class FormWebsite
$obj = $this->db->fetch_object($result);
if ($selected == $obj->rowid)
{
$out.='<option value="'.$obj->rowid.'" selected>';
$out .= '<option value="'.$obj->rowid.'" selected>';
}
else
{
$out.='<option value="'.$obj->rowid.'">';
$out .= '<option value="'.$obj->rowid.'">';
}
$out.=$obj->ref;
$out.='</option>';
$out .= $obj->ref;
$out .= '</option>';
$i++;
}
$out.="</select>";
$out .= "</select>";
}
else {
dol_print_error($this->db);
@ -114,9 +114,9 @@ class FormWebsite
$langs->load("admin");
$sql = "SELECT rowid, code, label, entity";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container';
$sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
$sql.= " ORDER BY label";
$sql .= " FROM ".MAIN_DB_PREFIX.'c_type_container';
$sql .= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
$sql .= " ORDER BY label";
dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG);
$result = $this->db->query($sql);
@ -126,7 +126,7 @@ class FormWebsite
$i = 0;
if ($num)
{
print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || ($useempty == 2 && $num > 1))
{
print '<option value="-1">&nbsp;</option>';
@ -179,8 +179,8 @@ class FormWebsite
$listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$');
$arrayofsamples = array();
$arrayofsamples['empty']='EmptyPage'; // Always this one first
foreach($listofsamples as $sample)
$arrayofsamples['empty'] = 'EmptyPage'; // Always this one first
foreach ($listofsamples as $sample)
{
$reg = array();
if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg))
@ -193,14 +193,14 @@ class FormWebsite
}
$out = '';
$out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
$out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || $useempty == 2)
{
$out .= '<option value="-1">&nbsp;</option>';
}
foreach($arrayofsamples as $key => $val)
foreach ($arrayofsamples as $key => $val)
{
if ($selected == $key)
{
@ -238,57 +238,57 @@ class FormWebsite
$atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
$out='';
$out = '';
if ($atleastonepage && $action != 'editsource')
{
$out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="maxwidth300'.($morecss ? ' '.$morecss : '').'">';
$out .= '<select name="'.$htmlname.'" id="'.$htmlname.'" class="maxwidth300'.($morecss ? ' '.$morecss : '').'">';
}
else
{
$out.='<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ? ' '.$morecss : '').'" disabled="disabled">';
$out .= '<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ? ' '.$morecss : '').'" disabled="disabled">';
}
if ($showempty || ! $atleastonepage) $out.='<option value="-1">&nbsp;</option>';
if ($showempty || !$atleastonepage) $out .= '<option value="-1">&nbsp;</option>';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($website->lines as $key => $valpage)
$firstpageid = 0; $homepageid = 0;
foreach ($website->lines as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id;
if (empty($firstpageid)) $firstpageid = $valpage->id;
if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid = $valpage->id;
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
$pageid = $homepageid ? $homepageid : $firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($website->lines as $key => $valpage)
foreach ($website->lines as $key => $valpage)
{
if (is_array($excludeids) && count($excludeids) && in_array($valpage->id, $excludeids)) continue;
$valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> ';
$valueforoption.= $valpage->pageurl.' - '.$valpage->title;
if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>';
$valueforoption .= $valpage->pageurl.' - '.$valpage->title;
if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption .= ' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>';
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.=' data-html="'.dol_escape_htmltag($valueforoption).'"';
$out.='>';
$out.=$valueforoption;
$out.='</option>';
$out .= '<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out .= ' selected'; // To preselect a value
$out .= ' data-html="'.dol_escape_htmltag($valueforoption).'"';
$out .= '>';
$out .= $valueforoption;
$out .= '</option>';
}
}
$out.='</select>';
$out .= '</select>';
if ($atleastonepage && $action != 'editsource')
{
$out.=ajax_combobox($htmlname);
$out .= ajax_combobox($htmlname);
}
else
{
$out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">';
$out.=ajax_combobox($htmlname);
$out .= '<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">';
$out .= ajax_combobox($htmlname);
}
return $out;
}

View File

@ -173,24 +173,24 @@ class Menubase
global $conf, $langs;
// Clean parameters
$this->menu_handler=trim($this->menu_handler);
$this->module=trim($this->module);
$this->type=trim($this->type);
$this->mainmenu=trim($this->mainmenu);
$this->leftmenu=trim($this->leftmenu);
$this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined
$this->fk_mainmenu=trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu);
$this->menu_handler = trim($this->menu_handler);
$this->module = trim($this->module);
$this->type = trim($this->type);
$this->mainmenu = trim($this->mainmenu);
$this->leftmenu = trim($this->leftmenu);
$this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined
$this->fk_mainmenu = trim($this->fk_mainmenu);
$this->fk_leftmenu = trim($this->fk_leftmenu);
$this->position = (int) $this->position;
$this->url=trim($this->url);
$this->target=trim($this->target);
$this->titre=trim($this->titre);
$this->langs=trim($this->langs);
$this->perms=trim($this->perms);
$this->enabled=trim($this->enabled);
$this->url = trim($this->url);
$this->target = trim($this->target);
$this->titre = trim($this->titre);
$this->langs = trim($this->langs);
$this->perms = trim($this->perms);
$this->enabled = trim($this->enabled);
$this->user = (int) $this->user;
if (empty($this->position)) $this->position=0;
if (! $this->level) $this->level=0;
if (empty($this->position)) $this->position = 0;
if (!$this->level) $this->level = 0;
// Check parameters
if (empty($this->menu_handler)) return -1;
@ -201,32 +201,32 @@ class Menubase
if (in_array($this->db->type, array('pgsql')))
{
$sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu";
$resqlrowid=$this->db->query($sql);
$resqlrowid = $this->db->query($sql);
if ($resqlrowid) {
$obj=$this->db->fetch_object($resqlrowid);
$maxrowid=$obj->maxrowid;
$obj = $this->db->fetch_object($resqlrowid);
$maxrowid = $obj->maxrowid;
// Max rowid can be empty if there is no record yet
if(empty($maxrowid)) $maxrowid=1;
if (empty($maxrowid)) $maxrowid = 1;
$sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")";
//print $sql; exit;
$resqlrowidset=$this->db->query($sql);
if (! $resqlrowidset) dol_print_error($this->db);
$resqlrowidset = $this->db->query($sql);
if (!$resqlrowidset) dol_print_error($this->db);
}
else dol_print_error($this->db);
}
// Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."menu";
$sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
$sql.= " AND fk_menu = ".((int) $this->fk_menu);
$sql.= " AND position = ".((int) $this->position);
$sql.= " AND url = '".$this->db->escape($this->url)."'";
$sql.= " AND entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."menu";
$sql .= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
$sql .= " AND fk_menu = ".((int) $this->fk_menu);
$sql .= " AND position = ".((int) $this->position);
$sql .= " AND url = '".$this->db->escape($this->url)."'";
$sql .= " AND entity = ".$conf->entity;
$result=$this->db->query($sql);
$result = $this->db->query($sql);
if ($result)
{
$row = $this->db->fetch_row($result);
@ -235,45 +235,45 @@ class Menubase
{
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
$sql.= "menu_handler,";
$sql.= "entity,";
$sql.= "module,";
$sql.= "type,";
$sql.= "mainmenu,";
$sql.= "leftmenu,";
$sql.= "fk_menu,";
$sql.= "fk_mainmenu,";
$sql.= "fk_leftmenu,";
$sql.= "position,";
$sql.= "url,";
$sql.= "target,";
$sql.= "titre,";
$sql.= "langs,";
$sql.= "perms,";
$sql.= "enabled,";
$sql.= "usertype";
$sql.= ") VALUES (";
$sql.= " '".$this->db->escape($this->menu_handler)."',";
$sql.= " '".$this->db->escape($conf->entity)."',";
$sql.= " '".$this->db->escape($this->module)."',";
$sql.= " '".$this->db->escape($this->type)."',";
$sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null
$sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").",";
$sql.= " ".((int) $this->fk_menu).",";
$sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
$sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").",";
$sql.= " ".((int) $this->position).",";
$sql.= " '".$this->db->escape($this->url)."',";
$sql.= " '".$this->db->escape($this->target)."',";
$sql.= " '".$this->db->escape($this->titre)."',";
$sql.= " '".$this->db->escape($this->langs)."',";
$sql.= " '".$this->db->escape($this->perms)."',";
$sql.= " '".$this->db->escape($this->enabled)."',";
$sql.= " '".$this->db->escape($this->user)."'";
$sql.= ")";
$sql .= "menu_handler,";
$sql .= "entity,";
$sql .= "module,";
$sql .= "type,";
$sql .= "mainmenu,";
$sql .= "leftmenu,";
$sql .= "fk_menu,";
$sql .= "fk_mainmenu,";
$sql .= "fk_leftmenu,";
$sql .= "position,";
$sql .= "url,";
$sql .= "target,";
$sql .= "titre,";
$sql .= "langs,";
$sql .= "perms,";
$sql .= "enabled,";
$sql .= "usertype";
$sql .= ") VALUES (";
$sql .= " '".$this->db->escape($this->menu_handler)."',";
$sql .= " '".$this->db->escape($conf->entity)."',";
$sql .= " '".$this->db->escape($this->module)."',";
$sql .= " '".$this->db->escape($this->type)."',";
$sql .= " ".($this->mainmenu ? "'".$this->db->escape($this->mainmenu)."'" : "''").","; // Can't be null
$sql .= " ".($this->leftmenu ? "'".$this->db->escape($this->leftmenu)."'" : "null").",";
$sql .= " ".((int) $this->fk_menu).",";
$sql .= " ".($this->fk_mainmenu ? "'".$this->db->escape($this->fk_mainmenu)."'" : "null").",";
$sql .= " ".($this->fk_leftmenu ? "'".$this->db->escape($this->fk_leftmenu)."'" : "null").",";
$sql .= " ".((int) $this->position).",";
$sql .= " '".$this->db->escape($this->url)."',";
$sql .= " '".$this->db->escape($this->target)."',";
$sql .= " '".$this->db->escape($this->titre)."',";
$sql .= " '".$this->db->escape($this->langs)."',";
$sql .= " '".$this->db->escape($this->perms)."',";
$sql .= " '".$this->db->escape($this->enabled)."',";
$sql .= " '".$this->db->escape($this->user)."'";
$sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu");
@ -283,7 +283,7 @@ class Menubase
}
else
{
$this->error="Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -312,22 +312,22 @@ class Menubase
//global $conf, $langs;
// Clean parameters
$this->rowid=trim($this->rowid);
$this->menu_handler=trim($this->menu_handler);
$this->module=trim($this->module);
$this->type=trim($this->type);
$this->mainmenu=trim($this->mainmenu);
$this->leftmenu=trim($this->leftmenu);
$this->rowid = trim($this->rowid);
$this->menu_handler = trim($this->menu_handler);
$this->module = trim($this->module);
$this->type = trim($this->type);
$this->mainmenu = trim($this->mainmenu);
$this->leftmenu = trim($this->leftmenu);
$this->fk_menu = (int) $this->fk_menu;
$this->fk_mainmenu=trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu);
$this->fk_mainmenu = trim($this->fk_mainmenu);
$this->fk_leftmenu = trim($this->fk_leftmenu);
$this->position = (int) $this->position;
$this->url=trim($this->url);
$this->target=trim($this->target);
$this->titre=trim($this->titre);
$this->langs=trim($this->langs);
$this->perms=trim($this->perms);
$this->enabled=trim($this->enabled);
$this->url = trim($this->url);
$this->target = trim($this->target);
$this->titre = trim($this->titre);
$this->langs = trim($this->langs);
$this->perms = trim($this->perms);
$this->enabled = trim($this->enabled);
$this->user = (int) $this->user;
// Check parameters
@ -335,29 +335,29 @@ class Menubase
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
$sql.= " menu_handler='".$this->db->escape($this->menu_handler)."',";
$sql.= " module='".$this->db->escape($this->module)."',";
$sql.= " type='".$this->db->escape($this->type)."',";
$sql.= " mainmenu='".$this->db->escape($this->mainmenu)."',";
$sql.= " leftmenu='".$this->db->escape($this->leftmenu)."',";
$sql.= " fk_menu=".$this->fk_menu.",";
$sql.= " fk_mainmenu=".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
$sql.= " fk_leftmenu=".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").",";
$sql.= " position=".($this->position > 0 ? $this->position : 0).",";
$sql.= " url='".$this->db->escape($this->url)."',";
$sql.= " target='".$this->db->escape($this->target)."',";
$sql.= " titre='".$this->db->escape($this->titre)."',";
$sql.= " langs='".$this->db->escape($this->langs)."',";
$sql.= " perms='".$this->db->escape($this->perms)."',";
$sql.= " enabled='".$this->db->escape($this->enabled)."',";
$sql.= " usertype='".$this->db->escape($this->user)."'";
$sql.= " WHERE rowid=".$this->id;
$sql .= " menu_handler='".$this->db->escape($this->menu_handler)."',";
$sql .= " module='".$this->db->escape($this->module)."',";
$sql .= " type='".$this->db->escape($this->type)."',";
$sql .= " mainmenu='".$this->db->escape($this->mainmenu)."',";
$sql .= " leftmenu='".$this->db->escape($this->leftmenu)."',";
$sql .= " fk_menu=".$this->fk_menu.",";
$sql .= " fk_mainmenu=".($this->fk_mainmenu ? "'".$this->db->escape($this->fk_mainmenu)."'" : "null").",";
$sql .= " fk_leftmenu=".($this->fk_leftmenu ? "'".$this->db->escape($this->fk_leftmenu)."'" : "null").",";
$sql .= " position=".($this->position > 0 ? $this->position : 0).",";
$sql .= " url='".$this->db->escape($this->url)."',";
$sql .= " target='".$this->db->escape($this->target)."',";
$sql .= " titre='".$this->db->escape($this->titre)."',";
$sql .= " langs='".$this->db->escape($this->langs)."',";
$sql .= " perms='".$this->db->escape($this->perms)."',";
$sql .= " enabled='".$this->db->escape($this->enabled)."',";
$sql .= " usertype='".$this->db->escape($this->user)."'";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
if (!$resql)
{
$this->error="Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
@ -377,37 +377,37 @@ class Menubase
//global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.menu_handler,";
$sql.= " t.entity,";
$sql.= " t.module,";
$sql.= " t.type,";
$sql.= " t.mainmenu,";
$sql.= " t.leftmenu,";
$sql.= " t.fk_menu,";
$sql.= " t.fk_mainmenu,";
$sql.= " t.fk_leftmenu,";
$sql.= " t.position,";
$sql.= " t.url,";
$sql.= " t.target,";
$sql.= " t.titre,";
$sql.= " t.langs,";
$sql.= " t.perms,";
$sql.= " t.enabled,";
$sql.= " t.usertype as user,";
$sql.= " t.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as t";
$sql.= " WHERE t.rowid = ".$id;
$sql .= " t.rowid,";
$sql .= " t.menu_handler,";
$sql .= " t.entity,";
$sql .= " t.module,";
$sql .= " t.type,";
$sql .= " t.mainmenu,";
$sql .= " t.leftmenu,";
$sql .= " t.fk_menu,";
$sql .= " t.fk_mainmenu,";
$sql .= " t.fk_leftmenu,";
$sql .= " t.position,";
$sql .= " t.url,";
$sql .= " t.target,";
$sql .= " t.titre,";
$sql .= " t.langs,";
$sql .= " t.perms,";
$sql .= " t.enabled,";
$sql .= " t.usertype as user,";
$sql .= " t.tms";
$sql .= " FROM ".MAIN_DB_PREFIX."menu as t";
$sql .= " WHERE t.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->id = $obj->rowid;
$this->menu_handler = $obj->menu_handler;
$this->entity = $obj->entity;
@ -434,7 +434,7 @@ class Menubase
}
else
{
$this->error="Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -451,13 +451,13 @@ class Menubase
//global $conf, $langs;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
$sql.= " WHERE rowid=".$this->id;
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
if (!$resql)
{
$this->error="Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
@ -474,25 +474,25 @@ class Menubase
*/
public function initAsSpecimen()
{
$this->id=0;
$this->id = 0;
$this->menu_handler='all';
$this->module='specimen';
$this->type='top';
$this->mainmenu='';
$this->fk_menu='0';
$this->position='';
$this->url='http://dummy';
$this->target='';
$this->titre='Specimen menu'; // deprecated
$this->title='Specimen menu';
$this->langs='';
$this->level='';
$this->leftmenu='';
$this->perms='';
$this->enabled='';
$this->user='';
$this->tms='';
$this->menu_handler = 'all';
$this->module = 'specimen';
$this->type = 'top';
$this->mainmenu = '';
$this->fk_menu = '0';
$this->position = '';
$this->url = 'http://dummy';
$this->target = '';
$this->titre = 'Specimen menu'; // deprecated
$this->title = 'Specimen menu';
$this->langs = '';
$this->level = '';
$this->leftmenu = '';
$this->perms = '';
$this->enabled = '';
$this->user = '';
$this->tms = '';
}
@ -508,16 +508,16 @@ class Menubase
*/
public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
{
global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu,$leftmenu; // To export to dol_eval function
global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu, $leftmenu; // To export to dol_eval function
$mainmenu=$mymainmenu; // To export to dol_eval function
$leftmenu=$myleftmenu; // To export to dol_eval function
$mainmenu = $mymainmenu; // To export to dol_eval function
$leftmenu = $myleftmenu; // To export to dol_eval function
$newTabMenu=array();
foreach($tabMenu as $val)
$newTabMenu = array();
foreach ($tabMenu as $val)
{
if ($val['type']=='top') $newTabMenu[]=$val;
if ($val['type'] == 'top') $newTabMenu[] = $val;
}
return $newTabMenu;
@ -537,20 +537,20 @@ class Menubase
*/
public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
{
global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu,$leftmenu; // To export to dol_eval function
global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu, $leftmenu; // To export to dol_eval function
$mainmenu=$mymainmenu; // To export to dol_eval function
$leftmenu=$myleftmenu; // To export to dol_eval function
$mainmenu = $mymainmenu; // To export to dol_eval function
$leftmenu = $myleftmenu; // To export to dol_eval function
// Detect what is top mainmenu id
$menutopid='';
foreach($tabMenu as $key => $val)
$menutopid = '';
foreach ($tabMenu as $key => $val)
{
// Define menutopid of mainmenu
if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu)
{
$menutopid=$val['rowid'];
$menutopid = $val['rowid'];
break;
}
}
@ -562,7 +562,7 @@ class Menubase
$this->recur($tabMenu, $menutopid, 1);
// Now complete $this->newmenu->list when fk_menu value is -1 (left menu added by modules with no top menu)
foreach($tabMenu as $key => $val)
foreach ($tabMenu as $key => $val)
{
//var_dump($tabMenu);
if ($val['fk_menu'] == -1 && $val['fk_mainmenu'] == $mainmenu) // We found a menu entry not linked to parent with good mainmenu
@ -578,16 +578,16 @@ class Menubase
else
{
// Search first menu with this couple (mainmenu,leftmenu)=(fk_mainmenu,fk_leftmenu)
$searchlastsub=0;$lastid=0;$nextid=0;$found=0;
foreach($this->newmenu->liste as $keyparent => $valparent)
$searchlastsub = 0; $lastid = 0; $nextid = 0; $found = 0;
foreach ($this->newmenu->liste as $keyparent => $valparent)
{
//var_dump($valparent);
if ($searchlastsub) // If we started to search for last submenu
{
if ($valparent['level'] >= $searchlastsub) $lastid=$keyparent;
if ($valparent['level'] >= $searchlastsub) $lastid = $keyparent;
if ($valparent['level'] < $searchlastsub)
{
$nextid=$keyparent;
$nextid = $keyparent;
break;
}
}
@ -595,9 +595,9 @@ class Menubase
{
//print "We found parent: keyparent='.$keyparent.' - level=".$valparent['level'].' - '.join(',',$valparent).'<br>';
// Now we look to find last subelement of this parent (we add at end)
$searchlastsub=($valparent['level']+1);
$lastid=$keyparent;
$found=1;
$searchlastsub = ($valparent['level'] + 1);
$lastid = $keyparent;
$found = 1;
}
}
//print 'We must insert menu entry between entry '.$lastid.' and '.$nextid.'<br>';
@ -629,16 +629,16 @@ class Menubase
global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu, $leftmenu; // To export to dol_eval function
$mainmenu=$mymainmenu; // To export to dol_eval function
$leftmenu=$myleftmenu; // To export to dol_eval function
$mainmenu = $mymainmenu; // To export to dol_eval function
$leftmenu = $myleftmenu; // To export to dol_eval function
$sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE m.entity IN (0,".$conf->entity.")";
$sql.= " AND m.menu_handler IN ('".$menu_handler."','all')";
if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)";
if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)";
$sql.= " ORDER BY m.position, m.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql .= " WHERE m.entity IN (0,".$conf->entity.")";
$sql .= " AND m.menu_handler IN ('".$menu_handler."','all')";
if ($type_user == 0) $sql .= " AND m.usertype IN (0,2)";
if ($type_user == 1) $sql .= " AND m.usertype IN (1,2)";
$sql .= " ORDER BY m.position, m.rowid";
//print $sql;
//dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG);
@ -658,8 +658,8 @@ class Menubase
$perms = true;
if ($menu['perms'])
{
$tmpcond=$menu['perms'];
if ($leftmenu == 'all') $tmpcond=preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
$tmpcond = $menu['perms'];
if ($leftmenu == 'all') $tmpcond = preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
$perms = verifCond($tmpcond);
//print "verifCond rowid=".$menu['rowid']." ".$tmpcond.":".$perms."<br>\n";
}
@ -668,19 +668,19 @@ class Menubase
$enabled = true;
if ($menu['enabled'])
{
$tmpcond=$menu['enabled'];
if ($leftmenu == 'all') $tmpcond=preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
$tmpcond = $menu['enabled'];
if ($leftmenu == 'all') $tmpcond = preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
$enabled = verifCond($tmpcond);
}
// Define $title
if ($enabled)
{
$title = $langs->trans($menu['titre']); // If $menu['titre'] start with $, a dol_eval is done.
$title = $langs->trans($menu['titre']); // If $menu['titre'] start with $, a dol_eval is done.
//var_dump($title.'-'.$menu['titre']);
if ($title == $menu['titre']) // Translation not found
{
if (! empty($menu['langs'])) // If there is a dedicated translation file
if (!empty($menu['langs'])) // If there is a dedicated translation file
{
//print 'Load file '.$menu['langs'].'<br>';
$langs->load($menu['langs']);
@ -715,10 +715,10 @@ class Menubase
$tabMenu[$b]['module'] = $menu['module'];
$tabMenu[$b]['fk_menu'] = $menu['fk_menu'];
$tabMenu[$b]['url'] = $menu['url'];
if (! preg_match("/^(http:\/\/|https:\/\/)/i", $tabMenu[$b]['url']))
if (!preg_match("/^(http:\/\/|https:\/\/)/i", $tabMenu[$b]['url']))
{
if (preg_match('/\?/', $tabMenu[$b]['url'])) $tabMenu[$b]['url'].='&amp;idmenu='.$menu['rowid'];
else $tabMenu[$b]['url'].='?idmenu='.$menu['rowid'];
if (preg_match('/\?/', $tabMenu[$b]['url'])) $tabMenu[$b]['url'] .= '&amp;idmenu='.$menu['rowid'];
else $tabMenu[$b]['url'] .= '?idmenu='.$menu['rowid'];
}
$tabMenu[$b]['titre'] = $title;
$tabMenu[$b]['target'] = $menu['target'];
@ -767,10 +767,10 @@ class Menubase
for ($x = 0; $x < $num; $x++)
{
//si un element a pour pere : $pere
if ( (($tab[$x]['fk_menu'] >= 0 && $tab[$x]['fk_menu'] == $pere)) && $tab[$x]['enabled'])
if ((($tab[$x]['fk_menu'] >= 0 && $tab[$x]['fk_menu'] == $pere)) && $tab[$x]['enabled'])
{
$this->newmenu->add($tab[$x]['url'], $tab[$x]['titre'], ($level-1), $tab[$x]['perms'], $tab[$x]['target'], $tab[$x]['mainmenu'], $tab[$x]['leftmenu']);
$this->recur($tab, $tab[$x]['rowid'], ($level+1));
$this->newmenu->add($tab[$x]['url'], $tab[$x]['titre'], ($level - 1), $tab[$x]['perms'], $tab[$x]['target'], $tab[$x]['mainmenu'], $tab[$x]['leftmenu']);
$this->recur($tab, $tab[$x]['rowid'], ($level + 1));
}
}
}

View File

@ -29,70 +29,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("products","other"));
$langs->loadLangs(array("products", "other"));
$id=GETPOST('id', 'int');
$action=GETPOST('action', 'alpha');
$modulepart=GETPOST('modulepart', 'alpha')?GETPOST('modulepart', 'alpha'):'produit|service';
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$modulepart = GETPOST('modulepart', 'alpha') ?GETPOST('modulepart', 'alpha') : 'produit|service';
$original_file = GETPOST("file");
$backtourl=GETPOST('backtourl');
$cancel=GETPOST('cancel', 'alpha');
$backtourl = GETPOST('backtourl');
$cancel = GETPOST('cancel', 'alpha');
// Security check
if (empty($modulepart)) accessforbidden('Bad value for modulepart');
$accessallowed=0;
$accessallowed = 0;
if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service')
{
$result=restrictedArea($user, 'produit|service', $id, 'product&product');
if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, 'produit|service', $id, 'product&product');
if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) accessforbidden();
$accessallowed = 1;
}
elseif ($modulepart == 'project')
{
$result=restrictedArea($user, 'projet', $id);
if (! $user->rights->projet->lire) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, 'projet', $id);
if (!$user->rights->projet->lire) accessforbidden();
$accessallowed = 1;
}
elseif ($modulepart == 'bom')
{
$result=restrictedArea($user, $modulepart, $id, 'bom_bom');
if (! $user->rights->bom->read) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, $modulepart, $id, 'bom_bom');
if (!$user->rights->bom->read) accessforbidden();
$accessallowed = 1;
}
elseif ($modulepart == 'member')
{
$result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid');
if (! $user->rights->adherent->lire) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid');
if (!$user->rights->adherent->lire) accessforbidden();
$accessallowed = 1;
}
elseif ($modulepart == 'user')
{
$result=restrictedArea($user, $modulepart, $id, $modulepart);
if (! $user->rights->user->user->lire) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, $modulepart, $id, $modulepart);
if (!$user->rights->user->user->lire) accessforbidden();
$accessallowed = 1;
}
elseif ($modulepart == 'tax')
{
$result=restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
if (! $user->rights->tax->charges->lire) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
if (!$user->rights->tax->charges->lire) accessforbidden();
$accessallowed = 1;
}
elseif ($modulepart == 'bank')
{
$result=restrictedArea($user, 'banque', $id, 'bank_account');
if (! $user->rights->banque->lire) accessforbidden();
$accessallowed=1;
$result = restrictedArea($user, 'banque', $id, 'bank_account');
if (!$user->rights->banque->lire) accessforbidden();
$accessallowed = 1;
}
else // ticket, holiday, expensereport, societe...
{
$result=restrictedArea($user, $modulepart, $id, $modulepart);
$result = restrictedArea($user, $modulepart, $id, $modulepart);
if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) accessforbidden();
$accessallowed=1;
$accessallowed = 1;
}
// Security:
// Limit access if permissions are wrong
if (! $accessallowed)
if (!$accessallowed)
{
accessforbidden();
}
@ -106,9 +106,9 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->product->multidir_output[$object->entity]; // By default
if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity];
if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity];
$dir = $conf->product->multidir_output[$object->entity]; // By default
if ($object->type == Product::TYPE_PRODUCT) $dir = $conf->product->multidir_output[$object->entity];
if ($object->type == Product::TYPE_SERVICE) $dir = $conf->service->multidir_output[$object->entity];
}
}
elseif ($modulepart == 'project')
@ -119,7 +119,7 @@ elseif ($modulepart == 'project')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->projet->dir_output; // By default
$dir = $conf->projet->dir_output; // By default
}
}
elseif ($modulepart == 'holiday')
@ -130,7 +130,7 @@ elseif ($modulepart == 'holiday')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'member')
@ -141,7 +141,7 @@ elseif ($modulepart == 'member')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->adherent->dir_output; // By default
$dir = $conf->adherent->dir_output; // By default
}
}
elseif ($modulepart == 'societe')
@ -152,7 +152,7 @@ elseif ($modulepart == 'societe')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output;
$dir = $conf->$modulepart->dir_output;
}
}
elseif ($modulepart == 'user')
@ -163,7 +163,7 @@ elseif ($modulepart == 'user')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'expensereport')
@ -174,7 +174,7 @@ elseif ($modulepart == 'expensereport')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->expensereport->dir_output; // By default
$dir = $conf->expensereport->dir_output; // By default
}
}
elseif ($modulepart == 'tax')
@ -185,7 +185,7 @@ elseif ($modulepart == 'tax')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'ticket')
@ -196,7 +196,7 @@ elseif ($modulepart == 'ticket')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'bom')
@ -207,7 +207,7 @@ elseif ($modulepart == 'bom')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'bank')
@ -218,7 +218,7 @@ elseif ($modulepart == 'bank')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->bank->dir_output; // By default
$dir = $conf->bank->dir_output; // By default
}
}
else {
@ -227,17 +227,17 @@ else {
if (empty($backtourl))
{
if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('bank'))) $backtourl=DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
else $backtourl=DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]);
if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]);
}
@ -261,9 +261,9 @@ if ($cancel)
if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != ""))
{
$fullpath=$dir."/".$original_file;
$fullpath = $dir."/".$original_file;
$result=dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']);
$result = dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']);
if ($result == $fullpath)
{
@ -274,7 +274,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found
{
@ -295,11 +295,11 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
@ -322,18 +322,18 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
else
{
setEventMessages($result, null, 'errors');
$_GET['file']=$_POST["file"];
$action='';
$_GET['file'] = $_POST["file"];
$action = '';
}
}
// Crop d'une image
if ($action == 'confirm_crop')
{
$fullpath=$dir."/".$original_file;
$fullpath = $dir."/".$original_file;
//var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit;
$result=dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']);
$result = dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']);
if ($result == $fullpath)
{
@ -344,7 +344,7 @@ if ($action == 'confirm_crop')
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found
{
@ -365,11 +365,11 @@ if ($action == 'confirm_crop')
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
@ -392,8 +392,8 @@ if ($action == 'confirm_crop')
else
{
setEventMessages($result, null, 'errors');
$_GET['file']=$_POST["file"];
$action='';
$_GET['file'] = $_POST["file"];
$action = '';
}
}
@ -402,14 +402,14 @@ if ($action == 'confirm_crop')
* View
*/
llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js','/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css'));
llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js', '/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css'));
print load_fiche_titre($langs->trans("ImageEditor"));
$infoarray=dol_getImageSize($dir."/".GETPOST("file", 'alpha'));
$height=$infoarray['height'];
$width=$infoarray['width'];
$infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha'));
$height = $infoarray['height'];
$width = $infoarray['width'];
print $langs->trans("CurrentInformationOnImage").': ';
print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>';
@ -450,18 +450,18 @@ print '<br>'."\n";
print '<br>'."\n";
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
$infoarray=dol_getImageSize($dir."/".GETPOST("file"));
$height=$infoarray['height'];
$width=$infoarray['width'];
$widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1;
$infoarray = dol_getImageSize($dir."/".GETPOST("file"));
$height = $infoarray['height'];
$width = $infoarray['width'];
$widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1;
// If image is too large, we use another scale.
if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2)))
if (!empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth'] / 2)))
{
$ratioforcrop=2;
$widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop);
$refsizeforcrop='screenwidth';
$ratioforcrop = 2;
$widthforcrop = round($_SESSION['dol_screenwidth'] / $ratioforcrop);
$refsizeforcrop = 'screenwidth';
}
print '<!-- Form to crop -->'."\n";

View File

@ -912,20 +912,20 @@ class Thirdparties extends DolibarrApi
{
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->societe->lire) {
if (!DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
if(empty($id)) {
if (empty($id)) {
throw new RestException(400, 'Thirdparty ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('societe', $id)) {
if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->company->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@ -1366,7 +1366,7 @@ class Thirdparties extends DolibarrApi
foreach ($accounts as $account) {
$object = array();
foreach ($account as $key => $value) {
if(in_array($key, $fields)) {
if (in_array($key, $fields)) {
$object[$key] = $value;
}
}
@ -1488,11 +1488,11 @@ class Thirdparties extends DolibarrApi
// We found an existing SocieteAccount entity, we are replacing it
} else {
if (isset($request_data['site']) && $request_data['site'] !== $site) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' ";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' ";
$result = $db->query($sql);
if ($result->num_rows !== 0) {
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists with this site key.");
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site']." but another SocieteAccount entity already exists with this site key.");
}
}
@ -1676,9 +1676,9 @@ class Thirdparties extends DolibarrApi
// phpcs:enable
$object = parent::_cleanObjectDatas($object);
unset($object->nom); // ->name already defined and nom deprecated
unset($object->name_bis); // ->name_alias already defined
unset($object->note); // ->note_private and note_public already defined
unset($object->nom); // ->name already defined and nom deprecated
unset($object->name_bis); // ->name_alias already defined
unset($object->note); // ->note_private and note_public already defined
unset($object->departement);
unset($object->departement_code);
unset($object->pays);
@ -1694,7 +1694,7 @@ class Thirdparties extends DolibarrApi
unset($object->lines);
unset($object->thirdparty);
unset($object->fk_delivery_address); // deprecated feature
unset($object->fk_delivery_address); // deprecated feature
return $object;
}
@ -1742,20 +1742,20 @@ class Thirdparties extends DolibarrApi
private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
{
global $conf;
if(! DolibarrApiAccess::$user->rights->societe->lire) {
if (!DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
$result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {

View File

@ -71,7 +71,7 @@ class Users extends DolibarrApi
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->user->user->lire) {
if (!DolibarrApiAccess::$user->rights->user->user->lire) {
throw new RestException(401, "You are not allowed to read list of users");
}
@ -79,29 +79,29 @@ class Users extends DolibarrApi
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
$sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."user as t";
$sql.= ' WHERE t.entity IN ('.getEntity('user').')';
if ($user_ids) $sql.=" AND t.rowid IN (".$user_ids.")";
$sql .= " FROM ".MAIN_DB_PREFIX."user as t";
$sql .= ' WHERE t.entity IN ('.getEntity('user').')';
if ($user_ids) $sql .= " AND t.rowid IN (".$user_ids.")";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
@ -115,7 +115,7 @@ class Users extends DolibarrApi
{
$obj = $db->fetch_object($result);
$user_static = new User($db);
if($user_static->fetch($obj->rowid)) {
if ($user_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($user_static);
}
$i++;
@ -124,7 +124,7 @@ class Users extends DolibarrApi
else {
throw new RestException(503, 'Error when retrieve User list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
if (!count($obj_ret)) {
throw new RestException(404, 'No User found');
}
return $obj_ret;
@ -154,7 +154,7 @@ class Users extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
{
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
return $this->_cleanObjectDatas($this->useraccount);
@ -181,7 +181,7 @@ class Users extends DolibarrApi
}
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$usergroup = new UserGroup($this->db);
@ -250,7 +250,7 @@ class Users extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
{
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach ($request_data as $field => $value)
@ -295,13 +295,13 @@ class Users extends DolibarrApi
{
$obj_ret = array();
if (! DolibarrApiAccess::$user->rights->user->user->lire) {
if (!DolibarrApiAccess::$user->rights->user->user->lire) {
throw new RestException(401);
}
$user = new User($this->db);
$result = $user->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'user not found');
}
@ -341,12 +341,12 @@ class Users extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
{
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && ! empty(DolibarrApiAccess::$user->admin) && empty(DolibarrApiAccess::$user->entity))
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && !empty(DolibarrApiAccess::$user->admin) && empty(DolibarrApiAccess::$user->entity))
{
$entity = (! empty($entity) ? $entity : $conf->entity);
$entity = (!empty($entity) ? $entity : $conf->entity);
}
else
{
@ -356,7 +356,7 @@ class Users extends DolibarrApi
}
$result = $this->useraccount->SetInGroup($group, $entity);
if (! ($result > 0))
if (!($result > 0))
{
throw new RestException(500, $this->useraccount->error);
}
@ -383,7 +383,7 @@ class Users extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
{
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->useraccount->oldcopy = clone $this->useraccount;
return $this->useraccount->delete(DolibarrApiAccess::$user);
@ -435,10 +435,10 @@ class Users extends DolibarrApi
unset($object->openid);
$canreadsalary = ((! empty($conf->salaries->enabled) && ! empty(DolibarrApiAccess::$user->rights->salaries->read))
|| (! empty($conf->hrm->enabled) && ! empty(DolibarrApiAccess::$user->rights->hrm->employee->read)));
$canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read))
|| (!empty($conf->hrm->enabled) && !empty(DolibarrApiAccess::$user->rights->hrm->employee->read)));
if (! $canreadsalary)
if (!$canreadsalary)
{
unset($object->salary);
unset($object->salaryextra);