Correction pour aficher les erreurs
This commit is contained in:
parent
798c2defb2
commit
fab41ebdf0
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
class EnvoiController extends Zend_Controller_Action
|
class EnvoiController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
@ -7,12 +7,12 @@ class EnvoiController extends Zend_Controller_Action
|
|||||||
$this->view->headScript()->appendFile('/scripts/enrichissement.js', 'text/javascript');
|
$this->view->headScript()->appendFile('/scripts/enrichissement.js', 'text/javascript');
|
||||||
$this->view->headLink()->appendStylesheet('/styles/enrichissement.css');
|
$this->view->headLink()->appendStylesheet('/styles/enrichissement.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here ...
|
* Enter description here ...
|
||||||
*/
|
*/
|
||||||
public function indexAction(){}
|
public function indexAction(){}
|
||||||
|
|
||||||
public function fileformAction()
|
public function fileformAction()
|
||||||
{
|
{
|
||||||
$this->view->headScript()->appendFile('/scripts/jquery.form.js', 'text/javascript');
|
$this->view->headScript()->appendFile('/scripts/jquery.form.js', 'text/javascript');
|
||||||
@ -35,37 +35,37 @@ class EnvoiController extends Zend_Controller_Action
|
|||||||
->where("actif = 'Oui'");
|
->where("actif = 'Oui'");
|
||||||
$clients = $sqlmetier->fetchAll($sql, null, Zend_Db::FETCH_OBJ);
|
$clients = $sqlmetier->fetchAll($sql, null, Zend_Db::FETCH_OBJ);
|
||||||
|
|
||||||
$this->view->assign('clients', $clients);
|
$this->view->assign('clients', $clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fileuploadAction()
|
public function fileuploadAction()
|
||||||
{
|
{
|
||||||
$this->_helper->layout()->disableLayout();
|
$this->_helper->layout()->disableLayout();
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
$name = $request->getParam('ref', '');
|
$name = $request->getParam('ref', '');
|
||||||
$idClient = $request->getParam('client');
|
$idClient = $request->getParam('client');
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
echo "Référence non définie.";
|
echo "Référence non définie.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
||||||
$path = realpath($config->data).'/validation';
|
$path = realpath($config->data).'/validation';
|
||||||
if(!file_exists($path)) mkdir($path);
|
if(!file_exists($path)) mkdir($path);
|
||||||
|
|
||||||
if ( isset($_FILES) && count($_FILES)==1 ){
|
if ( isset($_FILES) && count($_FILES)==1 ){
|
||||||
$n = $_FILES['fichier']['name'];
|
$n = $_FILES['fichier']['name'];
|
||||||
$s = $_FILES['fichier']['size'];
|
$s = $_FILES['fichier']['size'];
|
||||||
$tmp_name = $_FILES['fichier']['tmp_name'];
|
$tmp_name = $_FILES['fichier']['tmp_name'];
|
||||||
|
|
||||||
$extValide = array('csv');
|
$extValide = array('csv');
|
||||||
$extension = strrchr($n,'.');
|
$extension = strrchr($n,'.');
|
||||||
$extension = substr($extension,1);
|
$extension = substr($extension,1);
|
||||||
//Vérifier l'extension du fichier
|
//Vérifier l'extension du fichier
|
||||||
if(!in_array($extension, $extValide)){
|
if(!in_array($extension, $extValide)){
|
||||||
echo "Extension de fichier incorrect !";
|
echo "Extension de fichier incorrect !";
|
||||||
} elseif (move_uploaded_file($tmp_name, $path.'/'.$idClient.'-'.$name.'.'.$extension)){
|
} elseif (move_uploaded_file($tmp_name, $path.'/'.$idClient.'-'.$name.'.'.$extension)){
|
||||||
echo "Fichier envoyé, <a href=\"".
|
echo "Fichier envoyé, <a href=\"".
|
||||||
@ -81,7 +81,7 @@ class EnvoiController extends Zend_Controller_Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Etat de progression de l'upload du fichier
|
* Etat de progression de l'upload du fichier
|
||||||
*/
|
*/
|
||||||
@ -89,8 +89,8 @@ class EnvoiController extends Zend_Controller_Action
|
|||||||
{
|
{
|
||||||
$this->_helper->layout()->disableLayout();
|
$this->_helper->layout()->disableLayout();
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$key = $request->getParam('key', '');
|
$key = $request->getParam('key', '');
|
||||||
if (!empty($key)) {
|
if (!empty($key)) {
|
||||||
//$rep sera égal à false si la clef n'existe pas dans le cache apc
|
//$rep sera égal à false si la clef n'existe pas dans le cache apc
|
||||||
@ -98,35 +98,35 @@ class EnvoiController extends Zend_Controller_Action
|
|||||||
echo json_encode($rep);
|
echo json_encode($rep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkfileAction()
|
public function checkfileAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$file = $request->getParam('file');
|
$file = $request->getParam('file');
|
||||||
|
|
||||||
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
||||||
|
|
||||||
$pathIn = $config->data.'/validation';
|
$pathIn = $config->data.'/validation';
|
||||||
$pathOut = $config->data.'/clients';
|
$pathOut = $config->data.'/clients';
|
||||||
if(!file_exists($pathOut)) mkdir($pathOut);
|
if(!file_exists($pathOut)) mkdir($pathOut);
|
||||||
|
|
||||||
//Vérifier le format du fichier
|
//Vérifier le format du fichier
|
||||||
require_once 'Scores/Enrichissement.php';
|
require_once 'Scores/Enrichissement.php';
|
||||||
$data = new Enrichissement();
|
$data = new Enrichissement();
|
||||||
|
|
||||||
$result = $data->checkFileEntete($pathIn.'/'.$file);
|
$result = $data->checkFileEntete($pathIn.'/'.$file);
|
||||||
if ($result===FALSE)
|
if ($result===FALSE)
|
||||||
{
|
{
|
||||||
$this->view->assign('errors',array("Impossible de lire le fichier !"));
|
$this->view->assign('errors',array("Impossible de lire le fichier !"));
|
||||||
//Supprimer le fichier
|
//Supprimer le fichier
|
||||||
unlink($pathIn.'/'.$file);
|
unlink($pathIn.'/'.$file);
|
||||||
}
|
}
|
||||||
elseif (is_array($result))
|
elseif (is_array($result))
|
||||||
{
|
{
|
||||||
$this->view->assign('errors',$error);
|
$this->view->assign('errors',$result);
|
||||||
//Supprimer le fichier
|
//Supprimer le fichier
|
||||||
unlink($pathIn.'/'.$file);
|
unlink($pathIn.'/'.$file);
|
||||||
}
|
}
|
||||||
elseif (is_int($result))
|
elseif (is_int($result))
|
||||||
{
|
{
|
||||||
//Enregistrer dans la bdd
|
//Enregistrer dans la bdd
|
||||||
@ -146,5 +146,5 @@ class EnvoiController extends Zend_Controller_Action
|
|||||||
$this->view->assign('nb', $result);
|
$this->view->assign('nb', $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user