Skip to content

Commit

Permalink
Merge pull request #298 from Eoxia/develop
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
nicolas-eoxia authored Aug 29, 2024
2 parents 1d116d9 + e7e475d commit c3708cc
Show file tree
Hide file tree
Showing 28 changed files with 875 additions and 539 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
## Informations

- Numéro du module : 436351
- Dernière mise à jour : 05/07/2024
- Dernière mise à jour : 29/08/2024
- Éditeur : [Eoxia](https://eoxia.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux
-
### Version

- Version : 1.4.0
- Version : 1.5.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 17.0.2 - 20.0.0
- Saturne Framework : 1.5.1
- Saturne Framework : 1.6.0

## Liens

Expand Down
106 changes: 0 additions & 106 deletions admin/address.php

This file was deleted.

16 changes: 16 additions & 0 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
$timespent = GETPOST('timespent');
$typeEvent = GETPOST('actioncode');
$statusEvent = (GETPOST('status') == 'NA' ? -1 : GETPOST('status'));
$quickEventLabelLength = GETPOST('quick_event_label_length');

if (!empty($projectOpportunityStatus)) {
dolibarr_set_const($db, 'EASYCRM_PROJECT_OPPORTUNITY_STATUS_VALUE', $projectOpportunityStatus, 'integer', 0, '', $conf->entity);
Expand All @@ -102,6 +103,9 @@
if (!empty($typeEvent)) {
dolibarr_set_const($db, 'EASYCRM_EVENT_TYPE_CODE_VALUE', $typeEvent, 'chaine', 0, '', $conf->entity);
}
if (!empty($quickEventLabelLength)) {
dolibarr_set_const($db, 'EASYCRM_EVENT_LABEL_MAX_LENGTH_VALUE', $quickEventLabelLength, 'integer', 0, '', $conf->entity);
}
dolibarr_set_const($db, 'EASYCRM_EVENT_STATUS_VALUE', $statusEvent, 'integer', 0, '', $conf->entity);

setEventMessage('SavedConfig');
Expand Down Expand Up @@ -461,6 +465,18 @@
//print ajax_constantonoff('EASYCRM_EVENT_LABEL_VISIBLE');
print '</td></td><td></td></tr>';

// LabelLength
print '<tr class="oddeven"><td>';
print $langs->trans('LabelLength');
print '</td><td>';
print $langs->trans('LabelLengthDescription');

print '<td class="center"></td>';

print '<td><input type="number" name="quick_event_label_length" class="minwidth200" value="' . getDolGlobalInt('EASYCRM_EVENT_LABEL_MAX_LENGTH_VALUE') . '" min="1" max="128"></td>';

print '</tr>';

// Date start
print '<tr class="oddeven"><td>';
print $langs->trans('DateStart');
Expand Down
31 changes: 24 additions & 7 deletions class/actions_easycrm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,17 @@ public function printCommonFooter(array $parameters): int

// Do something only for the current context
if (preg_match('/thirdpartycomm|projectcard/', $parameters['context'])) {
$pictoPath = dol_buildpath('/easycrm/img/easycrm_color.png', 1);
$pictoMod = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule');

if (isModEnabled('agenda')) {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';

$pictopath = dol_buildpath('/easycrm/img/easycrm_color.png', 1);
$picto = img_picto('', $pictopath, '', 1, 0, 0, '', 'pictoModule');

$actionComm = new ActionComm($db);
$socid = (GETPOSTISSET('socid') ? GETPOST('socid') : $object->socid);

$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 . ')';
$actionComms = $actionComm->getActions(GETPOST('socid'), ((strpos($parameters['context'], 'thirdpartycomm') !== false) ? '' : GETPOST('id')), ((strpos($parameters['context'], 'thirdpartycomm') !== false) ? '' : 'project'), $filter, 'a.datec');
$filter = ' AND a.id IN (SELECT c.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'categorie_actioncomm as c WHERE c.fk_categorie = ' . getDolGlobalInt('EASYCRM_ACTIONCOMM_COMMERCIAL_RELAUNCH_TAG') . ')';
$actionComms = $actionComm->getActions($socid, ((strpos($parameters['context'], 'thirdpartycomm') !== false) ? '' : GETPOST('id')), ((strpos($parameters['context'], 'thirdpartycomm') !== false) ? '' : 'project'), $filter, 'a.datec');
if (is_array($actionComms) && !empty($actionComms)) {
$nbActionComms = count($actionComms);
$lastActionComm = array_shift($actionComms);
Expand All @@ -321,8 +322,8 @@ public function printCommonFooter(array $parameters): int
$badgeClass = 8;
}

$url = '?socid=' . $object->socid . '&fromtype=project' . '&project_id=' . $object->id . '&action=create&token=' . newToken();
$out = '<tr><td class="titlefield">' . $picto . $langs->trans('CommercialsRelaunching') . '</td>';
$url = '?socid=' . $socid . (strpos($_SERVER['PHP_SELF'], 'projet') ? '&fromtype=project' . '&project_id=' . $object->id : '') . '&action=create&token=' . newToken();
$out = '<tr><td class="titlefield">' . $pictoMod . $langs->trans('CommercialsRelaunching') . '</td>';

$picto = img_picto($langs->trans('CommercialsRelaunching'), 'fontawesome_fa-headset_fas');

Expand All @@ -344,6 +345,22 @@ public function printCommonFooter(array $parameters): int
</script>
<?php
}

if (!empty($object->array_options['options_projectaddress'])) {
$contact = new Contact($db);
$result = $contact->fetch($object->array_options['options_projectaddress']);
if ($result > 0) {
$pictoContact = img_picto('', 'contact', 'class="pictofixedwidth"') . $contact->lastname;
$outAddress = '<td>';
$outAddress .= dolButtonToOpenUrlInDialogPopup('address' . $result, $langs->transnoentities('FavoriteAddress'), $pictoContact, '/contact/card.php?id='. $contact->id);
$outAddress .= '</td></tr>';
?>
<script>
jQuery('.valuefield.project_extras_projectaddress').replaceWith(<?php echo json_encode($outAddress); ?>)
</script>
<?php
}
}
}

// Do something only for the current context
Expand Down
72 changes: 3 additions & 69 deletions class/address.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,10 @@ public function create(User $user, bool $notrigger = false): int
$region = is_array($regionAndState) && !empty($regionAndState['region']) ? $regionAndState['region'] : '';
$state = is_array($regionAndState) && !empty($regionAndState['label']) ? $regionAndState['label'] : '';
$parameters = (dol_strlen($country) > 0 ? $country . ',+' : '') . (dol_strlen($region) > 0 ? $region . ',+' : '') . (dol_strlen($state) > 0 ? $state . ',+' : '') . (dol_strlen($this->town) > 0 ? $this->town . ',+' : '') . (dol_strlen($this->zip) > 0 ? $this->zip . ',+' : '') . (dol_strlen($this->address) > 0 ? $this->address : '');
$parameters = dol_sanitizeFileName($parameters);
$parameters = str_replace(' ', '+', $parameters);

$context = stream_context_create(["http" => ["header" => "User-Agent:" . $_SERVER['HTTP_USER_AGENT']]]);
$context = stream_context_create(["http" => ["header" => "Referer:" . $_SERVER['HTTP_REFERER']]]);
$response = file_get_contents('https://nominatim.openstreetmap.org/search?q='. $parameters .'&format=json&polygon=1&addressdetails=1', false, $context);
$data = json_decode($response, false);

Expand Down Expand Up @@ -425,72 +426,5 @@ public function LibStatut(int $status, int $mode = 0): string

return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}

/**
* Fetch addresses in database with parent ID
*
* @param int $element_id ID of object linked
* @param string $element_type Type of object
* @param string $morefilter Filter
* @return array|integer
* @throws Exception
*/
public function fetchAddresses(int $element_id, string $element_type, string $morefilter = '1 = 1')
{
$filter = ['customsql' => 'element_id=' . $element_id . ' AND ' . $morefilter . ' AND element_type="' . $element_type . '"' . ' AND status >= 0'];
return parent::fetchAll('', '', 0, 0, $filter);
}

/**
* Convert longitude and latitude format WGS 84 (EPSG:4326) to Web Mercator (EPSG:3857)
*
* @return object
*/
public function convertCoordinates()
{
$convertFactor = 6378137.0;
$longitude = $this->longitude / 180 * pi();
$latitude = $this->latitude / 180 * pi();
$this->longitude = $convertFactor * $longitude;
$this->latitude = $convertFactor * log(tan(pi() / 4 + $latitude / 2));

return $this;
}

/**
* Inject map features
*
* @param array $features array of features: id, description, color, longitude, latitude
* @param int $chunkSize size of chunk
* @param int $deep
* @return int
*/
public function injectMapFeatures(array $features, int $chunkSize, int $deep = 0): int
{
$error = 0;

if (!empty($features)) {
$bulkFeatures = array_chunk($features, $chunkSize);
foreach ($bulkFeatures as $bulk) {
$encodedBulk = json_encode($bulk);
if (!empty($encodedBulk)) {
print "geojsonMarkers.features = $.merge(geojsonMarkers.features, $encodedBulk);\n";
} else {
if ($chunkSize > 1) {
$result = $this->injectMapFeatures($bulk, floor($chunkSize / 2), $deep + 1);
$result < 0 ? $error++ : '';
} else {
ob_start();
print_r($bulk);
$content = ob_get_contents();
ob_clean();
print "console.error('Map: Error encode json map feature, data:', '" . dol_escape_js($content, 1) . "');\n";
$error++;
}
}
}
}

return $error > 0 ? -1 : 0;
}
}

Loading

0 comments on commit c3708cc

Please sign in to comment.