Fix: Too many parameter

Fix: Can't delete bank account
This commit is contained in:
Laurent Destailleur 2014-08-01 14:51:40 +02:00
parent bb8ec0c8f9
commit 605919be76
5 changed files with 80 additions and 81 deletions

View File

@ -35,6 +35,7 @@ $langs->load("bills");
$action=GETPOST('action'); $action=GETPOST('action');
$id=GETPOST('id'); $id=GETPOST('id');
$ref=GETPOST('ref');
// Security check // Security check
if (isset($_GET["id"]) || isset($_GET["ref"])) if (isset($_GET["id"]) || isset($_GET["ref"]))
@ -89,7 +90,8 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
{ {
// Modification // Modification
$account = new Account($db); $account = new Account($db);
$account->delete($_GET["id"]); $account->fetch($id);
$account->delete();
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php"); header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
exit; exit;

View File

@ -106,11 +106,11 @@ class Localtax extends CommonObject
// Call trigger // Call trigger
$result=$this->call_trigger('LOCALTAX_CREATE',$user); $result=$this->call_trigger('LOCALTAX_CREATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
//FIXME: Add rollback if trigger fail //FIXME: Add rollback if trigger fail
return $this->id; return $this->id;
} }
else else
@ -167,9 +167,9 @@ class Localtax extends CommonObject
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LOCALTAX_MODIFY',$user); $result=$this->call_trigger('LOCALTAX_MODIFY',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
//FIXME: Add rollback if trigger fail //FIXME: Add rollback if trigger fail
} }
@ -257,8 +257,8 @@ class Localtax extends CommonObject
$result=$this->call_trigger('LOCALTAX_DELETE',$user); $result=$this->call_trigger('LOCALTAX_DELETE',$user);
if ($result < 0) return -1; if ($result < 0) return -1;
// End call triggers // End call triggers
$sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -326,35 +326,32 @@ class Localtax extends CommonObject
*/ */
function localtax_sum_collectee($year = 0) function localtax_sum_collectee($year = 0)
{ {
$sql = "SELECT sum(f.localtax) as amount"; $sql = "SELECT sum(f.localtax) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
if ($year) if ($year)
{ {
$sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; $sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->amount; $ret = $obj->amount;
$this->db->free($result);
return $ret;
} }
else else
{ {
return 0; $this->db->free($result);
return 0;
} }
$this->db->free($result);
} }
else else
{ {
print $this->db->error(); print $this->db->lasterror();
return -1; return -1;
} }
} }
@ -370,31 +367,30 @@ class Localtax extends CommonObject
$sql = "SELECT sum(f.total_localtax) as total_localtax"; $sql = "SELECT sum(f.total_localtax) as total_localtax";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
if ($year) if ($year)
{ {
$sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; $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 ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->total_localtax; $ret = $obj->total_localtax;
$this->db->free($result);
return $ret;
} }
else else
{ {
return 0; $this->db->free($result);
return 0;
} }
$this->db->free();
} }
else else
{ {
print $this->db->error(); print $this->db->lasterror();
return -1; return -1;
} }
} }
@ -412,32 +408,30 @@ class Localtax extends CommonObject
$sql = "SELECT sum(f.amount) as amount"; $sql = "SELECT sum(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f"; $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
if ($year) if ($year)
{ {
$sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' "; $sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->amount; $ret = $obj->amount;
$this->db->free($result);
return $ret;
} }
else else
{ {
return 0; $this->db->free($result);
return 0;
} }
$this->db->free();
} }
else else
{ {
print $this->db->error(); print $this->db->lasterror();
return -1; return -1;
} }
} }
@ -543,14 +537,14 @@ class Localtax extends CommonObject
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }

View File

@ -123,7 +123,7 @@ class Tva extends CommonObject
// Call trigger // Call trigger
$result=$this->call_trigger('TVA_CREATE',$user); $result=$this->call_trigger('TVA_CREATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
//FIXME: Add rollback if trigger fail //FIXME: Add rollback if trigger fail
@ -138,7 +138,7 @@ class Tva extends CommonObject
/** /**
* Update database * Update database
* *
* @param User $user User that modify * @param User $user User that modify
* @param int $notrigger 0=no, 1=yes (no update trigger) * @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -188,9 +188,9 @@ class Tva extends CommonObject
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('TVA_MODIFY',$user); $result=$this->call_trigger('TVA_MODIFY',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
//FIXME: Add rollback if trigger fail //FIXME: Add rollback if trigger fail
} }
@ -200,7 +200,7 @@ class Tva extends CommonObject
/** /**
* Load object in memory from database * Load object in memory from database
* *
* @param int $id id object * @param int $id id object
* @param User $user User that load * @param User $user User that load
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -269,7 +269,7 @@ class Tva extends CommonObject
/** /**
* Delete object in database * Delete object in database
* *
* @param User $user User that delete * @param User $user User that delete
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
@ -278,12 +278,12 @@ class Tva extends CommonObject
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
// Call trigger // Call trigger
$result=$this->call_trigger('TVA_DELETE',$user); $result=$this->call_trigger('TVA_DELETE',$user);
if ($result < 0) return -1; if ($result < 0) return -1;
// End call triggers // End call triggers
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -325,7 +325,7 @@ class Tva extends CommonObject
/** /**
* Balance of VAT * Balance of VAT
* *
* @param int $year Year * @param int $year Year
* @return double Amount * @return double Amount
*/ */
@ -344,7 +344,7 @@ class Tva extends CommonObject
/** /**
* Total of the VAT from invoices emitted by the society. * Total of the VAT from invoices emitted by the society.
* *
* @param int $year Year * @param int $year Year
* @return double Amount * @return double Amount
*/ */
@ -353,32 +353,30 @@ class Tva extends CommonObject
$sql = "SELECT sum(f.tva) as amount"; $sql = "SELECT sum(f.tva) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
if ($year) if ($year)
{ {
$sql .= " AND f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' "; $sql .= " AND f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' ";
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->amount; $ret = $obj->amount;
$this->db->free($result);
return $ret;
} }
else else
{ {
return 0; $this->db->free($result);
return 0;
} }
$this->db->free($result);
} }
else else
{ {
print $this->db->error(); print $this->db->lasterror();
return -1; return -1;
} }
} }
@ -394,31 +392,30 @@ class Tva extends CommonObject
$sql = "SELECT sum(f.total_tva) as total_tva"; $sql = "SELECT sum(f.total_tva) as total_tva";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
if ($year) if ($year)
{ {
$sql .= " WHERE f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' "; $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 ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->total_tva; $ret = $obj->total_tva;
$this->db->free($result);
return $ret;
} }
else else
{ {
return 0; $this->db->free($result);
return 0;
} }
$this->db->free();
} }
else else
{ {
print $this->db->error(); print $this->db->lasterror();
return -1; return -1;
} }
} }
@ -442,25 +439,24 @@ class Tva extends CommonObject
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
return $obj->amount; $ret = $obj->amount;
$this->db->free($result);
return $ret;
} }
else else
{ {
return 0; $this->db->free($result);
return 0;
} }
$this->db->free();
} }
else else
{ {
print $this->db->error(); print $this->db->lasterror();
return -1; return -1;
} }
} }
@ -485,7 +481,7 @@ class Tva extends CommonObject
$this->fk_bank=trim($this->fk_bank); $this->fk_bank=trim($this->fk_bank);
$this->fk_user_creat=trim($this->fk_user_creat); $this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif); $this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters // Check parameters
if (! $this->label) if (! $this->label)
{ {
@ -542,13 +538,13 @@ class Tva extends CommonObject
// Call trigger // Call trigger
//XXX: Should be done just befor commit no ? //XXX: Should be done just befor commit no ?
$result=$this->call_trigger('TVA_ADDPAYMENT',$user); $result=$this->call_trigger('TVA_ADDPAYMENT',$user);
if ($result < 0) if ($result < 0)
{ {
$this->id = 0; $this->id = 0;
$ok = 0; $ok = 0;
} }
// End call triggers // End call triggers
if ($this->id > 0) if ($this->id > 0)
{ {
$ok=1; $ok=1;

View File

@ -68,7 +68,7 @@ if ($action == 'setstocklimit')
$product = new Product($db); $product = new Product($db);
$result=$product->fetch($id); $result=$product->fetch($id);
$product->seuil_stock_alerte=$stocklimit; $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) if ($result < 0)
setEventMessage($product->error, 'errors'); setEventMessage($product->error, 'errors');
$action=''; $action='';
@ -80,7 +80,7 @@ if ($action == 'setdesiredstock')
$product = new Product($db); $product = new Product($db);
$result=$product->fetch($id); $result=$product->fetch($id);
$product->desiredstock=$desiredstock; $product->desiredstock=$desiredstock;
$result=$product->update($product->id,$user,1,0,1); $result=$product->update($product->id,$user,0,'update');
if ($result < 0) if ($result < 0)
setEventMessage($product->error, 'errors'); setEventMessage($product->error, 'errors');
$action=''; $action='';
@ -154,7 +154,7 @@ if ($action == "correct_stock" && ! $cancel)
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id);
exit; exit;
} }
else else
{ {
setEventMessage($product->error,'errors'); setEventMessage($product->error,'errors');
$action='correction'; $action='correction';
@ -258,7 +258,7 @@ if ($id > 0 || $ref)
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'stock', $titre, 0, $picto); dol_fiche_head($head, 'stock', $titre, 0, $picto);
dol_htmloutput_events(); dol_htmloutput_events();
$form = new Form($db); $form = new Form($db);

View File

@ -279,6 +279,7 @@ if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivat
if (empty($user->societe_id)) print showModulesExludedForExternal($modules).'<br><br>'."\n"; if (empty($user->societe_id)) print showModulesExludedForExternal($modules).'<br><br>'."\n";
// For multicompany transversal mode // For multicompany transversal mode
// TODO Place a hook here
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
{ {
$aEntities=array_keys($permsgroupbyentity); $aEntities=array_keys($permsgroupbyentity);
@ -422,6 +423,12 @@ if ($result)
else dol_print_error($db); else dol_print_error($db);
print '</table>'; 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(); dol_fiche_end();