Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 100 |
| TalukService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
506.00 | |
0.00% |
0 / 100 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getAllTaluks | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
| getTaluks | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 20 |
|||
| insertTaluk | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| updateTaluk | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| deleteTaluk | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getTaluksByDistrictId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| getTaluksByDistrictIdForDataImport | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 16 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use phpDocumentor\Reflection\Types\Integer; | |
| class TalukService extends BaseService | |
| { | |
| private static $_instance = null; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| {} | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() | |
| {} | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() | |
| { | |
| if (! is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self(); | |
| return self::$_instance; | |
| } | |
| /** | |
| * | |
| * | |
| * @author gadheyan | |
| * @throws ProfessionalException | |
| * @return | |
| */ | |
| public function getAllTaluks() | |
| { | |
| $query = "select t.id, t.state_id as stateId, t.districts_id as districtId, t.talukName as name, s.state_name as stateName, d.districtName from taluks t LEFT JOIN districts d ON d.id = t.districts_id LEFT JOIN state s ON d.state_id = s.id AND t.state_id = s.id"; | |
| try { | |
| $responseList = $this->executeQueryForList($query); | |
| if (empty($responseList)) { | |
| throw new ProfessionalException(ProfessionalException::ARRAY_EMPTY, "No Records Found!"); | |
| } | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $responseList; | |
| } | |
| /** | |
| * | |
| * @param unknown $districtId | |
| * @param unknown $stateId | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| */ | |
| public function getTaluks($districtId,$stateId = null) | |
| { | |
| $sql = ''; | |
| $stateId = $this->realEscapeString($stateId); | |
| $districtId = $this->realEscapeString($districtId); | |
| $conditions = ""; | |
| if($stateId){ | |
| $conditions=" AND state_id = '$stateId' "; | |
| } | |
| if($districtId){ | |
| $conditions=" AND districts_id = '$districtId' "; | |
| } | |
| $talukDetails = []; | |
| try{ | |
| $sql = "SELECT id AS talukId, state_id AS stateId , districts_id AS districtId , talukName,student_specify FROM taluks WHERE 1=1 $conditions"; | |
| $talukDetails = $this->executeQueryForList($sql); | |
| }catch (\Exception $e){ | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return $talukDetails; | |
| } | |
| /** | |
| * | |
| * @param unknown | |
| * @throws ProfessionalException | |
| * @return unknown | |
| */ | |
| public function insertTaluk($taluk) | |
| { | |
| $taluk = $this->realEscapeObject($taluk); | |
| $query = "insert into taluks ( state_id, districts_id, talukName) values ('$taluk->stateId', '$taluk->districtId', '$taluk->name')"; | |
| try{ | |
| $response=$this->executeQueryForObject($query,true); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return $response; | |
| } | |
| /** | |
| * | |
| * @param $nationality | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| public function updateTaluk($taluk) | |
| { | |
| $taluk=$this->realEscapeObject($taluk); | |
| $query = "update taluks set state_id='$taluk->stateId', districts_id='$taluk->districtId', talukName = '$taluk->name' where id='$taluk->id'"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return "success"; | |
| } | |
| /** | |
| * | |
| * @param integer $id | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| public function deleteTaluk($id) | |
| { | |
| $id=$this->realEscapeString($id); | |
| $query = "delete from taluks where id='$id'"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return "success"; | |
| } | |
| /** | |
| * | |
| * @param unknown $districtId | |
| * @param unknown $stateId | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| * @author Vishnu M | |
| */ | |
| public function getTaluksByDistrictId($districtId) | |
| { | |
| $sql = ''; | |
| $districtId = $this->realEscapeString($districtId); | |
| $talukDetails = []; | |
| try{ | |
| $sql = "SELECT id AS talukId, state_id AS stateId , districts_id AS districtId , talukName,student_specify FROM taluks WHERE districts_id = '$districtId'"; | |
| $talukDetails = $this->executeQueryForList($sql); | |
| }catch (\Exception $e){ | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return $talukDetails; | |
| } | |
| public function getTaluksByDistrictIdForDataImport($districtId) | |
| { | |
| $sql = ''; | |
| $districtId = $this->realEscapeString($districtId); | |
| $cond = ''; | |
| $talukDetails = []; | |
| if($districtId){ | |
| $cond .= " AND districts_id = '$districtId' "; | |
| } | |
| try{ | |
| $sql = "SELECT id AS id, state_id AS stateId , districts_id AS districtId , talukName as name,student_specify FROM taluks WHERE 1=1 $cond "; | |
| $talukDetails = $this->executeQueryForList($sql); | |
| }catch (\Exception $e){ | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return $talukDetails; | |
| } | |
| } | |