// 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'));