Skip to content

Commit

Permalink
Fix update entrepot
Browse files Browse the repository at this point in the history
fix int for fk_parent
clean parenthesis
fix clean parameter country_id
  • Loading branch information
fappels committed Nov 15, 2016
1 parent 59ba5ef commit eeb62ea
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions htdocs/product/stock/class/entrepot.class.php
Expand Up @@ -174,10 +174,12 @@ function create($user)
function update($id, $user)
{
// Check if new parent is already a child of current warehouse
if(!empty($this->fk_parent)) {
if(!empty($this->fk_parent))
{
$TChildWarehouses = array($id);
$TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses);
if(in_array($this->fk_parent, $TChildWarehouses)) {
if(in_array($this->fk_parent, $TChildWarehouses))
{
$this->error = 'ErrorCannotAddThisParentWarehouse';
return -2;
}
Expand All @@ -189,13 +191,13 @@ function update($id, $user)
$this->lieu=trim($this->lieu);

$this->address=trim($this->address);
$this->zip=trim($this->zip);
$this->town=trim($this->town);
$this->country_id=($this->country_id > 0 ? $this->country_id : $this->country_id);
$this->zip=trim($this->zip);
$this->town=trim($this->town);
$this->country_id=($this->country_id > 0 ? $this->country_id : 0);

$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
$sql .= " SET label = '" . $this->db->escape($this->libelle) ."'";
$sql .= ", fk_parent = '" . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL') ."'";
$sql .= ", fk_parent = " . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL');
$sql .= ", description = '" . $this->db->escape($this->description) ."'";
$sql .= ", statut = " . $this->statut;
$sql .= ", lieu = '" . $this->db->escape($this->lieu) ."'";
Expand Down

0 comments on commit eeb62ea

Please sign in to comment.