Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class WsGetChildController extends Controller
- {
- public $photoUrl = "http://ihcms.telkom.co.id/api/index.php?r=api/photo&nik=";
- public function actions() {
- return array(
- 'wsdl' => array(
- 'class' => 'CWebServiceAction',
- 'serviceOptions'=>array(
- 'generatorConfig'=>array(
- 'class'=>'CWsdlGenerator',
- 'bindingStyle'=>'document',
- 'operationBodyStyle'=>array('use'=>'literal'),
- )
- ),
- ),
- );
- }
- public function actionIndex()
- {
- $this->render('index');
- }
- function getphotoUrl($telkonik)
- {
- $getUrl = urlencode($this->photoUrl.$telkonik);
- return $getUrl;
- }
- function getChildId($telkonik)
- {
- $c1 = new CDbCriteria();
- $c1->compare('N_NIK_GROUP',$telkonik);
- $theList = RptOmPosisi::model()->find($c1);
- // foreach ($theList as $oneRow)
- // {
- $oneR = new WsGetChildId();
- if(!empty($theList)){
- $oneR->childList = $this->getChildList($theList["OBJIDPOSISI"], $telkonik);
- }
- // }
- return $oneR;
- }
- function getChildList($idParent, $telkonik)
- {
- $c2 = new CDbCriteria();
- $c2->order = 'V_NAMA_KARYAWAN ASC';
- $c2->compare('OBJIDPOSISI_PARENT',$idParent);
- $theList = RptOmPosisi::model()->findAll($c2);
- $result = array();
- foreach ($theList as $oneRow)
- {
- $oneR = new WsGetChildRecord();
- $oneR->telkoNik = $oneRow->N_NIK_GROUP;
- $oneR->childName = $oneRow->V_NAMA_KARYAWAN;
- $oneR->childPosition = $oneRow->V_NAMA_POSISI;
- $myEmail = Yii::app()->db->createCommand()->select('TELKONIK, INTERNETADDR')->from('TBL_NDPROFILEPERSON')->where('TELKONIK=:nik', array(':nik'=>$oneR->telkoNik))->queryRow();
- $oneR->profilePictUrl = $this->getphotoUrl($oneR->telkoNik);
- if(isset($myEmail["INTERNETADDR"])){
- $oneR->contactEmail = $myEmail["INTERNETADDR"];
- }else{
- $oneR->contactEmail = "";
- }
- $result[]= $oneR;
- }
- // $e = new WsErrorModel();
- // if (empty($theList))
- // {
- // $e->errorCode = "9000";
- // $e->errorMessage = "Wrong username and password";
- // }
- return $result;
- }
- // public function getError(){
- // $errResult = array();
- // $err = new WsGetChildId();
- // $err->errorCode = "9000";
- // $err->errorMessage = "Wrong username and password";
- // $errResult[] = $err;
- // return $errResult;
- // }
- /**
- * @param string telkonik
- * @return WsGetChildId
- * @soap
- */
- function getInfo($telkonik)
- {
- try {
- $db = Yii::app()->db->active = true;
- $parent = $this->getChildId($telkonik);
- $a = new WsGetChildId();
- if (!empty($parent->childList)) {
- $a = $parent;
- $a->errorCode = "0000";
- $a->errorMessage = "";
- } else {
- $a->errorCode = "9000";
- $a->errorMessage = "Empty Data";
- }
- } catch (Exception $e) {
- $a->errorCode = "9002";
- $a->errorMessage = "Database Error";
- }
- return $a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement