Changeset 726
- Timestamp:
- Jan 5, 2015, 10:01:40 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Version.php
r725 r726 1 1 <?php 2 2 3 $Revision = 72 5; // Subversion revision4 $DatabaseRevision = 72 5; // SQL structure revision5 $ReleaseTime = strtotime('2015-01-0 4');3 $Revision = 726; // Subversion revision 4 $DatabaseRevision = 726; // SQL structure revision 5 $ReleaseTime = strtotime('2015-01-05'); -
trunk/Common/Setup/Updates.php
r725 r726 1033 1033 } 1034 1034 1035 /*1036 function UpdateTo719($Manager)1037 {1038 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_1`;');1039 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Subject` `SubjectFrom` INT(11) NULL DEFAULT "";');1040 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `SubjectTo` INT NULL AFTER `SubjectFrom`, ADD INDEX (`SubjectTo`) ;');1041 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`SubjectFrom`) REFERENCES `Subject`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');1042 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`SubjectTo`) REFERENCES `Subject`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');1043 // Set target subject to 1 = company subject id1044 $Manager->Execute('UPDATE `FinanceOperation` SET `SubjectTo` = 1;');1045 $Manager->Execute('UPDATE `FinanceOperation` SET `SubjectTo` = `SubjectFrom` WHERE `Value` < 0');1046 $Manager->Execute('UPDATE `FinanceOperation` SET `SubjectFrom` = 1,`Value`= -`Value` WHERE `Value` < 0');1047 1048 }1049 */1050 1051 1035 function UpdateTo719($Manager) 1052 1036 { … … 1163 1147 } 1164 1148 $DbResult = $Manager->Execute('UPDATE `FinanceInvoiceItem` SET `Description` = "'.$SearchText.'" WHERE `Description` LIKE "'.$SearchText.' za období%";'); 1149 } 1150 1151 function UpdateTo726($Manager) 1152 { 1153 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); 1154 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;'); 1155 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` DROP FOREIGN KEY `ServiceCustomerRel_ibfk_4`;'); 1156 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); 1157 $Manager->Execute('ALTER TABLE `ServiceCustomerRel` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `ServiceCustomerRel`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1158 1159 $Manager->Execute('ALTER TABLE `Service` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); 1160 $Manager->Execute('ALTER TABLE `Service` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;'); 1161 $Manager->Execute('ALTER TABLE `Service` DROP FOREIGN KEY `Service_ibfk_2`;'); 1162 $Manager->Execute('ALTER TABLE `Service` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); 1163 $Manager->Execute('ALTER TABLE `Service` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `Service`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1164 1165 $Manager->Execute('ALTER TABLE `FinanceCharge` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;'); 1166 $Manager->Execute('ALTER TABLE `FinanceCharge` ADD `ChangeTime` DATETIME NULL AFTER `ChangeAction`;'); 1167 $Manager->Execute('ALTER TABLE `FinanceCharge` DROP FOREIGN KEY `FinanceCharge_ibfk_1`;'); 1168 $Manager->Execute('ALTER TABLE `FinanceCharge` CHANGE `ReplaceId` `ChangeReplaceId` INT(11) NULL DEFAULT NULL;'); 1169 $Manager->Execute('ALTER TABLE `FinanceCharge` ADD FOREIGN KEY (`ChangeReplaceId`) REFERENCES `FinanceCharge`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1170 1171 $Manager->Execute('ALTER TABLE `MemberPayment` DROP `NetworkDevice`;'); 1165 1172 } 1166 1173 … … 1225 1232 720 => array('Revision' => 722, 'Function' => 'UpdateTo722'), 1226 1233 722 => array('Revision' => 725, 'Function' => 'UpdateTo725'), 1234 725 => array('Revision' => 726, 'Function' => 'UpdateTo726'), 1227 1235 )); 1228 1236 } -
trunk/Modules/Customer/Customer.php
r723 r726 82 82 'Storage' => array('Type' => 'Integer', 'Caption' => 'Úložiště', 'Default' => '0', 'Suffix' => 'GB'), 83 83 'CPUCount' => array('Type' => 'Integer', 'Caption' => 'Počet jader', 'Default' => '0', 'Suffix' => ''), 84 'Action' => array('Type' => 'TActionEnum', 'Caption' => 'Změna období', 'Default' => '', 'Null' => true), 85 'ReplaceId' => array('Type' => 'TService', 'Caption' => 'Cílová položka', 'Default' => '', 'Null' => true), 84 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 85 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true), 86 'ChangeReplaceId' => array('Type' => 'TService', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true), 86 87 'CustomerRel' => array('Type' => 'TServiceCustomerRelListService', 'Caption' => 'Placení zákazníky', 'Default' => ''), 87 88 ), … … 101 102 'Service' => array('Type' => 'TService', 'Caption' => 'Služba', 'Default' => ''), 102 103 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''), 103 'Action' => array('Type' => 'TActionEnum', 'Caption' => 'Změna období', 'Default' => '', 'Null' => true), 104 'ReplaceId' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Cílová položka', 'Default' => '', 'Null' => true), 104 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 105 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true), 106 'ChangeReplaceId' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true), 105 107 ), 106 108 )); -
trunk/Modules/Finance/Finance.php
r725 r726 46 46 47 47 // Period parameter is not used as it have to be determined from item replacement 48 $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE `ReplaceId` IS NULLLIMIT 1');48 $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE (`ChangeAction` IS NULL) LIMIT 1'); 49 49 $Row = $DbResult->fetch_array(); 50 50 $this->kWh = $Row['kWh']; … … 115 115 while($Member = $DbResult->fetch_assoc()) 116 116 { 117 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE( -SUM(Value*Direction), 0) FROM FinanceOperation '.118 'WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(-SUM(Value*Direction), 0) FROM FinanceInvoice '.117 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value*Direction), 0) FROM FinanceOperation '. 118 'WHERE Subject='.$Member['Subject'].') - (SELECT COALESCE(SUM(Value*Direction), 0) FROM FinanceInvoice '. 119 119 'WHERE Subject='.$Member['Subject'].')) AS Cash'); 120 120 $Cash = $DbResult2->fetch_row(); … … 129 129 $DbResult2 = $this->Database->query('SELECT SUM(`Service`.`Price`) AS `Price` '. 130 130 'FROM `ServiceCustomerRel` LEFT JOIN '. 131 '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE `ServiceCustomerRel`.`Customer`='.132 $Member['Id'].' AND `ServiceCustomerRel`.`Action` IS NULL');131 '`Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` WHERE (`ServiceCustomerRel`.`Customer`='. 132 $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)'); 133 133 $DbRow = $DbResult2->fetch_assoc(); 134 134 $Monthly = 0; … … 149 149 } 150 150 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 151 ' NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet,151 'MonthlyInternet' => $MonthlyInet, 152 152 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 153 153 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus))); … … 430 430 'BaseTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Základní cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'), 431 431 'TopTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Nejvyšší cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'), 432 'Action' => array('Type' => 'TActionEnum', 'Caption' => 'Změna období', 'Default' => '', 'Null' => true), 433 'ReplaceId' => array('Type' => 'TFinanceCharge', 'Caption' => 'Cílová položka', 'Default' => '0', 'Null' => true), 432 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 433 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true), 434 'ChangeReplaceId' => array('Type' => 'TFinanceCharge', 'Caption' => 'Změna - položka', 'Default' => '0', 'Null' => true), 434 435 ), 435 436 )); -
trunk/Modules/Finance/Manage.php
r724 r726 54 54 '(SELECT GROUP_CONCAT(`Service`.`Name`) FROM `ServiceCustomerRel` LEFT JOIN `Service` '. 55 55 'ON `Service`.`Id`=`ServiceCustomerRel`.`Service` WHERE `ServiceCustomerRel`.`Customer`=`Member`.`Id` AND '. 56 '`ServiceCustomerRel`.` Action` IS NULL) AS `ServicesNextMonth`, '.56 '`ServiceCustomerRel`.`ChangeAction` IS NULL) AS `ServicesNextMonth`, '. 57 57 'UNIX_TIMESTAMP(`Member`.`BillingPeriodLastDate`) AS `LastDate`, `Subject`.`Name` AS `SubjectName`, '. 58 58 '`FinanceBillingPeriod`.`Name` AS `BillingPeriodName` '. … … 156 156 'ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '. 157 157 'WHERE (`ServiceCustomerRel`.`Customer`='. 158 $Member['Id'].') AND (`ServiceCustomerRel`.` Action` IS NULL) ');158 $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '); 159 159 while($Service = $DbResult2->fetch_assoc()) 160 160 { … … 192 192 } 193 193 194 function TableUpdatePeriod($Table) 195 { 196 $DbResult = $this->Database->select($Table, '*', '`Action` IS NOT NULL'); 194 function TableUpdateChanges($Table) 195 { 196 $Time = time(); 197 $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '. 198 '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC'); 197 199 while($Service = $DbResult->fetch_array()) 198 200 { 199 if($Service[' Action'] == 'add')201 if($Service['ChangeAction'] == 'add') 200 202 { 201 203 unset($Service['Id']); 202 unset($Service[' ReplaceId']);203 unset($Service[' Action']);204 unset($Service['ChangeReplaceId']); 205 unset($Service['ChangeAction']); 204 206 $this->Database->insert($Table, $Service); 205 207 } else 206 if($Service[' Action'] == 'modify')208 if($Service['ChangeAction'] == 'modify') 207 209 { 208 210 unset($Service['Id']); 209 unset($Service[' Action']);210 $ReplaceId = $Service[' ReplaceId'];211 unset($Service[' ReplaceId']);211 unset($Service['ChangeAction']); 212 $ReplaceId = $Service['ChangeReplaceId']; 213 unset($Service['ChangeReplaceId']); 212 214 $this->Database->update($Table, 'Id='.$ReplaceId, $Service); 213 215 } else 214 if($Service[' Action'] == 'delete')216 if($Service['ChangeAction'] == 'delete') 215 217 { 216 218 $this->Database->delete($Table, '`Id`='.$Service['ReplaceId']); 217 219 } 218 220 } 219 $this->Database->delete($Table, '`Action` IS NOT NULL'); 220 } 221 221 $this->Database->delete($Table, '(`ChangeAction` IS NOT NULL) AND (`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'")'); 222 } 223 224 function ProcessTableUpdates() 225 { 226 // Update finance charge 227 $Output = 'Měním aktuální parametry sítě...<br>'; 228 $this->TableUpdateChanges('FinanceCharge'); 229 230 // Update services 231 $Output .= 'Aktualizuji služby....<br>'; 232 $this->TableUpdateChanges('Service'); 233 234 // Update customer service selections 235 $Output .= 'Aktualizuji výběr služeb zákazníků....<br>'; 236 $this->TableUpdateChanges('ServiceCustomerRel'); 237 238 return($Output); 239 } 240 222 241 function ProcessMonthlyPayment() 223 242 { … … 225 244 $Output = ''; 226 245 246 $Output .= $this->ProcessTableUpdates(); 247 227 248 $Finance = &$this->System->Modules['Finance']; 228 249 $Finance->LoadMonthParameters(0); 229 250 230 251 // Načti poslední měsíční přehled a nastavení 231 $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY DateDESC LIMIT 1');252 $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY `Date` DESC LIMIT 1'); 232 253 $Overall = $DbResult->fetch_array(); 233 254 234 $Output -= 'Datum: '.date('j.n.Y').'<br />';255 $Output .= 'Datum: '.date('j.n.Y').'<br />'; 235 256 236 257 $DateParts = explode('-', $Overall['Date']); … … 240 261 $Output .= $Finance->RecalculateMemberPayment(); 241 262 242 $DbResult = $this->Database->query('SELECT SUM(NetworkDevice) FROM MemberPayment'); 243 $Row = $DbResult->fetch_row(); 244 $TotalMemberDeviceCost = $Row[0]; 245 $Output .= '), Členové('.$TotalMemberDeviceCost.')<br />'; 246 247 $DbResult = $this->Database->query('SELECT SUM(Cash) FROM MemberPayment'); 263 $DbResult = $this->Database->query('SELECT SUM(`Cash`) FROM `MemberPayment`'); 248 264 $Row = $DbResult->fetch_row(); 249 265 $TotalMemberCash = $Row[0]; 250 266 $Output .= 'Stav pokladny: Členové('.$TotalMemberCash.')'; 251 267 252 $DbResult = $this->Database->query('SELECT SUM(Product.Consumption) AS Consumption FROM StockSerialNumber '. 253 'JOIN Product ON StockSerialNumber.Product = Product.Id WHERE (StockSerialNumber.TimeElimination IS NULL) '. 254 'AND (StockSerialNumber.Segment IS NOT NULL)'); 268 $DbResult = $this->Database->query('SELECT SUM(`Product`.`Consumption`) AS `Consumption` FROM `StockSerialNumber` '. 269 'JOIN `Product` ON `StockSerialNumber`.`Product` = `Product`.`Id` WHERE (`StockSerialNumber`.`TimeElimination` IS NULL) '); 255 270 $Row = $DbResult->fetch_row(); 256 271 $TotalConsumption = $Row[0]; … … 266 281 $Output .= 'Odečítám měsíční poplatek...<br />'; 267 282 $Output .= $this->ProduceInvoices(); 268 269 // Update finance charge 270 $Output .= 'Měním aktuální parametry sítě...<br>'; 271 $this->TableUpdatePeriod('FinanceCharge'); 272 283 273 284 $Output .= 'Přidávám měsíční přehled...<br />'; 274 $DbResult = $this->Database->query('SELECT * FROM FinanceCharge WHERE Action IS NULLLIMIT 1');285 $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE (`ChangeAction` IS NULL) LIMIT 1'); 275 286 $Charge = $DbResult->fetch_assoc(); 276 287 $this->Database->insert('FinanceMonthlyOverall', array('Date' => 'NOW()', … … 281 292 'TopTariffPrice' => $Charge['TopTariffPrice'], 'MemberCount' => $Finance->InternetUsers)); 282 293 283 // Update services284 $Output .= 'Aktualizuji služby....<br>';285 $this->TableUpdatePeriod('Service');286 287 // Update customer service selections288 $Output .= 'Aktualizuji výběr služeb zákazníků....<br>';289 $this->TableUpdatePeriod('ServiceCustomerRel');290 291 294 $Finance->RecalculateMemberPayment(); 292 295 //CreateMonthlyOverallBill(); … … 335 338 $DbResult = $this->Database->query('SELECT GROUP_CONCAT(Service.Name) AS Name FROM ServiceCustomerRel LEFT JOIN Service '. 336 339 'ON Service.Id=ServiceCustomerRel.Service WHERE (ServiceCustomerRel.Customer='.$Member['Id'].') '. 337 'AND ServiceCustomerRel. Action IS NULL');340 'AND ServiceCustomerRel.ChangeAction IS NULL'); 338 341 $Service = $DbResult->fetch_assoc(); 339 342 $Content .= '<strong>'.$Service['Name'].'</strong><br />'."\n". -
trunk/Modules/Finance/UserState.php
r724 r726 9 9 function ShowFinanceOperation($Subject) 10 10 { 11 $UserOperationTableQuery = '((SELECT Text, Time, (Value*Direction) AS Value, File, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo'.12 'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.13 '(SELECT (SELECT GROUP_CONCAT( Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.14 ' Time, -(Value*Direction) as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')))';11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 12 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 13 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 14 '`Time`, -(`Value`*`Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')))'; 15 15 16 16 $Output = '<div style="text-align:center">Výpis finančních operací</div>'; 17 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS T1');17 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS `T1`'); 18 18 $DbRow = $DbResult->fetch_row(); 19 19 $PageList = GetPageList($DbRow[0]); … … 33 33 $Output .= $Order['Output']; 34 34 35 $StateQuery = 'SELECT SUM( T2.Value) FROM '.$UserOperationTableQuery.36 ' AS T2 WHERE T2.Time <= T1.Time';37 $Query = 'SELECT *, ('.$StateQuery.') AS State FROM '.$UserOperationTableQuery.' AS T1'.$Order['SQL'].$PageList['SQLLimit'];35 $StateQuery = 'SELECT SUM(`T2`.`Value`) FROM '.$UserOperationTableQuery. 36 ' AS `T2` WHERE `T2`.`Time` <= `T1`.`Time` '; 37 $Query = 'SELECT *, ('.$StateQuery.') AS `State` FROM '.$UserOperationTableQuery.' AS `T1` '.$Order['SQL'].$PageList['SQLLimit']; 38 38 39 39 $DbResult = $this->Database->query($Query); … … 78 78 if(!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění'); 79 79 $UserId = $this->System->User->User['Id']; 80 $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$UserId.' LIMIT 1');80 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 81 81 if($DbResult->num_rows > 0) 82 82 { … … 87 87 88 88 // Load customer info 89 $DbResult = $this->Database->query('SELECT * FROM Member WHERE Id='.$CustomerId);89 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 90 90 if($DbResult->num_rows == 1) 91 91 { … … 95 95 96 96 // Load subject info 97 $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$Customer['Subject']);97 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 98 98 if($DbResult->num_rows == 1) 99 99 { … … 105 105 106 106 // Account state 107 $UserOperationTableQuery = '((SELECT Text, Time, (Value*Direction) AS Value, File, BillCode, NULL AS PeriodFrom, NULL AS PeriodTo'.108 'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.109 '(SELECT (SELECT GROUP_CONCAT( Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.110 ' Time, -(Value*Direction) as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';111 $DbResult = $this->Database->query('SELECT SUM( T1.Value) AS TotalFROM '.$UserOperationTableQuery);107 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 108 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 109 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 110 '`Time`, -(`Value`*`Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')) ORDER BY `Time` DESC) AS `T1`'; 111 $DbResult = $this->Database->query('SELECT SUM(`T1`.`Value`) AS `Total` FROM '.$UserOperationTableQuery); 112 112 $DbRow = $DbResult->fetch_array(); 113 113 $Total = $DbRow['Total']; … … 133 133 $Output .= 'Rozpis měsíčního poplatku:<br><table class="WideTable">'. 134 134 '<tr><th>Služba</th><th>Cena [Kč]</th></tr>'; 135 $DbResult = $this->Database->query('SELECT Service.Name, Service.Price FROM ServiceCustomerRel'.136 'LEFT JOIN Service ON Service.Id=ServiceCustomerRel.Service'.137 'WHERE ( ServiceCustomerRel.Customer='.$Customer['Id'].') AND (ServiceCustomerRel.ActionIS NULL)');135 $DbResult = $this->Database->query('SELECT `Service`.`Name`, `Service`.`Price` FROM `ServiceCustomerRel` '. 136 'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '. 137 'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)'); 138 138 while($DbRow = $DbResult->fetch_assoc()) 139 139 { -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r724 r726 50 50 $InetInterface = $Config['MainRouter']['InetInterface']; 51 51 52 $DbResult = $System->Database->select('Service', '*', '(` ReplaceId` IS NULL) AND (`Id`='.TARIFF_FREE.')');52 $DbResult = $System->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')'); 53 53 if($DbResult->num_rows == 1) 54 54 { … … 79 79 $DbResult4 = $System->Database->query('SELECT `Service`.*, `ServiceCustomerRel`.`Id` AS `RelId` FROM `ServiceCustomerRel` '. 80 80 'JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` '. 81 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.` Action` IS NULL) '.81 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '. 82 82 'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)'); 83 83 while($Service = $DbResult4->fetch_assoc())
Note:
See TracChangeset
for help on using the changeset viewer.