Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. $("#applyCalls").click(function(){
  2. $.get("admin/processCalls.php");
  3. });
  4.  
  5. include '../phpexcel2/Classes/PHPExcel.php';
  6. include '../phpexcel2/Classes/PHPExcel/IOFactory.php';
  7. date_default_timezone_set('Europe/Bucharest');
  8.  
  9. $fisierInbound = "inbound.xls";
  10. $fisierOutbound = "outbound.xls";
  11.  
  12. callsInbound();
  13.  
  14. function callsInbound() {
  15.  
  16. global $fisierInbound;
  17. global $current;
  18.  
  19. global $con;
  20.  
  21. $identify = PHPExcel_IOFactory::identify('daily/' . $fisierInbound);
  22. $objReader = PHPExcel_IOFactory::createReader($identify);
  23. $objReader->setReadDataOnly(true);
  24. $objPHPExcel = $objReader->load('daily/' . $fisierInbound);
  25. $worksheet = $objPHPExcel->setActiveSheetIndex(0);
  26.  
  27. $query = mysqli_query($con, "SELECT * FROM users WHERE tip_user='agent' AND NOT (departament='online')");
  28.  
  29. while($usr = mysqli_fetch_array($query)) {
  30. $data[] = $usr;
  31. }
  32.  
  33. $worksheetTitle = $worksheet->getTitle();
  34. $highestRow = $worksheet->getHighestRow(); // e.g. 10
  35. $highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
  36. $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
  37. $dataCalls = $worksheet->getCellByColumnAndRow(2, 2)->getValue();
  38. $dataSubstr = substr($dataCalls, 53);
  39. echo $dataSubstr;
  40. foreach ($data as $db) {
  41.  
  42. for ($row = 6; $row <= $highestRow; ++ $row) {
  43.  
  44. $marca = $worksheet->getCellByColumnAndRow(3, $row)->getValue();
  45. $nr = $worksheet->getCellByColumnAndRow(4, $row)->getValue();
  46.  
  47. if($db['marca'] == $marca) {
  48. mysqli_query($con, "INSERT INTO dailycalls(data, nr, departament, oras, tip, id_user)
  49. VALUES('$dataSubstr', '$nr', '" . $db['departament'] . "', '" . $db['oras'] . "', 'inbound', '" . $db['id'] . "')");
  50. }
  51. }
  52. }
  53. }
  54.  
  55. $("#applyCalls").off('click', callServer).on('click', callServer);
  56.  
  57. var callServer = function(){
  58. $.get("admin/processCalls.php");
  59. };
  60.  
  61. $("#applyCalls").unbind("click").click(function(){$.get("admin/processCalls.php");});
  62.  
  63. $("#applyCalls").click(function(event){
  64. event.stopPropagation()
  65. $.post("admin/processCalls.php");
  66. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement