mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Validation of order if a file was attached
This commit is contained in:
parent
4a794016fb
commit
af1cede0ed
|
|
@ -29,6 +29,7 @@ For users:
|
|||
- Fix: Clicktodial plugin works correctly now
|
||||
- Fix: Multiprices features works correctly.
|
||||
- Fix: Project module and task creation.
|
||||
- Fix: Validation of order if a file was attached.
|
||||
|
||||
For translators:
|
||||
- Added ca_ES language files
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ class Commande extends CommonObject
|
|||
global $conf,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
// Protection
|
||||
if ($this->statut == 1)
|
||||
{
|
||||
|
|
@ -221,7 +221,7 @@ class Commande extends CommonObject
|
|||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Definition du nom de module de numerotation de commande
|
||||
|
|
@ -251,34 +251,26 @@ class Commande extends CommonObject
|
|||
// On efface le repertoire de pdf provisoire
|
||||
if (eregi('^\(PROV', $this->ref))
|
||||
{
|
||||
// On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref)
|
||||
// afin de ne pas perdre les fichiers attachés
|
||||
$comref = sanitizeFileName($this->ref);
|
||||
if ($conf->commande->dir_output)
|
||||
$snum = sanitizeFileName($num);
|
||||
$dirsource = $conf->commande->dir_output.'/'.$comref;
|
||||
$dirdest = $conf->commande->dir_output.'/'.$snum;
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
commande_delete_preview($this->db, $this->id, $this->ref);
|
||||
dol_syslog("Commande::valid() rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (file_exists($dir))
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
if (!dol_delete_dir($dir))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
dol_syslog("Rename ok");
|
||||
// Suppression ancien fichier PDF dans nouveau rep
|
||||
dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'.*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If stock is incremented on validate order, we must increment it
|
||||
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||
{
|
||||
|
|
@ -563,7 +555,7 @@ class Commande extends CommonObject
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mise a jour ref
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
|
|
@ -805,10 +797,10 @@ class Commande extends CommonObject
|
|||
// print "id : ".$value[1].' :qty: '.$value[0].'<br>';
|
||||
if(! in_array($value[1],$this->products))
|
||||
$this->add_product($value[1], $value[0]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
**/
|
||||
}
|
||||
|
|
@ -1260,7 +1252,7 @@ class Commande extends CommonObject
|
|||
if ($result > 0)
|
||||
{
|
||||
$result=$this->update_price();
|
||||
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
|
|
@ -1765,7 +1757,7 @@ class Commande extends CommonObject
|
|||
if (file_exists($file))
|
||||
{
|
||||
commande_delete_preview($this->db, $this->id, $this->ref);
|
||||
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||
|
|
|
|||
|
|
@ -428,9 +428,9 @@ class Facture extends CommonObject
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// End
|
||||
|
|
@ -682,7 +682,7 @@ class Facture extends CommonObject
|
|||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->facnumber)) $this->facnumber=trim($this->ref);
|
||||
|
|
@ -711,7 +711,7 @@ class Facture extends CommonObject
|
|||
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
|
||||
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
|
||||
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
|
|
@ -1310,11 +1310,11 @@ class Facture extends CommonObject
|
|||
$dirdest = $conf->facture->dir_output.'/'.$snumfa;
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
dol_syslog("Facture::set_valid() renommage rep ".$dirsource." en ".$dirdest);
|
||||
dol_syslog("Facture::set_valid() rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
dol_syslog("Renommage ok");
|
||||
dol_syslog("Rename ok");
|
||||
// Suppression ancien fichier PDF dans nouveau rep
|
||||
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
|
||||
}
|
||||
|
|
@ -1393,7 +1393,7 @@ class Facture extends CommonObject
|
|||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
|
||||
dol_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
|
|
@ -1412,8 +1412,8 @@ class Facture extends CommonObject
|
|||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
|
@ -1535,7 +1535,7 @@ class Facture extends CommonObject
|
|||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
|
||||
// \TODO A virer
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
|
|
@ -1734,7 +1734,7 @@ class Facture extends CommonObject
|
|||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Efface ligne de facture
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid;
|
||||
dol_syslog("Facture::Deleteline sql=".$sql);
|
||||
|
|
@ -1746,18 +1746,18 @@ class Facture extends CommonObject
|
|||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
$result=$this->update_price();
|
||||
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -2531,7 +2531,7 @@ class Facture extends CommonObject
|
|||
global $conf, $user;
|
||||
|
||||
$now=gmmktime();
|
||||
|
||||
|
||||
$this->nbtodo=$this->nbtodolate=0;
|
||||
$clause = "WHERE";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user