diff --git a/class/actions_easycrm.class.php b/class/actions_easycrm.class.php index 653f794..4cbaf52 100644 --- a/class/actions_easycrm.class.php +++ b/class/actions_easycrm.class.php @@ -75,7 +75,7 @@ public function addMoreBoxStatsCustomer(array $parameters, CommonObject $object, global $conf, $langs, $user; // Do something only for the current context - if ($parameters['currentcontext'] == 'thirdpartycomm') { + if (strpos($parameters['context'], 'thirdpartycomm') !== false) { if (isModEnabled('project') && $user->hasRight('projet', 'lire') && isModEnabled('saturne')) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once __DIR__ . '/../../saturne/lib/object.lib.php'; @@ -129,7 +129,7 @@ public function addMoreRecentObjects(array $parameters, CommonObject $object, st global $conf, $db, $langs, $user; // Do something only for the current context - if ($parameters['currentcontext'] == 'thirdpartycomm') { + if (strpos($parameters['context'], 'thirdpartycomm') !== false) { if (isModEnabled('project') && $user->hasRight('projet', 'lire') && isModEnabled('saturne')) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once __DIR__ . '/../../saturne/lib/object.lib.php'; @@ -217,9 +217,9 @@ public function addMoreActionsButtons(array $parameters, CommonObject $object, s global $langs, $user; // Do something only for the current context - if (in_array($parameters['currentcontext'], ['thirdpartycomm', 'projectcard'])) { + if (preg_match('/thirdpartycomm|projectcard/', $parameters['context'])) { if (empty(GETPOST('action')) || GETPOST('action') == 'update') { - if ($parameters['currentcontext'] == 'thirdpartycomm') { + if (strpos($parameters['context'], 'thirdpartycomm') !== false) { $socid = $object->id; $moreparam = ''; } else { @@ -245,7 +245,7 @@ public function addMoreActionsButtons(array $parameters, CommonObject $object, s */ public function doActions(array $parameters, $object, string $action): int { - if (in_array($parameters['currentcontext'], ['invoicecard', 'invoicereccard', 'thirdpartycomm', 'thirdpartycard'])) { + if (preg_match('/invoicecard|invoicereccard|thirdpartycomm|thirdpartycard/', $parameters['context'])) { if ($action == 'set_notation_object_contact') { require_once __DIR__ . '/../lib/easycrm_function.lib.php'; @@ -271,7 +271,7 @@ public function printCommonFooter(array $parameters): int global $conf, $db, $langs , $object; // Do something only for the current context - if (in_array($parameters['currentcontext'], ['thirdpartycomm', 'projectcard'])) { + if (preg_match('/thirdpartycomm|projectcard/', $parameters['context'])) { if (isModEnabled('agenda')) { require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; @@ -281,7 +281,7 @@ public function printCommonFooter(array $parameters): int $actiomcomm = new ActionComm($db); $filter = ' AND a.id IN (SELECT c.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'categorie_actioncomm as c WHERE c.fk_categorie = ' . $conf->global->EASYCRM_ACTIONCOMM_COMMERCIAL_RELAUNCH_TAG . ')'; - $actiomcomms = $actiomcomm->getActions(GETPOST('socid'), ($parameters['currentcontext'] != 'thirdpartycomm' ? GETPOST('id') : ''), ($parameters['currentcontext'] != 'thirdpartycomm' ? 'project' : ''), $filter, 'a.datec'); + $actiomcomms = $actiomcomm->getActions(GETPOST('socid'), ((strpos($parameters['context'], 'thirdpartycomm') !== false) ? '' : GETPOST('id')), ((strpos($parameters['context'], 'thirdpartycomm') !== false) ? '' : 'project'), $filter, 'a.datec'); if (is_array($actiomcomms) && !empty($actiomcomms)) { $nbActiomcomms = count($actiomcomms); $lastActiomcomm = array_shift($actiomcomms); @@ -306,7 +306,7 @@ public function printCommonFooter(array $parameters): int } // Do something only for the current context - if ($parameters['currentcontext'] == 'projectcard') { + if (strpos($parameters['context'], 'projectcard') !== false) { if (empty(GETPOST('action')) || GETPOST('action') == 'update') { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; @@ -329,7 +329,7 @@ public function printCommonFooter(array $parameters): int } } - if (in_array($parameters['currentcontext'], ['invoicelist', 'invoicereclist', 'thirdpartylist'])) { + if (preg_match('/invoicelist|invoicereclist|thirdpartylist/', $parameters['context'])) { $cssPath = dol_buildpath('/saturne/css/saturne.min.css', 1); print ''; @@ -346,7 +346,7 @@ public function printCommonFooter(array $parameters): int '; @@ -368,7 +368,7 @@ public function printCommonFooter(array $parameters): int + resprints = ''; + } + + return 0; // or return 1 to replace standard code--> + } + /** * Overloading the printFieldListValue function : replacing the parent's function with the one below * @@ -393,7 +414,7 @@ public function printFieldListValue(array $parameters): int global $conf, $db, $langs, $object, $user; // Do something only for the current context - if ($parameters['currentcontext'] == 'projectlist') { + if (strpos($parameters['context'], 'projectlist') !== false) { if (isModEnabled('agenda') && isModEnabled('project') && $user->hasRight('projet', 'lire') && isModEnabled('saturne')) { require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; @@ -436,7 +457,7 @@ public function printFieldListValue(array $parameters): int } } - if (in_array($parameters['currentcontext'], ['invoicelist', 'invoicereclist', 'thirdpartylist'])) { + if (preg_match('/invoicelist|invoicereclist|thirdpartylist/', $parameters['context'])) { if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $extrafieldName = 'options_notation_' . $object->element . '_contact'; if ($object->element == 'facturerec') { @@ -472,7 +493,7 @@ public function printFieldListValue(array $parameters): int */ public function formConfirm(array $parameters, CommonObject $object): int { - if ($parameters['currentcontext'] == 'propalcard') { + if (strpos($parameters['context'], 'propalcard') !== false) { if (empty($object->thirdparty->id)) { $object->fetch_thirdparty(); } @@ -491,7 +512,7 @@ public function completeTabsHead(array $parameters): int { global $langs; - if (in_array($parameters['currentcontext'], ['invoicereccard', 'invoicereccontact'])) { + if (preg_match('/invoicereccard|invoicereccontact/', $parameters['context'])) { $nbContact = 0; // Enable caching of thirdrparty count Contacts require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php'; diff --git a/core/modules/modEasyCRM.class.php b/core/modules/modEasyCRM.class.php index 640d4b6..b2ee63e 100644 --- a/core/modules/modEasyCRM.class.php +++ b/core/modules/modEasyCRM.class.php @@ -129,7 +129,8 @@ public function __construct($db) 'invoicecard', 'contactcard', 'thirdpartycard', - 'thirdpartylist' + 'thirdpartylist', + 'main' ], // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, diff --git a/view/map.php b/view/map.php index f6b666d..707c3e0 100644 --- a/view/map.php +++ b/view/map.php @@ -147,55 +147,55 @@ $num = 0; $allObjects = saturne_fetch_all_object_type($objectInfos['class_name']); -if ($conf->global->EASYCRM_DISPLAY_MAIN_ADDRESS) { - if (is_array($allObjects) && !empty($allObjects)) { - foreach ($allObjects as $objectLinked) { - $objectLinked->fetch_optionals(); - - if (!isset($objectLinked->array_options['options_' . $objectType . 'address']) || dol_strlen($objectLinked->array_options['options_' . $objectType . 'address']) <= 0) { - continue; - } else { - $addressId = $objectLinked->array_options['options_' . $objectType . 'address']; - } - - $object->fetch($addressId); - - if (($filterId > 0 && $filterId != $objectLinked->id) || (dol_strlen($filterType) > 0 && $filterType != $object->type) || (dol_strlen($filterTown) > 0 && $filterTown != $object->town) || - ($filterCountry > 0 && $filterCountry != $object->fk_country) || ($filterRegion > 0 && $filterRegion != $object->fk_region) || ($filterState > 0 && $filterState != $object->fk_department)) { - continue; - } - - if ($object->longitude != 0 && $object->latitude != 0) { - $object->convertCoordinates(); - $num++; - } else { - continue; - } - - $locationID = $addressId; - - $description = $objectLinked->getNomUrl(1) . '
'; - $description .= $langs->trans($object->type) . ' : ' . $object->name; - $description .= dol_strlen($object->town) > 0 ? '
' . $langs->trans('Town') . ' : ' . $object->town : ''; - $color = randomColor(); - - $objectList[$locationID] = !empty($object->fields['color']) ? $object->fields['color'] : '#' . $color; - - // Add geoJSON point - $features[] = [ - 'type' => 'Feature', - 'geometry' => [ - 'type' => 'Point', - 'coordinates' => [$object->longitude, $object->latitude], - ], - 'properties' => [ - 'desc' => $description, - 'address' => $locationID, - ], - ]; - } - } -} else { +//if ($conf->global->EASYCRM_DISPLAY_MAIN_ADDRESS) { +// if (is_array($allObjects) && !empty($allObjects)) { +// foreach ($allObjects as $objectLinked) { +// $objectLinked->fetch_optionals(); +// +// if (!isset($objectLinked->array_options['options_' . $objectType . 'address']) || dol_strlen($objectLinked->array_options['options_' . $objectType . 'address']) <= 0) { +// continue; +// } else { +// $addressId = $objectLinked->array_options['options_' . $objectType . 'address']; +// } +// +// $object->fetch($addressId); +// +// if (($filterId > 0 && $filterId != $objectLinked->id) || (dol_strlen($filterType) > 0 && $filterType != $object->type) || (dol_strlen($filterTown) > 0 && $filterTown != $object->town) || +// ($filterCountry > 0 && $filterCountry != $object->fk_country) || ($filterRegion > 0 && $filterRegion != $object->fk_region) || ($filterState > 0 && $filterState != $object->fk_department)) { +// continue; +// } +// +// if ($object->longitude != 0 && $object->latitude != 0) { +// $object->convertCoordinates(); +// $num++; +// } else { +// continue; +// } +// +// $locationID = $addressId; +// +// $description = $objectLinked->getNomUrl(1) . '
'; +// $description .= $langs->trans($object->type) . ' : ' . $object->name; +// $description .= dol_strlen($object->town) > 0 ? '
' . $langs->trans('Town') . ' : ' . $object->town : ''; +// $color = randomColor(); +// +// $objectList[$locationID] = !empty($object->fields['color']) ? $object->fields['color'] : '#' . $color; +// +// // Add geoJSON point +// $features[] = [ +// 'type' => 'Feature', +// 'geometry' => [ +// 'type' => 'Point', +// 'coordinates' => [$object->longitude, $object->latitude], +// ], +// 'properties' => [ +// 'desc' => $description, +// 'address' => $locationID, +// ], +// ]; +// } +// } +//} else { $geolocations = $geolocation->fetchAll('', '', 0, 0, ['customsql' => 't.element_type = ' . "'" . GETPOST('from_type') . "'"]); if (is_array($geolocations) && !empty($geolocations)) { foreach($geolocations as $geolocation) { @@ -247,7 +247,7 @@ ]; } } -} +//} if ($fromId > 0) { $objectLinked->fetch($fromId);