Exemple #1
0
 public function hasPermissionToCreateRegional($regionalIdOwner, $newServiceAreaData, $indice)
 {
     $modelServiceArea = new Model_ServiceArea();
     $regionalOwnerSA = $modelServiceArea->getAllServiceAreaByRegionalId($regionalIdOwner);
     switch ($indice) {
         case 'StateId':
             // só verifica se tem acesso aos Estados
             if (!($regionalOwnerSA['indice'] == 'StateId')) {
                 $error['messageError'] = 'Sem permissão para criar regional com Estado(s)';
                 throw new Vtx_UserException($error['messageError']);
                 return;
             }
             // verifica se é/são o(s) mesmo(s) Estado(s)
             if (!Vtx_Util_Array::array_all_in_array($newServiceAreaData['StateId'], $regionalOwnerSA['value']['StateId'])) {
                 $error['messageError'] = 'Sem permissão para criar regional com este(s) Estado(s)';
                 throw new Vtx_UserException($error['messageError']);
                 return;
             }
             break;
         case 'CityId':
             //Regional Estadual, pode criar p/ cidades.
             if ($regionalOwnerSA['indice'] == 'StateId') {
                 return true;
             }
             if ($regionalOwnerSA['indice'] == 'NeighborhoodId') {
                 $error['messageError'] = 'Sem permissão para criar regional com esta(s) Cidade(s)';
                 throw new Vtx_UserException($error['messageError']);
                 return;
             }
             //Regional Municipal, apenas para suas cidades.
             if (!Vtx_Util_Array::array_all_in_array($newServiceAreaData['CityId'], $regionalOwnerSA['value']['CityId'])) {
                 $error['messageError'] = 'Sem permissão para criar regional com esta(s) Cidade(s)';
                 throw new Vtx_UserException($error['messageError']);
                 return;
             }
             break;
         case 'NeighborhoodId':
             //Regional Estadual, pode criar p/ cidades.
             if ($regionalOwnerSA['indice'] == 'StateId') {
                 return true;
             }
             //Regional Municipal, pode criar p/  bairros.
             if ($regionalOwnerSA['indice'] == 'CityId') {
                 return true;
             }
             //Regional Bairro, apenas para seus bairros.
             if (!Vtx_Util_Array::array_all_in_array($newServiceAreaData['NeighborhoodId'], $regionalOwnerSA['value']['NeighborhoodId'])) {
                 $error['messageError'] = 'Sem permissão para criar regional com este(s) Bairro(s)';
                 throw new Vtx_UserException($error['messageError']);
                 return;
             }
             break;
         default:
             break;
     }
     return true;
 }
Exemple #2
0
 public function getAllEnterpriseByRegionalServiceArea($regionalId, $count = null, $offset = null, $filter = null)
 {
     $modelServiceArea = new Model_ServiceArea();
     $dbTable_Enterprise = new DbTable_Enterprise();
     $sa = $modelServiceArea->getAllServiceAreaByRegionalId($regionalId);
     $indice = $sa['indice'];
     $getAllEnterpriseQuery = $dbTable_Enterprise->getAllByColAE($sa['value'][$indice], $indice, null, 'select', $filter);
     return Zend_Paginator::factory($getAllEnterpriseQuery)->setItemCountPerPage($count ? $count : null)->setCurrentPageNumber($offset ? $offset : 1);
 }