|
|
@@ -0,0 +1,141 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+Lib::loadClass('RouteBase');
|
|
|
+Lib::loadClass('ProcesHelper');
|
|
|
+
|
|
|
+class Route_UrlAction_TVObciazeniaVOD extends RouteBase {
|
|
|
+
|
|
|
+ private $conf = array('ID_LIST_SERVICES' => '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);
|
|
|
+
|
|
|
+?>
|
|
|
+<div class="container" style="margin-top:20px">
|
|
|
+ <form class="form-horizontal" method="post">
|
|
|
+ <legend>
|
|
|
+ Obciążenia za VOD
|
|
|
+ <span class="pull-right">
|
|
|
+ ID_SERVICES: <?=$ID_SERVICES?>
|
|
|
+ </span>
|
|
|
+ </legend>
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-12">
|
|
|
+ Klient: ID <?=$result[0]['ID_BILLING_USERS'].", ".$result[0]['P_NAME']." ".$result[0]['P_NAME_SECOND'].", ul. ".$result[0]['P_ADDRESS_STREET']." ".$result[0]['P_ADDRESS_HOUSE'].($result[0]['P_ADDRESS_HOME']?"/".$result[0]['P_ADDRESS_HOME']:"").", ".$result[0]['P_ADDRESS_POST_CODE']." ".$result[0]['P_ADDRESS_CITY']?><br/>
|
|
|
+ Adres instalacji: <?=$result[0]['S_ADDRESS_STREET']?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-12">
|
|
|
+ <h4>Nowe obciążenie:</h4>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="col-sm-offset-4 col-sm-2 control-label">Rok i miesiąc (RRRR-MM)</label>
|
|
|
+ <div class="col-sm-2">
|
|
|
+ <div class="input-group">
|
|
|
+ <input type="text" id="MIESIAC" class="form-control se_type-date" name="MIESIAC" value="<?=date("Y-m")?>" maxlength="7"/>
|
|
|
+ <span class="input-group-addon">
|
|
|
+ <span class="glyphicon glyphicon-calendar">
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="col-sm-offset-4 col-sm-2 control-label">Kwota brutto</label>
|
|
|
+ <div class="col-sm-2">
|
|
|
+ <div class="input-group">
|
|
|
+ <input type="text" id="BRUTTO" class="form-control" name="BRUTTO" value="0.00"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-sm-1">
|
|
|
+ <button type="submit" class="btn btn-primary">Dodaj</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-offset-4 col-sm-4">
|
|
|
+ <br/><h4>Dotychczasowe obciążenia za VOD:</h4>
|
|
|
+ <table class="table table-bordered table-hover table-striped">
|
|
|
+ <thead>
|
|
|
+ <tr style="text-align:center; background-color:lightgray"><td width="1">Lp.</td><td>Rok - miesiąc</td><td>Kwota brutto</td><td>Rozliczone</td></tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+<?php
|
|
|
+ if ($obciazenia) {
|
|
|
+ $i = 1;
|
|
|
+ foreach ($obciazenia as $x) {
|
|
|
+ echo "<tr><td style='text-align:right'>".$i++."</td><td style='text-align:center'>{$x['MIESIAC']}</td><td style='text-align:right'>{$x['BRUTTO']}</td><td style='text-align:center'>".($x['ROZLICZONE']?"Tak":"Nie")."</td></tr>";
|
|
|
+ }
|
|
|
+ } else echo '<tr style="text-align:center"><td colspan="4">Brak obciążeń</td></tr>';
|
|
|
+?>
|
|
|
+ </tbody>
|
|
|
+ <table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+</div>
|
|
|
+<script>
|
|
|
+jQuery(document.getElementById('MIESIAC')).parent().datetimepicker({
|
|
|
+format: 'YYYY-MM'
|
|
|
+, locale: 'pl'
|
|
|
+, showTodayButton: false
|
|
|
+, maxDate: '<?=date("Y-m")?>'
|
|
|
+});
|
|
|
+</script>
|
|
|
+<?php
|
|
|
+ } catch (Exception $e) {
|
|
|
+ SE_Layout::alert('danger',$e->getMessage());
|
|
|
+ }
|
|
|
+ SE_Layout::dol();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reinstallAction() {
|
|
|
+ die('OK');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|