Fix: Too many parameter
Fix: Can't delete bank account
This commit is contained in:
parent
bb8ec0c8f9
commit
605919be76
@ -35,6 +35,7 @@ $langs->load("bills");
|
||||
|
||||
$action=GETPOST('action');
|
||||
$id=GETPOST('id');
|
||||
$ref=GETPOST('ref');
|
||||
|
||||
// Security check
|
||||
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
||||
@ -89,7 +90,8 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
|
||||
{
|
||||
// Modification
|
||||
$account = new Account($db);
|
||||
$account->delete($_GET["id"]);
|
||||
$account->fetch($id);
|
||||
$account->delete();
|
||||
|
||||
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
|
||||
exit;
|
||||
|
||||
@ -106,11 +106,11 @@ class Localtax extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LOCALTAX_CREATE',$user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
//FIXME: Add rollback if trigger fail
|
||||
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
@ -167,9 +167,9 @@ class Localtax extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LOCALTAX_MODIFY',$user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
|
||||
//FIXME: Add rollback if trigger fail
|
||||
}
|
||||
|
||||
@ -257,8 +257,8 @@ class Localtax extends CommonObject
|
||||
$result=$this->call_trigger('LOCALTAX_DELETE',$user);
|
||||
if ($result < 0) return -1;
|
||||
// End call triggers
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
@ -326,35 +326,32 @@ class Localtax extends CommonObject
|
||||
*/
|
||||
function localtax_sum_collectee($year = 0)
|
||||
{
|
||||
|
||||
$sql = "SELECT sum(f.localtax) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
|
||||
|
||||
if ($year)
|
||||
{
|
||||
$sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
return $obj->amount;
|
||||
$ret = $obj->amount;
|
||||
$this->db->free($result);
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
$this->db->free($result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
{
|
||||
print $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -370,31 +367,30 @@ class Localtax extends CommonObject
|
||||
|
||||
$sql = "SELECT sum(f.total_localtax) as total_localtax";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
|
||||
if ($year)
|
||||
{
|
||||
$sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
return $obj->total_localtax;
|
||||
$ret = $obj->total_localtax;
|
||||
$this->db->free($result);
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
$this->db->free($result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -412,32 +408,30 @@ class Localtax extends CommonObject
|
||||
|
||||
$sql = "SELECT sum(f.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
|
||||
|
||||
if ($year)
|
||||
{
|
||||
$sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
return $obj->amount;
|
||||
$ret = $obj->amount;
|
||||
$this->db->free($result);
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
$this->db->free($result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -543,14 +537,14 @@ class Localtax extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ class Tva extends CommonObject
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TVA_CREATE',$user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
//FIXME: Add rollback if trigger fail
|
||||
@ -138,7 +138,7 @@ class Tva extends CommonObject
|
||||
|
||||
/**
|
||||
* Update database
|
||||
*
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 0=no, 1=yes (no update trigger)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
@ -188,9 +188,9 @@ class Tva extends CommonObject
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TVA_MODIFY',$user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
|
||||
//FIXME: Add rollback if trigger fail
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ class Tva extends CommonObject
|
||||
|
||||
/**
|
||||
* Load object in memory from database
|
||||
*
|
||||
*
|
||||
* @param int $id id object
|
||||
* @param User $user User that load
|
||||
* @return int <0 if KO, >0 if OK
|
||||
@ -269,7 +269,7 @@ class Tva extends CommonObject
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
@ -278,12 +278,12 @@ class Tva extends CommonObject
|
||||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TVA_DELETE',$user);
|
||||
if ($result < 0) return -1;
|
||||
// End call triggers
|
||||
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
@ -325,7 +325,7 @@ class Tva extends CommonObject
|
||||
|
||||
/**
|
||||
* Balance of VAT
|
||||
*
|
||||
*
|
||||
* @param int $year Year
|
||||
* @return double Amount
|
||||
*/
|
||||
@ -344,7 +344,7 @@ class Tva extends CommonObject
|
||||
|
||||
/**
|
||||
* Total of the VAT from invoices emitted by the society.
|
||||
*
|
||||
*
|
||||
* @param int $year Year
|
||||
* @return double Amount
|
||||
*/
|
||||
@ -353,32 +353,30 @@ class Tva extends CommonObject
|
||||
|
||||
$sql = "SELECT sum(f.tva) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
|
||||
|
||||
if ($year)
|
||||
{
|
||||
$sql .= " AND f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' ";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
return $obj->amount;
|
||||
$ret = $obj->amount;
|
||||
$this->db->free($result);
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
$this->db->free($result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -394,31 +392,30 @@ class Tva extends CommonObject
|
||||
|
||||
$sql = "SELECT sum(f.total_tva) as total_tva";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
|
||||
if ($year)
|
||||
{
|
||||
$sql .= " WHERE f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' ";
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
return $obj->total_tva;
|
||||
$ret = $obj->total_tva;
|
||||
$this->db->free($result);
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
$this->db->free($result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -442,25 +439,24 @@ class Tva extends CommonObject
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
return $obj->amount;
|
||||
$ret = $obj->amount;
|
||||
$this->db->free($result);
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
$this->db->free($result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -485,7 +481,7 @@ class Tva extends CommonObject
|
||||
$this->fk_bank=trim($this->fk_bank);
|
||||
$this->fk_user_creat=trim($this->fk_user_creat);
|
||||
$this->fk_user_modif=trim($this->fk_user_modif);
|
||||
|
||||
|
||||
// Check parameters
|
||||
if (! $this->label)
|
||||
{
|
||||
@ -542,13 +538,13 @@ class Tva extends CommonObject
|
||||
// Call trigger
|
||||
//XXX: Should be done just befor commit no ?
|
||||
$result=$this->call_trigger('TVA_ADDPAYMENT',$user);
|
||||
if ($result < 0)
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->id = 0;
|
||||
$ok = 0;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
|
||||
if ($this->id > 0)
|
||||
{
|
||||
$ok=1;
|
||||
|
||||
@ -68,7 +68,7 @@ if ($action == 'setstocklimit')
|
||||
$product = new Product($db);
|
||||
$result=$product->fetch($id);
|
||||
$product->seuil_stock_alerte=$stocklimit;
|
||||
$result=$product->update($product->id,$user,1,0,1);
|
||||
$result=$product->update($product->id,$user,0,'update');
|
||||
if ($result < 0)
|
||||
setEventMessage($product->error, 'errors');
|
||||
$action='';
|
||||
@ -80,7 +80,7 @@ if ($action == 'setdesiredstock')
|
||||
$product = new Product($db);
|
||||
$result=$product->fetch($id);
|
||||
$product->desiredstock=$desiredstock;
|
||||
$result=$product->update($product->id,$user,1,0,1);
|
||||
$result=$product->update($product->id,$user,0,'update');
|
||||
if ($result < 0)
|
||||
setEventMessage($product->error, 'errors');
|
||||
$action='';
|
||||
@ -154,7 +154,7 @@ if ($action == "correct_stock" && ! $cancel)
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
setEventMessage($product->error,'errors');
|
||||
$action='correction';
|
||||
@ -258,7 +258,7 @@ if ($id > 0 || $ref)
|
||||
$titre=$langs->trans("CardProduct".$product->type);
|
||||
$picto=($product->type==1?'service':'product');
|
||||
dol_fiche_head($head, 'stock', $titre, 0, $picto);
|
||||
|
||||
|
||||
dol_htmloutput_events();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
@ -279,6 +279,7 @@ if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivat
|
||||
if (empty($user->societe_id)) print showModulesExludedForExternal($modules).'<br><br>'."\n";
|
||||
|
||||
// For multicompany transversal mode
|
||||
// TODO Place a hook here
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
{
|
||||
$aEntities=array_keys($permsgroupbyentity);
|
||||
@ -422,6 +423,12 @@ if ($result)
|
||||
else dol_print_error($db);
|
||||
print '</table>';
|
||||
|
||||
// For multicompany transversal mode
|
||||
// TODO Place a hook here
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
{
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user