Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into 11.0
This commit is contained in:
commit
b77892451f
@ -2992,8 +2992,11 @@ class Propal extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX . 'propaldet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = " . $this->id . ")";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql))
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
|
||||
@ -3396,6 +3396,19 @@ class Commande extends CommonOrder
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete extrafields of order details
|
||||
$main = MAIN_DB_PREFIX . 'commandedet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = " . $this->id . ")";
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete order details
|
||||
|
||||
@ -664,9 +664,13 @@ class FactureRec extends CommonInvoice
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$main = MAIN_DB_PREFIX . 'facturedet_rec';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)";
|
||||
dol_syslog($sqlef);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid;
|
||||
dol_syslog($sql);
|
||||
if ($this->db->query($sql))
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql))
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid;
|
||||
dol_syslog($sql);
|
||||
@ -675,6 +679,9 @@ class FactureRec extends CommonInvoice
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) $error = -3;
|
||||
// Delete extrafields
|
||||
$res = $this->deleteExtraFields();
|
||||
if ($res < 0) $error = -4;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1882,6 +1889,14 @@ class FactureLigneRec extends CommonInvoiceLine
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
|
||||
|
||||
@ -2166,13 +2166,16 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Invoice line extrafileds
|
||||
$main = MAIN_DB_PREFIX . 'facturedet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)";
|
||||
// Delete invoice line
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
|
||||
if ($this->db->query($sql) && $this->delete_linked_contact())
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql) && $this->delete_linked_contact())
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid;
|
||||
|
||||
@ -5312,6 +5315,13 @@ class FactureLigne extends CommonInvoiceLine
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
// extrafields
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
|
||||
@ -1234,6 +1234,22 @@ class Contrat extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete contratdet extrafields
|
||||
$main = MAIN_DB_PREFIX . 'contratdet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_contrat = " . $this->id . ")";
|
||||
|
||||
dol_syslog(get_class($this)."::delete contratdet_extrafields", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->error = $this->db->error();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Delete contratdet
|
||||
|
||||
@ -474,7 +474,6 @@ class doc_generic_task_odt extends ModelePDFTask
|
||||
|
||||
if (!file_exists($dir))
|
||||
{
|
||||
print '$dir'.$dir;
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
|
||||
@ -1280,15 +1280,23 @@ class Expedition extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX . 'expeditiondet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = " . $this->id . ")";
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
|
||||
$sql .= " WHERE fk_expedition = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql))
|
||||
{
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) $error++;
|
||||
|
||||
// delete extrafields
|
||||
$res = $this->deleteExtraFields();
|
||||
if ($res < 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";
|
||||
|
||||
@ -961,6 +961,16 @@ class Fichinter extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX . 'fichinterdet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = " . $this->id . ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) $error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet";
|
||||
@ -1704,6 +1714,13 @@ class FichinterLigne extends CommonObjectLine
|
||||
dol_syslog(get_class($this)."::deleteline lineid=".$this->id);
|
||||
$this->db->begin();
|
||||
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->id;
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
|
||||
@ -1994,6 +1994,17 @@ class CommandeFournisseur extends CommonOrder
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
$main = MAIN_DB_PREFIX . 'commande_fournisseurdet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = " . $this->id . ")";
|
||||
dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG);
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =".$this->id;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
if (!$this->db->query($sql))
|
||||
@ -3700,6 +3711,14 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// extrafields
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
@ -303,6 +303,7 @@ class CommandeFournisseurDispatch extends CommonObject
|
||||
$this->batch = $obj->batch;
|
||||
$this->eatby = $this->db->jdate($obj->eatby);
|
||||
$this->sellby = $this->db->jdate($obj->sellby);
|
||||
$this->fetch_optionals();
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
@ -439,6 +440,16 @@ class CommandeFournisseurDispatch extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// Remove extrafields
|
||||
if (!$error) {
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||
@ -689,6 +700,7 @@ class CommandeFournisseurDispatch extends CommonObject
|
||||
$line->batch = $obj->batch;
|
||||
$line->eatby = $this->db->jdate($obj->eatby);
|
||||
$line->sellby = $this->db->jdate($obj->sellby);
|
||||
$line->fetch_optionals();
|
||||
|
||||
$this->lines[$line->id] = $line;
|
||||
}
|
||||
|
||||
@ -1180,10 +1180,14 @@ class FactureFournisseur extends CommonInvoice
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX . 'facture_fourn_det';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture_fourn = $rowid)";
|
||||
$resqlef = $this->db->query($sqlef);
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
if ($resqlef && $resql)
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
@ -3141,6 +3145,11 @@ class SupplierInvoiceLine extends CommonObjectLine
|
||||
|
||||
$this->deleteObjectLinked();
|
||||
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Supprime ligne
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
|
||||
|
||||
@ -515,6 +515,8 @@ class MouvementStock extends CommonObject
|
||||
// Update PMP and denormalized value of stock qty at product level
|
||||
if (! $error)
|
||||
{
|
||||
$newpmp = price2num($newpmp, 'MU');
|
||||
|
||||
// $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty;
|
||||
// $sql.= " WHERE rowid = ".$fk_product;
|
||||
// Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql
|
||||
|
||||
@ -763,8 +763,13 @@ class Reception extends CommonObject
|
||||
}
|
||||
|
||||
// extrafields
|
||||
$line->array_options = $supplierorderline->array_options;
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used
|
||||
$line->array_options = $array_options;
|
||||
{
|
||||
foreach ($array_options as $key => $value) {
|
||||
$line->array_options[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$line->fk_product = $fk_product;
|
||||
$line->fk_commande = $supplierorderline->fk_commande;
|
||||
@ -938,10 +943,14 @@ class Reception extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX . 'commande_fournisseur_dispatch';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_reception = " . $this->id . ")";
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch";
|
||||
$sql .= " WHERE fk_reception = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql))
|
||||
{
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
|
||||
@ -2061,11 +2061,14 @@ class SupplierProposal extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$main = MAIN_DB_PREFIX . 'supplier_proposaldet';
|
||||
$ef = $main . "_extrafields";
|
||||
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_supplier_proposal = " . $this->id . ")";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal = ".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal WHERE rowid = ".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
if ($this->db->query($sqlef) && $this->db->query($sql))
|
||||
{
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user