forked from Wavyzz/dolibarr
Work on generic usage of get_exdir.
This commit is contained in:
@@ -578,11 +578,9 @@ class FormFile
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
// Define relative path for download link (depends on module)
|
// Define relative path for download link (depends on module)
|
||||||
$relativepath=$file["name"]; // Cas general
|
$relativepath=$file["name"]; // Cas general
|
||||||
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
|
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
|
||||||
// Autre cas
|
if ($modulepart == 'export') $relativepath = $file["name"]; // Other case
|
||||||
if ($modulepart == 'donation') { $relativepath = get_exdir($modulesubdir,2,0,0,null,'donation').$file["name"]; }
|
|
||||||
if ($modulepart == 'export') { $relativepath = $file["name"]; }
|
|
||||||
|
|
||||||
$out.= "<tr ".$bc[$var].">";
|
$out.= "<tr ".$bc[$var].">";
|
||||||
|
|
||||||
|
|||||||
@@ -1399,7 +1399,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta
|
|||||||
/**
|
/**
|
||||||
* Security check when accessing to a document (used by document.php, viewimage.php and webservices)
|
* Security check when accessing to a document (used by document.php, viewimage.php and webservices)
|
||||||
*
|
*
|
||||||
* @param string $modulepart Module of document (module, module_user_temp, module_user or module_temp)
|
* @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp')
|
||||||
* @param string $original_file Relative path with filename
|
* @param string $original_file Relative path with filename
|
||||||
* @param string $entity Restrict onto entity
|
* @param string $entity Restrict onto entity
|
||||||
* @param User $fuser User object (forced)
|
* @param User $fuser User object (forced)
|
||||||
@@ -1817,7 +1817,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
|
|||||||
$accessallowed=1;
|
$accessallowed=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$original_file=$conf->banque->dir_output.'/bordereau/'.get_exdir(basename($original_file,".pdf"),2,1,0,null,'cheque').$original_file;
|
$original_file=$conf->banque->dir_output.'/bordereau/'.$original_file; // original_file should contains relative path so include the get_exdir result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapping for export module
|
// Wrapping for export module
|
||||||
|
|||||||
@@ -3713,13 +3713,16 @@ function yn($yesno, $case=1, $color=0)
|
|||||||
* @param string $modulepart Type of object ('invoice_supplier, 'donation', 'invoice', ...')
|
* @param string $modulepart Type of object ('invoice_supplier, 'donation', 'invoice', ...')
|
||||||
* @return string Dir to use ending. Example '' or '1/' or '1/2/'
|
* @return string Dir to use ending. Example '' or '1/' or '1/2/'
|
||||||
*/
|
*/
|
||||||
function get_exdir($num,$level,$alpha=0,$withoutslash=0,$object=null,$modulepart='')
|
function get_exdir($num,$level,$alpha,$withoutslash,$object,$modulepart)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$path = '';
|
$path = '';
|
||||||
|
|
||||||
if (! empty($level) && in_array($modulepart, array('shipment', 'member','don','donation','supplier_invoice','invoice_supplier')))
|
// TODO if object is null, load it from id and modulepart.
|
||||||
|
|
||||||
|
|
||||||
|
if (! empty($level) && in_array($modulepart, array('cheque','user','category','shipment', 'member','don','donation','supplier_invoice','invoice_supplier')))
|
||||||
{
|
{
|
||||||
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
|
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
|
||||||
if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
|
if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier
|
|||||||
$objphoto = new Product($this->db);
|
$objphoto = new Product($this->db);
|
||||||
$objphoto->fetch($object->lines[$i]->fk_product);
|
$objphoto->fetch($object->lines[$i]->fk_product);
|
||||||
|
|
||||||
$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$object,'product') . $object->lines[$i]->fk_product ."/photos/";
|
$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
|
||||||
$dir = $conf->product->dir_output.'/'.$pdir;
|
$dir = $conf->product->dir_output.'/'.$pdir;
|
||||||
|
|
||||||
$realpath='';
|
$realpath='';
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class html_cerfafr extends ModeleDon
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$donref = dol_sanitizeFileName($don->ref);
|
$donref = dol_sanitizeFileName($don->ref);
|
||||||
$dir = $conf->don->dir_output . "/" . get_exdir($donref,2,0,0,$don,'donation');
|
$dir = $conf->don->dir_output . "/" . get_exdir($donref,2,0,1,$don,'donation') . "/" . dol_sanitizeFileName($don->ref);
|
||||||
$file = $dir . "/" . $donref . ".html";
|
$file = $dir . "/" . $donref . ".html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,10 @@ if ($action == 'add')
|
|||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer)
|
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer)
|
||||||
@@ -232,7 +236,7 @@ if ($action == 'set_paid')
|
|||||||
if ($action == 'builddoc')
|
if ($action == 'builddoc')
|
||||||
{
|
{
|
||||||
$object = new Don($db);
|
$object = new Don($db);
|
||||||
$object->fetch($id);
|
$result=$object->fetch($id);
|
||||||
|
|
||||||
// Save last template used to generate document
|
// Save last template used to generate document
|
||||||
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
@@ -380,6 +384,7 @@ if (! empty($id) && $action == 'edit')
|
|||||||
dol_print_error($db); exit;
|
dol_print_error($db); exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hselected='card';
|
||||||
$head = donation_prepare_head($object);
|
$head = donation_prepare_head($object);
|
||||||
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
||||||
|
|
||||||
@@ -507,6 +512,8 @@ if (! empty($id) && $action != 'edit')
|
|||||||
dol_print_error($db); exit;
|
dol_print_error($db); exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hselected='card';
|
||||||
|
|
||||||
$head = donation_prepare_head($object);
|
$head = donation_prepare_head($object);
|
||||||
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
||||||
|
|
||||||
@@ -720,7 +727,7 @@ if (! empty($id) && $action != 'edit')
|
|||||||
* Documents generes
|
* Documents generes
|
||||||
*/
|
*/
|
||||||
$filename=dol_sanitizeFileName($object->id);
|
$filename=dol_sanitizeFileName($object->id);
|
||||||
$filedir=$conf->don->dir_output . '/' . get_exdir($filename,2,0,0,$object,'donation');
|
$filedir=$conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref);
|
||||||
$urlsource=$_SERVER['PHP_SELF'].'?rowid='.$object->id;
|
$urlsource=$_SERVER['PHP_SELF'].'?rowid='.$object->id;
|
||||||
// $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer);
|
// $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer);
|
||||||
// $delallowed=$user->rights->facture->supprimer;
|
// $delallowed=$user->rights->facture->supprimer;
|
||||||
@@ -730,7 +737,7 @@ if (! empty($id) && $action != 'edit')
|
|||||||
$var=true;
|
$var=true;
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
$formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed);
|
$formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
|
||||||
|
|
||||||
print '</td><td> </td>';
|
print '</td><td> </td>';
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,10 @@ class Don extends CommonObject
|
|||||||
var $note_private;
|
var $note_private;
|
||||||
var $note_public;
|
var $note_public;
|
||||||
var $statut;
|
var $statut;
|
||||||
|
var $modelpdf;
|
||||||
var $projet;
|
var $projet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -306,14 +307,14 @@ class Don extends CommonObject
|
|||||||
* @return int <0 if KO, id of created donation if OK
|
* @return int <0 if KO, id of created donation if OK
|
||||||
* TODO add numbering module for Ref
|
* TODO add numbering module for Ref
|
||||||
*/
|
*/
|
||||||
function create($user, $notrigger)
|
function create($user, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->address=($this->address>0?$this->address:$this->address);
|
$this->address=($this->address>0?$this->address:$this->address);
|
||||||
$this->zip=($this->zip>0?$this->zip:$this->zip);
|
$this->zip=($this->zip>0?$this->zip:$this->zip);
|
||||||
@@ -391,7 +392,7 @@ class Don extends CommonObject
|
|||||||
$this->errno = $this->db->lasterrno();
|
$this->errno = $this->db->lasterrno();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update extrafield
|
// Update extrafield
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
@@ -403,7 +404,7 @@ class Don extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
||||||
{
|
{
|
||||||
$res = $this->setValid($user);
|
$res = $this->setValid($user);
|
||||||
@@ -434,7 +435,7 @@ class Don extends CommonObject
|
|||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->address=($this->address>0?$this->address:$this->address);
|
$this->address=($this->address>0?$this->address:$this->address);
|
||||||
$this->zip=($this->zip>0?$this->zip:$this->zip);
|
$this->zip=($this->zip>0?$this->zip:$this->zip);
|
||||||
@@ -523,11 +524,11 @@ class Don extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Delete donation
|
// Delete donation
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@@ -601,7 +602,7 @@ class Don extends CommonObject
|
|||||||
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
|
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
|
||||||
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
|
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
|
||||||
$sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
|
$sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
|
||||||
$sql.= " d.phone_mobile, d.fk_projet,";
|
$sql.= " d.phone_mobile, d.fk_projet, d.model_pdf,";
|
||||||
$sql.= " p.title as project_label,";
|
$sql.= " p.title as project_label,";
|
||||||
$sql.= " c.code as country_code, c.label as country";
|
$sql.= " c.code as country_code, c.label as country";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
|
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
|
||||||
@@ -651,12 +652,13 @@ class Don extends CommonObject
|
|||||||
$this->public = $obj->public;
|
$this->public = $obj->public;
|
||||||
$this->modepaymentid = $obj->fk_payment;
|
$this->modepaymentid = $obj->fk_payment;
|
||||||
$this->modepayment = $obj->libelle;
|
$this->modepayment = $obj->libelle;
|
||||||
$this->paid = $obj->paid;
|
$this->paid = $obj->paid;
|
||||||
$this->amount = $obj->amount;
|
$this->amount = $obj->amount;
|
||||||
$this->note_private = $obj->note_private;
|
$this->note_private = $obj->note_private;
|
||||||
$this->note_public = $obj->note_public;
|
$this->note_public = $obj->note_public;
|
||||||
|
$this->modelpdf = $obj->model_pdf;
|
||||||
$this->commentaire = $obj->note; // deprecated
|
$this->commentaire = $obj->note; // deprecated
|
||||||
|
|
||||||
// Retrieve all extrafield for thirdparty
|
// Retrieve all extrafield for thirdparty
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
@@ -821,7 +823,7 @@ class Don extends CommonObject
|
|||||||
if ($withpicto != 2) $result.=$link.$this->id.$linkend;
|
if ($withpicto != 2) $result.=$link.$this->id.$linkend;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information on record
|
* Information on record
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ if ($resql)
|
|||||||
$facturestatic->ref_supplier=$obj->ref_supplier;
|
$facturestatic->ref_supplier=$obj->ref_supplier;
|
||||||
print $facturestatic->getNomUrl(1);
|
print $facturestatic->getNomUrl(1);
|
||||||
$filename=dol_sanitizeFileName($obj->ref);
|
$filename=dol_sanitizeFileName($obj->ref);
|
||||||
$filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$object,'invoice_supplier').dol_sanitizeFileName($object->ref?$obj->ref:$obj->facid);
|
$filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref);
|
||||||
print $formfile->getDocumentsLink('facture_fournisseur', $filename, $filedir);
|
print $formfile->getDocumentsLink('facture_fournisseur', $filename, $filedir);
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||||
|
|
||||||
|
|
||||||
UPDATE TABLE llx_facture_fourn set ref=id where ref IS NULL;
|
UPDATE llx_facture_fourn set ref=rowid where ref IS NULL;
|
||||||
ALTER TABLE llx_facture_fourn MODIFY COLUMN ref varchar(255) NOT NULL;
|
ALTER TABLE llx_facture_fourn MODIFY COLUMN ref varchar(255) NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
@@ -451,6 +451,7 @@ ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL after country;
|
|||||||
ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer;
|
ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer;
|
||||||
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
|
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
|
||||||
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_projet integer NULL;
|
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_projet integer NULL;
|
||||||
|
ALTER TABLE llx_don CHANGE COLUMN fk_project fk_projet integer NULL;
|
||||||
|
|
||||||
create table llx_don_extrafields
|
create table llx_don_extrafields
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user