Loading dev/depenses/sifac/commandes.sql +1 −28 Original line number Diff line number Diff line SELECT SAPSR3.DD07V.DDTEXT, 'engage et non paye', SAPSR3.LFA1.NAME1 NOMFOUR, SAPSR3.FMIOI.MEASURE, -- PFI SAPSR3.FMIOI.RLDNR, SAPSR3.FMIOI.STUNR, '' numsifac, SAPSR3.FMIOI.REFBN, '' numpiece, SAPSR3.FMIOI.LIFNR, '' pieceref, '1010' codesociete, '' codeservicefait, SAPSR3.FMIOI.FAREA, SAPSR3.FMIOI.SGTXT, '' texteFacture, SAPSR3.FMIOI.WRTTP, SAPSR3.FMIOI.TRBTR, SAPSR3.FMIOI.FISTL, SAPSR3.FMIOI.FIPEX, NVL(substr(SAPSR3.FMIOI.OBJNRZ, '12'), SAPSR3.FMIOI.PRCTR) CENTREFINANCIER, SAPSR3.FMIOI.HKONT, sapsr3.fmioi.budat date_piece_a_confirmer, sapsr3.fmioi.bldocdate date_comptable_a_confirmer, sapsr3.fmioi.gjahr date_annee_exercice_a_confirmer, sapsr3.fmioi.zhldt date_paiement_a_confirmer, '' date_service_fait DISTINCT SAPSR3.FMIOI.STUNR FROM SAPSR3.FMIOI, Loading doc/depenses.md 0 → 100644 +0 −0 Empty file added. module/Oscar/src/Oscar/Command/OscarSpentTestDatasCommand.php 0 → 100644 +90 −0 Original line number Diff line number Diff line <?php /** * Created by PhpStorm. * User: bouvry * Date: 04/10/19 * Time: 11:49 */ namespace Oscar\Command; use Oscar\Connector\ConnectorSpentSifacOCI; use Oscar\Service\OscarConfigurationService; use Oscar\Service\OscarUserContext; use Oscar\Service\SpentService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; class OscarSpentTestDatasCommand extends OscarCommandAbstract { protected static $defaultName = 'spent:test-data'; protected function configure() { $this ->setDescription("Permet d'obtenir les données des dépenses") ->setHelp("") ->addArgument('pfi', InputArgument::OPTIONAL, "PFI"); } protected function execute(InputInterface $input, OutputInterface $output) { $this->addOutputStyle($output); /** @var OscarUserContext $oscaruserContext */ $oscaruserContext = $this->getServicemanager()->get(OscarUserContext::class); $io = new SymfonyStyle($input, $output); $io->title("Synchronisation des dépenses"); /** @var OscarConfigurationService $oscarConfig */ $oscarConfig = $this->getServicemanager()->get(OscarConfigurationService::class); $pfi = $input->getArgument('pfi'); if ($pfi) { $io->writeln("PFI : $pfi"); } else { $io->error("PFI requis"); return Command::FAILURE; } try { $connectorConfig = $oscarConfig->getConfiguration('connectors.spent'); $keysConfig = array_keys($connectorConfig); if (count($keysConfig) == 0) { $io->error("Pas de synchronisation des dépenses configuré"); return Command::FAILURE; } elseif (count($keysConfig) > 1) { $io->error("Oscar ne prends en charge qu'une source de synchronisation pour les dépenses."); return Command::FAILURE; } else { $conf = $connectorConfig[$keysConfig[0]]; $class = $conf['class']; $factory = new \ReflectionClass($class); /** @var ConnectorSpentSifacOCI $instance */ $instance = $factory->newInstanceArgs( [$this->getServicemanager()->get(SpentService::class), $conf['params']] ); $result = $instance->data($pfi, true); $io->write($result); return Command::SUCCESS; } } catch (\Exception $e) { $io->error("Impossible de synchroniser les dépenses : " . $e->getMessage()); return Command::FAILURE; } } } No newline at end of file module/Oscar/src/Oscar/Connector/ConnectorSpentSifacOCI.php +53 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,59 @@ class ConnectorSpentSifacOCI } } public function getQueries(): array { if(!array_key_exists('queries', $this->sifacAccess)) { return []; } $queries = $this->sifacAccess['queries']; if( !is_array($queries) ) { throw new OscarException("Le paramètres 'queries' doit être un tableau"); } return $queries; } public function data(string $pfi) :array { $queries = $this->getQueries(); foreach ($queries as $query) { $result = $this->query($pfi, $query); } var_dump($result); die("DATA $pfi"); } protected function query(string $pfi, string $query) :array { try { $c = $this->getConnection(); $query = sprintf($query, $pfi); if ($c) { $stid = oci_parse($c, $query); if (!$stid) { throw new OscarException("ORACLE - PARSE ERROR : " . oci_error()); } if (!oci_execute($stid)) { throw new OscarException("ORACLE - QUERY ERROR : " . oci_error()); } $lines = []; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { try { $lines[] = $row; } catch (\Exception $e) { throw new OscarException( "ERROR - Query : " . $e->getMessage() ); } } return $lines; } } catch (\Exception $e) { throw new OscarException($e->getMessage()); } } /** * @param $pfi * @return string Loading module/Oscar/src/Oscar/Service/SpentService.php +2 −1 Original line number Diff line number Diff line Loading @@ -938,11 +938,12 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us protected function getNearestType($code, $original = "") { $this->getLoggerService()->debug("getNearestType($code, $original)"); static $types; static $assoc; // Fix : Pas de type chargé en base de donnée if ($code === false) return "0"; if ($code === false || $code == '') return "0"; if ($types === null) $types = $this->getSpentsTypes(); Loading Loading
dev/depenses/sifac/commandes.sql +1 −28 Original line number Diff line number Diff line SELECT SAPSR3.DD07V.DDTEXT, 'engage et non paye', SAPSR3.LFA1.NAME1 NOMFOUR, SAPSR3.FMIOI.MEASURE, -- PFI SAPSR3.FMIOI.RLDNR, SAPSR3.FMIOI.STUNR, '' numsifac, SAPSR3.FMIOI.REFBN, '' numpiece, SAPSR3.FMIOI.LIFNR, '' pieceref, '1010' codesociete, '' codeservicefait, SAPSR3.FMIOI.FAREA, SAPSR3.FMIOI.SGTXT, '' texteFacture, SAPSR3.FMIOI.WRTTP, SAPSR3.FMIOI.TRBTR, SAPSR3.FMIOI.FISTL, SAPSR3.FMIOI.FIPEX, NVL(substr(SAPSR3.FMIOI.OBJNRZ, '12'), SAPSR3.FMIOI.PRCTR) CENTREFINANCIER, SAPSR3.FMIOI.HKONT, sapsr3.fmioi.budat date_piece_a_confirmer, sapsr3.fmioi.bldocdate date_comptable_a_confirmer, sapsr3.fmioi.gjahr date_annee_exercice_a_confirmer, sapsr3.fmioi.zhldt date_paiement_a_confirmer, '' date_service_fait DISTINCT SAPSR3.FMIOI.STUNR FROM SAPSR3.FMIOI, Loading
module/Oscar/src/Oscar/Command/OscarSpentTestDatasCommand.php 0 → 100644 +90 −0 Original line number Diff line number Diff line <?php /** * Created by PhpStorm. * User: bouvry * Date: 04/10/19 * Time: 11:49 */ namespace Oscar\Command; use Oscar\Connector\ConnectorSpentSifacOCI; use Oscar\Service\OscarConfigurationService; use Oscar\Service\OscarUserContext; use Oscar\Service\SpentService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; class OscarSpentTestDatasCommand extends OscarCommandAbstract { protected static $defaultName = 'spent:test-data'; protected function configure() { $this ->setDescription("Permet d'obtenir les données des dépenses") ->setHelp("") ->addArgument('pfi', InputArgument::OPTIONAL, "PFI"); } protected function execute(InputInterface $input, OutputInterface $output) { $this->addOutputStyle($output); /** @var OscarUserContext $oscaruserContext */ $oscaruserContext = $this->getServicemanager()->get(OscarUserContext::class); $io = new SymfonyStyle($input, $output); $io->title("Synchronisation des dépenses"); /** @var OscarConfigurationService $oscarConfig */ $oscarConfig = $this->getServicemanager()->get(OscarConfigurationService::class); $pfi = $input->getArgument('pfi'); if ($pfi) { $io->writeln("PFI : $pfi"); } else { $io->error("PFI requis"); return Command::FAILURE; } try { $connectorConfig = $oscarConfig->getConfiguration('connectors.spent'); $keysConfig = array_keys($connectorConfig); if (count($keysConfig) == 0) { $io->error("Pas de synchronisation des dépenses configuré"); return Command::FAILURE; } elseif (count($keysConfig) > 1) { $io->error("Oscar ne prends en charge qu'une source de synchronisation pour les dépenses."); return Command::FAILURE; } else { $conf = $connectorConfig[$keysConfig[0]]; $class = $conf['class']; $factory = new \ReflectionClass($class); /** @var ConnectorSpentSifacOCI $instance */ $instance = $factory->newInstanceArgs( [$this->getServicemanager()->get(SpentService::class), $conf['params']] ); $result = $instance->data($pfi, true); $io->write($result); return Command::SUCCESS; } } catch (\Exception $e) { $io->error("Impossible de synchroniser les dépenses : " . $e->getMessage()); return Command::FAILURE; } } } No newline at end of file
module/Oscar/src/Oscar/Connector/ConnectorSpentSifacOCI.php +53 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,59 @@ class ConnectorSpentSifacOCI } } public function getQueries(): array { if(!array_key_exists('queries', $this->sifacAccess)) { return []; } $queries = $this->sifacAccess['queries']; if( !is_array($queries) ) { throw new OscarException("Le paramètres 'queries' doit être un tableau"); } return $queries; } public function data(string $pfi) :array { $queries = $this->getQueries(); foreach ($queries as $query) { $result = $this->query($pfi, $query); } var_dump($result); die("DATA $pfi"); } protected function query(string $pfi, string $query) :array { try { $c = $this->getConnection(); $query = sprintf($query, $pfi); if ($c) { $stid = oci_parse($c, $query); if (!$stid) { throw new OscarException("ORACLE - PARSE ERROR : " . oci_error()); } if (!oci_execute($stid)) { throw new OscarException("ORACLE - QUERY ERROR : " . oci_error()); } $lines = []; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { try { $lines[] = $row; } catch (\Exception $e) { throw new OscarException( "ERROR - Query : " . $e->getMessage() ); } } return $lines; } } catch (\Exception $e) { throw new OscarException($e->getMessage()); } } /** * @param $pfi * @return string Loading
module/Oscar/src/Oscar/Service/SpentService.php +2 −1 Original line number Diff line number Diff line Loading @@ -938,11 +938,12 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us protected function getNearestType($code, $original = "") { $this->getLoggerService()->debug("getNearestType($code, $original)"); static $types; static $assoc; // Fix : Pas de type chargé en base de donnée if ($code === false) return "0"; if ($code === false || $code == '') return "0"; if ($types === null) $types = $this->getSpentsTypes(); Loading