'12', 'ID_LIST_SES_B_TYPES' => '19', 'TABLE' => 'SES_TV_C'); public function handleAuth() { if (!User::logged()) { throw new HttpException('Unauthorized', 401); } } public function addTVObciazenieVODAction($ID_SERVICES, $MIESIAC, $BRUTTO) { if (!preg_match("/^[[:digit:]]{4}-[[:digit:]]{2}$/",$MIESIAC)) throw new Exception("Błędna data"); if (strtotime($MIESIAC) > strtotime(date("Y-m"))) throw new Exception("Błędna data"); if (!preg_match("/^[[:digit:]]+(\.[[:digit:]]{1,2})?$/",$BRUTTO)) throw new Exception("Błędna kwota"); if ($BRUTTO == 0) throw new Exception("Błędna kwota"); if (!($ID_BILLING_USERS = DB::getPDO()->fetchValue("select ID_BILLING_USERS from SES_TV_A where ID_SERVICES='{$ID_SERVICES}'"))) throw new Exception("Błąd danych"); if (!($VAT = DB::getPDO()->fetchValue("select VAT from LIST_SERVICES where ID='{$this->conf['ID_LIST_SERVICES']}'"))) throw new Exception("Błąd danych"); $sqlObj = new stdClass(); $sqlObj->ID_SERVICES = $ID_SERVICES; $sqlObj->ID_BILLING_USERS = $ID_BILLING_USERS; $sqlObj->TYPE = $this->conf['ID_LIST_SES_B_TYPES']; $sqlObj->VALUE1 = $MIESIAC; $sqlObj->VALUE2 = V::nettoOdBrutto($BRUTTO,$VAT); $id = DB::getDB()->ADD_NEW_OBJ($this->conf['TABLE'], $sqlObj); return $id>0; } public function defaultAction() { SE_Layout::gora(); SE_Layout::menu(); try { if (!($ID_SERVICES = V::get('ID_SERVICES',0,$_GET,'int'))) throw new Exception("Błąd parametru"); $query = "select c.ID as ID_BILLING_USERS, c.P_NAME, c.P_NAME_SECOND, c.P_ADDRESS_STREET, c.P_ADDRESS_HOUSE, c.P_ADDRESS_HOME, c.P_ADDRESS_POST_CODE, c.P_ADDRESS_CITY, stva.S_ADDRESS_STREET from SES_TV_A stva join COMPANIES c on c.ID=stva.ID_BILLING_USERS where stva.ID_SERVICES='{$ID_SERVICES}'"; $result = DB::getPDO()->fetchall($query); if (!$result) throw new Exception("Błąd danych"); if (($MIESIAC = V::get('MIESIAC','',$_POST))!='' && ($BRUTTO = V::get('BRUTTO','',$_POST))) { try { if ($this->addTVObciazenieVODAction($ID_SERVICES, $MIESIAC, $BRUTTO)) SE_Layout::alert('success','Pomyślnie dodano obiążenie za VOD'); else SE_Layout::alert('danger','Nie udało się dodać obciążenia za VOD - nie dodano rekordu do SES_TV_C'); } catch (Exception $e) { SE_Layout::alert('danger',"Nie udało się dodać obciążenia za VOD - ".$e->getMessage()); } } $query = "select t1.VALUE1 as MIESIAC, round(t1.VALUE2*(1+t2.VAT/100),2) as BRUTTO, if (t1.ID_BILLING_NUMBERS is null, '0', '1') as ROZLICZONE from {$this->conf['TABLE']} as t1 join LIST_SERVICES t2 on t2.ID='{$this->conf['ID_LIST_SERVICES']}' where t1.ID_SERVICES='{$ID_SERVICES}' and t1.TYPE='{$this->conf['ID_LIST_SES_B_TYPES']}'"; $obciazenia = DB::getPDO()->fetchall($query); ?>