Przeglądaj źródła

Windykacja: add termin płatności to send mass msg (closes #98)

Piotr Labudda 11 lat temu
rodzic
commit
42847dbe9c
1 zmienionych plików z 68 dodań i 22 usunięć
  1. 68 22
      SE/superedit-USERS2_WINDYKACJA_STATUS.php

+ 68 - 22
SE/superedit-USERS2_WINDYKACJA_STATUS.php

@@ -195,7 +195,9 @@ function USERS2_WINDYKACJA_STATUS() {
 
 				$selectedMsgStatus = V::get('msgStatus', '', $_REQUEST);
 				$saldoLimit = V::get('saldoLimit', '100', $_REQUEST, 'int');
+				$terminPlatnosci = V::get('terminPlatnosci', '', $_REQUEST);
 				if ($saldoLimit <= 0) $saldoLimit = 100;
+				if (strlen($terminPlatnosci) != 10 || $terminPlatnosci < date("Y-m-d")) $terminPlatnosci = '';
 				//echo'<pre>$selectedMsgStatus:';print_r($selectedMsgStatus);echo'</pre>';
 				if ('1' != V::get('confirm', '', $_POST) || empty($selectedMsgStatus)) {
 					WindykacjaView::css();
@@ -209,22 +211,50 @@ body{font-size:14px;line-height:1.4;}
 		<p>Wyślij wiadomości (<?php echo $msgType; ?>) do <b><?php echo $usersTotal; ?></b> użytkowników wg filtra
 			<br><b><?php echo $fltrLabel; ?></b>
 		</p>
-		<form class="form-inline" method="POST">
+		<form class="form-horizontal" method="POST">
 			<input type="hidden" name="confirm" value="1">
-			<label>
-				<input type="radio" name="msgStatus" value="<?php echo $msgStatusFirstKey; ?>">
-				<?php echo $msgStatusInfo['label']; ?>
-				<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>
+			<div class="form-group">
+				<div class="col-sm-offset-2 col-sm-10">
+					<div class="radio">
+						<label>
+							<input type="radio" name="msgStatus" value="<?php echo $msgStatusFirstKey; ?>">
+							<?php echo $msgStatusInfo['label']; ?>
+							<div style="margin:0 0 0 100px;"><?php echo $msgStatusInfo['msg']; ?></div>
+						</label>
+					</div>
+				</div>
+			</div>
+
+			<div class="form-group">
+				<label for="saldoLimit" class="col-sm-2 control-label">Limit:</label>
+				<div class="col-sm-10">
+					<input style="width:100px;" class="form-control" name="saldoLimit" type="number" value="<?php echo $saldoLimit; ?>" />
+				</div>
+			</div>
+
+			<div class="form-group">
+				<label for="terminPlatnosci" class="col-sm-2 control-label">Termin płatności:</label>
+				<div class="col-sm-10">
+					<div class="input-group date" id="fldTerminPlatnosci" style="width:140px;">
+						<input type="text" name="terminPlatnosci" class="form-control" value="<?php echo $terminPlatnosci; ?>" />
+						<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
+					</div>
+				</div>
+			</div>
+
+			<div class="form-group">
+				<div class="col-sm-offset-2 col-sm-10">
+					<label style="text-info"><i>Określenenie terminu zmienia w wiadomości zdanie: "Prosimy o niezwloczne uregulowanie zaleglosci" na "Prosimy o uregulowanie w/w zaleglosci w terminie do {podany termin}."</i></label>
+				</div>
+			</div>
+
+			<div class="form-group">
+				<div class="col-sm-offset-2 col-sm-10">
+					<button type="submit" id="sendMassMsgsBtn" class="btn btn-primary" autocomplete="off">
+						Wyślij
+					</button>
+				</div>
+			</div>
 		</form>
 	</div>
 </div>
@@ -232,8 +262,14 @@ body{font-size:14px;line-height:1.4;}
 jQuery(document).ready(function () {
   jQuery('#sendMassMsgsBtn').on('click', function () {
     jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
-		jQuery(this).parent().submit();
+		jQuery(this).get(0).form.submit();
   })
+	jQuery("#fldTerminPlatnosci").datetimepicker({
+		format: "YYYY-MM-DD",
+		//defaultDate: new Date(<?php echo date("Y"); ?>, <?php echo intval(date("m")) - 1; ?>, 1),
+		minDate: new Date(<?php echo date("Y"); ?>, <?php echo (int)date("m"); ?>, <?php echo (int)date("d"); ?>),
+		// maxDate: "<?php echo date("Y"); ?>"
+	});
 });
 </script>
 					<?php
@@ -252,12 +288,14 @@ jQuery(document).ready(function () {
 						}
 
 						if ('mail' == $msgType) {
-							$msgStatusList = WindykacjaStatsHelper::get_mail_status_info($user);
+							$msgStatusList = WindykacjaStatsHelper::get_mail_status_info($user, $terminPlatnosci);
 						} else if ('sms' == $msgType) {
-							$msgStatusList  = WindykacjaStatsHelper::get_sms_status_info($user);
+							$msgStatusList  = WindykacjaStatsHelper::get_sms_status_info($user, $terminPlatnosci);
 						}
 						$msgStatusFirstKey = reset(array_keys($msgStatusList));
 						$msgStatusInfo = $msgStatusList[$msgStatusFirstKey];
+						//echo'<pre>';print_r($msgStatusInfo);echo'</pre>';
+						//continue;
 						if ('mail' == $msgType) {
 							$ret = WindykacjaStatsHelper::update_mail_status($user, $msgStatusFirstKey);
 						} else if ('sms' == $msgType) {
@@ -3568,14 +3606,18 @@ SQL;
 		return $ret;
 	}
 
-	public static function get_sms_status_info($user) {
+	public static function get_sms_status_info($user, $terminPlatnosci = '') {
 		$ret = array();
 		$today = date("Y-m-d");
 		$due_date = $user->PAY_TERM;// ustalowny pay term
 		$zaleglosc = number_format($user->PAY_SALDO, 2, ',', '');
 		if ($user->PAY_SALDO <= -0.05) {
 			$msg = "Twoje saldo na dzien {$today} wynosi {$zaleglosc} zl.\n";
-			$msg .= "Prosimy o niezwloczne uregulowanie zaleglosci.";
+			if (strlen($terminPlatnosci) == 10 && $terminPlatnosci > date("Y-m-d")) {
+				$msg .= "Prosimy o uregulowanie w/w zaleglosci w terminie do {$terminPlatnosci}.";
+			} else {
+				$msg .= "Prosimy o niezwloczne uregulowanie zaleglosci.";
+			}
 			if ($due_date > $today) {
 			//	$msg .= "Prosimy o uregulowanie zaleglosci do dnia {$due_date} r.";
 			} else {
@@ -3588,14 +3630,18 @@ SQL;
 	/*
 <html><body>Informujemy Pana/Pania o zalegosci w platnosciach w wysokosci 109.16 zl. Prosimy o uregulowanie w/w zaleglosci w terminie do 31.03.2015 r.<br>W przypadku watpliwosci prosimy o kontakt z Biurem Obslugi Klienta. <p>BIALL-NET Sp. z o.o. <br><br>Biuro Obslugi Klienta:<br>tel. 58 741 84 10<br>fax 58 741 84 30</body></html>
 	*/
-	public static function get_mail_status_info($user) {
+	public static function get_mail_status_info($user, $terminPlatnosci = '') {
 		$ret = array();
 		$today = date("Y-m-d");
 		$due_date = $user->PAY_TERM;// ustalowny pay term
 		$zaleglosc = number_format(abs($user->PAY_SALDO), 2, ',', '');
 		if ($user->PAY_SALDO <= -0.05) {
 			$msg = "Informujemy Pana/Pania o zalegosci w platnosciach w wysokosci {$zaleglosc} zl.\n";
-			$msg .= "Prosimy o niezwloczne uregulowanie zaleglosci.";
+			if (strlen($terminPlatnosci) == 10 && $terminPlatnosci > date("Y-m-d")) {
+				$msg .= "Prosimy o uregulowanie w/w zaleglosci w terminie do {$terminPlatnosci}.";
+			} else {
+				$msg .= "Prosimy o niezwloczne uregulowanie zaleglosci.";
+			}
 			$msg .= "<br>W przypadku watpliwosci prosimy o kontakt z Biurem Obslugi Klienta.";
 			$msg .= "<p>BIALL-NET Sp. z o.o.</p>";
 			if ($due_date > $today) {