389 lines
10 KiB
PHP
389 lines
10 KiB
PHP
<?php
|
|
require_once realpath(dirname(__FILE__)).'/Types/InterneTypes.php';
|
|
|
|
class WsInterne
|
|
{
|
|
protected $dbConfig;
|
|
|
|
function __construct()
|
|
{
|
|
$dbConfig = new Zend_Config_Ini(APPLICATION_PATH .
|
|
'/configs/databases.ini', APPLICATION_ENV);
|
|
$this->dbConfig = $dbConfig->db;
|
|
}
|
|
|
|
/**
|
|
* Enregistrement des informations saisie manuellement
|
|
* @param string $siret
|
|
* @param int $idEntreprise
|
|
* @param array $tabInfos
|
|
*/
|
|
public function setInfosEntrep( $siret, $idEntreprise, $tabInfos )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Commande de bilan
|
|
* @param InfoCommandeBilan $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return SetCommandeReturnType
|
|
*/
|
|
public function setCommandeBilan( $infoCommande, $infoDemandeur )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande de bilan
|
|
* @param string $reference
|
|
* @return CommandeReturnType
|
|
*/
|
|
public function getCommandeBilan( $reference )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Commande d'acte
|
|
* @param InfoCommandeActe $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return SetCommandeReturnType
|
|
*/
|
|
public function setCommandeActe( $infoCommande, $infoDemandeur )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande d'acte
|
|
* @param string $reference
|
|
* @return CommandeReturnType
|
|
*/
|
|
public function getCommandeActe( $reference ){}
|
|
|
|
/**
|
|
* Commande de kbis
|
|
* @param InfoCommandeKbis $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return SetCommandeReturnType
|
|
*/
|
|
public function setCommandeKbis( $infoCommande, $infoDemandeur ){}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande de Kbis
|
|
* @param string $reference
|
|
* @return CommandeReturnType
|
|
*/
|
|
public function getCommandeKbis( $reference ){}
|
|
|
|
/**
|
|
* Commande de statut association
|
|
* @param InfoCommandeAsso $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return SetCommandeReturnType
|
|
*/
|
|
public function setCommandeAsso( $infoCommande, $infoDemandeur ){}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande association
|
|
* @param string $reference
|
|
* @return CommandeReturnType
|
|
*/
|
|
public function getCommandeAsso( $reference ){}
|
|
|
|
/**
|
|
* Commande de privilèges et nantissements par email
|
|
* @param InfoCommandePieces $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return CommandeReturnType
|
|
*/
|
|
public function setCommandePieces( $infoCommande, $infoDemandeur )
|
|
{
|
|
$error = new ErrorType();
|
|
$ref = new RefCommande();
|
|
|
|
if (!empty($infoCommande->siren))
|
|
{
|
|
$login = $_SERVER['PHP_AUTH_USER'];
|
|
//Vérification SIREN
|
|
//Vérification email - Si infoDemandeur->email vide alors on prend user_email
|
|
// Insertion des données commande
|
|
$dataCommandes = array(
|
|
'user_login' => $login,
|
|
'user_email' => '',
|
|
'type' => 'pieces',
|
|
'statut' => 0,
|
|
'demandeurReference' => $infoDemandeur->reference,
|
|
'demandeurEmail' => $infoDemandeur->email,
|
|
'demandeurTel' => $infoDemandeur->tel,
|
|
'demandeurNom' => $infoDemandeur->nom,
|
|
'demandeurService' => $infoDemandeur->service,
|
|
'demandeurSociete' => $infoDemandeur->societe,
|
|
'demandeurAdresse' => $infoDemandeur->adresse,
|
|
'demandeurCp' => $infoDemandeur->cp,
|
|
'demandeurVille' => $infoDemandeur->ville,
|
|
'infoCommande' => serialize($infoCommande)
|
|
);
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commande = new Application_Model_Commandes();
|
|
$commandes_id = $commande->insert($dataCommandes);
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')->err("setCommandePieces - ".$e->getMessage());
|
|
}
|
|
if ($commandes_id)
|
|
{
|
|
//Enregistrement des détails de commande
|
|
$dataCommandesPieces = array(
|
|
'commande_id' => $commandes_id,
|
|
'siren' => $infoCommande->siren,
|
|
'raisonSociale' => '',
|
|
'fichier' => '',
|
|
);
|
|
try {
|
|
$commandePieces = new Application_Model_CommandesPieces();
|
|
$commandePieces->insert($dataCommandesPieces);
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')->err("setCommandePieces - ".$e->getMessage());
|
|
}
|
|
|
|
try {
|
|
$row = $commande->find($commandes_id);
|
|
$data = $row->current();
|
|
$ref->reference = $data->id;
|
|
$ref->dateCommande = $data->date_added;
|
|
$ref->dateMaj = $data->date_updated;
|
|
$ref->dateReception = $data->date_closed;
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')->err("setCommandePieces - ".$e->getMessage());
|
|
$error->errnum = 0;
|
|
$error->errmsg = "Commande Introuvable";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = "Erreur enregistrement commande";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = 'Erreur SIREN invalide';
|
|
}
|
|
$output = new CommandeReturnType();
|
|
$output->error = $error;
|
|
$output->ref = $ref;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande pièces
|
|
* @param string $reference
|
|
* @return CommandeReturnType
|
|
*/
|
|
public function getCommandePieces( $reference ){}
|
|
|
|
/**
|
|
* Obtenir la liste des commandes passées
|
|
* @param ListeCommandeFiltre $filtre
|
|
* @param int $position
|
|
* @param int $nbRep
|
|
* @return ListeCommandeReturnType
|
|
*/
|
|
public function getListeCommande( $filtre, $position = 0, $nbRep = 20 )
|
|
{
|
|
$output = new ListeCommandeReturnType();
|
|
$error = new ErrorType();
|
|
$result = new ListeCommande();
|
|
$where = null;
|
|
$order = 'date_added DESC';
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commandes = new Application_Model_Commandes();
|
|
if (!empty($filtre->type))
|
|
{
|
|
switch($filtre->type)
|
|
{
|
|
case 'pieces':
|
|
$where = $commandes->select()->where('type = ?', 'pieces');
|
|
break;
|
|
}
|
|
}
|
|
$rows = $commandes->fetchAll($where, $order, $nbRep, $position);
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')->err("getListeStatut - ".$e->getMessage());
|
|
}
|
|
|
|
$liste = array();
|
|
if (count($rows)>0)
|
|
{
|
|
foreach ($rows as $r) {
|
|
$selectEven = $commandes->select()->order('date_added DESC')->limit(1);
|
|
$evens = $r->findDependentRowset('CommandesEven', null, $selectEven);
|
|
$data = $evens->toArray();
|
|
$info = '';
|
|
if (count($data)>0){
|
|
$info = $data[0]['commentaire'];
|
|
}
|
|
$fichier = '';
|
|
if (in_array($r['type'], array('pieces'))){
|
|
//@todo gérer la présence d'un fichier
|
|
}
|
|
$ref = new RefCommande();
|
|
$ref->reference = strtoupper($r['type']).'-'.$r['id'];
|
|
$ref->dateCommande = $r['date_added'];
|
|
$ref->dateMaj = $r['date_updated'];
|
|
$ref->dateReception = $r['date_closed'];
|
|
$ref->info = $info;
|
|
$ref->fichier = $fichier;
|
|
$ref->login = $r['user_login'];
|
|
$demandeur = new InfoDemandeur();
|
|
$demandeur->reference = $r['demandeurReference'];
|
|
$demandeur->email = $r['demandeurEmail'];
|
|
$demandeur->nom = $r['demandeurNom'];
|
|
$demandeur->tel = $r['demandeurTel'];
|
|
$demandeur->service = $r['demandeurService'];
|
|
$demandeur->societe = $r['demandeurSociete'];
|
|
$demandeur->adresse = $r['demandeurAdresse'];
|
|
$demandeur->cp = $r['demandeurCp'];
|
|
$demandeur->ville = $r['demandeurVille'];
|
|
$ref->demandeur = $demandeur;
|
|
$liste[] = $ref;
|
|
}
|
|
}
|
|
$result->nbCommandes = count($rows);
|
|
$result->commandes = $liste;
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Liste des bilans
|
|
* @param string $siren
|
|
* @param string $waldec
|
|
* @param int $idEntreprise
|
|
* @return ListeBilan
|
|
*/
|
|
public function getListeBilan( $siren, $waldec = null, $idEntreprise = null ){}
|
|
|
|
/**
|
|
* Liste des actes
|
|
* @param string $siren
|
|
* @return ListeActe
|
|
*/
|
|
public function getListeActe( $siren ){}
|
|
|
|
/**
|
|
* Retourne la liste des statuts de commande
|
|
* @param string $type
|
|
* @return Statut[]
|
|
*/
|
|
public function getListeStatut( $type )
|
|
{
|
|
Zend_Registry::get('WsLogger')->info("getListeStatut - ".$type);
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$dbStatut = new Application_Model_CommandesStatut();
|
|
$result = $dbStatut->fetchAll(array("commande_type = '$type'"));
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')->err("getListeStatut - ".$e->getMessage());
|
|
}
|
|
$listeStatut = array();
|
|
if (count($result)>0)
|
|
{
|
|
foreach($result as $r)
|
|
{
|
|
$statut = new Statut();
|
|
$statut->code = $r['code'];
|
|
$statut->lib = $r['libelle'];
|
|
$listeStatut[] = $statut;
|
|
}
|
|
}
|
|
return $listeStatut;
|
|
}
|
|
|
|
/**
|
|
* Spécifier un état défini pour une commande (avec déclenchement d'une action)
|
|
* @param string $reference
|
|
* @param int $statutCode
|
|
* @return bool
|
|
*/
|
|
public function setCommandeStatut( $reference, $statutCode)
|
|
{
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$dbStatut = new Application_Model_CommandesStatut();
|
|
$result = $dbStatut->fetchRow(array("code = '$statutCode'"));
|
|
if ( count($result)>0 && $this->setCommandeEven($reference, $statut->lib) )
|
|
{
|
|
if (!empty($result->action)){
|
|
switch($result->action){
|
|
case 'CLOSE':
|
|
//date_closed
|
|
break;
|
|
}
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Spécifier un état pour une commande
|
|
* @param string $reference
|
|
* @param string $comment
|
|
* @return bool
|
|
*/
|
|
public function setCommandeEven ( $reference, $comment )
|
|
{
|
|
$login = $_SERVER['PHP_AUTH_USER'];
|
|
//Vérifier que la commande existe avec la référence fournie
|
|
//Enregistrer l'information
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commandeEven = new Application_Model_CommandesEven();
|
|
$insert = $commandeEven->createRow();
|
|
$insert->commande_id = (int)$reference;
|
|
$insert->commentaire = $comment;
|
|
$insert->user_login = $login;
|
|
$insert->save();
|
|
return true;
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')->err("getListeStatut - ".$e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ajout du nom de fichier liée à la commande
|
|
* @param string $reference
|
|
* @param string $filename
|
|
*/
|
|
public function setCommandeDocument( $reference, $filename )
|
|
{
|
|
//Suivant la référence,
|
|
|
|
//On détermine le type
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} |