Skip to content

Commit

Permalink
0.5.3 rev 3440
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Apr 9, 2014
1 parent 90c1df2 commit 5e16211
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.3 rev 3438
0.5.3 rev 3440
25 changes: 23 additions & 2 deletions api/libs/api.ukv.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,22 @@ protected function userLifeStoryForm($userid) {
$result = wf_TableBody($rows, '100%', '0', 'sortable');
return ($result);
}

/*
* checks is user contract unique
*
* @param $contract - contract number to check
*
* @return bool
*/
protected function checkContract($contract) {
if (isset($this->contracts[$contract])) {
$result=false;
} else {
$result=true;
}
return ($result);
}

/*
* saves some user params into database
Expand Down Expand Up @@ -859,8 +875,13 @@ public function userSave() {
//saving contract
if ($this->users[$userId]['contract'] != $_POST['ueditcontract']) {
$newContract = trim($_POST['ueditcontract']);
simple_update_field($tablename, 'contract', $newContract, $where);
log_register('UKV USER ((' . $userId . ')) CHANGE CONTRACT `' . $newContract . '`');
if ($this->checkContract($newContract)) {
simple_update_field($tablename, 'contract', $newContract, $where);
log_register('UKV USER ((' . $userId . ')) CHANGE CONTRACT `' . $newContract . '`');
} else {
log_register('UKV USER ((' . $userId . ')) CHANGE FAIL CONTRACT `' . $newContract . '` DUPLICATE');
}

}

//saving tariff
Expand Down
2 changes: 2 additions & 0 deletions api/libs/api.userdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,5 +485,7 @@ function zb_TariffGetPricesAll() {

return ($result);
}



?>
30 changes: 29 additions & 1 deletion api/libs/api.workaround.php
Original file line number Diff line number Diff line change
Expand Up @@ -3677,4 +3677,32 @@ function web_SnmpSwitchControlForm($login,$allswitches,$allportassigndata,$sugge
rcms_redirect('?module=switchpoller&switchid='.$suggestswitchid);
}
return ($result);
}
}


function zb_TariffGetPeriodsAll() {
$result=array();
$dbSchema= zb_CheckDbSchema();
if ($dbSchema>0) {
//stargazer >= 2.409
$query="SELECT `name`,`period` from `tariffs`";
$all=simple_queryall($query);
if (!empty($all)) {
foreach ($all as $io=>$eachtariff) {
$result[$eachtariff['name']]=$eachtariff['period'];
}
}
} else {
//stargazer 2.408
$query="SELECT `name` from `tariffs`";
$all=simple_queryall($query);
if (!empty($all)) {
foreach ($all as $io=>$eachtariff) {
$result[$eachtariff['name']]='month';
}
}
}


return ($result);
}
7 changes: 7 additions & 0 deletions languages/russian/billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1647,5 +1647,12 @@
$lang['def']['Switch ping custom script'] = 'Скрипт кастомного пинга свитчей';
$lang['def']['right to delete UKV users'] = 'Право удалять пользователей УКВ';

//rev 3439
$lang['def']['Users who have zero balance'] = 'Пользователи с нулевым балансом';
$lang['def'][''] = '';
$lang['def'][''] = '';
$lang['def'][''] = '';
$lang['def'][''] = '';
$lang['def'][''] = '';

?>
26 changes: 24 additions & 2 deletions modules/general/turbosms/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function tsms_SafeEscapeString($string) {
$td_realnames= zb_UserGetAllRealnames();
$td_realnamestrans= tsms_RealnamesTranslit($td_realnames);
$td_tariffprices= zb_TariffGetPricesAll();
$td_tariffperiods= zb_TariffGetPeriodsAll();

$td_curdate= curdate();
$td_users= tsms_UserGetAllStargazerData();
$td_mobiles= tsms_GetAllMobileNumbers();
Expand Down Expand Up @@ -92,7 +94,7 @@ function tsms_CheckMobile($num) {
}

function tsms_UserFilter($type) {
global $td_mobiles,$td_users,$td_tariffprices;
global $td_mobiles,$td_users,$td_tariffprices,$td_tariffperiods;
$result=array();

//debtors filter
Expand All @@ -117,7 +119,12 @@ function tsms_UserFilter($type) {
if (tsms_CheckMobile($userMobile)) {
$userTariff=$data['Tariff'];
$userTariffPrice=$td_tariffprices[$userTariff];
$dayprice=$userTariffPrice/30;
$userTariffPeriod=$td_tariffperiods[$userTariff];
if ($userTariffPeriod=='month') {
$dayprice=$userTariffPrice/30;
} else {
$dayprice=$userTariffPrice;
}
$fiveDayPrice=$dayprice*5;
if (($data['Cash']<$fiveDayPrice) AND ($data['Cash']>=0)) {
$result[$login]=$userMobile;
Expand All @@ -127,6 +134,20 @@ function tsms_UserFilter($type) {
}
}

//cash == 0
if ($type=='msendzero') {
if (!empty($td_users)) {
foreach ($td_users as $login=>$data) {
@$userMobile=$td_mobiles[$login];
if (tsms_CheckMobile($userMobile)) {
if ($data['Cash']==0) {
$result[$login]=$userMobile;
}
}
}
}
}

//all users with existing mobile phone
if ($type=='msendall') {
if (!empty($td_users)) {
Expand Down Expand Up @@ -188,6 +209,7 @@ function tsms_ExcludeUserDelete($login) {
function web_TsmsMassendForm() {
$inputs= wf_RadioInput('msendtype', __('Debtors with balance less then 0'), 'msenddebtors', true, true);
$inputs.= wf_RadioInput('msendtype', __('Users who have money left for 5 days'), 'msendless5', true, false);
$inputs.= wf_RadioInput('msendtype', __('Users who have zero balance'), 'msendzero', true, false);
$inputs.= wf_RadioInput('msendtype', __('All users with mobile'), 'msendall', true, false);
$inputs.= wf_Submit(__('Search'));
$result= wf_Form("", "POST", $inputs, 'glamour');
Expand Down

0 comments on commit 5e16211

Please sign in to comment.