Skip to content

Commit

Permalink
Rework of URLs pointing to CRM
Browse files Browse the repository at this point in the history
  • Loading branch information
Mapiiik committed Oct 30, 2023
1 parent 0361339 commit 1004d35
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 46 deletions.
3 changes: 0 additions & 3 deletions config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export REPORT_EMAILS=""

export WATCHER_CRM_URL=""
export WATCHER_CRM_KEY=""
export CUSTOMER_SERIES=110000

export CUSTOMER_POINTS_URL=""

# Uncomment these to define cache configuration via environment variables.
#export CACHE_DURATION="+2 minutes"
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CustomerPointsUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function execute(Arguments $args, ConsoleIo $io)
{
$url = $args->getArgument('url');
if (!isset($url)) {
$url = (string)env('CUSTOMER_POINTS_URL');
$url = env('WATCHER_CRM_URL') . '/api/customers/customer-points.json?api_key=' . env('WATCHER_CRM_KEY');
}

$json = file_get_contents($url);
Expand Down
22 changes: 14 additions & 8 deletions templates/AccessPointContacts/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,23 @@
</tr>
<tr>
<th><?= __('Customer Number') ?></th>
<td><?= $accessPointContact->__isset('customer_number') ? $this->Html->link(
$accessPointContact->customer_number,
env('WATCHER_CRM_URL') . '/admin/customers/' . (
(int)$accessPointContact->customer_number - (int)env('CUSTOMER_SERIES', '0')
),
['target' => '_blank']
) : '' ?></td>
<td><?= $accessPointContact->__isset('customer_number') && env('WATCHER_CRM_URL') ?
$this->Html->link(
$accessPointContact->customer_number,
env('WATCHER_CRM_URL')
. '/customers?search=' . $accessPointContact->customer_number,
['target' => '_blank']
) : h($accessPointContact->customer_number) ?></td>
</tr>
<tr>
<th><?= __('Contract Number') ?></th>
<td><?= h($accessPointContact->contract_number) ?></td>
<td><?= $accessPointContact->__isset('contract_number') && env('WATCHER_CRM_URL') ?
$this->Html->link(
$accessPointContact->contract_number,
env('WATCHER_CRM_URL')
. '/customers?search=' . $accessPointContact->contract_number,
['target' => '_blank']
) : h($accessPointContact->contract_number) ?></td>
</tr>
</table>
</div>
Expand Down
40 changes: 22 additions & 18 deletions templates/AccessPoints/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,37 +182,41 @@
<th><?= __('Note') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($accessPoint->access_point_contacts as $accessPointContacts) : ?>
<?php foreach ($accessPoint->access_point_contacts as $accessPointContact) : ?>
<tr>
<td><?= h($accessPointContacts->name) ?></td>
<td><?= h($accessPointContacts->phone) ?></td>
<td><?= h($accessPointContacts->email) ?></td>
<td>
<?= $accessPointContacts->__isset('customer_number') ? $this->Html->link(
$accessPointContacts->customer_number,
env('WATCHER_CRM_URL') . '/admin/customers/' . (
(int)$accessPointContacts->customer_number - (int)env('CUSTOMER_SERIES', '0')
),
<td><?= h($accessPointContact->name) ?></td>
<td><?= h($accessPointContact->phone) ?></td>
<td><?= h($accessPointContact->email) ?></td>
<td><?= $accessPointContact->__isset('customer_number') && env('WATCHER_CRM_URL') ?
$this->Html->link(
$accessPointContact->customer_number,
env('WATCHER_CRM_URL')
. '/customers?search=' . $accessPointContact->customer_number,
['target' => '_blank']
) : '' ?>
</td>
<td><?= h($accessPointContacts->contract_number) ?></td>
<td><?= $this->Text->autoParagraph(h($accessPointContacts->note)); ?></td>
) : h($accessPointContact->customer_number) ?></td>
<td><?= $accessPointContact->__isset('contract_number') && env('WATCHER_CRM_URL') ?
$this->Html->link(
$accessPointContact->contract_number,
env('WATCHER_CRM_URL')
. '/customers?search=' . $accessPointContact->contract_number,
['target' => '_blank']
) : h($accessPointContact->contract_number) ?></td>
<td><?= $this->Text->autoParagraph(h($accessPointContact->note)); ?></td>
<td class="actions">
<?= $this->Html->link(
__('View'),
[
'controller' => 'AccessPointContacts',
'action' => 'view',
$accessPointContacts->id,
$accessPointContact->id,
]
) ?>
<?= $this->Html->link(
__('Edit'),
[
'controller' => 'AccessPointContacts',
'action' => 'edit',
$accessPointContacts->id,
$accessPointContact->id,
],
['class' => 'win-link']
) ?>
Expand All @@ -221,11 +225,11 @@
[
'controller' => 'AccessPointContacts',
'action' => 'delete',
$accessPointContacts->id,
$accessPointContact->id,
],
['confirm' => __(
'Are you sure you want to delete # {0}?',
$accessPointContacts->id
$accessPointContact->id
)]
) ?>
</td>
Expand Down
28 changes: 12 additions & 16 deletions templates/CustomerConnections/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,44 @@
</tr>
<tr>
<th><?= __('Customer Point') ?></th>
<td>
<?= $customerConnection->__isset('customer_point') ? $this->Html->link(
<td><?= $customerConnection->__isset('customer_point') ?
$this->Html->link(
$customerConnection->customer_point->name,
[
'controller' => 'CustomerPoints',
'action' => 'view',
$customerConnection->customer_point->id,
]
) : '' ?>
</td>
) : '' ?></td>
</tr>
<tr>
<th><?= __('Access Point') ?></th>
<td>
<?= $customerConnection->__isset('access_point') ? $this->Html->link(
<td><?= $customerConnection->__isset('access_point') ?
$this->Html->link(
$customerConnection->access_point->name,
[
'controller' => 'AccessPoints',
'action' => 'view',
$customerConnection->access_point->id,
]
) : '' ?>
</td>
) : '' ?></td>
<tr>
<th><?= __('Customer Number') ?></th>
<td>
<?= $customerConnection->__isset('customer_url') ? $this->Html->link(
<td><?= $customerConnection->__isset('customer_url') && env('WATCHER_CRM_URL') ?
$this->Html->link(
$customerConnection->customer_number,
env('WATCHER_CRM_URL') . $customerConnection->customer_url,
['target' => '_blank']
) : h($customerConnection->customer_number) ?>
</td>
) : h($customerConnection->customer_number) ?></td>
</tr>
<tr>
<th><?= __('Contract Number') ?></th>
<td>
<?= $customerConnection->__isset('contract_url') ? $this->Html->link(
<td><?= $customerConnection->__isset('contract_url') && env('WATCHER_CRM_URL') ?
$this->Html->link(
$customerConnection->contract_number,
env('WATCHER_CRM_URL') . $customerConnection->contract_url,
['target' => '_blank']
) : h($customerConnection->contract_number) ?>
</td>
) : h($customerConnection->contract_number) ?></td>
</tr>
</table>
</div>
Expand Down

0 comments on commit 1004d35

Please sign in to comment.