Merge branch '3.5' of git@github.com:Dolibarr/dolibarr.git into 3.5

This commit is contained in:
Laurent Destailleur 2014-06-28 01:54:20 +02:00
commit d903db6a18
8 changed files with 141 additions and 25 deletions

View File

@ -36,8 +36,12 @@ Fix: If multiprice level is used the VAT on addline is not correct
Fix: [ bug #1254 ] Error when using "Enter" on qty input box of a product (on supplier order part) Fix: [ bug #1254 ] Error when using "Enter" on qty input box of a product (on supplier order part)
Fix: [ bug #1462, 1468, 1480, 1483, 1490, 1497] $this instead of $object Fix: [ bug #1462, 1468, 1480, 1483, 1490, 1497] $this instead of $object
Fix: [ bug #1455 ] outstanding amount Fix: [ bug #1455 ] outstanding amount
Fix: [ bug #1425 ]
Fix: [ bug #1425 ] LINEBILL_SUPPLIER_DELETE failure trigger leads to an endless loop Fix: [ bug #1425 ] LINEBILL_SUPPLIER_DELETE failure trigger leads to an endless loop
Fix: [ bug #1460 ] Several supplier order triggers do not show error messages
Fix: [ bug #1461 ] LINEORDER_SUPPLIER_CREATE does not intercept supplier order line insertion
Fix: [ bug #1484 ] BILL_SUPPLIER_PAYED trigger action does not intercept failure under some circumstances
Fix: [ bug #1482 ] Several supplier invoice triggers do not show trigger error messages
Fix: [ bug #1486 ] LINEBILL_SUPPLIER_CREATE and LINEBILL_SUPPLIER_UPDATE triggers do not intercept trigger action
***** ChangeLog for 3.5.3 compared to 3.5.2 ***** ***** ChangeLog for 3.5.3 compared to 3.5.2 *****
Fix: Error on field accountancy code for export profile of invoices. Fix: Error on field accountancy code for export profile of invoices.

View File

@ -257,10 +257,30 @@ class InterfaceDemo
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }
elseif ($action == 'ORDER_SUPPLIER_CLONE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_VALIDATE') elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }
elseif ($action == 'ORDER_SUPPLIER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_APPROVE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_REFUSE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_CANCEL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -411,6 +431,28 @@ class InterfaceDemo
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }
//Supplier Bill
elseif ($action == 'BILL_SUPPLIER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_PAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_UNPAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_SUPPLIER_CREATE') elseif ($action == 'LINEBILL_SUPPLIER_CREATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);

View File

@ -390,7 +390,13 @@ class CommandeFournisseur extends CommonOrder
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('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }
@ -401,9 +407,9 @@ class CommandeFournisseur extends CommonOrder
} }
else else
{ {
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->lasterror();
return -1; return -1;
} }
} }
@ -744,7 +750,6 @@ class CommandeFournisseur extends CommonOrder
else else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->lasterror();
return -1; return -1;
} }
} }
@ -779,6 +784,8 @@ class CommandeFournisseur extends CommonOrder
$result = 0; $result = 0;
if ($user->rights->fournisseur->commande->approuver) if ($user->rights->fournisseur->commande->approuver)
{ {
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 9"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 9";
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
@ -793,12 +800,19 @@ class CommandeFournisseur extends CommonOrder
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('ORDER_SUPPLIER_REFUSE',$this,$user,$langs,$conf); $result=$interface->run_triggers('ORDER_SUPPLIER_REFUSE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
}
// Fin appel triggers // Fin appel triggers
} }
} }
else else
{ {
$this->db->rollback();
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::refuse Error -1"); dol_syslog(get_class($this)."::refuse Error -1");
$result = -1; $result = -1;
} }
@ -855,7 +869,6 @@ class CommandeFournisseur extends CommonOrder
else else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->lasterror();
return -1; return -1;
} }
} }
@ -1039,7 +1052,13 @@ class CommandeFournisseur extends CommonOrder
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('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }
@ -1286,7 +1305,13 @@ class CommandeFournisseur extends CommonOrder
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('LINEORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }
@ -1351,7 +1376,13 @@ class CommandeFournisseur extends CommonOrder
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('LINEORDER_SUPPLIER_DISPATCH',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEORDER_SUPPLIER_DISPATCH',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }
@ -1380,6 +1411,7 @@ class CommandeFournisseur extends CommonOrder
} }
} }
//TODO: Check if there is a current transaction in DB but seems not.
if ($error == 0) if ($error == 0)
{ {
$this->db->commit(); $this->db->commit();
@ -1411,6 +1443,7 @@ class CommandeFournisseur extends CommonOrder
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idligne; $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idligne;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
//TODO: Add trigger for deleted line
dol_syslog(get_class($this)."::deleteline sql=".$sql); dol_syslog(get_class($this)."::deleteline sql=".$sql);
if ($resql) if ($resql)
{ {
@ -1457,11 +1490,13 @@ class CommandeFournisseur extends CommonOrder
{ {
if ($this->db->affected_rows($resql) < 1) if ($this->db->affected_rows($resql) < 1)
{ {
$this->error=$this->db->lasterror();
$error++; $error++;
} }
} }
else else
{ {
$this->error=$this->db->lasterror();
$error++; $error++;
} }
@ -1524,7 +1559,6 @@ class CommandeFournisseur extends CommonOrder
} }
else else
{ {
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -$error; return -$error;
@ -1725,7 +1759,7 @@ class CommandeFournisseur extends CommonOrder
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
//TODO: Add trigger for status modification
} }
else else
{ {
@ -1849,7 +1883,13 @@ class CommandeFournisseur extends CommonOrder
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('LINEORDER_SUPPLIER_UPDATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEORDER_SUPPLIER_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }

View File

@ -651,7 +651,10 @@ class FactureFournisseur extends CommonInvoice
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_SUPPLIER_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('BILL_SUPPLIER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
} }
// Fin appel triggers // Fin appel triggers
} }
@ -1103,7 +1106,13 @@ class FactureFournisseur extends CommonInvoice
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('LINEBILL_SUPPLIER_CREATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEBILL_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }
@ -1193,6 +1202,8 @@ class FactureFournisseur extends CommonInvoice
$product_type = $type; $product_type = $type;
} }
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " description ='".$this->db->escape($desc)."'"; $sql.= " description ='".$this->db->escape($desc)."'";
$sql.= ", pu_ht = ".price2num($pu_ht); $sql.= ", pu_ht = ".price2num($pu_ht);
@ -1228,17 +1239,26 @@ class FactureFournisseur extends CommonInvoice
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('LINEBILL_SUPPLIER_UPDATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEBILL_SUPPLIER_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0)
{
$error++;
$this->errors=$interface->errors;
$this->db->rollback();
return -1;
}
// Fin appel triggers // Fin appel triggers
} }
// Update total price into invoice record // Update total price into invoice record
$result=$this->update_price(); $result=$this->update_price();
$this->db->commit();
return $result; return $result;
} }
else else
{ {
$this->db->rollback();
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::updateline error=".$this->error, LOG_ERR); dol_syslog(get_class($this)."::updateline error=".$this->error, LOG_ERR);
return -1; return -1;

View File

@ -931,7 +931,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
if ($error) if ($error)
{ {
dol_print_error($db); setEventMessage($object->error, 'errors');
} }
else else
{ {
@ -1057,6 +1057,7 @@ if ($action=="create")
print_fiche_titre($langs->trans('NewOrder')); print_fiche_titre($langs->trans('NewOrder'));
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
dol_htmloutput_events();
$societe=''; $societe='';
if ($socid>0) if ($socid>0)

View File

@ -188,6 +188,10 @@ elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournis
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->set_paid($user); $result=$object->set_paid($user);
if ($result<0)
{
setEventMessage($object->error,'errors');
}
} }
// Set supplier ref // Set supplier ref
@ -524,6 +528,10 @@ elseif ($action == 'update_line' && $user->rights->fournisseur->facture->creer)
{ {
unset($_POST['label']); unset($_POST['label']);
} }
else
{
setEventMessage($object->error,'errors');
}
} }
} }
@ -1074,6 +1082,7 @@ if ($action == 'create')
print_fiche_titre($langs->trans('NewBill')); print_fiche_titre($langs->trans('NewBill'));
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
dol_htmloutput_events();
$societe=''; $societe='';
if ($_GET['socid']) if ($_GET['socid'])

View File

@ -61,8 +61,8 @@ if(empty($year)) {
} }
$sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, cp.halfday"; $sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, cp.halfday";
$sql.= " FROM llx_holiday cp"; $sql.= " FROM " . MAIN_DB_PREFIX . "holiday cp";
$sql.= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "user u ON cp.fk_user = u.rowid";
$sql.= " WHERE cp.statut = 3"; // Approved $sql.= " WHERE cp.statut = 3"; // Approved
// TODO Use BETWEEN instead of date_format // TODO Use BETWEEN instead of date_format
$sql.= " AND (date_format(cp.date_debut, '%Y-%c') = '$year-$month' OR date_format(cp.date_fin, '%Y-%c') = '$year-$month')"; $sql.= " AND (date_format(cp.date_debut, '%Y-%c') = '$year-$month' OR date_format(cp.date_fin, '%Y-%c') = '$year-$month')";

View File

@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
function dispatched($order_id) function dispatched($order_id)
{ {
global $db; global $db;
$sql = 'SELECT fk_product, SUM(qty) from llx_commande_fournisseur_dispatch'; $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch';
$sql .= ' WHERE fk_commande = ' . $order_id . ' GROUP BY fk_product'; $sql .= ' WHERE fk_commande = ' . $order_id . ' GROUP BY fk_product';
$sql .= ' ORDER by fk_product'; $sql .= ' ORDER by fk_product';
$resql = $db->query($sql); $resql = $db->query($sql);
@ -44,7 +44,7 @@ function dispatched($order_id)
while($res = $db->fetch_object($resql)) while($res = $db->fetch_object($resql))
$dispatched[] = $res; $dispatched[] = $res;
} }
$sql = 'SELECT fk_product, SUM(qty) from llx_commande_fournisseurdet'; $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet';
$sql .= ' WHERE fk_commande = ' . $order_id . ' GROUP BY fk_product'; $sql .= ' WHERE fk_commande = ' . $order_id . ' GROUP BY fk_product';
$sql .= ' ORDER by fk_product'; $sql .= ' ORDER by fk_product';
$resql = $db->query($sql); $resql = $db->query($sql);