Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/fourn/class/fournisseur.commande.dispatch.class.php htdocs/fourn/class/fournisseur.facture.class.php htdocs/reception/class/reception.class.php
This commit is contained in:
commit
7bbfd2175d
@ -2999,8 +2999,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))
|
||||
|
||||
@ -3409,6 +3409,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
|
||||
|
||||
@ -1768,6 +1768,8 @@ if (empty($reshook))
|
||||
|
||||
if (!empty($origin) && !empty($originid))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
$object->origin = $origin;
|
||||
$object->origin_id = $originid;
|
||||
|
||||
@ -1800,6 +1802,17 @@ if (empty($reshook))
|
||||
$line->fetch_optionals();
|
||||
$line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note
|
||||
|
||||
// The $line->situation_percent has been modified, so we must recalculate all amounts
|
||||
$tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $line->situation_percent);
|
||||
$line->total_ht = $tabprice[0];
|
||||
$line->total_tva = $tabprice[1];
|
||||
$line->total_ttc = $tabprice[2];
|
||||
$line->total_localtax1 = $tabprice[9];
|
||||
$line->total_localtax2 = $tabprice[10];
|
||||
$line->multicurrency_total_ht = $tabprice[16];
|
||||
$line->multicurrency_total_tva = $tabprice[17];
|
||||
$line->multicurrency_total_ttc = $tabprice[18];
|
||||
|
||||
// Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée
|
||||
if ($line->fk_remise_except)
|
||||
{
|
||||
@ -1844,6 +1857,7 @@ if (empty($reshook))
|
||||
{
|
||||
$nextSituationInvoice = new Facture($db);
|
||||
$nextSituationInvoice->fetch($id);
|
||||
|
||||
// create extrafields with data from create form
|
||||
$extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $nextSituationInvoice);
|
||||
|
||||
@ -748,9 +748,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);
|
||||
@ -759,6 +763,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
|
||||
{
|
||||
@ -1966,6 +1973,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;
|
||||
|
||||
@ -2186,13 +2186,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;
|
||||
|
||||
@ -5477,6 +5480,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);
|
||||
|
||||
@ -1252,6 +1252,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
|
||||
|
||||
@ -483,7 +483,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);
|
||||
|
||||
@ -1289,15 +1289,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";
|
||||
|
||||
@ -992,6 +992,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";
|
||||
@ -1735,6 +1745,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);
|
||||
|
||||
|
||||
@ -2035,6 +2035,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))
|
||||
@ -3771,6 +3782,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);
|
||||
|
||||
@ -292,6 +292,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);
|
||||
|
||||
@ -428,6 +429,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;
|
||||
@ -678,6 +689,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);
|
||||
|
||||
@ -540,6 +540,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
|
||||
|
||||
@ -750,8 +750,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)
|
||||
$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;
|
||||
@ -925,10 +930,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();
|
||||
|
||||
@ -2069,11 +2069,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