示例#1
0
 static function sendBloodRequestSMS($requestId)
 {
     $donationRequest = DonationRequest::model()->findByPk($requestId);
     $users = UserDetails::model()->findAllByAttributes(array('blood_group' => $donationRequest->blood_group, 'donation_status' => 'Y'));
     foreach ($users as $i => $user) {
         $str = Constants::$req_user_message;
         $tempurl = Constants::$sms_url;
         $repstr = strtr($str, array('{$GROUP}' => $donationRequest->bloodGroup->lookup_value, '{$ADMIN}' => Constants::$admin_number));
         $url1 = strtr($tempurl, array('{$number}' => $user->number, '{$message}' => $repstr));
         $url2 = $url2 = preg_replace('/ /', '%20', $url1);
         $payload = file_get_contents($url2);
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return DonationRequest the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = DonationRequest::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#3
0
 public function actionDelete()
 {
     switch ($_GET['model']) {
         // Load the respective model
         case 'userDetails':
             $model = UserDetails::model()->findByPk($_GET['id']);
             break;
         case 'lookupDetails':
             $model = LookupDetails::model()->findByPk($_GET['id']);
             break;
         case 'donationRequest':
             $model = DonationRequest::model()->findByPk($_GET['id']);
             break;
         default:
             $this->_sendResponse(501, sprintf('Error: Mode <b>delete</b> is not implemented for model <b>%s</b>', $_GET['model']));
             Yii::app()->end();
     }
     // Was a model found? If not, raise an error
     if ($model === null) {
         $this->_sendResponse(400, sprintf("Error: Didn't find any model <b>%s</b> with ID <b>%s</b>.", $_GET['model'], $_GET['id']));
     }
     // Delete the model
     $num = $model->delete();
     if ($num > 0) {
         $this->_sendResponse(200, $num);
     } else {
         $this->_sendResponse(500, sprintf("Error: Couldn't delete model <b>%s</b> with ID <b>%s</b>.", $_GET['model'], $_GET['id']));
     }
 }