2013-11-05 11:18:30 +00:00
|
|
|
<?php
|
2014-09-12 14:57:26 +00:00
|
|
|
require_once 'framework/fwk.php';
|
|
|
|
require_once 'framework/mail/sendMail.php';
|
|
|
|
require_once 'Metier/insee/classMInsee.php';
|
|
|
|
require_once 'Metier/insee/classMSirene.php';
|
|
|
|
require_once 'Metier/partenaires/classMBilans.php';
|
|
|
|
require_once 'Metier/partenaires/classMBourse.php';
|
|
|
|
require_once 'Metier/partenaires/classMTva.php';
|
|
|
|
require_once 'Metier/partenaires/classMMap.php';
|
|
|
|
require_once 'Metier/partenaires/classMGreffes.php';
|
|
|
|
require_once 'Metier/partenaires/classMPrivileges.php';
|
|
|
|
require_once 'Metier/scores/classMFinancier.php';
|
|
|
|
require_once 'Metier/scores/classMSolvabilite.php';
|
|
|
|
|
2014-05-24 16:57:17 +00:00
|
|
|
require_once __DIR__ . '/Types.php';
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-05-24 09:12:09 +00:00
|
|
|
class Pieces extends Scores_Ws_Server
|
2013-11-05 11:18:30 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Récupération d'un kbis
|
|
|
|
* @param string $siren
|
2014-07-25 13:49:04 +00:00
|
|
|
* SIREN ou SIRET siege
|
2014-02-13 14:17:20 +00:00
|
|
|
* @param string $diffusion
|
2014-04-04 07:22:34 +00:00
|
|
|
* Mode de diffusion (T=Téléchargement|M=Email|C=Courrier)
|
2014-02-13 14:17:20 +00:00
|
|
|
* @param string $reference
|
|
|
|
* Reference du client
|
2013-11-05 11:18:30 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
2014-02-25 16:33:07 +00:00
|
|
|
public function getKbis($siren, $diffusion = 'T', $reference = '')
|
2013-11-05 11:18:30 +00:00
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('KBIS');
|
|
|
|
|
2014-08-18 09:39:57 +00:00
|
|
|
$siren = substr($siren, 0, 9);
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
//Vérification du siren
|
2014-07-25 13:49:04 +00:00
|
|
|
if ( intval($siren)==0 ) {
|
2013-11-05 11:18:30 +00:00
|
|
|
$this->sendError('1010');
|
2014-08-18 09:39:57 +00:00
|
|
|
} elseif ( strlen($siren)!=9 ) {
|
2013-11-05 11:18:30 +00:00
|
|
|
$this->sendError('1020');
|
|
|
|
}
|
2014-08-27 08:58:20 +00:00
|
|
|
if ( empty($diffusion) ) {
|
|
|
|
$diffusion = 'T';
|
|
|
|
}
|
2014-07-10 14:58:00 +00:00
|
|
|
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$identite = $iInsee->getIdentiteLight($siren);
|
2014-08-18 12:36:10 +00:00
|
|
|
|
|
|
|
$refCommande = uniqid();
|
|
|
|
|
2014-08-27 08:58:20 +00:00
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
|
|
|
try {
|
|
|
|
$id = $commandeM->insert(array(
|
|
|
|
'refCommande' => $refCommande,
|
|
|
|
'login' => $this->User->login,
|
|
|
|
'email' => $this->User->email,
|
|
|
|
'refClient' => $reference,
|
|
|
|
'mode' => $diffusion,
|
|
|
|
'siren' => $siren,
|
|
|
|
'raisonSociale' => $identite['Nom'],
|
|
|
|
'dateInsert' => date('YmdHis'),
|
|
|
|
));
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
|
|
|
|
}
|
2014-02-13 14:17:20 +00:00
|
|
|
|
|
|
|
switch ( $diffusion ) {
|
|
|
|
|
2014-08-18 09:39:57 +00:00
|
|
|
//Demande de KBIS par email
|
|
|
|
case 'M':
|
|
|
|
//Demande de KBIS original par courrier
|
2014-02-13 14:17:20 +00:00
|
|
|
case 'C':
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-02-13 14:17:20 +00:00
|
|
|
return $refCommande;
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-02-13 14:17:20 +00:00
|
|
|
break;
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-08-18 09:39:57 +00:00
|
|
|
//Téléchargement du KBIS (payant)
|
2014-02-25 16:33:07 +00:00
|
|
|
case 'T':
|
2014-02-13 14:17:20 +00:00
|
|
|
default:
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-02-13 14:17:20 +00:00
|
|
|
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
|
|
|
if ($_SERVER['SERVER_PORT']!='80'){
|
|
|
|
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
2014-02-13 14:17:20 +00:00
|
|
|
|
|
|
|
$c = Zend_Registry::get('config');
|
|
|
|
$path = realpath($c->profil->path->secure).'/kbis/';
|
|
|
|
|
|
|
|
//Le fichier existe avec une date de validité inférieure à 1 jour
|
|
|
|
$filepdf = $path.$siren.'.pdf';
|
|
|
|
if ( file_exists($filepdf) && date('Ymd', filemtime($filepdf))==date('Ymd') ) {
|
|
|
|
|
|
|
|
$this->wsLog('kbis', $siren, basename($filepdf));
|
2014-08-18 12:36:10 +00:00
|
|
|
$commandeM->update(array('dateEnvoi'=> date('YmdHis')), 'id='.$id);
|
|
|
|
|
2014-02-13 14:17:20 +00:00
|
|
|
return $hostname.DOC_WEB_URL.'kbis/'.basename($filepdf);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$file = null;
|
|
|
|
|
|
|
|
//On vérifie quand même si il n'existe pas une commande en html
|
|
|
|
$dir = $path.date('Ymd');
|
|
|
|
if ( file_exists($dir) ) {
|
|
|
|
foreach ( glob($dir.'/'.$siren.'-*.html') as $file ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty($file) ) {
|
2014-07-10 14:58:00 +00:00
|
|
|
|
|
|
|
$identifiant = $identite['Siret'];
|
|
|
|
|
2014-02-13 14:17:20 +00:00
|
|
|
//Téléchargement du KBIS
|
|
|
|
$result = array();
|
2014-08-27 08:58:20 +00:00
|
|
|
exec('php '.$c->profil->path->batch.'/getKbis.php --siren '.$siren, $result);
|
2014-02-13 14:17:20 +00:00
|
|
|
$result = end($result);
|
|
|
|
if (substr($result,-5)=='.html')
|
|
|
|
{
|
2014-08-18 12:36:10 +00:00
|
|
|
$file = $dir.'/'.$result;
|
2014-02-13 14:17:20 +00:00
|
|
|
$this->wsLog('kbis', $siren, $result);
|
|
|
|
}
|
|
|
|
elseif ( $result!='ERREUR')
|
|
|
|
{
|
|
|
|
throw new SoapFault('MSG',$result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$text = 'La récupération du KBIS a échoué sur le siren : '.$siren;
|
|
|
|
sendMail(
|
|
|
|
'production@scores-decisions.com',
|
|
|
|
'supportdev@scores-decisions.com',
|
|
|
|
'[ERREUR KBIS]',
|
|
|
|
$text);
|
|
|
|
throw new SoapFault('0000',"Erreur récupération du kbis");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->wsLog('kbis', $siren, basename($file));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Génération du PDF
|
|
|
|
$pdf = new Scores_Wkhtml_Pdf();
|
|
|
|
$fileOut = $pdf->exec($file, $filepdf);
|
|
|
|
|
|
|
|
if ( !file_exists($filepdf) ) {
|
|
|
|
throw new SoapFault('0000',"Fichier PDF introuvable");
|
|
|
|
}
|
2014-08-18 12:36:10 +00:00
|
|
|
|
|
|
|
$commandeM->update(array('dateEnvoi'=> date('YmdHis')), 'id='.$id);
|
|
|
|
|
2014-02-13 14:17:20 +00:00
|
|
|
return $hostname.DOC_WEB_URL.'kbis/'.basename($filepdf);
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
2014-02-13 14:17:20 +00:00
|
|
|
|
|
|
|
break;
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Liste des bilans disponible au format image
|
|
|
|
* @param string $identifiant
|
|
|
|
* SIREN ou autre identifiant
|
|
|
|
* @param int $position
|
|
|
|
* Numéro de page
|
|
|
|
* @param int $nbRep
|
|
|
|
* Nombre de réponse par page (max=200)
|
|
|
|
* @return Bilans
|
|
|
|
* @throws SoapFault
|
|
|
|
*/
|
|
|
|
public function getBilans($identifiant, $position = 0, $nbRep = 200)
|
|
|
|
{
|
|
|
|
// @todo : Code Saisie + Date saisie
|
|
|
|
|
|
|
|
$this->authenticate();
|
|
|
|
|
|
|
|
if ( empty($position) ) {
|
|
|
|
$position = 0;
|
|
|
|
}
|
|
|
|
if ($nbRep > 200) {
|
|
|
|
$nbRep = 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( strlen($identifiant)!=9 ) {
|
|
|
|
$this->sendError('1010');
|
|
|
|
}
|
|
|
|
|
2014-01-29 08:39:29 +00:00
|
|
|
/**
|
2013-11-05 11:18:30 +00:00
|
|
|
* Entreprise avec des bilans
|
|
|
|
* Base RNCS
|
|
|
|
* Si association alors lire dans la base de données pour établir la liste
|
|
|
|
* //@todo : Enregistrer dans la base jo.greffes_bilans
|
|
|
|
*/
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$identite = $iInsee->getIdentiteLight($identifiant);
|
|
|
|
if (empty($identite['id'])){
|
|
|
|
$this->sendError('1020');
|
|
|
|
}
|
|
|
|
$fj = $identite['FJ'];
|
|
|
|
|
|
|
|
$assoFormeJuridique = array(
|
|
|
|
//Associations
|
|
|
|
'9210','9220','9221','9222','9223','9224','9230','9240','9260',
|
|
|
|
//Syndicats
|
|
|
|
'7345','7353','7354','7355','8410','8420','9110',
|
|
|
|
//Fondation
|
|
|
|
'9300',
|
|
|
|
);
|
|
|
|
|
|
|
|
$list = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Liste des bilans association
|
|
|
|
*/
|
|
|
|
if ( in_array($fj, $assoFormeJuridique) ) {
|
|
|
|
|
|
|
|
$bilansM = new Application_Model_JoAssoBilans();
|
|
|
|
//Comptage
|
|
|
|
$sql = $bilansM->select()
|
|
|
|
->from($bilansM, 'COUNT(*) as nb')
|
|
|
|
->where('siren=?', $identifiant);
|
|
|
|
|
|
|
|
$nbBilans = $bilansM->fetchRow($sql)->nb;
|
|
|
|
|
|
|
|
if ($nbBilans>0)
|
|
|
|
{
|
|
|
|
//Liste
|
|
|
|
$sql = $bilansM->select()
|
|
|
|
->from($bilansM, array('dateCloture', 'Assoc_Date_Declaration', 'pdfLink',
|
|
|
|
'typeCompte', 'pdfSize', 'pdfPage'))
|
|
|
|
->where('siren = ?', $identifiant)
|
|
|
|
->order('dateCloture DESC')
|
|
|
|
->limit($nbRep, $position);
|
|
|
|
$bilans = $bilansM->fetchAll($sql);
|
|
|
|
|
|
|
|
if( $bilans->count() > 0) {
|
|
|
|
foreach ($bilans as $item) {
|
|
|
|
|
|
|
|
$filename = basename($item->pdfLink);
|
|
|
|
$file = SECURE_STORAGE . 'association/bilans/' . $filename;
|
|
|
|
|
|
|
|
$bilansList = new Bilan();
|
|
|
|
$bilansList->DateCloture = substr($item->dateCloture,0,4).substr($item->dateCloture,5,2).substr($item->dateCloture,8,2);
|
|
|
|
$bilansList->DateDepot = substr($item->Assoc_Date_Declaration,0,4).substr($item->Assoc_Date_Declaration,5,2).substr($item->Assoc_Date_Declaration,8,2);
|
|
|
|
$bilansList->DureeExercice = '';
|
|
|
|
$bilansList->Type = $item->typeCompte;
|
|
|
|
|
|
|
|
//Chech file exist
|
|
|
|
if ( file_exists($file) )
|
|
|
|
{
|
|
|
|
$bilansList->File = 'ASS_'.$filename;
|
|
|
|
$bilansList->FileSize = $item->pdfSize;
|
|
|
|
$bilansList->NumberOfPages = $item->pdfPage;
|
|
|
|
$bilansList->ModeDiffusion = 'T';
|
|
|
|
}
|
|
|
|
$list[] = $bilansList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//Liste des bilans Infogreffe
|
|
|
|
else
|
|
|
|
{
|
2015-03-24 14:05:48 +00:00
|
|
|
$infogreffe = new SdMetier_Infogreffe_DocBI($identifiant);
|
2014-02-25 16:33:07 +00:00
|
|
|
try {
|
|
|
|
$list = $infogreffe->getList();
|
|
|
|
} catch (Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-02-25 16:33:07 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
$nbBilans = count($list);
|
2014-01-29 08:39:29 +00:00
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
//Ajout d'informations supplémentaires
|
|
|
|
if ( count($list)>0 ) {
|
|
|
|
foreach ( $list as $i => $item ) {
|
|
|
|
|
|
|
|
//Surcharge des codes de saisie
|
|
|
|
$date = new Zend_Date($item->DateCloture, 'yyyy-MM-dd');
|
|
|
|
try {
|
|
|
|
$liasseM = new Application_Model_JoBilans();
|
|
|
|
$sql = $liasseM->select()
|
|
|
|
->where('siren=?', $identifiant)
|
|
|
|
->where('dateExercice=?', $date->toString('yyyyMMdd'));
|
2014-07-10 14:58:00 +00:00
|
|
|
if ( $item->Type == 'consolides' ) {
|
|
|
|
$sql->where('typeBilan = "C"');
|
|
|
|
} elseif ( $item->Type == 'sociaux' ) {
|
|
|
|
$sql->where('typeBilan="N" OR typeBilan="S"');
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
$row = $liasseM->fetchRow($sql);
|
2014-02-25 16:33:07 +00:00
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-02-07 16:14:36 +00:00
|
|
|
//file_put_contents('debug.log', $e->getMessage()."\n", FILE_APPEND);
|
|
|
|
}
|
2014-07-10 14:58:00 +00:00
|
|
|
|
2014-07-10 15:07:13 +00:00
|
|
|
//Override SaisieDate
|
|
|
|
if ( $row === null ) {
|
|
|
|
|
2014-07-10 14:58:00 +00:00
|
|
|
//Reset greffe_bilans : duree_exercice, saisie_date, saisie_code, ctrl_code, pages
|
2014-07-10 15:07:13 +00:00
|
|
|
if ( $item->SaisieDate !== null ) {
|
|
|
|
try {
|
|
|
|
$bilansM = new Application_Model_JoGreffesBilans();
|
|
|
|
$bilansM->update(array(
|
|
|
|
'duree_exercice' => null,
|
|
|
|
'saisie_date' => null,
|
|
|
|
'saisie_code' => null,
|
|
|
|
'ctrl_code' => null,
|
|
|
|
'pages' => null,
|
|
|
|
), array('siren='.$identifiant, 'num_depot='.$item->NumDepot) );
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
file_put_contents('debug.log', $e->getMessage()."\n", FILE_APPEND);
|
|
|
|
}
|
2014-07-10 14:58:00 +00:00
|
|
|
}
|
|
|
|
$item->DureeExercice = null;
|
|
|
|
$item->SaisieDate = null;
|
|
|
|
$item->SaisieCode = null;
|
|
|
|
|
|
|
|
} else {
|
2014-02-07 16:14:36 +00:00
|
|
|
$item->DureeExercice = $row->dureeExercice;
|
2014-07-10 14:58:00 +00:00
|
|
|
$item->SaisieDate = substr($row->dateProvPartenaire,0,4).'-'.
|
|
|
|
substr($row->dateProvPartenaire,4,2).'-'.
|
|
|
|
substr($row->dateProvPartenaire,6,2);
|
2014-02-07 16:14:36 +00:00
|
|
|
$item->SaisieCode = '00';
|
|
|
|
//@todo : Améliorer le label de retour - partenaire de saisie
|
|
|
|
//$item->SaisieLabel = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $item->ModeDiffusion == 'C' ) {
|
|
|
|
$cmdM = new Application_Model_Sdv1GreffeCommandesBi();
|
|
|
|
$sql = $cmdM->select()
|
|
|
|
->where('siren=?', $identifiant)
|
|
|
|
->where('bilanCloture=?', $item->DateCloture);
|
|
|
|
$row = $cmdM->fetchRow($sql);
|
|
|
|
if ( $row !== null ) {
|
|
|
|
$item->ModeDiffusion = 'O';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2014-01-29 08:39:29 +00:00
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->wsLog('greffe_bilans', $identifiant, 'Liste');
|
|
|
|
|
|
|
|
$output = new Bilans();
|
|
|
|
$output->nbReponses = $nbBilans;
|
|
|
|
$output->result = $list;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Commande du fichier (URL ou Référence de commande)
|
|
|
|
* @param string $identifiant
|
|
|
|
* SIREN ou autre identifiant
|
|
|
|
* @param string $dateCloture
|
2014-01-16 10:47:25 +00:00
|
|
|
* Date de cloture du bilan (SSAA-MM-JJ)
|
2013-11-05 11:18:30 +00:00
|
|
|
* @param string $type
|
|
|
|
* Type de compte (null|sociaux|consolides)
|
|
|
|
* @param string $diffusion
|
|
|
|
* Mode de diffusion (T|C)
|
|
|
|
* @param string $reference
|
|
|
|
* Nom du fichier ou référence de commande
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return string
|
|
|
|
* URL ou identifiant de commande
|
|
|
|
*/
|
2014-01-16 10:47:25 +00:00
|
|
|
public function getBilan($identifiant, $dateCloture, $type, $diffusion, $reference = '')
|
2013-11-05 11:18:30 +00:00
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('actes');
|
|
|
|
|
|
|
|
if ( strlen($identifiant)!=9 ) {
|
|
|
|
$this->sendError('1010');
|
2014-02-07 16:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty($reference) ) {
|
|
|
|
$reference = '';
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$output = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Association
|
|
|
|
*/
|
|
|
|
if ( substr($reference, 0,4) == 'ASS_' ) {
|
|
|
|
switch ( $diffusion ) {
|
|
|
|
case 'T':
|
|
|
|
if ( preg_match('/^ASS_([0-9]{9})_([0-9]{8})/', $reference, $parseRef) ) {
|
|
|
|
$controlSiren = $parseRef[1];
|
|
|
|
$controlDate = substr($parseRef[2],4,4).substr($parseRef[2],2,2).substr($parseRef[2],0,2);
|
|
|
|
if ( $controlSiren == $identifiant && $controlDate == $dateCloture) {
|
|
|
|
|
|
|
|
$filename = substr($reference,4);
|
|
|
|
$c = Zend_Registry::get('config');
|
2014-02-07 16:14:36 +00:00
|
|
|
$file = $c->profil->path->secure . '/association/bilans/' . $filename;
|
2014-06-26 08:44:38 +00:00
|
|
|
$dest = $c->profil->path->files . '/' . $reference;
|
2013-11-05 11:18:30 +00:00
|
|
|
|
|
|
|
if ( file_exists($file) && copy($file, $dest)) {
|
|
|
|
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
|
|
|
if ($_SERVER['SERVER_PORT']!='80') {
|
|
|
|
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
|
|
|
}
|
|
|
|
$output = $hostname . '/fichier/associations/' . basename($dest);
|
|
|
|
$dateClotureD = substr($dateCloture,4,2).'/'.substr($dateCloture,6,2).'/'.substr($dateCloture,0,4);
|
|
|
|
$this->wsLog('greffe_bilans', $identifiant, 'Bilan association au '.$dateClotureD);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-02-07 16:14:36 +00:00
|
|
|
|
|
|
|
return $output;
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Entreprise
|
|
|
|
*/
|
|
|
|
else {
|
2014-02-07 16:14:36 +00:00
|
|
|
|
|
|
|
//Génération identifiant de commande unique
|
|
|
|
$refCommande = uniqid();
|
|
|
|
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$identite = $iInsee->getIdentiteLight($identifiant);
|
|
|
|
|
|
|
|
//Sauvegarde dans la base
|
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
|
|
|
|
$id = $commandeM->insert(array(
|
|
|
|
'refCommande' => $refCommande,
|
2014-08-06 20:27:01 +00:00
|
|
|
'login' => $this->User->login,
|
|
|
|
'email' => $this->User->email,
|
2014-02-07 16:14:36 +00:00
|
|
|
'refClient' => $reference,
|
|
|
|
'mode' => $diffusion,
|
|
|
|
'siren' => $identifiant,
|
|
|
|
'raisonSociale' => $identite['Nom'],
|
|
|
|
'bilanCloture' => $dateCloture,
|
|
|
|
'bilanType' => $type,
|
|
|
|
'dateInsert' => date('YmdHis'),
|
|
|
|
));
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
switch ( $diffusion ) {
|
|
|
|
|
|
|
|
case 'T':
|
2014-02-07 16:14:36 +00:00
|
|
|
|
|
|
|
//Passer la commande chez infogreffe
|
2015-03-24 14:05:48 +00:00
|
|
|
$infogreffe = new SdMetier_Infogreffe_DocBI($identifiant);
|
2014-02-25 16:33:07 +00:00
|
|
|
//$infogreffe->debug = true;
|
2014-02-07 16:14:36 +00:00
|
|
|
try {
|
|
|
|
$pdf = $infogreffe->getCommandeT($dateCloture, $type, $id);
|
2014-03-24 16:02:28 +00:00
|
|
|
$commandeM->update(array('dateEnvoi'=> date('YmdHis')), 'id='.$id);
|
2014-02-07 16:14:36 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
$commandeM->update(array('cmdError'=> $e->getMessage()), 'id='.$id);
|
2014-07-10 07:20:29 +00:00
|
|
|
if ( $e->getCode() == $infogreffe::INT ) {
|
2014-06-06 15:25:10 +00:00
|
|
|
throw new SoapFault('ERR', "Erreur lors de la commande auprès de notre prestataire.");
|
|
|
|
}
|
2014-02-07 16:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Distribuer le fichier
|
2013-11-05 11:18:30 +00:00
|
|
|
if ( !empty($pdf) ) {
|
|
|
|
|
|
|
|
$c = Zend_Registry::get('config');
|
2014-02-07 16:14:36 +00:00
|
|
|
$file = $c->profil->infogreffe->storage->path . '/' . $pdf;
|
2014-06-26 08:44:38 +00:00
|
|
|
$dest = $c->profil->path->files . '/' . basename($file);
|
2013-11-05 11:18:30 +00:00
|
|
|
|
|
|
|
if ( file_exists($file) && copy($file, $dest)) {
|
|
|
|
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
|
|
|
if ( $_SERVER['SERVER_PORT'] != '80' ) {
|
|
|
|
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
|
|
|
}
|
2014-02-07 16:14:36 +00:00
|
|
|
$output = $hostname . '/fichier/greffes/' . basename($dest); // @todo : Chemin du fichier
|
2014-01-16 10:47:25 +00:00
|
|
|
$this->wsLog('greffe_bilans', $identifiant, basename($dest));
|
2013-11-05 11:18:30 +00:00
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', 'Fichier introuvable');
|
|
|
|
}
|
|
|
|
|
2014-01-16 10:47:25 +00:00
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
2014-01-29 08:39:29 +00:00
|
|
|
case 'F':
|
2013-11-05 11:18:30 +00:00
|
|
|
|
|
|
|
//Commande chez Infogreffe
|
2014-01-29 08:39:29 +00:00
|
|
|
if ( $diffusion == 'C' ) {
|
2015-03-24 14:05:48 +00:00
|
|
|
$infogreffe = new SdMetier_Infogreffe_DocBI($identifiant);
|
2014-02-07 16:14:36 +00:00
|
|
|
try {
|
|
|
|
$infogreffe->getCommandeC($dateCloture, $type, 'G-BI-'.$id);
|
2014-03-24 16:02:28 +00:00
|
|
|
$commandeM->update(array('dateCommande'=> date('YmdHis')), 'id='.$id);
|
2014-02-07 16:14:36 +00:00
|
|
|
$this->wsLog('greffe_bilans', $identifiant, $refCommande);
|
|
|
|
} catch(Exception $e) {
|
|
|
|
$commandeM->update(array('cmdError'=> $e->getMessage()), 'id='.$id);
|
2014-01-29 08:39:29 +00:00
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
$output = $refCommande;
|
2013-11-05 11:18:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
return $output;
|
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Liste des actes au format image
|
|
|
|
* @param string $identifiant
|
2014-01-16 10:47:25 +00:00
|
|
|
* SIREN ou autre identifiant
|
|
|
|
* @param int $position
|
|
|
|
* Numéro de page
|
|
|
|
* @param int $nbRep
|
|
|
|
* Nombre de réponse par page (max=200)
|
|
|
|
* @throws SoapFault
|
2013-11-05 11:18:30 +00:00
|
|
|
* @return Actes
|
|
|
|
*/
|
2014-01-16 10:47:25 +00:00
|
|
|
public function getActes($identifiant, $position = 0, $nbRep = 200)
|
2013-11-05 11:18:30 +00:00
|
|
|
{
|
2014-01-16 10:47:25 +00:00
|
|
|
$this->authenticate();
|
|
|
|
|
|
|
|
if ( empty($position) ) {
|
|
|
|
$position = 0;
|
|
|
|
}
|
|
|
|
if ($nbRep > 200) {
|
|
|
|
$nbRep = 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( strlen($identifiant)!=9 ) {
|
|
|
|
$this->sendError('1010');
|
|
|
|
}
|
|
|
|
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$identite = $iInsee->getIdentiteLight($identifiant);
|
|
|
|
if (empty($identite['id'])){
|
|
|
|
$this->sendError('1020');
|
|
|
|
}
|
|
|
|
|
2015-03-24 14:05:48 +00:00
|
|
|
$infogreffe = new SdMetier_Infogreffe_DocAC($identifiant);
|
2014-02-07 16:14:36 +00:00
|
|
|
$list = $infogreffe->getList();
|
2013-11-05 11:18:30 +00:00
|
|
|
$nbActes = count($list);
|
|
|
|
|
|
|
|
if ($nbActes>0) {
|
|
|
|
//Information INPI
|
|
|
|
$rncs = new MRncs();
|
|
|
|
foreach ($list as $i => $item) {
|
|
|
|
$result = $rncs->getListeDepots($identifiant, $item->DepotDate);
|
|
|
|
if (count($result)>0) {
|
|
|
|
foreach ($result as $infos) {
|
|
|
|
$list[$i]->infos[] = $infos['libDepot'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-29 08:39:29 +00:00
|
|
|
|
|
|
|
//@todo : Marquer les éléments en commande courrier si déjà commandé ModeDiffusion = O
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->wsLog('greffe_actes', $identifiant, 'Liste');
|
|
|
|
|
|
|
|
$output = new Actes();
|
|
|
|
$output->result = $list;
|
|
|
|
$output->nbReponses = $nbActes;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo :
|
|
|
|
* @param string $identifiant
|
|
|
|
* SIREN
|
|
|
|
* @param string $diffusion
|
|
|
|
* Mode de diffusion (C|T)
|
|
|
|
* @param string $depotNum
|
|
|
|
*
|
|
|
|
* @param string $depotDate
|
|
|
|
*
|
|
|
|
* @param string $acteType
|
|
|
|
* Type de l'acte
|
|
|
|
* @param string $acteNum
|
|
|
|
* Numéro de l'acte
|
|
|
|
* @param string $acteDate
|
|
|
|
* Date de l'acte
|
|
|
|
* @param string $reference
|
|
|
|
* A DETERMINER
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return string
|
|
|
|
* URL ou identifiant de commande
|
|
|
|
*/
|
|
|
|
public function getActe($identifiant, $diffusion, $depotNum, $depotDate, $acteType, $acteNum, $acteDate, $reference = '')
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('actes');
|
|
|
|
|
|
|
|
if ( strlen($identifiant)!=9 ) {
|
|
|
|
$this->sendError('1010');
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = '';
|
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
//Génération identifiant de commande unique
|
|
|
|
$refCommande = uniqid();
|
|
|
|
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$identite = $iInsee->getIdentiteLight($identifiant);
|
|
|
|
|
|
|
|
//Sauvegarde dans la base
|
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
|
|
|
|
$id = $commandeM->insert(array(
|
|
|
|
'refCommande' => $refCommande,
|
2014-08-06 20:27:01 +00:00
|
|
|
'login' => $this->User->login,
|
|
|
|
'email' => $this->User->email,
|
2014-02-07 16:14:36 +00:00
|
|
|
'refClient' => $reference,
|
|
|
|
'siren' => $identifiant,
|
|
|
|
'mode' => $diffusion,
|
|
|
|
'raisonSociale' => $identite['Nom'],
|
|
|
|
'depotNum' => $depotNum,
|
|
|
|
'depotDate' => $depotDate,
|
|
|
|
'acteType' => $acteType,
|
|
|
|
'acteDate' => $acteDate,
|
|
|
|
'acteNum' => $acteNum,
|
|
|
|
'dateInsert' => date('YmdHis'),
|
|
|
|
));
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
switch ( $diffusion ) {
|
|
|
|
|
|
|
|
case 'T':
|
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
//Passer la commande chez Infogreffe
|
2015-03-24 14:05:48 +00:00
|
|
|
$infogreffe = new SdMetier_Infogreffe_DocAC($identifiant);
|
2014-02-07 16:14:36 +00:00
|
|
|
try {
|
|
|
|
$pdf = $infogreffe->getCommandeT($depotDate, $depotNum, $acteType, $acteDate, $acteNum, $id);
|
|
|
|
$commandeM->update(array('dateEnvoi'=> date('YmdHis')), 'id='.$id);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$commandeM->update(array('cmdError'=> $e->getMessage()), 'id='.$id);
|
2014-07-10 07:20:29 +00:00
|
|
|
if ( $e->getCode() == $infogreffe::INT ) {
|
2014-06-06 15:25:10 +00:00
|
|
|
throw new SoapFault('ERR', "Erreur lors de la commande auprès de notre prestataire.");
|
|
|
|
}
|
2014-02-07 16:14:36 +00:00
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
//Distribuer le fichier
|
2013-11-05 11:18:30 +00:00
|
|
|
if ( !empty($pdf) ) {
|
|
|
|
|
|
|
|
$c = Zend_Registry::get('config');
|
2014-02-07 16:14:36 +00:00
|
|
|
$file = $c->profil->infogreffe->storage->path . '/' . $pdf;
|
2014-06-26 08:44:38 +00:00
|
|
|
$dest = $c->profil->path->files . '/' . basename($file);
|
2013-11-05 11:18:30 +00:00
|
|
|
|
|
|
|
if ( file_exists($file) && copy($file, $dest)) {
|
2014-02-25 16:33:07 +00:00
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
|
|
|
if ( $_SERVER['SERVER_PORT'] != '80' ) {
|
|
|
|
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
|
|
|
}
|
2014-02-07 16:14:36 +00:00
|
|
|
$output = $hostname . '/fichier/greffes/' . basename($dest);
|
2014-06-04 09:35:29 +00:00
|
|
|
$this->wsLog('greffe_actes', $identifiant, basename($dest));
|
2014-02-25 16:33:07 +00:00
|
|
|
return $output;
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
} else {
|
2014-06-06 15:25:10 +00:00
|
|
|
throw new SoapFault('ERR', 'Fichier introuvable.');
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
2014-03-18 10:02:22 +00:00
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 16:33:07 +00:00
|
|
|
return false;
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
2014-01-29 08:39:29 +00:00
|
|
|
case 'F':
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-02-07 16:14:36 +00:00
|
|
|
if ( $diffusion == 'C' ) {
|
2014-01-29 08:39:29 +00:00
|
|
|
//Commande chez Infogreffe
|
2015-03-24 14:05:48 +00:00
|
|
|
$infogreffe = new SdMetier_Infogreffe_DocAC($identifiant);
|
2014-02-07 16:14:36 +00:00
|
|
|
try {
|
|
|
|
$infogreffe->getCommandeC($depotDate, $depotNum, $acteType, $acteDate, $acteNum, 'G-AC-'.$id);
|
2014-03-18 10:02:22 +00:00
|
|
|
$commandeM->update(array('dateCommande'=> date('YmdHis')), 'id='.$id);
|
2014-02-07 16:14:36 +00:00
|
|
|
$this->wsLog('greffe_actes', $identifiant, $refCommande);
|
|
|
|
} catch(Exception $e) {
|
|
|
|
$commandeM->update(array('cmdError'=> $e->getMessage()), 'id='.$id);
|
2014-01-29 08:39:29 +00:00
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $refCommande;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2014-05-24 09:02:11 +00:00
|
|
|
/**
|
|
|
|
* Set an email associated to the command
|
|
|
|
* @param string $id
|
|
|
|
* @param string $email
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function setActeCmdEmail($id, $email)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('actes');
|
|
|
|
|
|
|
|
$validator = new Zend_Validate_EmailAddress();
|
|
|
|
if ( !$validator->isValid($email) ){
|
|
|
|
throw new SoapFault('ERR', "Adresse email invalide.");
|
|
|
|
}
|
|
|
|
|
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
|
|
|
|
$sql = $commandeM->select()
|
2014-08-06 20:27:01 +00:00
|
|
|
->where('login=?', $this->User->login)
|
2014-05-24 09:02:11 +00:00
|
|
|
->where('refCommande=?', $id);
|
|
|
|
try {
|
|
|
|
$result = $commandeM->fetchRow($sql);
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-05-24 09:02:11 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $result !== null ) {
|
|
|
|
if ( is_int($email) ) {
|
|
|
|
//Id of secondary email
|
|
|
|
} else {
|
|
|
|
$dataUpdate = array('email' => $email);
|
|
|
|
try {
|
|
|
|
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
|
|
|
return true;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-05-24 09:02:11 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set an email associated to the command
|
|
|
|
* @param string $id
|
|
|
|
* @param string $email
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function setBilanCmdEmail($id, $email)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('actes');
|
|
|
|
|
|
|
|
$validator = new Zend_Validate_EmailAddress();
|
|
|
|
if ( !$validator->isValid($email) ){
|
|
|
|
throw new SoapFault('ERR', "Adresse email invalide.");
|
|
|
|
}
|
|
|
|
|
2014-08-18 06:56:50 +00:00
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
|
2014-05-24 09:02:11 +00:00
|
|
|
$sql = $commandeM->select()
|
2014-08-06 20:27:01 +00:00
|
|
|
->where('login=?', $this->User->login)
|
2014-05-24 09:02:11 +00:00
|
|
|
->where('refCommande=?', $id);
|
|
|
|
try {
|
|
|
|
$result = $commandeM->fetchRow($sql);
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-05-24 09:02:11 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $result !== null ) {
|
|
|
|
if ( is_int($email) ) {
|
|
|
|
//Id of secondary email
|
|
|
|
} else {
|
2015-04-02 08:51:48 +00:00
|
|
|
$dataUpdate = array('email' => $email);
|
2014-05-24 09:02:11 +00:00
|
|
|
try {
|
|
|
|
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
|
|
|
return true;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-05-24 09:02:11 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set an email associated to the command
|
|
|
|
* @param string $id
|
|
|
|
* @param string $email
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function setKbisCmdEmail($id, $email)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('KBIS');
|
|
|
|
|
|
|
|
$validator = new Zend_Validate_EmailAddress();
|
|
|
|
if ( !$validator->isValid($email) ){
|
|
|
|
throw new SoapFault('ERR', "Adresse email invalide.");
|
|
|
|
}
|
|
|
|
|
2014-08-18 06:56:50 +00:00
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
2014-05-24 09:02:11 +00:00
|
|
|
$sql = $commandeM->select()
|
2014-08-06 20:27:01 +00:00
|
|
|
->where('login=?', $this->User->login)
|
2014-05-24 09:02:11 +00:00
|
|
|
->where('refCommande=?', $id);
|
|
|
|
try {
|
|
|
|
$result = $commandeM->fetchRow($sql);
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-05-24 09:02:11 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $result !== null ) {
|
|
|
|
if ( is_int($email) ) {
|
|
|
|
//Id of secondary email
|
|
|
|
} else {
|
2015-04-02 08:51:48 +00:00
|
|
|
$dataUpdate = array('email' => $email);
|
2014-05-24 09:02:11 +00:00
|
|
|
try {
|
|
|
|
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
|
|
|
return true;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
2014-08-06 20:27:01 +00:00
|
|
|
if ($this->User->idClient==1) {
|
2014-05-24 09:02:11 +00:00
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-08-18 12:36:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ajouter des informations pour la commande, principalement lors de commande courrier
|
|
|
|
* @param string $id
|
|
|
|
* Identifiant de la commande
|
|
|
|
* @param string $infos
|
|
|
|
* Information au format json
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function setKbisCmdLetter($id, $infos)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('KBIS');
|
|
|
|
|
|
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
|
|
|
$sql = $commandeM->select()
|
|
|
|
->where('login=?', $this->User->login)
|
|
|
|
->where('refCommande=?', $id);
|
|
|
|
try {
|
|
|
|
$result = $commandeM->fetchRow($sql);
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient==1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $result !== null ) {
|
2015-04-02 08:51:48 +00:00
|
|
|
$dataUpdate = array('infos' => $infos);
|
|
|
|
try {
|
|
|
|
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
|
|
|
return true;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient == 1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Commande de statut association
|
|
|
|
* @param string $companyId
|
|
|
|
* @param string $type (siren|waldec)
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function setAssoStatut($companyId, $type = null)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('actes');
|
|
|
|
|
|
|
|
$inseeM = new MInsee();
|
|
|
|
if ($type == 'siren') {
|
|
|
|
$result = $inseeM->getIdentiteLight($companyId);
|
|
|
|
$companyName = $result['Nom'];
|
|
|
|
} elseif ($type == 'waldec') {
|
|
|
|
$result = $inseeM->getEtablissementsParId('AUTRE', $companyId);
|
|
|
|
$companyName = $result['Nom'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$refCommande = uniqid();
|
|
|
|
|
|
|
|
try {
|
|
|
|
$commandeM = new Application_Model_Sdv1OrderAssoStatut();
|
|
|
|
$commandeM->insert(array(
|
|
|
|
'refCommande' => $refCommande,
|
|
|
|
'companyId' => $companyId,
|
|
|
|
'typeId' => $type,
|
|
|
|
'companyName' => $companyName,
|
|
|
|
'userId' => $this->User->id,
|
|
|
|
'userLogin' => $this->User->login,
|
|
|
|
'userEmail' => $this->USer->email,
|
|
|
|
'dateInsert' => date('YmdHis'),
|
|
|
|
));
|
|
|
|
return $refCommande;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient == 1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifier une commande de statut association
|
|
|
|
* @param string $id
|
|
|
|
* Référence de commande
|
|
|
|
* @param string $data
|
|
|
|
* Objet json (email, reference)
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function setAssoStatutDetail($id, $data)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
|
|
|
|
// --- Vérification que la commande existe
|
|
|
|
try {
|
|
|
|
$commandeM = new Application_Model_Sdv1OrderAssoStatut();
|
|
|
|
$sql = $commandeM->select()
|
|
|
|
->where('userLogin=?', $this->User->login)
|
|
|
|
->where('refCommande=?', $id);
|
|
|
|
$result = $commandeM->fetchRow($sql);
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient == 1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- Paramètres envoyés
|
|
|
|
$params = json_decode($data, true);
|
|
|
|
$dataUpdate = array();
|
|
|
|
if (count($params) > 0) {
|
|
|
|
foreach ($params as $k => $v) {
|
|
|
|
switch ($k) {
|
|
|
|
case 'email':
|
|
|
|
// --- Vérification email
|
|
|
|
$validator = new Zend_Validate_EmailAddress();
|
|
|
|
if ( !$validator->isValid($v) ){
|
|
|
|
throw new SoapFault('ERR', "Adresse email invalide.");
|
|
|
|
}
|
|
|
|
$dataUpdate['email'] = $v;
|
|
|
|
break;
|
|
|
|
case 'reference':
|
|
|
|
$dataUpdate['reference'] = $v;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- Mise à jour de la commande
|
|
|
|
if (count($dataUpdate) > 0) {
|
2014-08-18 12:36:10 +00:00
|
|
|
try {
|
|
|
|
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
|
|
|
return true;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient==1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
2015-04-02 08:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Commande de privileges
|
|
|
|
* @param string $companyId
|
|
|
|
* Siren
|
|
|
|
* @param string $doc
|
|
|
|
* Type de privilege (privsecu, privtres, nantfond, declcrea)
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function setPrivileges($companyId, $doc = null)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
$this->permission('priv');
|
|
|
|
|
|
|
|
$inseeM = new MInsee();
|
|
|
|
$result = $inseeM->getIdentiteLight($companyId);
|
|
|
|
$companyName = $result['Nom'];
|
|
|
|
|
|
|
|
$refCommande = uniqid();
|
|
|
|
|
|
|
|
try {
|
|
|
|
$commandeM = new Application_Model_Sdv1OrderPrivileges();
|
|
|
|
$commandeM->insert(array(
|
|
|
|
'refCommande' => $refCommande,
|
|
|
|
'docType' => $doc,
|
|
|
|
'companyId' => $companyId,
|
|
|
|
'companyName' => $companyName,
|
|
|
|
'userId' => $this->User->id,
|
|
|
|
'userLogin' => $this->User->login,
|
|
|
|
'userEmail' => $this->USer->email,
|
|
|
|
'dateInsert' => date('YmdHis'),
|
|
|
|
));
|
|
|
|
return $refCommande;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient == 1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Défini un email pour la commande de privilege
|
|
|
|
* @param string $id
|
|
|
|
* @param string $email
|
|
|
|
* @throws SoapFault
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function setPrivilegesEmail($id, $email)
|
|
|
|
{
|
|
|
|
$this->authenticate();
|
|
|
|
|
|
|
|
$validator = new Zend_Validate_EmailAddress();
|
|
|
|
if ( !$validator->isValid($email) ){
|
|
|
|
throw new SoapFault('ERR', "Adresse email invalide.");
|
|
|
|
}
|
|
|
|
|
|
|
|
$commandeM = new Application_Model_Sdv1OrderPrivileges();
|
|
|
|
$sql = $commandeM->select()
|
|
|
|
->where('login=?', $this->User->login)
|
|
|
|
->where('refCommande=?', $id);
|
|
|
|
try {
|
|
|
|
$result = $commandeM->fetchRow($sql);
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient==1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $result !== null ) {
|
|
|
|
if ( is_int($email) ) {
|
|
|
|
//Id of secondary email
|
|
|
|
} else {
|
|
|
|
$dataUpdate = array('email' => $email);
|
|
|
|
try {
|
|
|
|
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
|
|
|
return true;
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
|
|
if ($this->User->idClient == 1) {
|
|
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
|
|
} else {
|
|
|
|
throw new SoapFault('ERR', "Application error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-18 12:36:10 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-02 08:51:48 +00:00
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|