forked from Wavyzz/dolibarr
Merge branch 'develop' into prod-attr
# Conflicts: # htdocs/compta/facture.php
This commit is contained in:
@@ -965,7 +965,7 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac
|
||||
* @return mixed Return html part or void if noprint is 1
|
||||
* TODO change function to be able to list event linked to an object.
|
||||
*/
|
||||
function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
|
||||
function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep,a.id', $sortorder='DESC')
|
||||
{
|
||||
global $bc,$user,$conf;
|
||||
global $form;
|
||||
@@ -1183,7 +1183,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
}
|
||||
$out.=getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder);
|
||||
$out.='<td class="maxwidth100onsmartphone">'.$langs->trans("Label").'</td>';
|
||||
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep, a.id', '', $param, '', $sortfield, $sortorder);
|
||||
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, '', $sortfield, $sortorder);
|
||||
$out.='<td>'.$langs->trans("Type").'</td>';
|
||||
$out.='<td></td>';
|
||||
$out.='<td></td>';
|
||||
|
||||
@@ -41,7 +41,7 @@ function dol_basename($pathfile)
|
||||
* Scan a directory and return a list of files/directories.
|
||||
* Content for string is UTF8 and dir separator is "/".
|
||||
*
|
||||
* @param string $path Starting path from which to search
|
||||
* @param string $path Starting path from which to search. This is a full path.
|
||||
* @param string $types Can be "directories", "files", or "all"
|
||||
* @param int $recursive Determines whether subdirectories are searched
|
||||
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
|
||||
@@ -50,7 +50,8 @@ function dol_basename($pathfile)
|
||||
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
|
||||
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
|
||||
* @param int $nohook Disable all hooks
|
||||
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
|
||||
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
|
||||
* @see dol_dir_list_indatabase
|
||||
*/
|
||||
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=false)
|
||||
{
|
||||
@@ -87,7 +88,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
||||
}
|
||||
|
||||
// $reshook may contain returns stacked by other modules
|
||||
// $reshook is always empty with an array for can not lose returns stacked with other modules
|
||||
// $reshook is always empty with an array to not lose returns stacked with other modules
|
||||
// $hookmanager->resArray may contain array stacked by other modules
|
||||
if (! $nohook && ! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty
|
||||
{
|
||||
@@ -205,6 +206,84 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scan a directory and return a list of files/directories.
|
||||
* Content for string is UTF8 and dir separator is "/".
|
||||
*
|
||||
* @param string $path Starting path from which to search. Example: 'produit/MYPROD'
|
||||
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
|
||||
* @param array|null $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.'))
|
||||
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
|
||||
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
|
||||
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like description
|
||||
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','type'=>'dir|file',...)
|
||||
* @see dol_dir_list
|
||||
*/
|
||||
function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
|
||||
{
|
||||
global $conf, $db;
|
||||
|
||||
$sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
|
||||
if ($mode) $sql.=", description";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
|
||||
$sql.=" WHERE filepath = '".$db->escape($path)."'";
|
||||
$sql.=" AND entity = ".$conf->entity;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$file_list=array();
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
|
||||
$level1name=(isset($reg[1])?$reg[1]:'');
|
||||
$file_list[] = array(
|
||||
"rowid" => $obj->rowid,
|
||||
"label" => $obj->label, // md5
|
||||
"name" => $obj->filename,
|
||||
"path" => DOL_DATA_ROOT.'/'.$obj->filepath,
|
||||
"level1name" => $level1name,
|
||||
"fullname" => DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,
|
||||
"fullpath_orig" => $obj->fullpath_orig,
|
||||
"date_c" => $db->jdate($obj->date_c),
|
||||
"date_m" => $db->jdate($obj->date_m),
|
||||
"type" => 'file',
|
||||
"keywords" => $obj->keywords,
|
||||
"cover" => $obj->cover,
|
||||
"position" => (int) $obj->position,
|
||||
"acl" => $obj->acl
|
||||
);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Obtain a list of columns
|
||||
if (! empty($sortcriteria))
|
||||
{
|
||||
$myarray=array();
|
||||
foreach ($file_list as $key => $row)
|
||||
{
|
||||
$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
|
||||
}
|
||||
// Sort the data
|
||||
if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
|
||||
}
|
||||
|
||||
return $file_list;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fast compare of 2 files identified by their properties ->name, ->date and ->size
|
||||
*
|
||||
@@ -497,11 +576,19 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
|
||||
*/
|
||||
function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
||||
{
|
||||
global $conf;
|
||||
global $user, $db, $conf;
|
||||
$result=false;
|
||||
|
||||
dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
|
||||
$srcexists=dol_is_file($srcfile);
|
||||
$destexists=dol_is_file($destfile);
|
||||
|
||||
if (! $srcexists)
|
||||
{
|
||||
dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($overwriteifexists || ! $destexists)
|
||||
{
|
||||
$newpathofsrcfile=dol_osencode($srcfile);
|
||||
@@ -512,13 +599,68 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
||||
{
|
||||
if ($destexists)
|
||||
{
|
||||
dol_syslog("files.lib.php::dol_move failed. We try to delete first and move after.", LOG_WARNING);
|
||||
dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING);
|
||||
// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
|
||||
dol_delete_file($destfile);
|
||||
$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
|
||||
}
|
||||
else dol_syslog("files.lib.php::dol_move failed", LOG_WARNING);
|
||||
else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
|
||||
}
|
||||
|
||||
// Move ok
|
||||
if ($result)
|
||||
{
|
||||
// Rename entry into ecm database
|
||||
$rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
|
||||
$rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
|
||||
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
|
||||
{
|
||||
$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
|
||||
$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
|
||||
//var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
|
||||
|
||||
dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
|
||||
if ($result > 0) // If found
|
||||
{
|
||||
$filename = basename($rel_filetorenameafter);
|
||||
$rel_dir = dirname($rel_filetorenameafter);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$result = $ecmfile->update($user);
|
||||
}
|
||||
elseif ($result == 0) // If not found
|
||||
{
|
||||
$filename = basename($rel_filetorenameafter);
|
||||
$rel_dir = dirname($rel_filetorenameafter);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file
|
||||
$ecmfile->fullpath_orig = $srcfile;
|
||||
$ecmfile->gen_or_uploaded = 'unknown';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
elseif ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
|
||||
$newmaskdec=octdec($newmask);
|
||||
// Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
|
||||
@@ -743,10 +885,33 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
|
||||
{
|
||||
if ($nophperrors) $ok=@unlink($filename);
|
||||
else $ok=unlink($filename);
|
||||
if ($ok) dol_syslog("Removed file ".$filename, LOG_DEBUG);
|
||||
if ($ok)
|
||||
{
|
||||
dol_syslog("Removed file ".$filename, LOG_DEBUG);
|
||||
|
||||
// Delete entry into ecm database
|
||||
$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
|
||||
if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file
|
||||
{
|
||||
$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
|
||||
|
||||
dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', $rel_filetodelete);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$result = $ecmfile->delete($user);
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
|
||||
// TODO Failure to remove can be because file was already removed or because of permission
|
||||
// If error because of not exists, we must can return true but we should return false if this is a permission problem
|
||||
// If error because of not exists, we must should return true and we should return false if this is a permission problem
|
||||
}
|
||||
}
|
||||
else dol_syslog("No files to delete found", LOG_WARNING);
|
||||
@@ -995,12 +1160,12 @@ function dol_init_file_process($pathtoscan='', $trackid='')
|
||||
* All information used are in db, conf, langs, user and _FILES.
|
||||
* Note: This function can be used only into a HTML page context.
|
||||
*
|
||||
* @param string $upload_dir Directory where to store uploaded file (note: also find in first part of dest_file)
|
||||
* @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename)
|
||||
* @param int $allowoverwrite 1=Allow overwrite existing file
|
||||
* @param int $donotupdatesession 1=Do no edit _SESSION variable
|
||||
* @param string $varfiles _FILES var name
|
||||
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
|
||||
* @param string $link Link to add
|
||||
* @param string $link Link to add (to add a link instead of a file)
|
||||
* @param string $trackid Track id (used to prefix name of session vars to avoid conflict)
|
||||
* @return void
|
||||
*/
|
||||
@@ -1026,49 +1191,82 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
|
||||
|
||||
for ($i = 0; $i < $nbfile; $i++)
|
||||
{
|
||||
// Define $destpath (path to file including filename) and $destfile (only filename)
|
||||
$destpath=$upload_dir . "/" . $TFile['name'][$i];
|
||||
// Define $destfull (path to file including filename) and $destfile (only filename)
|
||||
$destfull=$upload_dir . "/" . $TFile['name'][$i];
|
||||
$destfile=$TFile['name'][$i];
|
||||
|
||||
$savingdocmask = dol_sanitizeFileName($savingdocmask);
|
||||
|
||||
if ($savingdocmask)
|
||||
{
|
||||
$destpath=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
|
||||
$destfull=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
|
||||
$destfile=preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
|
||||
}
|
||||
|
||||
// lowercase extension
|
||||
$info = pathinfo($destpath);
|
||||
$destpath = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']);
|
||||
$info = pathinfo($destfull);
|
||||
$destfull = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']);
|
||||
$info = pathinfo($destfile);
|
||||
$destfile = $info['filename'].'.'.strtolower($info['extension']);
|
||||
|
||||
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destpath, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
|
||||
if (is_numeric($resupload) && $resupload > 0)
|
||||
|
||||
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
|
||||
|
||||
if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'
|
||||
{
|
||||
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
|
||||
// Generate thumbs.
|
||||
if (image_format_supported($destfull) == 1)
|
||||
{
|
||||
// Create thumbs
|
||||
// We can't use $object->addThumbs here because there is no $object known
|
||||
|
||||
// Used on logon for example
|
||||
$imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
|
||||
// Create mini thumbs for image (Ratio is near 16/9)
|
||||
// Used on menu or for setup page for example
|
||||
$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
|
||||
}
|
||||
|
||||
// Update session
|
||||
if (empty($donotupdatesession))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->trackid = $trackid;
|
||||
$formmail->add_attached_files($destpath, $destfile, $TFile['type'][$i]);
|
||||
$formmail->add_attached_files($destfull, $destfile, $TFile['type'][$i]);
|
||||
}
|
||||
if (image_format_supported($destpath) == 1)
|
||||
|
||||
// Update table of files
|
||||
if ($donotupdatesession)
|
||||
{
|
||||
// Create thumbs
|
||||
// We can't use $object->addThumbs here because there is no $object known
|
||||
|
||||
// Used on logon for example
|
||||
$imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
|
||||
// Create mini thumbs for image (Ratio is near 16/9)
|
||||
// Used on menu or for setup page for example
|
||||
$imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
|
||||
|
||||
if (! preg_match('/[\\/]temp[\\/]/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull));
|
||||
$ecmfile->fullpath_orig = $TFile['name'][$i];
|
||||
$ecmfile->gen_or_uploaded = 'uploaded';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
@@ -1145,7 +1343,7 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=
|
||||
{
|
||||
$pathtodelete=$listofpaths[$keytodelete];
|
||||
$filetodelete=$listofnames[$keytodelete];
|
||||
if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1);
|
||||
if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1); // The delete of ecm database is inside the function dol_delete_file
|
||||
else $result=0;
|
||||
if ($result >= 0)
|
||||
{
|
||||
@@ -1337,11 +1535,11 @@ 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)
|
||||
*
|
||||
* @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, relative to modulepart.
|
||||
* @param string $entity Restrict onto entity
|
||||
* @param User $fuser User object (forced)
|
||||
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
|
||||
* @return mixed Array with access information : accessallowed & sqlprotectagainstexternals & original_file (as full path name)
|
||||
* @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
|
||||
*/
|
||||
function dol_check_secure_access_document($modulepart,$original_file,$entity,$fuser='',$refname='')
|
||||
{
|
||||
@@ -1635,7 +1833,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->projet->dir_output.'/'.$original_file;
|
||||
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
|
||||
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project', 1).")";
|
||||
}
|
||||
else if ($modulepart == 'project_task')
|
||||
{
|
||||
@@ -1644,7 +1842,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->projet->dir_output.'/'.$original_file;
|
||||
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
|
||||
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project', 1).")";
|
||||
}
|
||||
// Wrapping for interventions
|
||||
else if ($modulepart == 'fichinter')
|
||||
@@ -1759,6 +1957,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->contrat->dir_output.'/'.$original_file;
|
||||
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract', 1).")";
|
||||
}
|
||||
|
||||
// Wrapping pour les dons
|
||||
|
||||
@@ -203,7 +203,7 @@ function getBrowserInfo($user_agent)
|
||||
elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; }
|
||||
elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];\srv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end
|
||||
elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; }
|
||||
|
||||
|
||||
if ($tablet) {
|
||||
$layout = 'tablet';
|
||||
} elseif ($phone) {
|
||||
@@ -268,14 +268,14 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
|
||||
{
|
||||
$tmp=dol_getdate(dol_now(), true);
|
||||
$out = $tmp['mon'];
|
||||
}
|
||||
}
|
||||
elseif ($reg[1] == 'YEAR')
|
||||
{
|
||||
$tmp=dol_getdate(dol_now(), true);
|
||||
$out = $tmp['year'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch ($check)
|
||||
{
|
||||
case 'int':
|
||||
@@ -409,15 +409,15 @@ function dol_buildpath($path, $type=0)
|
||||
if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value
|
||||
if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value
|
||||
if ($type == 3) $res = DOL_URL_ROOT.'/'.$path;
|
||||
|
||||
|
||||
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
|
||||
{
|
||||
if ($key == 'main')
|
||||
if ($key == 'main')
|
||||
{
|
||||
if ($type == 3)
|
||||
{
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
@@ -444,12 +444,12 @@ function dol_buildpath($path, $type=0)
|
||||
if ($type == 3)
|
||||
{
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
|
||||
$res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax
|
||||
}
|
||||
break;
|
||||
@@ -716,13 +716,13 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
throw new Exception('Incorrect log level');
|
||||
}
|
||||
if ($level > $conf->global->SYSLOG_LEVEL) return;
|
||||
|
||||
|
||||
// If adding log inside HTML page is required
|
||||
if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility
|
||||
{
|
||||
$conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
|
||||
// If enable html log tag enabled and url parameter log defined, we show output log on HTML comments
|
||||
if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"]))
|
||||
@@ -731,7 +731,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
print $message."\n";
|
||||
print "Log end -->\n";
|
||||
}
|
||||
|
||||
|
||||
$data = array(
|
||||
'message' => $message,
|
||||
'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false),
|
||||
@@ -739,7 +739,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
'user' => ((is_object($user) && $user->id) ? $user->login : false),
|
||||
'ip' => false
|
||||
);
|
||||
|
||||
|
||||
if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
|
||||
else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR'];
|
||||
@@ -926,7 +926,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
|
||||
{
|
||||
$out = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -985,7 +985,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
if ($object->element == 'member') $modulepart='memberphoto';
|
||||
if ($object->element == 'user') $modulepart='userphoto';
|
||||
if ($object->element == 'product') $modulepart='product';
|
||||
|
||||
|
||||
if ($object->element == 'product')
|
||||
{
|
||||
$width=80; $cssclass='photoref';
|
||||
@@ -993,7 +993,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
else
|
||||
{
|
||||
if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
|
||||
$nophoto='';
|
||||
@@ -1003,14 +1003,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$nophoto='/public/theme/common/nophoto.png';
|
||||
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.$nophoto.'"></div>';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if ($showimage)
|
||||
if ($showimage)
|
||||
{
|
||||
if ($modulepart != 'unknown')
|
||||
if ($modulepart != 'unknown')
|
||||
{
|
||||
$phototoshow = $form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos);
|
||||
if ($phototoshow)
|
||||
@@ -1023,7 +1023,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
elseif ($conf->browser->layout != 'phone') // Show no photo link
|
||||
{
|
||||
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">';
|
||||
if ($object->element == 'action')
|
||||
if ($object->element == 'action')
|
||||
{
|
||||
$cssclass='photorefcenter';
|
||||
$nophoto=img_picto('', 'title_agenda', '', false, 1);
|
||||
@@ -1042,7 +1042,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
|
||||
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
||||
$morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
|
||||
}
|
||||
}
|
||||
elseif ($object->element == 'product')
|
||||
{
|
||||
//$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') ';
|
||||
@@ -1062,7 +1062,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
elseif ($object->element == 'facture' || $object->element == 'invoice' || $object->element == 'invoice_supplier')
|
||||
{
|
||||
$tmptxt=$object->getLibStatut(6, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
$morehtmlstatus.=$tmptxt;
|
||||
}
|
||||
elseif ($object->element == 'chargesociales')
|
||||
@@ -1084,7 +1084,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
}
|
||||
else { // Generic case
|
||||
$tmptxt=$object->getLibStatut(6);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
|
||||
$morehtmlstatus.=$tmptxt;
|
||||
}
|
||||
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
|
||||
@@ -1278,9 +1278,9 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
$reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0;
|
||||
$formatwithoutreduce = preg_replace('/reduceformat/','',$format);
|
||||
if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day
|
||||
|
||||
|
||||
// Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
|
||||
// TODO Add format daysmallyear and dayhoursmallyear
|
||||
// TODO Add format daysmallyear and dayhoursmallyear
|
||||
if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short);
|
||||
else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short);
|
||||
else if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration);
|
||||
@@ -1782,7 +1782,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep
|
||||
$newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set)
|
||||
{
|
||||
if (! empty($conf->browser->phone) || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone
|
||||
@@ -1912,7 +1912,7 @@ function dol_user_country()
|
||||
* @param int $mode thirdparty|contact|member|other
|
||||
* @param int $id Id of object
|
||||
* @param int $noprint No output. Result is the function return
|
||||
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
|
||||
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
|
||||
* @return string|void Nothing if noprint is 0, formatted address if noprint is 1
|
||||
* @see dol_format_address
|
||||
*/
|
||||
@@ -1933,7 +1933,7 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0, $charfornl
|
||||
{
|
||||
if (empty($charfornl)) $out.=nl2br($address);
|
||||
else $out.=preg_replace('/[\r\n]+/', $charfornl, $address);
|
||||
|
||||
|
||||
$showgmap=$showomap=0;
|
||||
|
||||
// TODO Add a hook here
|
||||
@@ -2061,7 +2061,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
|
||||
print '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (empty($conf->use_javascript_ajax)) return;
|
||||
$jsgraphlib='flot';
|
||||
$datacolor=array();
|
||||
@@ -2230,7 +2230,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
|
||||
global $conf;
|
||||
|
||||
if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
|
||||
|
||||
|
||||
if (empty($stringencoding)) $stringencoding='UTF-8';
|
||||
// reduce for small screen
|
||||
if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3);
|
||||
@@ -3196,11 +3196,11 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
|
||||
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
|
||||
$savlimit = $limit;
|
||||
$savtotalnboflines = $totalnboflines;
|
||||
$totalnboflines=abs($totalnboflines);
|
||||
|
||||
|
||||
if ($picto == 'setup') $picto='title_setup.png';
|
||||
if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif';
|
||||
if ($limit < 0) $limit = $conf->liste_limit;
|
||||
@@ -3213,7 +3213,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
|
||||
$nextpage = 0;
|
||||
}
|
||||
//print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage;
|
||||
|
||||
|
||||
print "\n";
|
||||
print "<!-- Begin title '".$titre."' -->\n";
|
||||
print '<table width="100%" border="0" class="notopnoleftnoright'.($morecss?' '.$morecss:'').'" style="margin-bottom: 6px;"><tr>';
|
||||
@@ -3314,7 +3314,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
//$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
|
||||
//$pagesizechoices.=',2:2';
|
||||
if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES;
|
||||
|
||||
|
||||
print '<li class="pagination">';
|
||||
print '<select class="flat selectlimit" name="limit">';
|
||||
$tmpchoice=explode(',',$pagesizechoices);
|
||||
@@ -3354,7 +3354,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
</script>
|
||||
';
|
||||
}
|
||||
print '</li>';
|
||||
print '</li>';
|
||||
}
|
||||
if ($page > 0)
|
||||
{
|
||||
@@ -3393,7 +3393,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
|
||||
{
|
||||
$morelabel='';
|
||||
|
||||
|
||||
if (preg_match('/%/',$rate))
|
||||
{
|
||||
$rate=str_replace('%','',$rate);
|
||||
@@ -3596,7 +3596,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
|
||||
|
||||
/**
|
||||
* Output a dimension with best unit
|
||||
*
|
||||
*
|
||||
* @param float $dimension Dimension
|
||||
* @param int $unit Unit of dimension (0, -3, ...)
|
||||
* @param string $type 'weight', 'volume', ...
|
||||
@@ -3608,16 +3608,16 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
|
||||
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
|
||||
if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
|
||||
|
||||
if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
|
||||
{
|
||||
$dimension = $dimension * 1000000;
|
||||
$unit = $unit - 6;
|
||||
$unit = $unit - 6;
|
||||
}
|
||||
elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
|
||||
{
|
||||
$dimension = $dimension * 1000;
|
||||
$unit = $unit - 3;
|
||||
$unit = $unit - 3;
|
||||
}
|
||||
elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
|
||||
{
|
||||
@@ -3629,9 +3629,9 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=
|
||||
$dimension = $dimension / 1000;
|
||||
$unit = $unit + 3;
|
||||
}
|
||||
|
||||
|
||||
$ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type);
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -3662,12 +3662,12 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
|
||||
$vatratecleaned = trim($reg[1]);
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
|
||||
/*if ($thirdparty_buyer->country_code != $thirdparty_seller->country_code)
|
||||
{
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
// Some test to guess with no need to make database access
|
||||
if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local taxe
|
||||
{
|
||||
@@ -3765,7 +3765,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
|
||||
if ($local==1) return $obj->localtax1;
|
||||
elseif ($local==2) return $obj->localtax2;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3825,7 +3825,7 @@ function get_localtax_by_third($local)
|
||||
|
||||
/**
|
||||
* Get vat rate and npr from id.
|
||||
* You can call getLocalTaxesFromRate after to get other fields
|
||||
* You can call getLocalTaxesFromRate after to get other fields
|
||||
*
|
||||
* @param int $vatrowid Line ID into vat rate table.
|
||||
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
|
||||
@@ -3879,7 +3879,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
$vatratecleaned = $reg[1];
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
|
||||
// Search local taxes
|
||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
|
||||
@@ -3892,7 +3892,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
$sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
|
||||
if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
|
||||
}
|
||||
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -4299,7 +4299,7 @@ function yn($yesno, $case=1, $color=0)
|
||||
/**
|
||||
* Return a path to have a directory according to object.
|
||||
* New usage: $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart')
|
||||
* Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
|
||||
* Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
|
||||
*
|
||||
* @param string $num Id of object (deprecated, $object will be used in future)
|
||||
* @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future)
|
||||
@@ -4316,7 +4316,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
|
||||
$path = '';
|
||||
|
||||
$arrayforoldpath=array('cheque','user','category','holiday','shipment','supplier_invoice','invoice_supplier','mailing');
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product';
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product';
|
||||
if (! empty($level) && in_array($modulepart, $arrayforoldpath))
|
||||
{
|
||||
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
|
||||
@@ -4469,7 +4469,7 @@ function dolGetFirstLineOfText($text)
|
||||
{
|
||||
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
|
||||
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5375,7 +5375,7 @@ function picto_from_langcode($codelang)
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete or removed entries into a head array (used to build tabs).
|
||||
* Complete or removed entries into a head array (used to build tabs).
|
||||
* For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab'].
|
||||
* Or by change using hook completeTabsHead
|
||||
*
|
||||
@@ -5405,7 +5405,7 @@ function picto_from_langcode($codelang)
|
||||
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')
|
||||
{
|
||||
global $hookmanager;
|
||||
|
||||
|
||||
if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type]))
|
||||
{
|
||||
foreach ($conf->modules_parts['tabs'][$type] as $value)
|
||||
@@ -5471,7 +5471,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// No need to make a return $head. Var is modified as a reference
|
||||
if (! empty($hookmanager))
|
||||
{
|
||||
@@ -5509,11 +5509,11 @@ function printCommonFooter($zone='private')
|
||||
{
|
||||
print '<!-- Reposition management (does not work if a redirect is done after action of submission) -->'."\n";
|
||||
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() {'."\n";
|
||||
|
||||
|
||||
print '<!-- If page_y set, we set scollbar with it -->'."\n";
|
||||
print "page_y=getParameterByName('page_y', 0);";
|
||||
print "if (page_y > 0) $('html, body').scrollTop(page_y);\n";
|
||||
|
||||
|
||||
print '<!-- Set handler to add page_y param on some a href links -->'."\n";
|
||||
print 'jQuery(".reposition").click(function() {
|
||||
var page_y = $(document).scrollTop();
|
||||
@@ -5533,7 +5533,7 @@ function printCommonFooter($zone='private')
|
||||
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
|
||||
// Google Analytics (need Google module)
|
||||
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
|
||||
{
|
||||
@@ -5677,7 +5677,7 @@ function dol_getmypid()
|
||||
* If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000"
|
||||
* If param $mode is 2, can contains a list of id separated by comma like "1,3,4"
|
||||
* @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4')
|
||||
* @param integer $nofirstand 1=Do now output the first 'AND'
|
||||
* @param integer $nofirstand 1=Do not output the first 'AND'
|
||||
* @return string $res The statement to append to the SQL query
|
||||
*/
|
||||
function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
@@ -5692,6 +5692,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
{
|
||||
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
|
||||
}
|
||||
|
||||
$value = preg_replace('/\s*\|\s*/','|', $value);
|
||||
|
||||
$crits = explode(' ', $value);
|
||||
$res = '';
|
||||
if (! is_array($fields)) $fields = array($fields);
|
||||
@@ -5746,15 +5749,15 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
$tmpcrit=trim($tmpcrit);
|
||||
$tmpcrit2=$tmpcrit;
|
||||
$tmpbefore='%'; $tmpafter='%';
|
||||
if (preg_match('/^[\^\$]/', $tmpcrit))
|
||||
{
|
||||
if (preg_match('/^[\^\$]/', $tmpcrit))
|
||||
{
|
||||
$tmpbefore='';
|
||||
$tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
|
||||
$tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
|
||||
}
|
||||
if (preg_match('/[\^\$]$/', $tmpcrit))
|
||||
{
|
||||
if (preg_match('/[\^\$]$/', $tmpcrit))
|
||||
{
|
||||
$tmpafter='';
|
||||
$tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
|
||||
$tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
|
||||
}
|
||||
$newres .= $tmpbefore;
|
||||
$newres .= $db->escape($tmpcrit2);
|
||||
@@ -5819,7 +5822,7 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
|
||||
function getAdvancedPreviewUrl($modulepart, $relativepath)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
if (empty($conf->use_javascript_ajax)) return '';
|
||||
|
||||
$mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css');
|
||||
|
||||
@@ -37,8 +37,10 @@ $quality = 80;
|
||||
*/
|
||||
function image_format_supported($file)
|
||||
{
|
||||
$regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into product.class.php
|
||||
|
||||
// Case filename is not a format image
|
||||
if (! preg_match('/(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$/i',$file,$reg)) return -1;
|
||||
if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1;
|
||||
|
||||
// Case filename is a format image but not supported by this PHP
|
||||
$imgfonction='';
|
||||
@@ -47,6 +49,8 @@ function image_format_supported($file)
|
||||
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
|
||||
if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
|
||||
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
|
||||
if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm';
|
||||
if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm';
|
||||
if ($imgfonction)
|
||||
{
|
||||
if (! function_exists($imgfonction))
|
||||
|
||||
@@ -26,9 +26,13 @@
|
||||
// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth)
|
||||
$supportedoauth2array=array(
|
||||
'OAUTH_GOOGLE_NAME'=>'google',
|
||||
'OAUTH_GITHUB_NAME'=>'github'
|
||||
);
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
$supportedoauth2array['OAUTH_GITHUB_NAME']='github';
|
||||
}
|
||||
$supportedoauth2array['OAUTH_GITHUB_NAME']='github';
|
||||
// API access parameters OAUTH
|
||||
$list = array (
|
||||
array(
|
||||
@@ -264,7 +268,7 @@ function oauthadmin_prepare_head()
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = dol_buildpath('/admin/oauthlogintokens.php', 1);
|
||||
$head[$h][1] = $langs->trans("ManualTokenGeneration");
|
||||
$head[$h][1] = $langs->trans("TokenManager");
|
||||
$head[$h][2] = 'tokengeneration';
|
||||
$h++;
|
||||
|
||||
|
||||
@@ -1248,11 +1248,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
|
||||
{
|
||||
if ($issupplierline)
|
||||
{
|
||||
//$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref
|
||||
if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) $ref_prodserv =$ref_supplier;
|
||||
else $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref
|
||||
if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1)
|
||||
$ref_prodserv = $ref_supplier;
|
||||
elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2)
|
||||
$ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')';
|
||||
else
|
||||
$ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')';
|
||||
}
|
||||
else $ref_prodserv = $prodser->ref; // Show local ref only
|
||||
else
|
||||
$ref_prodserv = $prodser->ref; // Show local ref only
|
||||
|
||||
if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";
|
||||
}
|
||||
|
||||
@@ -110,12 +110,9 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
|
||||
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink;
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td colspan="4" align="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
|
||||
print '</form>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
Reference in New Issue
Block a user