440 lines
13 KiB
PHP
440 lines
13 KiB
PHP
<?php
|
|
require_once __DIR__ . '/Types.php';
|
|
|
|
class Order extends Scores_Ws_Server
|
|
{
|
|
/**
|
|
* Financial account : Place an order to have number enter in database
|
|
* @param string $siren
|
|
* @param string $date
|
|
* @param string $type N:Normal, S:Simplifié, C:Consolidé
|
|
* @param string $source
|
|
* @param integer $private
|
|
* @throws SoapFault
|
|
* @return string
|
|
*/
|
|
public function setBilanInput($siren, $date, $type, $source, $private = 0)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('UPLOADBILAN');
|
|
|
|
//Check siren
|
|
|
|
$refCommande = uniqid();
|
|
|
|
$data = array(
|
|
'refCommande' => $refCommande,
|
|
'siren' => $siren,
|
|
'userId' => $this->User->id,
|
|
'bilanConfidentiel' => $private,
|
|
'bilanSource' => $source,
|
|
'bilanCloture' => $date,
|
|
'bilanType' => $type,
|
|
'dateInsert' => date('YmdHis'),
|
|
);
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
|
$commandeM->insert($data);
|
|
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");
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Financial account : Tag file is sent
|
|
* @param string $ref
|
|
* @param string $filename
|
|
* @throws SoapFault
|
|
* @return boolean
|
|
*/
|
|
public function setBilanInputFile($ref, $filename)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('UPLOADBILAN');
|
|
|
|
$data = array(
|
|
'bilanFileSent' => date('YmdHis'),
|
|
'bilanFile' => $filename,
|
|
);
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
|
$commandeM->update($data, 'refCommande="'.$ref.'"');
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* Liste des commandes de saisie de bilan
|
|
* @param string $month
|
|
* @throws SoapFault
|
|
* @return BilanInput[]
|
|
*/
|
|
public function getBilanInputList($month = null)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if ($month === null) {
|
|
$month = date('Y-m');
|
|
}
|
|
$dateStart = $month.'-01 00:00:00';
|
|
$dateEnd = $month.'-31 23:59:59';
|
|
|
|
$list = array();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
|
$sql = $commandeM->select()->where('userId=?', $this->User->id);
|
|
$result = $commandeM->fetchAll($sql);
|
|
if (count($result) > 0) {
|
|
foreach($result as $item) {
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Siren = $item->siren;
|
|
$cmd->BilanFileRecv = $item->bilanFileRecv;
|
|
$cmd->BilanCloture = $item->bilanCloture;
|
|
$cmd->BilanType = $item->bilanType;
|
|
$cmd->ErreurDate = $item->erreurDate;
|
|
$cmd->ErreurLabel = $item->erreurTxt;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateSaisie = $item->dateSaisie;
|
|
$list[] = $cmd;
|
|
}
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* Détail d'un bilan en commande saisie
|
|
* @param string $ref
|
|
* @throws SoapFault
|
|
* @return BilanInput|NULL
|
|
*/
|
|
protected function getBilanInputDetail($ref)
|
|
{
|
|
$this->authenticate();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
|
$sql = $commandeM->select()->where('userId=?', $this->User->id)->where('refCommande=?', $ref);
|
|
$item = $commandeM->fetchRow($sql);
|
|
if ($item !== null) {
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Siren = $item->siren;
|
|
$cmd->BilanFileRecv = $item->bilanFileRecv;
|
|
$cmd->BilanCloture = $item->bilanCloture;
|
|
$cmd->BilanType = $item->bilanType;
|
|
$cmd->ErreurDate = $item->erreurDate;
|
|
$cmd->ErreurLabel = $item->erreurTxt;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateSaisie = $item->dateSaisie;
|
|
return $cmd;
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Liste des commandes KBIS
|
|
* @param string $month
|
|
* @throws SoapFault
|
|
* @return PieceKbis[]
|
|
*/
|
|
public function getKbisList($month = null)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if ($month === null) {
|
|
$month = date('Y-m');
|
|
}
|
|
$dateStart = $month.'-01 00:00:00';
|
|
$dateEnd = $month.'-31 23:59:59';
|
|
|
|
$list = array();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
|
$sql = $commandeM->select()->where('login=?', $this->User->login);
|
|
$result = $commandeM->fetchAll($sql);
|
|
if (count($result) > 0) {
|
|
foreach($result as $item) {
|
|
$cmd = new PieceKbis();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Mode = $item->mode;
|
|
$cmd->Error = $item->cmdError;
|
|
$cmd->CompanyName = $item->raisonSociale;
|
|
$cmd->CompanySiren = $item->siren;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateEnvoi = $item->dateEnvoi;
|
|
$list[] = $cmd;
|
|
}
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* Detail de la commande d'un KBIS
|
|
* @param unknown $ref
|
|
* @throws SoapFault
|
|
* @return BilanInput|NULL
|
|
*/
|
|
protected function getKbisDetail($ref)
|
|
{
|
|
$this->authenticate();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
|
$sql = $commandeM->select()->where('login=?', $this->User->login)->where('refCommande=?', $ref);
|
|
$item = $commandeM->fetchRow($sql);
|
|
if ($item !== null) {
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Mode = $item->mode;
|
|
$cmd->Error = $item->cmdError;
|
|
$cmd->CompanyName = $item->raisonSociale;
|
|
$cmd->CompanySiren = $item->siren;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateEnvoi = $item->dateEnvoi;
|
|
return $cmd;
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
protected function getKbisFile($ref)
|
|
{
|
|
$this->authenticate();
|
|
|
|
// --- Paramètres
|
|
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
|
if ($_SERVER['SERVER_PORT']!='80'){
|
|
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
|
}
|
|
$c = Zend_Registry::get('config');
|
|
$path = realpath($c->profil->path->secure).'/kbis';
|
|
$file = null;
|
|
|
|
// --- Lecture des informations de la commande
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
|
$sql = $commandeM->select()->where('login=?', $this->User->login)->where('refCommande=?', $ref);
|
|
$item = $commandeM->fetchRow($sql);
|
|
if ($item !== null) {
|
|
|
|
|
|
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Mode = $item->mode;
|
|
$cmd->Error = $item->cmdError;
|
|
$cmd->CompanyName = $item->raisonSociale;
|
|
$cmd->CompanySiren = $item->siren;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateEnvoi = $item->dateEnvoi;
|
|
return $cmd;
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
protected function getActeList($month = null)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if ($month === null) {
|
|
$month = date('Y-m');
|
|
}
|
|
$dateStart = $month.'-01 00:00:00';
|
|
$dateEnd = $month.'-31 23:59:59';
|
|
|
|
$list = array();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
|
|
$sql = $commandeM->select()->where('login=?', $this->User->login);
|
|
$result = $commandeM->fetchAll($sql);
|
|
if (count($result) > 0) {
|
|
foreach($result as $item) {
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Mode = $item->mode;
|
|
$cmd->Error = $item->cmdError;
|
|
|
|
//@todo : Génére le libellé du document
|
|
$cmd->DocDepotNum;
|
|
$cmd->DocDepotDate;
|
|
$cmd->DocActeNum;
|
|
$cmd->DocActeType;
|
|
$cmd->DocActeDate;
|
|
|
|
$cmd->CompanyName = $item->raisonSociale;
|
|
$cmd->CompanySiren = $item->siren;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateEnvoi = $item->dateEnvoi;
|
|
$list[] = $cmd;
|
|
}
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
|
|
protected function getActeDetail($ref){}
|
|
protected function getActeFile($ref){}
|
|
|
|
/**
|
|
* Liste des commandes de bilan infogreffe
|
|
* @param string $month
|
|
* @throws SoapFault
|
|
* @return multitype:BilanInput
|
|
*/
|
|
protected function getBilanList($month = null)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if ($month === null) {
|
|
$month = date('Y-m');
|
|
}
|
|
$dateStart = $month.'-01 00:00:00';
|
|
$dateEnd = $month.'-31 23:59:59';
|
|
|
|
$list = array();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
|
|
$sql = $commandeM->select()->where('login=?', $this->User->login);
|
|
$result = $commandeM->fetchAll($sql);
|
|
if (count($result) > 0) {
|
|
foreach($result as $item) {
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Mode = $item->mode;
|
|
$cmd->Error = $item->cmdError;
|
|
$cmd->DocBilanCloture = $item->bilanCloture;
|
|
$cmd->DocBilanType = $item->bilanType;
|
|
$cmd->CompanyName = $item->raisonSociale;
|
|
$cmd->CompanySiren = $item->siren;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateEnvoi = $item->dateEnvoi;
|
|
$list[] = $cmd;
|
|
}
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* Détail de la commande de bilan Infogreffe
|
|
* @param unknown $ref
|
|
* @throws SoapFault
|
|
* @return BilanInput|NULL
|
|
*/
|
|
protected function getBilanDetail($ref)
|
|
{
|
|
$this->authenticate();
|
|
|
|
try {
|
|
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
|
$sql = $commandeM->select()->where('login=?', $this->User->login)->where('refCommande=?', $ref);
|
|
$item = $commandeM->fetchRow($sql);
|
|
if ($item !== null) {
|
|
$cmd = new BilanInput();
|
|
$cmd->Reference = $item->refCommande;
|
|
$cmd->Mode = $item->mode;
|
|
$cmd->Error = $item->cmdError;
|
|
$cmd->DocBilanCloture = $item->bilanCloture;
|
|
$cmd->DocBilanType = $item->bilanType;
|
|
$cmd->CompanyName = $item->raisonSociale;
|
|
$cmd->CompanySiren = $item->siren;
|
|
$cmd->DateInsert = $item->dateInsert;
|
|
$cmd->DateEnvoi = $item->dateEnvoi;
|
|
return $cmd;
|
|
}
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
protected function getBilanFile($ref){}
|
|
|
|
protected function setInvestigation()
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('enquetec');
|
|
|
|
//Table pour le stockage des demandes d'investigation
|
|
|
|
}
|
|
|
|
} |