forked from Wavyzz/dolibarr
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -749,7 +749,9 @@ function listOfSessions()
|
||||
{
|
||||
$sessValues = file_get_contents($fullpath); // get raw session data
|
||||
// Example of possible value
|
||||
//$sessValues = 'newtoken|s:32:"1239f7a0c4b899200fe9ca5ea394f307";dol_loginmesg|s:0:"";newtoken|s:32:"1236457104f7ae0f328c2928973f3cb5";dol_loginmesg|s:0:"";token|s:32:"123615ad8d650c5cc4199b9a1a76783f";dol_login|s:5:"admin";dol_authmode|s:8:"dolibarr";dol_tz|s:1:"1";dol_tz_string|s:13:"Europe/Berlin";dol_dst|i:0;dol_dst_observed|s:1:"1";dol_dst_first|s:0:"";dol_dst_second|s:0:"";dol_screenwidth|s:4:"1920";dol_screenheight|s:3:"971";dol_company|s:12:"MyBigCompany";dol_entity|i:1;mainmenu|s:4:"home";leftmenuopened|s:10:"admintools";idmenu|s:0:"";leftmenu|s:10:"admintools";';
|
||||
//$sessValues = 'newtoken|s:32:"1239f7a0c4b899200fe9ca5ea394f307";dol_loginmesg|s:0:"";newtoken|s:32:"1236457104f7ae0f328c2928973f3cb5";dol_loginmesg|s:0:"";token|s:32:"123615ad8d650c5cc4199b9a1a76783f";
|
||||
// dol_login|s:5:"admin";dol_authmode|s:8:"dolibarr";dol_tz|s:1:"1";dol_tz_string|s:13:"Europe/Berlin";dol_dst|i:0;dol_dst_observed|s:1:"1";dol_dst_first|s:0:"";dol_dst_second|s:0:"";dol_screenwidth|s:4:"1920";
|
||||
// dol_screenheight|s:3:"971";dol_company|s:12:"MyBigCompany";dol_entity|i:1;mainmenu|s:4:"home";leftmenuopened|s:10:"admintools";idmenu|s:0:"";leftmenu|s:10:"admintools";';
|
||||
|
||||
if (preg_match('/dol_login/i',$sessValues) && // limit to dolibarr session
|
||||
(preg_match('/dol_entity\|i:'.$conf->entity.';/i',$sessValues) || preg_match('/dol_entity\|s:([0-9]+):"'.$conf->entity.'"/i',$sessValues)) && // limit to current entity
|
||||
|
||||
@@ -234,8 +234,8 @@ function societe_prepare_head(Societe $object)
|
||||
$head[$h][1] = $langs->trans("WebSiteAccounts");
|
||||
$nbNote = 0;
|
||||
$sql = "SELECT COUNT(n.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."website_account as n";
|
||||
$sql.= " WHERE fk_soc = ".$object->id;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_account as n";
|
||||
$sql.= " WHERE fk_soc = ".$object->id.' AND fk_website > 0';
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -420,7 +420,7 @@ function societe_admin_prepare_head()
|
||||
* @param Translate $outputlangs Langs object for output translation
|
||||
* @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output
|
||||
* @param int $searchlabel Label of country to search (warning: searching on label is not reliable)
|
||||
* @return mixed String with country code or translated country name or Array('id','code','label')
|
||||
* @return mixed Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined'
|
||||
*/
|
||||
function getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
|
||||
{
|
||||
@@ -728,7 +728,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin
|
||||
$newcardbutton='';
|
||||
if (! empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink))
|
||||
{
|
||||
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$langs->trans("AddProject");
|
||||
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'"><span class="valignmiddle">'.$langs->trans("AddProject").'</span>';
|
||||
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
|
||||
$newcardbutton.= '</a>';
|
||||
}
|
||||
@@ -891,7 +891,13 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
|
||||
{
|
||||
foreach($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$contactstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key]));
|
||||
if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) {
|
||||
$arrayfields["ef.".$key]=array(
|
||||
'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key],
|
||||
'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1),
|
||||
'position'=>$extrafields->attributes[$contactstatic->table_element]['pos'][$key],
|
||||
'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,7 +931,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
$addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
|
||||
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$addcontact;
|
||||
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'"><span class="valignmiddle">'.$addcontact.'</span>';
|
||||
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
|
||||
$newcardbutton.= '</a>';
|
||||
}
|
||||
@@ -1179,7 +1185,7 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='')
|
||||
$newcardbutton='';
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress");
|
||||
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'"><span class="valignmiddle">'.$langs->trans("AddAddress").'</span>';
|
||||
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
|
||||
$newcardbutton.= '</a>';
|
||||
}
|
||||
@@ -1702,7 +1708,7 @@ function show_subsidiaries($conf,$langs,$db,$object)
|
||||
|
||||
$i=-1;
|
||||
|
||||
$sql = "SELECT s.rowid, s.nom as name, s.address, s.zip, s.town, s.code_client, s.canvas";
|
||||
$sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE s.parent = ".$object->id;
|
||||
$sql.= " AND s.entity IN (".getEntity('societe').")";
|
||||
@@ -1730,12 +1736,22 @@ function show_subsidiaries($conf,$langs,$db,$object)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$socstatic->id = $obj->rowid;
|
||||
$socstatic->name = $obj->name;
|
||||
$socstatic->name_alias = $obj->name_alias;
|
||||
$socstatic->email = $obj->email;
|
||||
$socstatic->code_client = $obj->code_client;
|
||||
$socstatic->code_fournisseur = $obj->code_client;
|
||||
$socstatic->code_compta = $obj->code_compta;
|
||||
$socstatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
$socstatic->email = $obj->email;
|
||||
$socstatic->canvas = $obj->canvas;
|
||||
$socstatic->client = $obj->client;
|
||||
$socstatic->fournisseur = $obj->fournisseur;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td>';
|
||||
$socstatic->id = $obj->rowid;
|
||||
$socstatic->name = $obj->name;
|
||||
$socstatic->canvas = $obj->canvas;
|
||||
print $socstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
|
||||
@@ -161,7 +161,16 @@ function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
|
||||
* Can be used to show a duration.
|
||||
*
|
||||
* @param int $iSecond Number of seconds
|
||||
* @param string $format Output format ('all': total delay days hour:min like "2 days 12:30", 'allwithouthour': total delay days without hour part like "2 days", 'allhourmin': total delay with format hours:min like "60:30", 'allhour': total delay hours without min/sec like "60:30", 'fullhour': total delay hour decimal like "60.5" for 60:30, 'hour': only hours part "12", 'min': only minutes part "30", 'sec': only seconds part, 'month': only month part, 'year': only year part);
|
||||
* @param string $format Output format ('all': total delay days hour:min like "2 days 12:30",
|
||||
* 'allwithouthour': total delay days without hour part like "2 days",
|
||||
* 'allhourmin': total delay with format hours:min like "60:30",
|
||||
* 'allhour': total delay hours without min/sec like "60:30",
|
||||
* 'fullhour': total delay hour decimal like "60.5" for 60:30,
|
||||
* 'hour': only hours part "12",
|
||||
* 'min': only minutes part "30",
|
||||
* 'sec': only seconds part,
|
||||
* 'month': only month part,
|
||||
* 'year': only year part);
|
||||
* @param int $lengthOfDay Length of day (default 86400 seconds for 1 day, 28800 for 8 hour)
|
||||
* @param int $lengthOfWeek Length of week (default 7)
|
||||
* @return string Formated text of duration
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
|
||||
|
||||
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
|
||||
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
|
||||
|
||||
*
|
||||
* 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
|
||||
@@ -162,4 +163,23 @@ function fichinter_admin_prepare_head()
|
||||
return $head;
|
||||
}
|
||||
|
||||
function fichinter_rec_prepare_head ($object)
|
||||
{
|
||||
global $langs, $conf; //, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("CardFichinter");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
|
||||
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -1200,23 +1200,26 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
|
||||
{
|
||||
$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 && $ecmfile->id > 0)
|
||||
if (is_object($db)) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1)
|
||||
{
|
||||
$result = $ecmfile->delete($user);
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
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 && $ecmfile->id > 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 should return true and we should return false if this is a permission problem
|
||||
// If error because it does not exists, we should return true, and we should return false if this is a permission problem
|
||||
}
|
||||
}
|
||||
else dol_syslog("No files to delete found", LOG_DEBUG);
|
||||
|
||||
@@ -293,7 +293,6 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
|
||||
|
||||
if (empty($method) || $method == 3 || $method == 4)
|
||||
{
|
||||
|
||||
$relativepathstring = $_SERVER["PHP_SELF"];
|
||||
// Clean $relativepathstring
|
||||
if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
|
||||
@@ -303,21 +302,32 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
|
||||
//var_dump($user->default_values);
|
||||
|
||||
// Code for search criteria persistence.
|
||||
// Retrieve values if restore_lastsearch_values is set and there is saved values
|
||||
if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here
|
||||
// Retrieve values if restore_lastsearch_values
|
||||
if (! empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST
|
||||
{
|
||||
$tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
|
||||
if (is_array($tmp))
|
||||
if (! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values
|
||||
{
|
||||
foreach($tmp as $key => $val)
|
||||
$tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
|
||||
if (is_array($tmp))
|
||||
{
|
||||
if ($key == $paramname)
|
||||
foreach($tmp as $key => $val)
|
||||
{
|
||||
$out=$val;
|
||||
break;
|
||||
if ($key == $paramname) // We are on the requested parameter
|
||||
{
|
||||
$out=$val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) // If there is saved contextpage
|
||||
{
|
||||
if ($paramname == 'contextpage')
|
||||
{
|
||||
$out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
|
||||
//var_dump($paramname.' '.$out);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Else, retreive default values if we are not doing a sort
|
||||
elseif (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set
|
||||
@@ -1008,6 +1018,14 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
// If syslog module enabled
|
||||
if (empty($conf->syslog->enabled)) return;
|
||||
|
||||
if ($ident < 0)
|
||||
{
|
||||
foreach ($conf->loghandlers as $loghandlerinstance)
|
||||
{
|
||||
$loghandlerinstance->setIdent($ident);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($message))
|
||||
{
|
||||
// Test log level
|
||||
@@ -1060,7 +1078,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
unset($data);
|
||||
}
|
||||
|
||||
if (! empty($ident))
|
||||
if ($ident > 0)
|
||||
{
|
||||
foreach ($conf->loghandlers as $loghandlerinstance)
|
||||
{
|
||||
@@ -1349,13 +1367,13 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
//}
|
||||
}
|
||||
}
|
||||
elseif ($object->element == 'ticketsup')
|
||||
elseif ($object->element == 'ticket')
|
||||
{
|
||||
$width=80; $cssclass='photoref';
|
||||
$showimage=$object->is_photo_available($conf->ticketsup->multidir_output[$entity].'/'.$object->track_id);
|
||||
$showimage=$object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->track_id);
|
||||
$maxvisiblephotos=(isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO)?$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO:2);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('ticketsup', $conf->ticketsup->multidir_output[$entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('ticket', $conf->ticket->multidir_output[$entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
{
|
||||
if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
|
||||
@@ -1379,17 +1397,20 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick"))
|
||||
{
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir_output = $conf->$modulepart->multidir_output[$entity] . "/";
|
||||
$dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]) . "/";
|
||||
if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice')))
|
||||
{
|
||||
$subdir = get_exdir($object->id, 2, 0, 0, $object, $modulepart).$objectref; // the objectref dir is not include into get_exdir when used with level=2, so we add it here
|
||||
$subdir = get_exdir($object->id, 2, 0, 1, $object, $modulepart);
|
||||
$subdir.= ((! empty($subdir) && ! preg_match('/\/$/',$subdir))?'/':'').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
|
||||
}
|
||||
else
|
||||
{
|
||||
$subdir = get_exdir($object->id, 0, 0, 0, $object, $modulepart);
|
||||
$subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart);
|
||||
}
|
||||
if (empty($subdir)) $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path
|
||||
|
||||
$filepath = $dir_output . $subdir . "/";
|
||||
|
||||
$file = $filepath . $objectref . ".pdf";
|
||||
$relativepath = $subdir.'/'.$objectref.'.pdf';
|
||||
|
||||
@@ -2000,7 +2021,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error('','PHP version must be 5.3+');
|
||||
dol_print_error('','PHP version must be 5.4+');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -2761,6 +2782,35 @@ function isValidEmail($address, $acceptsupervisorkey=0)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the domain name has a valid MX record.
|
||||
* WARNING: This need function idn_to_ascii, checkdnsrr and getmxrr
|
||||
*
|
||||
* @param string $domain Domain name (Ex: "yahoo.com", "yhaoo.com", "dolibarr.fr")
|
||||
* @return int -1 if error (function not available), 0=Not valid, 1=Valid
|
||||
*/
|
||||
function isValidMXRecord($domain)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && function_exists('checkdnsrr'))
|
||||
{
|
||||
if (! checkdnsrr(idn_to_ascii($domain), 'MX'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (function_exists('getmxrr'))
|
||||
{
|
||||
$mxhosts=array();
|
||||
$weight=array();
|
||||
getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
|
||||
if (count($mxhosts) > 1) return 1;
|
||||
if (count($mxhosts) == 1 && ! empty($mxhosts[0])) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if phone number syntax is ok
|
||||
* TODO Decide what to do with this
|
||||
@@ -4051,10 +4101,6 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
|
||||
$options=preg_replace('/&+/i','&',$options);
|
||||
if (! preg_match('/^&/',$options)) $options='&'.$options;
|
||||
|
||||
//print " ";
|
||||
//$sortimg.= '<img width="2" src="'.DOL_URL_ROOT.'/theme/common/transparent.png" alt="">';
|
||||
//$sortimg.= '<span class="nowrap">';
|
||||
|
||||
if (! $sortorder || $field1 != $sortfield1)
|
||||
{
|
||||
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
|
||||
@@ -4073,8 +4119,6 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
|
||||
$sortimg.= '<span class="nowrap">'.img_down("A-Z",0).'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
//$sortimg.= '</span>';
|
||||
}
|
||||
|
||||
$out.=$sortimg;
|
||||
@@ -4296,7 +4340,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
print '<div class="pagination"><ul>';
|
||||
if ((int) $limit >= 0 && empty($hideselectlimit))
|
||||
{
|
||||
$pagesizechoices='10:10,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
|
||||
$pagesizechoices='10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
|
||||
//$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
|
||||
//$pagesizechoices.=',2:2';
|
||||
if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES;
|
||||
@@ -4415,7 +4459,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
|
||||
* @param integer $form Type of format, HTML or not (not by default)
|
||||
* @param Translate $outlangs Object langs for output
|
||||
* @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless.
|
||||
* @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
|
||||
* @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT)
|
||||
* @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force)
|
||||
* @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency)
|
||||
* @return string Chaine avec montant formate
|
||||
@@ -4505,7 +4549,7 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
|
||||
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
|
||||
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
|
||||
* @param int $alreadysqlnb Put 1 if you know that content is already universal format number
|
||||
* @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails.
|
||||
* @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. If amount is null or '', it returns ''.
|
||||
*
|
||||
* @see price Opposite function of price2num
|
||||
*/
|
||||
@@ -5110,7 +5154,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
|
||||
$buyer_country_code = $thirdparty_buyer->country_code;
|
||||
$buyer_in_cee = isInEEC($thirdparty_buyer);
|
||||
|
||||
dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:''));
|
||||
dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer vat number=".$thirdparty_buyer->tva_intra." buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:''));
|
||||
|
||||
// If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm)
|
||||
// we use the buyer VAT.
|
||||
@@ -5323,7 +5367,9 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
|
||||
// TODO
|
||||
// We will enhance here a common way of forging path for document storage
|
||||
// Here, object->id, object->ref and modulepart are required.
|
||||
if (in_array($modulepart, array('thirdparty','contact','member','propal','proposal','commande','order','facture','invoice','shipment','expensereport')))
|
||||
//var_dump($modulepart);
|
||||
if (in_array($modulepart, array('thirdparty','contact','member','propal','proposal','commande','order','facture','invoice',
|
||||
'supplier_order','supplier_proposal','shipment','contract','expensereport')))
|
||||
{
|
||||
$path=($object->ref?$object->ref:$object->id);
|
||||
}
|
||||
@@ -5431,7 +5477,7 @@ function picto_required()
|
||||
* @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag)
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags
|
||||
* @see dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags
|
||||
*/
|
||||
function dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0)
|
||||
{
|
||||
@@ -5463,6 +5509,51 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UT
|
||||
return trim($temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean a string to keep only desirable HTML tags.
|
||||
*
|
||||
* @param string $stringtoclean String to clean
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags
|
||||
*/
|
||||
function dol_string_onlythesehtmltags($stringtoclean)
|
||||
{
|
||||
$allowed_tags = array(
|
||||
"html", "head", "meta", "body", "b", "br", "div", "em", "font", "img", "hr", "i", "li", "link",
|
||||
"ol", "p", "s", "section", "span", "strong", "title",
|
||||
"table", "tr", "th", "td", "u", "ul"
|
||||
);
|
||||
|
||||
$allowed_tags_string = join("><", $allowed_tags);
|
||||
$allowed_tags_string = preg_replace('/^>/','',$allowed_tags_string);
|
||||
$allowed_tags_string = preg_replace('/<$/','',$allowed_tags_string);
|
||||
|
||||
$temp = strip_tags($stringtoclean, $allowed_tags_string);
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean a string from some undesirable HTML tags.
|
||||
*
|
||||
* @param string $stringtoclean String to clean
|
||||
* @param array $disallowed_tags Array of tags not allowed
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags
|
||||
*/
|
||||
function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'))
|
||||
{
|
||||
$temp = $stringtoclean;
|
||||
foreach($disallowed_tags as $tagtoremove)
|
||||
{
|
||||
$temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp);
|
||||
$temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp);
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return first line of text. Cut will depends if content is HTML or not.
|
||||
@@ -5756,6 +5847,7 @@ function dol_textishtml($msg,$option=0)
|
||||
if (preg_match('/<html/i',$msg)) return true;
|
||||
elseif (preg_match('/<body/i',$msg)) return true;
|
||||
elseif (preg_match('/<(b|em|i|u)>/i',$msg)) return true;
|
||||
elseif (preg_match('/<br\/>/i',$msg)) return true;
|
||||
elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i',$msg)) return true;
|
||||
elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true;
|
||||
elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true;
|
||||
@@ -6017,17 +6109,20 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
{
|
||||
$substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '') : '';
|
||||
$substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '') : '';
|
||||
|
||||
$substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:'';
|
||||
$substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:'';
|
||||
$substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?$object->total_localtax1:'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?$object->total_localtax1:'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?$object->total_localtax2:'';
|
||||
$substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
|
||||
$substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
$substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
$substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat?price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency_code):price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency_code)):'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)?price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)?price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
// TODO Add keys for foreign multicurrency
|
||||
$substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat?price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency_code):price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency_code)):'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)?price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)?price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency_code):'';
|
||||
|
||||
// TODO Add keys for foreign multicurrency
|
||||
|
||||
// For backward compatibility
|
||||
if ($onlykey != 2)
|
||||
|
||||
@@ -708,9 +708,10 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany)
|
||||
* @param User $objuser Object user we need data from.
|
||||
* @param int $forceentity Entity id to force
|
||||
* @return string New value (numeric) or error message
|
||||
*/
|
||||
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null)
|
||||
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null, $forceentity=null)
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@@ -987,7 +988,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$sql.= " AND ".$field." NOT LIKE '(PROV%)'";
|
||||
if ($bentityon) // only if entity enable
|
||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
|
||||
else if (! empty($forceentity))
|
||||
$sql.= " AND entity = ".(int) $forceentity;
|
||||
if ($where) $sql.=$where;
|
||||
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||
|
||||
@@ -1035,6 +1037,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$sql.= " AND ".$field." NOT LIKE '%PROV%'";
|
||||
if ($bentityon) // only if entity enable
|
||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
$sql.= " AND entity = ".(int) $forceentity;
|
||||
if ($where) $sql.=$where;
|
||||
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||
|
||||
@@ -1089,6 +1093,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
|
||||
if ($bentityon) // only if entity enable
|
||||
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
$sql.= " AND entity = ".(int) $forceentity;
|
||||
if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
|
||||
if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask
|
||||
$maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')";
|
||||
@@ -2286,7 +2292,7 @@ function getModuleDirForApiClass($module)
|
||||
$moduledirforclass = 'fichinter';
|
||||
}
|
||||
elseif ($module == 'tickets') {
|
||||
$moduledirforclass = 'ticketsup';
|
||||
$moduledirforclass = 'ticket';
|
||||
}
|
||||
|
||||
return $moduledirforclass;
|
||||
|
||||
@@ -61,3 +61,32 @@ function holiday_prepare_head($object)
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations
|
||||
*
|
||||
* @return array head
|
||||
*/
|
||||
function holiday_admin_prepare_head()
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/holiday.php';
|
||||
$head[$h][1] = $langs->trans("Setup");
|
||||
$head[$h][2] = 'holiday';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin','remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
return -2;
|
||||
}
|
||||
if (! preg_match('/^(integer|date|timestamp|varchar|double|html|price)/', $addfieldentry['type']))
|
||||
|
||||
if (! preg_match('/^(price|boolean|sellist|integer|date|timestamp|varchar|double|text|html)/', $addfieldentry['type']))
|
||||
|
||||
{
|
||||
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
|
||||
return -2;
|
||||
@@ -256,11 +258,13 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$type = $val['type'];
|
||||
|
||||
$type = $val['type'];
|
||||
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
|
||||
|
||||
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
|
||||
if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
|
||||
else if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
|
||||
else if ($type == 'link' || $type == 'sellist') $type = 'integer';
|
||||
$texttoinsert.= "\t".$key." ".$type;
|
||||
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
||||
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
||||
@@ -269,7 +273,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
||||
if ($val['default'] != '')
|
||||
{
|
||||
if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL";
|
||||
else if (preg_match('/varchar/', $val['type'])) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
|
||||
else if (preg_match('/varchar/', $type )) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
|
||||
else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:'');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,32 @@ function payment_supplier_prepare_head(Paiement $object) {
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of valid payment mode
|
||||
*
|
||||
* @param string $paymentmethod Filter on this payment method
|
||||
* @return array Array of valid payment method
|
||||
*/
|
||||
function getValidOnlinePaymentMethods($paymentmethod='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$validpaymentmethod=array();
|
||||
|
||||
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled))
|
||||
{
|
||||
$validpaymentmethod['paypal']='valid';
|
||||
}
|
||||
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled))
|
||||
{
|
||||
$validpaymentmethod['paybox']='valid';
|
||||
}
|
||||
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled))
|
||||
{
|
||||
$validpaymentmethod['stripe']='valid';
|
||||
}
|
||||
return $validpaymentmethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string with full Url
|
||||
|
||||
@@ -129,8 +129,11 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
|
||||
//$format=array($arrayformat['width'],$arrayformat['height']);
|
||||
//$metric=$arrayformat['unit'];
|
||||
|
||||
if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
|
||||
else $pdf = new TCPDF($pagetype,$metric,$format);
|
||||
$pdfa=false; // PDF-1.3
|
||||
if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A
|
||||
|
||||
if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa);
|
||||
else $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa);
|
||||
|
||||
// Protection and encryption of pdf
|
||||
if (! empty($conf->global->PDF_SECURITY_ENCRYPTION))
|
||||
@@ -1228,7 +1231,17 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
|
||||
{
|
||||
if ($idprod)
|
||||
{
|
||||
if (empty($hidedesc)) $libelleproduitservice.=$desc;
|
||||
if (empty($hidedesc))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST))
|
||||
{
|
||||
$libelleproduitservice=$desc."\n".$libelleproduitservice;
|
||||
}
|
||||
else
|
||||
{
|
||||
$libelleproduitservice.=$desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -174,11 +174,10 @@ function dol_verifyHash($chain, $hash, $type='0')
|
||||
* @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'.
|
||||
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
|
||||
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
|
||||
* @param Canvas $objcanvas Object canvas
|
||||
* @return int Always 1, die process if not allowed
|
||||
* @see dol_check_secure_access_document
|
||||
*/
|
||||
function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
|
||||
function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
|
||||
{
|
||||
global $db, $conf;
|
||||
global $hookmanager;
|
||||
@@ -470,13 +469,32 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled))
|
||||
{
|
||||
$sql.= " AND dbt.entity IS NOT NULL";
|
||||
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if ($conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IS NOT NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND (ug.fk_user = dbt.rowid";
|
||||
$sql.= " AND ug.entity IN (".getEntity('user')."))";
|
||||
$sql.= " OR dbt.entity = 0"; // Show always superadmin
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
@@ -510,12 +528,12 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
else if (in_array($feature,$checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
|
||||
{
|
||||
// If external user: Check permission for external users
|
||||
if ($user->societe_id > 0)
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.fk_soc = ".$user->societe_id;
|
||||
$sql.= " AND dbt.fk_soc = ".$user->socid;
|
||||
}
|
||||
// If internal user: Check permission for internal users that are restricted on their objects
|
||||
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
|
||||
@@ -578,13 +596,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
else if (! in_array($feature,$nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
|
||||
{
|
||||
// If external user: Check permission for external users
|
||||
if ($user->societe_id > 0)
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.rowid IN (".$objectid.")";
|
||||
$sql.= " AND dbt.".$dbt_keyfield." = ".$user->societe_id;
|
||||
$sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid;
|
||||
}
|
||||
// If internal user: Check permission for internal users that are restricted on their objects
|
||||
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file core/lib/ticketsup.lib.php
|
||||
* \ingroup ticketsup
|
||||
* \brief This file is a library for TicketSup module
|
||||
* \file core/lib/ticket.lib.php
|
||||
* \ingroup ticket
|
||||
* \brief This file is a library for Ticket module
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -27,72 +27,72 @@
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function ticketsupAdminPrepareHead()
|
||||
function ticketAdminPrepareHead()
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$langs->load("ticketsup");
|
||||
$langs->load("ticket");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/ticketsup.php';
|
||||
$head[$h][1] = $langs->trans("TicketSupSettings");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/ticket.php';
|
||||
$head[$h][1] = $langs->trans("TicketSettings");
|
||||
$head[$h][2] = 'settings';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/ticketsup_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsTicketSup");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsTicket");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
//$this->tabs = array(
|
||||
// 'entity:+tabname:Title:@ticketsup:/ticketsup/mypage.php?id=__ID__'
|
||||
// 'entity:+tabname:Title:@ticket:/ticket/mypage.php?id=__ID__'
|
||||
//); // to add new tab
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@ticketsup:/ticketsup/mypage.php?id=__ID__'
|
||||
// 'entity:-tabname:Title:@ticket:/ticket/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticketsupadmin');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticketadmin');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build tabs for a Ticketsup object
|
||||
* Build tabs for a Ticket object
|
||||
*
|
||||
* @param Ticketsup $object Object Ticket
|
||||
* @param Ticket $object Object Ticket
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function ticketsup_prepare_head($object)
|
||||
function ticket_prepare_head($object)
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticketsup/card.php?action=view&track_id=' . $object->track_id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'tabTicketsup';
|
||||
$head[$h][2] = 'tabTicket';
|
||||
$h++;
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticketsup/contact.php?track_id='.$object->track_id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticketsup');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket');
|
||||
|
||||
// Attached files
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$upload_dir = $conf->ticketsup->dir_output . "/" . $object->track_id;
|
||||
$upload_dir = $conf->ticket->dir_output . "/" . $object->track_id;
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files'));
|
||||
$head[$h][0] = dol_buildpath('/ticketsup/document.php', 1) . '?track_id=' . $object->track_id;
|
||||
$head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?track_id=' . $object->track_id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if ($nbFiles > 0) {
|
||||
$head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
|
||||
@@ -103,13 +103,13 @@ function ticketsup_prepare_head($object)
|
||||
|
||||
|
||||
// History
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticketsup/history.php?track_id=' . $object->track_id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/history.php?track_id=' . $object->track_id;
|
||||
$head[$h][1] = $langs->trans('Events');
|
||||
$head[$h][2] = 'tabTicketLogs';
|
||||
$h++;
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticketsup','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket','remove');
|
||||
|
||||
|
||||
return $head;
|
||||
@@ -150,8 +150,22 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $
|
||||
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
|
||||
print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">';
|
||||
|
||||
if (! empty($conf->global->TICKETS_SHOW_COMPANY_LOGO)) {
|
||||
showlogo();
|
||||
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) {
|
||||
// Print logo
|
||||
$urllogo = DOL_URL_ROOT . '/theme/login_logo.png';
|
||||
|
||||
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_small);
|
||||
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode($mysoc->logo);
|
||||
$width = 128;
|
||||
} elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) {
|
||||
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
|
||||
}
|
||||
print '<center>';
|
||||
print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
|
||||
print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
|
||||
print '</center><br>';
|
||||
}
|
||||
|
||||
print '<div style="margin-left: 50px; margin-right: 50px;">';
|
||||
@@ -173,29 +187,3 @@ function llxFooterTicket()
|
||||
print "</body>\n";
|
||||
print "</html>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Show logo
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showlogo()
|
||||
{
|
||||
global $conf, $langs, $mysoc;
|
||||
|
||||
// Print logo
|
||||
$urllogo = DOL_URL_ROOT . '/theme/login_logo.png';
|
||||
|
||||
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_small);
|
||||
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode($mysoc->logo);
|
||||
$width = 128;
|
||||
} elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) {
|
||||
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
|
||||
}
|
||||
print '<center>';
|
||||
print '<a href="' . ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticketsup/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
|
||||
print '<strong>' . ($conf->global->TICKETS_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKETS_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
|
||||
print '</center><br>';
|
||||
}
|
||||
@@ -143,7 +143,10 @@ function user_prepare_head($object)
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))
|
||||
|| (! empty($conf->expensereport->enabled) && ! empty($user->rights->expensereport->lire) && $user->id == $object->id)
|
||||
|| (! empty($conf->holiday->enabled) && ! empty($user->rights->holiday->read) && $user->id == $object->id )
|
||||
)
|
||||
{
|
||||
// Bank
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
|
||||
|
||||
@@ -131,6 +131,8 @@ function dolWebsiteOutput($content)
|
||||
}
|
||||
}
|
||||
|
||||
$content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep);
|
||||
|
||||
dol_syslog("dolWebsiteOutput end");
|
||||
|
||||
print $content;
|
||||
|
||||
Reference in New Issue
Block a user