|
@@ -157,6 +157,112 @@ function USERS2_WINDYKACJA_STATUS() {
|
|
|
}
|
|
}
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
|
|
+ else if ($task == 'send_mass_mail'
|
|
|
|
|
+ || $task == 'send_mass_sms'
|
|
|
|
|
+ ) {
|
|
|
|
|
+ $usersLimit = 10000;
|
|
|
|
|
+ $msgType = '';
|
|
|
|
|
+ if ($task == 'send_mass_mail') {
|
|
|
|
|
+ $msgType = 'mail';
|
|
|
|
|
+ } else if ($task == 'send_mass_sms') {
|
|
|
|
|
+ $msgType = 'sms';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ echo "Błędny rodzaj wiadomości";
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ $filter_selected = WindykacjaStatsHelper::get_filter_selected();
|
|
|
|
|
+ if (empty($filter_selected)) {
|
|
|
|
|
+ echo "Nie wybrano filtra";
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $_GET['_special_filter_active'] = 'today';
|
|
|
|
|
+ $_GET["_special_filter_msg_{$msgType}"] = 'not_today';
|
|
|
|
|
+ $usersTotal = WindykacjaStatsModel::get_users_total();
|
|
|
|
|
+
|
|
|
|
|
+ if ($usersTotal > 0) {
|
|
|
|
|
+ $firstUser = WindykacjaStatsModel::get_users('', 1, 0);
|
|
|
|
|
+ $firstUser = reset($firstUser);
|
|
|
|
|
+ //echo'<pre>';print_r($firstUser);echo'</pre>';
|
|
|
|
|
+ if ('mail' == $msgType) {
|
|
|
|
|
+ $msgStatusList = WindykacjaStatsHelper::get_mail_status_info($firstUser);
|
|
|
|
|
+ } else if ('sms' == $msgType) {
|
|
|
|
|
+ $msgStatusList = WindykacjaStatsHelper::get_sms_status_info($firstUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ $msgStatusFirstKey = reset(array_keys($msgStatusList));
|
|
|
|
|
+ $msgStatusInfo = $msgStatusList[$msgStatusFirstKey];
|
|
|
|
|
+ //echo'<pre>$msgStatusInfo:';print_r($msgStatusInfo);echo'</pre>';
|
|
|
|
|
+
|
|
|
|
|
+ $selectedMsgStatus = V::get('msgStatus', '', $_REQUEST);
|
|
|
|
|
+ //echo'<pre>$selectedMsgStatus:';print_r($selectedMsgStatus);echo'</pre>';
|
|
|
|
|
+ if ('1' != V::get('confirm', '', $_POST) || empty($selectedMsgStatus)) {
|
|
|
|
|
+ WindykacjaView::css();
|
|
|
|
|
+ $fltrLabel = WindykacjaStatsHelper::get_filter_selected_label();
|
|
|
|
|
+ ?>
|
|
|
|
|
+<style type="text/css">
|
|
|
|
|
+body{font-size:14px;line-height:1.4;}
|
|
|
|
|
+</style>
|
|
|
|
|
+<div class="jumbotron">
|
|
|
|
|
+ <div class="container">
|
|
|
|
|
+ <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">
|
|
|
|
|
+ <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>
|
|
|
|
|
+ <button type="submit" id="sendMassMsgsBtn" class="btn btn-primary" autocomplete="off">
|
|
|
|
|
+ Wyślij
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</div>
|
|
|
|
|
+<script type="text/javascript">
|
|
|
|
|
+jQuery(document).ready(function () {
|
|
|
|
|
+ jQuery('#sendMassMsgsBtn').on('click', function () {
|
|
|
|
|
+ jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
|
|
|
|
|
+ jQuery(this).parent().submit();
|
|
|
|
|
+ })
|
|
|
|
|
+});
|
|
|
|
|
+</script>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $users = WindykacjaStatsModel::get_users('', $usersLimit, 0);
|
|
|
|
|
+ foreach ($users as $user) {
|
|
|
|
|
+ if ('mail' == $msgType) {
|
|
|
|
|
+ $msgStatusList = WindykacjaStatsHelper::get_mail_status_info($user);
|
|
|
|
|
+ } else if ('sms' == $msgType) {
|
|
|
|
|
+ $msgStatusList = WindykacjaStatsHelper::get_sms_status_info($user);
|
|
|
|
|
+ }
|
|
|
|
|
+ $msgStatusFirstKey = reset(array_keys($msgStatusList));
|
|
|
|
|
+ $msgStatusInfo = $msgStatusList[$msgStatusFirstKey];
|
|
|
|
|
+
|
|
|
|
|
+ if ('mail' == $msgType) {
|
|
|
|
|
+ $ret = WindykacjaStatsHelper::update_mail_status($user, $msgStatusFirstKey);
|
|
|
|
|
+ } else if ('sms' == $msgType) {
|
|
|
|
|
+ $ret = WindykacjaStatsHelper::update_sms_status($user, $msgStatusFirstKey);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($ret) {
|
|
|
|
|
+ echo '<div class="alert alert-success">';
|
|
|
|
|
+ echo "wysłano wiadomość do klienta {$user->ID}";
|
|
|
|
|
+ echo '</div>';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ echo '<div class="alert alert-danger">';
|
|
|
|
|
+ echo "nie udało się wysłać wiadomości do klienta {$user->ID}";
|
|
|
|
|
+ echo '</div>';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ echo'<p>' . "Brak danych" . '</p>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
WindykacjaView::css();
|
|
WindykacjaView::css();
|
|
@@ -1085,7 +1191,18 @@ function frm_kontakt_add_id_koresp(frm){
|
|
|
$out_link_arr['task'] = 'export_csv';
|
|
$out_link_arr['task'] = 'export_csv';
|
|
|
$out_link = V::make_link('', $out_link_arr);
|
|
$out_link = V::make_link('', $out_link_arr);
|
|
|
$page_nav_out .= ' <a style="margin:0 0 0 20px;" href="' . $out_link . '" target="_blank">export csv</a>';
|
|
$page_nav_out .= ' <a style="margin:0 0 0 20px;" href="' . $out_link . '" target="_blank">export csv</a>';
|
|
|
|
|
+
|
|
|
|
|
+ $out_link_arr = V::copy($page_nav->base_link_arr);
|
|
|
|
|
+ $out_link_arr['task'] = 'send_mass_mail';
|
|
|
|
|
+ $out_link = V::make_link('', $out_link_arr);
|
|
|
|
|
+ $page_nav_out .= ' <a style="margin:0 0 0 20px;" href="' . $out_link . '" target="_blank">send mail</a>';
|
|
|
|
|
+
|
|
|
|
|
+ $out_link_arr = V::copy($page_nav->base_link_arr);
|
|
|
|
|
+ $out_link_arr['task'] = 'send_mass_sms';
|
|
|
|
|
+ $out_link = V::make_link('', $out_link_arr);
|
|
|
|
|
+ $page_nav_out .= ' <a style="margin:0 0 0 20px;" href="' . $out_link . '" target="_blank">send sms</a>';
|
|
|
$page_nav_out .= '</div>';
|
|
$page_nav_out .= '</div>';
|
|
|
|
|
+
|
|
|
if (empty($items)) {
|
|
if (empty($items)) {
|
|
|
echo'<p style="color:red">'."Brak danych".'</p>';
|
|
echo'<p style="color:red">'."Brak danych".'</p>';
|
|
|
return;
|
|
return;
|
|
@@ -1316,7 +1433,7 @@ function frm_kontakt_add_id_koresp(frm){
|
|
|
|
|
|
|
|
public static function css() {
|
|
public static function css() {
|
|
|
echo'<style type="text/css">'."
|
|
echo'<style type="text/css">'."
|
|
|
-body{font-family:arial;}
|
|
|
|
|
|
|
+body{font-family:arial;line-height:1.4;}
|
|
|
.box{border:1px solid #999;padding:5px;margin:5px;}
|
|
.box{border:1px solid #999;padding:5px;margin:5px;}
|
|
|
.box-center{border:1px solid #999;padding:5px;margin:5px auto;}
|
|
.box-center{border:1px solid #999;padding:5px;margin:5px auto;}
|
|
|
.box-silver{border-color:#999;}
|
|
.box-silver{border-color:#999;}
|
|
@@ -3104,6 +3221,17 @@ class WindykacjaStatsHelper {
|
|
|
return $filter_selected;
|
|
return $filter_selected;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static function get_filter_selected_label() {
|
|
|
|
|
+ $fltrLabel = '';
|
|
|
|
|
+ $fltrSelected = self::get_filter_selected();
|
|
|
|
|
+ if (!empty($fltrSelected)) {
|
|
|
|
|
+ $fltrs = self::get_filters();
|
|
|
|
|
+ $fltrLabel = V::get($fltrSelected, '', $fltrs);
|
|
|
|
|
+ $fltrLabel = V::get(0, '', $fltrLabel);
|
|
|
|
|
+ }
|
|
|
|
|
+ return $fltrLabel;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static function get_filters() {
|
|
public static function get_filters() {
|
|
|
$filter_arr['stan_zero'] = array("stan zerowy");
|
|
$filter_arr['stan_zero'] = array("stan zerowy");
|
|
|
$filter_arr['10-ego'] = array("termin płatności faktur, saldo na -", 'desc'=>array("10-ego", "10-ego każdego miesiąca - termin płatnosci faktur oraz saldo na minusie"));
|
|
$filter_arr['10-ego'] = array("termin płatności faktur, saldo na -", 'desc'=>array("10-ego", "10-ego każdego miesiąca - termin płatnosci faktur oraz saldo na minusie"));
|
|
@@ -3487,6 +3615,7 @@ SQL;
|
|
|
$sql = "insert into `HIST_CONTACTS` (" . implode(",", array_keys($sqlArr)) . ")
|
|
$sql = "insert into `HIST_CONTACTS` (" . implode(",", array_keys($sqlArr)) . ")
|
|
|
values (" . implode(",", array_values($sqlArr)) . ");";
|
|
values (" . implode(",", array_values($sqlArr)) . ");";
|
|
|
//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">sql ';print_r($sql);echo'</pre>';
|
|
//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">sql ';print_r($sql);echo'</pre>';
|
|
|
|
|
+ //echo'TODO: TEST...';return true;
|
|
|
$db_webone->query($sql);
|
|
$db_webone->query($sql);
|
|
|
$msgId = $db_webone->insert_id();
|
|
$msgId = $db_webone->insert_id();
|
|
|
//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">$msgId ';print_r($msgId);echo'</pre>';
|
|
//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">$msgId ';print_r($msgId);echo'</pre>';
|
|
@@ -3547,6 +3676,7 @@ SQL;
|
|
|
$sql = "insert into `HIST_CONTACTS` (" . implode(",", array_keys($sqlArr)) . ")
|
|
$sql = "insert into `HIST_CONTACTS` (" . implode(",", array_keys($sqlArr)) . ")
|
|
|
values (" . implode(",", array_values($sqlArr)) . ");";
|
|
values (" . implode(",", array_values($sqlArr)) . ");";
|
|
|
//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">sql ';print_r($sql);echo'</pre>';
|
|
//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">sql ';print_r($sql);echo'</pre>';
|
|
|
|
|
+ //echo'TODO: TEST...';return true;
|
|
|
$db_webone->query($sql);
|
|
$db_webone->query($sql);
|
|
|
$msgId = $db_webone->insert_id();
|
|
$msgId = $db_webone->insert_id();
|
|
|
echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">$msgId ';print_r($msgId);echo'</pre>';
|
|
echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">$msgId ';print_r($msgId);echo'</pre>';
|
|
@@ -4235,6 +4365,21 @@ class WindykacjaStatsModel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ $special_filter_active = V::get('_special_filter_active', '', $_GET);
|
|
|
|
|
+ if ('today' == $special_filter_active) {
|
|
|
|
|
+ $today = date("Y-m-d");
|
|
|
|
|
+ $sql_where_and_arr[] = "w.`A_STATUS_UPDATE_DATE`='{$today}'";
|
|
|
|
|
+ }
|
|
|
|
|
+ $special_filter_msg_mail = V::get('_special_filter_msg_mail', '', $_GET);
|
|
|
|
|
+ if ('not_today' == $special_filter_msg_mail) {
|
|
|
|
|
+ $sql_where_and_arr[] = "w.`LAST_PHONE_STATUS_DATE`<'{$today}'";
|
|
|
|
|
+ }
|
|
|
|
|
+ $special_filter_msg_sms = V::get('_special_filter_msg_sms', '', $_GET);
|
|
|
|
|
+ if ('not_today' == $special_filter_msg_sms) {
|
|
|
|
|
+ $sql_where_and_arr[] = "w.`LAST_PHONE_STATUS_DATE`<'{$today}'";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!empty($sql_where_and_arr)) {
|
|
if (!empty($sql_where_and_arr)) {
|
|
|
$sql_where = implode(" and ", $sql_where_and_arr);
|
|
$sql_where = implode(" and ", $sql_where_and_arr);
|
|
|
} else {
|
|
} else {
|
|
@@ -4268,6 +4413,7 @@ class WindykacjaStatsModel {
|
|
|
left join `BILLING_USERS_ADD` as a on(a.`id_users`=w.`ID_BILLING_USERS`)
|
|
left join `BILLING_USERS_ADD` as a on(a.`id_users`=w.`ID_BILLING_USERS`)
|
|
|
where {$sql_where}
|
|
where {$sql_where}
|
|
|
";
|
|
";
|
|
|
|
|
+ //echo'<pre>sqlTotal:';print_r($sql);echo'</pre>';
|
|
|
$res = $db->query($sql);
|
|
$res = $db->query($sql);
|
|
|
if ($r = $db->fetch($res)) {
|
|
if ($r = $db->fetch($res)) {
|
|
|
$total = $r->cnt;
|
|
$total = $r->cnt;
|
|
@@ -4322,7 +4468,7 @@ class WindykacjaStatsModel {
|
|
|
return $sql_select;
|
|
return $sql_select;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function &get_users($q = '', $limit = 10, $limit_start = 0, $order_by = '', $order_dir = '') {
|
|
|
|
|
|
|
+ public static function get_users($q = '', $limit = 10, $limit_start = 0, $order_by = '', $order_dir = '') {
|
|
|
$ret = array();
|
|
$ret = array();
|
|
|
|
|
|
|
|
$sql_select = self::get_sql_users_select();
|
|
$sql_select = self::get_sql_users_select();
|
|
@@ -4355,6 +4501,7 @@ class WindykacjaStatsModel {
|
|
|
{$sql_order_by}
|
|
{$sql_order_by}
|
|
|
{$sql_limit}
|
|
{$sql_limit}
|
|
|
";
|
|
";
|
|
|
|
|
+ //echo'<pre>';print_r($sql);echo'</pre>';
|
|
|
$res = $db->query($sql);
|
|
$res = $db->query($sql);
|
|
|
while ($r = $db->fetch($res)) {
|
|
while ($r = $db->fetch($res)) {
|
|
|
$ret[$r->id_users] = $r;
|
|
$ret[$r->id_users] = $r;
|