Просмотр исходного кода

Windykacja: add limit ot send mass sms/mail (closes #94)

Piotr Labudda 11 лет назад
Родитель
Сommit
42af787e66
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      SE/superedit-USERS2_WINDYKACJA_STATUS.php

+ 18 - 1
SE/superedit-USERS2_WINDYKACJA_STATUS.php

@@ -194,6 +194,8 @@ function USERS2_WINDYKACJA_STATUS() {
 				//echo'<pre>$msgStatusInfo:';print_r($msgStatusInfo);echo'</pre>';
 
 				$selectedMsgStatus = V::get('msgStatus', '', $_REQUEST);
+				$saldoLimit = V::get('saldoLimit', '100', $_REQUEST, 'int');
+				if ($saldoLimit <= 0) $saldoLimit = 100;
 				//echo'<pre>$selectedMsgStatus:';print_r($selectedMsgStatus);echo'</pre>';
 				if ('1' != V::get('confirm', '', $_POST) || empty($selectedMsgStatus)) {
 					WindykacjaView::css();
@@ -215,6 +217,11 @@ body{font-size:14px;line-height:1.4;}
 				<div style="margin:0 0 0 100px;"><?php echo $msgStatusInfo['msg']; ?></div>
 			</label>
 			<br>
+			<label for="saldoLimit">
+				Limit:
+			</label>
+			<input name="saldoLimit" type="number" value="<?php echo $saldoLimit; ?>" />
+			<br>
 			<button type="submit" id="sendMassMsgsBtn" class="btn btn-primary" autocomplete="off">
 				Wyślij
 			</button>
@@ -233,6 +240,17 @@ jQuery(document).ready(function () {
 				} else {
 					$users = WindykacjaStatsModel::get_users('', $usersLimit, 0);
 					foreach ($users as $user) {
+						if ($user->PAY_SALDO > -1 * $saldoLimit) {
+							echo '<div class="alert alert-warning">';
+								$zaleglosc = number_format($user->PAY_SALDO, 2, ',', '');
+								echo "pominięto klienta {$user->ID} ze względu na limit płatności (zaległość: {$zaleglosc} zł)";
+							echo '</div>';
+						} else {
+							//echo '<div class="alert alert-info">';
+							//	echo "wysyłanie wiadomości do klienta {$user->ID}...";
+							//echo '</div>';
+						}
+
 						if ('mail' == $msgType) {
 							$msgStatusList = WindykacjaStatsHelper::get_mail_status_info($user);
 						} else if ('sms' == $msgType) {
@@ -240,7 +258,6 @@ jQuery(document).ready(function () {
 						}
 						$msgStatusFirstKey = reset(array_keys($msgStatusList));
 						$msgStatusInfo = $msgStatusList[$msgStatusFirstKey];
-
 						if ('mail' == $msgType) {
 							$ret = WindykacjaStatsHelper::update_mail_status($user, $msgStatusFirstKey);
 						} else if ('sms' == $msgType) {