--- /dev/null
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouvelle instance applicative',
+ array('controller' => 'appliances', 'action' => 'add')
+); ?>
+</h1>
+<button onclick="checkAppliancesInformation();">Vérifier ces informations avec Sugar</button>
+<table>
+ <tr>
+ <th>Référence d'instance applicative</th>
+ <th>Client</th>
+ <th>Canal</th>
+ <?php if(isset($warningsArray) && count($warningsArray) > 0) { ?>
+ <th>Alertes</th>
+ <?php } ?>
+ <th>Actions</th>
+ </tr>
+
+ <?php
+ if(isset($appliances)) { foreach ($appliances as $appliance): ?>
+ <tr>
+ <td><?php echo $appliance['Appliance']['reference']; ?></td>
+
+ <?php
+
+ // CHECKING CUSTOMER EXISTENCE / FINDABILITY FOR THIS APPLIANCE
+ if(isset($customersArray) && array_key_exists($appliance['Appliance']['id'], $customersArray)) {
+ $customer = $customersArray[$appliance['Appliance']['id']]; ?>
+ <td>
+ <?php
+
+ // DISPLAYING CUSTOMER AP ID (ADD / CHANGE TO ITS NAME ?)
+ echo $customer['Customer']['ap_id'];
+ ?>
+ </td>
+
+ <?php
+
+ // DISPLAYING ERROR MESSAGE IF NO CUSTOMER IS FOUND
+ } else { ?>
+ <td>Client pour cette instance applicative inexistant ou introuvable</td>
+ <?php } ?>
+
+ <!-- TO-DO : DISPLAY PRODUCT NAME -->
+
+ <!-- TO-DO : DISPLAY LAST VERSION DECLARED FROM CHANGELOG
+
+ if(array_key_exists($appliance['Appliance']['id'], $lastUpdates)) {
+ $lastUpdate = $lastUpdates[$appliance['Appliance']['id']];
+ echo $appliance['Appliance']['version']." le ".$lastUpdate;
+ } else {
+ echo $appliance['Appliance']['version'];
+ }
+ -->
+
+
+ <td><?php echo strtoupper($appliance['Appliance']['channel']); ?></td>
+
+ <?php
+
+ // CHECKING CHANGELOG EXISTENCE FOR THIS APPLIANCE
+ if(isset($changelogsArray) && array_key_exists($appliance['Appliance']['id'], $changelogsArray)) {
+ $changelog = $changelogsArray[$appliance['Appliance']['id']];
+
+ // CHECKING WARNING EXISTENCE
+ if(isset($warningsArray) && count($warningsArray) > 0) {
+ ?>
+ <td>
+ <table>
+ <tr>
+ <?php if(array_key_exists($changelog['Changelog']['id'], $warningsArray)) { ?>
+ <th>Message</th>
+ <th>Actions</th>
+ <?php } ?>
+ </tr>
+ <?php
+
+ // CHECKING WARNING EXISTENCE FOR THIS CHANGELOG AND APPLIANCE
+ if(array_key_exists($changelog['Changelog']['id'], $warningsArray)) {
+ foreach ($warningsArray[$changelogsArray[$appliance['Appliance']['id']]['Changelog']['id']] as $warning): ?>
+ <tr>
+ <td>
+ <?php
+
+ // DISPLAYING WARNING MESSAGE
+ echo $warning['Warning']['message'] ?>
+ </td>
+ <td>
+ <?php
+ $escapedApplianceReference = str_replace("/", "SLASH", $appliance['Appliance']['reference']);
+
+ // WARNING VALIDATION ACTION
+ echo $this->Html->link(
+ $this->Html->image('validate.png', array('class' => 'button')),
+ array('controller' => 'changelogs', 'action' => 'acknowledgeWarning', $changelog['Changelog']['id'], $warning['Warning']['id'], true, $escapedApplianceReference),
+ array('escape' => false)
+ )
+ .' '.
+
+ // WARNING REFUSAL ACTION
+ $this->Html->link(
+ $this->Html->image('delete.png', array('class' => 'button')), '#',
+ array('escape' => false,
+ 'onclick' => 'keepMaintained('.$appliance['Appliance']['id'].', '.$changelog['Changelog']['id'].', '.$warning['Warning']['id'].')'
+ )
+ );
+ ?>
+ </td>
+ </tr>
+ <?php endforeach; } ?>
+ </table>
+ </td>
+ <?php } ?>
+ <td>
+ <?php echo $this->Html->link(
+ $this->Html->image('edit.jpg', array('class' => 'button')),
+ array('controller' => 'appliances', 'action' => 'edit', $appliance['Appliance']['id']),
+ array('escape' => false)
+ ).' '.
+ $this->Html->link(
+ $this->Html->image('delete.png', array('class' => 'button')), '#',
+ array('escape' => false,
+ 'onclick' => 'deleteAppliance('.$appliance['Appliance']['id'].', '.$changelog['Changelog']['id'].')'
+ )
+ );
+ ?>
+ </td>
+ <?php
+
+ // DISPLAYING ERROR MESSAGE IF NO CHANGELOG IS FOUND
+ } else { ?>
+ <td>Historique pour cette instance applicative inexistant ou introuvable</td>
+ <td>
+ <?php
+
+ // APPLIANCE EDIT ACTION
+ echo $this->Html->link(
+ $this->Html->image('edit.jpg', array('class' => 'button')),
+ array('controller' => 'appliances', 'action' => 'edit', $appliance['Appliance']['id']),
+ array('escape' => false)
+ ).' '.
+
+ // APPLIANCE DELETE ACTION
+ $this->Form->postLink(
+ $this->Html->image('delete.png', array('class' => 'button')),
+ array('controller' => 'appliances', 'action' => 'delete', $appliance['Appliance']['id']),
+ array('escape' => false, 'confirm' => 'Etes-vous certain ?')
+ );
+ ?>
+ </td>
+ <?php } ?>
+ </tr>
+ <?php endforeach; unset($appliances); } ?>
+</table>
+<script>
+
+ // JS FUNCTIONS FOR CONFIRMATION POP-UPS AND AJAX CALLS
+ var keepMaintained = function (appliance_id, changelog_id, warning_id) {
+ var acknowledgeWarningUrl = "/changelogs/acknowledgeWarning/"+changelog_id+"/"+warning_id+"/false",
+ isStillMaintained = confirm("Conserver le maintien de l'appliance ?");
+ if(isStillMaintained) {
+ alert('Maintien conservé');
+ location.href = acknowledgeWarningUrl;
+ } else {
+ alert('Maintien supprimé');
+ $.ajax({
+ url: "http://allo_serveur?action=disable_maintained&id="+appliance_id,
+ beforeSend: function(xhr) {
+ xhr.overrideMimeType("text/plain; charset=x-user-defined");
+ }
+ })
+ .done(function(data) {
+ location.href = acknowledgeWarningUrl;
+ });
+ }
+ };
+
+ var deleteAppliance = function (appliance_id, changelog_id) {
+ var confirmAction = confirm("Etes-vous certain ?");
+ if (confirmAction) {
+ var isChangelogKept = confirm("Conserver l'historique de l'instance applicative ?");
+ if(isChangelogKept) {
+ alert('historique conservé');
+ location.href = "/appliances/delete/"+appliance_id;
+ } else {
+ alert('historique supprimé');
+ $.ajax({
+ url: "http://allo_webadmin/changelogs/delete/"+changelog_id,
+ beforeSend: function(xhr) {
+ xhr.overrideMimeType("text/plain; charset=x-user-defined");
+ }
+ })
+ .done(function(data) {
+ location.href = "/appliances/delete/"+appliance_id;
+ });
+ }
+ }
+ };
+
+ var checkAppliancesInformation = function () {
+ $.ajax({
+ url: "http://allo_serveur/?action=check_appliances_infos",
+ beforeSend: function(xhr) {
+ xhr.overrideMimeType("text/plain; charset=x-user-defined");
+ }
+ })
+ .done(function( data ) {
+ location.href = "/appliances";
+ });
+ };
+</script>
\ No newline at end of file