issue #0000930 : Gestion des services et des tarifs
This commit is contained in:
parent
3f585797cf
commit
034740a906
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
class Application_Model_ClientsTarif extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'clientsTarif';
|
||||
}
|
5
application/models/Sdv1ClientsServices.php
Normal file
5
application/models/Sdv1ClientsServices.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1ClientsServices extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'clients_services';
|
||||
}
|
5
application/models/Sdv1ClientsTarifs.php
Normal file
5
application/models/Sdv1ClientsTarifs.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1ClientsTarifs extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'clients_tarifs';
|
||||
}
|
5
application/models/Sdv1UtilisateursService.php
Normal file
5
application/models/Sdv1UtilisateursService.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1UtilisateursService extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'utilisateurs_service';
|
||||
}
|
6
config/_sql/sdv1.clients_services.sql
Normal file
6
config/_sql/sdv1.clients_services.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `clients_services` (
|
||||
`code` varchar(20) NOT NULL COMMENT 'Code du service (elements texte sans espace ni caractères spéciaux)',
|
||||
`label` varchar(100) NOT NULL COMMENT 'Libellé du service',
|
||||
`idClient` int(11) NOT NULL,
|
||||
KEY `code` (`code`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
@ -1,14 +1,9 @@
|
||||
--
|
||||
-- Structure de la table `clientsTarif`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `clientsTarif` (
|
||||
CREATE TABLE IF NOT EXISTS `clients_tarifs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`idClient` int(11) NOT NULL,
|
||||
`service` char(20) NOT NULL,
|
||||
`login` char(20) NOT NULL,
|
||||
`log` char(20) NOT NULL COMMENT 'Element à facturer',
|
||||
`type` enum('Unitaire','ForfaitLimit','ForfaitIllimit') NOT NULL,
|
||||
`type` enum('Unitaire','ForfaitLimit','ForfaitNolimit') NOT NULL,
|
||||
`priceUnit` float NOT NULL DEFAULT '0' COMMENT 'Prix unitaire d''un élément',
|
||||
`limit` int(11) NOT NULL DEFAULT '0' COMMENT 'Nombre limite de consommation',
|
||||
`dateDebut` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date de debut du contrat',
|
5
config/_sql/sdv1.utilisateurs_service.sql
Normal file
5
config/_sql/sdv1.utilisateurs_service.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS `utilisateurs_service` (
|
||||
`login` varchar(20) NOT NULL,
|
||||
`serviceCode` varchar(20) NOT NULL COMMENT 'Code du service',
|
||||
KEY `login` (`login`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
@ -21,3 +21,4 @@ Type[] = "ModeleUtilisateurReturn"
|
||||
Type[] = "ModeleUtilisateur"
|
||||
Type[] = "ClientTarif"
|
||||
Type[] = "ClientPrestation"
|
||||
Type[] = "Service"
|
@ -1255,7 +1255,7 @@ class Gestion extends WsScore
|
||||
|
||||
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||
|
||||
$tarifM = new Application_Model_ClientsTarif($db);
|
||||
$tarifM = new Application_Model_Sdv1ClientsTarifs($db);
|
||||
|
||||
if (!in_array($tarif->log, array_keys($this->listeDroits))) {
|
||||
throw new SoapFault('ClientTarif', 'log inexistant');
|
||||
@ -1278,7 +1278,6 @@ class Gestion extends WsScore
|
||||
$data = array(
|
||||
'idClient' => $tarif->idClient,
|
||||
'service' => $tarif->service,
|
||||
'login' => $tarif->login,
|
||||
'log' => $tarif->log,
|
||||
'type' => $tarif->type,
|
||||
'priceForfait' => $tarif->priceForfait,
|
||||
@ -1311,7 +1310,7 @@ class Gestion extends WsScore
|
||||
|
||||
$db = Zend_Db::factory($this->dbConfig->db->sdv1);
|
||||
|
||||
$tarifM = new Application_Model_ClientsTarif($db);
|
||||
$tarifM = new Application_Model_Sdv1ClientsTarifs($db);
|
||||
|
||||
//Au client
|
||||
$sql = $tarifM->select()
|
||||
@ -1490,4 +1489,192 @@ class Gestion extends WsScore
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a Service in Client
|
||||
* @param int $idClient
|
||||
* @param string $code
|
||||
* @param string $label
|
||||
* @throws SoapFault
|
||||
* @return int
|
||||
*/
|
||||
public function setService($idClient, $code, $label)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($this->tabInfoUser['profil']!='SuperAdministrateur') {
|
||||
$this->sendError('0902');
|
||||
}
|
||||
|
||||
//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");
|
||||
}
|
||||
|
||||
try {
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices();
|
||||
|
||||
//Check if code exist in idClient
|
||||
$sql = $serviceM->select()
|
||||
->where('idClient=?',$idClient)
|
||||
->where('code=?',$code);
|
||||
|
||||
$row = $serviceM->fetchAll($sql);
|
||||
|
||||
if ($row->count()>0) {
|
||||
$data = array(
|
||||
'label' => $label,
|
||||
);
|
||||
$result = $serviceM->update($data, array('idClient'=>$idClient, 'code'=> $code));
|
||||
} else {
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
'label' => $label,
|
||||
'idClient' => $idClient
|
||||
);
|
||||
$result = $serviceM->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());
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a User in a Service
|
||||
* @param string $login
|
||||
* @param string $code
|
||||
* @throws SoapFault
|
||||
* @return int
|
||||
*/
|
||||
public function setUtilisateurService($login, $code)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($this->tabInfoUser['profil']!='SuperAdministrateur') {
|
||||
$this->sendError('0902');
|
||||
}
|
||||
|
||||
//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");
|
||||
}
|
||||
|
||||
try {
|
||||
$serviceM = new Application_Model_Sdv1UtilisateursService();
|
||||
|
||||
//Check if code exist in idClient
|
||||
$sql = $serviceM->select()->where('login=?',$login);
|
||||
|
||||
$row = $serviceM->fetchAll($sql);
|
||||
|
||||
if ($row->count()>0) {
|
||||
$data = array(
|
||||
'serviceCode' => $label,
|
||||
);
|
||||
$result = $serviceM->update($data, array('login'=>$login));
|
||||
} else {
|
||||
$data = array(
|
||||
'login' => $login,
|
||||
'serviceCode' => $code,
|
||||
);
|
||||
$result = $serviceM->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());
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* List Services
|
||||
* @param int $idClient
|
||||
* @throws SoapFault
|
||||
* @return Service
|
||||
*/
|
||||
public function getServices($idClient)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($this->tabInfoUser['profil']!='SuperAdministrateur') {
|
||||
$this->sendError('0902');
|
||||
}
|
||||
|
||||
//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");
|
||||
}
|
||||
|
||||
try {
|
||||
$serviceM = new Application_Model_Sdv1ClientsServices();
|
||||
$sql = $serviceM->select()->where('idClient=?', $idClient);
|
||||
$rows = $serviceM->fetchAll($sql);
|
||||
} 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");
|
||||
}
|
||||
|
||||
$output = array();
|
||||
if ($rows->count()>0) {
|
||||
foreach($rows as $item) {
|
||||
$service = new Service();
|
||||
$service->code = $item->code;
|
||||
$service->label = $item->label;
|
||||
|
||||
//Get logins
|
||||
$userserviceM = new Application_Model_Sdv1UtilisateursService();
|
||||
$sql = $userserviceM->select()->where('code=?',$item->code);
|
||||
$logins = $userserviceM->fetchAll($sql);
|
||||
|
||||
if ($logins->count()>0) {
|
||||
foreach($logins as $login) {
|
||||
$service->login[] = $login;
|
||||
}
|
||||
}
|
||||
$output[] = $service;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
@ -454,12 +454,6 @@ class ClientTarif
|
||||
*/
|
||||
public $service;
|
||||
|
||||
/**
|
||||
* Identifiant de l'utilisateur
|
||||
* @var string
|
||||
*/
|
||||
public $login;
|
||||
|
||||
/**
|
||||
* Type du forfait ('Unitaire'|'ForfaitLimit'|'ForfaitIllimit')
|
||||
* @var string
|
||||
@ -553,3 +547,15 @@ class ClientPrestation
|
||||
/** @var string */
|
||||
public $dateFin;
|
||||
}
|
||||
|
||||
class Service
|
||||
{
|
||||
/** @var string*/
|
||||
public $code;
|
||||
|
||||
/** @var string*/
|
||||
public $label;
|
||||
|
||||
/** @var string[]*/
|
||||
public $login;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user