Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
e7276f9044
commit
1648fc142e
@ -99,9 +99,9 @@ class AdherentType extends CommonObject
|
|||||||
public $mail_valid;
|
public $mail_valid;
|
||||||
|
|
||||||
/** @var array Array of members */
|
/** @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();
|
$current_lang = $langs->getDefaultLang();
|
||||||
|
|
||||||
$sql = "SELECT lang, label, description, email";
|
$sql = "SELECT lang, label, description, email";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
||||||
$sql.= " WHERE fk_type=".$this->id;
|
$sql .= " WHERE fk_type=".$this->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@ -149,7 +149,7 @@ class AdherentType extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error="Error: ".$this->db->lasterror()." - ".$sql;
|
$this->error = "Error: ".$this->db->lasterror()." - ".$sql;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,75 +171,75 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($key == $current_lang) {
|
if ($key == $current_lang) {
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
||||||
$sql.= " WHERE fk_type=".$this->id;
|
$sql .= " WHERE fk_type=".$this->id;
|
||||||
$sql.= " AND lang='".$key."'";
|
$sql .= " AND lang='".$key."'";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($this->db->num_rows($result)) // if there is already a description line for this language
|
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 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
|
||||||
$sql2.= " SET ";
|
$sql2 .= " SET ";
|
||||||
$sql2.= " label='".$this->db->escape($this->label)."',";
|
$sql2 .= " label='".$this->db->escape($this->label)."',";
|
||||||
$sql2.= " description='".$this->db->escape($this->description)."'";
|
$sql2 .= " description='".$this->db->escape($this->description)."'";
|
||||||
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'";
|
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
|
else
|
||||||
{
|
{
|
||||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
|
$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 .= ")";
|
||||||
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',";
|
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
|
||||||
$sql2.= " '".$this->db->escape($this->description)."'";
|
$sql2 .= " '".$this->db->escape($this->description)."'";
|
||||||
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'";
|
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);
|
dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
|
||||||
if (! $this->db->query($sql2)) {
|
if (!$this->db->query($sql2)) {
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (isset($this->multilangs[$key])) {
|
elseif (isset($this->multilangs[$key])) {
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
||||||
$sql.= " WHERE fk_type=".$this->id;
|
$sql .= " WHERE fk_type=".$this->id;
|
||||||
$sql.= " AND lang='".$key."'";
|
$sql .= " AND lang='".$key."'";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($this->db->num_rows($result)) // if there is already a description line for this language
|
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 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
|
||||||
$sql2.= " SET ";
|
$sql2 .= " SET ";
|
||||||
$sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
|
$sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
|
||||||
$sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
|
$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"])."'";
|
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
|
else
|
||||||
{
|
{
|
||||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
|
$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 .= ")";
|
||||||
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',";
|
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
|
||||||
$sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
|
$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"])."'";
|
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
|
// We do not save if main fields are empty
|
||||||
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
|
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
|
||||||
if (! $this->db->query($sql2)) {
|
if (!$this->db->query($sql2)) {
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ class AdherentType extends CommonObject
|
|||||||
public function delMultiLangs($langtodelete, $user)
|
public function delMultiLangs($langtodelete, $user)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
|
$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);
|
dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -289,7 +289,7 @@ class AdherentType extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
|
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -306,22 +306,22 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$error=0;
|
$error = 0;
|
||||||
|
|
||||||
$this->statut=(int) $this->statut;
|
$this->statut = (int) $this->statut;
|
||||||
$this->label=trim($this->label);
|
$this->label = trim($this->label);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
|
||||||
$sql.= " morphy";
|
$sql .= " morphy";
|
||||||
$sql.= ", libelle";
|
$sql .= ", libelle";
|
||||||
$sql.= ", entity";
|
$sql .= ", entity";
|
||||||
$sql.= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
$sql.= "'".$this->db->escape($this->morphy)."'";
|
$sql .= "'".$this->db->escape($this->morphy)."'";
|
||||||
$sql.= ", '".$this->db->escape($this->label)."'";
|
$sql .= ", '".$this->db->escape($this->label)."'";
|
||||||
$sql.= ", ".$conf->entity;
|
$sql .= ", ".$conf->entity;
|
||||||
$sql.= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
dol_syslog("Adherent_type::create", LOG_DEBUG);
|
dol_syslog("Adherent_type::create", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -336,15 +336,15 @@ class AdherentType extends CommonObject
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $notrigger)
|
if (!$notrigger)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('MEMBER_TYPE_CREATE', $user);
|
$result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -358,7 +358,7 @@ class AdherentType extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -375,23 +375,23 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
global $langs, $conf, $hookmanager;
|
global $langs, $conf, $hookmanager;
|
||||||
|
|
||||||
$error=0;
|
$error = 0;
|
||||||
|
|
||||||
$this->label=trim($this->label);
|
$this->label = trim($this->label);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
|
||||||
$sql.= "SET ";
|
$sql .= "SET ";
|
||||||
$sql.= "statut = ".$this->statut.",";
|
$sql .= "statut = ".$this->statut.",";
|
||||||
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
|
$sql .= "libelle = '".$this->db->escape($this->label)."',";
|
||||||
$sql.= "morphy = '".$this->db->escape($this->morphy) ."',";
|
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
|
||||||
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
|
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
|
||||||
$sql.= "duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."',";
|
$sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
|
||||||
$sql.= "note = '".$this->db->escape($this->note)."',";
|
$sql .= "note = '".$this->db->escape($this->note)."',";
|
||||||
$sql.= "vote = ".(integer) $this->db->escape($this->vote).",";
|
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
|
||||||
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
|
$sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
|
||||||
$sql.= " WHERE rowid =".$this->id;
|
$sql .= " WHERE rowid =".$this->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -399,34 +399,34 @@ class AdherentType extends CommonObject
|
|||||||
$this->description = $this->db->escape($this->note);
|
$this->description = $this->db->escape($this->note);
|
||||||
|
|
||||||
// Multilangs
|
// Multilangs
|
||||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||||
if ($this->setMultiLangs($user) < 0) {
|
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;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$action='update';
|
$action = 'update';
|
||||||
|
|
||||||
// Actions on extra fields
|
// 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)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error && ! $notrigger)
|
if (!$error && !$notrigger)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('MEMBER_TYPE_MODIFY', $user);
|
$result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) { $error++; }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
@ -440,7 +440,7 @@ class AdherentType extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -458,13 +458,13 @@ class AdherentType extends CommonObject
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
|
$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)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// 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; }
|
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ class AdherentType extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,7 +495,7 @@ class AdherentType extends CommonObject
|
|||||||
|
|
||||||
dol_syslog("Adherent_type::fetch", LOG_DEBUG);
|
dol_syslog("Adherent_type::fetch", LOG_DEBUG);
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows($resql))
|
if ($this->db->num_rows($resql))
|
||||||
@ -509,7 +509,7 @@ class AdherentType extends CommonObject
|
|||||||
$this->statut = $obj->status; // deprecated
|
$this->statut = $obj->status; // deprecated
|
||||||
$this->status = $obj->status;
|
$this->status = $obj->status;
|
||||||
$this->duration = $obj->duration;
|
$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->duration_unit = substr($obj->duration, -1);
|
||||||
$this->subscription = $obj->subscription;
|
$this->subscription = $obj->subscription;
|
||||||
$this->mail_valid = $obj->mail_valid;
|
$this->mail_valid = $obj->mail_valid;
|
||||||
@ -517,7 +517,7 @@ class AdherentType extends CommonObject
|
|||||||
$this->vote = $obj->vote;
|
$this->vote = $obj->vote;
|
||||||
|
|
||||||
// multilangs
|
// multilangs
|
||||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||||
$this->getMultiLangs();
|
$this->getMultiLangs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -526,7 +526,7 @@ class AdherentType extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,15 +540,15 @@ class AdherentType extends CommonObject
|
|||||||
public function liste_array()
|
public function liste_array()
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf,$langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$adherenttypes = array();
|
$adherenttypes = array();
|
||||||
|
|
||||||
$sql = "SELECT rowid, libelle as label";
|
$sql = "SELECT rowid, libelle as label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
||||||
$sql.= " WHERE entity IN (".getEntity('member_type').")";
|
$sql .= " WHERE entity IN (".getEntity('member_type').")";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$nump = $this->db->num_rows($resql);
|
$nump = $this->db->num_rows($resql);
|
||||||
@ -585,13 +585,13 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $user;
|
global $conf, $user;
|
||||||
|
|
||||||
$ret=array();
|
$ret = array();
|
||||||
|
|
||||||
$sql = "SELECT a.rowid";
|
$sql = "SELECT a.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||||
$sql.= " WHERE a.entity IN (".getEntity('member').")";
|
$sql .= " WHERE a.entity IN (".getEntity('member').")";
|
||||||
$sql.= " AND a.fk_adherent_type = ".$this->id;
|
$sql .= " AND a.fk_adherent_type = ".$this->id;
|
||||||
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
|
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
|
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -599,31 +599,31 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
while ($obj = $this->db->fetch_object($resql))
|
while ($obj = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
if (! array_key_exists($obj->rowid, $ret))
|
if (!array_key_exists($obj->rowid, $ret))
|
||||||
{
|
{
|
||||||
if ($mode < 2)
|
if ($mode < 2)
|
||||||
{
|
{
|
||||||
$memberstatic=new Adherent($this->db);
|
$memberstatic = new Adherent($this->db);
|
||||||
if ($mode == 1) {
|
if ($mode == 1) {
|
||||||
$memberstatic->fetch($obj->rowid, '', '', '', false, false);
|
$memberstatic->fetch($obj->rowid, '', '', '', false, false);
|
||||||
} else {
|
} else {
|
||||||
$memberstatic->fetch($obj->rowid);
|
$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->db->free($resql);
|
||||||
|
|
||||||
$this->members=$ret;
|
$this->members = $ret;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,15 +655,15 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result='';
|
$result = '';
|
||||||
$label=$langs->trans("ShowTypeCard", $this->label);
|
$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">';
|
$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;
|
$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) $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 != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
|
||||||
$result .= $linkend;
|
$result .= $linkend;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -723,10 +723,10 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
$dn='';
|
$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 == 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 == 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];
|
if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
|
||||||
return $dn;
|
return $dn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,27 +741,27 @@ class AdherentType extends CommonObject
|
|||||||
public function _load_ldap_info()
|
public function _load_ldap_info()
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf,$langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$info=array();
|
$info = array();
|
||||||
|
|
||||||
// Object classes
|
// Object classes
|
||||||
$info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
|
$info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
|
||||||
|
|
||||||
// Champs
|
// Champs
|
||||||
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
|
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 ($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 (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
|
||||||
{
|
{
|
||||||
$valueofldapfield=array();
|
$valueofldapfield = array();
|
||||||
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
|
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);
|
$member->fetch($val->id, '', '', '', false, false);
|
||||||
$info2 = $member->_load_ldap_info();
|
$info2 = $member->_load_ldap_info();
|
||||||
$valueofldapfield[] = $member->_load_ldap_dn($info2);
|
$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;
|
return $info;
|
||||||
}
|
}
|
||||||
@ -780,18 +780,18 @@ class AdherentType extends CommonObject
|
|||||||
// Initialise parametres
|
// Initialise parametres
|
||||||
$this->id = 0;
|
$this->id = 0;
|
||||||
$this->ref = 'MTSPEC';
|
$this->ref = 'MTSPEC';
|
||||||
$this->specimen=1;
|
$this->specimen = 1;
|
||||||
|
|
||||||
$this->label='MEMBERS TYPE SPECIMEN';
|
$this->label = 'MEMBERS TYPE SPECIMEN';
|
||||||
$this->note='This is a note';
|
$this->note = 'This is a note';
|
||||||
$this->mail_valid='This is welcome email';
|
$this->mail_valid = 'This is welcome email';
|
||||||
$this->subscription=1;
|
$this->subscription = 1;
|
||||||
$this->vote=0;
|
$this->vote = 0;
|
||||||
|
|
||||||
$this->statut=1;
|
$this->statut = 1;
|
||||||
|
|
||||||
// Members of this member type is just me
|
// Members of this member type is just me
|
||||||
$this->members=array(
|
$this->members = array(
|
||||||
$user->id => $user
|
$user->id => $user
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -805,7 +805,7 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
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;
|
return $this->mail_valid;
|
||||||
}
|
}
|
||||||
@ -823,7 +823,7 @@ class AdherentType extends CommonObject
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
// mail_subscription not defined so never used
|
// 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;
|
return $this->mail_subscription;
|
||||||
}
|
}
|
||||||
@ -841,7 +841,7 @@ class AdherentType extends CommonObject
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
// NOTE mail_resiliate not defined so never used
|
// 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;
|
return $this->mail_resiliate;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,16 +78,16 @@ class Categories extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
public function get($id, $include_childs = false)
|
public function get($id, $include_childs = false)
|
||||||
{
|
{
|
||||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
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);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,29 +126,29 @@ class Categories extends DolibarrApi
|
|||||||
|
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT t.rowid";
|
$sql = "SELECT t.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('category').')';
|
$sql .= ' WHERE t.entity IN ('.getEntity('category').')';
|
||||||
if (!empty($type))
|
if (!empty($type))
|
||||||
{
|
{
|
||||||
$sql.= ' AND t.type='.array_search($type, Categories::$TYPES);
|
$sql .= ' AND t.type='.array_search($type, Categories::$TYPES);
|
||||||
}
|
}
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters)
|
if ($sqlfilters)
|
||||||
{
|
{
|
||||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||||
{
|
{
|
||||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||||
}
|
}
|
||||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0)
|
if ($page < 0)
|
||||||
{
|
{
|
||||||
@ -156,20 +156,20 @@ class Categories extends DolibarrApi
|
|||||||
}
|
}
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
|
|
||||||
$sql.= $db->plimit($limit + 1, $offset);
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$i=0;
|
$i = 0;
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||||
while ($i < $min)
|
while ($i < $min)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$category_static = new Categorie($db);
|
$category_static = new Categorie($db);
|
||||||
if($category_static->fetch($obj->rowid)) {
|
if ($category_static->fetch($obj->rowid)) {
|
||||||
$obj_ret[] = $this->_cleanObjectDatas($category_static);
|
$obj_ret[] = $this->_cleanObjectDatas($category_static);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
@ -178,7 +178,7 @@ class Categories extends DolibarrApi
|
|||||||
else {
|
else {
|
||||||
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
|
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');
|
throw new RestException(404, 'No category found');
|
||||||
}
|
}
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
@ -192,14 +192,14 @@ class Categories extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
public function post($request_data = null)
|
public function post($request_data = null)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
|
if (!DolibarrApiAccess::$user->rights->categorie->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check mandatory fields
|
// Check mandatory fields
|
||||||
$result = $this->_validate($request_data);
|
$result = $this->_validate($request_data);
|
||||||
|
|
||||||
foreach($request_data as $field => $value) {
|
foreach ($request_data as $field => $value) {
|
||||||
$this->category->$field = $value;
|
$this->category->$field = $value;
|
||||||
}
|
}
|
||||||
if ($this->category->create(DolibarrApiAccess::$user) < 0) {
|
if ($this->category->create(DolibarrApiAccess::$user) < 0) {
|
||||||
@ -217,20 +217,20 @@ class Categories extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
public function put($id, $request_data = null)
|
public function put($id, $request_data = null)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
|
if (!DolibarrApiAccess::$user->rights->categorie->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
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);
|
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;
|
if ($field == 'id') continue;
|
||||||
$this->category->$field = $value;
|
$this->category->$field = $value;
|
||||||
}
|
}
|
||||||
@ -253,19 +253,19 @@ class Categories extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->supprimer) {
|
if (!DolibarrApiAccess::$user->rights->categorie->supprimer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
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);
|
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');
|
throw new RestException(401, 'error when delete category');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,21 +306,21 @@ class Categories extends DolibarrApi
|
|||||||
throw new RestException(401);
|
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);
|
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);
|
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);
|
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);
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
|
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
|
||||||
|
|
||||||
if( ! is_array($categories)) {
|
if (!is_array($categories)) {
|
||||||
if ($categories == 0) {
|
if ($categories == 0) {
|
||||||
throw new RestException(404, 'No category found for this object');
|
throw new RestException(404, 'No category found for this object');
|
||||||
}
|
}
|
||||||
@ -347,37 +347,37 @@ class Categories extends DolibarrApi
|
|||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
throw new RestException(404, 'category not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === Categorie::TYPE_PRODUCT) {
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Product($this->db);
|
$object = new Product($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CONTACT) {
|
} elseif ($type === Categorie::TYPE_CONTACT) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Contact($this->db);
|
$object = new Contact($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_MEMBER) {
|
} elseif ($type === Categorie::TYPE_MEMBER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
|
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Adherent($this->db);
|
$object = new Adherent($this->db);
|
||||||
@ -388,7 +388,7 @@ class Categories extends DolibarrApi
|
|||||||
if (!empty($object)) {
|
if (!empty($object)) {
|
||||||
$result = $object->fetch($object_id);
|
$result = $object->fetch($object_id);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$result=$this->category->add_type($object, $type);
|
$result = $this->category->add_type($object, $type);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
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));
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
throw new RestException(404, 'category not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === Categorie::TYPE_PRODUCT) {
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Product($this->db);
|
$object = new Product($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CONTACT) {
|
} elseif ($type === Categorie::TYPE_CONTACT) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Contact($this->db);
|
$object = new Contact($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_MEMBER) {
|
} elseif ($type === Categorie::TYPE_MEMBER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
|
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Adherent($this->db);
|
$object = new Adherent($this->db);
|
||||||
@ -468,7 +468,7 @@ class Categories extends DolibarrApi
|
|||||||
if (!empty($object)) {
|
if (!empty($object)) {
|
||||||
$result = $object->fetch('', $object_ref);
|
$result = $object->fetch('', $object_ref);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$result=$this->category->add_type($object, $type);
|
$result = $this->category->add_type($object, $type);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
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));
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
throw new RestException(404, 'category not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === Categorie::TYPE_PRODUCT) {
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Product($this->db);
|
$object = new Product($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CONTACT) {
|
} elseif ($type === Categorie::TYPE_CONTACT) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Contact($this->db);
|
$object = new Contact($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_MEMBER) {
|
} elseif ($type === Categorie::TYPE_MEMBER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
|
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Adherent($this->db);
|
$object = new Adherent($this->db);
|
||||||
@ -548,7 +548,7 @@ class Categories extends DolibarrApi
|
|||||||
if (!empty($object)) {
|
if (!empty($object)) {
|
||||||
$result = $object->fetch((int) $object_id);
|
$result = $object->fetch((int) $object_id);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$result=$this->category->del_type($object, $type);
|
$result = $this->category->del_type($object, $type);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
throw new RestException(404, 'category not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === Categorie::TYPE_PRODUCT) {
|
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);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Product($this->db);
|
$object = new Product($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
} elseif ($type === Categorie::TYPE_CUSTOMER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
} elseif ($type === Categorie::TYPE_SUPPLIER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_CONTACT) {
|
} elseif ($type === Categorie::TYPE_CONTACT) {
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Contact($this->db);
|
$object = new Contact($this->db);
|
||||||
} elseif ($type === Categorie::TYPE_MEMBER) {
|
} elseif ($type === Categorie::TYPE_MEMBER) {
|
||||||
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
|
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$object = new Adherent($this->db);
|
$object = new Adherent($this->db);
|
||||||
@ -626,7 +626,7 @@ class Categories extends DolibarrApi
|
|||||||
if (!empty($object)) {
|
if (!empty($object)) {
|
||||||
$result = $object->fetch('', (string) $object_ref);
|
$result = $object->fetch('', (string) $object_ref);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$result=$this->category->del_type($object, $type);
|
$result = $this->category->del_type($object, $type);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
|
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);
|
dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
|
||||||
|
|
||||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,11 +746,11 @@ class Categories extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->category->fetch($id);
|
$result = $this->category->fetch($id);
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'category not found');
|
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);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -781,18 +781,18 @@ class Categorie extends CommonObject
|
|||||||
|
|
||||||
$objs = array();
|
$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 = "SELECT c.fk_".$this->MAP_CAT_FK[$type];
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c";
|
$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 .= ", ".MAIN_DB_PREFIX.$this->MAP_OBJ_TABLE[$type]." as o";
|
||||||
$sql .= " WHERE o.entity IN (" . getEntity($obj->element).")";
|
$sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
|
||||||
$sql .= " AND c.fk_categorie = ".$this->id;
|
$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
|
// Protection for external users
|
||||||
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0)
|
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);
|
if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset);
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
|
|||||||
@ -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/doleditor.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.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->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||||
if (! empty($conf->projet->enabled)) {
|
if (!empty($conf->projet->enabled)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
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/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
|
// 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');
|
$action = GETPOST('action', 'alpha');
|
||||||
$confirm=GETPOST('confirm', 'alpha');
|
$confirm = GETPOST('confirm', 'alpha');
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
$id = GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$ref=GETPOST('ref', 'alpha');
|
$ref = GETPOST('ref', 'alpha');
|
||||||
$origin=GETPOST('origin', 'alpha');
|
$origin = GETPOST('origin', 'alpha');
|
||||||
$originid=GETPOST('originid', 'int');
|
$originid = GETPOST('originid', 'int');
|
||||||
|
|
||||||
$datecontrat='';
|
$datecontrat = '';
|
||||||
$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0);
|
$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->socid) $socid=$user->socid;
|
if ($user->socid) $socid = $user->socid;
|
||||||
$result=restrictedArea($user, 'contrat', $id);
|
$result = restrictedArea($user, 'contrat', $id);
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// 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);
|
$object = new Contrat($db);
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
// Load object
|
// Load object
|
||||||
if ($id > 0 || ! empty($ref) && $action!='add') {
|
if ($id > 0 || !empty($ref) && $action != 'add') {
|
||||||
$ret = $object->fetch($id, $ref);
|
$ret = $object->fetch($id, $ref);
|
||||||
if ($ret > 0)
|
if ($ret > 0)
|
||||||
$ret = $object->fetch_thirdparty();
|
$ret = $object->fetch_thirdparty();
|
||||||
@ -444,8 +444,8 @@ if (empty($reshook))
|
|||||||
$error++;
|
$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_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_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)
|
if (!empty($date_start) && !empty($date_end) && $date_start > $date_end)
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
||||||
@ -528,46 +528,46 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
if ($price_base_type != 'HT')
|
if ($price_base_type != 'HT')
|
||||||
{
|
{
|
||||||
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU');
|
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU');
|
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$desc=$prod->description;
|
$desc = $prod->description;
|
||||||
$desc=dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
$desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||||
$fk_unit = $prod->fk_unit;
|
$fk_unit = $prod->fk_unit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$pu_ht=GETPOST('price_ht');
|
$pu_ht = GETPOST('price_ht');
|
||||||
$price_base_type = '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_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;
|
$tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0;
|
||||||
$desc=$product_desc;
|
$desc = $product_desc;
|
||||||
$fk_unit= GETPOST('units', 'alpha');
|
$fk_unit = GETPOST('units', 'alpha');
|
||||||
}
|
}
|
||||||
|
|
||||||
$localtax1_tx=get_localtax($tva_tx, 1, $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);
|
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
|
||||||
|
|
||||||
// ajout prix achat
|
// ajout prix achat
|
||||||
$fk_fournprice = $_POST['fournprice'];
|
$fk_fournprice = $_POST['fournprice'];
|
||||||
if ( ! empty($_POST['buying_price']) )
|
if (!empty($_POST['buying_price']))
|
||||||
$pa_ht = $_POST['buying_price'];
|
$pa_ht = $_POST['buying_price'];
|
||||||
else
|
else
|
||||||
$pa_ht = null;
|
$pa_ht = null;
|
||||||
|
|
||||||
$info_bits=0;
|
$info_bits = 0;
|
||||||
if ($tva_npr) $info_bits |= 0x01;
|
if ($tva_npr) $info_bits |= 0x01;
|
||||||
|
|
||||||
if (((! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance))
|
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))))
|
|| 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));
|
$object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||||
$result = -1 ;
|
$result = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1239,34 +1239,34 @@ if ($action == 'create')
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
if (! empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
$langs->load('projects');
|
$langs->load('projects');
|
||||||
|
|
||||||
$formproject=new FormProjets($db);
|
$formproject = new FormProjets($db);
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||||
$formproject->select_projects(($soc->id>0?$soc->id:-1), $projectid, "projectid", 0, 0, 1, 1);
|
$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, "projectid", 0, 0, 1, 1);
|
||||||
print ' <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 ' <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 "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("NotePublic").'</td><td class="tdtop">';
|
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 $doleditor->Create(1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if (empty($user->socid))
|
if (empty($user->socid))
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td class="tdtop">';
|
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 $doleditor->Create(1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols' => '3');
|
$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
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
@ -1389,62 +1389,62 @@ else
|
|||||||
|
|
||||||
// Contract card
|
// 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='';
|
$morehtmlref = '';
|
||||||
if (! empty($modCodeContract->code_auto)) {
|
if (!empty($modCodeContract->code_auto)) {
|
||||||
$morehtmlref.=$object->ref;
|
$morehtmlref .= $object->ref;
|
||||||
} else {
|
} else {
|
||||||
$morehtmlref.=$form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3);
|
$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->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$morehtmlref.='<div class="refidno">';
|
$morehtmlref .= '<div class="refidno">';
|
||||||
// Ref customer
|
// Ref customer
|
||||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
|
$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->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
|
||||||
// Ref supplier
|
// Ref supplier
|
||||||
$morehtmlref.='<br>';
|
$morehtmlref .= '<br>';
|
||||||
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
|
$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 .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
|
||||||
// Thirdparty
|
// Thirdparty
|
||||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
$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>)';
|
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
|
// Project
|
||||||
if (! empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||||
if ($user->rights->contrat->creer)
|
if ($user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
if ($action != 'classify') {
|
if ($action != 'classify') {
|
||||||
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||||
}
|
}
|
||||||
if ($action == 'classify') {
|
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->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 .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
|
||||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
$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 .= $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 .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||||
$morehtmlref.='</form>';
|
$morehtmlref .= '</form>';
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
if (! empty($object->fk_project)) {
|
if (!empty($object->fk_project)) {
|
||||||
$proj = new Project($db);
|
$proj = new Project($db);
|
||||||
$proj->fetch($object->fk_project);
|
$proj->fetch($object->fk_project);
|
||||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
|
||||||
$morehtmlref.=$proj->ref;
|
$morehtmlref .= $proj->ref;
|
||||||
$morehtmlref.='</a>';
|
$morehtmlref .= '</a>';
|
||||||
} else {
|
} else {
|
||||||
$morehtmlref.='';
|
$morehtmlref .= '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$morehtmlref.='</div>';
|
$morehtmlref .= '</div>';
|
||||||
|
|
||||||
|
|
||||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
|
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
|
||||||
@ -1619,7 +1619,7 @@ else
|
|||||||
// Quantity
|
// Quantity
|
||||||
print '<td class="center">'.$objp->qty.'</td>';
|
print '<td class="center">'.$objp->qty.'</td>';
|
||||||
// Unit
|
// 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
|
// Discount
|
||||||
if ($objp->remise_percent > 0)
|
if ($objp->remise_percent > 0)
|
||||||
{
|
{
|
||||||
@ -1717,32 +1717,32 @@ else
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
if ($objp->fk_product)
|
if ($objp->fk_product)
|
||||||
{
|
{
|
||||||
$productstatic->id=$objp->fk_product;
|
$productstatic->id = $objp->fk_product;
|
||||||
$productstatic->type=$objp->ptype;
|
$productstatic->type = $objp->ptype;
|
||||||
$productstatic->ref=$objp->pref;
|
$productstatic->ref = $objp->pref;
|
||||||
$productstatic->entity=$objp->pentity;
|
$productstatic->entity = $objp->pentity;
|
||||||
print $productstatic->getNomUrl(1, '', 32);
|
print $productstatic->getNomUrl(1, '', 32);
|
||||||
print $objp->label?' - '.dol_trunc($objp->label, 32):'';
|
print $objp->label ? ' - '.dol_trunc($objp->label, 32) : '';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $objp->label?$objp->label.'<br>':'';
|
print $objp->label ? $objp->label.'<br>' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// editeur wysiwyg
|
// editeur wysiwyg
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
$nbrows=ROWS_2;
|
$nbrows = ROWS_2;
|
||||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
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);
|
$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 = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%');
|
||||||
$doleditor->Create();
|
$doleditor->Create();
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
print '<td class="right">';
|
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>';
|
print '</td>';
|
||||||
|
|
||||||
// Price
|
// Price
|
||||||
@ -1767,7 +1767,7 @@ else
|
|||||||
// Discount
|
// Discount
|
||||||
print '<td class="nowrap right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
|
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">';
|
print '<td class="right">';
|
||||||
if ($objp->fk_product) print '<select id="fournprice" name="fournprice"></select>';
|
if ($objp->fk_product) print '<select id="fournprice" name="fournprice"></select>';
|
||||||
@ -1885,27 +1885,27 @@ else
|
|||||||
// Area with status and activation info of line
|
// Area with status and activation info of line
|
||||||
if ($object->statut > 0)
|
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 '<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">';
|
print '<td width="30" class="right">';
|
||||||
if ($user->socid == 0)
|
if ($user->socid == 0)
|
||||||
{
|
{
|
||||||
if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline')
|
if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline')
|
||||||
{
|
{
|
||||||
$tmpaction='activateline';
|
$tmpaction = 'activateline';
|
||||||
$tmpactionpicto='play';
|
$tmpactionpicto = 'play';
|
||||||
$tmpactiontext=$langs->trans("Activate");
|
$tmpactiontext = $langs->trans("Activate");
|
||||||
if ($objp->statut == 4)
|
if ($objp->statut == 4)
|
||||||
{
|
{
|
||||||
$tmpaction='unactivateline';
|
$tmpaction = 'unactivateline';
|
||||||
$tmpactionpicto='playstop';
|
$tmpactionpicto = 'playstop';
|
||||||
$tmpactiontext=$langs->trans("Disable");
|
$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 . '&ligne=' . $object->lines[$cursorline - 1]->id . '&action=' . $tmpaction . '">';
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&ligne='.$object->lines[$cursorline - 1]->id.'&action='.$tmpaction.'">';
|
||||||
print img_picto($tmpactiontext, $tmpactionpicto);
|
print img_picto($tmpactiontext, $tmpactionpicto);
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
@ -2060,12 +2060,12 @@ else
|
|||||||
// Form to add new line
|
// Form to add new line
|
||||||
if ($user->rights->contrat->creer && ($object->statut == 0))
|
if ($user->rights->contrat->creer && ($object->statut == 0))
|
||||||
{
|
{
|
||||||
$dateSelector=1;
|
$dateSelector = 1;
|
||||||
|
|
||||||
print "\n";
|
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="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="mode" value="">
|
||||||
<input type="hidden" name="id" value="'.$object->id.'">
|
<input type="hidden" name="id" value="'.$object->id.'">
|
||||||
';
|
';
|
||||||
@ -2076,7 +2076,7 @@ else
|
|||||||
// Form to add new line
|
// Form to add new line
|
||||||
if ($action != 'editline')
|
if ($action != 'editline')
|
||||||
{
|
{
|
||||||
$forcetoshowtitlelines=1;
|
$forcetoshowtitlelines = 1;
|
||||||
if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts
|
if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts
|
||||||
|
|
||||||
// Add free products/services
|
// Add free products/services
|
||||||
|
|||||||
@ -602,123 +602,123 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS
|
$countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS
|
||||||
|
|
||||||
$contactid=0;
|
$contactid = 0;
|
||||||
$thirdpartyid=0;
|
$thirdpartyid = 0;
|
||||||
if ($this->element == 'societe')
|
if ($this->element == 'societe')
|
||||||
{
|
{
|
||||||
$thirdpartyid=$this->id;
|
$thirdpartyid = $this->id;
|
||||||
}
|
}
|
||||||
if ($this->element == 'contact')
|
if ($this->element == 'contact')
|
||||||
{
|
{
|
||||||
$contactid=$this->id;
|
$contactid = $this->id;
|
||||||
$thirdpartyid=$object->fk_soc;
|
$thirdpartyid = $object->fk_soc;
|
||||||
}
|
}
|
||||||
if ($this->element == 'user')
|
if ($this->element == 'user')
|
||||||
{
|
{
|
||||||
$contactid=$this->contact_id;
|
$contactid = $this->contact_id;
|
||||||
$thirdpartyid=$object->fk_soc;
|
$thirdpartyid = $object->fk_soc;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out='<!-- BEGIN part to show address block -->';
|
$out = '<!-- BEGIN part to show address block -->';
|
||||||
|
|
||||||
$outdone=0;
|
$outdone = 0;
|
||||||
$coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
|
$coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
|
||||||
if ($coords)
|
if ($coords)
|
||||||
{
|
{
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if (!empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
$namecoords = '';
|
$namecoords = '';
|
||||||
if ( $this->element == 'contact' && ! empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS))
|
if ($this->element == 'contact' && !empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS))
|
||||||
{
|
{
|
||||||
$namecoords.= $object->name.'<br>';
|
$namecoords .= $object->name.'<br>';
|
||||||
}
|
}
|
||||||
$namecoords.= $this->getFullName($langs, 1).'<br>'.$coords;
|
$namecoords .= $this->getFullName($langs, 1).'<br>'.$coords;
|
||||||
// hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
|
// hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
|
||||||
$out.='<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">';
|
$out .= '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">';
|
||||||
$out.=img_picto($langs->trans("Address"), 'object_address.png');
|
$out .= img_picto($langs->trans("Address"), 'object_address.png');
|
||||||
$out.='</a> ';
|
$out .= '</a> ';
|
||||||
}
|
}
|
||||||
$out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++;
|
$out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++;
|
||||||
$outdone++;
|
$outdone++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
|
if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
|
||||||
&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state)
|
&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state)
|
||||||
{
|
{
|
||||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
|
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
|
||||||
$out.=($outdone?' - ':'').$this->region.' - '.$this->state;
|
$out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$out.=($outdone?' - ':'').$this->state;
|
$out .= ($outdone ? ' - ' : '').$this->state;
|
||||||
}
|
}
|
||||||
$outdone++;
|
$outdone++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'<br>':'');
|
if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) $out .= ($outdone ? '<br>' : '');
|
||||||
if (! empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone
|
if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone
|
||||||
$out.=dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++;
|
$out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->phone_pro)) {
|
if (!empty($this->phone_pro)) {
|
||||||
$out.=dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++;
|
$out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->phone_mobile)) {
|
if (!empty($this->phone_mobile)) {
|
||||||
$out.=dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++;
|
$out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->phone_perso)) {
|
if (!empty($this->phone_perso)) {
|
||||||
$out.=dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++;
|
$out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->office_phone)) {
|
if (!empty($this->office_phone)) {
|
||||||
$out.=dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++;
|
$out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->user_mobile)) {
|
if (!empty($this->user_mobile)) {
|
||||||
$out.=dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++;
|
$out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->fax)) {
|
if (!empty($this->fax)) {
|
||||||
$out.=dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++;
|
$out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->office_fax)) {
|
if (!empty($this->office_fax)) {
|
||||||
$out.=dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++;
|
$out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.='<div style="clear: both;"></div>';
|
$out .= '<div style="clear: both;"></div>';
|
||||||
$outdone=0;
|
$outdone = 0;
|
||||||
if (! empty($this->email))
|
if (!empty($this->email))
|
||||||
{
|
{
|
||||||
$out.=dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1);
|
$out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1);
|
||||||
$outdone++;
|
$outdone++;
|
||||||
}
|
}
|
||||||
if (! empty($this->url))
|
if (!empty($this->url))
|
||||||
{
|
{
|
||||||
//$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank
|
//$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank
|
||||||
$out.=dol_print_url($this->url, '_blank', 0, 1);
|
$out .= dol_print_url($this->url, '_blank', 0, 1);
|
||||||
$outdone++;
|
$outdone++;
|
||||||
}
|
}
|
||||||
$out.='<div style="clear: both;">';
|
$out .= '<div style="clear: both;">';
|
||||||
if (! empty($conf->socialnetworks->enabled))
|
if (!empty($conf->socialnetworks->enabled))
|
||||||
{
|
{
|
||||||
if (is_array($this->socialnetworks) && count($this->socialnetworks)>0) {
|
if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) {
|
||||||
foreach ($this->socialnetworks as $key => $value) {
|
foreach ($this->socialnetworks as $key => $value) {
|
||||||
$out.=dol_print_socialnetworks($value, $this->id, $object->id, $key);
|
$out .= dol_print_socialnetworks($value, $this->id, $object->id, $key);
|
||||||
$outdone++;
|
$outdone++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype');
|
if ($this->skype) $out .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype');
|
||||||
$outdone++;
|
$outdone++;
|
||||||
if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber');
|
if ($this->jabberid) $out .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber');
|
||||||
$outdone++;
|
$outdone++;
|
||||||
if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter');
|
if ($this->twitter) $out .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter');
|
||||||
$outdone++;
|
$outdone++;
|
||||||
if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook');
|
if ($this->facebook) $out .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook');
|
||||||
$outdone++;
|
$outdone++;
|
||||||
if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin');
|
if ($this->linkedin) $out .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin');
|
||||||
$outdone++;
|
$outdone++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.='</div>';
|
$out .= '</div>';
|
||||||
|
|
||||||
$out.='<!-- END Part to show address block -->';
|
$out .= '<!-- END Part to show address block -->';
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
@ -1086,49 +1086,49 @@ abstract class CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$tab=array();
|
$tab = array();
|
||||||
|
|
||||||
$sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user
|
$sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user
|
||||||
if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo";
|
if ($source == 'internal') $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo";
|
||||||
if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact";
|
if ($source == 'external' || $source == 'thirdparty') $sql .= ", t.fk_soc as socid, t.statut as statuscontact";
|
||||||
$sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email";
|
$sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email";
|
||||||
$sql.= ", tc.source, tc.element, tc.code, tc.libelle";
|
$sql .= ", tc.source, tc.element, tc.code, tc.libelle";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."element_contact ec";
|
$sql .= ", ".MAIN_DB_PREFIX."element_contact ec";
|
||||||
if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
|
if ($source == 'internal') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
|
||||||
if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
|
if ($source == 'external' || $source == 'thirdparty') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
|
||||||
$sql.= " WHERE ec.element_id =".$this->id;
|
$sql .= " WHERE ec.element_id =".$this->id;
|
||||||
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
|
$sql .= " AND ec.fk_c_type_contact=tc.rowid";
|
||||||
$sql.= " AND tc.element='".$this->db->escape($this->element)."'";
|
$sql .= " AND tc.element='".$this->db->escape($this->element)."'";
|
||||||
if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'";
|
if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'";
|
||||||
if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
|
if ($source == 'internal') $sql .= " AND tc.source = 'internal'";
|
||||||
if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'";
|
if ($source == 'external' || $source == 'thirdparty') $sql .= " AND tc.source = 'external'";
|
||||||
$sql.= " AND tc.active=1";
|
$sql .= " AND tc.active=1";
|
||||||
if ($status >= 0) $sql.= " AND ec.statut = ".$status;
|
if ($status >= 0) $sql .= " AND ec.statut = ".$status;
|
||||||
$sql.=" ORDER BY t.lastname ASC";
|
$sql .= " ORDER BY t.lastname ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG);
|
dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num=$this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i=0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
if (! $list)
|
if (!$list)
|
||||||
{
|
{
|
||||||
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
|
$transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
|
||||||
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
|
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
|
||||||
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,
|
$tab[$i] = array('source'=>$obj->source, 'socid'=>$obj->socid, 'id'=>$obj->id,
|
||||||
'nom'=>$obj->lastname, // For backward compatibility
|
'nom'=>$obj->lastname, // For backward compatibility
|
||||||
'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact,
|
'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact,
|
||||||
'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact);
|
'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tab[$i]=$obj->id;
|
$tab[$i] = $obj->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -1900,23 +1900,23 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||||
if (! empty($this->fields['fk_project'])) // Common case
|
if (!empty($this->fields['fk_project'])) // Common case
|
||||||
{
|
{
|
||||||
if ($projectid) $sql.= ' SET fk_project = '.$projectid;
|
if ($projectid) $sql .= ' SET fk_project = '.$projectid;
|
||||||
else $sql.= ' SET fk_project = NULL';
|
else $sql .= ' SET fk_project = NULL';
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql .= ' WHERE rowid = '.$this->id;
|
||||||
}
|
}
|
||||||
elseif ($this->table_element == 'actioncomm') // Special case for actioncomm
|
elseif ($this->table_element == 'actioncomm') // Special case for actioncomm
|
||||||
{
|
{
|
||||||
if ($projectid) $sql.= ' SET fk_project = '.$projectid;
|
if ($projectid) $sql .= ' SET fk_project = '.$projectid;
|
||||||
else $sql.= ' SET fk_project = NULL';
|
else $sql .= ' SET fk_project = NULL';
|
||||||
$sql.= ' WHERE id = '.$this->id;
|
$sql .= ' WHERE id = '.$this->id;
|
||||||
}
|
}
|
||||||
else // Special case for old architecture objects
|
else // Special case for old architecture objects
|
||||||
{
|
{
|
||||||
if ($projectid) $sql.= ' SET fk_projet = '.$projectid;
|
if ($projectid) $sql .= ' SET fk_projet = '.$projectid;
|
||||||
else $sql.= ' SET fk_projet = NULL';
|
else $sql .= ' SET fk_projet = NULL';
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql .= ' WHERE rowid = '.$this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::setProject", LOG_DEBUG);
|
dol_syslog(get_class($this)."::setProject", LOG_DEBUG);
|
||||||
@ -3857,7 +3857,7 @@ abstract class CommonObject
|
|||||||
if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch)
|
if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch)
|
||||||
{
|
{
|
||||||
//print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit;
|
//print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit;
|
||||||
$trueVolumeUnit=pow(10, $volumeUnit);
|
$trueVolumeUnit = pow(10, $volumeUnit);
|
||||||
//print $line->volume;
|
//print $line->volume;
|
||||||
$totalVolume += $volume * $qty * $trueVolumeUnit;
|
$totalVolume += $volume * $qty * $trueVolumeUnit;
|
||||||
}
|
}
|
||||||
@ -4017,11 +4017,11 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl')
|
public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl')
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs,$object,$hookmanager,$extrafields;
|
global $conf, $user, $langs, $object, $hookmanager, $extrafields;
|
||||||
global $form;
|
global $form;
|
||||||
|
|
||||||
// Line extrafield
|
// Line extrafield
|
||||||
if (! is_object($extrafields))
|
if (!is_object($extrafields))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafields = new ExtraFields($this->db);
|
$extrafields = new ExtraFields($this->db);
|
||||||
@ -4108,9 +4108,9 @@ abstract class CommonObject
|
|||||||
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php';
|
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php';
|
||||||
}
|
}
|
||||||
if (empty($conf->file->strict_mode)) {
|
if (empty($conf->file->strict_mode)) {
|
||||||
$res=@include $tpl;
|
$res = @include $tpl;
|
||||||
} else {
|
} else {
|
||||||
$res=include $tpl; // for debug
|
$res = include $tpl; // for debug
|
||||||
}
|
}
|
||||||
if ($res) break;
|
if ($res) break;
|
||||||
}
|
}
|
||||||
@ -4167,21 +4167,21 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')
|
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')
|
||||||
{
|
{
|
||||||
global $conf,$langs,$user,$object,$hookmanager;
|
global $conf, $langs, $user, $object, $hookmanager;
|
||||||
global $form;
|
global $form;
|
||||||
global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
|
global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
|
||||||
|
|
||||||
$object_rights = $this->getRights();
|
$object_rights = $this->getRights();
|
||||||
|
|
||||||
$element=$this->element;
|
$element = $this->element;
|
||||||
|
|
||||||
$text=''; $description=''; $type=0;
|
$text = ''; $description = ''; $type = 0;
|
||||||
|
|
||||||
// Show product and description
|
// Show product and description
|
||||||
$type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type);
|
$type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type);
|
||||||
// Try to enhance type detection using date_start and date_end for free lines where type was not saved.
|
// Try to enhance type detection using date_start and date_end for free lines where type was not saved.
|
||||||
if (! empty($line->date_start)) $type=1; // deprecated
|
if (!empty($line->date_start)) $type = 1; // deprecated
|
||||||
if (! empty($line->date_end)) $type=1; // deprecated
|
if (!empty($line->date_end)) $type = 1; // deprecated
|
||||||
|
|
||||||
// Ligne en mode visu
|
// Ligne en mode visu
|
||||||
if ($action != 'editline' || $selected != $line->id)
|
if ($action != 'editline' || $selected != $line->id)
|
||||||
@ -4320,16 +4320,16 @@ abstract class CommonObject
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if (! empty($this->lines))
|
if (!empty($this->lines))
|
||||||
{
|
{
|
||||||
foreach ($this->lines as $line)
|
foreach ($this->lines as $line)
|
||||||
{
|
{
|
||||||
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
|
if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line)))
|
||||||
{
|
{
|
||||||
if (empty($line->fk_parent_line))
|
if (empty($line->fk_parent_line))
|
||||||
{
|
{
|
||||||
$parameters=array('line'=>$line, 'i'=>$i);
|
$parameters = array('line'=>$line, 'i'=>$i);
|
||||||
$action='';
|
$action = '';
|
||||||
$hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
$hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4623,48 +4623,48 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs, $user, $hookmanager, $action;
|
global $conf, $langs, $user, $hookmanager, $action;
|
||||||
|
|
||||||
$srctemplatepath='';
|
$srctemplatepath = '';
|
||||||
|
|
||||||
$parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams);
|
$parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams);
|
||||||
$reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null'));
|
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
|
||||||
|
|
||||||
// Increase limit for PDF build
|
// Increase limit for PDF build
|
||||||
$err=error_reporting();
|
$err = error_reporting();
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
@set_time_limit(120);
|
@set_time_limit(120);
|
||||||
error_reporting($err);
|
error_reporting($err);
|
||||||
|
|
||||||
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
|
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
|
||||||
$tmp=explode(':', $modele, 2);
|
$tmp = explode(':', $modele, 2);
|
||||||
if (! empty($tmp[1]))
|
if (!empty($tmp[1]))
|
||||||
{
|
{
|
||||||
$modele=$tmp[0];
|
$modele = $tmp[0];
|
||||||
$srctemplatepath=$tmp[1];
|
$srctemplatepath = $tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search template files
|
// Search template files
|
||||||
$file='';
|
$file = '';
|
||||||
$classname='';
|
$classname = '';
|
||||||
$filefound=0;
|
$filefound = 0;
|
||||||
$dirmodels=array('/');
|
$dirmodels = array('/');
|
||||||
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
|
if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
||||||
foreach($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
foreach(array('doc','pdf') as $prefix)
|
foreach (array('doc', 'pdf') as $prefix)
|
||||||
{
|
{
|
||||||
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
||||||
else $file = $prefix."_".$modele.".modules.php";
|
else $file = $prefix."_".$modele.".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// On verifie l'emplacement du modele
|
||||||
$file=dol_buildpath($reldir.$modelspath.$file, 0);
|
$file = dol_buildpath($reldir.$modelspath.$file, 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound = 1;
|
||||||
$classname=$prefix.'_'.$modele;
|
$classname = $prefix.'_'.$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4683,32 +4683,32 @@ abstract class CommonObject
|
|||||||
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
||||||
if ($obj->type == 'odt' && empty($srctemplatepath))
|
if ($obj->type == 'odt' && empty($srctemplatepath))
|
||||||
{
|
{
|
||||||
$varfortemplatedir=$obj->scandir;
|
$varfortemplatedir = $obj->scandir;
|
||||||
if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir))
|
if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir))
|
||||||
{
|
{
|
||||||
$dirtoscan=$conf->global->$varfortemplatedir;
|
$dirtoscan = $conf->global->$varfortemplatedir;
|
||||||
|
|
||||||
$listoffiles=array();
|
$listoffiles = array();
|
||||||
|
|
||||||
// Now we add first model found in directories scanned
|
// Now we add first model found in directories scanned
|
||||||
$listofdir=explode(',', $dirtoscan);
|
$listofdir = explode(',', $dirtoscan);
|
||||||
foreach($listofdir as $key => $tmpdir)
|
foreach ($listofdir as $key => $tmpdir)
|
||||||
{
|
{
|
||||||
$tmpdir=trim($tmpdir);
|
$tmpdir = trim($tmpdir);
|
||||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||||
if (! $tmpdir) { unset($listofdir[$key]); continue; }
|
if (!$tmpdir) { unset($listofdir[$key]); continue; }
|
||||||
if (is_dir($tmpdir))
|
if (is_dir($tmpdir))
|
||||||
{
|
{
|
||||||
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
|
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
|
||||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
|
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($listoffiles))
|
if (count($listoffiles))
|
||||||
{
|
{
|
||||||
foreach($listoffiles as $record)
|
foreach ($listoffiles as $record)
|
||||||
{
|
{
|
||||||
$srctemplatepath=$record['fullname'];
|
$srctemplatepath = $record['fullname'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4716,23 +4716,23 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if (empty($srctemplatepath))
|
if (empty($srctemplatepath))
|
||||||
{
|
{
|
||||||
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
|
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($obj->type == 'odt' && ! empty($srctemplatepath))
|
if ($obj->type == 'odt' && !empty($srctemplatepath))
|
||||||
{
|
{
|
||||||
if (! dol_is_file($srctemplatepath))
|
if (!dol_is_file($srctemplatepath))
|
||||||
{
|
{
|
||||||
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
|
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We save charset_output to restore it because write_file can change it if needed for
|
// We save charset_output to restore it because write_file can change it if needed for
|
||||||
// output format that does not support UTF8.
|
// output format that does not support UTF8.
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output = $outputlangs->charset_output;
|
||||||
|
|
||||||
if (in_array(get_class($this), array('Adherent')))
|
if (in_array(get_class($this), array('Adherent')))
|
||||||
{
|
{
|
||||||
@ -4747,46 +4747,46 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if ($resultwritefile > 0)
|
if ($resultwritefile > 0)
|
||||||
{
|
{
|
||||||
$outputlangs->charset_output=$sav_charset_output;
|
$outputlangs->charset_output = $sav_charset_output;
|
||||||
|
|
||||||
// We delete old preview
|
// We delete old preview
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
dol_delete_preview($this);
|
dol_delete_preview($this);
|
||||||
|
|
||||||
// Index file in database
|
// Index file in database
|
||||||
if (! empty($obj->result['fullpath']))
|
if (!empty($obj->result['fullpath']))
|
||||||
{
|
{
|
||||||
$destfull = $obj->result['fullpath'];
|
$destfull = $obj->result['fullpath'];
|
||||||
$upload_dir = dirname($destfull);
|
$upload_dir = dirname($destfull);
|
||||||
$destfile = basename($destfull);
|
$destfile = basename($destfull);
|
||||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
|
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
|
||||||
|
|
||||||
if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||||
{
|
{
|
||||||
$filename = basename($destfile);
|
$filename = basename($destfile);
|
||||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||||
$ecmfile=new EcmFiles($this->db);
|
$ecmfile = new EcmFiles($this->db);
|
||||||
$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
|
$result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename);
|
||||||
|
|
||||||
// Set the public "share" key
|
// Set the public "share" key
|
||||||
$setsharekey = false;
|
$setsharekey = false;
|
||||||
if ($this->element == 'propal')
|
if ($this->element == 'propal')
|
||||||
{
|
{
|
||||||
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
|
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
|
||||||
if ($useonlinesignature) $setsharekey=true;
|
if ($useonlinesignature) $setsharekey = true;
|
||||||
if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
|
if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true;
|
||||||
}
|
}
|
||||||
if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
|
if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||||
$setsharekey=true;
|
$setsharekey = true;
|
||||||
}
|
}
|
||||||
if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
|
if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||||
$setsharekey=true;
|
$setsharekey = true;
|
||||||
}
|
}
|
||||||
if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||||
$setsharekey=true;
|
$setsharekey = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($setsharekey) {
|
if ($setsharekey) {
|
||||||
@ -4834,15 +4834,15 @@ abstract class CommonObject
|
|||||||
//var_dump($obj->update_main_doc_field);exit;
|
//var_dump($obj->update_main_doc_field);exit;
|
||||||
|
|
||||||
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
|
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
|
||||||
$update_main_doc_field=0;
|
$update_main_doc_field = 0;
|
||||||
if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
|
if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1;
|
||||||
if ($update_main_doc_field && ! empty($this->table_element))
|
if ($update_main_doc_field && !empty($this->table_element))
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql .= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql) {
|
if (!$resql) {
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
} else {
|
} else {
|
||||||
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
|
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
|
||||||
@ -4862,14 +4862,14 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$outputlangs->charset_output=$sav_charset_output;
|
$outputlangs->charset_output = $sav_charset_output;
|
||||||
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
|
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
|
$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
|
||||||
dol_print_error('', $this->error);
|
dol_print_error('', $this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -4963,26 +4963,26 @@ abstract class CommonObject
|
|||||||
public function call_trigger($trigger_name, $user)
|
public function call_trigger($trigger_name, $user)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs,$conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
if (! is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
|
if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||||
$langs = new Translate('', $conf);
|
$langs = new Translate('', $conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($this->db);
|
$interface = new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers($trigger_name, $this, $user, $langs, $conf);
|
$result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
if (!empty($this->errors))
|
if (!empty($this->errors))
|
||||||
{
|
{
|
||||||
$this->errors=array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
|
$this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->errors=$interface->errors;
|
$this->errors = $interface->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
@ -6088,77 +6088,77 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||||
$data[$obj->rowid]=$labeltoshow;
|
$data[$obj->rowid] = $labeltoshow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($InfoFieldList[3]) && $parentField) {
|
if (!empty($InfoFieldList[3]) && $parentField) {
|
||||||
$parent = $parentName . ':' . $obj->{$parentField};
|
$parent = $parentName.':'.$obj->{$parentField};
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[$obj->rowid]=$labeltoshow;
|
$data[$obj->rowid] = $labeltoshow;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i ++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
$out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
|
$out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
|
||||||
} else {
|
} else {
|
||||||
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
|
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($type == 'link')
|
elseif ($type == 'link')
|
||||||
{
|
{
|
||||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]'
|
$param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]'
|
||||||
$param_list_array = explode(':', $param_list[0]);
|
$param_list_array = explode(':', $param_list[0]);
|
||||||
$showempty=(($required && $default != '')?0:1);
|
$showempty = (($required && $default != '') ? 0 : 1);
|
||||||
|
|
||||||
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1);
|
$out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled']) ? 0 : 1);
|
||||||
|
|
||||||
if (! empty($param_list_array[2])) // If we set to add a create button
|
if (!empty($param_list_array[2])) // If we set to add a create button
|
||||||
{
|
{
|
||||||
if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled".
|
if (!GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled".
|
||||||
{
|
{
|
||||||
list($class,$classfile)=explode(':', $param_list[0]);
|
list($class, $classfile) = explode(':', $param_list[0]);
|
||||||
if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1);
|
if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1);
|
||||||
else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1);
|
else $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1);
|
||||||
$paramforthenewlink = '';
|
$paramforthenewlink = '';
|
||||||
$paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):'');
|
$paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : '');
|
||||||
$paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):'');
|
$paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : '');
|
||||||
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--';
|
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--';
|
||||||
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page
|
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page
|
||||||
$out.='<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
$out .= '<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($type == 'password')
|
elseif ($type == 'password')
|
||||||
{
|
{
|
||||||
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
||||||
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
$out = '<input type="'.($keyprefix == 'search_' ? 'text' : 'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'>';
|
||||||
}
|
}
|
||||||
elseif ($type == 'array')
|
elseif ($type == 'array')
|
||||||
{
|
{
|
||||||
$newval = $val;
|
$newval = $val;
|
||||||
$newval['type'] = 'varchar(256)';
|
$newval['type'] = 'varchar(256)';
|
||||||
|
|
||||||
$out='';
|
$out = '';
|
||||||
|
|
||||||
$inputs = array();
|
$inputs = array();
|
||||||
if(! empty($value)) {
|
if (!empty($value)) {
|
||||||
foreach($value as $option) {
|
foreach ($value as $option) {
|
||||||
$out.= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
|
$out .= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
|
||||||
$out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'<br></span>';
|
$out .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'<br></span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
$out .= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
||||||
|
|
||||||
$newInput = '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
|
$newInput = '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
|
||||||
$newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'<br></span>';
|
$newInput .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'<br></span>';
|
||||||
|
|
||||||
if(! empty($conf->use_javascript_ajax)) {
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
$out.= '
|
$out .= '
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() {
|
$("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() {
|
||||||
@ -6690,7 +6690,7 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id);
|
$html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id);
|
||||||
|
|
||||||
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ': '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
|
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; }
|
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; }
|
||||||
|
|
||||||
@ -6734,7 +6734,7 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
|
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
|
||||||
|
|
||||||
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ': '').'class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
|
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').'class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
|
||||||
|
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case "view":
|
case "view":
|
||||||
@ -7163,7 +7163,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (is_array($info))
|
if (is_array($info))
|
||||||
{
|
{
|
||||||
if(isset($info['type']) && $info['type']=='array') return true;
|
if (isset($info['type']) && $info['type'] == 'array') return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -7177,7 +7177,7 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function isDate($info)
|
public function isDate($info)
|
||||||
{
|
{
|
||||||
if (isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
|
if (isset($info['type']) && ($info['type'] == 'date' || $info['type'] == 'datetime' || $info['type'] == 'timestamp')) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7191,7 +7191,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (is_array($info))
|
if (is_array($info))
|
||||||
{
|
{
|
||||||
if (isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i', $info['type']))) return true;
|
if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
else return false;
|
else return false;
|
||||||
@ -7223,7 +7223,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (is_array($info))
|
if (is_array($info))
|
||||||
{
|
{
|
||||||
if(isset($info['type']) && $info['type']=='text') return true;
|
if (isset($info['type']) && $info['type'] == 'text') return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -7239,7 +7239,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (is_array($info))
|
if (is_array($info))
|
||||||
{
|
{
|
||||||
if(isset($info['notnull']) && $info['notnull']!='1') return true;
|
if (isset($info['notnull']) && $info['notnull'] != '1') return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -7255,7 +7255,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (is_array($info))
|
if (is_array($info))
|
||||||
{
|
{
|
||||||
if(isset($info['notnull']) && $info['notnull']=='-1') return true;
|
if (isset($info['notnull']) && $info['notnull'] == '-1') return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -7271,7 +7271,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (is_array($info))
|
if (is_array($info))
|
||||||
{
|
{
|
||||||
if(isset($info['index']) && $info['index']==true) return true;
|
if (isset($info['index']) && $info['index'] == true) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -7315,19 +7315,19 @@ abstract class CommonObject
|
|||||||
$queryarray[$field] = null;
|
$queryarray[$field] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($this->isInt($info))
|
elseif ($this->isInt($info))
|
||||||
{
|
{
|
||||||
if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity;
|
if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field] = $conf->entity;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$queryarray[$field] = (int) $this->{$field};
|
$queryarray[$field] = (int) $this->{$field};
|
||||||
if (empty($queryarray[$field])) $queryarray[$field]=0; // May be reset to null later if property 'notnull' is -1 for this field.
|
if (empty($queryarray[$field])) $queryarray[$field] = 0; // May be reset to null later if property 'notnull' is -1 for this field.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($this->isFloat($info))
|
elseif ($this->isFloat($info))
|
||||||
{
|
{
|
||||||
$queryarray[$field] = (double) $this->{$field};
|
$queryarray[$field] = (double) $this->{$field};
|
||||||
if (empty($queryarray[$field])) $queryarray[$field]=0;
|
if (empty($queryarray[$field])) $queryarray[$field] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -7443,13 +7443,13 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$now=dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
$fieldvalues = $this->setSaveQuery();
|
$fieldvalues = $this->setSaveQuery();
|
||||||
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now);
|
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now);
|
||||||
if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id;
|
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id;
|
||||||
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
|
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
|
||||||
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data
|
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data
|
||||||
|
|
||||||
$keys = array();
|
$keys = array();
|
||||||
$values = array();
|
$values = array();
|
||||||
@ -7460,55 +7460,55 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean and check mandatory
|
// Clean and check mandatory
|
||||||
foreach($keys as $key)
|
foreach ($keys as $key)
|
||||||
{
|
{
|
||||||
// If field is an implicit foreign key field
|
// If field is an implicit foreign key field
|
||||||
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]='';
|
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = '';
|
||||||
if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]='';
|
if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = '';
|
||||||
|
|
||||||
//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
|
//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
|
||||||
if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default']))
|
if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && !isset($values[$key]) && is_null($val['default']))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
|
$this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If field is an implicit foreign key field
|
// If field is an implicit foreign key field
|
||||||
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key]='null';
|
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key] = 'null';
|
||||||
if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key]='null';
|
if (!empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key] = 'null';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error) return -1;
|
if ($error) return -1;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if (! $error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
|
||||||
$sql.= ' ('.implode(", ", $keys).')';
|
$sql .= ' ('.implode(", ", $keys).')';
|
||||||
$sql.= ' VALUES ('.implode(", ", $values).')';
|
$sql .= ' VALUES ('.implode(", ", $values).')';
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res===false) {
|
if ($res === false) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->errors[] = $this->db->lasterror();
|
$this->errors[] = $this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a field ref with a default value of (PROV)
|
// If we have a field ref with a default value of (PROV)
|
||||||
if (! $error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && ! is_null($this->fields['ref']['default']) && $this->fields['ref']['default'] == '(PROV)')
|
if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && !is_null($this->fields['ref']['default']) && $this->fields['ref']['default'] == '(PROV)')
|
||||||
{
|
{
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id;
|
||||||
$resqlupdate = $this->db->query($sql);
|
$resqlupdate = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resqlupdate===false)
|
if ($resqlupdate === false)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$this->errors[] = $this->db->lasterror();
|
$this->errors[] = $this->db->lasterror();
|
||||||
@ -7675,11 +7675,11 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$now=dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
$fieldvalues = $this->setSaveQuery();
|
$fieldvalues = $this->setSaveQuery();
|
||||||
if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now);
|
if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now);
|
||||||
if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id;
|
if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id;
|
||||||
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
|
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
|
||||||
|
|
||||||
$keys = array();
|
$keys = array();
|
||||||
@ -8048,11 +8048,11 @@ abstract class CommonObject
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
$categorystatic = new Categorie($this->db);
|
$categorystatic = new Categorie($this->db);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type] . " (fk_categorie, fk_product)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$categorystatic->MAP_CAT_TABLE[$type]." (fk_categorie, fk_product)";
|
||||||
$sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type];
|
$sql .= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_".$categorystatic->MAP_CAT_TABLE[$type];
|
||||||
$sql.= " WHERE fk_product = '".$fromId."'";
|
$sql .= " WHERE fk_product = '".$fromId."'";
|
||||||
|
|
||||||
if (! $this->db->query($sql))
|
if (!$this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
|||||||
@ -178,7 +178,7 @@ class Conf
|
|||||||
|
|
||||||
if ($value && preg_match('/^MAIN_MODULE_/', $key))
|
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 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))
|
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.
|
// 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);
|
$filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
|
||||||
foreach ($filesList as $file) {
|
foreach ($filesList as $file) {
|
||||||
$file=dol_sanitizeFileName($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.
|
include_once DOL_DOCUMENT_ROOT."/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,30 +329,30 @@ class Conf
|
|||||||
$this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
|
$this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
|
||||||
$this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp");
|
$this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp");
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
$this->mycompany->dir_output=$rootfordata."/mycompany";
|
$this->mycompany->dir_output = $rootfordata."/mycompany";
|
||||||
$this->mycompany->dir_temp=$rootfordata."/mycompany/temp";
|
$this->mycompany->dir_temp = $rootfordata."/mycompany/temp";
|
||||||
|
|
||||||
// For admin storage
|
// For admin storage
|
||||||
$this->admin->dir_output=$rootfordata.'/admin';
|
$this->admin->dir_output = $rootfordata.'/admin';
|
||||||
$this->admin->dir_temp=$rootfordata.'/admin/temp';
|
$this->admin->dir_temp = $rootfordata.'/admin/temp';
|
||||||
|
|
||||||
// For user storage
|
// For user storage
|
||||||
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
|
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
|
||||||
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
|
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
$this->user->dir_output=$rootforuser."/users";
|
$this->user->dir_output = $rootforuser."/users";
|
||||||
$this->user->dir_temp=$rootforuser."/users/temp";
|
$this->user->dir_temp = $rootforuser."/users/temp";
|
||||||
|
|
||||||
// For usergroup storage
|
// For usergroup storage
|
||||||
$this->usergroup->dir_output=$rootforuser."/usergroups";
|
$this->usergroup->dir_output = $rootforuser."/usergroups";
|
||||||
$this->usergroup->dir_temp=$rootforuser."/usergroups/temp";
|
$this->usergroup->dir_temp = $rootforuser."/usergroups/temp";
|
||||||
|
|
||||||
// For proposal storage
|
// For proposal storage
|
||||||
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
|
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
|
||||||
$this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp");
|
$this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp");
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
$this->propal->dir_output=$rootfordata."/propale";
|
$this->propal->dir_output = $rootfordata."/propale";
|
||||||
$this->propal->dir_temp=$rootfordata."/propale/temp";
|
$this->propal->dir_temp = $rootfordata."/propale/temp";
|
||||||
|
|
||||||
// For bank storage
|
// For bank storage
|
||||||
$this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
|
$this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
|
||||||
@ -367,101 +367,101 @@ class Conf
|
|||||||
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
|
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
|
||||||
|
|
||||||
// Sous module bons d'expedition
|
// 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
|
// 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
|
// Module fournisseur
|
||||||
// TODO To split into module supplier_invoice and supplier_order
|
// 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 = new stdClass();
|
||||||
$this->fournisseur->commande->multidir_output=array($this->entity => $rootfordata."/fournisseur/commande");
|
$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->multidir_temp = array($this->entity => $rootfordata."/fournisseur/commande/temp");
|
||||||
$this->fournisseur->commande->dir_output=$rootfordata."/fournisseur/commande"; // For backward compatibility
|
$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->commande->dir_temp = $rootfordata."/fournisseur/commande/temp"; // For backward compatibility
|
||||||
$this->fournisseur->facture=new stdClass();
|
$this->fournisseur->facture = new stdClass();
|
||||||
$this->fournisseur->facture->multidir_output=array($this->entity => $rootfordata."/fournisseur/facture");
|
$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->multidir_temp = array($this->entity => $rootfordata."/fournisseur/facture/temp");
|
||||||
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture"; // For backward compatibility
|
$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->facture->dir_temp = $rootfordata."/fournisseur/facture/temp"; // For backward compatibility
|
||||||
|
|
||||||
$this->fournisseur->payment=new stdClass();
|
$this->fournisseur->payment = new stdClass();
|
||||||
$this->fournisseur->payment->multidir_output=array($this->entity => $rootfordata."/fournisseur/payment");
|
$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->multidir_temp = array($this->entity => $rootfordata."/fournisseur/payment/temp");
|
||||||
$this->fournisseur->payment->dir_output =$rootfordata."/fournisseur/payment"; // For backward compatibility
|
$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->dir_temp = $rootfordata."/fournisseur/payment/temp"; // For backward compatibility
|
||||||
|
|
||||||
// To prepare split of module vendor(fournisseur) into vendor + supplier_order + supplier_invoice + supplierproposal
|
// 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
|
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 = new stdClass();
|
||||||
$this->supplier_order->enabled=1;
|
$this->supplier_order->enabled = 1;
|
||||||
$this->supplier_order->multidir_output=array($this->entity => $rootfordata."/fournisseur/commande");
|
$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->multidir_temp = array($this->entity => $rootfordata."/fournisseur/commande/temp");
|
||||||
$this->supplier_order->dir_output=$rootfordata."/fournisseur/commande"; // For backward compatibility
|
$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->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
|
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 = new stdClass();
|
||||||
$this->supplier_invoice->enabled=1;
|
$this->supplier_invoice->enabled = 1;
|
||||||
$this->supplier_invoice->multidir_output=array($this->entity => $rootfordata."/fournisseur/facture");
|
$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->multidir_temp = array($this->entity => $rootfordata."/fournisseur/facture/temp");
|
||||||
$this->supplier_invoice->dir_output=$rootfordata."/fournisseur/facture"; // For backward compatibility
|
$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->dir_temp = $rootfordata."/fournisseur/facture/temp"; // For backward compatibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module product/service
|
// Module product/service
|
||||||
$this->product->multidir_output=array($this->entity => $rootfordata."/produit");
|
$this->product->multidir_output = array($this->entity => $rootfordata."/produit");
|
||||||
$this->product->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
|
$this->product->multidir_temp = array($this->entity => $rootfordata."/produit/temp");
|
||||||
$this->service->multidir_output=array($this->entity => $rootfordata."/produit");
|
$this->service->multidir_output = array($this->entity => $rootfordata."/produit");
|
||||||
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
|
$this->service->multidir_temp = array($this->entity => $rootfordata."/produit/temp");
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
$this->product->dir_output=$rootfordata."/produit";
|
$this->product->dir_output = $rootfordata."/produit";
|
||||||
$this->product->dir_temp =$rootfordata."/produit/temp";
|
$this->product->dir_temp = $rootfordata."/produit/temp";
|
||||||
$this->service->dir_output=$rootfordata."/produit";
|
$this->service->dir_output = $rootfordata."/produit";
|
||||||
$this->service->dir_temp =$rootfordata."/produit/temp";
|
$this->service->dir_temp = $rootfordata."/produit/temp";
|
||||||
|
|
||||||
// Module productbatch
|
// Module productbatch
|
||||||
$this->productbatch->multidir_output=array($this->entity => $rootfordata."/produitlot");
|
$this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot");
|
||||||
$this->productbatch->multidir_temp =array($this->entity => $rootfordata."/produitlot/temp");
|
$this->productbatch->multidir_temp = array($this->entity => $rootfordata."/produitlot/temp");
|
||||||
|
|
||||||
// Module contrat
|
// Module contrat
|
||||||
$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
|
$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
|
||||||
$this->contrat->multidir_temp = array($this->entity => $rootfordata."/contract/temp");
|
$this->contrat->multidir_temp = array($this->entity => $rootfordata."/contract/temp");
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
$this->contrat->dir_output=$rootfordata."/contract";
|
$this->contrat->dir_output = $rootfordata."/contract";
|
||||||
$this->contrat->dir_temp =$rootfordata."/contract/temp";
|
$this->contrat->dir_temp = $rootfordata."/contract/temp";
|
||||||
|
|
||||||
// Module bank
|
// Module bank
|
||||||
$this->bank->dir_output=$rootfordata."/bank";
|
$this->bank->dir_output = $rootfordata."/bank";
|
||||||
$this->bank->dir_temp =$rootfordata."/bank/temp";
|
$this->bank->dir_temp = $rootfordata."/bank/temp";
|
||||||
|
|
||||||
|
|
||||||
// Set some default values
|
// 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_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
|
// societe
|
||||||
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard";
|
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_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($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($conf->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple';
|
||||||
|
|
||||||
// Security
|
// Security
|
||||||
if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator
|
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->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask
|
||||||
|
|
||||||
// conf->use_javascript_ajax
|
// conf->use_javascript_ajax
|
||||||
$this->use_javascript_ajax=1;
|
$this->use_javascript_ajax = 1;
|
||||||
if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax=! $this->global->MAIN_DISABLE_JAVASCRIPT;
|
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 no javascript_ajax, Ajax features are disabled.
|
||||||
if (empty($this->use_javascript_ajax))
|
if (empty($this->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
@ -471,231 +471,231 @@ class Conf
|
|||||||
unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
|
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_BILL = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0;
|
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_SHIPMENT=1;
|
$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
|
||||||
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0;
|
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0;
|
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0;
|
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
|
||||||
if(empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
|
if (empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
|
||||||
else {
|
else {
|
||||||
$this->global->STOCK_CALCULATE_ON_RECEPTION=1;
|
$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
|
||||||
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE=0;
|
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// conf->currency
|
// conf->currency
|
||||||
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR';
|
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE = 'EUR';
|
||||||
$this->currency=$this->global->MAIN_MONNAIE;
|
$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,...)
|
// 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
|
// 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
|
// 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
|
// 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
|
// conf->liste_limit = constante de taille maximale des listes
|
||||||
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25;
|
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
|
||||||
$this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT;
|
$this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
|
||||||
|
|
||||||
// conf->product->limit_size = constante de taille maximale des select de produit
|
// 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;
|
if (!isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE = 1000;
|
||||||
$this->product->limit_size=$this->global->PRODUIT_LIMIT_SIZE;
|
$this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
|
||||||
|
|
||||||
// conf->theme et $this->css
|
// conf->theme et $this->css
|
||||||
if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME="eldy";
|
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;
|
if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
|
||||||
$this->theme=$this->global->MAIN_THEME;
|
$this->theme = $this->global->MAIN_THEME;
|
||||||
$this->css = "/theme/".$this->theme."/style.css.php";
|
$this->css = "/theme/".$this->theme."/style.css.php";
|
||||||
|
|
||||||
// conf->email_from = email pour envoi par dolibarr des mails automatiques
|
// conf->email_from = email pour envoi par dolibarr des mails automatiques
|
||||||
$this->email_from = "robot@example.com";
|
$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
|
// conf->notification->email_from = email pour envoi par Dolibarr des notifications
|
||||||
$this->notification->email_from=$this->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;
|
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
|
// conf->mailing->email_from = email pour envoi par Dolibarr des mailings
|
||||||
$this->mailing->email_from=$this->email_from;
|
$this->mailing->email_from = $this->email_from;
|
||||||
if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_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;
|
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)
|
// 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 = "%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_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
|
||||||
$this->format_hour_short="%H:%M";
|
$this->format_hour_short = "%H:%M";
|
||||||
$this->format_hour_short_duration="%H:%M";
|
$this->format_hour_short_duration = "%H:%M";
|
||||||
$this->format_date_text_short="%d %b %Y";
|
$this->format_date_text_short = "%d %b %Y";
|
||||||
$this->format_date_text="%d %B %Y";
|
$this->format_date_text = "%d %B %Y";
|
||||||
$this->format_date_hour_short="%d/%m/%Y %H:%M";
|
$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_sec_short = "%d/%m/%Y %H:%M:%S";
|
||||||
$this->format_date_hour_text_short="%d %b %Y %H:%M";
|
$this->format_date_hour_text_short = "%d %b %Y %H:%M";
|
||||||
$this->format_date_hour_text="%d %B %Y %H:%M";
|
$this->format_date_hour_text = "%d %B %Y %H:%M";
|
||||||
|
|
||||||
// Duration of workday
|
// 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)
|
// 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_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_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_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
|
||||||
|
|
||||||
// Default pdf option
|
// 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->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->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
|
// Default max file size for upload
|
||||||
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
|
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
|
||||||
|
|
||||||
// By default, we propagate contacts
|
// 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
|
// 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
|
// 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
|
// 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)
|
// 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"
|
// 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 (!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 (!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
|
// 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
|
// Timeouts
|
||||||
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10;
|
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_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
|
||||||
|
|
||||||
// Set default variable to calculate VAT as if option tax_mode was 0 (standard)
|
// 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_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_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_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_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment';
|
||||||
|
|
||||||
// Delay before warnings
|
// Delay before warnings
|
||||||
// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
|
// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
|
||||||
if (isset($this->agenda)) {
|
if (isset($this->agenda)) {
|
||||||
$this->adherent->subscription = new stdClass();
|
$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)) {
|
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))
|
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->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 = 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->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 24 * 60 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->commande)) {
|
if (isset($this->commande)) {
|
||||||
$this->commande->client = new stdClass();
|
$this->commande->client = new stdClass();
|
||||||
$this->commande->fournisseur = 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->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->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)) {
|
if (isset($this->propal)) {
|
||||||
$this->propal->cloture = new stdClass();
|
$this->propal->cloture = new stdClass();
|
||||||
$this->propal->facturation = 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->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->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)) {
|
if (isset($this->facture)) {
|
||||||
$this->facture->client = new stdClass();
|
$this->facture->client = new stdClass();
|
||||||
$this->facture->fournisseur = 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->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->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)) {
|
if (isset($this->contrat)) {
|
||||||
$this->contrat->services = new stdClass();
|
$this->contrat->services = new stdClass();
|
||||||
$this->contrat->services->inactifs = new stdClass();
|
$this->contrat->services->inactifs = new stdClass();
|
||||||
$this->contrat->services->expires = 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->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->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60;
|
||||||
}
|
}
|
||||||
if (isset($this->commande)) {
|
if (isset($this->commande)) {
|
||||||
$this->bank->rappro = new stdClass();
|
$this->bank->rappro = new stdClass();
|
||||||
$this->bank->cheque = 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->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->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)) {
|
if (isset($this->expensereport)) {
|
||||||
$this->expensereport->approve = new stdClass();
|
$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 = 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)) {
|
if (isset($this->holiday)) {
|
||||||
$this->holiday->approve = new stdClass();
|
$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;
|
$this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For modules that want to disable top or left menu
|
// 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_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_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
|
// 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_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_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 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
|
// For backward compatibility
|
||||||
if (isset($this->product)) $this->produit=$this->product;
|
if (isset($this->product)) $this->produit = $this->product;
|
||||||
if (isset($this->facture)) $this->invoice=$this->facture;
|
if (isset($this->facture)) $this->invoice = $this->facture;
|
||||||
if (isset($this->commande)) $this->order=$this->commande;
|
if (isset($this->commande)) $this->order = $this->commande;
|
||||||
if (isset($this->contrat)) $this->contract=$this->contrat;
|
if (isset($this->contrat)) $this->contract = $this->contrat;
|
||||||
if (isset($this->categorie)) $this->category=$this->categorie;
|
if (isset($this->categorie)) $this->category = $this->categorie;
|
||||||
if (isset($this->project)) $this->project=$this->projet;
|
if (isset($this->project)) $this->project = $this->projet;
|
||||||
|
|
||||||
// Object $mc
|
// Object $mc
|
||||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled))
|
||||||
{
|
{
|
||||||
if (is_object($mc)) $mc->setValues($this);
|
if (is_object($mc)) $mc->setValues($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We init log handlers
|
// We init log handlers
|
||||||
if (! empty($this->global->SYSLOG_HANDLERS)) {
|
if (!empty($this->global->SYSLOG_HANDLERS)) {
|
||||||
$handlers = json_decode($this->global->SYSLOG_HANDLERS);
|
$handlers = json_decode($this->global->SYSLOG_HANDLERS);
|
||||||
} else {
|
} else {
|
||||||
$handlers = array();
|
$handlers = array();
|
||||||
|
|||||||
@ -56,19 +56,19 @@ class FormWebsite
|
|||||||
*/
|
*/
|
||||||
public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0)
|
public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0)
|
||||||
{
|
{
|
||||||
$out='';
|
$out = '';
|
||||||
|
|
||||||
$sql = "SELECT rowid, ref";
|
$sql = "SELECT rowid, ref";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."website";
|
$sql .= " FROM ".MAIN_DB_PREFIX."website";
|
||||||
$sql.= " WHERE 1 = 1";
|
$sql .= " WHERE 1 = 1";
|
||||||
$sql.= " ORDER BY rowid";
|
$sql .= " ORDER BY rowid";
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
|
$out .= '<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||||
if ($useempty)
|
if ($useempty)
|
||||||
{
|
{
|
||||||
$out.='<option value="-1"> </option>';
|
$out .= '<option value="-1"> </option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
@ -78,17 +78,17 @@ class FormWebsite
|
|||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
if ($selected == $obj->rowid)
|
if ($selected == $obj->rowid)
|
||||||
{
|
{
|
||||||
$out.='<option value="'.$obj->rowid.'" selected>';
|
$out .= '<option value="'.$obj->rowid.'" selected>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$out.='<option value="'.$obj->rowid.'">';
|
$out .= '<option value="'.$obj->rowid.'">';
|
||||||
}
|
}
|
||||||
$out.=$obj->ref;
|
$out .= $obj->ref;
|
||||||
$out.='</option>';
|
$out .= '</option>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$out.="</select>";
|
$out .= "</select>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
@ -114,9 +114,9 @@ class FormWebsite
|
|||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
$sql = "SELECT rowid, code, label, entity";
|
$sql = "SELECT rowid, code, label, entity";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container';
|
$sql .= " FROM ".MAIN_DB_PREFIX.'c_type_container';
|
||||||
$sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
|
$sql .= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
|
||||||
$sql.= " ORDER BY label";
|
$sql .= " ORDER BY label";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG);
|
dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -126,7 +126,7 @@ class FormWebsite
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num)
|
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))
|
if ($useempty == 1 || ($useempty == 2 && $num > 1))
|
||||||
{
|
{
|
||||||
print '<option value="-1"> </option>';
|
print '<option value="-1"> </option>';
|
||||||
@ -179,8 +179,8 @@ class FormWebsite
|
|||||||
$listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$');
|
$listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$');
|
||||||
|
|
||||||
$arrayofsamples = array();
|
$arrayofsamples = array();
|
||||||
$arrayofsamples['empty']='EmptyPage'; // Always this one first
|
$arrayofsamples['empty'] = 'EmptyPage'; // Always this one first
|
||||||
foreach($listofsamples as $sample)
|
foreach ($listofsamples as $sample)
|
||||||
{
|
{
|
||||||
$reg = array();
|
$reg = array();
|
||||||
if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg))
|
if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg))
|
||||||
@ -193,14 +193,14 @@ class FormWebsite
|
|||||||
}
|
}
|
||||||
|
|
||||||
$out = '';
|
$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)
|
if ($useempty == 1 || $useempty == 2)
|
||||||
{
|
{
|
||||||
$out .= '<option value="-1"> </option>';
|
$out .= '<option value="-1"> </option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($arrayofsamples as $key => $val)
|
foreach ($arrayofsamples as $key => $val)
|
||||||
{
|
{
|
||||||
if ($selected == $key)
|
if ($selected == $key)
|
||||||
{
|
{
|
||||||
@ -238,57 +238,57 @@ class FormWebsite
|
|||||||
|
|
||||||
$atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
|
$atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
|
||||||
|
|
||||||
$out='';
|
$out = '';
|
||||||
if ($atleastonepage && $action != 'editsource')
|
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
|
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"> </option>';
|
if ($showempty || !$atleastonepage) $out .= '<option value="-1"> </option>';
|
||||||
|
|
||||||
if ($atleastonepage)
|
if ($atleastonepage)
|
||||||
{
|
{
|
||||||
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
|
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
|
||||||
{
|
{
|
||||||
$firstpageid=0;$homepageid=0;
|
$firstpageid = 0; $homepageid = 0;
|
||||||
foreach($website->lines as $key => $valpage)
|
foreach ($website->lines as $key => $valpage)
|
||||||
{
|
{
|
||||||
if (empty($firstpageid)) $firstpageid=$valpage->id;
|
if (empty($firstpageid)) $firstpageid = $valpage->id;
|
||||||
if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$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;
|
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 = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> ';
|
||||||
$valueforoption.= $valpage->pageurl.' - '.$valpage->title;
|
$valueforoption .= $valpage->pageurl.' - '.$valpage->title;
|
||||||
if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>';
|
if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption .= ' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>';
|
||||||
|
|
||||||
$out.='<option value="'.$key.'"';
|
$out .= '<option value="'.$key.'"';
|
||||||
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
|
if ($pageid > 0 && $pageid == $key) $out .= ' selected'; // To preselect a value
|
||||||
$out.=' data-html="'.dol_escape_htmltag($valueforoption).'"';
|
$out .= ' data-html="'.dol_escape_htmltag($valueforoption).'"';
|
||||||
$out.='>';
|
$out .= '>';
|
||||||
$out.=$valueforoption;
|
$out .= $valueforoption;
|
||||||
$out.='</option>';
|
$out .= '</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.='</select>';
|
$out .= '</select>';
|
||||||
|
|
||||||
if ($atleastonepage && $action != 'editsource')
|
if ($atleastonepage && $action != 'editsource')
|
||||||
{
|
{
|
||||||
$out.=ajax_combobox($htmlname);
|
$out .= ajax_combobox($htmlname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">';
|
$out .= '<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">';
|
||||||
$out.=ajax_combobox($htmlname);
|
$out .= ajax_combobox($htmlname);
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -173,24 +173,24 @@ class Menubase
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->menu_handler=trim($this->menu_handler);
|
$this->menu_handler = trim($this->menu_handler);
|
||||||
$this->module=trim($this->module);
|
$this->module = trim($this->module);
|
||||||
$this->type=trim($this->type);
|
$this->type = trim($this->type);
|
||||||
$this->mainmenu=trim($this->mainmenu);
|
$this->mainmenu = trim($this->mainmenu);
|
||||||
$this->leftmenu=trim($this->leftmenu);
|
$this->leftmenu = trim($this->leftmenu);
|
||||||
$this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined
|
$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_mainmenu = trim($this->fk_mainmenu);
|
||||||
$this->fk_leftmenu=trim($this->fk_leftmenu);
|
$this->fk_leftmenu = trim($this->fk_leftmenu);
|
||||||
$this->position = (int) $this->position;
|
$this->position = (int) $this->position;
|
||||||
$this->url=trim($this->url);
|
$this->url = trim($this->url);
|
||||||
$this->target=trim($this->target);
|
$this->target = trim($this->target);
|
||||||
$this->titre=trim($this->titre);
|
$this->titre = trim($this->titre);
|
||||||
$this->langs=trim($this->langs);
|
$this->langs = trim($this->langs);
|
||||||
$this->perms=trim($this->perms);
|
$this->perms = trim($this->perms);
|
||||||
$this->enabled=trim($this->enabled);
|
$this->enabled = trim($this->enabled);
|
||||||
$this->user = (int) $this->user;
|
$this->user = (int) $this->user;
|
||||||
if (empty($this->position)) $this->position=0;
|
if (empty($this->position)) $this->position = 0;
|
||||||
if (! $this->level) $this->level=0;
|
if (!$this->level) $this->level = 0;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($this->menu_handler)) return -1;
|
if (empty($this->menu_handler)) return -1;
|
||||||
@ -201,32 +201,32 @@ class Menubase
|
|||||||
if (in_array($this->db->type, array('pgsql')))
|
if (in_array($this->db->type, array('pgsql')))
|
||||||
{
|
{
|
||||||
$sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu";
|
$sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu";
|
||||||
$resqlrowid=$this->db->query($sql);
|
$resqlrowid = $this->db->query($sql);
|
||||||
if ($resqlrowid) {
|
if ($resqlrowid) {
|
||||||
$obj=$this->db->fetch_object($resqlrowid);
|
$obj = $this->db->fetch_object($resqlrowid);
|
||||||
$maxrowid=$obj->maxrowid;
|
$maxrowid = $obj->maxrowid;
|
||||||
|
|
||||||
// Max rowid can be empty if there is no record yet
|
// 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).")";
|
$sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")";
|
||||||
//print $sql; exit;
|
//print $sql; exit;
|
||||||
$resqlrowidset=$this->db->query($sql);
|
$resqlrowidset = $this->db->query($sql);
|
||||||
if (! $resqlrowidset) dol_print_error($this->db);
|
if (!$resqlrowidset) dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
else 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
|
// 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 = "SELECT count(*)";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."menu";
|
$sql .= " FROM ".MAIN_DB_PREFIX."menu";
|
||||||
$sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
|
$sql .= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
|
||||||
$sql.= " AND fk_menu = ".((int) $this->fk_menu);
|
$sql .= " AND fk_menu = ".((int) $this->fk_menu);
|
||||||
$sql.= " AND position = ".((int) $this->position);
|
$sql .= " AND position = ".((int) $this->position);
|
||||||
$sql.= " AND url = '".$this->db->escape($this->url)."'";
|
$sql .= " AND url = '".$this->db->escape($this->url)."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$result=$this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($result);
|
$row = $this->db->fetch_row($result);
|
||||||
@ -235,45 +235,45 @@ class Menubase
|
|||||||
{
|
{
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
|
||||||
$sql.= "menu_handler,";
|
$sql .= "menu_handler,";
|
||||||
$sql.= "entity,";
|
$sql .= "entity,";
|
||||||
$sql.= "module,";
|
$sql .= "module,";
|
||||||
$sql.= "type,";
|
$sql .= "type,";
|
||||||
$sql.= "mainmenu,";
|
$sql .= "mainmenu,";
|
||||||
$sql.= "leftmenu,";
|
$sql .= "leftmenu,";
|
||||||
$sql.= "fk_menu,";
|
$sql .= "fk_menu,";
|
||||||
$sql.= "fk_mainmenu,";
|
$sql .= "fk_mainmenu,";
|
||||||
$sql.= "fk_leftmenu,";
|
$sql .= "fk_leftmenu,";
|
||||||
$sql.= "position,";
|
$sql .= "position,";
|
||||||
$sql.= "url,";
|
$sql .= "url,";
|
||||||
$sql.= "target,";
|
$sql .= "target,";
|
||||||
$sql.= "titre,";
|
$sql .= "titre,";
|
||||||
$sql.= "langs,";
|
$sql .= "langs,";
|
||||||
$sql.= "perms,";
|
$sql .= "perms,";
|
||||||
$sql.= "enabled,";
|
$sql .= "enabled,";
|
||||||
$sql.= "usertype";
|
$sql .= "usertype";
|
||||||
$sql.= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
$sql.= " '".$this->db->escape($this->menu_handler)."',";
|
$sql .= " '".$this->db->escape($this->menu_handler)."',";
|
||||||
$sql.= " '".$this->db->escape($conf->entity)."',";
|
$sql .= " '".$this->db->escape($conf->entity)."',";
|
||||||
$sql.= " '".$this->db->escape($this->module)."',";
|
$sql .= " '".$this->db->escape($this->module)."',";
|
||||||
$sql.= " '".$this->db->escape($this->type)."',";
|
$sql .= " '".$this->db->escape($this->type)."',";
|
||||||
$sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null
|
$sql .= " ".($this->mainmenu ? "'".$this->db->escape($this->mainmenu)."'" : "''").","; // Can't be null
|
||||||
$sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").",";
|
$sql .= " ".($this->leftmenu ? "'".$this->db->escape($this->leftmenu)."'" : "null").",";
|
||||||
$sql.= " ".((int) $this->fk_menu).",";
|
$sql .= " ".((int) $this->fk_menu).",";
|
||||||
$sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
|
$sql .= " ".($this->fk_mainmenu ? "'".$this->db->escape($this->fk_mainmenu)."'" : "null").",";
|
||||||
$sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").",";
|
$sql .= " ".($this->fk_leftmenu ? "'".$this->db->escape($this->fk_leftmenu)."'" : "null").",";
|
||||||
$sql.= " ".((int) $this->position).",";
|
$sql .= " ".((int) $this->position).",";
|
||||||
$sql.= " '".$this->db->escape($this->url)."',";
|
$sql .= " '".$this->db->escape($this->url)."',";
|
||||||
$sql.= " '".$this->db->escape($this->target)."',";
|
$sql .= " '".$this->db->escape($this->target)."',";
|
||||||
$sql.= " '".$this->db->escape($this->titre)."',";
|
$sql .= " '".$this->db->escape($this->titre)."',";
|
||||||
$sql.= " '".$this->db->escape($this->langs)."',";
|
$sql .= " '".$this->db->escape($this->langs)."',";
|
||||||
$sql.= " '".$this->db->escape($this->perms)."',";
|
$sql .= " '".$this->db->escape($this->perms)."',";
|
||||||
$sql.= " '".$this->db->escape($this->enabled)."',";
|
$sql .= " '".$this->db->escape($this->enabled)."',";
|
||||||
$sql.= " '".$this->db->escape($this->user)."'";
|
$sql .= " '".$this->db->escape($this->user)."'";
|
||||||
$sql.= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu");
|
||||||
@ -283,7 +283,7 @@ class Menubase
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,22 +312,22 @@ class Menubase
|
|||||||
//global $conf, $langs;
|
//global $conf, $langs;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->rowid=trim($this->rowid);
|
$this->rowid = trim($this->rowid);
|
||||||
$this->menu_handler=trim($this->menu_handler);
|
$this->menu_handler = trim($this->menu_handler);
|
||||||
$this->module=trim($this->module);
|
$this->module = trim($this->module);
|
||||||
$this->type=trim($this->type);
|
$this->type = trim($this->type);
|
||||||
$this->mainmenu=trim($this->mainmenu);
|
$this->mainmenu = trim($this->mainmenu);
|
||||||
$this->leftmenu=trim($this->leftmenu);
|
$this->leftmenu = trim($this->leftmenu);
|
||||||
$this->fk_menu = (int) $this->fk_menu;
|
$this->fk_menu = (int) $this->fk_menu;
|
||||||
$this->fk_mainmenu=trim($this->fk_mainmenu);
|
$this->fk_mainmenu = trim($this->fk_mainmenu);
|
||||||
$this->fk_leftmenu=trim($this->fk_leftmenu);
|
$this->fk_leftmenu = trim($this->fk_leftmenu);
|
||||||
$this->position = (int) $this->position;
|
$this->position = (int) $this->position;
|
||||||
$this->url=trim($this->url);
|
$this->url = trim($this->url);
|
||||||
$this->target=trim($this->target);
|
$this->target = trim($this->target);
|
||||||
$this->titre=trim($this->titre);
|
$this->titre = trim($this->titre);
|
||||||
$this->langs=trim($this->langs);
|
$this->langs = trim($this->langs);
|
||||||
$this->perms=trim($this->perms);
|
$this->perms = trim($this->perms);
|
||||||
$this->enabled=trim($this->enabled);
|
$this->enabled = trim($this->enabled);
|
||||||
$this->user = (int) $this->user;
|
$this->user = (int) $this->user;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
@ -335,29 +335,29 @@ class Menubase
|
|||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
|
||||||
$sql.= " menu_handler='".$this->db->escape($this->menu_handler)."',";
|
$sql .= " menu_handler='".$this->db->escape($this->menu_handler)."',";
|
||||||
$sql.= " module='".$this->db->escape($this->module)."',";
|
$sql .= " module='".$this->db->escape($this->module)."',";
|
||||||
$sql.= " type='".$this->db->escape($this->type)."',";
|
$sql .= " type='".$this->db->escape($this->type)."',";
|
||||||
$sql.= " mainmenu='".$this->db->escape($this->mainmenu)."',";
|
$sql .= " mainmenu='".$this->db->escape($this->mainmenu)."',";
|
||||||
$sql.= " leftmenu='".$this->db->escape($this->leftmenu)."',";
|
$sql .= " leftmenu='".$this->db->escape($this->leftmenu)."',";
|
||||||
$sql.= " fk_menu=".$this->fk_menu.",";
|
$sql .= " fk_menu=".$this->fk_menu.",";
|
||||||
$sql.= " fk_mainmenu=".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
|
$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 .= " fk_leftmenu=".($this->fk_leftmenu ? "'".$this->db->escape($this->fk_leftmenu)."'" : "null").",";
|
||||||
$sql.= " position=".($this->position > 0 ? $this->position : 0).",";
|
$sql .= " position=".($this->position > 0 ? $this->position : 0).",";
|
||||||
$sql.= " url='".$this->db->escape($this->url)."',";
|
$sql .= " url='".$this->db->escape($this->url)."',";
|
||||||
$sql.= " target='".$this->db->escape($this->target)."',";
|
$sql .= " target='".$this->db->escape($this->target)."',";
|
||||||
$sql.= " titre='".$this->db->escape($this->titre)."',";
|
$sql .= " titre='".$this->db->escape($this->titre)."',";
|
||||||
$sql.= " langs='".$this->db->escape($this->langs)."',";
|
$sql .= " langs='".$this->db->escape($this->langs)."',";
|
||||||
$sql.= " perms='".$this->db->escape($this->perms)."',";
|
$sql .= " perms='".$this->db->escape($this->perms)."',";
|
||||||
$sql.= " enabled='".$this->db->escape($this->enabled)."',";
|
$sql .= " enabled='".$this->db->escape($this->enabled)."',";
|
||||||
$sql.= " usertype='".$this->db->escape($this->user)."'";
|
$sql .= " usertype='".$this->db->escape($this->user)."'";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql .= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (!$resql)
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,30 +377,30 @@ class Menubase
|
|||||||
//global $langs;
|
//global $langs;
|
||||||
|
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
$sql.= " t.rowid,";
|
$sql .= " t.rowid,";
|
||||||
$sql.= " t.menu_handler,";
|
$sql .= " t.menu_handler,";
|
||||||
$sql.= " t.entity,";
|
$sql .= " t.entity,";
|
||||||
$sql.= " t.module,";
|
$sql .= " t.module,";
|
||||||
$sql.= " t.type,";
|
$sql .= " t.type,";
|
||||||
$sql.= " t.mainmenu,";
|
$sql .= " t.mainmenu,";
|
||||||
$sql.= " t.leftmenu,";
|
$sql .= " t.leftmenu,";
|
||||||
$sql.= " t.fk_menu,";
|
$sql .= " t.fk_menu,";
|
||||||
$sql.= " t.fk_mainmenu,";
|
$sql .= " t.fk_mainmenu,";
|
||||||
$sql.= " t.fk_leftmenu,";
|
$sql .= " t.fk_leftmenu,";
|
||||||
$sql.= " t.position,";
|
$sql .= " t.position,";
|
||||||
$sql.= " t.url,";
|
$sql .= " t.url,";
|
||||||
$sql.= " t.target,";
|
$sql .= " t.target,";
|
||||||
$sql.= " t.titre,";
|
$sql .= " t.titre,";
|
||||||
$sql.= " t.langs,";
|
$sql .= " t.langs,";
|
||||||
$sql.= " t.perms,";
|
$sql .= " t.perms,";
|
||||||
$sql.= " t.enabled,";
|
$sql .= " t.enabled,";
|
||||||
$sql.= " t.usertype as user,";
|
$sql .= " t.usertype as user,";
|
||||||
$sql.= " t.tms";
|
$sql .= " t.tms";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."menu as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."menu as t";
|
||||||
$sql.= " WHERE t.rowid = ".$id;
|
$sql .= " WHERE t.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows($resql))
|
if ($this->db->num_rows($resql))
|
||||||
@ -434,7 +434,7 @@ class Menubase
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -451,13 +451,13 @@ class Menubase
|
|||||||
//global $conf, $langs;
|
//global $conf, $langs;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
|
$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);
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (!$resql)
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,25 +474,25 @@ class Menubase
|
|||||||
*/
|
*/
|
||||||
public function initAsSpecimen()
|
public function initAsSpecimen()
|
||||||
{
|
{
|
||||||
$this->id=0;
|
$this->id = 0;
|
||||||
|
|
||||||
$this->menu_handler='all';
|
$this->menu_handler = 'all';
|
||||||
$this->module='specimen';
|
$this->module = 'specimen';
|
||||||
$this->type='top';
|
$this->type = 'top';
|
||||||
$this->mainmenu='';
|
$this->mainmenu = '';
|
||||||
$this->fk_menu='0';
|
$this->fk_menu = '0';
|
||||||
$this->position='';
|
$this->position = '';
|
||||||
$this->url='http://dummy';
|
$this->url = 'http://dummy';
|
||||||
$this->target='';
|
$this->target = '';
|
||||||
$this->titre='Specimen menu'; // deprecated
|
$this->titre = 'Specimen menu'; // deprecated
|
||||||
$this->title='Specimen menu';
|
$this->title = 'Specimen menu';
|
||||||
$this->langs='';
|
$this->langs = '';
|
||||||
$this->level='';
|
$this->level = '';
|
||||||
$this->leftmenu='';
|
$this->leftmenu = '';
|
||||||
$this->perms='';
|
$this->perms = '';
|
||||||
$this->enabled='';
|
$this->enabled = '';
|
||||||
$this->user='';
|
$this->user = '';
|
||||||
$this->tms='';
|
$this->tms = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -509,15 +509,15 @@ class Menubase
|
|||||||
public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
|
public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
|
||||||
{
|
{
|
||||||
global $langs, $user, $conf; // 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
|
global $mainmenu, $leftmenu; // To export to dol_eval function
|
||||||
|
|
||||||
$mainmenu=$mymainmenu; // To export to dol_eval function
|
$mainmenu = $mymainmenu; // To export to dol_eval function
|
||||||
$leftmenu=$myleftmenu; // To export to dol_eval function
|
$leftmenu = $myleftmenu; // To export to dol_eval function
|
||||||
|
|
||||||
$newTabMenu=array();
|
$newTabMenu = array();
|
||||||
foreach($tabMenu as $val)
|
foreach ($tabMenu as $val)
|
||||||
{
|
{
|
||||||
if ($val['type']=='top') $newTabMenu[]=$val;
|
if ($val['type'] == 'top') $newTabMenu[] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $newTabMenu;
|
return $newTabMenu;
|
||||||
@ -538,19 +538,19 @@ class Menubase
|
|||||||
public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
|
public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
|
||||||
{
|
{
|
||||||
global $langs, $user, $conf; // 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
|
global $mainmenu, $leftmenu; // To export to dol_eval function
|
||||||
|
|
||||||
$mainmenu=$mymainmenu; // To export to dol_eval function
|
$mainmenu = $mymainmenu; // To export to dol_eval function
|
||||||
$leftmenu=$myleftmenu; // To export to dol_eval function
|
$leftmenu = $myleftmenu; // To export to dol_eval function
|
||||||
|
|
||||||
// Detect what is top mainmenu id
|
// Detect what is top mainmenu id
|
||||||
$menutopid='';
|
$menutopid = '';
|
||||||
foreach($tabMenu as $key => $val)
|
foreach ($tabMenu as $key => $val)
|
||||||
{
|
{
|
||||||
// Define menutopid of mainmenu
|
// Define menutopid of mainmenu
|
||||||
if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu)
|
if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu)
|
||||||
{
|
{
|
||||||
$menutopid=$val['rowid'];
|
$menutopid = $val['rowid'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -562,7 +562,7 @@ class Menubase
|
|||||||
$this->recur($tabMenu, $menutopid, 1);
|
$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)
|
// 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);
|
//var_dump($tabMenu);
|
||||||
if ($val['fk_menu'] == -1 && $val['fk_mainmenu'] == $mainmenu) // We found a menu entry not linked to parent with good mainmenu
|
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
|
else
|
||||||
{
|
{
|
||||||
// Search first menu with this couple (mainmenu,leftmenu)=(fk_mainmenu,fk_leftmenu)
|
// Search first menu with this couple (mainmenu,leftmenu)=(fk_mainmenu,fk_leftmenu)
|
||||||
$searchlastsub=0;$lastid=0;$nextid=0;$found=0;
|
$searchlastsub = 0; $lastid = 0; $nextid = 0; $found = 0;
|
||||||
foreach($this->newmenu->liste as $keyparent => $valparent)
|
foreach ($this->newmenu->liste as $keyparent => $valparent)
|
||||||
{
|
{
|
||||||
//var_dump($valparent);
|
//var_dump($valparent);
|
||||||
if ($searchlastsub) // If we started to search for last submenu
|
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)
|
if ($valparent['level'] < $searchlastsub)
|
||||||
{
|
{
|
||||||
$nextid=$keyparent;
|
$nextid = $keyparent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -595,9 +595,9 @@ class Menubase
|
|||||||
{
|
{
|
||||||
//print "We found parent: keyparent='.$keyparent.' - level=".$valparent['level'].' - '.join(',',$valparent).'<br>';
|
//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)
|
// Now we look to find last subelement of this parent (we add at end)
|
||||||
$searchlastsub=($valparent['level']+1);
|
$searchlastsub = ($valparent['level'] + 1);
|
||||||
$lastid=$keyparent;
|
$lastid = $keyparent;
|
||||||
$found=1;
|
$found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print 'We must insert menu entry between entry '.$lastid.' and '.$nextid.'<br>';
|
//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 $langs, $user, $conf; // To export to dol_eval function
|
||||||
global $mainmenu, $leftmenu; // To export to dol_eval function
|
global $mainmenu, $leftmenu; // To export to dol_eval function
|
||||||
|
|
||||||
$mainmenu=$mymainmenu; // To export to dol_eval function
|
$mainmenu = $mymainmenu; // To export to dol_eval function
|
||||||
$leftmenu=$myleftmenu; // 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 = "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 .= " FROM ".MAIN_DB_PREFIX."menu as m";
|
||||||
$sql.= " WHERE m.entity IN (0,".$conf->entity.")";
|
$sql .= " WHERE m.entity IN (0,".$conf->entity.")";
|
||||||
$sql.= " AND m.menu_handler IN ('".$menu_handler."','all')";
|
$sql .= " AND m.menu_handler IN ('".$menu_handler."','all')";
|
||||||
if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)";
|
if ($type_user == 0) $sql .= " AND m.usertype IN (0,2)";
|
||||||
if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)";
|
if ($type_user == 1) $sql .= " AND m.usertype IN (1,2)";
|
||||||
$sql.= " ORDER BY m.position, m.rowid";
|
$sql .= " ORDER BY m.position, m.rowid";
|
||||||
//print $sql;
|
//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);
|
//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;
|
$perms = true;
|
||||||
if ($menu['perms'])
|
if ($menu['perms'])
|
||||||
{
|
{
|
||||||
$tmpcond=$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
|
if ($leftmenu == 'all') $tmpcond = preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
|
||||||
$perms = verifCond($tmpcond);
|
$perms = verifCond($tmpcond);
|
||||||
//print "verifCond rowid=".$menu['rowid']." ".$tmpcond.":".$perms."<br>\n";
|
//print "verifCond rowid=".$menu['rowid']." ".$tmpcond.":".$perms."<br>\n";
|
||||||
}
|
}
|
||||||
@ -668,8 +668,8 @@ class Menubase
|
|||||||
$enabled = true;
|
$enabled = true;
|
||||||
if ($menu['enabled'])
|
if ($menu['enabled'])
|
||||||
{
|
{
|
||||||
$tmpcond=$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
|
if ($leftmenu == 'all') $tmpcond = preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
|
||||||
$enabled = verifCond($tmpcond);
|
$enabled = verifCond($tmpcond);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,7 +680,7 @@ class Menubase
|
|||||||
//var_dump($title.'-'.$menu['titre']);
|
//var_dump($title.'-'.$menu['titre']);
|
||||||
if ($title == $menu['titre']) // Translation not found
|
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>';
|
//print 'Load file '.$menu['langs'].'<br>';
|
||||||
$langs->load($menu['langs']);
|
$langs->load($menu['langs']);
|
||||||
@ -715,10 +715,10 @@ class Menubase
|
|||||||
$tabMenu[$b]['module'] = $menu['module'];
|
$tabMenu[$b]['module'] = $menu['module'];
|
||||||
$tabMenu[$b]['fk_menu'] = $menu['fk_menu'];
|
$tabMenu[$b]['fk_menu'] = $menu['fk_menu'];
|
||||||
$tabMenu[$b]['url'] = $menu['url'];
|
$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'].='&idmenu='.$menu['rowid'];
|
if (preg_match('/\?/', $tabMenu[$b]['url'])) $tabMenu[$b]['url'] .= '&idmenu='.$menu['rowid'];
|
||||||
else $tabMenu[$b]['url'].='?idmenu='.$menu['rowid'];
|
else $tabMenu[$b]['url'] .= '?idmenu='.$menu['rowid'];
|
||||||
}
|
}
|
||||||
$tabMenu[$b]['titre'] = $title;
|
$tabMenu[$b]['titre'] = $title;
|
||||||
$tabMenu[$b]['target'] = $menu['target'];
|
$tabMenu[$b]['target'] = $menu['target'];
|
||||||
@ -767,10 +767,10 @@ class Menubase
|
|||||||
for ($x = 0; $x < $num; $x++)
|
for ($x = 0; $x < $num; $x++)
|
||||||
{
|
{
|
||||||
//si un element a pour pere : $pere
|
//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->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->recur($tab, $tab[$x]['rowid'], ($level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,70 +29,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("products","other"));
|
$langs->loadLangs(array("products", "other"));
|
||||||
|
|
||||||
$id=GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$action=GETPOST('action', 'alpha');
|
$action = GETPOST('action', 'alpha');
|
||||||
$modulepart=GETPOST('modulepart', 'alpha')?GETPOST('modulepart', 'alpha'):'produit|service';
|
$modulepart = GETPOST('modulepart', 'alpha') ?GETPOST('modulepart', 'alpha') : 'produit|service';
|
||||||
$original_file = GETPOST("file");
|
$original_file = GETPOST("file");
|
||||||
$backtourl=GETPOST('backtourl');
|
$backtourl = GETPOST('backtourl');
|
||||||
$cancel=GETPOST('cancel', 'alpha');
|
$cancel = GETPOST('cancel', 'alpha');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (empty($modulepart)) accessforbidden('Bad value for modulepart');
|
if (empty($modulepart)) accessforbidden('Bad value for modulepart');
|
||||||
$accessallowed=0;
|
$accessallowed = 0;
|
||||||
if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service')
|
if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, 'produit|service', $id, 'product&product');
|
$result = restrictedArea($user, 'produit|service', $id, 'product&product');
|
||||||
if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden();
|
if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'project')
|
elseif ($modulepart == 'project')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, 'projet', $id);
|
$result = restrictedArea($user, 'projet', $id);
|
||||||
if (! $user->rights->projet->lire) accessforbidden();
|
if (!$user->rights->projet->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'bom')
|
elseif ($modulepart == 'bom')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, $modulepart, $id, 'bom_bom');
|
$result = restrictedArea($user, $modulepart, $id, 'bom_bom');
|
||||||
if (! $user->rights->bom->read) accessforbidden();
|
if (!$user->rights->bom->read) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'member')
|
elseif ($modulepart == 'member')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid');
|
$result = restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid');
|
||||||
if (! $user->rights->adherent->lire) accessforbidden();
|
if (!$user->rights->adherent->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'user')
|
elseif ($modulepart == 'user')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, $modulepart, $id, $modulepart);
|
$result = restrictedArea($user, $modulepart, $id, $modulepart);
|
||||||
if (! $user->rights->user->user->lire) accessforbidden();
|
if (!$user->rights->user->user->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'tax')
|
elseif ($modulepart == 'tax')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
|
$result = restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
|
||||||
if (! $user->rights->tax->charges->lire) accessforbidden();
|
if (!$user->rights->tax->charges->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'bank')
|
elseif ($modulepart == 'bank')
|
||||||
{
|
{
|
||||||
$result=restrictedArea($user, 'banque', $id, 'bank_account');
|
$result = restrictedArea($user, 'banque', $id, 'bank_account');
|
||||||
if (! $user->rights->banque->lire) accessforbidden();
|
if (!$user->rights->banque->lire) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
else // ticket, holiday, expensereport, societe...
|
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();
|
if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) accessforbidden();
|
||||||
$accessallowed=1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security:
|
// Security:
|
||||||
// Limit access if permissions are wrong
|
// Limit access if permissions are wrong
|
||||||
if (! $accessallowed)
|
if (!$accessallowed)
|
||||||
{
|
{
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
@ -106,9 +106,9 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
||||||
$dir=$conf->product->multidir_output[$object->entity]; // By default
|
$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_PRODUCT) $dir = $conf->product->multidir_output[$object->entity];
|
||||||
if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity];
|
if ($object->type == Product::TYPE_SERVICE) $dir = $conf->service->multidir_output[$object->entity];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'project')
|
elseif ($modulepart == 'project')
|
||||||
@ -119,7 +119,7 @@ elseif ($modulepart == 'project')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'holiday')
|
||||||
@ -130,7 +130,7 @@ elseif ($modulepart == 'holiday')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'member')
|
||||||
@ -141,7 +141,7 @@ elseif ($modulepart == 'member')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'societe')
|
||||||
@ -152,7 +152,7 @@ elseif ($modulepart == 'societe')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
||||||
$dir=$conf->$modulepart->dir_output;
|
$dir = $conf->$modulepart->dir_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'user')
|
elseif ($modulepart == 'user')
|
||||||
@ -163,7 +163,7 @@ elseif ($modulepart == 'user')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'expensereport')
|
||||||
@ -174,7 +174,7 @@ elseif ($modulepart == 'expensereport')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'tax')
|
||||||
@ -185,7 +185,7 @@ elseif ($modulepart == 'tax')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'ticket')
|
||||||
@ -196,7 +196,7 @@ elseif ($modulepart == 'ticket')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'bom')
|
||||||
@ -207,7 +207,7 @@ elseif ($modulepart == 'bom')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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')
|
elseif ($modulepart == 'bank')
|
||||||
@ -218,7 +218,7 @@ elseif ($modulepart == 'bank')
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result <= 0) dol_print_error($db, 'Failed to load object');
|
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 {
|
else {
|
||||||
@ -227,17 +227,17 @@ else {
|
|||||||
|
|
||||||
if (empty($backtourl))
|
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"]);
|
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('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('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('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('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('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('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('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('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"]);
|
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"]);
|
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"]) != ""))
|
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)
|
if ($result == $fullpath)
|
||||||
{
|
{
|
||||||
@ -274,7 +274,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
|||||||
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
|
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||||
$ecmfile=new EcmFiles($db);
|
$ecmfile = new EcmFiles($db);
|
||||||
$result = $ecmfile->fetch(0, '', $rel_filename);
|
$result = $ecmfile->fetch(0, '', $rel_filename);
|
||||||
if ($result > 0) // If found
|
if ($result > 0) // If found
|
||||||
{
|
{
|
||||||
@ -322,18 +322,18 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($result, null, 'errors');
|
setEventMessages($result, null, 'errors');
|
||||||
$_GET['file']=$_POST["file"];
|
$_GET['file'] = $_POST["file"];
|
||||||
$action='';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crop d'une image
|
// Crop d'une image
|
||||||
if ($action == 'confirm_crop')
|
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;
|
//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)
|
if ($result == $fullpath)
|
||||||
{
|
{
|
||||||
@ -344,7 +344,7 @@ if ($action == 'confirm_crop')
|
|||||||
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
|
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||||
$ecmfile=new EcmFiles($db);
|
$ecmfile = new EcmFiles($db);
|
||||||
$result = $ecmfile->fetch(0, '', $rel_filename);
|
$result = $ecmfile->fetch(0, '', $rel_filename);
|
||||||
if ($result > 0) // If found
|
if ($result > 0) // If found
|
||||||
{
|
{
|
||||||
@ -392,8 +392,8 @@ if ($action == 'confirm_crop')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($result, null, 'errors');
|
setEventMessages($result, null, 'errors');
|
||||||
$_GET['file']=$_POST["file"];
|
$_GET['file'] = $_POST["file"];
|
||||||
$action='';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,14 +402,14 @@ if ($action == 'confirm_crop')
|
|||||||
* View
|
* 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"));
|
print load_fiche_titre($langs->trans("ImageEditor"));
|
||||||
|
|
||||||
$infoarray=dol_getImageSize($dir."/".GETPOST("file", 'alpha'));
|
$infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha'));
|
||||||
$height=$infoarray['height'];
|
$height = $infoarray['height'];
|
||||||
$width=$infoarray['width'];
|
$width = $infoarray['width'];
|
||||||
print $langs->trans("CurrentInformationOnImage").': ';
|
print $langs->trans("CurrentInformationOnImage").': ';
|
||||||
print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>';
|
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";
|
print '<br>'."\n";
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if (!empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
$infoarray=dol_getImageSize($dir."/".GETPOST("file"));
|
$infoarray = dol_getImageSize($dir."/".GETPOST("file"));
|
||||||
$height=$infoarray['height'];
|
$height = $infoarray['height'];
|
||||||
$width=$infoarray['width'];
|
$width = $infoarray['width'];
|
||||||
$widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1;
|
$widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1;
|
||||||
// If image is too large, we use another scale.
|
// 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;
|
$ratioforcrop = 2;
|
||||||
$widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop);
|
$widthforcrop = round($_SESSION['dol_screenwidth'] / $ratioforcrop);
|
||||||
$refsizeforcrop='screenwidth';
|
$refsizeforcrop = 'screenwidth';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<!-- Form to crop -->'."\n";
|
print '<!-- Form to crop -->'."\n";
|
||||||
|
|||||||
@ -912,20 +912,20 @@ class Thirdparties extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($id)) {
|
if (empty($id)) {
|
||||||
throw new RestException(400, 'Thirdparty ID is mandatory');
|
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);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->company->fetch($id);
|
$result = $this->company->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Thirdparty not found');
|
throw new RestException(404, 'Thirdparty not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1366,7 +1366,7 @@ class Thirdparties extends DolibarrApi
|
|||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$object = array();
|
$object = array();
|
||||||
foreach ($account as $key => $value) {
|
foreach ($account as $key => $value) {
|
||||||
if(in_array($key, $fields)) {
|
if (in_array($key, $fields)) {
|
||||||
$object[$key] = $value;
|
$object[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1488,11 +1488,11 @@ class Thirdparties extends DolibarrApi
|
|||||||
// We found an existing SocieteAccount entity, we are replacing it
|
// We found an existing SocieteAccount entity, we are replacing it
|
||||||
} else {
|
} else {
|
||||||
if (isset($request_data['site']) && $request_data['site'] !== $site) {
|
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);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result->num_rows !== 0) {
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 = '')
|
private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
if (!DolibarrApiAccess::$user->rights->societe->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias);
|
$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');
|
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);
|
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
|
$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
|
$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 {
|
} else {
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class Users extends DolibarrApi
|
|||||||
|
|
||||||
$obj_ret = array();
|
$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");
|
throw new RestException(401, "You are not allowed to read list of users");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,21 +79,21 @@ class Users extends DolibarrApi
|
|||||||
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
|
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
|
||||||
|
|
||||||
$sql = "SELECT t.rowid";
|
$sql = "SELECT t.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('user').')';
|
$sql .= ' WHERE t.entity IN ('.getEntity('user').')';
|
||||||
if ($user_ids) $sql.=" AND t.rowid IN (".$user_ids.")";
|
if ($user_ids) $sql .= " AND t.rowid IN (".$user_ids.")";
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters)
|
if ($sqlfilters)
|
||||||
{
|
{
|
||||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||||
{
|
{
|
||||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||||
}
|
}
|
||||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0)
|
if ($page < 0)
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ class Users extends DolibarrApi
|
|||||||
}
|
}
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
|
|
||||||
$sql.= $db->plimit($limit + 1, $offset);
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
@ -115,7 +115,7 @@ class Users extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$user_static = new User($db);
|
$user_static = new User($db);
|
||||||
if($user_static->fetch($obj->rowid)) {
|
if ($user_static->fetch($obj->rowid)) {
|
||||||
$obj_ret[] = $this->_cleanObjectDatas($user_static);
|
$obj_ret[] = $this->_cleanObjectDatas($user_static);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
@ -124,7 +124,7 @@ class Users extends DolibarrApi
|
|||||||
else {
|
else {
|
||||||
throw new RestException(503, 'Error when retrieve User list : '.$db->lasterror());
|
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');
|
throw new RestException(404, 'No User found');
|
||||||
}
|
}
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
@ -154,7 +154,7 @@ class Users extends DolibarrApi
|
|||||||
|
|
||||||
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
|
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);
|
return $this->_cleanObjectDatas($this->useraccount);
|
||||||
@ -181,7 +181,7 @@ class Users extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
|
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);
|
$usergroup = new UserGroup($this->db);
|
||||||
@ -250,7 +250,7 @@ class Users extends DolibarrApi
|
|||||||
|
|
||||||
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
|
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)
|
foreach ($request_data as $field => $value)
|
||||||
@ -295,13 +295,13 @@ class Users extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
if (! DolibarrApiAccess::$user->rights->user->user->lire) {
|
if (!DolibarrApiAccess::$user->rights->user->user->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new User($this->db);
|
$user = new User($this->db);
|
||||||
$result = $user->fetch($id);
|
$result = $user->fetch($id);
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'user not found');
|
throw new RestException(404, 'user not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,12 +341,12 @@ class Users extends DolibarrApi
|
|||||||
|
|
||||||
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -356,7 +356,7 @@ class Users extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->useraccount->SetInGroup($group, $entity);
|
$result = $this->useraccount->SetInGroup($group, $entity);
|
||||||
if (! ($result > 0))
|
if (!($result > 0))
|
||||||
{
|
{
|
||||||
throw new RestException(500, $this->useraccount->error);
|
throw new RestException(500, $this->useraccount->error);
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ class Users extends DolibarrApi
|
|||||||
|
|
||||||
if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user'))
|
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;
|
$this->useraccount->oldcopy = clone $this->useraccount;
|
||||||
return $this->useraccount->delete(DolibarrApiAccess::$user);
|
return $this->useraccount->delete(DolibarrApiAccess::$user);
|
||||||
@ -435,10 +435,10 @@ class Users extends DolibarrApi
|
|||||||
unset($object->openid);
|
unset($object->openid);
|
||||||
|
|
||||||
|
|
||||||
$canreadsalary = ((! empty($conf->salaries->enabled) && ! empty(DolibarrApiAccess::$user->rights->salaries->read))
|
$canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read))
|
||||||
|| (! empty($conf->hrm->enabled) && ! empty(DolibarrApiAccess::$user->rights->hrm->employee->read)));
|
|| (!empty($conf->hrm->enabled) && !empty(DolibarrApiAccess::$user->rights->hrm->employee->read)));
|
||||||
|
|
||||||
if (! $canreadsalary)
|
if (!$canreadsalary)
|
||||||
{
|
{
|
||||||
unset($object->salary);
|
unset($object->salary);
|
||||||
unset($object->salaryextra);
|
unset($object->salaryextra);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user