Composer, Nettoyage

This commit is contained in:
Michael RICOIS 2015-09-25 12:38:03 +00:00
parent 629738175e
commit bcda409a92
21 changed files with 144 additions and 2388 deletions

View File

@ -7,34 +7,3 @@ table commandes_kbis
table commandes_pieces
table commandes_statut
table commandes_tarifs => Needed dans GenCourrier
filesGreffes.php
getActes.php
greffeCmdMois.php
greffeCmdTelechargement
Controller/Dashboard
Dashboard
Client => Gestion client, forcer l'ADV a utiliser le nouveau backoffice
Actes et Bilans
Kbis
GenCourrier => dans backoffice
table aide
Cron OK
=============
sendBilanClient
getAltiScore

View File

@ -1,248 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Loader
* @subpackage Exception
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Generate class maps for use with autoloading.
*
* Usage:
* --help|-h Get usage message
* --library|-l [ <string> ] Library to parse; if none provided, assumes
* current directory
* --output|-o [ <string> ] Where to write autoload file; if not provided,
* assumes "autoload_classmap.php" in library directory
* --append|-a Append to autoload file if it exists
* --overwrite|-w Whether or not to overwrite existing autoload
* file
* --ignore|-i [ <string> ] Comma-separated namespaces to ignore
*/
$libPath = dirname(__FILE__) . '/../library';
if (!is_dir($libPath)) {
// Try to load StandardAutoloader from include_path
if (false === include('Zend/Loader/StandardAutoloader.php')) {
echo "Unable to locate autoloader via include_path; aborting" . PHP_EOL;
exit(2);
}
} else {
// Try to load StandardAutoloader from library
if (false === include(dirname(__FILE__) . '/../library/Zend/Loader/StandardAutoloader.php')) {
echo "Unable to locate autoloader via library; aborting" . PHP_EOL;
exit(2);
}
}
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath($libPath),
get_include_path(),
)));
$libraryPath = getcwd();
// Setup autoloading
$loader = new Zend_Loader_StandardAutoloader(array('autoregister_zf' => true));
$loader->setFallbackAutoloader(true);
$loader->register();
$rules = array(
'help|h' => 'Get usage message',
'library|l-s' => 'Library to parse; if none provided, assumes current directory',
'output|o-s' => 'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory',
'append|a' => 'Append to autoload file if it exists',
'overwrite|w' => 'Whether or not to overwrite existing autoload file',
'ignore|i-s' => 'Comma-separated namespaces to ignore',
);
try {
$opts = new Zend_Console_Getopt($rules);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit(2);
}
if ($opts->getOption('h')) {
echo $opts->getUsageMessage();
exit(0);
}
$ignoreNamespaces = array();
if (isset($opts->i)) {
$ignoreNamespaces = explode(',', $opts->i);
}
$relativePathForClassmap = '';
if (isset($opts->l)) {
if (!is_dir($opts->l)) {
echo 'Invalid library directory provided' . PHP_EOL
. PHP_EOL;
echo $opts->getUsageMessage();
exit(2);
}
$libraryPath = $opts->l;
}
$libraryPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath($libraryPath));
$usingStdout = false;
$appending = $opts->getOption('a');
$output = $libraryPath . '/autoload_classmap.php';
if (isset($opts->o)) {
$output = $opts->o;
if ('-' == $output) {
$output = STDOUT;
$usingStdout = true;
} elseif (is_dir($output)) {
echo 'Invalid output file provided' . PHP_EOL
. PHP_EOL;
echo $opts->getUsageMessage();
exit(2);
} elseif (!is_writeable(dirname($output))) {
echo "Cannot write to '$output'; aborting." . PHP_EOL
. PHP_EOL
. $opts->getUsageMessage();
exit(2);
} elseif (file_exists($output) && !$opts->getOption('w') && !$appending) {
echo "Autoload file already exists at '$output'," . PHP_EOL
. "but 'overwrite' or 'appending' flag was not specified; aborting." . PHP_EOL
. PHP_EOL
. $opts->getUsageMessage();
exit(2);
} else {
// We need to add the $libraryPath into the relative path that is created in the classmap file.
$classmapPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath(dirname($output)));
// Simple case: $libraryPathCompare is in $classmapPathCompare
if (strpos($libraryPath, $classmapPath) === 0) {
$relativePathForClassmap = substr($libraryPath, strlen($classmapPath) + 1) . '/';
} else {
$libraryPathParts = explode('/', $libraryPath);
$classmapPathParts = explode('/', $classmapPath);
// Find the common part
$count = count($classmapPathParts);
for ($i = 0; $i < $count; $i++) {
if (!isset($libraryPathParts[$i]) || $libraryPathParts[$i] != $classmapPathParts[$i]) {
// Common part end
break;
}
}
// Add parent dirs for the subdirs of classmap
$relativePathForClassmap = str_repeat('../', $count - $i);
// Add library subdirs
$count = count($libraryPathParts);
for (; $i < $count; $i++) {
$relativePathForClassmap .= $libraryPathParts[$i] . '/';
}
}
}
}
if (!$usingStdout) {
if ($appending) {
echo "Appending to class file map '$output' for library in '$libraryPath'..." . PHP_EOL;
} else {
echo "Creating class file map for library in '$libraryPath'..." . PHP_EOL;
}
}
// Get the ClassFileLocator, and pass it the library path
$l = new Zend_File_ClassFileLocator($libraryPath);
// Iterate over each element in the path, and create a map of
// classname => filename, where the filename is relative to the library path
$map = new stdClass;
foreach ($l as $file) {
$filename = str_replace($libraryPath . '/', '', str_replace(DIRECTORY_SEPARATOR, '/', $file->getPath()) . '/' . $file->getFilename());
// Add in relative path to library
$filename = $relativePathForClassmap . $filename;
foreach ($file->getClasses() as $class) {
foreach ($ignoreNamespaces as $ignoreNs) {
if ($ignoreNs == substr($class, 0, strlen($ignoreNs))) {
continue 2;
}
}
$map->{$class} = $filename;
}
}
if ($appending) {
$content = var_export((array) $map, true) . ';';
// Prefix with dirname(__FILE__); modify the generated content
$content = preg_replace("#(=> ')#", "=> dirname(__FILE__) . '/", $content);
// Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
$content = str_replace("\\'", "'", $content);
// Convert to an array and remove the first "array("
$content = explode("\n", $content);
array_shift($content);
// Load existing class map file and remove the closing "bracket ");" from it
$existing = file($output, FILE_IGNORE_NEW_LINES);
array_pop($existing);
// Merge
$content = implode("\n", array_merge($existing, $content));
} else {
// Create a file with the class/file map.
// Stupid syntax highlighters make separating < from PHP declaration necessary
$content = '<' . "?php\n"
. "// Generated by ZF's ./bin/classmap_generator.php\n"
. 'return ' . var_export((array) $map, true) . ';';
// Prefix with dirname(__FILE__); modify the generated content
$content = preg_replace("#(=> ')#", "=> dirname(__FILE__) . '/", $content);
// Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
$content = str_replace("\\'", "'", $content);
}
// Remove unnecessary double-backslashes
$content = str_replace('\\\\', '\\', $content);
// Exchange "array (" width "array("
$content = str_replace('array (', 'array(', $content);
// Align "=>" operators to match coding standard
preg_match_all('(\n\s+([^=]+)=>)', $content, $matches, PREG_SET_ORDER);
$maxWidth = 0;
foreach ($matches as $match) {
$maxWidth = max($maxWidth, strlen($match[1]));
}
$content = preg_replace('(\n\s+([^=]+)=>)e', "'\n \\1' . str_repeat(' ', " . $maxWidth . " - strlen('\\1')) . '=>'", $content);
// Make the file end by EOL
$content = rtrim($content, "\n") . "\n";
// Write the contents to disk
file_put_contents($output, $content);
if (!$usingStdout) {
echo "Wrote classmap file to '" . realpath($output) . "'" . PHP_EOL;
}

View File

@ -1,44 +0,0 @@
@ECHO off
REM Zend Framework
REM
REM LICENSE
REM
REM This source file is subject to the new BSD license that is bundled
REM with this package in the file LICENSE.txt.
REM It is also available through the world-wide-web at this URL:
REM http://framework.zend.com/license/new-bsd
REM If you did not receive a copy of the license and are unable to
REM obtain it through the world-wide-web, please send an email
REM to license@zend.com so we can send you a copy immediately.
REM
REM Zend
REM Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
REM http://framework.zend.com/license/new-bsd New BSD License
REM Test to see if this was installed via pear
SET ZTMPZTMPZTMPZ=@ph
SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@
REM below @php_bin@
FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED)
GOTO PEAR_INSTALLED
:NON_PEAR_INSTALLED
REM Assume php.exe is executable, and that zf.php will reside in the
REM same file as this one
SET PHP_BIN=php.exe
SET PHP_DIR=%~dp0
GOTO RUN
:PEAR_INSTALLED
REM Assume this was installed via PEAR and use replacements php_bin & php_dir
SET PHP_BIN=@php_bin@
SET PHP_DIR=@php_dir@
GOTO RUN
:RUN
SET ZF_SCRIPT=%PHP_DIR%\zf.php
"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %*

View File

@ -1,624 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Tool
* @subpackage Framework
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* ZF
*
* @category Zend
* @package Zend_Tool
* @subpackage Framework
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ZF
{
/**
* @var bool
*/
protected $_clientLoaded = false;
/**
* @var string
*/
protected $_mode = 'runTool';
/**
* @var array of messages
*/
protected $_messages = array();
/**
* @var string
*/
protected $_homeDirectory = null;
/**
* @var string
*/
protected $_storageDirectory = null;
/**
* @var string
*/
protected $_configFile = null;
/**
* main()
*
* @return void
*/
public static function main()
{
$zf = new self();
$zf->bootstrap();
$zf->run();
}
/**
* bootstrap()
*
* @return ZF
*/
public function bootstrap()
{
// detect settings
$this->_mode = $this->_detectMode();
$this->_homeDirectory = $this->_detectHomeDirectory();
$this->_storageDirectory = $this->_detectStorageDirectory();
$this->_configFile = $this->_detectConfigFile();
// setup
$this->_setupPHPRuntime();
$this->_setupToolRuntime();
}
/**
* run()
*
* @return ZF
*/
public function run()
{
switch ($this->_mode) {
case 'runError':
$this->_runError();
$this->_runInfo();
break;
case 'runSetup':
if ($this->_runSetup() === false) {
$this->_runInfo();
}
break;
case 'runInfo':
$this->_runInfo();
break;
case 'runTool':
default:
$this->_runTool();
break;
}
return $this;
}
/**
* _detectMode()
*
* @return ZF
*/
protected function _detectMode()
{
$arguments = $_SERVER['argv'];
$mode = 'runTool';
if (!isset($arguments[0])) {
return $mode;
}
if ($arguments[0] == $_SERVER['PHP_SELF']) {
$this->_executable = array_shift($arguments);
}
if (!isset($arguments[0])) {
return $mode;
}
if ($arguments[0] == '--setup') {
$mode = 'runSetup';
} elseif ($arguments[0] == '--info') {
$mode = 'runInfo';
}
return $mode;
}
/**
* _detectHomeDirectory() - detect the home directory in a variety of different places
*
* @param bool $mustExist Should the returned value already exist in the file system
* @param bool $returnMessages Should it log messages for output later
* @return string
*/
protected function _detectHomeDirectory($mustExist = true, $returnMessages = true)
{
$homeDirectory = null;
$homeDirectory = getenv('ZF_HOME'); // check env var ZF_HOME
if ($homeDirectory) {
$this->_logMessage('Home directory found in environment variable ZF_HOME with value ' . $homeDirectory, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
return $homeDirectory;
} else {
$this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
}
}
$homeDirectory = getenv('HOME'); // HOME environment variable
if ($homeDirectory) {
$this->_logMessage('Home directory found in environment variable HOME with value ' . $homeDirectory, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
return $homeDirectory;
} else {
$this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
}
}
$homeDirectory = getenv('HOMEPATH');
if ($homeDirectory) {
$this->_logMessage('Home directory found in environment variable HOMEPATH with value ' . $homeDirectory, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
return $homeDirectory;
} else {
$this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
}
}
$homeDirectory = getenv('USERPROFILE');
if ($homeDirectory) {
$this->_logMessage('Home directory found in environment variable USERPROFILE with value ' . $homeDirectory, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
return $homeDirectory;
} else {
$this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
}
}
return false;
}
/**
* _detectStorageDirectory() - Detect where the storage directory is from a variaty of possiblities
*
* @param bool $mustExist Should the returned value already exist in the file system
* @param bool $returnMessages Should it log messages for output later
* @return string
*/
protected function _detectStorageDirectory($mustExist = true, $returnMessages = true)
{
$storageDirectory = false;
$storageDirectory = getenv('ZF_STORAGE_DIR');
if ($storageDirectory) {
$this->_logMessage('Storage directory path found in environment variable ZF_STORAGE_DIR with value ' . $storageDirectory, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($storageDirectory))) {
return $storageDirectory;
} else {
$this->_logMessage('Storage directory does not exist at ' . $storageDirectory, $returnMessages);
}
}
$homeDirectory = ($this->_homeDirectory) ? $this->_homeDirectory : $this->_detectHomeDirectory(true, false);
if ($homeDirectory) {
$storageDirectory = $homeDirectory . '/.zf/';
$this->_logMessage('Storage directory assumed in home directory at location ' . $storageDirectory, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($storageDirectory))) {
return $storageDirectory;
} else {
$this->_logMessage('Storage directory does not exist at ' . $storageDirectory, $returnMessages);
}
}
return false;
}
/**
* _detectConfigFile() - Detect config file location from a variety of possibilities
*
* @param bool $mustExist Should the returned value already exist in the file system
* @param bool $returnMessages Should it log messages for output later
* @return string
*/
protected function _detectConfigFile($mustExist = true, $returnMessages = true)
{
$configFile = null;
$configFile = getenv('ZF_CONFIG_FILE');
if ($configFile) {
$this->_logMessage('Config file found environment variable ZF_CONFIG_FILE at ' . $configFile, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($configFile))) {
return $configFile;
} else {
$this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages);
}
}
$homeDirectory = ($this->_homeDirectory) ? $this->_homeDirectory : $this->_detectHomeDirectory(true, false);
if ($homeDirectory) {
$configFile = $homeDirectory . '/.zf.ini';
$this->_logMessage('Config file assumed in home directory at location ' . $configFile, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($configFile))) {
return $configFile;
} else {
$this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages);
}
}
$storageDirectory = ($this->_storageDirectory) ? $this->_storageDirectory : $this->_detectStorageDirectory(true, false);
if ($storageDirectory) {
$configFile = $storageDirectory . '/zf.ini';
$this->_logMessage('Config file assumed in storage directory at location ' . $configFile, $returnMessages);
if (!$mustExist || ($mustExist && file_exists($configFile))) {
return $configFile;
} else {
$this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages);
}
}
return false;
}
/**
* _setupPHPRuntime() - parse the config file if it exists for php ini values to set
*
* @return void
*/
protected function _setupPHPRuntime()
{
// set php runtime settings
ini_set('display_errors', true);
// support the changing of the current working directory, necessary for some providers
$cwd = getenv('ZEND_TOOL_CURRENT_WORKING_DIRECTORY');
if ($cwd != '' && realpath($cwd)) {
chdir($cwd);
}
if (!$this->_configFile) {
return;
}
$zfINISettings = parse_ini_file($this->_configFile);
$phpINISettings = ini_get_all();
foreach ($zfINISettings as $zfINIKey => $zfINIValue) {
if (substr($zfINIKey, 0, 4) === 'php.') {
$phpINIKey = substr($zfINIKey, 4);
if (array_key_exists($phpINIKey, $phpINISettings)) {
ini_set($phpINIKey, $zfINIValue);
}
}
}
}
/**
* _setupToolRuntime() - setup the tools include_path and load the proper framwork parts that
* enable Zend_Tool to work.
*
* @return void
*/
protected function _setupToolRuntime()
{
$includePathPrepend = getenv('ZEND_TOOL_INCLUDE_PATH_PREPEND');
$includePathFull = getenv('ZEND_TOOL_INCLUDE_PATH');
// check if the user has not provided anything
if (!($includePathPrepend || $includePathFull)) {
if ($this->_tryClientLoad()) {
return;
}
}
// if ZF is not in the include_path, but relative to this file, put it in the include_path
if ($includePathPrepend || $includePathFull) {
if (isset($includePathPrepend) && ($includePathPrepend !== false)) {
set_include_path($includePathPrepend . PATH_SEPARATOR . get_include_path());
} elseif (isset($includePathFull) && ($includePathFull !== false)) {
set_include_path($includePathFull);
}
}
if ($this->_tryClientLoad()) {
return;
}
$zfIncludePath['relativePath'] = dirname(__FILE__) . '/../library/';
if (file_exists($zfIncludePath['relativePath'] . 'Zend/Tool/Framework/Client/Console.php')) {
set_include_path(realpath($zfIncludePath['relativePath']) . PATH_SEPARATOR . get_include_path());
}
if (!$this->_tryClientLoad()) {
$this->_mode = 'runError';
return;
}
}
/**
* _tryClientLoad() - Attempt to load the Zend_Tool_Framework_Client_Console to enable the tool to run.
*
* This method will return false if its not loaded to allow the consumer to alter the environment in such
* a way that it can be called again to try loading the proper file/class.
*
* @return bool if the client is actuall loaded or not
*/
protected function _tryClientLoad()
{
$this->_clientLoaded = false;
$fh = @fopen('Zend/Tool/Framework/Client/Console.php', 'r', true);
if (!$fh) {
return $this->_clientLoaded; // false
} else {
fclose($fh);
unset($fh);
include 'Zend/Tool/Framework/Client/Console.php';
$this->_clientLoaded = class_exists('Zend_Tool_Framework_Client_Console');
}
return $this->_clientLoaded;
}
/**
* _runError() - Output the error screen that tells the user that the tool was not setup
* in a sane way
*
* @return void
*/
protected function _runError()
{
echo <<<EOS
***************************** ZF ERROR ********************************
In order to run the zf command, you need to ensure that Zend Framework
is inside your include_path. There are a variety of ways that you can
ensure that this zf command line tool knows where the Zend Framework
library is on your system, but not all of them can be described here.
The easiest way to get the zf command running is to give it the include
path via an environment variable ZEND_TOOL_INCLUDE_PATH or
ZEND_TOOL_INCLUDE_PATH_PREPEND with the proper include path to use,
then run the command "zf --setup". This command is designed to create
a storage location for your user, as well as create the zf.ini file
that the zf command will consult in order to run properly on your
system.
Example you would run:
$ ZEND_TOOL_INCLUDE_PATH=/path/to/library zf --setup
Your are encourged to read more in the link that follows.
EOS;
}
/**
* _runInfo() - this command will produce information about the setup of this script and
* Zend_Tool
*
* @return void
*/
protected function _runInfo()
{
echo 'Zend_Tool & CLI Setup Information' . PHP_EOL
. '(available via the command line "zf --info")'
. PHP_EOL;
echo ' * ' . implode(PHP_EOL . ' * ', $this->_messages) . PHP_EOL;
echo PHP_EOL;
echo 'To change the setup of this tool, run: "zf --setup"';
echo PHP_EOL;
}
/**
* _runSetup() - parse the request to see which setup command to run
*
* @return void
*/
protected function _runSetup()
{
$setupCommand = (isset($_SERVER['argv'][2])) ? $_SERVER['argv'][2] : null;
switch ($setupCommand) {
case 'storage-directory':
$this->_runSetupStorageDirectory();
break;
case 'config-file':
$this->_runSetupConfigFile();
break;
default:
$this->_runSetupMoreInfo();
break;
}
}
/**
* _runSetupStorageDirectory() - if the storage directory does not exist, create it
*
* @return void
*/
protected function _runSetupStorageDirectory()
{
$storageDirectory = $this->_detectStorageDirectory(false, false);
if (file_exists($storageDirectory)) {
echo 'Directory already exists at ' . $storageDirectory . PHP_EOL
. 'Cannot create storage directory.';
return;
}
mkdir($storageDirectory);
echo 'Storage directory created at ' . $storageDirectory . PHP_EOL;
}
/**
* _runSetupConfigFile()
*
* @return void
*/
protected function _runSetupConfigFile()
{
$configFile = $this->_detectConfigFile(false, false);
if (file_exists($configFile)) {
echo 'File already exists at ' . $configFile . PHP_EOL
. 'Cannot write new config file.';
return;
}
$includePath = get_include_path();
$contents = 'php.include_path = "' . $includePath . '"';
file_put_contents($configFile, $contents);
$iniValues = ini_get_all();
if ($iniValues['include_path']['global_value'] != $iniValues['include_path']['local_value']) {
echo 'NOTE: the php include_path to be used with the tool has been written' . PHP_EOL
. 'to the config file, using ZEND_TOOL_INCLUDE_PATH (or other include_path setters)' . PHP_EOL
. 'is no longer necessary.' . PHP_EOL . PHP_EOL;
}
echo 'Config file written to ' . $configFile . PHP_EOL;
}
/**
* _runSetupMoreInfo() - return more information about what can be setup, and what is setup
*
* @return void
*/
protected function _runSetupMoreInfo()
{
$homeDirectory = $this->_detectHomeDirectory(false, false);
$storageDirectory = $this->_detectStorageDirectory(false, false);
$configFile = $this->_detectConfigFile(false, false);
echo <<<EOS
ZF Command Line Tool - Setup
----------------------------
Current Paths (Existing or not):
Home Directory: {$homeDirectory}
Storage Directory: {$storageDirectory}
Config File: {$configFile}
Important Environment Variables:
ZF_HOME
- the directory this tool will look for a home directory
- directory must exist
ZF_STORAGE_DIR
- where this tool will look for a storage directory
- directory must exist
ZF_CONFIG_FILE
- where this tool will look for a configuration file
ZF_TOOL_INCLUDE_PATH
- set the include_path for this tool to use this value
ZF_TOOL_INCLUDE_PATH_PREPEND
- prepend the current php.ini include_path with this value
Search Order:
Home Directory:
- ZF_HOME, then HOME (*nix), then HOMEPATH (windows)
Storage Directory:
- ZF_STORAGE_DIR, then {home}/.zf/
Config File:
- ZF_CONFIG_FILE, then {home}/.zf.ini, then {home}/zf.ini,
then {storage}/zf.ini
Commands:
zf --setup storage-directory
- setup the storage directory, directory will be created
zf --setup config-file
- create the config file with some default values
EOS;
}
/**
* _runTool() - This is where the magic happens, dispatch Zend_Tool
*
* @return void
*/
protected function _runTool()
{
$configOptions = array();
if (isset($this->_configFile) && $this->_configFile) {
$configOptions['configOptions']['configFilepath'] = $this->_configFile;
}
if (isset($this->_storageDirectory) && $this->_storageDirectory) {
$configOptions['storageOptions']['directory'] = $this->_storageDirectory;
}
// ensure that zf.php loads the Zend_Tool_Project features
$configOptions['classesToLoad'] = 'Zend_Tool_Project_Provider_Manifest';
$console = new Zend_Tool_Framework_Client_Console($configOptions);
$console->dispatch();
}
/**
* _logMessage() - Internal method used to log setup and information messages.
*
* @param string $message
* @param bool $storeMessage
* @return void
*/
protected function _logMessage($message, $storeMessage = true)
{
if (!$storeMessage) {
return;
}
$this->_messages[] = $message;
}
}
if (!getenv('ZF_NO_MAIN')) {
ZF::main();
}

View File

@ -1,45 +0,0 @@
#!/bin/sh
#############################################################################
# Zend Framework
#
# LICENSE
#
# This source file is subject to the new BSD license that is bundled
# with this package in the file LICENSE.txt.
# It is also available through the world-wide-web at this URL:
# http://framework.zend.com/license/new-bsd
# If you did not receive a copy of the license and are unable to
# obtain it through the world-wide-web, please send an email
# to license@zend.com so we can send you a copy immediately.
#
# Zend
# Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
# http://framework.zend.com/license/new-bsd New BSD License
#############################################################################
# find php: pear first, command -v second, straight up php lastly
if test "@php_bin@" != '@'php_bin'@'; then
PHP_BIN="@php_bin@"
elif command -v php 1>/dev/null 2>/dev/null; then
PHP_BIN=`command -v php`
else
PHP_BIN=php
fi
# find zf.php: pear first, same directory 2nd,
if test "@php_dir@" != '@'php_dir'@'; then
PHP_DIR="@php_dir@"
else
SELF_LINK="$0"
SELF_LINK_TMP="$(readlink "$SELF_LINK")"
while test -n "$SELF_LINK_TMP"; do
SELF_LINK="$SELF_LINK_TMP"
SELF_LINK_TMP="$(readlink "$SELF_LINK")"
done
PHP_DIR="$(dirname "$SELF_LINK")"
fi
"$PHP_BIN" -d safe_mode=Off -f "$PHP_DIR/zf.php" -- "$@"

25
composer.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "scores/extranet",
"description": "Extranet",
"require": {
"zendframework/zendframework1": "^1.12"
},
"include-path": ["library/"],
"autoload": {
"classmap": [
"application/",
"library/Application/",
"library/GenCourrier/",
"library/Giant/",
"library/Infogreffe/",
"library/Scores/",
"library/Worldcheck/"
]
},
"authors": [
{
"name": "Scores et Decisions",
"email": "supportdev@scores-decisions.com"
}
]
}

66
composer.lock generated Normal file
View File

@ -0,0 +1,66 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "6ba703814e1db37f95ec75fce40a2bf0",
"content-hash": "934d96cbc45481a0d243a4d3af6161ab",
"packages": [
{
"name": "zendframework/zendframework1",
"version": "1.12.16",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zf1.git",
"reference": "8a3c471ef0a337d303cd5ae578e64c2ba1d2c025"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zf1/zipball/8a3c471ef0a337d303cd5ae578e64c2ba1d2c025",
"reference": "8a3c471ef0a337d303cd5ae578e64c2ba1d2c025",
"shasum": ""
},
"require": {
"php": ">=5.2.11"
},
"require-dev": {
"phpunit/dbunit": "1.3.*",
"phpunit/phpunit": "3.7.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.12.x-dev"
}
},
"autoload": {
"psr-0": {
"Zend_": "library/"
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"library/"
],
"license": [
"BSD-3-Clause"
],
"description": "Zend Framework 1",
"homepage": "http://framework.zend.com/",
"keywords": [
"ZF1",
"framework"
],
"time": "2015-09-15 15:49:51"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

11
docs/CRONTAB Normal file
View File

@ -0,0 +1,11 @@
# AltiScore
00 4 * * 1-5 www-data php /home/vhosts/extranet/current/scripts/jobs/getAltiScore.php --cron >> /home/vhosts/data/log/altiscore.log
# Envoi commande bilan
0 * * * * root php /home/vhosts/extranet/current/scripts/jobs/bilaninput.php --send >> /home/vhosts/data/log/bilaninput.log 2>&1
# Suppression fichier
#0 10 01 * * root php /home/vhosts/extranet/current/scripts/jobs/bilaninput.php --delete >> /home/vhosts/data/log/bilaninput.log 2>&1
# Suppression fichier temporaire
01 15 06 * * root php /home/vhosts/extranet/current/scripts/jobs/removeTempFile.php --options all

View File

@ -1,54 +1,15 @@
<?php
// Define path to application directory
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
// Define application environment
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// Check APC parameters
if (ini_get('apc.enabled')!=1) {
switch ( APPLICATION_ENV ) {
case 'production':
echo "Erreur technique.";
break;
default:
echo "APC is not enabled !";
break;
}
}
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../library/Zend',
'Application' => __DIR__ . '/../library/Application',
'Scores' => __DIR__ . '/../library/Scores',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// --- Composer autoload
require_once realpath(__DIR__ . '/../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();

View File

@ -1,33 +0,0 @@
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
$dir = array(
APPLICATION_PATH,
APPLICATION_PATH."/../library/Zend",
APPLICATION_PATH."/../library/Application",
APPLICATION_PATH."/../library/Scores",
);
$fileClassmap = APPLICATION_PATH."/../library/autoload_classmap.php";
$i = 0;
foreach($dir as $d) {
$options = " -a";
if ($i==0) {
$options = " -w";
}
passthru("php ".APPLICATION_PATH."/../bin/classmap_generator.php -l ".d.$options." -o ".$fileClassmap);
$i++;
}

View File

@ -1,38 +1,17 @@
<?php
//error_reporting(E_ALL & ~E_NOTICE);
// Define path to application directory
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// Define application environment
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'SdMetier' => __DIR__ . '/../../library/SdMetier',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
),
));
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
try {
$opts = new Zend_Console_Getopt(

View File

@ -1,44 +1,17 @@
<?php
// Define path to application directory
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// Define application environment
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$catalogs = array(
'evenements' => array(

View File

@ -1,16 +0,0 @@
<?php
/*
# Envoi des actes commandés par email
30 13,18 * * * root php /var/www/extranetrec/batch/getActes.php --send >> /var/www/data/log/getActes.log
00 12 * * * root php /var/www/extranetrec/batch/sendBilanClient.php --send >> /var/www/data/log/sendBilanClient.log
00 19 * * * root php /var/www/extranetrec/batch/sendBilanClient.php --send >> /var/www/data/log/sendBilanClient.log
# Reprise des actes en erreur infogreffe
00 6,13 * * * root php /var/www/extranet/batch/greffeCmdTelechargement.php --reprise >> /var/www/data/log/greffeCmdTelechargement.log
00 9 * * * root php /var/www/extranet/batch/greffeCmdTelechargement.php --rapport >> /var/www/data/log/greffeCmdTelechargement.log
00 13 1 * * root php /var/www/extranet/batch/greffeCmdMois.php $(date +\%Y\%m -d "-2 month")
30 14 * * 6 root php /var/www/extranet/batch/removeTempFile.php --all
*/

View File

@ -5,46 +5,19 @@
* pour envoyer sur le ftp
*/
// Define path to application directory
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// Define application environment
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
try {
$opts = new Zend_Console_Getopt(

View File

@ -1,227 +0,0 @@
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche l'aide.",
'acte' => "Intégration des actes ",
'bilan' => "Intégration des bilans",
'echo' => "Affiche les informations lors du traitement",
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(count($opts->getOptions())==0 || isset($opts->help))
{
echo "Vérifie les actes numérisés reçus en provenance des Greffes.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->sdv1);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
function fichierBilan($fichier)
{
global $dirStockage, $dirPDF;
if (preg_match('/^(bilan|acte)-([0-9]{9})-([0-9]{4})_([a-z]{0,})-([0-9]{8})/', $fichier, $matches))
{
$siren = $matches[2];
$annee = $matches[3];
$type = $matches[4];
if ($type == '') $type = 'sociaux';
$dateCloture = $matches[5];
//Création arborescence repertoire
$dirNew = $dirStockage.'/bilans/'.$type.'/'.$annee;
if (!is_dir($dirNew)) { mkdir($dirNew, 0777, true); }
//Copie du fichier
$fichierDest = 'bilan-'.$siren.'-'.$type.'-'.$dateCloture.'.pdf';
if (file_exists($dirNew.'/'.$fichierDest))
{
echo "BILAN - Le fichier $fichier a déjà été copié.\n";
}
else
{
if ( copy($dirPDF.'/'.$fichier, $dirNew.'/'.$fichierDest) )
{
echo "BILAN - Copie du fichier $dirPDF/$fichier vers $dirNew/$fichierDest\n";
}
else
{
echo "BILAN - ERREUR - Copie du fichier $fichier impossible!\n";
}
}
}
else
{
echo "BILAN - ERREUR - Fichier $fichier ne correspond pas au schéma.\n";
}
}
function fichierActe($fichier)
{
global $dirStockage, $dirPDF;
if (preg_match('/^acte-([0-9]{9})-(ST)-([0-9]{8})-.*\.pdf/', $fichier, $matches)) {
$siren = $matches[1];
$type_acte = $matches[2];
$date_acte = $matches[3];
$annee = substr($date_acte,0,4);
$mois = substr($date_acte,4,2);
//Création arborescence repertoire
$dirNew = $dirStockage.'/actes/'.$annee.'/'.$mois;
if (!is_dir($dirNew)) { mkdir($dirNew, 0, true); }
//Copie du fichier
if (file_exists($dirNew.'/'.$fichier)) {
//echo "ACTE - Le fichier $fichier a déjà été copié.\n";
} else {
if ( copy($dirPDF.'/'.$fichier, $dirNew.'/'.$fichier) ) {
echo "ACTE - Copie du fichier $dirPDF/$fichier vers $dirNew/$fichier\n";
} else {
echo "ACTE - ERREUR - Copie du fichier $fichier impossible!\n";
}
}
} elseif (preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-([0-9]{8})-.*-([0-9]{2})\.pdf/', $fichier, $matches)) {
$siren = $matches[1];
$type_acte = $matches[2];
$date_acte = $matches[3];
$annee = substr($date_acte,0,4);
$mois = substr($date_acte,4,2);
$num_acte = $matches[4];
$actesM = new Application_Model_ActesFiles();
$sql = $actesM->select()
->where('siren=?', $siren)
->where('type=?', $type_acte)
->where('date=?', $date_acte)
->where('num=?', $num_acte);
$result = $actesM->fetchRow($sql);
//Création arborescence repertoire
$dirNew = $dirStockage.'/actes/'.$annee.'/'.$mois;
if (!is_dir($dirNew)) { mkdir($dirNew, 0777, true); }
//Copie du fichier
if (file_exists($dirNew.'/'.$fichier)) {
//echo "ACTE - Le fichier $fichier a déjà été copié.\n";
} else {
if ( copy($dirPDF.'/'.$fichier, $dirNew.'/'.$fichier) ) {
if ( null === $result ) {
$actesM->insert(array(
'siren' => $siren,
'type' => $type_acte,
'date' => $date_acte,
'num' => $num_acte,
'file' => $fichier,
));
}
echo "ACTE - Copie du fichier $dirPDF/$fichier vers $dirNew/$fichier\n";
} else {
echo "ACTE - ERREUR - Copie du fichier $fichier impossible!\n";
}
}
}
else
{
echo "ACTE - ERREUR - Fichier $fichier ne correspond pas au schéma.\n";
}
}
//=> Start
$dirPDF = '/var/www/data/pdf';
$dirStockage = '/var/www/data/greffes';
if (!is_dir($dirStockage)) {
echo "Le nouveau répertoire $dirStockage n'a pas été trouvé.\n";
exit;
}
if (!is_dir($dirStockage.'/bilans')) {
mkdir($dirStockage.'/bilans');
}
if (!is_dir($dirStockage.'/actes')) {
mkdir($dirStockage.'/actes');
}
$i = 0;
if ($handle = opendir($dirPDF)) {
while ( false !== ($file = readdir($handle)) ) {
$i++;
if ( $file != '..' && $file != '.' ) {
if ($opts->echo) echo "Analyse du fichier $file ($i)\n";
// Traitement acte
if ($opts->acte) {
if ( preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-/', $file) ) {
fichierActe($file);
}
}
// Traitement bilan
if ($opts->bilan) {
if ( preg_match('/^(bilan|acte)-([0-9]{9})-([0-9]{4})_/', $file) ) {
fichierBilan($file);
}
}
}
}
}

View File

@ -1,378 +0,0 @@
#!/usr/bin/php -q
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche l'aide.",
'list' => "Liste les actes en attente disponible sur le FTP et affiche les informations",
'get-s' => "Recupère seulement les actes du FTP (un seul document si la référence est spécifier G<NNN> )",
'send-s' => "Récupère les actes et envoi un mail à chaque client (un seul acte si la référence est spécifier G<NNN>)",
'control' => "Control",
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(count($opts->getOptions())==0 || isset($opts->help))
{
echo "Vérifie les actes numérisés reçus en provenance des Greffes.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
$test = false;
if (isset($opts->list)){
$test = true;
}
//Configuration FTP
define ('ACTES_IGNUM_FTP_URL', 'ftp2.scores-decisions.com');
define ('ACTES_IGNUM_FTP_USER', 'mpc2500');
define ('ACTES_IGNUM_FTP_PASS', 'passmpc78');
define ('PATH_DATA', $c->profil->path->data);
define ('ACTES_IGNUM_LOCAL_DIR', PATH_DATA.'/pdf/scan/');
define ('ACTES_IG_LOCAL_DIR', PATH_DATA.'/pdf/');
$report_email = $c->profil->mail->email->support;
$report_subject = 'Traitement des actes '.date('Y-m-d H:i:s');
$report_txt = '';
function sendMail($commande, $nomCible){
$subject = "Actes ou Statuts disponible pour ".$commande['siren'];
$message = "Le document commandé pour le siren ".$commande['siren']." est disponible en téléchargement sur le site de Scores & Décisions à l'adresse suivante :\r\n\r\n";
$message.= "http://extranet.scores-decisions.com/fichier/pdf/$nomCible\r\n";
$headers = 'From: infoslegales@scores-decisions.com' . "\r\n" .
'Reply-To: infoslegales@scores-decisions.com';
if ( mail($commande['emailCommande'], $subject, utf8_decode($message), $headers) ){
echo date ('Y/m/d - H:i:s').' - Un email a été envoyé à '.$commande['emailCommande']." pour la commande $nomCible.\n";
return true;
} else {
echo date ('Y/m/d - H:i:s').' - ERREUR : Impossible d\'envoyer l\'email à '.$commande['emailCommande']." pour la commande $nomCible.\n";
return false;
}
}
set_time_limit(0);
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->sdv1);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
/**
* List actes files and check if an entry exist in the database
* greffes/actes/AAAA/MM
* preg_match('/^acte-([0-9]{9})-(ST)-([0-9]{8})-.*\.pdf/', $fichier, $matches)
* preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-([0-9]{8})-.*-([0-9]{2})\.pdf/', $fichier, $matches)
*/
if ($opts->control) {
$dir = PATH_DATA.'/greffes/actes';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
//Annee
while (($anneeDir = readdir($dh)) !== false) {
if ($anneeDir != '.' || $anneeDir != '..') {
echo "Dir ".$dir . DIRECTORY_SEPARATOR . $anneeDir."\n";
if ($dhAnneeDir = opendir($dir . DIRECTORY_SEPARATOR . $anneeDir)) {
//Mois
while (($moisDir = readdir($dhAnneeDir)) !== false) {
echo "Dir ".$dir . DIRECTORY_SEPARATOR . $anneeDir . DIRECTORY_SEPARATOR . $moisDir."\n";
if ($moisDir != '.' || $moisDir != '..') {
//Fichier
if ($dhFile = opendir($dir . DIRECTORY_SEPARATOR . $anneeDir . DIRECTORY_SEPARATOR . $moisDir)) {
while (($file = readdir($dhFile)) !== false) {
if ($file != '.' || $file != '..') {
if (preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-([0-9]{8})-.*-([0-9]{2})\.pdf/', $file, $matches)) {
$siren = $matches[1];
$type = $matches[2];
$date = $matches[3];
$num = $matches[4];
$actesM = new Application_Model_ActesFiles();
$sql = $actesM->select()
->where('siren=?', $siren)
->where('type=?', $type)
->where('date=?', $date)
->where('num=?', $num);
$result = $actesM->fetchRow($sql);
if ( null === $result ) {
echo "Insert $file\n";
$actesM->insert(array(
'siren' => $siren,
'type' => $type,
'date' => $date,
'num' => $num,
'file' => $file,
));
}
}
}
}
closedir($dhFile);
}
}
}
closedir($dhAnneeDir);
}
}
}
closedir($dh);
}
}
exit;
}
/**
* Liste des commandes non traités depuis la base de données
*/
$sql = "SELECT idCommande, idUser, login, emailCommande, siren, refDocument, typeCommande, dateCommande FROM commandes WHERE dateReception=0";
$tabCommandes = $db->fetchAssoc($sql);
$nbCommandes = count($tabCommandes);
$tabTmp = array();
foreach ($tabCommandes as $commande) {
if ($commande['typeCommande']=='C'){
$tabTmp['c'.$commande['idCommande']] = $commande;
} elseif ($commande['typeCommande']=='G' || $commande['typeCommande']==''){
$tabTmp['g'.$commande['idCommande']] = $commande;
}
}
$tabCommandes = $tabTmp;
unset($tabTmp);
echo date('Y/m/d - H:i:s') ." - Il y a $nbCommandes commandes en attente de réception courrier ou numérisation !\n";
/**
* Connexion au site FTP pour la récupération de la liste des fichiers au format pdf
*/
$conn_id = ftp_connect(ACTES_IGNUM_FTP_URL);
if (!$conn_id) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de se connecter au serveur FTP (".ACTES_IGNUM_FTP_URL.") !\n";
exit;
}
$login_result = ftp_login($conn_id, ACTES_IGNUM_FTP_USER, ACTES_IGNUM_FTP_PASS);
if (!$login_result) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de s'authentifier sur le serveur FTP (".ACTES_IGNUM_FTP_URL.")!\n";
exit;
}
$contents = ftp_nlist($conn_id, "*.pdf");
/**
* Liste de tout les fichiers disponible dans le repertoire
* et associe une clé pour faciliter le tri
*/
$tabFichiersFtp = array();
foreach ($contents as $filename){
$indice = 0;
if (preg_match('/[g|c][0-9]+\.pdf/', $filename)
|| preg_match('/[g|c][0-9]+-[0-9]{1,2}\.pdf/', $filename)){
list($ref, $indice) = explode('-', str_replace(array('.pdf', 'g', 'c'), array('','',''), $filename));
if(empty($indice)) $indice = 0;
$tabFichiersFtp[$ref.'-'.$indice] = strtolower($filename);
// Fichiers en anomalies
} else {
if ($test){
echo "Erreur : Anomalie fichier numérisé $filename\n";
} else {
$subject = "Erreur : Anomalie fichier numérisé";
$message = "Le fichier $filename a été trouvé et ne correspond pas au format attendu";
$headers = 'From: supportdev@scores-decisions.com' . "\r\n" .
'Reply-To: supportdev@scores-decisions.com';
mail('supportdev@scores-decisions.com', $subject, $message, $headers);
}
}
}
/**
* Tri des fichiers par ordre décroissant
* Les noms des fichiers sont incrémenté par 1
*/
krsort($tabFichiersFtp);
/**
* Dans le cas ou il y a eu une erreur de scan, la production passe a nouveau le
* document dans le scanner et le fichier est envoyé sur le ftp
* Le document est nommé G[ref],G[ref]-1,G[ref]-2,.....pdf.
* On garde donc le dernier document scanné.
*/
$lastRef = '';
$tabFichiersTemp = array();
foreach($tabFichiersFtp as $k => $val)
{
list($ref, $indice) = explode('-',$k);
if( $lastRef != $ref ) {
$tabFichiersTemp[$ref] = $val;
}
$lastRef = $ref;
}
$tabFichiers = $tabFichiersTemp;
unset($tabFichiersTemp);
/**
* Pour chaque commande, test de la présence d'un fichier associé
* Si le fichier correspond téléchargement du fichier
*/
foreach ($tabCommandes as $ref => $commande){
foreach ($tabFichiers as $refAssocie => $fichier){
if (substr($ref,1) == $refAssocie){
echo date ('Y/m/d - H:i:s')." - Traitement de la commande $ref\n";
if ($test){
echo date ('Y/m/d - H:i:s')." - Fichier $fichier \n";
} else {
//Récupération du fichier depuis le FTP (s'il n'existe pas déjà)
if (!file_exists(ACTES_IGNUM_LOCAL_DIR.$fichier)){
if (ftp_get($conn_id, ACTES_IGNUM_LOCAL_DIR.$fichier, $fichier, FTP_BINARY, 0)) {
echo date ('Y/m/d - H:i:s')." - Fichier $fichier téléchargé depuis le serveur FTP.\n";
} else {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de télécharger le fichier $fichier !\n";
}
}
//Copie et renommage du fichier suivant la ref infogreffe (s'il n'existe pas déjà)
$sirenC = $commande['siren'];
$refC = $commande['refDocument'];
require_once 'Infogreffe/Infogreffe.php';
$infogreffe = new Infogreffe();
if (preg_match('/^([0-9]{4}_).*?$/', $refC, $matches)){
$path = $infogreffe->bilanPath($refC);
$nomCible = $infogreffe->bilanFilename($sirenC, $refC);
$type = 'bilan';
} else {
$path = $infogreffe->actePath($refC);
$nomCible = $infogreffe->acteFilename($sirenC, $refC);
$type = 'acte';
}
if (file_exists(ACTES_IGNUM_LOCAL_DIR.$fichier)
&& !file_exists(PATH_DATA.$path.$nomCible)) {
if (rename(ACTES_IGNUM_LOCAL_DIR.$fichier, PATH_DATA.$path.$nomCible)){
if ( $type == 'acte' ){
preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-([0-9]{8})-(.*)-(.*)-(.*)-(.*)-(.*)-([0-9]{1,})\.pdf$/', $nomCible, $matches);
$siren = $matches[1];
$type_acte = $matches[2];
$date_acte = $matches[3];
$num_acte = $matches[9];
$actesM = new Application_Model_ActesFiles();
$sql = $actesM->select()->where('file=?',$nomCible);
$result = $actesM->fetchRow($sql);
if ( null === $result ) {
$actesM->insert(array(
'siren' => $siren,
'type' => $type_acte,
'date' => $date_acte,
'num' => $num_acte,
'file' => $nomCible,
));
}
}
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déplacé en ".PATH_DATA.$path.$nomCible.".\n";
} else {
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".ACTES_IGNUM_LOCAL_DIR.$fichier." en ".PATH_DATA.$path.$nomCible." !\n";
}
}
//Envoi du mail et Mise à jour de la commande
$testMail = false;
if (file_exists(PATH_DATA.$path.$nomCible)){
if ($testMail){
echo "Envoi fichier $nomCible ($ref) à ".$commande['emailCommande'];
} else {
$report_txt.= "$ref intégré à l'extranet";
$isMailSent = false;
if (trim($commande['emailCommande'])!=''){
$isMailSent = sendMail($commande, $nomCible);
} else {
$isMailSent = true;
}
if ($isMailSent){
echo date ('Y/m/d - H:i:s')." - Commande $ref mise à jour\n";
$commandesM = new Application_Model_Commandes();
$data = array( 'dateReception' => date('YmdHis'));
$commandesM->update($data, 'idCommande='.$commande['idCommande']);
$report_txt.= ' - Email envoyé à '.$commande['emailCommande'];
} else {
$report_txt.= ' - Email non envoyé !';
echo date ('Y/m/d - H:i:s')." ERREUR - Email non envoyé et commande $ref non mise à jour\n";
}
$report_txt.= "\n";
}
}
}
break;
}
}
}
ftp_close($conn_id);
if (empty($report_txt)) {
$report_txt = "Aucun envoi.";
}
//Envoi du mail de rapport
if (!$test && !$testMail){
if (mail($report_email, $report_subject, utf8_decode($report_txt))){
echo date ('Y/m/d - H:i:s')." - Rapport envoyé.\n";
} else {
echo date ('Y/m/d - H:i:s')." - Erreur lors de l'envoir du rapport !\n";
}
}
?>

View File

@ -1,44 +1,17 @@
<?php
// Define path to application directory
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// Define application environment
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
try {
$opts = new Zend_Console_Getopt(

View File

@ -1,179 +0,0 @@
#!/usr/bin/php -q
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche l'aide.",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help))
{
echo "Liste les commandes courrier traités";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
require_once 'Scores/WsScores.php';
define('LOGIN', 'mricois');
define('PASSWORD', '');
function listeCmd($statut)
{
$commandes = new Application_Model_Commandes();
$sql = $commandes->select()
->where('typeCommande = ?', 'C')
->where('statutCommande = ?', $statut);
$listeCmd = $commandes->fetchAll($sql);
if(count($listeCmd)>0){
$output = "<table border=\"1\" style=\"border:1px solid; margin:5px; border-collapse:collapse;\">";
$output.= "<thead>";
$output.= "<tr>";
$output.= "<th>Ref.</th>";
$output.= "<th>Siren</th>";
$output.= "<th>Ref. Document</th>";
$output.= "<th>Date de commande</th>";
$output.= "</tr>";
$output.= "</thead>";
$output.= "<tbody>";
foreach($listeCmd as $cmd){
$output.= "<tr>";
$output.= "<td style=\"padding:5px\">C".$cmd->idCommande."</td>";
$output.= "<td style=\"padding:5px\">".
"<a href=\"http://extranetrec.scores-decisions.com/".
"?page=competences&idEntreprise=0&siret=".
$cmd->siren."&type=tri\" >".
$cmd->siren.
"</a></td>";
$output.= "<td style=\"padding:5px\">".$cmd->refDocument."</td>";
$output.= "<td style=\"padding:5px\">".$cmd->dateCommande."</td>";
$output.= "</tr>";
if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) ){
$type = 'bilans';
}else{
$type = 'actes';
}
$tribunalCode = codeTribunal($cmd->siren);
$infoPaiement = infoPaiement($tribunalCode, $type);
$txtInfo = "Pas d'information de paiement enregistré dans la base.";
if($infoPaiement!==false){
$txtInfo =
"Chéque de ".$infoPaiement['prix']." ".
"à l'ordre de ".$infoPaiement['ordre'];
if($infoPaiement['enveloppe'])
$txtInfo.= ", fournir une enveloppe timbré";
}
$output.= "<tr>";
$output.= "<td>&nbsp;</td>";
$output.= "<td colspan=\"3\">".$txtInfo."</td>";
$output.= "</tr>";
}
$output.= "</tbody>";
$output.= "</table>";
}else{
$output.= "Aucune commande<br/>";
}
return $output;
}
function codeTribunal($siren)
{
$ws = new WsScores(LOGIN, PASSWORD);
$identite = $ws->getIdentite($siren, 0);
return $identite->TribunalCode;
}
function infoPaiement($codeTribunal, $type)
{
$tarifs = new Application_Model_CommandesTarifs();
$sql = $tarifs->select()
->where('annee = ?', date('Y'))
->where('type = ?', $type)
->where('codeTribunal = ?', $codeTribunal);
$rows = $tarifs->fetchAll($sql);
if(count($rows)>0) {
return array(
'prix'=> $rows[0]->prix,
'enveloppe' => $rows[0]->enveloppe,
'ordre' => $rows[0]->ordre
);
} else {
return false;
}
}
$emailTxt = "";
//Liste commandes non-traites
$emailTxt.= "<b><u>Liste des commandes courrier non-traités</u></b>";
$emailTxt.= "<br/>";
$emailTxt.= listeCmd(0);
$emailTxt.= "<br/>";
//Liste des commandes en attente de cheques
$emailTxt.= "<b><u>Liste des commandes courrier en attente de chèque</u></b>";
$emailTxt.= "<br/>";
$emailTxt.= listeCmd(1);
//Envoi mail
$mail = new Scores_Mail_Method();
$mail->setFromKey('production');
$mail->addTo('support@scores-decisions.com', 'Pieces');
$mail->setSubject("[COMMANDES PIECES COURRIER] - ".date('d')."/".date('m')."/".date('Y'));
$mail->setBodyHtml($emailTxt);
$mail->execute();

View File

@ -1,153 +0,0 @@
#!/usr/bin/php -q
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche l'aide.",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help))
{
echo "Liste les commandes non envoyées du mois dernier";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
echo $argv[0] . ' [AAAAMM] >> /vers/fichier.log';
echo "\n";
exit;
}
$args = $opts->getRemainingArgs();
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->sdv1);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
function listCmdMois($statut, $date)
{
$commandes = new Application_Model_Commandes();
$sql = $commandes->select()
->where('typeCommande = ?', 'G')
->where('statutCommande = ?', $statut)
->where('dateCommande LIKE ?', $date.'%')
->where('dateReception = ?', '0000-00-00 00:00:00');
return $commandes->fetchAll($sql);
}
//=> Debut
if (count($args)>1){
echo "Erreur\n";
exit;
} elseif (count($args)==0){
$timeMoisPrecedent = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
$moisPrecedent = date('Y-m', $timeMoisPrecedent);
} else {
$moisPrecedent = substr($args[0],0,4).'-'.substr($args[0],4,2);
}
$listeCmd = listCmdMois(0, $moisPrecedent);
$emailTxt = '';
//Liste commandes non-traites
$emailTxt.= '<b><u>Commandes greffe non receptionné</u></b>';
$emailTxt.= '<br/>';
if(count($listeCmd)>0){
$emailTxt.= '<table border="1" style="border:1px solid; margin:5px; border-collapse:collapse;">';
$emailTxt.= '<thead>';
$emailTxt.= '<tr>';
$emailTxt.= '<th>Ref.</th>';
$emailTxt.= '<th>Siren</th>';
$emailTxt.= '<th>Ref. Document</th>';
$emailTxt.= '<th>Date de commande</th>';
$emailTxt.= '</tr>';
$emailTxt.= '</thead>';
$emailTxt.= '<tbody>';
foreach($listeCmd as $cmd){
$emailTxt.= '<tr>';
$emailTxt.= '<td style="padding:5px">G'.$cmd->idCommande.'</td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->siren.'</a></td>';
if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) ){
$type = 'bilans';
}else{
$type = 'actes';
}
$emailTxt.= '<td style="padding:5px"><a href="/pieces/'.$type.'/siret/'.$cmd->siren.'">'.$cmd->refDocument.'</a></td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->dateCommande.'</td>';
$emailTxt.= '</tr>';
}
$emailTxt.= '</tbody>';
$emailTxt.= '</table>';
}else{
$emailTxt.= "Aucune commande<br/>";
}
$emailTxt.= '<br/>';
//Envoi mail
$mail = new Scores_Mail_Method();
$mail->setSubject("[Commandes greffe non receptionné] - ".date('d')."/".date('m')."/".date('Y'));
$mail->setFromKey('production');
$mail->addTo('support@scores-decisions.com', 'Support');
$mail->addTo('supportdev@scores-decisions.com', 'SupportDev');
$mail->setBodyHtml($emailTxt);
$mail->execute();

View File

@ -1,200 +0,0 @@
#!/usr/bin/php -q
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche l'aide.",
'reprise' => "Reprise des actes en erreur de moins de 120 heures",
'rapport' => "Envoi d'un email listant les commandes en erreur à J-1",
'rapportcomplet' => "Envoi d'un email listant toutes les commandes en erreur",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
/**
* Usage
*/
if(count($opts->getOptions())==0 || isset($opts->help))
{
echo "Reprise de commande InfoGreffe par le WebService.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
define ('PATH_DATA', $c->profil->path->data);
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->sdv1);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
$db->setFetchMode(Zend_Db::FETCH_OBJ);
if ( isset($opts->reprise) )
{
$timestamp = mktime(0, 0, 0, date("m"), date("d")-5, date("Y"));
$daybefore = date('Y-m-d', $timestamp);
$commandesM = new Application_Model_CommandesErreur();
$sql = $commandesM->select()->where("dateReception='0000-00-00 00:00:00' AND dateCommande > '".$daybefore." 00:00:00'");
$repErreur = $commandesM->fetchAll($sql);
if (count($repErreur)==0) exit;
foreach($repErreur as $cmd)
{
require_once 'Infogreffe/Infogreffe.php';
$infogreffe = new Infogreffe();
switch($cmd->type){
case 'acte':
$path = $infogreffe->actePath($cmd->ref);
$fichier = $infogreffe->acteFilename($cmd->siren, $cmd->ref);
break;
case 'bilan':
$path = $infogreffe->bilanPath('0000_'.$cmd->ref);
$fichier = $infogreffe->bilanFilename($cmd->siren, '0000_'.$cmd->ref);
break;
}
echo date('Y-m-d\TH:i:s').' - '.$path.$fichier." = ";
$dl = $infogreffe->dl($path.$fichier, $cmd->url, false);
echo $dl."\n";
if( $dl ) {
$data = array('erreur' => '', 'dateReception' => date('Y-m-d H:i:s'));
$where = "siren='".$cmd->siren."' AND type='".$cmd->type."' AND ref='".$cmd->ref."' AND dateCommande='".$cmd->dateCommande."'";
$commandesM->update($data, $where);
}
}
}
if ( isset($opts->rapport) || isset($opts->rapportcomplet) )
{
$commandesM = new Application_Model_CommandesErreur();
if (isset($opts->rapportcomplet)) {
$sql = $commandesM->select()->where("erreur!='' AND dateReception='0000-00-00 00:00:00'")
->order("dateCommande ASC");
$sujet = "[Commandes Greffe - Erreur WebService] - Rapport Complet";
} else {
$timestamp = mktime(0, 0, 0, date("m"), date("d")-1, date("Y"));
$hier = date('Y-m-d', $timestamp);
$sujet = "[Commandes Greffe - Erreur WebService] - ".$hier;
$sql = $commandesM->select()->where("(dateCommande BETWEEN '".$hier." 00:00:00' AND '".$hier." 23:59:59') AND erreur!='' AND dateReception='0000-00-00 00:00:00'")
->order("dateCommande ASC");;
}
$repErreur = $commandesM->fetchAll($sql);
$emailTxt = '<b><u>Commandes Greffe - Erreur WebService</u></b>';
$emailTxt.= '<br/>';
if (count($repErreur)==0) {
$emailtTxt.= "Aucune commande en erreur !";
} else {
$emailTxt.= '<table border="1" style="border:1px solid; margin:5px; border-collapse:collapse;">';
$emailTxt.= '<thead>';
$emailTxt.= '<tr>';
$emailTxt.= '<th>Siren</th>';
$emailTxt.= '<th>Type</th>';
$emailTxt.= '<th>Ref</th>';
$emailTxt.= '<th>Date de commande</th>';
$emailTxt.= '<th>URL</th>';
$emailTxt.= '<th>Erreur</th>';
$emailTxt.= '</tr>';
$emailTxt.= '</thead>';
$emailTxt.= '<tbody>';
foreach($repErreur as $cmd)
{
require_once 'Infogreffe/Infogreffe.php';
$infogreffe = new Infogreffe();
switch($cmd->type){
case 'acte':
$path = $infogreffe->actePath($cmd->ref);
$fichier = $infogreffe->acteFilename($cmd->siren, $cmd->ref);
break;
case 'bilan':
$path = $infogreffe->bilanPath($cmd->ref);
$fichier = $infogreffe->bilanFilename($cmd->siren, $cmd->ref);
break;
}
//Le fichier existe, alors on a résolu le problème (mauellement ?)
if( file_exists(PATH_DATA . $path . $fichier) ) {
$data = array('erreur' => '', 'dateReception' => date('Y-m-d H:i:s'));
$where = "siren='".$cmd->siren."' AND type='".$cmd->type."' AND ref='".$cmd->ref."' AND dateCommande='".$cmd->dateCommande."'";
$commandesM->update($data, $where);
} else {
//Lister les fichier en erreur
$emailTxt.= '<tr>';
$emailTxt.= '<td style="padding:5px">'.$cmd->siren.'</td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->type.'</a></td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->ref.'</a></td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->dateCommande.'</td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->url.'</td>';
$emailTxt.= '<td style="padding:5px">'.$cmd->erreur.'</td>';
$emailTxt.= '</tr>';
}
}
$emailTxt.= '</tbody>';
$emailTxt.= '</table>';
$emailTxt.= '<br/>';
$emailTxt = utf8_encode($emailTxt);
}
//Envoi mail
$mail = new Scores_Mail_Method();
$mail->setFromKey('production');
$mail->addTo('support@scores-decisions.com', 'Support');
$mail->addTo('supportdev@scores-decisions.com', 'Support Dev');
$mail->setSubject($sujet);
$mail->setBodyText($emailTxt);
$mail->execute();
}

View File

@ -1,44 +1,17 @@
<?php
// Define path to application directory
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// Define application environment
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
'Metier' => __DIR__ . '/../../library/Metier',
),
'fallback_autoloader' => true
)
));
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
try {
$opts = new Zend_Console_Getopt(