Skip to content

Commit

Permalink
Stable
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszkrzaczkowski committed Nov 23, 2020
1 parent 6111c07 commit fae267e
Show file tree
Hide file tree
Showing 5 changed files with 391 additions and 28 deletions.
2 changes: 1 addition & 1 deletion api/webservice/Portal/PrivilegeQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function getConditions(\App\Db\Query $query, string $moduleName, $
return;
}
$where = ['and'];
$where[] = [$fieldInfo['tablename'] . '.' . $fieldInfo['columnname'] => 1];
$where[] = [$fieldInfo['tablename'] . '.' . $fieldInfo['columnname'] => 1];
$parentModule = \App\Record::getType($parentId);
$fields = \App\Field::getRelatedFieldForModule($moduleName);
$foundField = true;
Expand Down
89 changes: 89 additions & 0 deletions app/Map/Routing/Yours.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/**
* Connector to find routing. Connector based on service YOURS.
*
* @package App
*
* @copyright YetiForce Sp. z o.o
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
* @author Mariusz Krzaczkowski <[email protected]>
*
* @see https://wiki.openstreetmap.org/wiki/YOURS
*/

namespace App\Map\Routing;

/**
* Connector for service YOURS to get routing.
*/
class Yours extends Base
{
/**
* {@inheritdoc}
*/
public function calculate()
{
if (!\App\RequestUtil::isNetConnection()) {
throw new \App\Exceptions\AppException('ERR_NO_INTERNET_CONNECTION');
}
$coordinates = [];
$travel = $distance = 0;
$description = '';
foreach ($this->parsePoints() as $track) {
$url = $this->url . '?format=geojson&flat=' . $track['startLat'] . '&flon=' . $track['startLon'] . '&tlat=' . $track['endLat'] . '&tlon=' . $track['endLon'] . '&lang=' . \App\Language::getLanguage() . '&instructions=1';
\App\Log::beginProfile("GET|Yours::calculate|{$url}", __NAMESPACE__);
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, [
'timeout' => 60,
'http_errors' => false,
]);
\App\Log::endProfile("GET|Yours::calculate|{$url}", __NAMESPACE__);
if (200 === $response->getStatusCode()) {
$json = \App\Json::decode($response->getBody());
} else {
throw new \App\Exceptions\AppException('Error with connection |' . $response->getReasonPhrase() . '|' . $response->getBody());
}
$coordinates = array_merge($coordinates, $json['coordinates']);
$description .= $json['properties']['description'];
$travel += $json['properties']['traveltime'];
$distance += $json['properties']['distance'];
}
$this->geoJson = [
'type' => 'LineString',
'coordinates' => $coordinates,
];
$this->travelTime = $travel;
$this->distance = $distance;
$this->description = $description;
}

/**
* {@inheritdoc}
*/
public function parsePoints(): array
{
$tracks = [];
$startLat = $this->start['lat'];
$startLon = $this->start['lon'];
if (!empty($this->indirectPoints)) {
foreach ($this->indirectPoints as $tempLon) {
$endLon = $tempLon['lon'];
$endLat = $tempLon['lat'];
$tracks[] = [
'startLat' => $startLat,
'startLon' => $startLon,
'endLat' => $endLat,
'endLon' => $endLon,
];
$startLat = $endLat;
$startLon = $endLon;
}
}
$tracks[] = [
'startLat' => $startLat,
'startLon' => $startLon,
'endLat' => $this->end['lat'],
'endLon' => $this->end['lon']
];
return $tracks;
}
}
56 changes: 56 additions & 0 deletions app/YetiForce/Shop/Product/YetiForceHelp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* YetiForce shop PremiumSupport file.
*
* @package App
*
* @copyright YetiForce Sp. z o.o
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
* @author Mariusz Krzaczkowski <[email protected]>
*/

namespace App\YetiForce\Shop\Product;

/**
* YetiForce shop PremiumSupport class.
*/
class YetiForceHelp extends \App\YetiForce\Shop\AbstractBaseProduct
{
/** {@inheritdoc} */
public $label = 'YetiForce Help';

/** {@inheritdoc} */
public $category = 'Support';

/** {@inheritdoc} */
public $website = 'https://yetiforce.com/en/marketplace/support';

/** {@inheritdoc} */
public $prices = [
'Micro' => 50,
'Small' => 80,
'Medium' => 200,
'Large' => 400,
'Corporation' => 800
];
/** {@inheritdoc} */
public $featured = true;

/** {@inheritdoc} */
public function getAdditionalButtons(): array
{
return [
\Vtiger_Link_Model::getInstanceFromValues([
'linklabel' => 'Website',
'relatedModuleName' => '_Base',
'linkicon' => 'fas fa-globe',
'linkhref' => true,
'linkExternal' => true,
'linktarget' => '_blank',
'linkurl' => $this->website,
'linkclass' => 'btn-info',
'showLabel' => 1,
]),
];
}
}
Loading

0 comments on commit fae267e

Please sign in to comment.