<?php\r
\r
function api_get() {\r
- $exploitantManager = new PdoExploitantManager();\r
- $clientManager = new PdoClientManager();\r
- $instanceManager = new PdoInstanceManager();\r
- $historiqueManager = new PdoHistoriqueManager();\r
- $alerteManager = new PdoAlerteManager();\r
+ $managerManager = new PdoManagerManager();\r
+ $customerManager = new PdoCustomerManager();\r
+ $applianceManager = new PdoApplianceManager();\r
+ $changelogManager = new PdoChangelogManager();\r
+ $warningManager = new PdoWarningManager();\r
$versionManager = new PdoVersionManager();\r
+ $productManager = new PdoProductManager();\r
\r
if($_GET['action']) {\r
switch ($_GET['action']) {\r
- case 'get_exploitant' :\r
- echo $exploitantManager -> getExploitant($_GET['id']) -> getJSONP();\r
+ case 'get_manager' :\r
+ echo $managerManager -> getManager($_GET['id']) -> getJSONP();\r
break;\r
\r
- case 'get_exploitants' :\r
- $exploitants = $exploitantManager -> getExploitants();\r
- if (!empty($exploitants)) {\r
+ case 'get_managers' :\r
+ $managers = $managerManager -> getManagers();\r
+ if (!empty($managers)) {\r
$i = 0;\r
echo '[';\r
- foreach ($exploitants as $exploitant) {\r
- echo $exploitant -> getJSON();\r
- if ($i != sizeof($exploitants) - 1) {\r
+ foreach ($managers as $manager) {\r
+ echo $manager -> getJSON();\r
+ if ($i != sizeof($managers) - 1) {\r
echo ',';\r
}\r
$i++;\r
}\r
break;\r
\r
- case 'get_instance' :\r
- echo $instanceManager -> getInstance($_GET['id']) -> getJSON();\r
+ case 'get_appliance' :\r
+ echo $applianceManager -> getAppliance($_GET['id']) -> getJSON();\r
break;\r
\r
- case 'get_instances' :\r
- $instances = $instanceManager -> getInstances();\r
- if (!empty($instances)) {\r
+ case 'get_appliances' :\r
+ $appliances = $applianceManager -> getAppliances();\r
+ if (!empty($appliances)) {\r
$i = 0;\r
echo '[';\r
- foreach ($instances as $instance) {\r
- echo $instance -> getJSON();\r
- if ($i != sizeof($instances) - 1) {\r
+ foreach ($appliances as $appliance) {\r
+ echo $appliance -> getJSON();\r
+ if ($i != sizeof($appliances) - 1) {\r
echo ',';\r
}\r
$i++;\r
}\r
break;\r
\r
- case 'disable_maintien' :\r
- $instanceManager -> desactiverMaintienById($_GET['id']);\r
+ case 'disable_maintained' :\r
+ $applianceManager -> disableMaintainedById($_GET['id']);\r
break;\r
\r
- case 'get_historique' :\r
- echo $historiqueManager -> getHistorique($_GET['id']) -> getJSON();\r
+ case 'get_changelog' :\r
+ echo $changelogManager -> getChangelog($_GET['id']) -> getJSON();\r
break;\r
\r
- case 'get_historiques' :\r
- $historiques = $historiqueManager -> getHistoriques();\r
- if (!empty($historiques)) {\r
+ case 'get_changelogs' :\r
+ $changelogs = $changelogManager -> getChangelogs();\r
+ if (!empty($changelogs)) {\r
$i = 0;\r
echo '[';\r
- foreach ($historiques as $historique) {\r
- echo $historique -> getJSONP();\r
- if ($i != sizeof($historiques) - 1) {\r
+ foreach ($changelogs as $changelog) {\r
+ echo $changelog -> getJSONP();\r
+ if ($i != sizeof($changelogs) - 1) {\r
echo ',';\r
}\r
$i++;\r
}\r
break;\r
\r
- case 'get_alerte' :\r
- echo $alerteManager -> getAlerte($_GET['id']) -> getJSON();\r
+ case 'get_warning' :\r
+ echo $warningManager -> getWarning($_GET['id']) -> getJSON();\r
break;\r
\r
- case 'get_alertes' :\r
- $alertes = $alerteManager -> getAlertes();\r
- if (!empty($alertes)) {\r
+ case 'get_warnings' :\r
+ $warnings = $warningManager -> getWarnings();\r
+ if (!empty($warnings)) {\r
$i = 0;\r
echo '[';\r
- foreach ($alertes as $alerte) {\r
- echo $alerte -> getJSON();\r
- if ($i != sizeof($alertes) - 1) {\r
+ foreach ($warnings as $warning) {\r
+ echo $warning -> getJSON();\r
+ if ($i != sizeof($warnings) - 1) {\r
echo ',';\r
}\r
$i++;\r
}\r
break;\r
\r
- case 'synchroniser_infos_clients' :\r
+ case 'synchronize_customers_info' :\r
\r
// LOGIN\r
$sugarConnector = new SugarConnector();\r
'phone_office',\r
'officenumber_c'\r
);\r
- $client_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos));\r
+ $customer_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos));\r
\r
- foreach($client_infos->entry_list as $client_info) {\r
+ foreach($customer_infos->entry_list as $customer_info) {\r
\r
// CHECKING RESULTS\r
- if(isset($client_info)) {\r
- $identifiantAP = $client_info->name_value_list->officenumber_c->value;\r
- $nom = $client_info->name_value_list->name->value;\r
+ if(isset($customer_info)) {\r
+ $cusomerAPId = $customer_info->name_value_list->officenumber_c->value;\r
+ $customerName = $customer_info->name_value_list->name->value;\r
\r
// IF AP ID IS NOT EMPTY\r
- if(isset($identifiantAP) && $identifiantAP != "") {\r
+ if(isset($cusomerAPId) && $cusomerAPId != "") {\r
\r
// GETTING CUSTOMER IN DB\r
- $client = $clientManager -> getClientByIdentifiantAP($identifiantAP);\r
+ $customer = $customerManager -> getCustomerByAPId($cusomerAPId);\r
\r
// IF CUSTOMER EXISTS, UPDATING INFORMATION\r
- if(isset($client) && $client->getId() > 0) {\r
- $client -> setIdentifiantAP($identifiantAP);\r
- $client -> setNom($nom);\r
- $clientManager -> updateClient($client);\r
+ if(isset($customer) && $customer->getId() > 0) {\r
+ $customer -> setAPId($cusomerAPId);\r
+ $customer -> setName($customerName);\r
+ $customerManager -> updateCustomer($customer);\r
\r
// IF CUSTOMER DOES NOT EXIST, CREATING A NEW ONE\r
} else {\r
- $client = new Client(null, $identifiantAP, $nom);\r
- $clientManager -> createClient($client);\r
+ $customer = new Customer(null, $cusomerAPId, $customerName);\r
+ $customerManager -> createCustomer($customer);\r
}\r
}\r
}\r
\r
break;\r
\r
- case 'check_synchro_info_version' :\r
+ case 'check_appliances_infos' :\r
\r
// LOGIN\r
$sugarConnector = new SugarConnector();\r
'id',\r
'name'\r
);\r
- $instances_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos));\r
+ $appliances_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos));\r
\r
- foreach($instances_infos->entry_list as $instance_infos) {\r
+ foreach($appliances_infos->entry_list as $appliance_infos) {\r
\r
// IF APPLIANCE EXISTS IN SUGAR\r
- if(isset($instance_infos)) {\r
- $refInstance = $instance_infos->name_value_list->name->value;\r
- $refInstanceArray = explode("/",$refInstance);\r
- $refClient = substr($refInstanceArray[1],0,-11);\r
- $refInstall = $refInstanceArray[0]."/".substr($refClient,0,-6);\r
+ if(isset($appliance_infos)) {\r
+ $applianceReference = $appliance_infos->name_value_list->name->value;\r
+ $applianceReferenceArray = explode("/",$applianceReference);\r
+ $customerAPId = substr($applianceReferenceArray[1],0,-11);\r
+ $opportunityReference = $applianceReferenceArray[0]."/".substr($customerAPId,0,-6);\r
\r
// GETTING APPLIANCE IN DB\r
- $instance = $instanceManager -> getInstanceByReference($refInstance);\r
+ $appliance = $applianceManager -> getApplianceByReference($applianceReference);\r
\r
// IF APPLIANCE EXISTS ON BOTH SIDES, COMPARING INFORMATIONS\r
- if(isset($instance) && $instance->getId() > 0) {\r
+ if(isset($appliance) && $appliance->getId() > 0) {\r
\r
// GETTING CHANGELOG OF APPLIANCE\r
- $historique = $historiqueManager -> getHistorique($instance -> getHistorique());\r
- $versions = $historique -> getVersions();\r
+ $changelog = $changelogManager -> getChangelog($appliance -> getChangelog());\r
+ $versions = $changelog -> getVersions();\r
\r
// CHECKING OPPORTUNITY EXISTENCE FOR EACH VERSION OF CHANGELOG\r
foreach($versions as $version) {\r
\r
// GETTING VALUE OF EACH VERSION OF CHANGELOG, AND ITS DECLARATION DATE\r
$versionArray = explode(';',$version);\r
- if(isset($versionArray[1])) {\r
- $versionId = $versionArray[0];\r
- $declaration = $versionArray[1];\r
- } else {\r
- $versionId = $version;\r
- $declaration = $historique -> getInstallation();\r
- }\r
- $versionValeur = $versionManager -> getVersion($versionId) -> getValeur();\r
- $refVersion = $refInstanceArray[0].' '.$versionValeur;\r
+ $versionId = $versionArray[0];\r
+ $versionDeclaration = $versionArray[1];\r
+ $versionValue = $versionManager -> getVersion($versionId) -> getValue();\r
+ $versionReference = $applianceReferenceArray[0].' '.$versionValue;\r
\r
// GETTING VERSION ID ON SUGAR\r
$moduleName = 'adul__Produits';\r
'id',\r
'name'\r
);\r
- $sqlWhereClause = "adul__produits.name = '".$refVersion."'";\r
+ $sqlWhereClause = "adul__produits.name = '".$versionReference."'";\r
$version_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
if(isset($version_infos->entry_list[0])) {\r
- $idVersion = $version_infos->entry_list[0]->id;\r
+ $versionSugarId = $version_infos->entry_list[0]->id;\r
}\r
\r
// GETTING OPPORTUNITIES LINKED TO THE VERSION IN SUGAR\r
- if(isset($idVersion)) {\r
+ if(isset($versionSugarId)) {\r
$moduleName = 'adul__Produits';\r
$parameters = array(\r
"link_name" => "adul__prits_opportunities",\r
- "primary_module_id" => $idVersion,\r
+ "primary_module_id" => $versionSugarId,\r
);\r
$requestedInfos = array(\r
'id',\r
'name',\r
'date_opened_c'\r
);\r
- $sqlWhereClause = "opportunities.name = '".$refInstall."'";\r
+ $sqlWhereClause = "opportunities.name = '".$opportunityReference."'";\r
$result = json_decode($sugarConnector -> getRelationships($moduleName, $parameters, $requestedInfos, $sqlWhereClause));\r
\r
// COMPARING INFORMATIONS IN ORDER TO FIND A CONCORDANCE : DATES, CHANNEL, et cetera\r
- $testRecherche = false;\r
- foreach($result->entry_list as $fiche_install_info) {\r
+ $opportunityFoundInSugar = false;\r
+ foreach($result->entry_list as $opportunity_info) {\r
\r
// IF OPPORTUNITY EXISTS IN SUGAR\r
- if(isset($fiche_install_info->id)) {\r
- if($fiche_install_info->name_value_list->date_opened_c->value == $declaration) {\r
- $testRecherche = true;\r
+ if(isset($opportunity_info->id)) {\r
+ if($opportunity_info->name_value_list->date_opened_c->value == $versionDeclaration) {\r
+ $opportunityFoundInSugar = true;\r
break;\r
}\r
}\r
}\r
\r
// IF NO OPPORTUNITY IS FOUND FOR THE VERSION\r
- if(!$testRecherche) {\r
+ if(!$opportunityFoundInSugar) {\r
\r
// CREATING NEW WARNING, VERSION TYPE\r
- $alerte = new Alerte(null, $declaration, "version",\r
- "Version declaree ".$versionValeur." n'a pas de fiche d'installation sur Sugar pour cette instance.", $versionId);\r
- $alerteManager -> createAlerte($alerte);\r
+ $warningMessage = "Version declaree ".$versionValue." n'a pas de fiche d'installation sur Sugar pour cette instance applicative.";\r
+ $warning = new Warning(null, $versionDeclaration, "synchro", $warningMessage, $versionId);\r
+ $warningManager -> createWarning($warning);\r
\r
// GETTING APPLIANCE CHANGELOG\r
- $historiqueManager = new PdoHistoriqueManager();\r
- $historique = $historiqueManager -> getHistorique($instance -> getHistorique());\r
+ $changelogManager = new PdoChangelogManager();\r
+ $changelog = $changelogManager -> getChangelog($appliance -> getChangelog());\r
\r
// ADDING WARNING TO CHANGELOG\r
- $alertes = $historique -> getAlertes();\r
- if((array_search("", $alertes)) !== false) {\r
- $alertes = array($alerteManager -> getLastAlerte() -> getId());\r
+ $warnings = $changelog -> getWarnings();\r
+ if((array_search("", $warnings)) !== false) {\r
+ $warnings = array($warningManager -> getLastWarning() -> getId());\r
} else {\r
- $alertes[] = $alerteManager -> getLastAlerte() -> getId();\r
+ $warnings[] = $warningManager -> getLastWarning() -> getId();\r
}\r
- $historique -> setAlertes($alertes);\r
- $historiqueManager -> updateHistorique($historique);\r
+ $changelog -> setWarnings($warnings);\r
+ $changelogManager -> updateChangelog($changelog);\r
}\r
}\r
}\r
} else {\r
- echo "Instance d'application existante sur Sugar introuvable sur ALLO Serveur.";\r
+ echo "Instance applicative existante sur Sugar introuvable sur ALLO Serveur.";\r
}\r
}\r
}\r
break;\r
\r
- case 'create_fiche_installation' :\r
-\r
- // GETTING REFERENCES\r
- $refInstance = str_replace("\\", "", $_GET['nom']);\r
- $instance = $instanceManager -> getInstanceByReference($refInstance);\r
- $historique = $historiqueManager -> getHistorique($instance -> getHistorique());\r
- $refInstanceArray = explode("/",$refInstance);\r
- $refClient = substr($refInstanceArray[1],0,-11);\r
- $refContrat = $refInstanceArray[0]."/".$refClient."/20".substr($refInstanceArray[1],19,-4);\r
- $refInstall = $refInstanceArray[0]."/".substr($refClient,0,-6);\r
- $refVersion = $refInstanceArray[0].' '.$instance -> getVersion();\r
-\r
- /*\r
- echo "REF INSTANCE = ".$refInstance."<br/>";\r
- echo "REF CLIENT = ".$refClient."<br/>";\r
- echo "REF CONTRAT = ".$refContrat."<br/>";\r
- echo "REF INSTALL = ".$refInstall."<br/>";\r
- echo "REF VERSION = ".$refVersion."<br/>";\r
- */\r
+ case 'create_opportunity' :\r
+\r
+ // GETTING REFERENCES AND OBJECTS :\r
+ // APPLIANCE\r
+ $applianceReference = str_replace("\\", "", $_GET['appliance_reference']);\r
+ $appliance = $applianceManager -> getApplianceByReference($applianceReference);\r
+ $applianceReferenceArray = explode("/",$applianceReference);\r
+ // PRODUCT\r
+ $product = $productManager -> getProduct($appliance -> getProduct());\r
+ $productAcronym = $applianceReferenceArray[0];\r
+ // VERSION\r
+ $lastVersion = $changelogManager -> findLastVersion();\r
+ $lastVersionDeclaration = $changelogManager -> findLastVersionDeclaration();\r
+ $lastVersionReference = $productAcronym.' '.$lastVersion -> getValue();\r
+ // CUSTOMER\r
+ $customerAPId = substr($applianceReferenceArray[1],0,-11);\r
+ // CONTRACT\r
+ $contractReference = $productAcronym."/".$customerAPId."/20".substr($applianceReferenceArray[1],19,-4);\r
+ // OPPORTUNITY\r
+ $opportunityReference = $productAcronym."/".substr($customerAPId,0,-6);\r
\r
// LOGIN\r
$sugarConnector = new SugarConnector();\r
// GETTING APPLIANCE IN SUGAR\r
$moduleName = 'allo_Instances';\r
$requestedInfos = array('name');\r
- $sqlWhereClause = "allo_instances.name = '".$refInstance."'";\r
- $instance_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
- if(isset($instance_infos->entry_list[0])) {\r
- $idInstance = $instance_infos->entry_list[0]->id;\r
+ $sqlWhereClause = "allo_instances.name = '".$applianceReference."'";\r
+ $appliance_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
+ if(isset($appliance_infos->entry_list[0])) {\r
+ $applianceSugarId = $appliance_infos->entry_list[0]->id;\r
}\r
\r
// GETTING THE MAINTENANCE CONTRACT\r
'name',\r
'etat_contrat_c'\r
);\r
- $sqlWhereClause = "maint_contrat_maintenance.name = '".$refContrat."'";\r
- $contrat_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
- if(isset($contrat_infos->entry_list[0])) {\r
- $idContrat = $contrat_infos->entry_list[0]->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
// QUESTIONING ITS VALIDITY STATE\r
- $etatContrat = $contrat_infos->entry_list[0]->name_value_list->etat_contrat_c->value;\r
+ $contractState = $contract_infos->entry_list[0]->name_value_list->etat_contrat_c->value;\r
\r
// IF NOT VALID OR DOES NOT EXIST, ERROR\r
- if(!isset($idContrat) || $etatContrat != "^encours^") {\r
- echo "Erreur : Contrat de maintenance inexistant ou invalide pour cette instance<br/>";\r
+ if(!isset($contractSugarId) || $contractState != "^encours^") {\r
+ echo "Erreur : Contrat de maintenance inexistant ou invalide pour cette appliance<br/>";\r
} else {\r
\r
// IF APPLIANCE DOES NOT EXIST, CREATING NEW ONE\r
- if(!isset($idInstance)) {\r
- // CRÉATION D'INSTANCE\r
+ if(!isset($applianceSugarId)) {\r
$moduleName = 'allo_Instances';\r
$parameters = array(\r
- 'name' => $refInstance\r
+ 'name' => $applianceReference\r
);\r
- $instance_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
- $idInstance = $instance_infos->id;\r
+ $appliance_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
+ $applianceSugarId = $appliance_infos->id;\r
\r
// LINKING IT TO MAINTENANCE CONTRACT\r
- if(isset($idInstance) && isset($idContrat)) {\r
+ if(isset($applianceSugarId)) {\r
$moduleName = 'maint_contrat_maintenance';\r
$parameters = array(\r
'link_name' => 'maint_contrat_maintenance_allo_instances_1',\r
- 'primary_module_id' => $idContrat,\r
- 'related_module_id' => $idInstance\r
+ 'primary_module_id' => $contractSugarId,\r
+ 'related_module_id' => $applianceSugarId\r
);\r
$sugarConnector -> createRelationship($moduleName, $parameters);\r
}\r
}\r
\r
// GETTING OPPORTUNITIES OF APPLIANCE\r
- $moduleName = 'Opportunities';\r
- $requestedInfos = array('id');\r
- $sqlWhereClause = "opportunities.name = '".$refInstall."'";\r
- $fiche_install_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
- $idInstall = $fiche_install_infos->entry_list[0]->id;\r
- if(isset($idInstall)) {\r
+ $moduleName = 'allo_Instances';\r
+ $parameters = array(\r
+ "link_name" => "allo_instances_opportunities_1",\r
+ "primary_module_id" => $applianceSugarId,\r
+ );\r
+ $requestedInfos = array(\r
+ 'id',\r
+ 'name',\r
+ 'date_closed',\r
+ 'date_entered',\r
+ 'liste_hebergement_c',\r
+ 'type_exploitation_c'\r
+ );\r
+ $sqlWhereClause = "opportunities.name = '".$opportunityReference."'";\r
+ $opportunity_infos = json_decode($sugarConnector -> getRelationships($moduleName, $parameters, $requestedInfos, $sqlWhereClause));\r
+\r
+ $opportunitySugarId = $opportunity_infos->entry_list[0]->id;\r
+ if(isset($opportunitySugarId)) {\r
\r
// GETTING MOST RECENT OPPORTUNITY\r
- $lastFI = $fiche_install_infos->entry_list[0];\r
- foreach($fiche_install_infos->entry_list as $fiche_install_info) {\r
+ $lastOpportunity = $opportunity_infos->entry_list[0];\r
+ foreach($opportunity_infos->entry_list as $opportunity_info) {\r
\r
// RESEARCH CRITERION : NO CLOSING DATE AND LAST ADDED\r
- if(!isset($fiche_install_info->name_value_list->date_closed->value) &&\r
- $fiche_install_info->name_value_list->date_entered->value > $lastFI->name_value_list->date_entered->value) {\r
- $lastFI = $fiche_install_info;\r
- }\r
- }\r
- $versions = $historique -> getVersions();\r
- $lastDeclaration = $historique -> getInstallation();\r
- $lastVersion = $instance -> getVersion();\r
-\r
- // GETTING DATE OF THE LAST VERSION DECLARATION\r
- foreach($versions as $version) {\r
- $versionArray = explode(';',$version);\r
- if(isset($versionArray[1])) {\r
- $declaration = $versionArray[1];\r
- if($declaration > $lastDeclaration) {\r
- $lastDeclaration = $declaration;\r
- $lastVersionId = $versionArray[0];\r
- }\r
+ if(!isset($opportunity_info->name_value_list->date_closed->value) &&\r
+ $opportunity_info->name_value_list->date_entered->value > $lastOpportunity->name_value_list->date_entered->value) {\r
+ $lastOpportunity = $opportunity_info;\r
}\r
}\r
\r
- // LAST VERSION DECLARED\r
- if(isset($lastVersionId)) {\r
- $lastVersion = $versionManager -> getVersion($lastVersionId) -> getValeur();\r
- }\r
-\r
// UPDATING LAST OPPORTUNITY IN SUGAR : ADDING CLOSING DATE\r
- $idLastFi = $lastFI->id;\r
- $moduleName = 'Opportunities';\r
- $parameters = array(\r
- 'id' => $idLastFi,\r
- 'date_closed' => $lastDeclaration\r
- );\r
- $sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters);\r
-\r
- // CREATING NEW OPPORTUNITY\r
- $moduleName = 'Opportunities';\r
- $parameters = array(\r
- 'name' => $refInstall,\r
- 'type_exploitation_c' => $instance->getCanal(),\r
- 'date_opened_c' => $lastDeclaration,\r
- 'systeme_d_exploitation_c' => $instance->getSysteme(),\r
- 'liste_hebergement_c' => 'CLIENT',\r
- 'description' => 'Création par ALLO'\r
- );\r
- $fiche_install_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
- $idInstall = $fiche_install_infos->id;\r
+ $lastOpportunitySugarId = $lastOpportunity->id;\r
+ if(isset($lastVersionDeclaration)) {\r
+ $moduleName = 'Opportunities';\r
+ $parameters = array(\r
+ 'id' => $lastOpportunitySugarId,\r
+ 'date_closed' => $lastVersionDeclaration\r
+ );\r
+ $sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters);\r
\r
- // CHANGING VERSION REFERENCE TO LINK TO THE OPPORTUNITY\r
- $refVersion = $refInstanceArray[0].' '.$lastVersion;\r
+ // CREATING NEW OPPORTUNITY\r
+ $moduleName = 'Opportunities';\r
+ $parameters = array(\r
+ 'name' => $lastOpportunity->name_value_list->name->value,\r
+ 'type_exploitation_c' => $lastOpportunity->name_value_list->type_exploitation_c->value,\r
+ 'date_opened_c' => $lastVersionDeclaration,\r
+ 'systeme_d_exploitation_c' => $appliance->getOs(),\r
+ 'liste_hebergement_c' => $lastOpportunity->name_value_list->liste_hebergement_c->value,\r
+ 'description' => 'Création par ALLO'\r
+ );\r
+ $opportunity_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
+ $opportunitySugarId = $opportunity_infos->id;\r
+ }\r
\r
// IF NO OPPORTUNITY IS FOUND ON SUGAR FOR THIS APPLIANCE, CREATING NEW ONE\r
} else {\r
$moduleName = 'Opportunities';\r
$parameters = array(\r
- 'name' => $refInstall,\r
- 'type_exploitation_c' => $instance->getCanal(),\r
- 'date_opened_c' => $historique->getInstallation(),\r
- 'systeme_d_exploitation_c' => $instance->getSysteme(),\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
+ 'systeme_d_exploitation_c' => $appliance->getOs(),\r
+ // TO-DO : CHANGE THIS VALUE FOR EACH MANAGEMENT TYPE\r
'liste_hebergement_c' => 'CLIENT',\r
'description' => 'Création par ALLO'\r
);\r
- $fiche_install_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
- $idInstall = $fiche_install_infos->id;\r
+ $opportunity_infos = json_decode($sugarConnector -> updateOrCreateEntryModule($moduleName, $parameters));\r
+ $opportunitySugarId = $opportunity_infos->id;\r
}\r
\r
// LINKING OPPORTUNITY TO APPLIANCE\r
- if(isset($idInstance) && isset($idInstall)) {\r
+ if(isset($applianceSugarId) && isset($opportunitySugarId)) {\r
$moduleName = 'allo_Instances';\r
$parameters = array(\r
'link_name' => 'allo_instances_opportunities_1',\r
- 'primary_module_id' => $idInstance,\r
- 'related_module_id' => $idInstall\r
+ 'primary_module_id' => $applianceSugarId,\r
+ 'related_module_id' => $opportunitySugarId\r
);\r
$sugarConnector -> createRelationship($moduleName, $parameters);\r
}\r
// GETTING VERSION ID IN SUGAR\r
$moduleName = 'adul__Produits';\r
$requestedInfos = array('name');\r
- $sqlWhereClause = "adul__produits.name = '".$refVersion."'";\r
+ $sqlWhereClause = "adul__produits.name = '".$lastVersionReference."'";\r
$version_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
if(isset($version_infos->entry_list[0])) {\r
- $idVersion = $version_infos->entry_list[0]->id;\r
+ $versionSugarId = $version_infos->entry_list[0]->id;\r
}\r
\r
// LINKING OPPORTUNITY TO VERSION\r
- if(isset($idVersion) && isset($idInstall)) {\r
+ if(isset($versionSugarId) && isset($opportunitySugarId)) {\r
$moduleName = 'adul__Produits';\r
$parameters = array(\r
'link_name' => 'adul__prits_opportunities',\r
- 'primary_module_id' => $idVersion,\r
- 'related_module_id' => $idInstall\r
+ 'primary_module_id' => $versionSugarId,\r
+ 'related_module_id' => $opportunitySugarId\r
+ );\r
+ $sugarConnector -> createRelationship($moduleName, $parameters);\r
+ }\r
+\r
+ // GETTING PRODUCT CATALOG ID IN SUGAR\r
+ $moduleName = 'maint_catalogue_produits';\r
+ $requestedInfos = array('name');\r
+ $sqlWhereClause = "maint_catalogue_produits.name = '".$product -> getName()."'";\r
+ $catalog_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
+ if(isset($catalog_infos->entry_list[0])) {\r
+ $catalogSugarId = $catalog_infos->entry_list[0]->id;\r
+ }\r
+\r
+ // LINKING OPPORTUNITY TO PRODUCT CATALOG\r
+ if(isset($catalogSugarId) && isset($opportunitySugarId)) {\r
+ $moduleName = 'maint_catalogue_produits';\r
+ $parameters = array(\r
+ 'link_name' => 'maint_caits_opportunities',\r
+ 'primary_module_id' => $catalogSugarId,\r
+ 'related_module_id' => $opportunitySugarId\r
);\r
$sugarConnector -> createRelationship($moduleName, $parameters);\r
}\r
'id',\r
'officenumber_c'\r
);\r
- $sqlWhereClause = "accounts_cstm.officenumber_c = '".$refClient."'";\r
- $client_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
- if(isset($client_infos->entry_list[0])) {\r
- $idClient = $client_infos->entry_list[0]->id;\r
+ $sqlWhereClause = "accounts_cstm.officenumber_c = '".$customerAPId."'";\r
+ $customer_infos = json_decode($sugarConnector -> getInfosModule($moduleName, $requestedInfos, $sqlWhereClause));\r
+ if(isset($customer_infos->entry_list[0])) {\r
+ $customerSugarId = $customer_infos->entry_list[0]->id;\r
}\r
\r
- // LINKING OPPORTUNITY TO CUSTOMER\r
- if(isset($idClient) && isset($idInstall)) {\r
+ // LINKING OPPORTUNITY TO CUSTOMER (FOR N-N RELATIONS, IT GOES BOTH WAYS)\r
+ if(isset($customerSugarId) && isset($opportunitySugarId)) {\r
$moduleName = 'Accounts';\r
$parameters = array(\r
'link_name' => 'opportunities',\r
- 'primary_module_id' => $idClient,\r
- 'related_module_id' => $idInstall\r
+ 'primary_module_id' => $customerSugarId,\r
+ 'related_module_id' => $opportunitySugarId\r
);\r
$sugarConnector -> createRelationship($moduleName, $parameters);\r
$moduleName = 'Opportunities';\r
$parameters = array(\r
'link_name' => 'accounts',\r
- 'primary_module_id' => $idInstall,\r
- 'related_module_id' => $idClient\r
+ 'primary_module_id' => $opportunitySugarId,\r
+ 'related_module_id' => $opportunitySugarId\r
);\r
$sugarConnector -> createRelationship($moduleName, $parameters);\r
}\r
+\r
+ // TO-DO : LINK OPPORTUNITY TO MAINTENANCE CONTRACT\r
}\r
break;\r
}\r
- } else { echo "Welcome sur ALLO Serveur !"; }\r
+ } else { echo "C'est plutôt vide par ici."; }\r
}\r
\r
?>
\ No newline at end of file