This commit is contained in:
Aram HARUTYUNYAN 2013-11-20 08:31:28 +00:00
parent 8b952b1033
commit 073de975fa
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1TabCities extends Zend_Db_Table_Abstract
{
protected $_name = 'zonesVilles';
protected $_schema = 'sdv1';
}

View File

@ -64,6 +64,63 @@ class Catalog extends WsScore
return json_encode($tab);
}
/**
* Cities
* @param string $id
* @param array $columns
* @throws SoapFault
* @return string
*/
public function getCity($id=null, $columns = array())
{
$this->authenticate();
$columnsList = array(
'cp',
'commune',
);
if (empty($columns) || count($columns)==0) {
$columnsDisplay = array('cp', 'commune');
}
// Check authorize column
else {
foreach ( $columns as $column ) {
if ( in_array($column, $columnsList) ) {
$columnsDisplay[] = $column;
}
}
}
try {
$model = new Application_Model_sdv1TabCities();
$sql = $model->select()->from($model, $columnsDisplay);
if ( $id!==null ) {
$sql->where('cp=?', $id);
}
$result = $model->fetchAll($sql);
} catch (Zend_Db_Adapter_Exception $e) {
if ($this->tabInfoUser['idClient']==1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
throw new SoapFault('ERR', "Application error");
}
} catch (Zend_Exception $e) {
throw new SoapFault('ERR', $e->getMessage());
}
$tab = array();
if ( $result->count()>0 ) {
foreach ( $result as $item ) {
$tab[] = $item->toArray();
}
}
return json_encode($tab);
}
/**
* Legal Form