|
@@ -0,0 +1,129 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+Lib::loadClass('RouteBase');
|
|
|
|
|
+
|
|
|
|
|
+class Route_ZestawieniaVectra extends RouteBase {
|
|
|
|
|
+
|
|
|
|
|
+ public function handleAuth() {
|
|
|
|
|
+ if (!User::logged()) {
|
|
|
|
|
+ throw new HttpException('Unauthorized', 401);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function defaultAction() {
|
|
|
|
|
+ SE_Layout::gora();
|
|
|
|
|
+ SE_Layout::menu();
|
|
|
|
|
+ echo'TODO: Main menu...';
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function sendMassAction() {
|
|
|
|
|
+ $selectedMonth = V::get('zest_month', date("Y-m"), $_REQUEST);
|
|
|
|
|
+
|
|
|
|
|
+ SE_Layout::gora();
|
|
|
|
|
+ //SE_Layout::menu();
|
|
|
|
|
+ $this->_sendMassMenu($selectedMonth);
|
|
|
|
|
+ $this->_showSendMass($selectedMonth);
|
|
|
|
|
+ SE_Layout::dol();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _showSendMass($selectedMonth) {
|
|
|
|
|
+ $zest = array();
|
|
|
|
|
+ if (strlen($selectedMonth) != 7) return;
|
|
|
|
|
+ $db = DB::getDB();
|
|
|
|
|
+ $sql = <<<SQL
|
|
|
|
|
+(
|
|
|
|
|
+ SELECT 'MAIL' as `TYPE`
|
|
|
|
|
+ , h.`A_RECORD_UPDATE_AUTHOR`
|
|
|
|
|
+ , substr(h.`A_RECORD_UPDATE_DATE`, 1, 10) as `_wind_save`
|
|
|
|
|
+ , hc.`STATUS_MAIL` as `STATUS`
|
|
|
|
|
+ , count(*) as cnt
|
|
|
|
|
+ FROM `SES_USERS2`.`USERS2_WINDYKACJA_STATUS_HIST` h
|
|
|
|
|
+ join `SES_USERS2`.`USERS2_WINDYKACJA_STATUS` w on(w.`ID`=h.`ID_USERS2`)
|
|
|
|
|
+ join `billing2013`.`HIST_CONTACTS` hc on(hc.`ID`=(IF(h.`LAST_SMS_MSG_ID` >0, h.`LAST_SMS_MSG_ID`, h.`LAST_MAIL_MSG_ID`)))
|
|
|
|
|
+ WHERE h.`LAST_MAIL_MSG_ID`>0
|
|
|
|
|
+ and h.`A_RECORD_UPDATE_DATE` like '{$selectedMonth}-%'
|
|
|
|
|
+ group by h.`A_RECORD_UPDATE_AUTHOR`, substr(h.`A_RECORD_UPDATE_DATE`, 1, 10), hc.`STATUS_MAIL`
|
|
|
|
|
+)
|
|
|
|
|
+union
|
|
|
|
|
+(
|
|
|
|
|
+ SELECT 'SMS' as `TYPE`
|
|
|
|
|
+ , h.`A_RECORD_UPDATE_AUTHOR`
|
|
|
|
|
+ , substr(h.`A_RECORD_UPDATE_DATE`, 1, 10) as `_wind_save`
|
|
|
|
|
+ , hc.`STATUS_SMS` as `STATUS`
|
|
|
|
|
+ , count(*) as cnt
|
|
|
|
|
+ FROM `SES_USERS2`.`USERS2_WINDYKACJA_STATUS_HIST` h
|
|
|
|
|
+ join `SES_USERS2`.`USERS2_WINDYKACJA_STATUS` w on(w.`ID`=h.`ID_USERS2`)
|
|
|
|
|
+ join `billing2013`.`HIST_CONTACTS` hc on(hc.`ID`=(IF(h.`LAST_SMS_MSG_ID` >0, h.`LAST_SMS_MSG_ID`, h.`LAST_MAIL_MSG_ID`)))
|
|
|
|
|
+ WHERE h.`LAST_SMS_MSG_ID` > 0
|
|
|
|
|
+ and h.`A_RECORD_UPDATE_DATE` like '{$selectedMonth}-%'
|
|
|
|
|
+ group by h.`A_RECORD_UPDATE_AUTHOR`, substr(h.`A_RECORD_UPDATE_DATE`, 1, 10), hc.`STATUS_SMS`
|
|
|
|
|
+)
|
|
|
|
|
+order by `_wind_save` ASC, `TYPE`
|
|
|
|
|
+;
|
|
|
|
|
+SQL;
|
|
|
|
|
+ $res = $db->query($sql);
|
|
|
|
|
+ while ($r = $db->fetch($res)) {
|
|
|
|
|
+ $zest[] = $r;
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+<table class="table table-bordered">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <th>Typ</th>
|
|
|
|
|
+ <th>User</th>
|
|
|
|
|
+ <th>Data</th>
|
|
|
|
|
+ <th>Status</th>
|
|
|
|
|
+ <th>Ilość</th>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ <?php foreach ($zest as $r) : ?>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td><?php echo $r->TYPE; ?></td>
|
|
|
|
|
+ <td><?php echo $r->A_RECORD_UPDATE_AUTHOR; ?></td>
|
|
|
|
|
+ <td><?php echo $r->_wind_save; ?></td>
|
|
|
|
|
+ <td><?php echo $r->STATUS; ?></td>
|
|
|
|
|
+ <td><?php echo $r->cnt; ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+</table>
|
|
|
|
|
+<?php
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _sendMassMenu($selectedMonth) {
|
|
|
|
|
+ $year = ($selectedMonth)? $selectedMonth : date("Y-m");
|
|
|
|
|
+ ?>
|
|
|
|
|
+<div class="jumbotron">
|
|
|
|
|
+ <div class="container">
|
|
|
|
|
+ <form class="form-inline" method="POST">
|
|
|
|
|
+ <input type="hidden" name="task" value="sendMass" />
|
|
|
|
|
+ <label for="zest_month">Zestawienie masowej wysyłki sms/mail:</label>
|
|
|
|
|
+ <div class="input-group date" id="fldZestMonth">
|
|
|
|
|
+ <input type="text" name="zest_month" class="form-control" value="<?php echo $selectedMonth; ?>" />
|
|
|
|
|
+ <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <button type="submit" id="fldZestMonthBtn" class="btn btn-primary" autocomplete="off">
|
|
|
|
|
+ Generuj zestawienie
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</div>
|
|
|
|
|
+<script type="text/javascript">
|
|
|
|
|
+jQuery(document).ready(function () {
|
|
|
|
|
+ jQuery('#fldZestMonthBtn').on('click', function () {
|
|
|
|
|
+ jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
|
|
|
|
|
+ jQuery(this).parent().submit();
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ jQuery("#fldZestMonth").datetimepicker({
|
|
|
|
|
+ format: "YYYY-MM",
|
|
|
|
|
+ defaultDate: new Date(<?php echo date("Y"); ?>, <?php echo intval(date("m")) - 1; ?>, 1),
|
|
|
|
|
+ minDate: new Date(2014, 11, 1),
|
|
|
|
|
+ // maxDate: "<?php echo date("Y"); ?>"
|
|
|
|
|
+ });
|
|
|
|
|
+});
|
|
|
|
|
+</script>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|