Advertisement
Guest User

tes

a guest
Oct 23rd, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. <?php
  2.  
  3. class WsGetChildController extends Controller
  4. {
  5. public $photoUrl = "http://ihcms.telkom.co.id/api/index.php?r=api/photo&nik=";
  6.  
  7. public function actions() {
  8.  
  9. return array(
  10. 'wsdl' => array(
  11. 'class' => 'CWebServiceAction',
  12. 'serviceOptions'=>array(
  13. 'generatorConfig'=>array(
  14. 'class'=>'CWsdlGenerator',
  15. 'bindingStyle'=>'document',
  16. 'operationBodyStyle'=>array('use'=>'literal'),
  17. )
  18. ),
  19. ),
  20. );
  21. }
  22.  
  23. public function actionIndex()
  24. {
  25. $this->render('index');
  26. }
  27.  
  28. function getphotoUrl($telkonik)
  29. {
  30. $getUrl = urlencode($this->photoUrl.$telkonik);
  31. return $getUrl;
  32. }
  33.  
  34. function getChildId($telkonik)
  35. {
  36. $c1 = new CDbCriteria();
  37. $c1->compare('N_NIK_GROUP',$telkonik);
  38. $theList = RptOmPosisi::model()->find($c1);
  39. // foreach ($theList as $oneRow)
  40. // {
  41. $oneR = new WsGetChildId();
  42. if(!empty($theList)){
  43. $oneR->childList = $this->getChildList($theList["OBJIDPOSISI"], $telkonik);
  44. }
  45. // }
  46. return $oneR;
  47. }
  48.  
  49. function getChildList($idParent, $telkonik)
  50. {
  51. $c2 = new CDbCriteria();
  52. $c2->order = 'V_NAMA_KARYAWAN ASC';
  53. $c2->compare('OBJIDPOSISI_PARENT',$idParent);
  54. $theList = RptOmPosisi::model()->findAll($c2);
  55. $result = array();
  56. foreach ($theList as $oneRow)
  57. {
  58. $oneR = new WsGetChildRecord();
  59. $oneR->telkoNik = $oneRow->N_NIK_GROUP;
  60. $oneR->childName = $oneRow->V_NAMA_KARYAWAN;
  61. $oneR->childPosition = $oneRow->V_NAMA_POSISI;
  62. $myEmail = Yii::app()->db->createCommand()->select('TELKONIK, INTERNETADDR')->from('TBL_NDPROFILEPERSON')->where('TELKONIK=:nik', array(':nik'=>$oneR->telkoNik))->queryRow();
  63. $oneR->profilePictUrl = $this->getphotoUrl($oneR->telkoNik);
  64. if(isset($myEmail["INTERNETADDR"])){
  65. $oneR->contactEmail = $myEmail["INTERNETADDR"];
  66. }else{
  67. $oneR->contactEmail = "";
  68. }
  69. $result[]= $oneR;
  70. }
  71.  
  72. // $e = new WsErrorModel();
  73. // if (empty($theList))
  74. // {
  75. // $e->errorCode = "9000";
  76. // $e->errorMessage = "Wrong username and password";
  77. // }
  78.  
  79. return $result;
  80. }
  81.  
  82. // public function getError(){
  83. // $errResult = array();
  84. // $err = new WsGetChildId();
  85. // $err->errorCode = "9000";
  86. // $err->errorMessage = "Wrong username and password";
  87. // $errResult[] = $err;
  88. // return $errResult;
  89. // }
  90.  
  91. /**
  92. * @param string telkonik
  93. * @return WsGetChildId
  94. * @soap
  95. */
  96. function getInfo($telkonik)
  97. {
  98. try {
  99. $db = Yii::app()->db->active = true;
  100. $parent = $this->getChildId($telkonik);
  101. $a = new WsGetChildId();
  102. if (!empty($parent->childList)) {
  103. $a = $parent;
  104. $a->errorCode = "0000";
  105. $a->errorMessage = "";
  106. } else {
  107. $a->errorCode = "9000";
  108. $a->errorMessage = "Empty Data";
  109. }
  110. } catch (Exception $e) {
  111. $a->errorCode = "9002";
  112. $a->errorMessage = "Database Error";
  113. }
  114. return $a;
  115. }
  116.  
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement