issue #0001416 : add methode getBourse, setBourse
This commit is contained in:
parent
a21efd5d08
commit
2485f9ca25
@ -1,9 +1,8 @@
|
|||||||
<?
|
<?php
|
||||||
|
|
||||||
require_once 'framework/common/curl.php';
|
require_once 'framework/common/curl.php';
|
||||||
|
|
||||||
class MBourse {
|
class MBourse
|
||||||
|
{
|
||||||
var $siren=false;
|
var $siren=false;
|
||||||
|
|
||||||
public function __construct($siren=0) {
|
public function __construct($siren=0) {
|
||||||
@ -116,12 +115,22 @@ class MBourse {
|
|||||||
$tabRet=array();
|
$tabRet=array();
|
||||||
if ($isin<>'') {
|
if ($isin<>'') {
|
||||||
$datePre=date('Y-m').'-01';
|
$datePre=date('Y-m').'-01';
|
||||||
|
if (APPLICATION_ENV=='development') {
|
||||||
|
$tabRes=$iDb->select( 'bourse_isin b, bourse_cours c',
|
||||||
|
'siren, raisonSociale, adresse, effectif, code_sicovam, code_mnemo, code_bloomberg, code_datastream, code_isin, logo, code_ric, '.
|
||||||
|
'dateIntroduction, dateDerAG, dateRadiation, autre_isin, eligibleSRD, eligiblePEA, nombreTitres, tel1, tel2, fax1, fax2, web, mail, '.
|
||||||
|
'marche, placeCotation, description, secteur, activite, activiteDet, dirigeants, actionnaires, chiffresTrim, '.
|
||||||
|
'c.autre, c.`date`, c.`heure`, c.`open` , c.`high` , c.`low` , c.`close` , c.`volume`',
|
||||||
|
"code_isin='$isin' /*OR siren=$siren)*/ AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u') ORDER BY b.dateUpdate DESC, c.dateInsert DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||||
|
} else {
|
||||||
$tabRes=$iDb->select( 'bourse_isin b, bourse_cours c',
|
$tabRes=$iDb->select( 'bourse_isin b, bourse_cours c',
|
||||||
'siren, raisonSociale, adresse, effectif, code_sicovam, code_mnemo, code_bloomberg, code_datastream, code_isin, logo, code_ric, '.
|
'siren, raisonSociale, adresse, effectif, code_sicovam, code_mnemo, code_bloomberg, code_datastream, code_isin, logo, code_ric, '.
|
||||||
'dateIntroduction, dateDerAG, dateRadiation, autre_isin, eligibleSRD, eligiblePEA, nombreTitres, tel1, tel2, fax1, fax2, web, mail, '.
|
'dateIntroduction, dateDerAG, dateRadiation, autre_isin, eligibleSRD, eligiblePEA, nombreTitres, tel1, tel2, fax1, fax2, web, mail, '.
|
||||||
'marche, placeCotation, description, secteur, activite, activiteDet, dirigeants, actionnaires, chiffresTrim, '.
|
'marche, placeCotation, description, secteur, activite, activiteDet, dirigeants, actionnaires, chiffresTrim, '.
|
||||||
'c.autre, c.`date`, c.`heure`, c.`open` , c.`high` , c.`low` , c.`close` , c.`volume`',
|
'c.autre, c.`date`, c.`heure`, c.`open` , c.`high` , c.`low` , c.`close` , c.`volume`',
|
||||||
"code_isin='$isin' /*OR siren=$siren)*/ AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u') AND c.`date`>='$datePre' ORDER BY b.dateUpdate DESC, c.dateInsert DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
"code_isin='$isin' /*OR siren=$siren)*/ AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u') AND c.`date`>='$datePre' ORDER BY b.dateUpdate DESC, c.dateInsert DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
$tabRet=$tabRes[0];
|
$tabRet=$tabRes[0];
|
||||||
$timer['infosBoursieres-infosIsin']=microtime(true);
|
$timer['infosBoursieres-infosIsin']=microtime(true);
|
||||||
|
|
||||||
@ -133,73 +142,9 @@ class MBourse {
|
|||||||
$tabRet['coursMoy']=$tabTmp['coursMoy'];
|
$tabRet['coursMoy']=$tabTmp['coursMoy'];
|
||||||
$tabRet['coursMax']=$tabTmp['coursMax'];
|
$tabRet['coursMax']=$tabTmp['coursMax'];
|
||||||
$timer['infosBoursieres-derniersCours']=microtime(true);
|
$timer['infosBoursieres-derniersCours']=microtime(true);
|
||||||
/*
|
|
||||||
$tabRes=$iDb->select( 'bourse_cours',
|
|
||||||
'`date`, close',
|
|
||||||
"isin='$isin' AND autre IN('','e','f','g','m','s','u') AND heure=9999 AND ( ".
|
|
||||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 6 DAY) OR ".
|
|
||||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 7 DAY) OR ".
|
|
||||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 8 DAY) OR ".
|
|
||||||
"`date`='".date('Y')."-01-02' OR ".
|
|
||||||
"`date`='".date('Y')."-01-03' OR ".
|
|
||||||
"`date`='".date('Y')."-01-04' OR ".
|
|
||||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 365 DAY) OR ".
|
|
||||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 366 DAY) OR ".
|
|
||||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 367 DAY) OR ".
|
|
||||||
"`date`=MIN(`date`) ) GROUP BY `date` ORDER BY `date` DESC", false, MYSQL_ASSOC);
|
|
||||||
$tabTmp=$tabRes[0];
|
|
||||||
print_r($tabTmp);
|
|
||||||
*/
|
|
||||||
/* Variations en clôture du 07/03/2008
|
|
||||||
Variation 5 jours -2.03%
|
|
||||||
Variation au 1 janvier +9.36%
|
|
||||||
Variation 1 an +13.84%
|
|
||||||
Variation 10 ans NC
|
|
||||||
Volumes
|
|
||||||
Volume séance 2 253
|
|
||||||
Volume moy. 20 séances 16 326
|
|
||||||
Ratio volumes 13.80%
|
|
||||||
Nombre de titres 113 038 156
|
|
||||||
Capital échangé séance 0.00%
|
|
||||||
Extrêmes
|
|
||||||
Plus haut 10 ans (14/02/2008) 78.5
|
|
||||||
Plus bas 10 ans (18/04/2005) 41.12*/
|
|
||||||
/*$tabRet[]=array( 'siren'=>$tabBourse,
|
|
||||||
'raisonSociale',
|
|
||||||
'adresse',
|
|
||||||
'effectif',
|
|
||||||
'code_sicovam',
|
|
||||||
'code_mnemo',
|
|
||||||
'code_bloomberg',
|
|
||||||
'code_datastream',
|
|
||||||
'code_isin',
|
|
||||||
'logo',
|
|
||||||
'code_ric',
|
|
||||||
'dateIntroduction',
|
|
||||||
'dateDerAG',
|
|
||||||
'dateRadiation',
|
|
||||||
'autre_isin',
|
|
||||||
'eligibleSRD',
|
|
||||||
'eligiblePEA',
|
|
||||||
'nombreTitres',
|
|
||||||
'tel1',
|
|
||||||
'tel2',
|
|
||||||
'fax1',
|
|
||||||
'fax2',
|
|
||||||
'web',
|
|
||||||
'mail',
|
|
||||||
'marche',
|
|
||||||
'placeCotation',
|
|
||||||
'description',
|
|
||||||
'secteur',
|
|
||||||
'activite',
|
|
||||||
'activiteDet',
|
|
||||||
'dirigeants',
|
|
||||||
'actionnaires',
|
|
||||||
'chiffresTrim'
|
|
||||||
);*/
|
|
||||||
}
|
}
|
||||||
return $tabRet;
|
return $tabRet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
@ -1906,5 +1906,114 @@ class Saisie extends WsScore
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bourse
|
||||||
|
* @param string $isin
|
||||||
|
* @param string $infos
|
||||||
|
* @throws SoapFault
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function setBourse($isin, $infos)
|
||||||
|
{
|
||||||
|
$this->authenticate();
|
||||||
|
|
||||||
|
if (strlen($isin)>12) {
|
||||||
|
throw new SoapFault('ERR', 'Code Isin incorrect.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($infos, true);
|
||||||
|
|
||||||
|
//Connect to the database
|
||||||
|
try {
|
||||||
|
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||||
|
$db->getConnection();
|
||||||
|
} catch (Zend_Db_Adapter_Exception $e) {
|
||||||
|
if ($this->tabInfoUser['idClient']!=1) {
|
||||||
|
throw new SoapFault('ERR', "Application error");
|
||||||
|
} else {
|
||||||
|
throw new SoapFault('ERR', $e->getMessage());
|
||||||
|
}
|
||||||
|
} catch (Zend_Exception $e) {
|
||||||
|
throw new SoapFault('ERR', "Application error");
|
||||||
|
}
|
||||||
|
|
||||||
|
$bourseM = new Application_Model_Sdv1BourseIsin($db);
|
||||||
|
|
||||||
|
//Check if exist
|
||||||
|
$sql = $bourseM->select()->where('code_isin=?',$isin);
|
||||||
|
$result = $bourseM->fetchAll($sql);
|
||||||
|
|
||||||
|
//Insert
|
||||||
|
if ($result->count()==0) {
|
||||||
|
|
||||||
|
$data = array_merge($data, array(
|
||||||
|
'dateInsert' => date('YmdHis'),
|
||||||
|
));
|
||||||
|
|
||||||
|
try {
|
||||||
|
$id = $bourseM->insert($data);
|
||||||
|
} catch (Zend_Db_Exception $e) {
|
||||||
|
if ($this->tabInfoUser['idClient']!=1) {
|
||||||
|
throw new SoapFault('ERR', "Application error");
|
||||||
|
} else {
|
||||||
|
throw new SoapFault('ERR', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//Update
|
||||||
|
else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$id = $bourseM->update($data, 'code_isin = '.$isin);
|
||||||
|
} catch (Zend_Db_Exception $e) {
|
||||||
|
if ($this->tabInfoUser['idClient']!=1) {
|
||||||
|
throw new SoapFault('ERR', "Application error");
|
||||||
|
} else {
|
||||||
|
throw new SoapFault('ERR', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Informations boursières pour la saisie
|
||||||
|
* @param string $isin
|
||||||
|
* @throws SoapFault
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBourse($isin)
|
||||||
|
{
|
||||||
|
$this->authenticate();
|
||||||
|
|
||||||
|
if (strlen($isin)>12) {
|
||||||
|
throw new SoapFault('ERR', 'Code Isin incorrect.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Connect to the database
|
||||||
|
try {
|
||||||
|
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||||
|
$db->getConnection();
|
||||||
|
} catch (Zend_Db_Adapter_Exception $e) {
|
||||||
|
if ($this->tabInfoUser['idClient']!=1) {
|
||||||
|
throw new SoapFault('ERR', "Application error");
|
||||||
|
} else {
|
||||||
|
throw new SoapFault('ERR', $e->getMessage());
|
||||||
|
}
|
||||||
|
} catch (Zend_Exception $e) {
|
||||||
|
throw new SoapFault('ERR', "Application error");
|
||||||
|
}
|
||||||
|
|
||||||
|
$bourseM = new Application_Model_Sdv1BourseIsin($db);
|
||||||
|
$result = $bourseM->find($isin)->current();
|
||||||
|
if ( $result===null ) {
|
||||||
|
throw new SoapFault('MSG', 'Aucun résultat');
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($result->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user