public function calculate($id, $per, $percentaj) { $this->per = $per; $this->percent = $percentaj; $this->subscription = Subscription::find($id); if (auth()->user()->hasRole(config('access.roles.saller'))) { $type = auth()->user()->type_id; if ($type == 2) { /*regulile cu minim ==> Borker*/ $this->price = $this->broker(); } else { /*reguli normale*/ $this->price = $this->normal(); } } return $this->price; }
public function actionNotify() { $proxy = new NSIProxy(); $proxy->loadFile('https://agg.cipo.rnp.br/dds/documents?id=urn:ogf:network:cipo.rnp.br:2013:'); $proxy->parseTopology(); $message = '<?xml version="1.0" encoding="UTF-8"?>' . '<tns:notifications xmlns:tns="http://schemas.ogf.org/nsi/2014/02/discovery/types" ' . 'providerId="urn:ogf:network:ufrgs.br:2015:nsa:proxy" ' . 'id="6" href="">' . '<tns:notification>' . '<discovered>none</discovered>' . '<event>Update</event>' . $proxy->xml->saveHTML() . '</tns:notification>' . '</tns:notifications>'; $xml = new \DOMDocument(); $xml->loadXML($message); $ch = curl_init(); foreach (Subscription::find()->asArray()->all() as $sub) { foreach ($xml->getElementsByTagNameNS('http://schemas.ogf.org/nsi/2014/02/discovery/types', 'notifications') as $subXml) { $subXml->setAttribute('id', $sub['id']); } Yii::trace($xml->saveXML()); $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $xml->saveXML(), CURLOPT_HTTPHEADER => array('Accept-encoding: application/xml;charset=utf-8', 'Content-Type: application/xml;charset=utf-8'), CURLOPT_USERAGENT => 'Meican', CURLOPT_URL => $sub['discovery_url']); curl_setopt_array($ch, $options); $output = curl_exec($ch); } curl_close($ch); return ""; }