Skip to content
Snippets Groups Projects
Commit 2dadffa9 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Uniformize code

parent d7d353ae
No related branches found
No related tags found
No related merge requests found
...@@ -238,7 +238,7 @@ class Societe extends CommonObject ...@@ -238,7 +238,7 @@ class Societe extends CommonObject
dol_syslog("Societe::Create success id=".$this->id); dol_syslog("Societe::Create success id=".$this->id);
$this->db->commit(); $this->db->commit();
return 0; return $this->id;
} }
else else
{ {
...@@ -550,26 +550,6 @@ class Societe extends CommonObject ...@@ -550,26 +550,6 @@ class Societe extends CommonObject
if (empty($socid) && empty($ref)) return -1; if (empty($socid) && empty($ref)) return -1;
// Init data for telephonie module
if ($conf->telephonie->enabled && $user && $user->id)
{
/* Lecture des permissions */
$sql = "SELECT p.pread, p.pwrite, p.pperms";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_perms as p";
$sql .= " WHERE p.fk_user = '".$user->id."'";
$sql .= " AND p.fk_soc = '".$socid."';";
$resql=$this->db->query($sql);
if ($resql)
{
if ($row = $this->db->fetch_row($resql))
{
$this->perm_read = $row[0];
$this->perm_write = $row[1];
$this->perm_perms = $row[2];
}
}
}
$sql = 'SELECT s.rowid, s.nom, s.entity, s.address, s.datec as dc, s.prefix_comm'; $sql = 'SELECT s.rowid, s.nom, s.entity, s.address, s.datec as dc, s.prefix_comm';
$sql .= ', s.price_level'; $sql .= ', s.price_level';
$sql .= ', s.tms as date_update'; $sql .= ', s.tms as date_update';
...@@ -785,8 +765,8 @@ class Societe extends CommonObject ...@@ -785,8 +765,8 @@ class Societe extends CommonObject
} }
/** /**
* \brief Suppression d'une societe de la base avec ses dependances (contacts, rib...) * Delete a third party from database and all its dependencies (contacts, rib...)
* \param id id de la societe a supprimer * @param id id of third party to delete
*/ */
function delete($id) function delete($id)
{ {
...@@ -921,7 +901,7 @@ class Societe extends CommonObject ...@@ -921,7 +901,7 @@ class Societe extends CommonObject
dol_delete_dir_recursive($docdir); dol_delete_dir_recursive($docdir);
} }
return 0; return 1;
} }
else else
{ {
...@@ -1244,8 +1224,11 @@ class Societe extends CommonObject ...@@ -1244,8 +1224,11 @@ class Societe extends CommonObject
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1;
} }
return 1;
} }
return -1;
} }
/** /**
...@@ -1861,8 +1844,8 @@ class Societe extends CommonObject ...@@ -1861,8 +1844,8 @@ class Societe extends CommonObject
} }
/** /**
* \brief Charge les informations d'ordre info dans l'objet societe * Charge les informations d'ordre info dans l'objet societe
* \param id id de la societe a charger * @param id id de la societe a charger
*/ */
function info($id) function info($id)
{ {
...@@ -2144,6 +2127,34 @@ class Societe extends CommonObject ...@@ -2144,6 +2127,34 @@ class Societe extends CommonObject
} }
} }
/**
* Initialise an example of company with random values
* Used to build previews or test instances
*/
function initAsSpecimen()
{
global $user,$langs,$conf,$mysoc;
// Initialize parameters
$this->id=0;
$this->nom = 'SPECIMEN';
$this->specimen=1;
$this->cp='99999';
$this->ville='MyTown';
$this->pays_id=1;
$this->pays_code='FR';
$this->siren='123456789';
$this->siret='ABCDE';
$this->capital=10000;
$this->client=1;
$this->prospect=1;
$this->fournisseur=1;
$this->note_public='This is a comment (public)';
$this->note='This is a comment (private)';
}
} }
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment