|
@@ -210,7 +210,8 @@ function getEntity($element, $shared = 1, $currentobject = null)
|
|
|
{
|
|
|
global $conf, $mc, $hookmanager, $object, $action, $db;
|
|
|
|
|
|
- if (! is_object($hookmanager)) {
|
|
|
+ if (!is_object($hookmanager)) {
|
|
|
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
|
$hookmanager = new HookManager($db);
|
|
|
}
|
|
|
|
|
@@ -535,6 +536,7 @@ function GETPOSTISARRAY($paramname, $method = 0)
|
|
|
* 'alphanohtml'=check there is no html content and no " and no ../
|
|
|
* 'aZ'=check it's a-z only
|
|
|
* 'aZ09'=check it's simple alpha string (recommended for keys)
|
|
|
+ * 'aZ09arobase'=check it's a string for an element type
|
|
|
* 'aZ09comma'=check it's a string for a sortfield or sortorder
|
|
|
* 'san_alpha'=Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string)
|
|
|
* 'nohtml'=check there is no html content
|
|
@@ -934,6 +936,14 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
+ case 'aZ09arobase': // great to sanitize objecttype parameter
|
|
|
+ if (!is_array($out)) {
|
|
|
+ $out = trim($out);
|
|
|
+ if (preg_match('/[^a-z0-9_\-\.@]+/i', $out)) {
|
|
|
+ $out = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh
|
|
|
if (!is_array($out)) {
|
|
|
$out = trim($out);
|
|
@@ -1890,9 +1900,10 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0
|
|
|
* @param string $morecss More CSS on the link <a>
|
|
|
* @param int $limittoshow Limit number of tabs to show. Use 0 to use automatic default value.
|
|
|
* @param string $moretabssuffix A suffix to use when you have several dol_get_fiche_head() in same page
|
|
|
+ * @param int $dragdropfile 0 (default) or 1. 1 enable a drop zone for file to be upload, 0 disable it
|
|
|
* @return string
|
|
|
*/
|
|
|
-function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limittoshow = 0, $moretabssuffix = '')
|
|
|
+function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limittoshow = 0, $moretabssuffix = '', $dragdropfile = 0)
|
|
|
{
|
|
|
global $conf, $langs, $hookmanager;
|
|
|
|
|
@@ -2058,9 +2069,11 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab
|
|
|
}
|
|
|
|
|
|
if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
|
|
|
- $out .= "\n".'<div class="tabBar'.($notab == -1 ? '' : ($notab == -2 ? ' tabBarNoTop' : (($notab == -3 ? ' noborderbottom' : '').' tabBarWithBottom'))).'">'."\n";
|
|
|
+ $out .= "\n".'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ? '' : ($notab == -2 ? ' tabBarNoTop' : (($notab == -3 ? ' noborderbottom' : '').' tabBarWithBottom'))).'">'."\n";
|
|
|
+ }
|
|
|
+ if (!empty($dragdropfile)) {
|
|
|
+ $out .= dragAndDropFileUpload("dragDropAreaTabBar");
|
|
|
}
|
|
|
-
|
|
|
$parameters = array('tabname' => $active, 'out' => $out);
|
|
|
$reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
|
|
|
if ($reshook > 0) {
|
|
@@ -7642,16 +7655,17 @@ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
|
|
|
* @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are trunc and html sanitized (to use for help tooltip)
|
|
|
* @param array $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...)
|
|
|
* @param Object $object Object for keys on object
|
|
|
+ * @param array $include Array of family keys we want to include. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...)
|
|
|
* @return array Array of substitutions
|
|
|
* @see setSubstitFromObject()
|
|
|
*/
|
|
|
-function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null)
|
|
|
+function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null, $include = null)
|
|
|
{
|
|
|
global $db, $conf, $mysoc, $user, $extrafields;
|
|
|
|
|
|
$substitutionarray = array();
|
|
|
|
|
|
- if (empty($exclude) || !in_array('user', $exclude)) {
|
|
|
+ if ((empty($exclude) || !in_array('user', $exclude)) && (empty($include) || in_array('user', $include))) {
|
|
|
// Add SIGNATURE into substitutionarray first, so, when we will make the substitution,
|
|
|
// this will include signature content first and then replace var found into content of signature
|
|
|
//var_dump($onlykey);
|
|
@@ -7680,7 +7694,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
));
|
|
|
}
|
|
|
}
|
|
|
- if ((empty($exclude) || !in_array('mycompany', $exclude)) && is_object($mysoc)) {
|
|
|
+ if ((empty($exclude) || !in_array('mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array('mycompany', $include))) {
|
|
|
$substitutionarray = array_merge($substitutionarray, array(
|
|
|
'__MYCOMPANY_NAME__' => $mysoc->name,
|
|
|
'__MYCOMPANY_EMAIL__' => $mysoc->email,
|
|
@@ -7704,7 +7718,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- if (($onlykey || is_object($object)) && (empty($exclude) || !in_array('object', $exclude))) {
|
|
|
+ if (($onlykey || is_object($object)) && (empty($exclude) || !in_array('object', $exclude)) && (empty($include) || in_array('object', $include))) {
|
|
|
if ($onlykey) {
|
|
|
$substitutionarray['__ID__'] = '__ID__';
|
|
|
$substitutionarray['__REF__'] = '__REF__';
|
|
@@ -7738,7 +7752,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = '__THIRDPARTY_NOTE_PUBLIC__';
|
|
|
$substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = '__THIRDPARTY_NOTE_PRIVATE__';
|
|
|
}
|
|
|
- if (isModEnabled('adherent') && (!is_object($object) || $object->element == 'adherent')) {
|
|
|
+ if (isModEnabled('adherent') && (!is_object($object) || $object->element == 'adherent') && (empty($exclude) || !in_array('member', $exclude)) && (empty($include) || in_array('member', $include))) {
|
|
|
$substitutionarray['__MEMBER_ID__'] = '__MEMBER_ID__';
|
|
|
$substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__';
|
|
|
$substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__';
|
|
@@ -7748,7 +7762,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
$substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/
|
|
|
}
|
|
|
// add variables subtitutions ticket
|
|
|
- if (isModEnabled('ticket') && (!is_object($object) || $object->element == 'ticket')) {
|
|
|
+ if (isModEnabled('ticket') && (!is_object($object) || $object->element == 'ticket') && (empty($exclude) || !in_array('ticket', $exclude)) && (empty($include) || in_array('ticket', $include))) {
|
|
|
$substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__';
|
|
|
$substitutionarray['__TICKET_SUBJECT__'] = '__TICKET_SUBJECT__';
|
|
|
$substitutionarray['__TICKET_TYPE__'] = '__TICKET_TYPE__';
|
|
@@ -7760,28 +7774,28 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
$substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__';
|
|
|
}
|
|
|
|
|
|
- if (isModEnabled('recruitment') && (!is_object($object) || $object->element == 'recruitmentcandidature')) {
|
|
|
+ if (isModEnabled('recruitment') && (!is_object($object) || $object->element == 'recruitmentcandidature') && (empty($exclude) || !in_array('recruitment', $exclude)) && (empty($include) || in_array('recruitment', $include))) {
|
|
|
$substitutionarray['__CANDIDATE_FULLNAME__'] = '__CANDIDATE_FULLNAME__';
|
|
|
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = '__CANDIDATE_FIRSTNAME__';
|
|
|
$substitutionarray['__CANDIDATE_LASTNAME__'] = '__CANDIDATE_LASTNAME__';
|
|
|
}
|
|
|
- if (isModEnabled('project')) { // Most objects
|
|
|
+ if (isModEnabled('project') && (empty($exclude) || !in_array('project', $exclude)) && (empty($include) || in_array('project', $include))) { // Most objects
|
|
|
$substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__';
|
|
|
$substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__';
|
|
|
$substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__';
|
|
|
/*$substitutionarray['__PROJECT_NOTE_PUBLIC__'] = '__PROJECT_NOTE_PUBLIC__';
|
|
|
$substitutionarray['__PROJECT_NOTE_PRIVATE__'] = '__PROJECT_NOTE_PRIVATE__';*/
|
|
|
}
|
|
|
- if (isModEnabled('contrat') && (!is_object($object) || $object->element == 'contract')) {
|
|
|
+ if (isModEnabled('contrat') && (!is_object($object) || $object->element == 'contract') && (empty($exclude) || !in_array('contract', $exclude)) && (empty($include) || in_array('contract', $include))) {
|
|
|
$substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = 'Highest date planned for a service start';
|
|
|
$substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = 'Highest date and hour planned for service start';
|
|
|
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service';
|
|
|
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service';
|
|
|
}
|
|
|
- if (isModEnabled("propal") && (!is_object($object) || $object->element == 'propal')) {
|
|
|
+ if (isModEnabled("propal") && (!is_object($object) || $object->element == 'propal') && (empty($exclude) || !in_array('propal', $exclude)) && (empty($include) || in_array('propal', $include))) {
|
|
|
$substitutionarray['__ONLINE_SIGN_URL__'] = 'ToOfferALinkForOnlineSignature';
|
|
|
}
|
|
|
- if (isModEnabled("ficheinter") && (!is_object($object) || $object->element == 'fichinter')) {
|
|
|
+ if (isModEnabled("ficheinter") && (!is_object($object) || $object->element == 'fichinter') && (empty($exclude) || !in_array('intervention', $exclude)) && (empty($include) || in_array('intervention', $include))) {
|
|
|
$substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = 'ToOfferALinkForOnlineSignature';
|
|
|
}
|
|
|
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable';
|
|
@@ -8119,7 +8133,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (empty($exclude) || !in_array('objectamount', $exclude)) {
|
|
|
+ if ((empty($exclude) || !in_array('objectamount', $exclude)) && (empty($include) || in_array('objectamount', $include))) {
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
|
|
|
|
|
|
$substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : '';
|
|
@@ -8175,7 +8189,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
}
|
|
|
|
|
|
//var_dump($substitutionarray['__AMOUNT_FORMATED__']);
|
|
|
- if (empty($exclude) || !in_array('date', $exclude)) {
|
|
|
+ if ((empty($exclude) || !in_array('date', $exclude)) && (empty($include) || in_array('date', $include))) {
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
|
|
|
|
$now = dol_now();
|
|
@@ -8212,7 +8226,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
|
|
if (isModEnabled('multicompany')) {
|
|
|
$substitutionarray = array_merge($substitutionarray, array('__ENTITY_ID__' => $conf->entity));
|
|
|
}
|
|
|
- if (empty($exclude) || !in_array('system', $exclude)) {
|
|
|
+ if ((empty($exclude) || !in_array('system', $exclude)) && (empty($include) || in_array('user', $include))) {
|
|
|
$substitutionarray['__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
|
|
|
$substitutionarray['__(AnyTranslationKey)__'] = $outputlangs->trans('TranslationOfKey');
|
|
|
$substitutionarray['__(AnyTranslationKey|langfile)__'] = $outputlangs->trans('TranslationOfKey').' (load also language file before)';
|
|
@@ -11194,7 +11208,10 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u
|
|
|
/**
|
|
|
* Get an array with properties of an element.
|
|
|
*
|
|
|
- * @param string $element_type Element type (Value of $object->element). Example: 'action', 'facture', 'project_task', 'myobject@mymodule' or 'mymodule_myobject' ...
|
|
|
+ * @param string $element_type Element type (Value of $object->element). Example:
|
|
|
+ * 'action', 'facture', 'project_task',
|
|
|
+ * 'myobject@mymodule' or
|
|
|
+ * 'myobject_mysubobject' (where mymodule = myobject, like 'project_task')
|
|
|
* @return array (module, classpath, element, subelement, classfile, classname)
|
|
|
* @see fetchObjectByElement()
|
|
|
*/
|
|
@@ -11204,19 +11221,20 @@ function getElementProperties($element_type)
|
|
|
|
|
|
$classfile = $classname = $classpath = '';
|
|
|
|
|
|
- // Parse element/subelement (ex: project_task)
|
|
|
+ // Parse element/subelement
|
|
|
$module = $element_type;
|
|
|
$element = $element_type;
|
|
|
$subelement = $element_type;
|
|
|
|
|
|
- // If we ask an resource form external module (instead of default path)
|
|
|
- if (preg_match('/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
|
|
|
+ // If we ask a resource form external module (instead of default path)
|
|
|
+ if (preg_match('/^([^@]+)@([^@]+)$/i', $element_type, $regs)) { // 'myobject@mymodule'
|
|
|
$element = $subelement = $regs[1];
|
|
|
$module = $regs[2];
|
|
|
}
|
|
|
|
|
|
- //print '<br>1. element : '.$element.' - module : '.$module .'<br>';
|
|
|
- if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) {
|
|
|
+ // If we ask a resource for a string with an element and a subelement
|
|
|
+ // Example 'project_task'
|
|
|
+ if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { // 'myobject_mysubobject' with myobject=mymodule
|
|
|
$module = $element = $regs[1];
|
|
|
$subelement = $regs[2];
|
|
|
}
|
|
@@ -11288,14 +11306,18 @@ function getElementProperties($element_type)
|
|
|
if ($element_type == 'order_supplier') {
|
|
|
$classpath = 'fourn/class';
|
|
|
$module = 'fournisseur';
|
|
|
- $subelement = 'commandefournisseur';
|
|
|
$classfile = 'fournisseur.commande';
|
|
|
+ $element = 'commande';
|
|
|
+ $subelement = '';
|
|
|
+ $classname = 'CommandeFournisseur';
|
|
|
}
|
|
|
if ($element_type == 'invoice_supplier') {
|
|
|
$classpath = 'fourn/class';
|
|
|
$module = 'fournisseur';
|
|
|
- $subelement = 'facturefournisseur';
|
|
|
$classfile = 'fournisseur.facture';
|
|
|
+ $element = 'facture';
|
|
|
+ $subelement = '';
|
|
|
+ $classname = 'FactureFournisseur';
|
|
|
}
|
|
|
if ($element_type == "service") {
|
|
|
$classpath = 'product/class';
|
|
@@ -11348,6 +11370,10 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '')
|
|
|
$objecttmp = new $classname($db);
|
|
|
$ret = $objecttmp->fetch($element_id, $element_ref);
|
|
|
if ($ret >= 0) {
|
|
|
+ if (empty($objecttmp->module)) {
|
|
|
+ $objecttmp->module = $element_prop['module'];
|
|
|
+ }
|
|
|
+
|
|
|
return $objecttmp;
|
|
|
}
|
|
|
} else {
|