// DEFAULT HOME (CAKEPHP PAGE)
//Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
// INSTANCES INDEX AS HOME PAGE
- Router::connect('/', array('controller' => 'instances', 'action' => 'index'));
+ Router::connect('/', array('controller' => 'appliances', 'action' => 'index'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
+++ /dev/null
-<?php
- class AdministrateursController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
-
- public function index() {
- $administrateurs = $this->Administrateur->find('all');
- $this->set(array(
- 'administrateurs' => $administrateurs,
- '_serialize' => array('administrateurs')
- ));
- }
-
- public function login() {
- if ($this->request->is('POST')) {
- $administrateurs = $this->Administrateur->find('all');
- $success = false;
- $login = $_POST['login'];
- $pass = md5($_POST['pass']);
- foreach($administrateurs as $administrateur) {
- if($administrateur['Administrateur']['login'] === $login && $administrateur['Administrateur']['pass'] == $pass) {
- $success = true;
- break;
- }
- }
- if ($success) {
- $this->Session->setFlash(__("Login OK."));
- return $this->redirect(array(/*'controller' => 'instances', */'action' => 'index'));
-
- } else {
- $this->Session->setFlash(__("Login FAIL."));
- return $this->redirect(array('action' => 'login'));
- }
- }
- }
-
- public function register() {
- if ($this->request->is('POST')) {
- $login = $_POST['login'];
- // VERIFICATION DE LA DISPONIBILITÉ DU PSEUDO
- $administrateurs = $this->Administrateur->find('all');
- $loginDispo = true;
- foreach($administrateurs as $administrateur) {
- if($administrateur['Administrateur']['login'] === $login) {
- $loginDispo = false;
- break;
- }
- }
- if($loginDispo) {
- $pass = md5($_POST['pass']);
- $this->Administrateur->create();
- $this->Administrateur->value('login', $login);
- $this->Administrateur->value('pass', $pass);
- $this->Administrateur->save();
- if (isset($this->Administrateur)) {
- $this->Session->setFlash(__("Register OK."));
- return $this->redirect(array(/*'controller' => 'instances', */'action' => 'index'));
- }
- $this->Session->setFlash(__("Register FAIL."));
- } else {
- $this->Session->setFlash(__("Ce pseudo est déjà utilisé."));
- }
- }
- }
- }
+++ /dev/null
-<?php
- class AlertesController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
-
- public function index() {
- //$this->set('alertes', $this->Alerte->find('all'));
- $alertes = $this->Alerte->find('all');
- $this->set(array(
- 'alertes' => $alertes,
- '_serialize' => array('alertes')
- ));
- }
-
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvaise alerte'));
- }
-
- $alerte = $this->Alerte->findById($id);
- if (!$alerte) {
- throw new NotFoundException(__('Mauvaise alerte'));
- }
- $this->set('alerte', $alerte);
- }
-
- public function add() {
- if ($this->request->is('alerte')) {
- $this->Alerte->create();
- if ($this->Alerte->save($this->request->data)) {
- $this->Session->setFlash(__("L'alerte a été enregistrée."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Enregistrement de l'alerte impossible."));
- }
- }
-
- public function edit($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Alerte introuvable'));
- }
-
- $alerte = $this->Alerte->findById($id);
- if (!$alerte) {
- throw new NotFoundException(__('Alerte introuvable'));
- }
- $this->set('alerte', $alerte);
-
- if ($this->request->is(array('alerte', 'put'))) {
- $this->Alerte->id = $id;
- if ($this->Alerte->save($this->request->data)) {
- $this->Session->setFlash(__("L'alerte a été mise à jour."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Mise à jour de l'alerte impossible."));
- }
-
- if (!$this->request->data) {
- $this->request->data = $alerte;
- }
- }
-
- public function delete($id) {
- if ($this->request->is('get')) {
- throw new MethodNotAllowedException();
- }
-
- if ($this->Alerte->delete($id)) {
- $this->Session->setFlash(
- __("L'alerte d'id: %s a été supprimée.", h($id))
- );
- return $this->redirect(array('action' => 'index'));
- }
- }
- }
-?>
// GETTING CUSTOMER
$applianceReferenceArray = explode("/",$appliance['Appliance']['reference']);
- $customerAPId = substr($applianceReferenceArray[1],0,-11);
- foreach($customers as $customer) {
+ if(isset($applianceReferenceArray[1])) {
+ $customerAPId = substr($applianceReferenceArray[1], 0, -11);
+ foreach($customers as $customer) {
- // ADDING CUSTOMER TO LIST
- if($customer['Customer']['ap_id'] === $customerAPId) {
- $customersArray[$appliance['Appliance']['id']] = $customer;
+ // ADDING CUSTOMER TO LIST
+ if($customer['Customer']['ap_id'] === $customerAPId) {
+ $customersArray[$appliance['Appliance']['id']] = $customer;
+ }
}
}
}
$this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__("Enregistrement de l'instance applicative impossible."));
+ } else {
+
+ // GETTING CONTROLLERS
+ App::import('Controller', 'Products');
+ $productsController = new ProductsController;
+ App::import('Controller', 'Versions');
+ $versionsController = new VersionsController;
+
+ // GETTING PRODUCTS LIST
+ $products = $productsController->Product->find('all');
+ $productsArray = array();
+ foreach($products as $product) {
+ $productsArray[$product['Product']['id']] = $product['Product']['name'];
+ }
+
+ // GETTING VERSIONS LIST AND ADDIND LINK BETWEEN VERSIONS AND PRODUCTS FOR FORM REFRESH
+ $versions = $versionsController->Version->find('all');
+ $versionsArray = array();
+ $versionsByProduct = array();
+ foreach($versions as $version) {
+ $versionsArray[$version['Version']['id']] = $version['Version']['value'];
+ $versionsByProduct[$version['Version']['id']] = $version['Version']['product'];
+ }
+
+ // SENDING DATA TO VIEW
+ $this->set(array(
+ 'productsArray' => $productsArray,
+ '_serialize' => array('productsArray')
+ ));
+ $this->set(array(
+ 'versionsArray' => $versionsArray,
+ '_serialize' => array('versionsArray')
+ ));
+ $this->set(array(
+ 'versionsByProduct' => $versionsByProduct,
+ '_serialize' => array('versionsByProduct')
+ ));
}
}
if (!$id) {
throw new NotFoundException(__('Instance applicative introuvable'));
}
-
$appliance = $this->Appliance->findById($id);
if (!$appliance) {
throw new NotFoundException(__('Instance applicative introuvable'));
$this->redirect(array('controller' => 'appliances', 'action' => 'index'));
}
}
-?>
+++ /dev/null
-<?php
- class ClientsController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
-
- public function index() {
- $clients = $this->Client->find('all');
- $this->set(array(
- 'clients' => $clients,
- '_serialize' => array('clients')
- ));
- }
-
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvais client'));
- }
-
- $client = $this->Client->findById($id);
- if (!$client) {
- throw new NotFoundException(__('Mauvais client'));
- }
- $this->set('client', $client);
- }
- }
-?>
--- /dev/null
+<?php
+ class CommandsController extends AppController {
+ public $helpers = array('Html', 'Form');
+ public $components = array('RequestHandler');
+
+ public function index() {
+ $commands = $this->Command->find('all');
+ $this->set(array(
+ 'commands' => $commands,
+ '_serialize' => array('commands')
+ ));
+ }
+
+ public function add($task_id = null) {
+ App::import('Controller', 'Tasks');
+ $tasksController = new TasksController;
+
+ // FORM IS SENT
+ if ($this->request->is('POST')) {
+ $this->Command->create();
+ $this->Command->value('value', $this->request->data['Command']['value']);
+ if ($this->Command->save($this->request->data)) {
+
+ // GETTING TASK
+ $task_id = $this->request->data['Command']['task'];
+ if(isset($task_id)) {
+ $task = $tasksController->Task->findById($task_id);
+ $this->set('task', $task);
+
+ // ADDING COMMAND TO TASK
+ $commands = array();
+ if($task['Task']['commands']) {
+ $commands = explode('|', $task['Task']['commands']);
+ }
+ $commands[] = $this->Command->id;
+ $tasksController->Task->read(null, $task_id);
+ $tasksController->Task->set('commands', implode("|", $commands));
+ $tasksController->Task->save();
+ }
+ $this->Session->setFlash(__("La commande a été enregistrée."));
+ if(isset($task_id)) {
+ $this->redirect(array('controller' => 'tasks', 'action' => 'index'));
+ } else {
+ $this->redirect(array('action' => 'index'));
+ }
+ }
+ $this->Session->setFlash(__("Enregistrement de la commande impossible."));
+
+ // FORM IS NOT SENT OR ACCESS VIA WRONG METHOD
+ } else {
+
+ // GETTING TASK IF ITS ID IS SET IN REQUEST
+ if(isset($task_id)) {
+ $task = $tasksController->Task->findById($task_id);
+ $this->set('task', $task);
+ }
+ }
+ }
+ }
+++ /dev/null
-<?php
- class ExploitantsController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
-
- public function index() {
- //$this->set('exploitants', $this->Exploitant->find('all'));
- $exploitants = $this->Exploitant->find('all');
- $this->set(array(
- 'exploitants' => $exploitants,
- '_serialize' => array('exploitants')
- ));
- }
-
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvais exploitant'));
- }
-
- $exploitant = $this->Exploitant->findById($id);
- if (!$exploitant) {
- throw new NotFoundException(__('Mauvais exploitant'));
- }
- $this->set('exploitant', $exploitant);
- }
-
- public function add() {
- if ($this->request->is('exploitant')) {
- $this->Exploitant->create();
- if ($this->Exploitant->save($this->request->data)) {
- $this->Session->setFlash(__("L'exploitant a été enregistré."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Enregistrement de l'exploitant impossible."));
- }
- }
-
- public function edit($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Exploitant introuvable'));
- }
-
- $exploitant = $this->Exploitant->findById($id);
- if (!$exploitant) {
- throw new NotFoundException(__('Exploitant introuvable'));
- }
- $this->set('exploitant', $exploitant);
-
- // Récupération des instances de l'exploitant
- $instances_id = explode('|', $this->Exploitant->value('instances'));
- App::import('Controller', 'Instances');
- $instancesController = new InstancesController;
- $instances = array();
-
- foreach ($instances_id as $instance_id) {
- $instances[] = $instancesController->Instance->findById($instance_id);
- }
-
- $this->set('instances', $instances);
-
- if ($this->request->is(array('exploitant', 'put'))) {
- $this->Exploitant->id = $id;
- if ($this->Exploitant->save($this->request->data)) {
- $this->Session->setFlash(__("L'exploitant a été mis à jour."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Mise à jour de l'exploitant impossible."));
- }
-
- if (!$this->request->data) {
- $this->request->data = $exploitant;
- }
- }
-
- public function delete($id) {
- if ($this->request->is('get')) {
- throw new MethodNotAllowedException();
- }
-
- if ($this->Exploitant->delete($id)) {
- $this->Session->setFlash(
- __("L'exploitant d'id: %s a été supprimé.", h($id))
- );
- return $this->redirect(array('action' => 'index'));
- }
- }
- }
-?>
+++ /dev/null
-<?php
- class HistoriquesController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
-
- public function index() {
- $historiques = $this->Historique->find('all');
- $this->set(array(
- 'historiques' => $historiques,
- '_serialize' => array('historiques')
- ));
- }
-
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvais historique'));
- }
-
- $historique = $this->Historique->findById($id);
- if (!$historique) {
- throw new NotFoundException(__('Mauvais historique'));
- }
- $this->set('historique', $historique);
- }
-
- public function add() {
- if ($this->request->is('historique')) {
- $this->Historique->create();
- if ($this->Historique->save($this->request->data)) {
- $this->Session->setFlash(__("L'historique a été enregistré."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Enregistrement de l'historique impossible."));
- }
- }
-
- public function edit($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Historique introuvable'));
- }
-
- // GETTING THE CHANGELOG OF THE APPLIANCE
- $this->Historique->id = $id;
- $historique = $this->Historique->findById($id);
- if (!$historique) {
- throw new NotFoundException(__('Historique introuvable'));
- }
- $this->set('historique', $historique);
-
- // GETTING ALL WARNINGS FROM THE CHANGELOG
- if($this->Historique->value('alertes')) {
- $alertes_id = explode('|', $this->Historique->value('alertes'));
- App::import('Controller', 'Alertes');
- $alertesController = new AlertesController;
- $alertes = array();
- foreach ($alertes_id as $alerte_id) {
- $alertes[] = $alertesController->Alerte->findById($alerte_id);
- }
-
- // SENDING DATA TO VIEW
- $this->set(array(
- 'alertes' => $alertes,
- '_serialize' => array('alertes')
- ));
- }
-
- if ($this->request->is(array('historique', 'put'))) {
- $this->Historique->id = $id;
- if ($this->Historique->save($this->request->data)) {
- $this->Session->setFlash(__("L'historique a été mis à jour."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Mise à jour de l'historique impossible."));
- }
-
- if (!$this->request->data) {
- $this->request->data = $historique;
- }
- }
-
- public function delete($id) {
- /*if ($this->request->is('get')) {
- throw new MethodNotAllowedException();
- }
- */
- if ($this->Historique->delete($id)) {
- $this->Session->setFlash(
- __("L'historique d'id: %s a été supprimé.", h($id))
- );
- return $this->redirect(array('action' => 'index'));
- }
- }
-
- public function actionAlerte($id = null, $alerte_id = null, $valider = false, $ref_install = null) {
-
- // GETTING CHANGELOG
- $this->Historique->id = $id;
- $historique = $this->Historique->findById($id);
- if (!$historique) {
- throw new NotFoundException(__('Historique introuvable'));
- }
-
- // GETTING WARNINGS OF CHANGELOG
- App::import('Controller', 'Alertes');
- $alertesController = new AlertesController;
- $alerte = $alertesController->Alerte->findById($alerte_id);
- if (!$alerte) {
- throw new NotFoundException(__('Alerte introuvable'));
- }
-
- // ADDING VERSION AND DATE OF WARNING TO CHANGELOG
- $version = $alerte['Alerte']['version'];
- $date = $alerte['Alerte']['creation'];
- switch($alerte['Alerte']['nature']) {
- case 'version':
- if($this->Historique->value('versions')) {
- $versions = explode('|', $this->Historique->value('versions'));
- } else {
- $versions = array();
- }
- $versions[] = $version.";".$date;
- $this->Historique->value('versions', implode('|', $versions));
- break;
-
- case 'creation':
- $creation = $alerte['Alerte']['creation'];
- // TO-DO : CHANGE APPLIANCE STATE ?
- break;
-
- default:
- break;
-
- }
-
- // IN CASE OF VALIDATION => OPPORTUNITY CREATION IN SUGAR THROUGH ALLO SERVEUR CONNECTOR
- if($valider) {
- $reference = str_replace("SLASH", "\\/", $ref_install);
- $url = 'http://allo_serveur/?action=create_fiche_installation&nom='.$reference;
- $options = array("http" => array("method" => "GET"));
- $context = stream_context_create($options);
- $reponse = file_get_contents($url, false, $context);
- if(isset($reponse)) {
- // USE THE ID SENT ?
- }
- }
-
- // DELETING WARNING
- $alertesController->Alerte->delete($alerte_id);
- $alertes_id = explode('|', $this->Historique->value('alertes'));
- if(($key = array_search($alerte_id, $alertes_id)) !== false) {
- unset($alertes_id[$key]);
- }
- $this->Historique->value('alertes', implode('|', $alertes_id));
-
- // REDIRECTION TO APPLIANCES PAGE
- return $this->redirect(array('controller' => 'instances', 'action' => 'index'));
- }
- }
-?>
+++ /dev/null
-<?php
- class InstancesController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
- public $uses = array('Instance', 'Historique');
-
- public function index() {
-
- // GETTING CONTROLLERS
- App::import('Controller', 'Alertes');
- $alertesController = new AlertesController;
- App::import('Controller', 'Historiques');
- $historiquesController = new HistoriquesController;
- App::import('Controller', 'Clients');
- $clientsController = new ClientsController;
-
- // GETTING ALL APPLIANCES
- $instances = $this->Instance->find('all');
-
- // GETTING ALL CLIENTS
- $totalClients = $clientsController->Client->find('all');
-
- // GETTING INFORMATION FOR EACH APPLIANCE
- $historiques = array();
- $totalAlertes = array();
- $clients = array();
- $last_updates = array();
- foreach($instances as $instance) {
- // GETTING CHANGELOG
- $historique = $historiquesController->Historique->findById($instance['Instance']['historique']);
- if ($historique) {
- // GETTING WARNINGS OF CHANGELOG
- if($historique['Historique']['alertes']) {
- $alertes_id = explode('|', $historique['Historique']['alertes']);
- $alertes = array();
- foreach ($alertes_id as $alerte_id) {
- $alertes[] = $alertesController->Alerte->findById($alerte_id);
- }
- // ADDING WARNING TO LIST
- $totalAlertes[$historique['Historique']['id']] = $alertes;
- }
- // GETTING LAST VERSION DECLARED OF CHANGELOG
- if($historique['Historique']['versions']) {
- $infos_versions = explode('|', $historique['Historique']['versions']);
- $last_update = $historique['Historique']['installation'];
- foreach ($infos_versions as $infos_version) {
- $infos_version_array = explode(';', $infos_version);
- if(isset($infos_version_array[1])) {
- $update = $infos_version_array[1];
- if($update > $last_update) {
- $last_update = $update;
- }
- }
- }
- // ADDING UPDATE DATE TO LIST
- $last_updates[$instance['Instance']['id']] = $last_update;
- }
- // ADDING CHANGELOG TO LIST
- $historiques[$instance['Instance']['id']] = $historique;
- }
-
- // GETTING CUSTOMER
- $refInstanceSansProduit = explode("/",$instance['Instance']['reference']);
- $idAPClient = substr($refInstanceSansProduit[1],0,-11);
- foreach($totalClients as $client) {
- // ADDING CUSTOMER TO LIST
- if($client['Client']['identifiant_AP'] === $idAPClient) {
- $clients[$instance['Instance']['id']] = $client;
- }
- }
- }
-
- // SENDING DATA TO VIEW
- $this->set(array(
- 'instances' => $instances,
- '_serialize' => array('instances')
- ));
- $this->set(array(
- 'historiques' => $historiques,
- '_serialize' => array('historiques')
- ));
- $this->set(array(
- 'clients' => $clients,
- '_serialize' => array('clients')
- ));
- $this->set(array(
- 'totalAlertes' => $totalAlertes,
- '_serialize' => array('totalAlertes')
- ));
- $this->set(array(
- 'last_updates' => $last_updates,
- '_serialize' => array('last_updates')
- ));
- }
-
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvaise instance'));
- }
-
- $instance = $this->Instance->findById($id);
- if (!$instance) {
- throw new NotFoundException(__('Mauvaise instance'));
- }
- $this->set('instance', $instance);
- }
-
- public function add() {
- if ($this->request->is('POST')) {
- $this->Instance->create();
- if ($this->Instance->save($this->request->data)) {
- $this->Session->setFlash(__("L'instance a été enregistrée."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Enregistrement de l'instance impossible."));
- }
- }
-
- public function edit($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Instance introuvable'));
- }
-
- $instance = $this->Instance->findById($id);
- if (!$instance) {
- throw new NotFoundException(__('Instance introuvable'));
- }
- $this->Instance->id = $id;
-
- // GETTING PRODUCT CONTROLLER AND PRODUCTS
- App::import('Controller', 'Produits');
- $produitsController = new ProduitsController;
- $produits = $produitsController->Produit->find('all');
-
- // GETTING VERSION CONTROLLER AND VERSIONS
- App::import('Controller', 'Versions');
- $versionsController = new VersionsController;
- $versions = $versionsController->Version->find('all');
-
- // GETTING PRODUCT ID FOR THIS APPLIANCE
- foreach($produits as $produit) {
- if($produit['Produit']['nom'] == $this->Instance->value('nom')) {
- $idProduit = $produit['Produit']['id'];
- break;
- }
- }
-
- // GETTING ALL AVAILABLE VERSIONS FOR THIS PRODUCT
- $versionsPossibles = array();
- foreach($versions as $version) {
- if($version['Version']['produit'] == $idProduit) {
- $versionsPossibles[] = $version['Version']['valeur'];
- }
- }
-
- // SENDING DATA TO VIEW
- $this->set(array(
- 'versionsPossibles' => $versionsPossibles,
- '_serialize' => array('versionsPossibles')
- ));
-
- // IN CASE OF A PUT REQUEST
- if ($this->request->is(array('instance', 'put'))) {
-
- // GETTING CHANGELOG
- $historique = $this->Historique->findById($this->Instance->value('historique'));
- if (!$historique) {
- throw new NotFoundException(__('Historique introuvable'));
- }
- $this->Historique->id = $this->Instance->value('historique');
-
- // GETTING VERSIONS OF APPLIANCE
- if($this->Historique->value('versions')) {
- $historiqueVersions = explode('|', $this->Historique->value('versions'));
- } else {
- $historiqueVersions = array();
- }
-
- // SAVING APPLIANCE
- if ($this->Instance->save($this->request->data)) {
-
- // GETTING VERSION TO ADD TO CHANGELOG
- foreach($versionsPossibles as $versionPossible) {
- if($versionPossible['Version']['valeur'] == $this->Instance->value('version')) {
- $idVersion = $versionPossible['Version']['id'];
- break;
- }
- }
-
- // CHANGING AND SAVING CHANGELOG
- $historiqueVersions[] = $idVersion.";".date('Y-m-d');
- $this->Historique->value('versions', implode('|', $historiqueVersions));
- $this->Historique->save();
- $this->Session->setFlash(__("L'instance a été mise à jour."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Mise à jour de l'instance impossible."));
- }
-
- if (!$this->request->data) {
- $this->request->data = $instance;
- }
- }
-
- public function delete($id) {
- /*if ($this->request->is('get')) {
- throw new MethodNotAllowedException();
- }*/
- $instance = $this->Instance->findById($id);
- if (!$instance) {
- throw new NotFoundException(__('Instance introuvable'));
- }
- if ($this->Instance->delete($id)) {
- $this->Session->setFlash(
- __("L'instance %s a été supprimée.", h($instance['Instance']['reference']))
- );
- return $this->redirect(array('action' => 'index'));
- }
- }
-
- // REST API
-
- /*public function rest_get_all() {
- $instances = $this->Instance->find('all');
- $this->set(array(
- 'instances' => $instances,
- '_serialize' => array('instances')
- ));
- }
-
- public function rest_get($reference) {
- $instance = $this->Instance->findByReference($reference);
- $this->set(array(
- 'instance' => $instance,
- '_serialize' => array('instance')
- ));
- }
-
- public function rest_create() {
- if ($this->Instance->save($this->request->data)) {
- $message = array(
- 'text' => __('Saved'),
- 'type' => 'success'
- );
- } else {
- $message = array(
- 'text' => __('Error'),
- 'type' => 'error'
- );
- }
- $this->set(array(
- 'message' => $message,
- '_serialize' => array('message')
- ));
- }
-
- public function rest_update($reference) {
- $this->Instance->reference = $reference;
- if ($this->Instance->save($this->request->data)) {
- $message = array(
- 'text' => __('Saved'),
- 'type' => 'success'
- );
- } else {
- $message = array(
- 'text' => __('Error'),
- 'type' => 'error'
- );
- }
- $this->set(array(
- 'message' => $message,
- '_serialize' => array('message')
- ));
- }
-
- public function rest_delete($reference) {
- if ($this->Instance->delete($reference)) {
- $message = array(
- 'text' => __('Deleted'),
- 'type' => 'success'
- );
- } else {
- $message = array(
- 'text' => __('Error'),
- 'type' => 'error'
- );
- }
- $this->set(array(
- 'message' => $message,
- '_serialize' => array('message')
- ));
- }*/
- }
-?>
--- /dev/null
+<?php
+ class PatchesController extends AppController {
+ public $helpers = array('Html', 'Form');
+ public $components = array('RequestHandler');
+
+ public function index() {
+
+ // GETTING TASK CONTROLLER
+ App::import('Controller', 'Tasks');
+ $tasksController = new TasksController;
+
+ // GETTING ALL PATCHES
+ $patches = $this->Patch->find('all');
+
+ // GETTING TASKS FOR EACH PATCH
+ $tasksArray = array();
+ foreach($patches as $patch) {
+
+ // GETTING TASKS ID
+ if($patch['Patch']['tasks']) {
+ $tasks_id = explode("|", $patch['Patch']['tasks']);
+ $tasks = array();
+ foreach($tasks_id as $task_id) {
+ $tasks[] = $tasksController->Task->findById($task_id);
+ }
+
+ // ADDIND TASKS TO ARRAY
+ $tasksArray[$patch['Patch']['id']] = $tasks;
+ }
+ }
+
+ // SENDING DATA TO VIEW
+ $this->set(array(
+ 'tasksArray' => $tasksArray,
+ '_serialize' => array('tasksArray')
+ ));
+ $this->set(array(
+ 'patches' => $patches,
+ '_serialize' => array('patches')
+ ));
+ }
+
+ public function add() {
+ if ($this->request->is('POST')) {
+ $this->Patch->create();
+ if ($this->Patch->save($this->request->data)) {
+ $this->Session->setFlash(__("Le patch a été enregistré."));
+ $this->redirect(array('action' => 'index'));
+ }
+ $this->Session->setFlash(__("Enregistrement du patch impossible."));
+ }
+ }
+
+ public function order_task($id = null, $order = null, $direction = null) {
+ if (!$id) {
+ throw new NotFoundException(__('Patch introuvable'));
+ }
+ $patch = $this->Patch->findById($id);
+ if (!$patch) {
+ throw new NotFoundException(__('Patch introuvable'));
+ }
+ $this->Patch->id = $id;
+
+ // GETTING TASKS ID
+ $tasks_id = explode("|", $patch['Patch']['tasks']);
+
+ // CHANGING PLACES
+ $newTasks_id = array();
+ $key = $order-1;
+ if($direction == "up") {
+ $newkey = $key-1;
+ } else if($direction == "down") {
+ $newkey = $order;
+ }
+ foreach($tasks_id as $task_id) {
+ $newTasks_id[] = $task_id;
+ }
+ if(isset($newkey)) {
+ $newTasks_id[$newkey] = $tasks_id[$key];
+ $newTasks_id[$key] = $tasks_id[$newkey];
+ }
+
+ // SAVING CHANGES
+ $this->Patch->value('tasks', implode("|", $newTasks_id));
+ $this->Patch->save();
+ $this->redirect(array('action' => 'index'));
+ }
+ }
+++ /dev/null
-<?php
- class ProduitsController extends AppController {
- public $helpers = array('Html', 'Form');
- public $components = array('RequestHandler');
-
- public function index() {
- // GETTING ALL PRODUCTS
- $produits = $this->Produit->find('all');
-
- // GETTING VERSION CONTROLLER AND ALL VERSIONS
- App::import('Controller', 'Versions');
- $versionsController = new VersionsController;
- $versions = $versionsController->Version->find('all');
-
- // SENDING DATA TO VIEW
- $this->set(array(
- 'produits' => $produits,
- '_serialize' => array('produits')
- ));
- $this->set(array(
- 'versions' => $versions,
- '_serialize' => array('versions')
- ));
- }
-
- public function view($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Mauvais produit'));
- }
-
- $produit = $this->Produit->findById($id);
- if (!$produit) {
- throw new NotFoundException(__('Mauvais produit'));
- }
- $this->set('produit', $produit);
- }
-
- public function add() {
- if ($this->request->is('POST')) {
- $this->Produit->create();
- if ($this->Produit->save($this->request->data)) {
- $this->Session->setFlash(__("Le produit a été enregistré."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Enregistrement du produit impossible."));
- }
- }
-
- public function edit($id = null) {
- if (!$id) {
- throw new NotFoundException(__('Produit introuvable'));
- }
-
- $produit = $this->Produit->findById($id);
- if (!$produit) {
- throw new NotFoundException(__('Produit introuvable'));
- }
-
- if ($this->request->is(array('produit', 'put'))) {
- $this->Produit->id = $id;
- if ($this->Produit->save($this->request->data)) {
- $this->Session->setFlash(__("La produit a été mis à jour."));
- return $this->redirect(array('action' => 'index'));
- }
- $this->Session->setFlash(__("Mise à jour du produit impossible."));
- }
-
- if (!$this->request->data) {
- $this->request->data = $produit;
- }
- }
-
- public function delete($id) {
- if ($this->request->is('get')) {
- throw new MethodNotAllowedException();
- }
-
- if ($this->Produit->delete($id)) {
- $this->Session->setFlash(
- __("La produit d'id: %s a été supprimé.", h($id))
- );
- return $this->redirect(array('action' => 'index'));
- }
- }
- }
-?>
--- /dev/null
+<?php
+ class TasksController extends AppController {
+ public $helpers = array('Html', 'Form');
+ public $components = array('RequestHandler');
+
+ public function index() {
+ $tasks = $this->Task->find('all');
+ $this->set(array(
+ 'tasks' => $tasks,
+ '_serialize' => array('tasks')
+ ));
+ }
+
+ public function add($patch_id = null) {
+ App::import('Controller', 'Patches');
+ $patchesController = new PatchesController;
+
+ // FORM IS SENT
+ if ($this->request->is('POST')) {
+ $this->Task->create();
+ $this->Task->value('name', $this->request->data['Task']['name']);
+ if ($this->Task->save($this->request->data)) {
+
+ // GETTING PATCH
+ $patch_id = $this->request->data['Task']['patch'];
+ if(isset($patch_id)) {
+ $patch = $patchesController->Patch->findById($patch_id);
+ $this->set('patch', $patch);
+
+ // ADDING TASK TO PATCH
+ $tasks = array();
+ if($patch['Patch']['tasks']) {
+ $tasks = explode('|', $patch['Patch']['tasks']);
+ }
+ $tasks[] = $this->Task->id;
+ $patchesController->Patch->read(null, $patch_id);
+ $patchesController->Patch->set('tasks', implode("|", $tasks));
+ $patchesController->Patch->save();
+ }
+ $this->Session->setFlash(__("La tâche a été enregistrée."));
+ if(isset($patch_id)) {
+ $this->redirect(array('controller' => 'patches', 'action' => 'index'));
+ } else {
+ $this->redirect(array('action' => 'index'));
+ }
+ }
+ $this->Session->setFlash(__("Enregistrement de la tâche impossible."));
+
+ // FORM IS NOT SENT OR ACCESS VIA WRONG METHOD
+ } else {
+
+ // GETTING PATCH IF ITS ID IS SET IN REQUEST
+ if(isset($patch_id)) {
+ $patch = $patchesController->Patch->findById($patch_id);
+ $this->set('patch', $patch);
+ }
+ }
+ }
+ }
public function add($product_id = null) {
if ($this->request->is('POST')) {
$this->Version->create();
- $this->Version->value('value', $_POST['value']);
- $this->Version->value('nature', $_POST['nature']);
- $this->Version->value('product', $_POST['product']);
+ $this->Version->value('value', $this->request->data['Version']['value']);
+ $this->Version->value('nature', $this->request->data['Version']['nature']);
+ $this->Version->value('product', $this->request->data['Version']['product']);
if ($this->Version->save($this->request->data)) {
$this->Session->setFlash(__("La version a été enregistrée."));
$this->redirect(array('action' => 'index'));
+++ /dev/null
-<?php
- class Administrateur extends AppModel {
- public $validate = array(
- 'identifiant_AP' => array(
- 'rule' => 'notEmpty'
- )
- );
-
- public function value($field, $value = null) {
- if(func_num_args() === 1){
- $result = $this->field($field);
- if($result){
- return $result;
- }
- } else {
- if($this->saveField($field, $value)) {
- return true;
- }
- }
- return false;
- }
- }
-?>
+++ /dev/null
-<?php
- class Alerte extends AppModel {
- /*public $validate = array(
- 'reference' => array(
- 'rule' => 'notEmpty'
- )
- );*/
-
- public function value($field, $value = null) {
- if(func_num_args() === 1){
- $result = $this->field($field);
- if($result){
- return $result;
- }
- } else {
- if($this->saveField($field, $value)) {
- return true;
- }
- }
- return false;
- }
- }
-?>
+++ /dev/null
-<?php
- class Client extends AppModel {
- public $validate = array(
- 'identifiant_AP' => array(
- 'rule' => 'notEmpty'
- )
- );
-
- public function value($field, $value = null) {
- if(func_num_args() === 1){
- $result = $this->field($field);
- if($result){
- return $result;
- }
- } else {
- if($this->saveField($field, $value)) {
- return true;
- }
- }
- return false;
- }
- }
-?>
<?php
- class Produit extends AppModel {
+ class Command extends AppModel {
public $validate = array(
- /*'fqdn' => array(
- 'rule' => 'notEmpty'
- ),*/
- /*'nom' => array(
- 'rule' => 'notEmpty'
- ),*/
- 'valeur' => array(
+ 'value' => array(
'rule' => 'notEmpty'
)
);
return false;
}
}
-?>
+++ /dev/null
-<?php
- class Exploitant extends AppModel {
- public $validate = array(
- 'reference' => array(
- 'rule' => 'notEmpty'
- )
- );
-
- public function value($field, $value = null) {
- if(func_num_args() === 1){
- $result = $this->field($field);
- if($result){
- return $result;
- }
- } else {
- if($this->saveField($field, $value)) {
- return true;
- }
- }
- return false;
- }
- }
-?>
+++ /dev/null
-<?php
- class Historique extends AppModel {
- public $validate = array(
- 'installation' => array(
- 'rule' => 'notEmpty'
- )
- );
-
- public function value($field, $value = null) {
- if(func_num_args() === 1){
- $result = $this->field($field);
- if($result){
- return $result;
- }
- } else {
- if($this->saveField($field, $value)) {
- return true;
- }
- }
- return false;
- }
- }
-?>
<?php
- class Instance extends AppModel {
+ class Patch extends AppModel {
public $validate = array(
- /*'fqdn' => array(
- 'rule' => 'notEmpty'
- ),*/
- /*'nom' => array(
- 'rule' => 'notEmpty'
- ),*/
'version' => array(
'rule' => 'notEmpty'
)
return false;
}
}
-?>
--- /dev/null
+<?php
+ class Task extends AppModel {
+ public $validate = array(
+ 'name' => array(
+ 'rule' => 'notEmpty'
+ )
+ );
+
+ public function value($field, $value = null) {
+ if(func_num_args() === 1){
+ $result = $this->field($field);
+ if($result){
+ return $result;
+ }
+ } else {
+ if($this->saveField($field, $value)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+++ /dev/null
-<h1>Liste des administrateurs</h1>
-<table>
- <tr>
- <th>Login</th>
- </tr>
-
- <?php foreach ($administrateurs as $administrateur): ?>
- <tr>
- <td><?php echo $administrateur['Administrateur']['login'] ?></td>
- </tr>
- <?php endforeach; ?>
- <?php unset($administrateur); ?>
-</table>
+++ /dev/null
-<h1>Merci de vous authentifier en tant qu'administrateur</h1>
-<?php
-echo $this->Form->create('Administrateur');
-echo $this->Form->input('login', array('name' => 'login'));
-echo $this->Form->input('pass', array('name' => 'pass'));
-echo $this->Form->end("Login");
-?>
+++ /dev/null
-<h1>Enregistrement d'un nouvel administrateur</h1>
-<?php
-echo $this->Form->create('Administrateur');
-echo $this->Form->input('login', array('name' => 'login'));
-echo $this->Form->input('pass', array('name' => 'pass'));
-echo $this->Form->end("Login");
-?>
+++ /dev/null
-<h1>Ajout d'un alerte</h1>
-<?php
- echo $this->Form->create('Alerte');
- echo $this->Form->end("Enregistrer l'alerte");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Editer l'alerte</h1>
-<?php
- echo $this->Form->create('Alerte');
- echo $this->Form->input('id', array('type' => 'hidden'));
- echo $this->Form->end("Mettre à jour l'alerte");
-?>
\ No newline at end of file
+++ /dev/null
-<table>
- <tr>
- <th>Date de d'émission</th>
- <th>Type</th>
- <th>Message</th>
- </tr>
-
- <?php foreach ($alertes as $alerte): ?>
- <tr>
- <td><?php echo $alerte['Alerte']['creation']; ?></td>
- <td><?php echo $alerte['Alerte']['nature']; ?></td>
- <td><?php echo $alerte['Alerte']['message']; ?></td>
- </tr>
- <?php endforeach; ?>
- <?php unset($alerte); ?>
-</table>
+++ /dev/null
-<h1>Émission le : <?php echo h($alerte['Alerte']['création']); ?></h1>
-
-<p>Alertes : <?php echo h($alerte['Alerte']['alertes']); ?></p>
-
<?php
echo $this->Form->create('Appliance');
echo $this->Form->input('reference', array('label' => "Référence d'instance"));
-// TO-DO : LINK TO THE RIGHT PRODUCT AND CHANGE VERSIONS ACCORDINGLY
+// TO-DO : CHANGE VERSIONS CHOICE WITCH PRODUCT CHANGE
+if(isset($productsArray)) {
+ echo $this->Form->input('product', array('label' => "Produit", 'options' => $productsArray));
+}
+if(isset($versionsArray)) {
+ echo $this->Form->input('version', array('label' => "Version", 'options' => $versionsArray));
+}
+if(isset($versionsByProduct)) {
+ echo "<div id='versionsByProduct' style='display: none'>";
+ foreach($versionsByProduct as $versionByProduct) {
+ echo "<input type='hidden' value='".$versionByProduct."'>";
+ }
+ echo "</div>";
+}
echo $this->Form->input('internal_fqdn', array('label' => "FQDN interne"));
echo $this->Form->input('external_fqdn', array('label' => "FQDN externe"));
-/*echo $this->Form->input('manager', array('label' => "Exploitant"));*/
echo $this->Form->end("Enregistrer l'instance applicative");
-?>
\ No newline at end of file
+?>
+
+<script>
+ var productElement = document.getElementById("ApplianceProduct");
+ var versionElement = document.getElementById("ApplianceVersion");
+ var versionsByProductElement = document.getElementById("versionsByProduct");
+ productElement.onclick = function() {
+ var productId = productElement.value,
+ versionElementChildNodes = versionElement.childNodes,
+ versionByProductElementChildNodes = versionsByProductElement.childNodes;
+
+ // ADDING NEW ONES
+ for(var i = 0 ; i < versionByProductElementChildNodes.length ; i++) {
+ if(i in versionElementChildNodes && versionElementChildNodes[i] != undefined && versionElementChildNodes[i] != null) {
+ // console.log(versionElementChildNodes[5].innerHTML);
+ if(versionByProductElementChildNodes[i].value == productId) {
+ versionElementChildNodes[i*2+1].style.visibility = "visible";
+ versionElementChildNodes[i*2+1].style.display = "inline";
+ } else {
+ versionElementChildNodes[i*2+1].style.visibility = "hidden";
+ versionElementChildNodes[i*2+1].style.display = "none";
+ }
+ }
+ }
+ };
+</script>
\ No newline at end of file
echo $this->Form->input('internal_fqdn', array('label' => "FQDN interne"));
echo $this->Form->input('external_fqdn', array('label' => "FQDN externe"));
echo $this->Form->input('os', array('label' => "Système"));
-/*echo $this->Form->input('manager', array('label' => "Exploitant"));*/
echo $this->Form->input('maintained', array('legend' => "Maintien de l'instance", 'type' => 'radio', 'options' => array('0' => 'Désactivé', '1' => 'Activé')));
echo $this->Form->input('disc_infos', array('label' => "Information disques"));
echo $this->Form->input('id', array('type' => 'hidden'));
// DISPLAYING ERROR MESSAGE IF NO CHANGELOG IS FOUND
} else { ?>
- <td>Historique pour cette instance applicative inexistant ou introuvable</td>
+ <!--<td>Historique pour cette instance applicative inexistant ou introuvable</td>-->
<td>
<?php
var deleteAppliance = function (appliance_id, changelog_id) {
var confirmAction = confirm("Etes-vous certain ?");
if (confirmAction) {
+ if(!changelog_id > 0) {
+ location.href = "/appliances/delete/"+appliance_id;
+ }
var isChangelogKept = confirm("Conserver l'historique de l'instance applicative ?");
if(isChangelogKept) {
alert('historique conservé');
+++ /dev/null
-<h1>Liste de clients</h1>
-<button onclick="synchroniserInfosClients();">Synchronisation</button>
-<table>
- <tr>
- <th>Nom</th>
- <th>Identifiant AP</th>
- </tr>
-
- <?php foreach ($clients as $client): ?>
- <tr>
- <td><?php echo $client['Client']['nom'] ?></td>
- <td><?php echo $client['Client']['identifiant_AP']; ?></td>
- </tr>
- <?php endforeach; ?>
- <?php unset($client); ?>
-</table>
-
-<script>
- var synchroniserInfosClients = function () {
- $.ajax({
- url: "http://allo_serveur/?action=synchroniser_infos_clients",
- beforeSend: function( xhr ) {
- xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
- }
- })
- .done(function( data ) {
- if ( console && console.log ) {
- //console.log( "Sample of data:", data.slice( 0, 100 ) );
- }
- location.href = "/clients";
- });
- };
-</script>
\ No newline at end of file
+++ /dev/null
-<h1>Nom : <?php echo h($exploitant['Exploitant']['nom']); ?></h1>
-
-<p>Reference : <?php echo h($exploitant['Exploitant']['reference']); ?></p>
-
-<p>Instances : <?php echo h($exploitant['Exploitant']['exploitants']); ?></p>
--- /dev/null
+<h1>Ajout d'une commande</h1>
+<?php
+echo $this->Form->create('Command');
+echo $this->Form->input('value', array('label' => "Valeur"));
+if(isset($task)) {
+ echo 'Tâche : '.$task['Task']['name'];
+ echo $this->Form->input('task', array('label' => 'Task', 'type' => 'hidden', 'value' => $task['Task']['id']));
+}
+echo $this->Form->end("Enregistrer la commande");
+?>
\ No newline at end of file
--- /dev/null
+<h1>Liste des commandes</h1>
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouvelle commande',
+ array('controller' => 'commands', 'action' => 'add')
+ ); ?>
+</h1>
+<table>
+ <tr>
+ <th>Valeur</th>
+ </tr>
+
+ <?php if(isset($commands)) { foreach ($commands as $command): ?>
+ <tr>
+ <td><?php echo $command['Command']['value'] ?></td>
+ </tr>
+ <?php endforeach; ?>
+ <?php unset($command); } ?>
+</table>
\ No newline at end of file
+++ /dev/null
-<h1>Ajout d'un exploitant</h1>
-<?php
- echo $this->Form->create('Exploitant');
- echo $this->Form->input('nom');
- echo $this->Form->input('reference');
- //echo $this->Form->input('instances');
- echo $this->Form->end("Enregistrer l'exploitant");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Editer l'exploitant</h1>
-<?php
- echo $this->Form->create('Exploitant');
- echo $this->Form->input('nom');
- echo $this->Form->input('reference');
- //echo $this->Form->input('instances');
- echo "Instances d'applications liées :";
- foreach ($instances as $instance) {
- ?><p><?php
- echo $this->Html->link(
- $instance['Instance']['reference'],
- array('controller' => 'instances', 'action' => 'edit', $instance['Instance']['id'])
- );
- ?></p><?php
- }
- echo $this->Form->input('id', array('type' => 'hidden'));
- echo $this->Form->end("Mettre à jour l'exploitant");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Liste d'exploitants</h1>
-<table>
- <tr>
- <th>Nom</th>
- <th>Référence</th>
- </tr>
-
- <?php foreach ($exploitants as $exploitant): ?>
- <tr>
- <td>
- <?php echo $this->Html->link(
- $exploitant['Exploitant']['nom'],
- array('controller' => 'exploitants', 'action' => 'edit', $exploitant['Exploitant']['id'])
- );
- ?>
- </td>
- <td><?php echo $exploitant['Exploitant']['reference']; ?></td>
- <td>
- <?php
- echo $this->Form->postLink(
- 'Supprimer',
- array('action' => 'delete', $exploitant['Exploitant']['id']),
- array('confirm' => 'Etes-vous certain ?')
- );
- ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php unset($exploitant); ?>
- <?php echo $this->Html->link(
- 'Ajouter un exploitant',
- array('controller' => 'exploitants', 'action' => 'add')
- ); ?>
-</table>
+++ /dev/null
-<h1>Nom : <?php echo h($exploitant['Exploitant']['nom']); ?></h1>
-
-<p>Reference : <?php echo h($exploitant['Exploitant']['reference']); ?></p>
-
-<p>Instances : <?php echo h($exploitant['Exploitant']['exploitants']); ?></p>
+++ /dev/null
-<h1>Ajout d'un historique</h1>
-<?php
- echo $this->Form->create('Historique');
- echo $this->Form->input('installation');
- echo $this->Form->end("Enregistrer l'historique");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Editer l'historique</h1>
-<?php
- echo $this->Form->create('Historique');
- echo $this->Form->input('installation');
- if(isset($alertes)) {
- echo "Alertes :";
-?>
-<table>
- <tr>
- <th>Date</th>
- <th>Version</th>
- <th>Type</th>
- <!--<th>Message</th>-->
- <th>Actions</th>
- </tr>
- <?php foreach ($alertes as $alerte) { ?>
- <tr>
- <td><?php echo $alerte['Alerte']['creation']; ?></td>
- <td><?php echo $alerte['Alerte']['version']; ?></td>
- <td><?php echo $alerte['Alerte']['nature']; ?></td>
- <!--<td><?php /*echo $alerte['Alerte']['message'];*/ ?></td>-->
- <td>
- <?php
- echo $this->Html->link(
- 'Valider',
- array('controller' => 'historiques', 'action' => 'validerAlerte', $historique['Historique']['id'], $alerte['Alerte']['id'])
- )
- . " - " .
- $this->Html->link(
- 'Refuser',
- array('controller' => 'historiques', 'action' => 'refuserAlerte', $historique['Historique']['id'], $alerte['Alerte']['id'])
- );
- ?>
- </td>
- </tr>
-<?php } ?>
-</table>
-<?php
- }
- echo $this->Form->input('id', array('type' => 'hidden'));
- echo $this->Form->end("Mettre à jour l'historique");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Liste d'historiques</h1>
-<table>
- <tr>
- <th>Date d'installation</th>
- </tr>
-
- <?php foreach ($historiques as $historique): ?>
- <tr>
- <td>
- <?php echo $this->Html->link(
- $historique['Historique']['installation'],
- array('controller' => 'historiques', 'action' => 'edit', $historique['Historique']['id'])
- );
- ?>
- </td>
- <td>
- <?php
- echo $this->Form->postLink(
- 'Supprimer',
- array('action' => 'delete', $historique['Historique']['id']),
- array('confirm' => 'Etes-vous certain ?')
- );
- ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php unset($historique); ?>
- <?php echo $this->Html->link(
- 'Ajouter un historique',
- array('controller' => 'historiques', 'action' => 'add')
- ); ?>
-</table>
+++ /dev/null
-<h1>Installation : <?php echo h($historique['Historique']['installation']); ?></h1>
-
-<p>Alertes : <?php echo h($historique['Historique']['alertes']); ?></p>
-
+++ /dev/null
-<h1>Ajout d'une instance</h1>
-<?php
-echo $this->Form->create('Instance');
-echo $this->Form->input('nom');
-echo $this->Form->input('version');
-echo $this->Form->input('reference');
-echo $this->Form->input('exploitant');
-echo $this->Form->input('fqdn_interne');
-echo $this->Form->input('fqdn_externe');
-echo $this->Form->input('systeme');
-echo $this->Form->input('uid');
-echo $this->Form->input('historique');
-echo $this->Form->input('maintenu');
-echo $this->Form->end("Enregistrer l'instance");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Editer l'instance</h1>
-<?php
-echo $this->Form->create('Instance');
-echo $this->Form->input('nom');
-echo $this->Form->input('reference');
-echo $this->Form->input('exploitant');
-echo $this->Form->input('version', array('options' => $versionsPossibles));
-echo $this->Form->input('fqdn_interne');
-echo $this->Form->input('maintenu', array('type' => 'radio', 'options' => array('0' => 'Faux', '1' => 'Vrai')));
-//echo $this->Form->input('fqdn_externe');
-//echo $this->Form->input('systeme');
-//echo $this->Form->input('uid');
-echo $this->Form->input('id', array('type' => 'hidden'));
-echo $this->Form->end("Mettre à jour l'instance");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>
- <?php echo $this->Html->link(
- 'Nouvelle instance',
- array('controller' => 'instances', 'action' => 'add')
-); ?>
-</h1>
-<button onclick="checkInfosInstances();">Vérifier ces informations avec Sugar</button>
-<table>
- <tr>
- <th>Référence fiche d'installation</th>
- <th>Client</th>
- <th>Produit</th>
- <th>Version déclarée</th>
- <th>Canal</th>
- <?php if(isset($totalAlertes) && count($totalAlertes) > 0) { ?>
- <th>Alertes</th>
- <?php } ?>
- <th>Actions</th>
- </tr>
-
- <?php foreach ($instances as $instance): ?>
- <tr>
- <td><?php echo $instance['Instance']['reference']; ?></td>
-
- <?php if(array_key_exists($instance['Instance']['id'], $clients)) {
- $client = $clients[$instance['Instance']['id']]; ?>
- <td><?php echo $client['Client']['identifiant_AP']; ?></td>
- <?php } else { ?>
- <td>Client pour cette instance inexistant ou introuvable</td>
- <?php } ?>
-
- <td><?php echo $instance['Instance']['nom']; ?></td>
-
- <td><?php
- if(array_key_exists($instance['Instance']['id'], $last_updates)) {
- $last_update = $last_updates[$instance['Instance']['id']];
- echo $instance['Instance']['version']." le ".$last_update;
- } else {
- echo $instance['Instance']['version'];
- }
-
- ?>
- </td>
-
- <td><?php echo strtoupper($instance['Instance']['canal']); ?></td>
-
- <?php if(array_key_exists($instance['Instance']['id'], $historiques)) {
- $historique = $historiques[$instance['Instance']['id']];
- if(isset($totalAlertes) && count($totalAlertes) > 0) {
- ?>
- <td>
- <table>
- <tr>
- <?php if(array_key_exists($historique['Historique']['id'], $totalAlertes)) { ?>
- <th>Message</th>
- <th>Actions</th>
- <?php } ?>
- </tr>
- <?php if(array_key_exists($historique['Historique']['id'], $totalAlertes)) { ?>
- <?php foreach ($totalAlertes[$historiques[$instance['Instance']['id']]['Historique']['id']] as $alerte): ?>
-
- <tr>
- <td>
- <?php echo $alerte['Alerte']['message'] ?>
- </td>
- <td>
- <?php
- $reference = str_replace("/", "SLASH", $instance['Instance']['reference']);
- echo $this->Html->link(
- $this->Html->image('validate.png', array('class' => 'button')),
- array('controller' => 'historiques', 'action' => 'actionAlerte', $historique['Historique']['id'], $alerte['Alerte']['id'], true, $reference),
- array('escape' => false)
- )
- .' '.
- $this->Html->link(
- $this->Html->image('delete.png', array('class' => 'button')), '#',
- array('escape' => false,
- 'onclick' => 'actionMaintien('.$instance['Instance']['id'].', '.$historique['Historique']['id'].', '.$alerte['Alerte']['id'].')'
- )
- );
- ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php unset($alerte);
- } ?>
- </table>
- </td>
- <?php }?>
- <td>
- <?php echo $this->Html->link(
- $this->Html->image('edit.jpg', array('class' => 'button')),
- array('controller' => 'instances', 'action' => 'edit', $instance['Instance']['id']),
- array('escape' => false)
- ).' '.
- $this->Html->link(
- $this->Html->image('delete.png', array('class' => 'button')), '#',
- array('escape' => false,
- 'onclick' => 'supprimerHistorique('.$instance['Instance']['id'].', '.$historique['Historique']['id'].')'
- )
- );
- ?>
- </td>
- <?php } else { ?>
- <td>Historique pour cette instance inexistant ou introuvable</td>
- <td>
- <?php echo $this->Html->link(
- $this->Html->image('edit.jpg', array('class' => 'button')),
- array('controller' => 'instances', 'action' => 'edit', $instance['Instance']['id']),
- array('escape' => false)
- ).' '.
- $this->Form->postLink(
- $this->Html->image('delete.png', array('class' => 'button')),
- array('controller' => 'instances', 'action' => 'delete', $instance['Instance']['id']),
- array('escape' => false, 'confirm' => 'Etes-vous certain ?')
- );
- ?>
- </td>
- <?php } ?>
- </tr>
- <?php endforeach; ?>
- <?php unset($instance); ?>
-</table>
-<script>
- (function() {
- /*var message = "Custom message here";
- var title = "Hello World!";
- var maintenu = true;
-
- var truc = function(bool) {
- maintenu = bool;
- }
-
- eModal.confirm('test', "Supprimer le maintien de l'instance ?", function() {
- // To do : appel du controlleur
- if(maintenu) {
- alert('Maintien conservé');
- } else {
- alert('Maintien supprimé');
- }
- });
-
- var options = {
-
- // for ajax popup
- url: "ajax.html",
-
- // loading indicator
- loadingHtml: '',
-
- // The body message string or the html element.
- message: "The famous question?",
-
- // The header title string
- title: 'Header title',
-
- // The header subtitle string.
- subtitle: 'Sub title',
-
- // custom buttons
- buttons: [
- {text: 'Ok', style: 'info', close: true, click: truc(true) },
- {text: 'KO', style: 'danger', close: true, click: truc(false) }
- ],
-
- // Defines the size of modal ['sm' | 'lg']
- size: 'sm',
-
- // Set loading progress as message
- loading: false,
-
- // set message as recycable
- useBin: false,
-
- // css objext try apply into message body
- css: '',
-
- // use the possitive lable as key
- label: "True",
-
- // callback
- callback: function() { }
-
- };*/
-
- // alert dialog
- /*$("#demo-1").click(function () {
- eModal.alert(message, title);
- });*/
-
- // confirm dialog
- /*$("#demo-2").click(function() {
-
- var test = confirm("Conserver le maintien de l'instance ?");
- if(test) {
- alert('Maintien conservé');
- } else {
- alert('Maintien supprimé');
- $.ajax({
- url: "http://allo_serveur?action=get_instances",
- beforeSend: function( xhr ) {
- xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
- }
- })
- .done(function( data ) {
- if ( console && console.log ) {
- console.log( "Sample of data:", data.slice( 0, 100 ) );
- }
- });
- }
- });*/
-
- // prompt dialog
- /*$("#demo-3").click(function(){
- eModal.prompt(message, title);
- });
-
- var url = "ajax.html";
-
- // ajax popup
- $("#demo-4").click(function(){
- eModal.ajax(url);
- });*/
-
- //eModal.setEModalOptions(options);
- })();
-
- var actionMaintien = function (instance_id, historique_id, alerte_id) {
- var urlActionAlerte = "/historiques/actionAlerte/"+historique_id+"/"+alerte_id+"/false",
- garderMaintien = confirm("Conserver le maintien de l'instance ?");
- if(garderMaintien) {
- alert('Maintien conservé');
- location.href = urlActionAlerte;
- } else {
- alert('Maintien supprimé');
- $.ajax({
- url: "http://allo_serveur?action=disable_maintien&id="+instance_id,
- beforeSend: function( xhr ) {
- xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
- }
- })
- .done(function( data ) {
- if ( console && console.log ) {
- //console.log( "Sample of data:", data.slice( 0, 100 ) );
- }
- location.href = urlActionAlerte;
- });
- }
- };
-
- var supprimerHistorique = function (instance_id, historique_id) {
- var confirmation = confirm("Etes-vous certain ?");
- if (confirmation) {
- var garderHistorique = confirm("Conserver l'historique de l'instance ?");
- if(garderHistorique) {
- alert('Historique conservé');
- location.href = "/instances/delete/"+instance_id;
- } else {
- alert('Historique supprimé');
- $.ajax({
- url: "http://allo_webadmin/historiques/delete/"+historique_id,
- beforeSend: function( xhr ) {
- xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
- }
- })
- .done(function( data ) {
- if ( console && console.log ) {
- //console.log( "Sample of data:", data.slice( 0, 100 ) );
- }
- location.href = "/instances/delete/"+instance_id;
- });
- }
- }
- };
-
- var checkInfosInstances = function () {
- $.ajax({
- url: "http://allo_serveur/?action=check_synchro_info_version",
- beforeSend: function( xhr ) {
- xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
- }
- })
- .done(function( data ) {
- if ( console && console.log ) {
- //console.log( "Sample of data:", data.slice( 0, 100 ) );
- }
- location.href = "/instances";
- });
- };
-</script>
\ No newline at end of file
+++ /dev/null
-<h1>Instance : <?php echo h($instance['Instance']['nom']); ?></h1>
-
-<p>Version : <?php echo h($instance['Instance']['version']); ?></p>
-
-<p>Maintenu : <?php echo h($instance['Instance']['maintenu']); ?></p>
</div>
<div id="menu">
<a href="/appliances">INSTANCES</a>
- <a href="/warnings">ALERTES</a>
<a href="/products">PRODUITS</a>
<a href="/customers">CLIENTS</a>
</div>
--- /dev/null
+<h1>Ajout d'un patch</h1>
+<?php
+ echo $this->Form->create('Patch');
+ echo $this->Form->input('version');
+ echo $this->Form->end("Enregistrer le patch");
+?>
\ No newline at end of file
--- /dev/null
+<h1>Liste des patches</h1>
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouveau patch',
+ array('controller' => 'patches', 'action' => 'add')
+ ); ?>
+</h1>
+<table>
+ <tr>
+ <th>Version</th>
+ <th>URL</th>
+ <th>Tâches</th>
+ </tr>
+
+ <?php if(isset($patches)) { foreach ($patches as $patch): ?>
+ <tr>
+ <td><?php echo $patch['Patch']['version'] ?></td>
+ <td><?php echo $patch['Patch']['file_url'] ?></td>
+ <td>
+ <?php
+
+ // CHECKING TASK EXISTENCE
+ if(isset($tasksArray) && count($tasksArray) > 0) { ?>
+ <table>
+ <?php if(array_key_exists($patch['Patch']['id'], $tasksArray)) {
+ $order = 1;
+ foreach ($tasksArray[$patch['Patch']['id']] as $task): ?>
+ <tr>
+ <td><?php echo $order." ".$task['Task']['name']; ?></td>
+ <td><?php echo $this->Html->link(
+ 'HAUT', array('controller' => 'patches', 'action' => 'order_task', $patch['Patch']['id'], $order, "up")
+ ).' '.
+ $this->Html->link(
+ 'BAS', array('controller' => 'patches', 'action' => 'order_task', $patch['Patch']['id'], $order, "down")
+ );
+ $order++;?>
+ </td>
+ </tr>
+ <?php endforeach; } ?>
+ </table>
+ <?php }
+ echo $this->Html->link(
+ 'Nouvelle tâche',
+ array('controller' => 'tasks', 'action' => 'add', $patch['Patch']['id'])
+ ); ?>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ <?php unset($patch); } ?>
+</table>
\ No newline at end of file
).' '.
$this->Form->postLink(
$this->Html->image('delete.png', array('class' => 'button')),
- array('action' => 'delete', $version['Version']['id']),
+ array('controller' => 'versions', 'action' => 'delete', $version['Version']['id']),
array('escape' => false, 'confirm' => 'Etes-vous certain ?')
);
?>
+++ /dev/null
-<h1>Ajout d'un produit</h1>
-<?php
-echo $this->Form->create('Produit');
-echo $this->Form->input('nom');
-echo $this->Form->end("Enregistrer le produit");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>Editer le produit</h1>
-<?php
-echo $this->Form->create('Produit');
-echo $this->Form->input('nom');
-echo $this->Form->input('id', array('type' => 'hidden'));
-echo $this->Form->end("Mettre à jour le produit");
-?>
\ No newline at end of file
+++ /dev/null
-<h1>
- <?php echo $this->Html->link(
- 'Nouveau produit',
- array('controller' => 'produits', 'action' => 'add')
-); ?>
-</h1>
-<table>
- <tr>
- <th>Nom</th>
- <th>Versions</th>
- <th>Actions</th>
- </tr>
-
- <?php foreach ($produits as $produit): ?>
- <tr>
- <td><?php echo $produit['Produit']['nom']; ?></td>
- <td>
- <?php echo $this->Html->link(
- 'Nouvelle version',
- array('controller' => 'versions', 'action' => 'add', $produit['Produit']['id'])
- ); ?>
- <table>
- <tr>
- <th>Valeur</th>
- <th>Type</th>
- <th>Actions</th>
- </tr>
- <?php foreach ($versions as $version): if($version['Version']['produit'] == $produit['Produit']['id']) { ?>
- <tr>
- <td><?php echo $version['Version']['valeur']; ?></td>
- <td><?php echo $version['Version']['nature']; ?></td>
- <td>
- <?php echo $this->Html->link(
- $this->Html->image('edit.jpg', array('class' => 'button')),
- array('controller' => 'versions', 'action' => 'edit', $version['Version']['id']),
- array('escape' => false)
- ).' '.
- $this->Form->postLink(
- $this->Html->image('delete.png', array('class' => 'button')),
- array('action' => 'delete', $version['Version']['id']),
- array('escape' => false, 'confirm' => 'Etes-vous certain ?')
- );
- ?>
- </td>
- </tr>
- <?php } endforeach; unset($version); ?>
- </table>
- </td>
- <td>
- <?php echo $this->Html->link(
- $this->Html->image('edit.jpg', array('class' => 'button')),
- array('controller' => 'produits', 'action' => 'edit', $produit['Produit']['id']),
- array('escape' => false)
- ).' '.
- $this->Form->postLink(
- $this->Html->image('delete.png', array('class' => 'button')),
- array('action' => 'delete', $produit['Produit']['id']),
- array('escape' => false, 'confirm' => 'Etes-vous certain ?')
- );
- ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php unset($produit); ?>
-</table>
+++ /dev/null
-<p>Nom : <?php echo h($produit['Produit']['nom']); ?></p>
--- /dev/null
+<h1>Ajout d'une tâche</h1>
+<?php
+echo $this->Form->create('Task');
+echo $this->Form->input('name', array('label' => "Nom"));
+if(isset($patch)) {
+ echo 'Patch : '.$patch['Patch']['version'];
+ echo $this->Form->input('patch', array('label' => 'Patch', 'type' => 'hidden', 'value' => $patch['Patch']['id']));
+}
+echo $this->Form->end("Enregistrer la tâche");
+?>
\ No newline at end of file
--- /dev/null
+<h1>Liste des tâches</h1>
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouvelle tâche',
+ array('controller' => 'tasks', 'action' => 'add')
+ ); ?>
+</h1>
+<table>
+ <tr>
+ <th>Nom</th>
+ <th>Actions</th>
+ </tr>
+
+ <?php if(isset($tasks)) { foreach ($tasks as $task): ?>
+ <tr>
+ <td><?php echo $task['Task']['name'] ?></td>
+ <td>
+ <?php echo $this->Html->link(
+ 'Nouvelle commande',
+ array('controller' => 'commands', 'action' => 'add', $task['Task']['id'])
+ ); ?>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ <?php unset($task); } ?>
+</table>
\ No newline at end of file
+++ /dev/null
-<p>Valeur : <?php echo h($version['Version']['valeur']); ?></p>
#header #home {
padding-left: 30px;
float: left;
- width: 30%;
+ width: 35%;
}
#header #menu {
text-align: center;
-Informations à jour sur le serveur ALLO.
\ No newline at end of file
+Votre version diffère de la dernière déclarée sur le serveur ALLO, merci de contacter machin pour plus d'informations
\ No newline at end of file
+++ /dev/null
-###### CONFIGURATION ALLO AGENT ######
-
-# REFERENCE INSTANCE APPLICATION SUR ALLO = NOM FICHE INSTALL SUGAR = NOM PRODUIT / REF CLIENT + TYPE + DATE (AAAAMMJJhhmm)
-
-# Client classique
-produit_reference="TEST"
-
-# Type d'usager (exploitant|client)
-usager_type="client"
-
-# Type d'instance du produit (qualif|prod) -> inutile avec reference ?
-produit_type="prod"
-
-# Fqdn interne
-produit_fqdn_interne="asalaedev.asalae.dev.adullact.org" # AS@LAE
-
-# Fqdn externe
-#produit.fqdn.externe=""
-
-# ALLO Serveur
-allo_serveur_url="allo_serveur"
-
-## Configuration du header http
-# Type de données acceptées
-response_accept="Accept: application/json"
-# Type de données envoyées
-request_type="Content-Type: application/json"
-
-# Logs
-log_file="allo_agent.log"
--- /dev/null
+parapheur.ihm.admin.dossier.locked.notify=600
--- /dev/null
+#!/bin/bash
+
+BACKUPDIR=/opt/iParapheur/backups
+DATE=`date +%d-%m-%Y`
+DOCUMENTROOT=/opt/iParapheur
+BINDIR=$DOCUMENTROOT/bin
+DBS="alfresco"
+HOSTNAME=`hostname`
+DIR=$BACKUPDIR/$DATE
+ROTATEDIR=$BACKUPDIR
+HER=`pwd`
+
+### test avant lancement du script
+if [ ! -d $DOCUMENTROOT ]; then
+ echo "**$0: DocumentRoot invalid:$DOCUMENTROOT"
+ exit 1
+fi
+
+#create backup directory
+if [ ! -d $DIR ]
+then
+ mkdir -p $DIR
+fi
+#save repository
+cd $DOCUMENTROOT
+tar -czf $DIR/parapheur.tar.gz alf_data
+
+#save metadata
+for b in $DBS
+ do
+ mysqldump --add-locks --add-drop-table -u"alfresco" -palfresco $b 1> $DIR/$b.sql
+ done
+#save backup cmd
+cd $HER
+cp -a $0 $DIR
+
+#rotate des archives
+i=`ls -c1 $ROTATEDIR|wc -l`
+NBR=4
+cd $ROTATEDIR
+
+if [ $i -gt $NBR ]; then
+
+ while [ $i -ne $NBR ]; do
+ rm -rf `ls -rt|head -1`
+ i=`ls -c1 $ROTATEDIR|wc -l`
+ done
+fi
+#Envoi de la sauvegarde sur le serveur ftp
+#$BINDIR/send_backup.sh $DATE
--- /dev/null
+#!/bin/bash
+
+cd /opt/iParapheur
+
+# ADDING NEW KEYS TO OLD CONFIG
+awk -F= '!a[$1]++' tomcat/shared/classes/alfresco-global.properties add-alfresco > merged-alfresco-global.properties
+
+# REWRITING SOME VALUES
+declare -A rewritevalues
+
+while read line
+do
+ if echo $line | grep -F = &>/dev/null
+ then
+ key=$(echo "$line" | cut -d '=' -f 1)
+ rewritevalues[$key]=$(echo "$line" | cut -d '=' -f 2-)
+ fi
+done < rewrite-alfresco
+
+cp merged-alfresco-global.properties /tmp/tmpfile
+
+for i in ${!rewritevalues[@]}
+do
+ value=${rewritevalues[$i]}
+ sed -e 's!'$i'=\(.*\)!'$i'='$value'!g' /tmp/tmpfile > merged-alfresco-global.properties
+ cp merged-alfresco-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+
+# COMMENTING OUT OBSOLETE VALUES
+declare -A obsoletevalues
+
+i=0
+while read line
+do
+ obsoletevalues[$i]=$(echo "$line")
+ ((i++))
+done < obsolete-alfresco
+
+cp merged-alfresco-global.properties /tmp/tmpfile
+
+for i in ${obsoletevalues[@]}
+do
+ sed -e 's/^'$i'=\(.*\)/# '$i'=\1 OBSOLETE/g' /tmp/tmpfile > merged-alfresco-global.properties
+ cp merged-alfresco-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+mv tomcat/shared/classes/alfresco-global.properties tomcat/shared/classes/alfresco-global.properties.old
+mv merged-alfresco-global.properties tomcat/shared/classes/alfresco-global.properties
--- /dev/null
+#!/bin/bash
+
+cd /opt/iParapheur
+
+# ADDING NEW KEYS TO OLD CONFIG
+awk -F= '!a[$1]++' tomcat/shared/classes/iparapheur-global.properties add-iparapheur > merged-iparapheur-global.properties
+
+# REWRITING SOME VALUES
+declare -A rewritevalues
+
+while read line
+do
+ if echo $line | grep -F = &>/dev/null
+ then
+ key=$(echo "$line" | cut -d '=' -f 1)
+ rewritevalues[$key]=$(echo "$line" | cut -d '=' -f 2-)
+ fi
+done < rewrite-iparapheur
+
+cp merged-iparapheur-global.properties /tmp/tmpfile
+
+for i in ${!rewritevalues[@]}
+do
+ value=${rewritevalues[$i]}
+ sed -e 's!'$i'=\(.*\)!'$i'='$value'!g' /tmp/tmpfile > merged-iparapheur-global.properties
+ cp merged-iparapheur-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+
+# COMMENTING OUT OBSOLETE VALUES
+declare -A obsoletevalues
+
+i=0
+while read line
+do
+ obsoletevalues[$i]=$(echo "$line")
+ ((i++))
+done < obsolete-iparapheur
+
+cp merged-iparapheur-global.properties /tmp/tmpfile
+
+for i in ${obsoletevalues[@]}
+do
+ sed -e 's/^'$i'=\(.*\)/# '$i'=\1 OBSOLETE/g' /tmp/tmpfile > merged-iparapheur-global.properties
+ cp merged-iparapheur-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+mv tomcat/shared/classes/iparapheur-global.properties tomcat/shared/classes/iparapheur-global.properties.old
+mv merged-iparapheur-global.properties tomcat/shared/classes/iparapheur-global.properties
--- /dev/null
+#!/bin/bash
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NC='\033[0m' # No Color
+
+# Arrêt de tomcat + frontal web
+echo -n "Arrêt des services..."
+service alfresco stop
+service nginx stop
+printf "${GREEN}OK${NC}\n"
+
+# Remplacement AMP
+echo -n "Remplacement de l'AMP..."
+rm -f /opt/iParapheur/amps/*
+cp /opt/_install/iParapheur-v4.2.07/iParapheur-v4.2.07*.amp /opt/iParapheur/amps/
+printf "${GREEN}OK${NC}\n"
+
+# Script de backup
+echo -n "Sauvegarde..."
+cd /opt/iParapheur && ./backup_parapheur.sh
+printf "${GREEN}OK${NC}\n"
+
+# [Prereq] Fichier alfresco.war original intègre
+#echo -n "Tests d'intégrité des webapps originales..."
+#cd /opt/iParapheur/tomcat/webapps
+#if [ -s alfresco.war ]
+#then
+# if [ -s alfresco.war.md5sum ]
+# then
+# if [ `md5sum alfresco.war | awk '{print $1}'` == `cat alfresco.war.md5sum` ]
+# then
+# printf "${GREEN}OK${NC}\n"
+# else
+# printf "${RED}Corrompu${NC}\n"
+# exit 1
+# fi
+# else
+# printf "${RED}Hash introuvable${NC}\n"
+# exit 1
+# fi
+#else
+# printf "${RED}Vide${NC}\n"
+# exit 1
+#fi
+
+# Déploiement des nouvelles sources
+cd /opt/iParapheur && ./iparaph-updateAMP.sh
+
+# Modif conf alfresco
+echo -n "Mise à jour de la configuration alfresco..."
+cd /opt/iParapheur ; cp /opt/_install/iParapheur-v4.2.07/confs/fusion_conf_alfresco.sh .
+cp /opt/_install/iParapheur-v4.2.07/confs/add-alfresco .
+cp /opt/_install/iParapheur-v4.2.07/confs/rewrite-alfresco .
+cp /opt/_install/iParapheur-v4.2.07/confs/obsolete-alfresco .
+./fusion_conf_alfresco.sh
+printf "${GREEN}OK${NC}\n"
+
+# Connecteur WS
+echo -n "Correction de l'accès à la wsdl..."
+cd /opt/iParapheur ; cp /opt/_install/iParapheur-v4.2.07/confs/custom-wsdl.sh .
+./custom-wsdl.sh secure-iparapheurdavid.test.adullact.org
+printf "${GREEN}OK${NC}\n"
+
+# Modif conf iparapheur
+echo -n "Mise à jour de la configuration iparapheur..."
+cd /opt/iParapheur ; cp /opt/_install/iParapheur-v4.2.07/confs/fusion_conf_iparapheur.sh .
+cp /opt/_install/iParapheur-v4.2.07/confs/add-iparapheur .
+cp /opt/_install/iParapheur-v4.2.07/confs/rewrite-iparapheur .
+cp /opt/_install/iParapheur-v4.2.07/confs/obsolete-iparapheur .
+./fusion_conf_iparapheur.sh
+printf "${GREEN}OK${NC}\n"
+
+# Redéploiement webapp iparapheur
+cd /opt/_install/iParapheur-v4.2.07
+cp *.war /opt/iParapheur/tomcat/webapps/iparapheur.war
+mkdir -p /opt/iParapheur/tomcat/webapps/iparapheur
+cd /opt/iParapheur ; chmod +x deployWarIparapheur.sh
+./deployWarIparapheur.sh
+
+# Démarrage alfresco + frontal web
+echo -n "Redémarrage des services..."
+service nginx start
+service alfresco start
+printf "${GREEN}OK${NC}\n"
--- /dev/null
+#!/bin/bash
+original_file=$1
+new_file=$2
+
+if [ -z "$(diff -q "$original_file" "$new_file")" ]
+then
+ echo "Les fichiers sont identiques, aucune modification apportée."
+else
+ # COMPARISON
+ diff -D allo_change "$original_file" "$new_file" > /tmp/tmpfile
+
+ # MAGIC (uggly but works...)
+ sed -e 's/\(.*\)ADD_VALUE/allo_change\n\1\n^#else allo_change/' /tmp/tmpfile > /tmp/tmpfile2
+ sed -e 's/\(.*\)REWRITE/allo_change\n\1REWRITE\n^#else allo_change/' /tmp/tmpfile2 > /tmp/tmpfile1
+ sed '/^#else/,/allo_change/d' /tmp/tmpfile1 | sed '/^#ifdef/,/allo_change/d' | sed '/allo_change/d' > /tmp/tmpfile2
+ sed -e 's/\(.*\)REWRITE/DELETE\n\1/' /tmp/tmpfile2 > /tmp/tmpfile
+ awk '{l[m=NR]=$0}/DELETE/{for(i=NR-1;i<=NR;i++)delete l[i]}END{for(i=1;i<=m;i++)if(i in l)print l[i]}' /tmp/tmpfile > $new_file
+ rm /tmp/tmpfile*
+fi
--- /dev/null
+#!/bin/bash
+
+# ADDING NEW KEYS TO OLD CONFIG
+awk -F= '!a[$1]++' alfresco-global.properties add-alfresco > merged-alfresco-global.properties
+
+# REWRITING SOME VALUES
+declare -A rewritevalues
+
+while read line
+do
+ if echo $line | grep -F = &>/dev/null
+ then
+ key=$(echo "$line" | cut -d '=' -f 1)
+ rewritevalues[$key]=$(echo "$line" | cut -d '=' -f 2-)
+ fi
+done < rewrite-alfresco
+
+cp merged-alfresco-global.properties /tmp/tmpfile
+
+for i in ${!rewritevalues[@]}
+do
+ value=${rewritevalues[$i]}
+ sed -e 's!'$i'=\(.*\)!'$i'='$value'!g' /tmp/tmpfile > merged-alfresco-global.properties
+ cp merged-alfresco-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+
+# COMMENTING OUT OBSOLETE VALUES
+declare -A obsoletevalues
+
+i=0
+while read line
+do
+ obsoletevalues[$i]=$(echo "$line")
+ ((i++))
+done < obsolete-alfresco
+
+cp merged-alfresco-global.properties /tmp/tmpfile
+
+for i in ${obsoletevalues[@]}
+do
+ sed -e 's/^'$i'=\(.*\)/# '$i'=\1 OBSOLETE/g' /tmp/tmpfile > merged-alfresco-global.properties
+ cp merged-alfresco-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+mv alfresco-global.properties alfresco-global.properties.old
+mv merged-alfresco-global.properties alfresco-global.properties
--- /dev/null
+#!/bin/bash
+
+# ADDING NEW KEYS TO OLD CONFIG
+awk -F= '!a[$1]++' iparapheur-global.properties add-iparapheur > merged-iparapheur-global.properties
+
+# REWRITING SOME VALUES
+declare -A rewritevalues
+
+while read line
+do
+ if echo $line | grep -F = &>/dev/null
+ then
+ key=$(echo "$line" | cut -d '=' -f 1)
+ rewritevalues[$key]=$(echo "$line" | cut -d '=' -f 2-)
+ fi
+done < rewrite-iparapheur
+
+cp merged-iparapheur-global.properties /tmp/tmpfile
+
+for i in ${!rewritevalues[@]}
+do
+ value=${rewritevalues[$i]}
+ sed -e 's!'$i'=\(.*\)!'$i'='$value'!g' /tmp/tmpfile > merged-iparapheur-global.properties
+ cp merged-iparapheur-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+
+# COMMENTING OUT OBSOLETE VALUES
+declare -A obsoletevalues
+
+i=0
+while read line
+do
+ obsoletevalues[$i]=$(echo "$line")
+ ((i++))
+done < obsolete-iparapheur
+
+cp merged-iparapheur-global.properties /tmp/tmpfile
+
+for i in ${obsoletevalues[@]}
+do
+ sed -e 's/^'$i'=\(.*\)/# '$i'=\1 OBSOLETE/g' /tmp/tmpfile > merged-iparapheur-global.properties
+ cp merged-iparapheur-global.properties /tmp/tmpfile
+done
+rm /tmp/tmpfile
+mv iparapheur-global.properties iparapheur-global.properties.old
+mv merged-iparapheur-global.properties iparapheur-global.properties
+++ /dev/null
-{
- "canal": "prod",
- "fqdn_interne": "api_test",
- "systeme": "Ubuntu 14.04.2 LTS ",
- "usager_type": "client",
- "produit": "i-Parapheur",
- "version": "4.2.06",
- "reference": "IP/VILLELAG_77243_2004151140",
- "disques": "/dev/sda1: UUID=ba9880c3-9243-4bf5-ac40-e444f50f5bab TYPE=ext4 \n/dev/sda2: UUID=60e43c5a-e2bd-4292-ae2f-c9a99f8f2e14 TYPE=swap \n/dev/sda3: UUID=8d5b0c17-4189-4de8-bc82-cc674b58b4b0 TYPE=ext4 ",
- "fqdn_externe": "instance.mondomaine.fr"
-}
+++ /dev/null
-{"produit":"i-Parapheur","version":"4.2.06"}
\ No newline at end of file
+++ /dev/null
-HTTP/1.1 200 OK
-Date: Tue, 19 May 2015 09:21:40 GMT
-Server: Apache/2.4.7 (Ubuntu)
-X-Powered-By: PHP/5.5.9-1ubuntu4.9
-Access-Control-Allow-Origin: *
-Content-Length: 10
-Content-Type: text/html; charset=utf-8
-
-TEST4.2.06
+++ /dev/null
-{
- "reference": "IP/VILLELAG_77243_2004151140",
- "version": "4.2.06",
- "produit": "i-Parapheur"
-}
+++ /dev/null
-{
- "usager_type": "client",
- "produit": "i-Parapheur",
- "version": "4.2.06",
- "reference": "IP/VILLELAG_77243_2004151140"
-}
+++ /dev/null
-{
- "disques": "/dev/sda1: UUID=ba9880c3-9243-4bf5-ac40-e444f50f5bab TYPE=ext4 \n/dev/sda2: UUID=60e43c5a-e2bd-4292-ae2f-c9a99f8f2e14 TYPE=swap \n/dev/sda3: UUID=8d5b0c17-4189-4de8-bc82-cc674b58b4b0 TYPE=ext4 ",
- "reference": "IP/VILLELAG_77243_2004151140",
- "version": "4.2.06",
- "produit": "i-Parapheur",
- "usager_type": "client"
-}
+++ /dev/null
-{
- "systeme": "Ubuntu 14.04.2 LTS ",
- "usager_type": "client",
- "produit": "i-Parapheur",
- "version": "4.2.06",
- "reference": "IP/VILLELAG_77243_2004151140",
- "disques": "/dev/sda1: UUID=ba9880c3-9243-4bf5-ac40-e444f50f5bab TYPE=ext4 \n/dev/sda2: UUID=60e43c5a-e2bd-4292-ae2f-c9a99f8f2e14 TYPE=swap \n/dev/sda3: UUID=8d5b0c17-4189-4de8-bc82-cc674b58b4b0 TYPE=ext4 "
-}
+++ /dev/null
-{
- "fqdn_externe": "instance.mondomaine.fr",
- "disques": "/dev/sda1: UUID=ba9880c3-9243-4bf5-ac40-e444f50f5bab TYPE=ext4 \n/dev/sda2: UUID=60e43c5a-e2bd-4292-ae2f-c9a99f8f2e14 TYPE=swap \n/dev/sda3: UUID=8d5b0c17-4189-4de8-bc82-cc674b58b4b0 TYPE=ext4 ",
- "reference": "IP/VILLELAG_77243_2004151140",
- "version": "4.2.06",
- "produit": "i-Parapheur",
- "usager_type": "client",
- "systeme": "Ubuntu 14.04.2 LTS "
-}
+++ /dev/null
-{
- "fqdn_interne": "api_test",
- "systeme": "Ubuntu 14.04.2 LTS ",
- "usager_type": "client",
- "produit": "i-Parapheur",
- "version": "4.2.06",
- "reference": "IP/VILLELAG_77243_2004151140",
- "disques": "/dev/sda1: UUID=ba9880c3-9243-4bf5-ac40-e444f50f5bab TYPE=ext4 \n/dev/sda2: UUID=60e43c5a-e2bd-4292-ae2f-c9a99f8f2e14 TYPE=swap \n/dev/sda3: UUID=8d5b0c17-4189-4de8-bc82-cc674b58b4b0 TYPE=ext4 ",
- "fqdn_externe": "instance.mondomaine.fr"
-}
then
verification=false
echo "Configuration incomplète, merci de vérifier les paramètres."
-fi
-
-# CLEAN DES LOGS
-if [ -e "${log_file}" ]
-then
- rm "${log_file}"
-fi
-
-# TEST DE CONNEXION
-echo "Test d'accès de l'application sur ""${instance_fqdn_interne}""..."
-code=$(curl -s -w "%{http_code}" --max-time 5 "http://""${instance_fqdn_interne}""/api/rest/allo/version" --output /dev/null)
-
-if [ "${code}" == 200 ] || [ "${code}" == 301 ]
-then
- echo "Test OK, récupération des informations..."
-
- # REQUETE (en insecure pour le moment)
- curl --max-time 10 -k -X GET -H "${response_accept}" "http://""${instance_fqdn_interne}""/api/rest/allo/version/" --output "response.json" 2> /dev/null
-
- # LOG DE LA REPONSE
- #echo "$(cat response.json)" 2>&1 | tee -a $log_file
-
- # VALIDATION DU JSON (nécessite outil de validation json et paquet node)
- isJSONCorrupted="$(module/json -nq response.json)"
- #echo "${isJSONCorrupted}"
-
- # SI LA VARIABLE EST INITIALISEE MAIS VIDE => PAS D'ERREUR
- if [[ -z $isJSONCorrupted && ${isJSONCorrupted+x} ]]
- then
- echo "Envoi des information au serveur ALLO..."
-
- # RÉCUPÉRATION DES NOMS, UUIDS ET LABELS DES DISQUES
- disques=$(blkid /dev/sd* | sed 's/\"//g')
-
- # SYSTEME D'EXPLOITATION
- systeme=$(sed 's/\\n\ \\l//g' /etc/issue)
-
- # AJOUT DE LA REFERENCE PRODUIT (nécessite package jq)
- jq '. + { "reference": "'"${instance_reference}"'" }' response.json > tmp1.json
-
- # AJOUT DU TYPE D'USAGER
- jq '. + { "usager_type": "'"${usager_type}"'" }' tmp1.json > tmp2.json
-
- # AJOUT DES INFOS DISQUES
- jq '. + { "disques": "'"${disques}"'" }' tmp2.json > tmp3.json
-
- # AJOUT DES INFOS DISQUES
- jq '. + { "systeme": "'"${systeme}"'" }' tmp3.json > tmp4.json
-
- # AJOUT DU FQDN EXTERNE
- jq '. + { "fqdn_externe": "'"${instance_fqdn_externe}"'" }' tmp4.json > tmp5.json
-
- # AJOUT DU FQDN INTERNE
- jq '. + { "fqdn_interne": "'"${instance_fqdn_interne}"'" }' tmp5.json > tmp6.json
-
- # AJOUT DU TYPE DE L'INSTANCE
- jq '. + { "canal": "'"${instance_canal}"'" }' tmp6.json > request.json
-
- # ENVOI DE L'UPDATE AU SERVEUR
- curl --cert bma.pem --key bma.key -X POST -H "${request_type}" --data-binary "@request.json" "https://""${allo_serveur_url}""/?action=upload_info" --output "response_server" 2> /dev/null
- if [ -e ./response_server ]
- then
- echo "Réponse du serveur ALLO :"
- #tee response_server -a "$log_file"
- cat response_server 2>&1 | tee -a "$log_file"
- else
- echo "Aucune réponse du serveur !" 2>&1 | tee -a "$log_file"
- fi
- rm response*
- rm request.json
- rm tmp*.json
- else
- echo "Les données récupérées sont illisibles" 2>&1 | tee -a "$log_file"
- fi
else
- echo "L'application a renvoyé une erreur : " 2>&1 | tee -a "$log_file"
- case "${code}" in
- "500")
- echo "Erreur interne du serveur" 2>&1 | tee -a "$log_file"
- ;;
- "400" | "404")
- echo "Mauvaise requete" 2>&1 | tee -a "$log_file"
- ;;
- "403")
- echo "Accès refusé" 2>&1 | tee -a "$log_file"
+ # CLEAN DES LOGS
+ if [ -e "${log_file}" ]
+ then
+ rm "${log_file}"
+ fi
+
+ # TEST DE CONNEXION
+ echo "Test d'accès de l'application sur ""${instance_fqdn_interne}""..."
+ code=$(curl -s -w "%{http_code}" --max-time 5 "http://""${instance_fqdn_interne}""/api/rest/allo/version" --output /dev/null)
+
+ if [ "${code}" == 200 ] || [ "${code}" == 301 ]
+ then
+ echo "Test OK, récupération des informations..."
+
+ # REQUETE (en insecure pour le moment)
+ curl --max-time 10 -k -X GET -H "${response_accept}" "http://""${instance_fqdn_interne}""/api/rest/allo/version/" --output "response.json" 2> /dev/null
+
+ # LOG DE LA REPONSE
+ #echo "$(cat response.json)" 2>&1 | tee -a $log_file
+
+ # VALIDATION DU JSON (nécessite outil de validation json et paquet node)
+ isJSONCorrupted="$(module/json -nq response.json)"
+ #echo "${isJSONCorrupted}"
+
+ # SI LA VARIABLE EST INITIALISEE MAIS VIDE => PAS D'ERREUR
+ if [[ -z $isJSONCorrupted && ${isJSONCorrupted+x} ]]
+ then
+ echo "Envoi des information au serveur ALLO..."
+
+ # RÉCUPÉRATION DES NOMS, UUIDS ET LABELS DES DISQUES
+ disques=$(blkid /dev/sd* | sed 's/\"//g')
+
+ # SYSTEME D'EXPLOITATION
+ systeme=$(sed 's/\\n\ \\l//g' /etc/issue)
+
+ # AJOUT DE LA REFERENCE PRODUIT (nécessite package jq)
+ jq '. + { "reference": "'"${instance_reference}"'" }' response.json > tmp1.json
+
+ # AJOUT DU TYPE D'USAGER
+ jq '. + { "usager_type": "'"${usager_type}"'" }' tmp1.json > tmp2.json
+
+ # AJOUT DES INFOS DISQUES
+ jq '. + { "disques": "'"${disques}"'" }' tmp2.json > tmp3.json
+
+ # AJOUT DES INFOS DISQUES
+ jq '. + { "systeme": "'"${systeme}"'" }' tmp3.json > tmp4.json
+
+ # AJOUT DU FQDN EXTERNE
+ jq '. + { "fqdn_externe": "'"${instance_fqdn_externe}"'" }' tmp4.json > tmp5.json
+
+ # AJOUT DU FQDN INTERNE
+ jq '. + { "fqdn_interne": "'"${instance_fqdn_interne}"'" }' tmp5.json > tmp6.json
+
+ # AJOUT DU TYPE DE L'INSTANCE
+ jq '. + { "canal": "'"${instance_canal}"'" }' tmp6.json > request.json
+
+ # ENVOI DE L'UPDATE AU SERVEUR
+ curl --cert bma.pem --key bma.key -X POST -H "${request_type}" --data-binary "@request.json" "https://""${allo_serveur_url}""/?action=upload_info" --output "response_server" 2> /dev/null
+ if [ -e ./response_server ]
+ then
+ echo "Réponse du serveur ALLO :"
+ #tee response_server -a "$log_file"
+ cat response_server 2>&1 | tee -a "$log_file"
+ else
+ echo "Aucune réponse du serveur !" 2>&1 | tee -a "$log_file"
+ fi
+ rm response*
+ rm request.json
+ rm tmp*.json
+ else
+ echo "Les données récupérées sont illisibles" 2>&1 | tee -a "$log_file"
+ fi
+ else
+ echo "L'application a renvoyé une erreur : " 2>&1 | tee -a "$log_file"
+ case "${code}" in
+ "500")
+ echo "Erreur interne du serveur" 2>&1 | tee -a "$log_file"
+ ;;
+ "400" | "404")
+ echo "Mauvaise requete" 2>&1 | tee -a "$log_file"
+ ;;
+ "403")
+ echo "Accès refusé" 2>&1 | tee -a "$log_file"
+ ;;
+ *)
+ echo "Aucune réponse de l'application" 2>&1 | tee -a "$log_file"
;;
- *)
- echo "Aucune réponse de l'application" 2>&1 | tee -a "$log_file"
- ;;
- esac
+ esac
+ fi
fi
echo ""
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- interface AlerteManager {
-
- function createAlerte($alerte);
- function updateAlerte($alerte);
- function getAlerte($id);
- function getLastAlerte();
- function getAlertes();
- function removeAlerte($alerte);
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- interface ExploitantManager {
-
- function createExploitant($exploitant);
- function updateExploitant($exploitant);
- function getExploitant($id);
- function getExploitants();
- function getExploitantByReference($reference);
- function removeExploitant($exploitant);
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- interface HistoriqueManager {
-
- function createHistorique($historique);
- function updateHistorique($historique);
- function getHistorique($id);
- function getLastHistorique();
- function getHistoriques();
- function removeHistorique($historique);
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- interface InstanceManager {
-
- function createInstance($instance);
- function updateInstance($instance);
- function updateInstanceInfos($array);
- function getInstance($id);
- function getInstances();
- function removeInstance($instance);
- function desactiverMaintienById($id);
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- interface ProduitManager {
-
- function createProduit($produit);
- function updateProduit($produit);
- function getProduit($id);
- function getProduitByNom($nom);
- function getProduits();
- function getNomsOfProduits();
- function removeProduit($produit);
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- interface VersionManager {
-
- function createVersion($version);
- function updateVersion($version);
- function getVersion($id);
- function getVersions();
- function findValeursOfVersionsByProduitId($produit_id);
- function removeVersion($version);
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoAlerteManager extends AbstractPdoManager {
-
- public function createAlerte($alerte) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO alertes (creation, nature, message, version) VALUES (NOW(), :nature, :message, :version);'
- );
- $query -> bindValue(':nature', $alerte -> getNature());
- $query -> bindValue(':message', $alerte -> getMessage());
- $query -> bindValue(':version', $alerte -> getVersion());
- $query -> execute();
- }
-
- public function updateAlerte($alerte) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE alertes
- SET creation = :creation,
- nature = :nature,
- message = :message,
- version = :version
- WHERE id = :id'
- );
- $query -> bindValue(':id', $alerte -> getId());
- $query -> bindValue(':creation', $alerte -> getCreation());
- $query -> bindValue(':nature', $alerte -> getNature());
- $query -> bindValue(':message', $alerte -> getMessage());
- $query -> bindValue(':version', $alerte -> getVersion());
- $query -> execute();
- }
-
- public function getAlerte($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM alertes WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $alerte = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
-
- $query->closeCursor();
-
- return $alerte;
- }
-
- public function getLastAlerte() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM alertes WHERE id = LAST_INSERT_ID()');
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $alerte = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
-
- $query->closeCursor();
-
- return $alerte;
- }
-
- public function getAlertes() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM alertes');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $alertes = array();
- foreach ($results as $result) {
- $alertes[] = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
- }
-
- $query->closeCursor();
-
- return $alertes;
- }
-
- public function removeAlerte($alerte) {
-
- $query = $this -> pdo -> prepare('DELETE FROM alertes WHERE id = :id');
- $query -> bindValue('id', $alerte -> getId());
- $query -> execute();
- }
-
- }
-
-?>
$query -> bindValue(':reference', $appliance -> getReference());
$query -> bindValue(':changelog', $appliance -> getChangelog());
$query -> bindValue(':maintained', $appliance -> isMaintained());
- $query -> bindValue(':internal_fqdn', $appliance -> getFqdnInterne());
- $query -> bindValue(':external_fqdn', $appliance -> getFqdnExterne());
+ $query -> bindValue(':internal_fqdn', $appliance -> getInternalFqdn());
+ $query -> bindValue(':external_fqdn', $appliance -> getExternalFqdn());
$query -> bindValue(':os', $appliance -> getOs());
$query -> bindValue(':disc_infos', $appliance -> getDiscInfos());
$query -> bindValue(':channel', $appliance -> getChannel());
// IF APPLIANCE EXISTS
if(isset($appliance) && $appliance -> getId() > 0) {
- // IF APPLIANCE IS MAINTAINED
+ // IF APPLIANCE ISN'T MAINTAINED
if(!$appliance -> isMaintained()) {
- echo "Votre application n'est plus maintainue par nos services, merci de vous renseigner auprès de votre contact ADULLACT Projet pour plus d'informations.";
+ $customerManager = new PdoCustomerManager();
+ $contactEmail = "";
+ $applianceReferenceArray = explode("/", $appliance -> getReference());
+ if(isset($applianceReferenceArray[1])) {
+ $customerAPId = substr($applianceReferenceArray[1], 0, -11);
+ $customer = $customerManager->getCustomerByAPId($customerAPId);
+ $contactEmail = ", dont l'adresse est ".$customer->getAPContact().",";
+ }
+ echo "Votre application n'est plus maintainue par nos services, merci de vous renseigner auprès de votre contact ADULLACT Projet".$contactEmail." pour plus d'informations.";
} else {
// GETTING PDO MANAGERS
} else if($array['usager_type'] === "client") {
// CHECKING APPLIANCE PRODUCT NAME
- //if ($array['produit'] === $appliance -> getProduct()) {
-
- // GETTING CHANGELOG OF APPLIANCE
- $changelog = $changelogManager -> getChangelog($appliance -> getChangelog());
-
- // IF CHANGELOG FOR THIS APPLIANCE EXISTS
- if(isset($changelog) && $changelog -> getId() > 0) {
-
- // IF VERSION DIFFERS FROM DB
- $lastVersionValue = $changelogManager -> findLastVersionForId($appliance -> getChangelog()) -> getValue();
- if($array['version'] === $lastVersionValue) {
- echo "Informations à jour sur le serveur ALLO.";
- } else {
-
- // GETTING VERSION ID
- $version_id = $versionManager -> getIdByValueAndProductId($array['version'], $productManager->getProductByName($array['produit'])->getId());
-
- // NEW WARNING CREATION, VERSION TYPE
- $warningMessage = "Version declaree ".$array['version']." sans mise à jour par ALLO.";
- $warning = new Warning(null, null, "version", $warningMessage, $version_id);
- $warningManager -> createWarning($warning);
-
- // SENDING MAIL TO ADMIN
- $to = 'david.calmel@adullact-projet.coop';
- $subject = 'ALLO - Nouvelle alerte';
- $message = $warningMessage;
- $headers = 'From: ne-pas-repondre@allo-serveur';
- mail($to, $subject, $message, $headers);
-
- // ADDING NEW WARNING TO CHANGELOG
- $warnings = $changelog -> getWarnings();
- if((array_search("", $warnings)) !== false) {
- $warnings = array($warningManager -> getLastWarning() -> getId());
+ if ($array['produit'] === $productManager -> getProduct($appliance -> getProduct()) -> getName()) {
+
+ // GETTING CHANGELOG OF APPLIANCE
+ $changelog = $changelogManager->getChangelog($appliance->getChangelog());
+
+ // IF CHANGELOG FOR THIS APPLIANCE EXISTS
+ if (isset($changelog) && $changelog->getId() > 0) {
+
+ // IF VERSION DIFFERS FROM DB
+ $lastVersionValue = $changelogManager->findLastVersionForId($appliance->getChangelog())->getValue();
+ if ($array['version'] === $lastVersionValue) {
+ echo "Informations à jour sur le serveur ALLO.";
} else {
- $warnings[] = $warningManager -> getLastWarning() -> getId();
+
+ // GETTING VERSION ID
+ $version_id = $versionManager->getIdByValueAndProductId($array['version'], $appliance -> getProduct());
+
+ // NEW WARNING CREATION, VERSION TYPE
+ $warningMessage = "Version declaree " . $array['version'] . " sans mise à jour par ALLO.";
+ $warning = new Warning(null, null, "version", $warningMessage, $version_id);
+ $warningManager->createWarning($warning);
+
+ // SENDING MAIL TO ADMIN
+ $to = 'david.calmel@adullact-projet.coop';
+ $subject = 'ALLO - Nouvelle alerte';
+ $message = $warningMessage;
+ $headers = 'From: ne-pas-repondre@allo-serveur';
+ mail($to, $subject, $message, $headers);
+
+ // ADDING NEW WARNING TO CHANGELOG
+ $warnings = $changelog->getWarnings();
+ if ((array_search("", $warnings)) !== false) {
+ $warnings = array($warningManager->getLastWarning()->getId());
+ } else {
+ $warnings[] = $warningManager->getLastWarning()->getId();
+ }
+ $changelog->setWarnings($warnings);
+ $changelogManager->updateChangelog($changelog);
+ // TO-DO : ADD CONTACT INFORMATIONS TO MESSAGE
+ echo "Votre version diffère de la dernière déclarée sur le serveur ALLO, merci de contacter machin pour plus d'informations";
}
- $changelog -> setWarnings($warnings);
- $changelogManager -> updateChangelog($changelog);
- // TO-DO : ADD CONTACT INFORMATIONS TO MESSAGE
- echo "Votre version diffère de la dernière déclarée sur le serveur ALLO, merci de contacter machin pour plus d'informations";
- }
-
- // IF CHANGELOG DOES NOT EXIST, CREATING NEW ONE (DELETE THIS ?)
- } /*else {
+
+ // IF CHANGELOG DOES NOT EXIST, CREATING NEW ONE (DELETE THIS ?)
+ } /*else {
$changelog = new Changelog(null, array($warningManager -> getLastWarning() -> getId()), array(""));
$changelogManager -> createChangelog($changelog);
$appliance -> setChangelog($changelogManager -> getLastChangelog() -> getId());
$this -> updateAppliance($appliance);
}*/
+ } else {
+ echo "Ce produit est incorrect, merci de contacter machin.";
+ }
} else {
echo "Le type d'usager est inconnu, merci de corriger la configuration.";
}
return $lastVersionDeclaration;
}
+ public function findFirstVersionForId($id) {
+
+ $query = $this -> pdo -> prepare('SELECT versions FROM changelogs WHERE id = :id');
+ $query -> bindValue('id', $id);
+ $query -> execute();
+
+ // GETTING LAST DECLARED VERSION ID
+ $lastVersionId = null;
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $versions = explode("|", $result['versions']);
+ foreach ($versions as $version) {
+ $versionArray = explode(';', $version);
+ $versionId = $versionArray[0];
+ $versionDeclaration = $versionArray[1];
+ if(!isset($lastVersionDeclaration) || $versionDeclaration < $lastVersionDeclaration) {
+ $lastVersionDeclaration = $versionDeclaration;
+ $lastVersionId = $versionId;
+ }
+ }
+ $query->closeCursor();
+
+ // GETTING VERSION
+ $versionManager = new PdoVersionManager();
+ if(isset($lastVersionId)) {
+ $version = $versionManager->getVersion($lastVersionId);
+ } else {
+ $version = new Version();
+ }
+ return $version;
+ }
+
+ public function findFirstVersionDeclarationForId($id) {
+
+ $query = $this -> pdo -> prepare('SELECT versions FROM changelogs WHERE id = :id');
+ $query -> bindValue('id', $id);
+ $query -> execute();
+
+ // GETTING LAST VERSION DECLARATION
+ $lastVersionDeclaration = null;
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $versions = explode("|", $result['versions']);
+ foreach ($versions as $version) {
+ $versionArray = explode(';',$version);
+ $versionDeclaration = $versionArray[1];
+ if(!isset($lastVersionDeclaration) || $versionDeclaration < $lastVersionDeclaration) {
+ $lastVersionDeclaration = $versionDeclaration;
+ }
+ }
+ $query->closeCursor();
+
+ return $lastVersionDeclaration;
+ }
+
}
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoClientManager extends AbstractPdoManager {
-
- public function createClient($client) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO clients (
- identifiant_AP,
- nom
- ) VALUES (
- :identifiant_AP,
- :nom
- );'
- );
- $query -> bindValue(':identifiant_AP', $client -> getIdentifiantAP());
- $query -> bindValue(':nom', $client -> getNom());
- $query -> execute();
- }
-
- public function updateClient($client) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE clients
- SET identifiant_AP = :identifiant_AP,
- nom = :nom
- WHERE id = :id'
- );
- $query -> bindValue(':id', $client -> getId());
- $query -> bindValue(':identifiant_AP', $client -> getIdentifiantAP());
- $query -> bindValue(':nom', $client -> getNom());
- $query -> execute();
- }
-
- public function getClient($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM clients WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $client = new Client($result['id'], $result['identifiant_AP'], $result['nom']);
-
- $query->closeCursor();
-
- return $client;
- }
-
- public function getClientByIdentifiantAP($identifiantAP) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM clients WHERE identifiant_AP = :identifiant_AP');
- $query -> bindValue(':identifiant_AP', $identifiantAP);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $client = new Client($result['id'], $result['identifiant_AP'], $result['nom']);
-
- $query->closeCursor();
-
- return $client;
- }
-
- public function getClients() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM clients');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $clients = array();
- foreach ($results as $result) {
- $clients[] = new Client($result['id'], $result['identifiant_AP'], $result['nom']);
- }
-
- $query->closeCursor();
-
- return $clients;
- }
-
- public function removeClient($client) {
-
- $query = $this -> pdo -> prepare('DELETE FROM clients WHERE id = :id');
- $query -> bindValue('id', $client -> getId());
- $query -> execute();
- }
-
- }
-
-?>
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class PdoContractManager extends AbstractPdoManager {
+
+ public function createContract($contract) {
+
+ $query = $this -> pdo -> prepare(
+ 'INSERT INTO contracts (
+ number,
+ state,
+ appliances
+ ) VALUES (
+ :number,
+ :state,
+ :appliances
+ );'
+ );
+ $query -> bindValue(':number', $contract -> getNumber());
+ $query -> bindValue(':state', $contract -> getState());
+ $query -> bindValue(':appliances', implode("|", $contract -> getAppliances()));
+ $query -> execute();
+ }
+
+ public function updateContract($contract) {
+
+ $query = $this -> pdo -> prepare(
+ 'UPDATE contracts
+ SET number = :number,
+ state = :state,
+ appliances = :appliances
+ WHERE id = :id'
+ );
+ $query -> bindValue(':id', $contract -> getId());
+ $query -> bindValue(':number', $contract -> getNumber());
+ $query -> bindValue(':state', $contract -> getState());
+ $query -> bindValue(':appliances', implode("|", $contract -> getAppliances()));
+ $query -> execute();
+ $query->closeCursor();
+ }
+
+ public function getContract($id) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM contracts WHERE id = :id');
+ $query -> bindValue(':id', $id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $contract = new Contract($result['id'], $result['number'], $result['state'], explode("|", $result['appliances']));
+
+ $query->closeCursor();
+
+ return $contract;
+ }
+
+ public function getContractByNumber($number) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM contracts WHERE number = :number');
+ $query -> bindValue(':number', $number);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $contract = new Contract($result['id'], $result['number'], $result['state'], explode("|", $result['appliances']));
+
+ $query->closeCursor();
+
+ return $contract;
+ }
+
+ public function getContracts() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM contracts');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $contracts = array();
+ foreach ($results as $result) {
+ $contracts[] = new Contract($result['id'], $result['number'], $result['state'], explode("|", $result['appliances']));
+ }
+
+ $query->closeCursor();
+
+ return $contracts;
+ }
+
+ public function removeContract($contract) {
+
+ $query = $this -> pdo -> prepare('DELETE FROM contracts WHERE id = :id');
+ $query -> bindValue('id', $contract -> getId());
+ $query -> execute();
+ }
+
+ }
+
$query = $this -> pdo -> prepare(
'INSERT INTO customers (
ap_id,
- name
+ name,
+ ap_contact
) VALUES (
:ap_id,
- :name
+ :name,
+ :ap_contact
);'
);
$query -> bindValue(':ap_id', $customer -> getAPId());
$query -> bindValue(':name', $customer -> getName());
+ $query -> bindValue(':ap_contact', $customer -> getAPContact());
$query -> execute();
}
$query = $this -> pdo -> prepare(
'UPDATE customers
SET ap_id = :ap_id,
- name = :name
+ name = :name,
+ ap_contact = :ap_contact
WHERE id = :id'
);
$query -> bindValue(':id', $customer -> getId());
$query -> bindValue(':ap_id', $customer -> getAPId());
$query -> bindValue(':name', $customer -> getName());
+ $query -> bindValue(':ap_contact', $customer -> getAPContact());
$query -> execute();
}
$query -> execute();
$result = $query -> fetch(PDO::FETCH_ASSOC);
- $customer = new Customer($result['id'], $result['ap_id'], $result['name']);
+ $customer = new Customer($result['id'], $result['ap_id'], $result['name'], $result['ap_contact']);
$query->closeCursor();
$query -> execute();
$result = $query -> fetch(PDO::FETCH_ASSOC);
- $customer = new Customer($result['id'], $result['ap_id'], $result['name']);
+ $customer = new Customer($result['id'], $result['ap_id'], $result['name'], $result['ap_contact']);
$query->closeCursor();
$results = $query -> fetchAll(PDO::FETCH_ASSOC);
$customers = array();
foreach ($results as $result) {
- $customers[] = new Customer($result['id'], $result['ap_id'], $result['name']);
+ $customers[] = new Customer($result['id'], $result['ap_id'], $result['name'], $result['ap_contact']);
}
$query->closeCursor();
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoExploitantManager extends AbstractPdoManager {
-
- public function createExploitant($exploitant) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO exploitants (nom, reference, instances) VALUES (:nom, :reference, :instances)'
- );
- $query -> bindValue(':nom', $exploitant -> getNom());
- $query -> bindValue(':reference', $exploitant -> getReference());
- $query -> bindValue(':instances', implode("|", $exploitant -> getInstances()));
- $query -> execute();
- $query -> closeCursor();
-
- }
-
- public function updateExploitant($exploitant) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE exploitants SET nom = :nom, reference = :reference, instances = :instances WHERE id = :id'
- );
- $query -> bindValue(':id', $exploitant -> getId());
- $query -> bindValue(':nom', $exploitant -> getNom());
- $query -> bindValue(':reference', $exploitant -> getReference());
- $query -> bindValue(':instances', implode("|", $exploitant -> getInstances()));
- $query -> execute();
- $query -> closeCursor();
- }
-
- public function getExploitant($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM exploitants WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $exploitant = new Exploitant($result['id'], $result['nom'], $result['reference'], explode("|", $result['instances']));
-
- $query->closeCursor();
-
- return $exploitant;
- }
-
- public function getExploitants() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM exploitants');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $exploitants = array();
- foreach ($results as $result) {
- $exploitants[] = new Exploitant($result['id'], $result['nom'], $result['reference'], explode("|", $result['instances']));
- }
-
- $query->closeCursor();
-
- return $exploitants;
- }
-
- public function getExploitantByReference($reference) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM exploitants WHERE reference = :reference');
- $query -> bindValue(':reference', $reference);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $exploitant = new Exploitant($result['id'], $result['nom'], $result['reference'], explode("|", $result['instances']));
-
- $query->closeCursor();
-
- return $exploitant;
- }
-
- public function removeExploitant($exploitant) {
-
- $query = $this -> pdo -> prepare('DELETE FROM exploitant WHERE id = :id');
- $query -> bindValue('id', $exploitant -> getId());
- $query -> execute();
-
- }
-
- }
-
-?>
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoHistoriqueManager extends AbstractPdoManager {
-
- public function createHistorique($historique) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO historiques (installation, alertes, versions) VALUES (NOW(), :alertes, :versions)'
- );
- $query -> bindValue(':alertes', implode("|", $historique -> getAlertes()));
- $query -> bindValue(':versions', implode("|", $historique -> getVersions()));
- $query -> execute();
- $query -> closeCursor();
- }
-
- public function updateHistorique($historique) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE historiques SET
- installation = :installation,
- alertes = :alertes,
- versions = :versions
- WHERE id = :id'
- );
- $query -> bindValue(':id', $historique -> getId());
- $query -> bindValue(':installation', $historique -> getInstallation());
- $query -> bindValue(':alertes', implode("|", $historique -> getAlertes()));
- $query -> bindValue(':versions', implode("|", $historique -> getVersions()));
- $query -> execute();
- $query -> closeCursor();
- }
-
- public function getHistorique($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM historiques WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $historique = new Historique($result['id'], $result['installation'], explode("|", $result['alertes']), explode("|", $result['versions']));
-
- $query->closeCursor();
-
- return $historique;
- }
-
- public function getLastHistorique() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM historiques WHERE id = LAST_INSERT_ID()');
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $historique = new Historique($result['id'], $result['installation'], explode("|", $result['alertes']), explode("|", $result['versions']));
-
- $query->closeCursor();
-
- return $historique;
- }
-
- public function getHistoriques() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM historiques');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $historiques = array();
- foreach ($results as $result) {
- $historiques[] = new Historique($result['id'], $result['installation'], explode("|", $result['alertes']), explode("|", $result['versions']));
- }
-
- $query->closeCursor();
-
- return $historiques;
- }
-
- public function removeHistorique($historique) {
-
- $query = $this -> pdo -> prepare('DELETE FROM historique WHERE id = :id');
- $query -> bindValue('id', $historique -> getId());
- $query -> execute();
-
- }
-
- }
-
-?>
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoInstanceManager extends AbstractPdoManager {
-
- public function createInstance($instance) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO instances (
- nom,
- exploitant,
- reference,
- version,
- historique,
- maintenu,
- fqdn_interne,
- fqdn_externe,
- systeme,
- disques,
- canal
- ) VALUES (
- :nom,
- :exploitant,
- :reference,
- :version,
- :historique,
- :maintenu,
- :fqdn_interne,
- :fqdn_externe,
- :systeme,
- :disques,
- :canal
- )'
- );
- $query -> bindValue(':nom', $instance -> getNom());
- $query -> bindValue(':exploitant', $instance -> getExploitant());
- $query -> bindValue(':reference', $instance -> getReference());
- $query -> bindValue(':version', $instance -> getVersion());
- $query -> bindValue(':historique', $instance -> getHistorique());
- $query -> bindValue(':maintenu', $instance -> estMaintenu());
- $query -> bindValue(':fqdn_interne', $instance -> getFqdnInterne());
- $query -> bindValue(':fqdn_externe', $instance -> getFqdnExterne());
- $query -> bindValue(':systeme', $instance -> getSysteme());
- $query -> bindValue(':disques', $instance -> getDisques());
- $query -> bindValue(':canal', $instance -> getCanal());
- $query -> execute();
- $query -> closeCursor();
-
- }
-
- public function updateInstance($instance) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE instances
- SET nom = :nom,
- exploitant = :exploitant,
- reference = :reference,
- version = :version,
- historique = :historique,
- maintenu = :maintenu,
- fqdn_interne = :fqdn_interne,
- fqdn_externe = :fqdn_externe,
- systeme = :systeme,
- disques = :disques,
- canal = :canal
- WHERE id = :id'
- );
- $query -> bindValue(':id', $instance -> getId());
- $query -> bindValue(':nom', $instance -> getNom());
- $query -> bindValue(':exploitant', $instance -> getExploitant());
- $query -> bindValue(':reference', $instance -> getReference());
- $query -> bindValue(':version', $instance -> getVersion());
- $query -> bindValue(':historique', $instance -> getHistorique());
- $query -> bindValue(':maintenu', $instance -> estMaintenu());
- $query -> bindValue(':fqdn_interne', $instance -> getFqdnInterne());
- $query -> bindValue(':fqdn_externe', $instance -> getFqdnExterne());
- $query -> bindValue(':systeme', $instance -> getSysteme());
- $query -> bindValue(':disques', $instance -> getDisques());
- $query -> bindValue(':canal', $instance -> getCanal());
- $query -> execute();
- $query -> closeCursor();
- }
-
- public function updateInstanceInfos($array) {
- $instance = $this -> getInstanceByReference($array['reference']);
-
- // IF APPLIANCE EXISTS
- if($instance -> getId() > 0) {
-
- // IF APPLIANCE IS MAINTAINED
- if(!$instance -> estMaintenu()) {
- echo "Votre application n'est plus maintenue par nos services, merci de vous renseigner auprès de votre contact ADULLACT Projet pour plus d'informations.";
- } else {
-
- // IN CASE OF MANAGER
- if($array['usager_type'] === "exploitant") {
-
- // GETTING MANAGER OF APPLIANCE
- $exploitantManager = new PdoExploitantManager();
- $exploitant = $exploitantManager -> getExploitantByReference($instance -> getExploitant());
-
- // UPDATING ALL APPLIANCES OF THIS MANAGER
- $array['usager_type'] = "client";
- $instances_id = $exploitant -> getInstances();
- foreach ($instances_id as $instance_id) {
- $array['reference'] = $this -> getInstance($instance_id) -> getReference();
- $this -> updateInstanceInfos($array);
- }
-
- // IN CASE OF CLIENT
- } else if($array['usager_type'] === "client") {
-
- // CHECKING APPLIANCE NAME
- if ($array['produit'] === $instance -> getNom()) {
-
- // IF VERSION DIFFERS FROM DB
- if($array['version'] != $instance -> getVersion()) {
-
- // GETTING PDO MANAGERS
- $versionManager = new PdoVersionManager();
- $produitManager = new PdoProduitManager();
- $alerteManager = new PdoAlerteManager();
-
- // GETTING VERSION ID
- $version_id = $versionManager->getIdByValeurAndProduitId($array['version'], $produitManager->getProduitByNom($array['produit'])->getId());
-
- // NEW WARNING CREATION, VERSION TYPE
- $alerte = new Alerte(null, null, "version",
- "Version declaree ".$array['version']." differente de l'actuelle : ".$instance -> getVersion(), $version_id);
- $alerteManager -> createAlerte($alerte);
-
- // GETTING CHANGELOG OF APPLIANCE
- $historiqueManager = new PdoHistoriqueManager();
- $historique = $historiqueManager -> getHistorique($instance -> getHistorique());
-
- // IF CHANGELOG EXISTS, ADDING NEW WARNING TO IT
- if($historique -> getId() > 0) {
- $alertes = $historique -> getAlertes();
- if((array_search("", $alertes)) !== false) {
- $alertes = array($alerteManager -> getLastAlerte() -> getId());
- } else {
- $alertes[] = $alerteManager -> getLastAlerte() -> getId();
- }
- $historique -> setAlertes($alertes);
- $historiqueManager -> updateHistorique($historique);
-
- // IF CHANGELOG DOES NOT EXIST, CREATING NEW ONE
- } else {
- $historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()), array($alerte -> getVersion()));
- $historiqueManager -> createHistorique($historique);
- $instance -> setHistorique($historiqueManager -> getLastHistorique() -> getId());
- $this -> updateInstance($instance);
- }
- }
-
- // UPDATING APPLIANCE INFORMATION
- $query = $this -> pdo -> prepare(
- 'UPDATE instances SET version = :version WHERE reference = :reference'
- );
- $query -> bindValue(':reference', $array['reference']);
- $query -> bindValue(':version', $array['version']);
- $query -> execute();
- } else {
- echo "Le nom de l'instance est incorrect";
- }
- } else {
- echo "Le type d'usager est inconnu, merci de corriger la configuration.";
- }
- }
-
- // IF APPLIANCE DOES NOT EXISTS
- } else {
-
- // GETTING PDO MANAGERS
- $versionManager = new PdoVersionManager();
- $produitManager = new PdoProduitManager();
- $alerteManager = new PdoAlerteManager();
-
- // GETTING VERSION ID
- $version_id = $versionManager->getIdByValeurAndProduitId($array['version'], $produitManager->getProduitByNom($array['produit'])->getId());
-
- // NEW WARNING CREATION, CREATION TYPE
- $alerteManager = new PdoAlerteManager();
- $alerte = new Alerte(null, null, "creation",
- "Nouvelle instance declaree : ".$array['produit']." ; version : ".$array['version'], $version_id);
- $alerteManager -> createAlerte($alerte);
-
- // NEW CHANGELOG CREATION
- $historiqueManager = new PdoHistoriqueManager();
- $historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()), array($alerte -> getVersion()));
- $historiqueManager -> createHistorique($historique);
-
- // NEW APPLIANCE CREATION
- // TO-DO : MANAGE APPLIANCE CREATION WITH MANAGER TYPE
- $instance = new Instance(
- // ID
- null,
- // PRODUCT
- $array['produit'],
- // MANAGER
- null,
- // REFERENCE
- $array['reference'],
- // VERSION
- $array['version'],
- // CHANGELOG
- $historiqueManager -> getLastHistorique() -> getId(),
- // IS MAINTAINED
- true,
- // FQDNs
- $array['fqdn_interne'],
- $array['fqdn_externe'],
- // OS
- $array['systeme'],
- // UUIDs
- $array['disques'],
- // CHANNEL
- $array['canal']
- );
- $this->createInstance($instance);
- }
-
-
- }
-
- public function getInstance($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM instances WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $instance = new Instance(
- $result['id'],
- $result['nom'],
- $result['exploitant'],
- $result['reference'],
- $result['version'],
- $result['historique'],
- $result['maintenu'],
- $result['fqdn_interne'],
- $result['fqdn_externe'],
- $result['systeme'],
- $result['disques'],
- $result['canal']
- );
-
- $query->closeCursor();
-
- return $instance;
- }
-
- public function getInstanceByReference($reference) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM instances WHERE reference = :reference');
- $query -> bindValue(':reference', $reference);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $instance = new Instance(
- $result['id'],
- $result['nom'],
- $result['exploitant'],
- $result['reference'],
- $result['version'],
- $result['historique'],
- $result['maintenu'],
- $result['fqdn_interne'],
- $result['fqdn_externe'],
- $result['systeme'],
- $result['disques'],
- $result['canal']
- );
-
- $query->closeCursor();
-
- return $instance;
- }
-
- public function getInstances() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM instances');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $instances = array();
- foreach ($results as $result) {
- $instances[] = new Instance(
- $result['id'],
- $result['nom'],
- $result['exploitant'],
- $result['reference'],
- $result['version'],
- $result['historique'],
- $result['maintenu'],
- $result['fqdn_interne'],
- $result['fqdn_externe'],
- $result['systeme'],
- $result['disques'],
- $result['canal']
- );
- }
-
- $query->closeCursor();
-
- return $instances;
- }
-
- public function removeInstance($instance) {
-
- $query = $this -> pdo -> prepare('DELETE FROM instances WHERE id = :id');
- $query -> bindValue('id', $instance -> getId());
- $query -> execute();
-
- }
-
- public function testInformationsAvantUpload($array) {
-
- // CHECKING REFERENCE FORMAT
- $regex = '#^[A-Z]{2}/[A-Z0-9]+_[0-9]{5}_[0-9]{10}$#';
- if (preg_match($regex, $array['reference'])) {
-
- // CHECKING PRODUCT EXISTENCE
- $produitManager = new PdoProduitManager();
- $produits = $produitManager -> getNomsOfProduits();
- if(in_array($array['produit'], $produits)) {
-
- // CHECKING VERSION VALIDITY
- $versionManager = new PdoVersionManager();
- $versions = $versionManager->findValeursOfVersionsByProduitId($produitManager->getProduitByNom($array['produit'])->getId());
- if(in_array($array['version'], $versions)) {
- $retour = "ok";
- } else {
- $retour = "Cette version n'est pas disponible pour ce produit";
- }
- } else {
- $retour = "Le produit n'est pas valide";
- }
- } else {
- $retour = 'Le format de la référence est incorrect.';
- }
- return $retour;
- }
-
- public function desactiverMaintienById($id) {
- $query = $this -> pdo -> prepare(
- 'UPDATE instances SET maintenu = :maintenu WHERE id = :id'
- );
- $query -> bindValue(':id', $id);
- $query -> bindValue(':maintenu', false);
- $query -> execute();
- $query -> closeCursor();
- }
- }
-
-?>
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoProduitManager extends AbstractPdoManager {
-
- public function createProduit($produit) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO produits (nom) VALUES (:nom);'
- );
- $query -> bindValue(':nom', $produit -> getNom());
- $query -> execute();
- }
-
- public function updateProduit($produit) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE produits
- SET nom = :nom
- WHERE id = :id'
- );
- $query -> bindValue(':id', $produit -> getId());
- $query -> bindValue(':nom', $produit -> getNom());
- $query -> execute();
- }
-
- public function getProduit($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM produits WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $produit = new Produit($result['id'], $result['nom']);
-
- $query->closeCursor();
-
- return $produit;
- }
-
- public function getProduitByNom($nom) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM produits WHERE nom = :nom');
- $query -> bindValue(':nom', $nom);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $produit = new Produit($result['id'], $result['nom']);
-
- $query->closeCursor();
-
- return $produit;
- }
-
- public function getProduits() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM produits');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $produits = array();
- foreach ($results as $result) {
- $produits[] = new Produit($result['id'], $result['nom']);
- }
-
- $query->closeCursor();
-
- return $produits;
- }
-
- public function getNomsOfProduits() {
-
- $query = $this -> pdo -> prepare('SELECT nom FROM produits');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $noms = array();
- foreach ($results as $result) {
- $noms[] = $result['nom'];
- }
-
- $query->closeCursor();
-
- return $noms;
- }
-
- public function removeProduit($produit) {
-
- $query = $this -> pdo -> prepare('DELETE FROM produits WHERE id = :id');
- $query -> bindValue('id', $produit -> getId());
- $query -> execute();
- }
-
- }
-
-?>
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class PdoTemplateManager extends AbstractPdoManager {
-
- public function createTemplate($template) {
-
- $query = $this -> pdo -> prepare(
- 'INSERT INTO templates (
- valeur1,
- valeur2,
- valeur3,
- valeur4,
- valeur5
- ) VALUES (
- :valeur1,
- :valeur2,
- :valeur3,
- :valeur4,
- :valeur5
- );'
- );
- $query -> bindValue(':valeur1', $template -> getValeur1());
- $query -> bindValue(':valeur2', $template -> getValeur2());
- $query -> bindValue(':valeur3', $template -> getValeur3());
- $query -> bindValue(':valeur4', $template -> getValeur4());
- $query -> bindValue(':valeur5', $template -> getValeur5());
- $query -> execute();
- }
-
- public function updateTemplate($template) {
-
- $query = $this -> pdo -> prepare(
- 'UPDATE templates
- SET valeur1 = :valeur1,
- valeur2 = :valeur2,
- valeur3 = :valeur3,
- valeur4 = :valeur4,
- valeur5 = :valeur5
- WHERE id = :id'
- );
- $query -> bindValue(':id', $template -> getId());
- $query -> bindValue(':valeur1', $template -> getValeur1());
- $query -> bindValue(':valeur2', $template -> getValeur2());
- $query -> bindValue(':valeur3', $template -> getValeur3());
- $query -> bindValue(':valeur4', $template -> getValeur4());
- $query -> bindValue(':valeur5', $template -> getValeur5());
- $query -> execute();
- }
-
- public function getTemplate($id) {
-
- $query = $this -> pdo -> prepare('SELECT * FROM templates WHERE id = :id');
- $query -> bindValue(':id', $id);
- $query -> execute();
-
- $result = $query -> fetch(PDO::FETCH_ASSOC);
- $template = new Template($result['id'], $result['valeur1'], $result['valeur2'], $result['valeur3'], $result['valeur4'], $result['valeur5']);
-
- $query->closeCursor();
-
- return $template;
- }
-
- public function getTemplates() {
-
- $query = $this -> pdo -> prepare('SELECT * FROM templates');
- $query -> execute();
-
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);
- $templates = array();
- foreach ($results as $result) {
- $templates[] = new Template($result['id'], $result['valeur1'], $result['valeur2'], $result['valeur3'], $result['valeur4'], $result['valeur5']);
- }
-
- $query->closeCursor();
-
- return $templates;
- }
-
- public function removeTemplate($template) {
-
- $query = $this -> pdo -> prepare('DELETE FROM templates WHERE id = :id');
- $query -> bindValue('id', $template -> getId());
- $query -> execute();
- }
-
- }
-
-?>
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class Alerte {
-
- protected $id, $creation, $nature, $message, $version;
-
- /// CONSTRUCTOR
- function __construct($id = null, $creation = null, $nature = null, $message = null, $version = null) {
-
- $this -> id = $id;
- $this -> creation = $creation;
- $this -> nature = $nature;
- $this -> message = $message;
- $this -> version = $version;
-
- }
-
- public function getJSON() {
- return json_encode(get_object_vars($this));
- }
-
- public function getJSONP() {
- $array["id"] = $this -> id;
- $array["creation"] = $this -> creation;
- $array["nature"] = $this -> nature;
- $array["message"] = $this -> message;
- $array["version"] = $this -> version;
-
- return json_encode($array);
- }
-
- /// GETTERS
- public function getId() { return $this -> id; }
- public function getCreation() { return $this->creation; }
- public function getNature() { return $this->nature; }
- public function getMessage() { return $this->message; }
- public function getVersion() { return $this->version; }
-
- /// SETTERS
- public function setId($id) { $this -> id = $id; }
- public function setCreation($creation) { $this->creation = $creation; }
- public function setNature($nature) { $this->nature = $nature; }
- public function setMessage($message) { $this->message = $message; }
- public function setVersion($version) { $this->version = $version; }
-
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class Client {
-
- protected $id, $identifiantAP, $nom;
-
- /// CONSTRUCTOR
- function __construct($id = null, $identifiantAP = null, $nom = null) {
-
- $this -> id = $id;
- $this -> identifiantAP = $identifiantAP;
- $this -> nom = $nom;
-
- }
-
- public function getJSON() {
- return json_encode(get_object_vars($this));
- }
-
- public function getJSONP() {
- $array["id"] = $this -> id;
- $array["identifiantAP"] = $this -> identifiantAP;
- $array["nom"] = $this -> nom;
-
- return json_encode($array);
- }
-
- /// GETTERS
- public function getId() { return $this -> id; }
- public function getIdentifiantAP() { return $this->identifiantAP; }
- public function getNom() { return $this->nom; }
-
- /// SETTERS
- public function setId($id) { $this -> id = $id; }
- public function setIdentifiantAP($identifiantAP) { $this->identifiantAP = $identifiantAP; }
- public function setNom($nom) { $this->nom = $nom; }
-
- }
-
-?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class Contract {
+
+ protected $id, $number, $state, $appliances;
+
+ /// CONSTRUCTOR
+ function __construct($id = null, $number = null, $state = null, $appliances = null) {
+
+ $this -> id = $id;
+ $this -> number = $number;
+ $this -> state = $state;
+ $this -> appliances = $appliances;
+
+ }
+
+ public function getJSON() {
+ return json_encode(get_object_vars($this));
+ }
+
+ public function getJSONP() {
+ $array["id"] = $this -> id;
+ $array["number"] = $this -> number;
+ $array["state"] = $this -> state;
+ $array["appliances"] = $this -> appliances;
+
+ return json_encode($array);
+ }
+
+ /// GETTERS
+ public function getId() { return $this -> id; }
+ public function getNumber() { return $this->number; }
+ public function getState() { return $this->state; }
+ public function getAppliances() { return $this->appliances; }
+
+ /// SETTERS
+ public function setId($id) { $this -> id = $id; }
+ public function setNumber($number) { $this->number = $number; }
+ public function setState($state) { $this->state = $state; }
+ public function setAppliances($appliances) { $this->appliances = $appliances; }
+
+ }
class Customer {
- protected $id, $APId, $name;
+ protected $id, $APId, $name, $APContact;
/// CONSTRUCTOR
- function __construct($id = null, $APId = null, $name = null) {
+ function __construct($id = null, $APId = null, $name = null, $APContact = null) {
$this -> id = $id;
$this -> APId = $APId;
$this -> name = $name;
+ $this -> APContact = $APContact;
}
public function getJSONP() {
$array["id"] = $this -> id;
- $array["aPId"] = $this -> APId;
+ $array["APId"] = $this -> APId;
$array["name"] = $this -> name;
+ $array["APContact"] = $this -> APContact;
return json_encode($array);
}
public function getId() { return $this -> id; }
public function getAPId() { return $this->APId; }
public function getName() { return $this->name; }
+ public function getAPContact() { return $this->APContact; }
/// SETTERS
public function setId($id) { $this -> id = $id; }
public function setAPId($APId) { $this->APId = $APId; }
public function setName($name) { $this->name = $name; }
+ public function setAPContact($APContact) { $this->APContact = $APContact; }
}
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-\r
- require_once('protected/required.php');\r
-\r
- class Exploitant {\r
-\r
- protected $id, $nom, $reference, $instances;\r
- \r
- /// CONSTRUCTOR\r
- function __construct($id = null, $nom = null, $reference = null, $instances = null) {\r
-\r
- $this -> id = $id;\r
- $this -> nom = $nom;\r
- $this -> reference = $reference;\r
- $this -> instances = $instances;\r
-\r
- }\r
-\r
- public function getJSON() {\r
- return json_encode(get_object_vars($this));\r
- }\r
- \r
- public function getJSONP() {\r
- $array["id"] = $this -> id;\r
- $array["nom"] = $this -> nom;\r
- $array["reference"] = $this -> reference;\r
- $array["instances"] = $this -> instances;\r
-\r
- return json_encode($array);\r
- }\r
-\r
- /// GETTERS\r
- public function getId() { return $this -> id; }\r
- public function getNom() { return $this->nom; }\r
- public function getReference() { return $this->reference; }\r
- public function getInstances() { return $this->instances; }\r
- \r
- /// SETTERS\r
- public function setId($id) { $this -> id = $id; }\r
- public function setNom($nom) { $this->nom = $nom; }\r
- public function setReference($reference) { $this->reference = $reference; }\r
- public function setInstances($instances) { $this->instances = $instances; }\r
-\r
- }\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class Historique {
-
- protected $id, $installation, $alertes, $versions;
-
- /// CONSTRUCTOR
- function __construct($id = null, $installation = null, $alertes = null, $versions = null) {
-
- $this -> id = $id;
- $this -> installation = $installation;
- $this -> alertes = $alertes;
- $this -> versions = $versions;
-
- }
-
- public function getJSON() {
- return json_encode(get_object_vars($this));
- }
-
- public function getJSONP() {
- $array["id"] = $this -> id;
- $array["installation"] = $this -> installation;
- $array["alertes"] = $this -> alertes;
- $array["versions"] = $this -> versions;
-
- return json_encode($array);
- }
-
- /// GETTERS
- public function getId() { return $this -> id; }
- public function getInstallation() { return $this->installation; }
- public function getAlertes() { return $this->alertes; }
- public function getVersions() { return $this->versions; }
-
- /// SETTERS
- public function setId($id) { $this -> id = $id; }
- public function setInstallation($installation) { $this->installation = $installation; }
- public function setAlertes($alertes) { $this->alertes = $alertes; }
- public function setVersions($versions) { $this->versions = $versions; }
-
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class Instance {
-
- protected $id, $nom, $exploitant, $reference, $version, $historique, $maintenu, $fqdnInterne, $fqdnExterne, $systeme, $disques, $canal;
-
- /// CONSTRUCTOR
- function __construct($id = null, $nom = null, $exploitant = null, $reference = null, $version = null, $historique = null,
- $maintenu = null, $fqdnInterne = null, $fqdnExterne = null, $systeme = null, $disques = null, $canal = null) {
-
- $this -> id = $id;
- $this -> nom = $nom;
- // MANAGER REFERENCE
- $this -> exploitant = $exploitant;
- // APPLIANCE REFERENCE
- $this -> reference = $reference;
- // VERSION
- $this -> version = $version;
- // CHANGELOG ID
- $this -> historique = $historique;
- // APPLIANCE MAINTENANCE STATE
- $this -> maintenu = $maintenu;
- // FQDNs
- $this -> fqdnInterne = $fqdnInterne;
- $this -> fqdnExterne = $fqdnExterne;
- // OS
- $this -> systeme = $systeme;
- // UUIDS
- $this -> disques = $disques;
- // CHANNEL
- $this -> canal = $canal;
- }
-
- public function getJSON() {
- return json_encode(get_object_vars($this));
- }
-
- public function getJSONP() {
- $array["id"] = $this -> id;
- $array["nom"] = $this -> nom;
- $array["exploitant"] = $this -> exploitant;
- $array["reference"] = $this -> reference;
- $array["version"] = $this -> version;
- $array["historique"] = $this -> historique;
- $array["maintenu"] = $this -> maintenu;
- $array["fqdnInterne"] = $this -> fqdnInterne;
- $array["fqdnExterne"] = $this -> fqdnExterne;
- $array["systeme"] = $this -> systeme;
- $array["disques"] = $this -> disques;
- $array["canal"] = $this -> canal;
-
- return json_encode($array);
- }
-
- /// GETTERS
- public function getId() { return $this -> id; }
- public function getNom() { return $this->nom; }
- public function getExploitant() { return $this->exploitant; }
- public function getReference() { return $this->reference; }
- public function getVersion() { return $this->version; }
- public function getHistorique() { return $this->historique; }
- public function estMaintenu() { return $this->maintenu; }
- public function getFqdnInterne() { return $this->fqdnInterne; }
- public function getFqdnExterne() { return $this->fqdnExterne; }
- public function getSysteme() { return $this->systeme; }
- public function getDisques() { return $this->disques; }
- public function getCanal() { return $this->canal; }
-
- /// SETTERS
- public function setId($id) { $this -> id = $id; }
- public function setNom($nom) { $this->nom = $nom; }
- public function setExploitant($exploitant) { $this->exploitant = $exploitant; }
- public function setReference($reference) { $this->reference = $reference; }
- public function setVersion($version) { $this->version = $version; }
- public function setHistorique($historique) { $this->historique = $historique; }
- public function setMaintenu($maintenu) { $this->maintenu = $maintenu; }
- public function setFqdnInterne($fqdnInterne) { $this->fqdnInterne = $fqdnInterne; }
- public function setFqdnExterne($fqdnExterne) { $this->fqdnExterne = $fqdnExterne; }
- public function setSysteme($systeme) { $this->systeme = $systeme; }
- public function setDisques($disques) { $this->disques = $disques; }
- public function setCanal($canal) { $this->canal = $canal; }
-
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class Produit {
-
- protected $id, $nom;
-
- /// CONSTRUCTOR
- function __construct($id = null, $nom = null) {
-
- $this -> id = $id;
- $this -> nom = $nom;
-
- }
-
- public function getJSON() {
- return json_encode(get_object_vars($this));
- }
-
- public function getJSONP() {
- $array["id"] = $this -> id;
- $array["nom"] = $this -> nom;
-
- return json_encode($array);
- }
-
- /// GETTERS
- public function getId() { return $this -> id; }
- public function getNom() { return $this->nom; }
-
- /// SETTERS
- public function setId($id) { $this -> id = $id; }
- public function setNom($nom) { $this->nom = $nom; }
-
- }
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
- require_once('protected/required.php');
-
- class Template {
-
- protected $id, $valeur1, $valeur2, $valeur3, $valeur4, $valeur5;
-
- /// CONSTRUCTOR
- function __construct($id = null, $valeur1 = null, $valeur2 = null, $valeur3 = null, $valeur4 = null, $valeur5 = null) {
-
- $this -> id = $id;
- $this -> valeur1 = $valeur1;
- $this -> valeur2 = $valeur2;
- $this -> valeur3 = $valeur3;
- $this -> valeur4 = $valeur4;
- $this -> valeur5 = $valeur5;
-
- }
-
- public function getJSON() {
- return json_encode(get_object_vars($this));
- }
-
- public function getJSONP() {
- $array["id"] = $this -> id;
- $array["valeur1"] = $this -> valeur1;
- $array["valeur2"] = $this -> valeur2;
- $array["valeur3"] = $this -> valeur3;
- $array["valeur4"] = $this -> valeur4;
- $array["valeur5"] = $this -> valeur5;
-
- return json_encode($array);
- }
-
- /// GETTERS
- public function getId() { return $this -> id; }
- public function getValeur1() { return $this->valeur1; }
- public function getValeur2() { return $this->valeur2; }
- public function getValeur3() { return $this->valeur3; }
- public function getValeur4() { return $this->valeur4; }
- public function getValeur5() { return $this->valeur5; }
-
- /// SETTERS
- public function setId($id) { $this -> id = $id; }
- public function setValeur1($valeur1) { $this->valeur1 = $valeur1; }
- public function setValeur2($valeur2) { $this->valeur2 = $valeur2; }
- public function setValeur3($valeur3) { $this->valeur3 = $valeur3; }
- public function setValeur4($valeur4) { $this->valeur4 = $valeur4; }
- public function setValeur5($valeur5) { $this->valeur5 = $valeur5; }
-
- }
-
-?>
\ No newline at end of file
function api_get() {\r
$managerManager = new PdoManagerManager();\r
$customerManager = new PdoCustomerManager();\r
+ $contractManager = new PdoContractManager();\r
$applianceManager = new PdoApplianceManager();\r
$changelogManager = new PdoChangelogManager();\r
$warningManager = new PdoWarningManager();\r
'name',\r
'billing_address_street',\r
'phone_office',\r
- 'officenumber_c'\r
+ 'officenumber_c',\r
+ 'assigned_user_id'\r
);\r
$customer_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos));\r
\r
\r
// CHECKING RESULTS\r
if(isset($customer_info)) {\r
- $cusomerAPId = $customer_info->name_value_list->officenumber_c->value;\r
+ $customerAPId = $customer_info->name_value_list->officenumber_c->value;\r
$customerName = $customer_info->name_value_list->name->value;\r
\r
+ // GETTING LINKED AP CONTACT ON SUGAR\r
+ $APContactSugarId = $customer_info->name_value_list->assigned_user_id->value;\r
+ $moduleName = 'Users';\r
+ $requestedInfos = array(\r
+ 'email1'\r
+ );\r
+ $sqlWhereClause = "users.id = '".$APContactSugarId."'";\r
+ $contact_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
+ $contactEmail = $contact_infos->entry_list[0]->name_value_list->email1->value;\r
+\r
// IF AP ID IS NOT EMPTY\r
- if(isset($cusomerAPId) && $cusomerAPId != "") {\r
+ if(isset($customerAPId) && $customerAPId != "") {\r
\r
// GETTING CUSTOMER IN DB\r
- $customer = $customerManager -> getCustomerByAPId($cusomerAPId);\r
+ $customer = $customerManager -> getCustomerByAPId($customerAPId);\r
\r
// IF CUSTOMER EXISTS, UPDATING INFORMATION\r
if(isset($customer) && $customer->getId() > 0) {\r
- $customer -> setAPId($cusomerAPId);\r
+ $customer -> setAPId($customerAPId);\r
$customer -> setName($customerName);\r
+ $customer -> setAPContact($contactEmail);\r
$customerManager -> updateCustomer($customer);\r
\r
// IF CUSTOMER DOES NOT EXIST, CREATING A NEW ONE\r
} else {\r
- $customer = new Customer(null, $cusomerAPId, $customerName);\r
+ $customer = new Customer(null, $customerAPId, $customerName, $contactEmail);\r
$customerManager -> createCustomer($customer);\r
}\r
}\r
\r
break;\r
\r
+ case 'synchronize_contracts_info' :\r
+\r
+ // LOGIN\r
+ $sugarConnector = new SugarConnector();\r
+ $sugarConnector -> login('test', 'test');\r
+\r
+ // GETTING MAINTENANCE CONTRACTS ON SUGAR\r
+ $moduleName = 'maint_contrat_maintenance';\r
+ $requestedInfos = array(\r
+ 'name',\r
+ 'etat_contrat_c'\r
+ );\r
+ $contracts_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos));\r
+\r
+ foreach($contracts_infos->entry_list as $contract_infos) {\r
+\r
+ // CHECKING RESULTS\r
+ if(isset($contract_infos)) {\r
+ $contractNumber = $contract_infos->name_value_list->name->value;\r
+ $contractState = $contract_infos->name_value_list->etat_contrat_c->value;\r
+\r
+ // IF CONTRACT NUMBER IS NOT EMPTY\r
+ if(isset($contractNumber) && $contractNumber != "") {\r
+\r
+ // GETTING CONTRACT IN DB\r
+ $contract = $contractManager -> getContractByNumber($contractNumber);\r
+\r
+ // IF CONTRACT EXISTS, UPDATING INFORMATION\r
+ if(isset($contract) && $contract->getId() > 0) {\r
+ $contract -> setState($contractState);\r
+\r
+ // IF THE CONTRACT IS NOT VALID ANYMORE\r
+ if($contractState === "^resilie^") {\r
+\r
+ // EVERY APPLIANCE LINKED TO IT LOSES ITS MAINTENANCE\r
+ $contractAppliancesId = $contract -> getAppliances();\r
+ if(isset($contractAppliancesId) && count($contractAppliancesId) > 0) {\r
+ foreach($contractAppliancesId as $contractApplianceId) {\r
+ $contractAppliance = $applianceManager -> getAppliance($contractApplianceId);\r
+ $contractAppliance -> setMaintained(false);\r
+ $applianceManager -> updateAppliance($contractAppliance);\r
+ }\r
+ }\r
+\r
+ // SAVING CHANGES\r
+ $contractManager -> updateContract($contract);\r
+ }\r
+\r
+ // IF CONTRACT DOES NOT EXIST, CREATING A NEW ONE\r
+ } else {\r
+ $contract = new Contract(null, $contractNumber, $contractState);\r
+ $contractManager -> createContract($contract);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ break;\r
+\r
case 'check_appliances_infos' :\r
\r
// LOGIN\r
$customerAPId = substr($applianceReferenceArray[1],0,-11);\r
// CONTRACT\r
$contractReference = $productAcronym."/".$customerAPId."/20".substr($applianceReferenceArray[1],19,-4);\r
+ $contract = $contractManager->getContractByNumber($contractReference);\r
// OPPORTUNITY\r
$opportunityReference = $productAcronym."/".substr($customerAPId,0,-6);\r
\r
$applianceSugarId = $appliance_infos->entry_list[0]->id;\r
}\r
\r
- // GETTING THE MAINTENANCE CONTRACT\r
- $moduleName = 'maint_contrat_maintenance';\r
- $requestedInfos = array(\r
- 'name',\r
- 'etat_contrat_c'\r
- );\r
- $sqlWhereClause = "maint_contrat_maintenance.name = '".$contractReference."'";\r
- $contract_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
- if(isset($contract_infos->entry_list[0])) {\r
- $contractSugarId = $contract_infos->entry_list[0]->id;\r
- }\r
-\r
// QUESTIONING ITS VALIDITY STATE\r
- $contractState = $contract_infos->entry_list[0]->name_value_list->etat_contrat_c->value;\r
+ $contractState = $contract->getState();\r
\r
// IF NOT VALID OR DOES NOT EXIST, ERROR\r
- if(!isset($contractSugarId) || $contractState != "^encours^") {\r
+ if(!isset($contract) || ($contractState != "^encours^" && $contractState != "^signe^" && $contractState != "^signe_maj_version^")) {\r
echo "Erreur : Contrat de maintenance inexistant ou invalide pour cette appliance<br/>";\r
} else {\r
\r
$appliance_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
$applianceSugarId = $appliance_infos->id;\r
\r
- // LINKING IT TO MAINTENANCE CONTRACT\r
- if(isset($applianceSugarId)) {\r
+ // GETTING THE MAINTENANCE CONTRACT SUGAR ID\r
+ $moduleName = 'maint_contrat_maintenance';\r
+ $requestedInfos = array('id');\r
+ $sqlWhereClause = "maint_contrat_maintenance.name = '".$contractReference."'";\r
+ $contract_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
+ if(isset($contract_infos->entry_list[0])) {\r
+ $contractSugarId = $contract_infos->entry_list[0]->id;\r
+ }\r
+\r
+ // LINKING IT TO MAINTENANCE CONTRACT IN SUGAR\r
+ if(isset($applianceSugarId) && isset($contractSugarId)) {\r
$moduleName = 'maint_contrat_maintenance';\r
$parameters = array(\r
'link_name' => 'maint_contrat_maintenance_allo_instances_1',\r
);\r
$sugarConnector -> createRelationship($moduleName, $parameters);\r
}\r
+\r
+ // LINKING IT TO MAINTENANCE CONTRACT IN DB\r
+ $contractAppliances = $contract -> getAppliances();\r
+ $contractAppliances[] = $appliance -> getId();\r
+ $contractManager -> updateContract($contract);\r
}\r
\r
// GETTING OPPORTUNITIES OF APPLIANCE\r
$parameters = array(\r
'name' => $opportunityReference,\r
'type_exploitation_c' => $appliance->getChannel(),\r
- // TO-DO : GET THE INSTALLATION DATE FROM CHANGELOG\r
- /*'date_opened_c' => $changelog->getInstallation(),*/\r
+ 'date_opened_c' => $changelogManager->findFirstVersionDeclarationForId($appliance->getChangelog()),\r
'systeme_d_exploitation_c' => $appliance->getOs(),\r
// TO-DO : CHANGE THIS VALUE FOR EACH MANAGEMENT TYPE\r
'liste_hebergement_c' => 'CLIENT',\r
<?php\r
\r
- header('Content-Type: text/html; charset=utf-8');\r
+header('Content-Type: text/html; charset=utf-8');\r
\r
- // MODELS\r
- require_once('classes/models/Manager.class.php');\r
- require_once('classes/models/Appliance.class.php');\r
- require_once('classes/models/Changelog.class.php');\r
- require_once('classes/models/Warning.class.php');\r
- require_once('classes/models/Product.class.php');\r
- require_once('classes/models/Version.class.php');\r
- require_once('classes/models/Customer.class.php');\r
+// MODELS\r
+require_once('classes/models/Manager.class.php');\r
+require_once('classes/models/Appliance.class.php');\r
+require_once('classes/models/Changelog.class.php');\r
+require_once('classes/models/Warning.class.php');\r
+require_once('classes/models/Product.class.php');\r
+require_once('classes/models/Version.class.php');\r
+require_once('classes/models/Customer.class.php');\r
+require_once('classes/models/Contract.class.php');\r
\r
- // MANAGERS\r
- require_once('classes/manager/pdo/AbstractPdoManager.php');\r
- require_once('classes/manager/pdo/PdoManagerManager.php');\r
- require_once('classes/manager/pdo/PdoApplianceManager.php');\r
- require_once('classes/manager/pdo/PdoChangelogManager.php');\r
- require_once('classes/manager/pdo/PdoWarningManager.php');\r
- require_once('classes/manager/pdo/PdoProductManager.php');\r
- require_once('classes/manager/pdo/PdoVersionManager.php');\r
- require_once('classes/manager/pdo/PdoCustomerManager.php');\r
+// MANAGERS\r
+require_once('classes/manager/pdo/AbstractPdoManager.php');\r
+require_once('classes/manager/pdo/PdoManagerManager.php');\r
+require_once('classes/manager/pdo/PdoApplianceManager.php');\r
+require_once('classes/manager/pdo/PdoChangelogManager.php');\r
+require_once('classes/manager/pdo/PdoWarningManager.php');\r
+require_once('classes/manager/pdo/PdoProductManager.php');\r
+require_once('classes/manager/pdo/PdoVersionManager.php');\r
+require_once('classes/manager/pdo/PdoCustomerManager.php');\r
+require_once('classes/manager/pdo/PdoContractManager.php');\r
\r
- // SUGAR CONNECTOR\r
- require_once('classes/SugarHttpClient.php');\r
- require_once('classes/SugarConnector.class.php');\r
-?>
\ No newline at end of file
+// SUGAR CONNECTOR\r
+require_once('classes/SugarHttpClient.php');\r
+require_once('classes/SugarConnector.class.php');\r