central server smslog report dashboard
Showing
1 changed file
with
236 additions
and
0 deletions
| 1 | <?php | ||
| 2 | use App\Models\CRMCallArchive; | ||
| 3 | use App\Models\CRMCall; | ||
| 4 | use App\Models\User; | ||
| 5 | use App\Jobs\KHRMSLib; | ||
| 6 | |||
| 7 | $wakka = new KHRMSLib(); | ||
| 8 | $dashboarduser=Auth::user(); | ||
| 9 | $userdialmode=$dashboarduser->dialmode_assign; | ||
| 10 | $userdialmode=explode(",",$userdialmode); | ||
| 11 | $timeoffset=$dashboarduser->timezone*60; | ||
| 12 | |||
| 13 | $locationserverip=DB::select(DB::raw("SELECT location from server_details group by location")); | ||
| 14 | |||
| 15 | if(isset($_GET['logdate']))$logdate=strtotime($_GET['logdate']." 00:00:00"); | ||
| 16 | else $logdate=strtotime(date('Y-m-d')." 00:00:00"); | ||
| 17 | |||
| 18 | $location =(isset($_GET['location'])) ? $_GET['location'] : "Select Location"; | ||
| 19 | $i=1; | ||
| 20 | $locations=explode(",",$location); | ||
| 21 | //print_r($locations); | ||
| 22 | foreach ($locations as $location) { | ||
| 23 | $serverid=DB::select(DB::raw("SELECT server_ip,id,location from server_details where location='$location' ORDER BY id ASC")); | ||
| 24 | |||
| 25 | //echo "All"; | ||
| 26 | //print_r($serverid); | ||
| 27 | |||
| 28 | //$serverip->get(); | ||
| 29 | foreach ($serverid as $server_id) { | ||
| 30 | //$serverids=$server_id->id<10?"0".$server_id->id:$server_id->id; | ||
| 31 | $serverids=$server_id->id; | ||
| 32 | //print_r($server_id->server_ip); | ||
| 33 | |||
| 34 | $alist=DB::select(DB::raw("SELECT * from sms_report where created_at>='".date("Y-m-d H:i:s",$logdate+$timeoffset)."' and created_at <= '".date("Y-m-d H:i:s",$logdate+24*60*60)."' and server=$serverids ORDER BY id DESC ")); | ||
| 35 | |||
| 36 | //print_r($alist); | ||
| 37 | foreach ($alist as $aline) { | ||
| 38 | $outstr.="<tr><td>".$i."</td> | ||
| 39 | <td>".$server_id->server_ip."</td> | ||
| 40 | <td>".$server_id->location."</td> | ||
| 41 | <td>".$aline->message_time."</td> | ||
| 42 | <td>".$aline->agent_name."</td> | ||
| 43 | <td>".$aline->subdispo."</td> | ||
| 44 | <td>".$aline->number."</td> | ||
| 45 | <td>".$aline->message."</td> | ||
| 46 | <td>".$aline->response."</td> | ||
| 47 | </tr>"; | ||
| 48 | $i++; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | if(Input::has("dllogxls")) | ||
| 54 | { | ||
| 55 | include_once(app_path().'/lib/phpexcel/PHPExcel.php'); | ||
| 56 | |||
| 57 | $inputFileType = "Excel5"; | ||
| 58 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); | ||
| 59 | $objPHPExcel = $objReader->load("assets/extras/blank.xls"); | ||
| 60 | $baseRow = 3; | ||
| 61 | |||
| 62 | $tcol=0;$fieldsarr=array();$extrahdrarr=array(); | ||
| 63 | $fieldsarr[$tcol++]='#'; | ||
| 64 | $fieldsarr[$tcol++]='server_ip'; | ||
| 65 | $fieldsarr[$tcol++]='location'; | ||
| 66 | $fieldsarr[$tcol++]='message_time'; | ||
| 67 | $fieldsarr[$tcol++]='agent_name'; | ||
| 68 | $fieldsarr[$tcol++]='SubDispo'; | ||
| 69 | $fieldsarr[$tcol++]='Number'; | ||
| 70 | $fieldsarr[$tcol++]='Message'; | ||
| 71 | $fieldsarr[$tcol++]='response'; | ||
| 72 | |||
| 73 | $highestColumn = sizeof($fieldsarr); | ||
| 74 | for ($head = 0; $head < $highestColumn; $head++){ | ||
| 75 | $colstr=PHPExcel_Cell::stringFromColumnIndex($head); | ||
| 76 | $objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $fieldsarr[$head]); | ||
| 77 | } | ||
| 78 | |||
| 79 | $ii=1; | ||
| 80 | foreach($alist as $aline) | ||
| 81 | { | ||
| 82 | $row = $baseRow++; | ||
| 83 | $col = 0; | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($ii++); | ||
| 88 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($server_id->server_ip); | ||
| 89 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($server_id->location); | ||
| 90 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->message_time); | ||
| 91 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->agent_name); | ||
| 92 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->subdispo); | ||
| 93 | |||
| 94 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->number); | ||
| 95 | |||
| 96 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->message); | ||
| 97 | $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col++,$row)->setValueExplicit($aline->response); | ||
| 98 | |||
| 99 | |||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | header('Content-Type: application/vnd.ms-excel'); | ||
| 105 | header('Content-Disposition: attachment;filename="CallLog.xls"'); | ||
| 106 | header('Cache-Control: max-age=0'); | ||
| 107 | |||
| 108 | $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType); | ||
| 109 | $objWriter->save('php://output'); | ||
| 110 | |||
| 111 | return ; | ||
| 112 | } | ||
| 113 | |||
| 114 | ?> | ||
| 115 | |||
| 116 | <div class=innerAll> | ||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | <style>#logtable.td{vertical-align:top;}#logtable.tr{height:28px;overflow-y:hidden;}</style> | ||
| 122 | <script> | ||
| 123 | function showExtraPost(varstr) | ||
| 124 | { | ||
| 125 | doAjax("hr?action=LiveUsers","getpostdata="+varstr,"dialoglog"); | ||
| 126 | |||
| 127 | $('#dialoglog').dialog('open'); | ||
| 128 | return false; | ||
| 129 | } | ||
| 130 | |||
| 131 | $(document).ready(function() | ||
| 132 | { | ||
| 133 | if(!$('#dialoglog').hasClass('ui-dialog-content')) | ||
| 134 | { | ||
| 135 | $('#dialoglog').dialog({ | ||
| 136 | autoOpen: false, | ||
| 137 | width: '70%', | ||
| 138 | buttons: { | ||
| 139 | "Ok": function() { | ||
| 140 | $(this).dialog("close"); | ||
| 141 | }, | ||
| 142 | "Cancel": function() { | ||
| 143 | $(this).dialog("close"); | ||
| 144 | } | ||
| 145 | } | ||
| 146 | }); | ||
| 147 | } | ||
| 148 | |||
| 149 | waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logtable') },"2000"); | ||
| 150 | $('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'}); | ||
| 151 | }); | ||
| 152 | </script> | ||
| 153 | <div> | ||
| 154 | |||
| 155 | |||
| 156 | Date : <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' /> | ||
| 157 | |||
| 158 | Location:<select id="location" style="border:1px solid #efefef;"> | ||
| 159 | <option value='Select Location' disabled selected>Select Location</option> | ||
| 160 | <option value='All'>All</option> | ||
| 161 | <?php foreach($locationserverip as $c){$s="";if($c->location==$location)$s='selected';echo "<option value='$c->location' $s>$c->location</option>";} ?> | ||
| 162 | </select> | ||
| 163 | |||
| 164 | <button id="load" onclick='callLogReloadFun("");return false;' value='Submit'>Submit</button> | ||
| 165 | |||
| 166 | </div> | ||
| 167 | <div style="float:right;width:30%"> | ||
| 168 | |||
| 169 | |||
| 170 | <button class="pull-right btn btn-sm btn-default" onclick='dlCalllogXls();return false;' title='Download' style='margin-top:-8px'><i class='fa fa-download'></i> Download</button> | ||
| 171 | |||
| 172 | </div> | ||
| 173 | |||
| 174 | <script> | ||
| 175 | function dataString() | ||
| 176 | { | ||
| 177 | return 'logdate='+$("#modfrom").val()+'&location='+$("#location").val(); | ||
| 178 | } | ||
| 179 | |||
| 180 | function callLogReloadFun(sortby) | ||
| 181 | { | ||
| 182 | var sortstr='';if(sortby!="")sortstr="&sort="+sortby | ||
| 183 | var searchStr = dataString(); | ||
| 184 | doAjax('dialer/smslog?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET'); | ||
| 185 | } | ||
| 186 | function dlCalllogXls() | ||
| 187 | { | ||
| 188 | var searchStr = dataString(); | ||
| 189 | window.open('dialer/smslog?dllogxls=1&'+searchStr); | ||
| 190 | return false; | ||
| 191 | |||
| 192 | } | ||
| 193 | |||
| 194 | </script> | ||
| 195 | |||
| 196 | <div style='clear:both'></div> | ||
| 197 | |||
| 198 | <div style='overflow:auto'> | ||
| 199 | <table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px'> | ||
| 200 | <thead> | ||
| 201 | <tr> | ||
| 202 | <th>#</th> | ||
| 203 | <th>ServerIp</th> | ||
| 204 | <th>Location</th> | ||
| 205 | <th>Message Time</th> | ||
| 206 | <th>RM Name</th> | ||
| 207 | |||
| 208 | <th>SubDispo</th> | ||
| 209 | <th style='width:120px'>Number</th> | ||
| 210 | <th>Message</th> | ||
| 211 | <th>Response</th> | ||
| 212 | |||
| 213 | |||
| 214 | </tr> | ||
| 215 | </thead> | ||
| 216 | <?php echo $outstr; ?> | ||
| 217 | </table> | ||
| 218 | </div> | ||
| 219 | <?php | ||
| 220 | function convert($size) | ||
| 221 | { | ||
| 222 | $unit=array('b','kb','mb','gb','tb','pb'); | ||
| 223 | return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; | ||
| 224 | } | ||
| 225 | |||
| 226 | echo "<br>".convert(memory_get_peak_usage(true)); // 123 kb | ||
| 227 | |||
| 228 | |||
| 229 | ?> | ||
| 230 | <div id=dialoglog></div> | ||
| 231 | |||
| 232 | |||
| 233 | |||
| 234 | |||
| 235 | |||
| 236 | </div> |
-
Please register or sign in to post a comment