|
|
@@ -13,9 +13,17 @@ class Route_UrlAction_TVObciazeniaVOD extends RouteBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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");
|
|
|
+ public function addTVObciazenieVODAction($ID_SERVICES, $DESC_TYPE, $DESC, $BRUTTO) {
|
|
|
+ if ($DESC_TYPE == 'month') {
|
|
|
+ if (!preg_match("/^[[:digit:]]{4}-[[:digit:]]{2}$/",$DESC)) throw new Exception("Błędna data");
|
|
|
+ if (strtotime($DESC) > strtotime(date("Y-m"))) throw new Exception("Błędna data");
|
|
|
+ $DESC = "w miesiącu " . $DESC;
|
|
|
+ } elseif ($DESC_TYPE == 'desc') {
|
|
|
+ if ($DESC == '') throw new Exception("Błędny opis");
|
|
|
+ $DESC = "- " . $DESC;
|
|
|
+ } else throw new Exception("Błąd formularza");
|
|
|
+ $DESC = "Opłata za VOD " . $DESC;
|
|
|
+
|
|
|
if (!preg_match("/^[[:digit:]]+(\.[[:digit:]]{1,2})?$/",$BRUTTO)) throw new Exception("Błędna kwota");
|
|
|
if ($BRUTTO == 0) throw new Exception("Błędna kwota");
|
|
|
|
|
|
@@ -26,12 +34,20 @@ class Route_UrlAction_TVObciazeniaVOD extends RouteBase {
|
|
|
$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->VALUE1 = $DESC;
|
|
|
$sqlObj->VALUE2 = V::nettoOdBrutto($BRUTTO,$VAT);
|
|
|
$id = DB::getDB()->ADD_NEW_OBJ($this->conf['TABLE'], $sqlObj);
|
|
|
return $id>0;
|
|
|
}
|
|
|
|
|
|
+ public function delTVObciazenieVODAction($ID_SERVICES, $ID_SES_TV_C) {
|
|
|
+ $result = DB::getPDO()->fetchValue("select if (ID_BILLING_NUMBERS is null, '0', '1') from {$this->conf['TABLE']} where ID='{$ID_SES_TV_C}' and ID_SERVICES='{$ID_SERVICES}'");
|
|
|
+ if ($result == '') throw new Exception("błąd danych");
|
|
|
+ if ($result == 1) throw new Exception("obciążenie zostało już rozliczone");
|
|
|
+ DB::getPDO()->query("delete from {$this->conf['TABLE']} where ID='{$ID_SES_TV_C}'");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public function defaultAction() {
|
|
|
SE_Layout::gora();
|
|
|
SE_Layout::menu();
|
|
|
@@ -42,16 +58,29 @@ class Route_UrlAction_TVObciazeniaVOD extends RouteBase {
|
|
|
$result = DB::getPDO()->fetchall($query);
|
|
|
if (!$result) throw new Exception("Błąd danych");
|
|
|
|
|
|
- if (($MIESIAC = V::get('MIESIAC','',$_POST))!='' && ($BRUTTO = V::get('BRUTTO','',$_POST))) {
|
|
|
+ if (V::get('action','',$_POST) == 'add') {
|
|
|
try {
|
|
|
- if ($this->addTVObciazenieVODAction($ID_SERVICES, $MIESIAC, $BRUTTO)) SE_Layout::alert('success','Pomyślnie dodano obiążenie za VOD');
|
|
|
+ if (($DESC_TYPE = V::get('DESC_TYPE','',$_POST)) == '') throw new Exception("Błąd formularza");
|
|
|
+ if ($DESC_TYPE == 'month') $DESC = V::get('MIESIAC','',$_POST);
|
|
|
+ elseif ($DESC_TYPE == 'desc') $DESC = htmlspecialchars(V::get('DESC','',$_POST));
|
|
|
+ else throw new Exception("Błąd formularza");
|
|
|
+
|
|
|
+ if ($this->addTVObciazenieVODAction($ID_SERVICES, $DESC_TYPE, $DESC, V::get('BRUTTO','',$_POST))) 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']}'";
|
|
|
+ if ($ID_SES_TV_C_to_delete = V::get('delete',0,$_POST,'int')) {
|
|
|
+ try {
|
|
|
+ if ($this->delTVObciazenieVODAction($ID_SERVICES, $ID_SES_TV_C_to_delete)) SE_Layout::alert('success','Pomyślnie usunięto obiążenie za VOD');
|
|
|
+ } catch (Exception $e) {
|
|
|
+ SE_Layout::alert('danger',"Nie udało się usunąć obciążenia za VOD - ".$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $query = "select t1.ID as ID, 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);
|
|
|
|
|
|
?>
|
|
|
@@ -75,7 +104,7 @@ class Route_UrlAction_TVObciazeniaVOD extends RouteBase {
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
- <label class="col-sm-offset-4 col-sm-2 control-label">Rok i miesiąc (RRRR-MM)</label>
|
|
|
+ <label class="col-sm-offset-3 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"/>
|
|
|
@@ -85,31 +114,52 @@ class Route_UrlAction_TVObciazeniaVOD extends RouteBase {
|
|
|
</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="col-sm-1">
|
|
|
+ <div class="radio">
|
|
|
+ <label>
|
|
|
+ <input type="radio" name="DESC_TYPE" value="month" checked>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
- <label class="col-sm-offset-4 col-sm-2 control-label">Kwota brutto</label>
|
|
|
+ <label class="col-sm-offset-3 col-sm-2 control-label">Własny opis</label>
|
|
|
<div class="col-sm-2">
|
|
|
- <div class="input-group">
|
|
|
- <input type="text" id="BRUTTO" class="form-control" name="BRUTTO" value="0.00"/>
|
|
|
+ <input type="text" id="DESC" class="form-control" name="DESC"/>
|
|
|
+ </div>
|
|
|
+ <div class="col-sm-1">
|
|
|
+ <div class="radio">
|
|
|
+ <label>
|
|
|
+ <input type="radio" name="DESC_TYPE" value="desc">
|
|
|
+ </label>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="col-sm-offset-3 col-sm-2 control-label">Kwota brutto</label>
|
|
|
+ <div class="col-sm-2">
|
|
|
+ <input type="text" id="BRUTTO" class="form-control" name="BRUTTO" value="0.00"/>
|
|
|
+ </div>
|
|
|
<div class="col-sm-1">
|
|
|
- <button type="submit" class="btn btn-primary">Dodaj</button>
|
|
|
+ <button type="submit" class="btn btn-primary" name="action" value="add">Dodaj</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
- <div class="col-sm-offset-4 col-sm-4">
|
|
|
+ <div class="col-sm-offset-3 col-sm-6">
|
|
|
<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>
|
|
|
+ <tr style="text-align:center; background-color:lightgray"><td width="1">Lp.</td><td>Tytułem</td><td nowrap>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>";
|
|
|
+ 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'>";
|
|
|
+ if ($x['ROZLICZONE']) echo "Tak";
|
|
|
+ else echo "Nie</td><td width=\"1\"><button class=\"btn btn-default btn-xs\" type=\"submit\" name=\"delete\" value=\"{$x['ID']}\">Usuń</button>";
|
|
|
+ echo "</td></tr>";
|
|
|
}
|
|
|
} else echo '<tr style="text-align:center"><td colspan="4">Brak obciążeń</td></tr>';
|
|
|
?>
|