mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-21 17:01:19 +01:00
Qual: Mutualize code to delete previews
This commit is contained in:
@@ -726,7 +726,15 @@ function dol_delete_preview($object)
|
||||
global $langs,$conf;
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
|
||||
if ($object->element == 'commande') $dir = $conf->commande->dir_output;
|
||||
if ($object->element == 'commande') $dir = $conf->commande->dir_output;
|
||||
elseif ($object->element == 'propal') $dir = $conf->propale->dir_output;
|
||||
elseif ($object->element == 'ficheinter') $dir = $conf->ficheinter->dir_output;
|
||||
elseif ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande';
|
||||
elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture';
|
||||
elseif ($object->element == 'project') $dir = $conf->projet->dir_output;
|
||||
elseif ($object->element == 'delivery') $dir = $conf->livraison->dir_output;
|
||||
elseif ($object->element == 'facture') $dir = $conf->facture->dir_output;
|
||||
elseif ($object->element == 'don') $dir = $conf->don->dir_output;
|
||||
if (empty($dir)) return 'ErrorObjectNoSupportedByFunction';
|
||||
|
||||
$refsan = dol_sanitizeFileName($object->ref);
|
||||
@@ -762,6 +770,58 @@ function dol_delete_preview($object)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a meta file with document file into same directory.
|
||||
* This should allow rgrep search
|
||||
*
|
||||
* @param Object $object Object
|
||||
* @return void
|
||||
*/
|
||||
function dol_meta_create($object)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if ($conf->facture->dir_output)
|
||||
{
|
||||
$facref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $conf->facture->dir_output . "/" . $facref ;
|
||||
$file = $dir . "/" . $facref . ".meta";
|
||||
|
||||
if (! is_dir($dir))
|
||||
{
|
||||
create_exdir($dir);
|
||||
}
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$nblignes = count($object->lines);
|
||||
$client = $object->client->nom . " " . $object->client->address . " " . $object->client->cp . " " . $object->client->ville;
|
||||
$meta = "REFERENCE=\"" . $object->ref . "\"
|
||||
DATE=\"" . dol_print_date($object->date,'') . "\"
|
||||
NB_ITEMS=\"" . $nblignes . "\"
|
||||
CLIENT=\"" . $client . "\"
|
||||
TOTAL_HT=\"" . $object->total_ht . "\"
|
||||
TOTAL_TTC=\"" . $object->total_ttc . "\"\n";
|
||||
|
||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||
{
|
||||
//Pour les articles
|
||||
$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\"
|
||||
ITEM_" . $i . "_UNIT_PRICE=\"" . $object->lines[$i]->price . "\"
|
||||
ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\"
|
||||
ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\"
|
||||
";
|
||||
}
|
||||
}
|
||||
$fp = fopen($file,"w");
|
||||
fputs($fp,$meta);
|
||||
fclose($fp);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and save an upload file (for example after submitting a new file a mail form).
|
||||
|
||||
Reference in New Issue
Block a user