mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -786,82 +786,132 @@ class Expedition extends CommonObject
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
|
||||
$sql.= " WHERE fk_expedition = ".$this->id;
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
|
||||
// Stock control
|
||||
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0)
|
||||
{
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
|
||||
|
||||
$langs->load("agenda");
|
||||
|
||||
// Loop on each product line to add a stock movement
|
||||
$sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed";
|
||||
$sql.= " WHERE ed.fk_expedition = ".$this->id;
|
||||
$sql.= " AND cd.rowid = ed.fk_origin_line";
|
||||
|
||||
dol_syslog(get_class($this)."::delete select details sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
$cpt = $this->db->num_rows($resql);
|
||||
for ($i = 0; $i < $cpt; $i++)
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
// On efface le repertoire de pdf provisoire
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if (! empty($conf->expedition->dir_output))
|
||||
dol_syslog(get_class($this)."::delete movement index ".$i);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
//var_dump($this->lines[$i]);
|
||||
$mouvS = new MouvementStock($this->db);
|
||||
// We decrement stock of product (and sub-products)
|
||||
// We use warehouse selected for each line
|
||||
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref));
|
||||
if ($result < 0)
|
||||
{
|
||||
$dir = $conf->expedition->dir_output . '/sending/' . $ref ;
|
||||
$file = $dir . '/' . $ref . '.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
if (! dol_delete_file($file))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (file_exists($dir))
|
||||
{
|
||||
if (!dol_delete_dir($dir))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if(! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
|
||||
$sql.= " WHERE fk_expedition = ".$this->id;
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
// On efface le repertoire de pdf provisoire
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if (! empty($conf->expedition->dir_output))
|
||||
{
|
||||
$dir = $conf->expedition->dir_output . '/sending/' . $ref ;
|
||||
$file = $dir . '/' . $ref . '.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
if (! dol_delete_file($file))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (file_exists($dir))
|
||||
{
|
||||
if (!dol_delete_dir($dir))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call triggers
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('SHIPPING_DELETE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// End call triggers
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
|
||||
// Call triggers
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('SHIPPING_DELETE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// End call triggers
|
||||
|
||||
// TODO il faut incrementer le stock si on supprime une expedition validee
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -192,6 +192,7 @@ MemberResiliatedInDolibarr=Membre %s donat de baixa en Dolibarr
|
||||
MemberDeletedInDolibarr=Membre %s eliminat de Dolibarr
|
||||
MemberSubscriptionAddedInDolibarr=Subscripció del membre %s afegida a Dolibarr
|
||||
ShipmentValidatedInDolibarr=Expedició %s validada en Dolibarr
|
||||
ShipmentDeletedInDolibarr=Expedició %s eliminada de Dolibarr
|
||||
##### Export #####
|
||||
Export=Exportació
|
||||
ExportsArea=Àrea d'exportacions
|
||||
|
||||
@@ -195,6 +195,7 @@ MemberResiliatedInDolibarr=Member %s resiliated in Dolibarr
|
||||
MemberDeletedInDolibarr=Member %s deleted from Dolibarr
|
||||
MemberSubscriptionAddedInDolibarr=Subscription for member %s added in Dolibarr
|
||||
ShipmentValidatedInDolibarr=Shipment %s validated in Dolibarr
|
||||
ShipmentDeletedInDolibarr=Shipment %s deleted from Dolibarr
|
||||
##### Export #####
|
||||
Export=Export
|
||||
ExportsArea=Exports area
|
||||
|
||||
@@ -193,6 +193,7 @@ MemberResiliatedInDolibarr=Miembro %s dado de baja en Dolibarr
|
||||
MemberDeletedInDolibarr=Miembro %s eliminado de Dolibarr
|
||||
MemberSubscriptionAddedInDolibarr=Subscripción del miembro % añadida en Dolibarr
|
||||
ShipmentValidatedInDolibarr=Expedición %s validada en Dolibarr
|
||||
ShipmentDeletedInDolibarr=Expedición %s eliminada de Dolibarr
|
||||
##### Export #####
|
||||
Export=Exportación
|
||||
ExportsArea=Área de exportaciones
|
||||
|
||||
@@ -195,6 +195,7 @@ MemberResiliatedInDolibarr=Adhérent %s résilié dans Dolibarr
|
||||
MemberDeletedInDolibarr=Adhérent %s supprimé de Dolibarr
|
||||
MemberSubscriptionAddedInDolibarr=Souscription adhérent %s ajoutée dans Dolibarr
|
||||
ShipmentValidatedInDolibarr=Expédition %s validée dans Dolibarr
|
||||
ShipmentDeletedInDolibarr=Expédition %s supprimé de Dolibarr
|
||||
##### Export #####
|
||||
Export=Export
|
||||
ExportsArea=Espace exports
|
||||
|
||||
Reference in New Issue
Block a user