src/Controller/BaseController.php line 66

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Ceviri;
  4. use App\Entity\Dil;
  5. use Gumlet\ImageResize;
  6. use FPDF;
  7. use Kreait\Firebase\Factory;
  8. use Kreait\Firebase\Messaging\CloudMessage;
  9. use Kreait\Firebase\Messaging\Notification;
  10. use Kreait\Firebase\Messaging\AndroidConfig;
  11. use Kreait\Firebase\Messaging\ApnsConfig;
  12. use setasign\Fpdi\Fpdi;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use App\Controller;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. class BaseController extends AbstractController
  18. {
  19.     function smsGonder($no,$mesaj)
  20.     {
  21.         $response="";
  22.         if ($no == '' or $mesaj == ''){}
  23.         else {
  24.             $no str_replace(array('(',')',' '),array('','',''),$no);
  25.             $no substr($no,1,strlen($no));
  26.             $curl curl_init();
  27.             curl_setopt_array($curl, array(
  28.                 CURLOPT_URL => 'https://api.netgsm.com.tr/sms/send/get',
  29.                 CURLOPT_RETURNTRANSFER => true,
  30.                 CURLOPT_ENCODING => '',
  31.                 CURLOPT_MAXREDIRS => 10,
  32.                 CURLOPT_TIMEOUT => 0,
  33.                 CURLOPT_FOLLOWLOCATION => true,
  34.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  35.                 CURLOPT_CUSTOMREQUEST => 'POST',
  36.                 CURLOPT_POSTFIELDS => array('usercode' => '8503092043''password' => 'AF#351B''gsmno' => $no'message' => $mesaj'msgheader' => 'OZMENTIC.''filter' => '0''startdate' => '''stopdate' => '''dil'=>'TR'),
  37.             ));
  38.             $response curl_exec($curl);
  39.             curl_close($curl);
  40.         }
  41.         return $response;
  42.     }
  43.     function GetIP()
  44.     {
  45.         if (getenv("HTTP_CLIENT_IP")) {
  46.             $ip getenv("HTTP_CLIENT_IP");
  47.         } elseif (getenv("HTTP_X_FORWARDED_FOR")) {
  48.             $ip getenv("HTTP_X_FORWARDED_FOR");
  49.             if (strstr($ip',')) {
  50.                 $tmp explode(','$ip);
  51.                 $ip trim($tmp[0]);
  52.             }
  53.         } else {
  54.             $ip getenv("REMOTE_ADDR");
  55.         }
  56.         return $ip;
  57.     }
  58.     function ayarlar($alan)
  59.     {
  60.         $em=$this->getDoctrine()->getManager();
  61.         $qb $em->createQueryBuilder();
  62.         $ayarlar=$qb->select("e.$alan")
  63.             ->from('App:Ayarlar''e')
  64.             ->getQuery()
  65.             ->getScalarResult();
  66.         return $ayarlar[0][$alan];
  67.     }
  68.     function firmaAyarlari($alan)
  69.     {
  70.         $em=$this->getDoctrine()->getManager();
  71.         $qb $em->createQueryBuilder();
  72.         $ayarlar=$qb->select("e.$alan")
  73.             ->from('App:FirmaAyarlari''e')
  74.             ->getQuery()
  75.             ->getScalarResult();
  76.         return $ayarlar[0][$alan];
  77.     }
  78.     function uzantiBul($type){
  79.         if($type=='application/pdf'){ return '.pdf'; }
  80.         if($type=='image/jpeg'){ return '.jpg'; }
  81.         elseif($type=='image/png'){ return '.png'; }
  82.         elseif($type=='image/gif'){ return '.gif'; }
  83.         elseif($type=='video/mp4'){ return '.mp4'; }
  84.         elseif($type=='application/rtf'){ return '.rtf'; }
  85.         elseif($type=='text/plain'){ return '.txt'; }
  86.         elseif($type=='application/vnd.ms-powerpoint'){ return '.ppt'; }
  87.         elseif($type=='application/vnd.openxmlformats-officedocument.presentationml.presentation'){ return '.pptx'; }
  88.         elseif($type=='application/xml'){ return '.xml'; }
  89.         elseif($type=='text/xml'){ return '.xml'; }
  90.         elseif($type=='application/vnd.ms-excel'){ return '.xls'; }
  91.         elseif($type=='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){ return '.xlsx'; }
  92.         elseif($type=='application/msword'){ return '.doc'; }
  93.         elseif($type=='application/vnd.openxmlformats-officedocument.wordprocessingml.document'){ return '.docx'; }
  94.         else{ return '.belirsiz'; }
  95.     }
  96.     function rasgele($uzunluk)
  97.     {
  98.         $key='';
  99.         $karakterler "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  100.         for($i=0;$i<$uzunluk;$i++)
  101.         {
  102.             $key .= $karakterler[rand(0,35)];
  103.         }
  104.         return $key;
  105.     }
  106.     function rasgeleSayi($uzunluk)
  107.     {
  108.         $key='';
  109.         $karakterler "1234567890";
  110.         for($i=0;$i<$uzunluk;$i++)
  111.         {
  112.             $key .= $karakterler[rand(0,9)];
  113.         }
  114.         return $key;
  115.     }
  116.     function seo($url,$dil=1){
  117.         if($dil==1) {
  118.             $tr = array('ş''Ş''ı''I''İ''ğ''Ğ''ü''Ü''ö''Ö''Ç''ç''('')''/'':'',');
  119.             $eng = array('s''s''i''i''i''g''g''u''u''o''o''c''c''''''-''-''');
  120.             $s str_replace($tr$eng$url);
  121.             $find = array('/[^A-Za-z0-9\-<>]/''/[\-]+/''/<[^>]*>/');
  122.             $repl = array('-''-''-');
  123.             $s preg_replace($find$repl$s);
  124.             $s strtolower($s);
  125.             $s preg_replace('/&amp;amp;amp;amp;amp;amp;amp;amp;amp;.+?;/'''$s);
  126.             $s preg_replace('/\s+/''-'$s);
  127.             $s preg_replace('|-+|''-'$s);
  128.             $s preg_replace('/#/'''$s);
  129.             $s str_replace('.'''$s);
  130.             $s trim($s'-');
  131.             $s strtolower($s);
  132.             return $s;
  133.         }else{
  134.             $tr = array('('')''/'':'',',' ');
  135.             $eng = array('''''-''-''','-');
  136.             $s str_replace($tr$eng$url);
  137.             $s strtolower($s);
  138.             return $s;
  139.         }
  140.     }
  141.     function imageResizer($resim,$resim2,$boyut=800){
  142.         $resimBol explode('.',$resim);
  143.         $uzanti $resimBol[count($resimBol)-1];
  144.         $yol 'gecici_yukleme/'.$resim;
  145.         $yol2 'gecici_yukleme/'.$resim2.'.webp';
  146.         list($width$height) = getimagesize($yol);
  147.         $oran $width $boyut;
  148.         $yeni_genislik $width $oran;
  149.         $yeni_yukseklik $height $oran;
  150.         if ($uzanti=='jpeg' or $uzanti=='jpg' or $uzanti=='JPEG' or $uzanti=='JPG'){
  151.             $mevcut_resim imagecreatefromjpeg($yol);
  152.         }else{
  153.             $mevcut_resim imagecreatefrompng($yol);
  154.         }
  155.         $yeni_resim imagecreatetruecolor($yeni_genislik$yeni_yukseklik);
  156.         imageAlphaBlending($yeni_resimfalse);
  157.         imageSaveAlpha($yeni_resimtrue);
  158. // By default, the canvas is black, so make it transparent
  159.         $trans imagecolorallocatealpha($yeni_resim000127);
  160.         imagefilledrectangle($yeni_resim00$yeni_genislik 1$yeni_yukseklik 1$trans);
  161.         imagecopyresampled($yeni_resim$mevcut_resim0000$yeni_genislik$yeni_yukseklik$width$height);
  162.         @unlink($yol);
  163.         imagewebp($yeni_resim$yol2 );
  164.         return $resim2.'.webp';
  165.     }
  166.     function removeEntity($veriler){
  167.         $em $this->getDoctrine()->getManager();
  168.         foreach ($veriler as $veri){
  169.             $em->remove($veri);
  170.         }
  171.     }
  172.     function uploadFile($file){
  173.         $username 'rvcloudstorage';
  174.         $password 'rvrv/*-2020';
  175.         $url 'https://j15502zk.ni.net.tr:2083';
  176.         $yukleme_yeri $this->ayarlar('uploadFolder');
  177.         $filePath 'gecici_yukleme/'.$file;
  178.         $curl curl_init();
  179.         $upload_file realpath($filePath);
  180.         $destination_dir "public_html/".$yukleme_yeri;
  181.         if (function_exists('curl_file_create')) {
  182.             $cf curl_file_create($upload_file);
  183.         } else {
  184.             $cf "@/" $upload_file;
  185.         }
  186.         $payload = array(
  187.             'dir' => $destination_dir,
  188.             'file-1' => $cf
  189.         );
  190.         $actionUrl $url "/execute/Fileman/upload_files";
  191.         curl_setopt($curlCURLOPT_SSL_VERIFYPEER0);       // Allow self-signed certs
  192.         curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);       // Allow certs that do not match the hostname
  193.         curl_setopt($curlCURLOPT_HEADER0);               // Do not include header in output
  194.         curl_setopt($curlCURLOPT_RETURNTRANSFER1);       // Return contents of transfer on curl_exec
  195.         $header[0] = "Authorization: Basic " base64_encode($username ":" $password) . "\n\r";
  196.         curl_setopt($curlCURLOPT_HTTPHEADER$header);    // set the username and password
  197.         curl_setopt($curlCURLOPT_URL$actionUrl);        // execute the query
  198.         // Set up a POST request with the payload.
  199.         curl_setopt($curlCURLOPT_POSTtrue);
  200.         curl_setopt($curlCURLOPT_POSTFIELDS$payload);
  201.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  202.         $result curl_exec($curl);
  203.         if ($result == false) {
  204.             error_log("curl_exec threw error \"" curl_error($curl) . "\" for $actionUrl");
  205.             // log error if curl exec fails
  206.         }
  207.         curl_close($curl);
  208.         @unlink($filePath);
  209.         return json_decode($resulttrue);
  210.     }
  211.     function deleteFile($file)
  212.     {
  213.         if ($file!='') {
  214.             $curl curl_init();
  215.             $destination_dir 'public_html/'.$this->ayarlar('uploadFolder').'/' $file;
  216.             $username 'root';
  217.             $password 'suleyman1995ilgin***';
  218.             $url 'https://j15502zk.ni.net.tr:2083';
  219.             $user 'rvcloudstorage';
  220.             $actionUrl 'https://j15502zk.ni.net.tr:2087/json-api/cpanel?cpanel_jsonapi_user=' $user '&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=fileop&op=unlink&sourcefiles=' $destination_dir '&doubledecode=1';
  221.             curl_setopt($curlCURLOPT_SSL_VERIFYPEER0);       // Allow self-signed certs
  222.             curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);       // Allow certs that do not match the hostname
  223.             curl_setopt($curlCURLOPT_HEADER0);               // Do not include header in output
  224.             curl_setopt($curlCURLOPT_RETURNTRANSFER1);       // Return contents of transfer on curl_exec
  225.             $header[0] = "Authorization: Basic " base64_encode($username ":" $password) . "\n\r";
  226.             curl_setopt($curlCURLOPT_HTTPHEADER$header);    // set the username and password
  227.             curl_setopt($curlCURLOPT_URL$actionUrl);        // execute the query
  228.             curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  229.             $result curl_exec($curl);
  230.             if ($result == false) {
  231.                 error_log("curl_exec threw error \"" curl_error($curl) . "\" for $actionUrl");
  232.                 // log error if curl exec fails
  233.             }
  234.             curl_close($curl);
  235.             return json_decode($resulttrue);
  236.         }
  237.     }
  238.     function fpdf_turkce($k)
  239.     {
  240.         return iconv('UTF-8''ISO-8859-9//TRANSLIT'$k);
  241.     }
  242.     function belgeDogrulama($belgeNo,$belgeTipi,$kanal,$dogrulamaAraci,$kanal2="",$dogrulamaAraci2=""){
  243.         $em=$this->getDoctrine()->getManager();
  244.         if ($belgeTipi==1){
  245.             $qb $em->createQueryBuilder();
  246.             $basvurular $qb->select('b.id,b.basvuruBelgesi,b.basvuruDK')
  247.                 ->from('App:Basvurular''b')
  248.                 ->join('b.sube''s')
  249.                 ->join('b.cihaz''c')
  250.                 ->join('s.bolge''bol')
  251.                 ->join('s.sorumlu''sor')
  252.                 ->where("b.basvuruNo='$belgeNo'")
  253.                 ->getQuery()
  254.                 ->getScalarResult();
  255.             $belge $basvurular[0]['basvuruBelgesi'];
  256.             $pdf = new Fpdi();
  257.             $pdf->AddFont('arial_tr','','arial_tr.php');
  258.             $pdf->AddFont('arial_tr','B','arial_tr_bold.php');
  259.             copy($this->ayarlar('siteYolu').'storage/'.$belge'gecici_yukleme/'.$belge);
  260.             $pageCount $pdf->setSourceFile('gecici_yukleme/'.$belge);
  261.             for ($pageNo 1$pageNo <= $pageCount$pageNo++) {
  262.                 $tplIdx $pdf->importPage($pageNo);
  263.                 $pdf->addPage();
  264.                 $pdf->useTemplate($tplIdx55200);
  265.                 if($kanal!="") {
  266.                     $pdf->SetFont('arial_tr''B'10);
  267.                     $pdf->SetTextColor(000);
  268.                     $pdf->setY(235);
  269.                     $pdf->SetX(10);
  270.                     $pdf->Cell(906$this->fpdf_turkce($kanal), 00'C'false); // Sorumlu E-Posta
  271.                 }else{
  272.                     $pdf->SetFont('arial_tr''B'10);
  273.                     $pdf->SetTextColor(000);
  274.                     $pdf->setY(235);
  275.                     $pdf->SetX(10);
  276.                     $pdf->Cell(906$this->fpdf_turkce("Sistem tarafından doğrulanmıştır."), 00'C'false); // Sorumlu E-Posta
  277.                 }
  278.                 if($kanal!="") {
  279.                     $pdf->SetFont('arial_tr'''10);
  280.                     $pdf->SetTextColor(000);
  281.                     $pdf->setY(250);
  282.                     $pdf->SetX(10);
  283.                     if ($dogrulamaAraci == 1) {
  284.                         $pdf->MultiCell(906$this->fpdf_turkce('Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  285.                     } else {
  286.                         $pdf->MultiCell(906$this->fpdf_turkce('Üstte yazılı sorumlu telefon numarası tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  287.                     }
  288.                     $pdf->SetFont('arial_tr''B'10);
  289.                     $pdf->SetTextColor(000);
  290.                     $pdf->setY(240);
  291.                     $pdf->SetX(10);
  292.                     $pdf->Cell(906$this->fpdf_turkce('D.K. : ' $basvurular[0]['basvuruDK']), 00'C'false); // D.K. : 245 658   E-Posta doğrulama kodu
  293.                 }
  294.             }
  295.             $pdf->Output('F''gecici_yukleme/'.$belge,true);
  296.             $this->deleteFile($belge);
  297.             $this->uploadFile($belge);
  298.         }
  299.         if ($belgeTipi==2){
  300.             $qb $em->createQueryBuilder();
  301.             $basvurular $qb->select('b.id,b.muayeneBelgesi,b.muayeneDK')
  302.                 ->from('App:Basvurular''b')
  303.                 ->join('b.sube''s')
  304.                 ->join('b.cihaz''c')
  305.                 ->join('s.bolge''bol')
  306.                 ->join('s.sorumlu''sor')
  307.                 ->where("b.muayeneNo='$belgeNo'")
  308.                 ->getQuery()
  309.                 ->getScalarResult();
  310.             $belge $basvurular[0]['muayeneBelgesi'];
  311.             $pdf = new Fpdi();
  312.             $pdf->AddFont('arial_tr','','arial_tr.php');
  313.             $pdf->AddFont('arial_tr','B','arial_tr_bold.php');
  314.             copy($this->ayarlar('siteYolu').'storage/'.$belge'gecici_yukleme/'.$belge);
  315.             $pageCount $pdf->setSourceFile('gecici_yukleme/'.$belge);
  316.             for ($pageNo 1$pageNo <= $pageCount$pageNo++) {
  317.                 $tplIdx $pdf->importPage($pageNo);
  318.                 $pdf->addPage();
  319.                 $pdf->useTemplate($tplIdx55200);
  320.                 $pdf->SetFont('arial_tr''B'10);
  321.                 $pdf->SetTextColor(000);
  322.                 $pdf->setY(247);
  323.                 $pdf->SetX(10);
  324.                 $pdf->Cell(906$this->fpdf_turkce($kanal), 00'C'false); // bilgi@suleymanilgin.com.tr
  325.                 $pdf->SetFont('arial_tr'''10);
  326.                 $pdf->SetTextColor(000);
  327.                 $pdf->setY(257);
  328.                 $pdf->SetX(10);
  329.                 if ($dogrulamaAraci == 1) {
  330.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  331.                 } else {
  332.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu telefon numarası tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  333.                 }
  334.                 $pdf->SetFont('arial_tr''B'10);
  335.                 $pdf->SetTextColor(000);
  336.                 $pdf->setY(252);
  337.                 $pdf->SetX(10);
  338.                 $pdf->Cell(906$this->fpdf_turkce('D.K. : ' $basvurular[0]['muayeneDK']), 00'C'false); // D.K. : 245 658
  339.             }
  340.             $pdf->Output('F''gecici_yukleme/'.$belge,true);
  341.             $this->deleteFile($belge);
  342.             $this->uploadFile($belge);
  343.         }
  344.         if ($belgeTipi==3){
  345.             $qb $em->createQueryBuilder();
  346.             $basvurular $qb->select('b.id,b.kontrolBelgesi,b.kontrolDK')
  347.                 ->from('App:Basvurular''b')
  348.                 ->join('b.sube''s')
  349.                 ->join('b.cihaz''c')
  350.                 ->join('s.bolge''bol')
  351.                 ->join('s.sorumlu''sor')
  352.                 ->where("b.kontrolNo='$belgeNo'")
  353.                 ->getQuery()
  354.                 ->getScalarResult();
  355.             $belge $basvurular[0]['kontrolBelgesi'];
  356.             $pdf = new Fpdi();
  357.             $pdf->AddFont('arial_tr','','arial_tr.php');
  358.             $pdf->AddFont('arial_tr','B','arial_tr_bold.php');
  359.             copy($this->ayarlar('siteYolu').'storage/'.$belge'gecici_yukleme/'.$belge);
  360.             $pageCount $pdf->setSourceFile('gecici_yukleme/'.$belge);
  361.             for ($pageNo 1$pageNo <= $pageCount$pageNo++) {
  362.                 $tplIdx $pdf->importPage($pageNo);
  363.                 $pdf->addPage();
  364.                 $pdf->useTemplate($tplIdx55200);
  365.                 $pdf->SetFont('arial_tr''B'10);
  366.                 $pdf->SetTextColor(000);
  367.                 $pdf->setY(247);
  368.                 $pdf->SetX(10);
  369.                 $pdf->Cell(906$this->fpdf_turkce($kanal), 00'C'false); // bilgi@suleymanilgin.com.tr
  370.                 $pdf->SetFont('arial_tr'''10);
  371.                 $pdf->SetTextColor(000);
  372.                 $pdf->setY(257);
  373.                 $pdf->SetX(10);
  374.                 if ($dogrulamaAraci == 1) {
  375.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  376.                 } else {
  377.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu telefon numarası tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  378.                 }
  379.                 $pdf->SetFont('arial_tr''B'10);
  380.                 $pdf->SetTextColor(000);
  381.                 $pdf->setY(252);
  382.                 $pdf->SetX(10);
  383.                 $pdf->Cell(906$this->fpdf_turkce('D.K. : ' $basvurular[0]['kontrolDK']), 00'C'false); // D.K. : 245 658
  384.             }
  385.             $pdf->Output('F''gecici_yukleme/'.$belge,true);
  386.             $this->deleteFile($belge);
  387.             $this->uploadFile($belge);
  388.         }
  389.         if ($belgeTipi==4){
  390.             $qb $em->createQueryBuilder();
  391.             $basvurular $qb->select('b.id,b.tahsilatBelgesi,b.tahsilatDK,b.tahsilatDK2')
  392.                 ->from('App:Basvurular''b')
  393.                 ->join('b.sube''s')
  394.                 ->join('b.cihaz''c')
  395.                 ->join('s.bolge''bol')
  396.                 ->join('s.sorumlu''sor')
  397.                 ->where("b.tahsilatNo='$belgeNo'")
  398.                 ->getQuery()
  399.                 ->getScalarResult();
  400.             $belge $basvurular[0]['tahsilatBelgesi'];
  401.             $pdf = new Fpdi();
  402.             $pdf->AddFont('arial_tr','','arial_tr.php');
  403.             $pdf->AddFont('arial_tr','B','arial_tr_bold.php');
  404.             copy($this->ayarlar('siteYolu').'storage/'.$belge'gecici_yukleme/'.$belge);
  405.             $pageCount $pdf->setSourceFile('gecici_yukleme/'.$belge);
  406.             for ($pageNo 1$pageNo <= $pageCount$pageNo++) {
  407.                 $tplIdx $pdf->importPage($pageNo);
  408.                 $pdf->addPage();
  409.                 $pdf->useTemplate($tplIdx55200);
  410.                 $pdf->SetFont('arial_tr''B'10);
  411.                 $pdf->SetTextColor(000);
  412.                 $pdf->setY(123);
  413.                 $pdf->SetX(10);
  414.                 $pdf->Cell(906$this->fpdf_turkce($kanal), 00'C'false); // bilgi@suleymanilgin.com.tr
  415.                 $pdf->SetFont('arial_tr''B'10);
  416.                 $pdf->SetTextColor(000);
  417.                 $pdf->setY(127);
  418.                 $pdf->SetX(10);
  419.                 $pdf->Cell(906$this->fpdf_turkce('D.K. : ' $basvurular[0]['tahsilatDK']), 00'C'false); // D.K. : 245 658
  420.                 $pdf->SetFont('arial_tr'''10);
  421.                 $pdf->SetTextColor(000);
  422.                 $pdf->setY(133);
  423.                 $pdf->SetX(10);
  424.                 if ($dogrulamaAraci == 1) {
  425.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  426.                 } else {
  427.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu telefon numarası tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  428.                 }
  429.                 $pdf->SetFont('arial_tr''B'10);
  430.                 $pdf->SetTextColor(000);
  431.                 $pdf->setY(123);
  432.                 $pdf->SetX(110);
  433.                 $pdf->Cell(906$this->fpdf_turkce($kanal2), 00'C'false); // bilgi@suleymanilgin.com.tr
  434.                 $pdf->SetFont('arial_tr''B'10);
  435.                 $pdf->SetTextColor(000);
  436.                 $pdf->setY(127);
  437.                 $pdf->SetX(110);
  438.                 $pdf->Cell(906$this->fpdf_turkce('D.K. : ' $basvurular[0]['tahsilatDK2']), 00'C'false); // D.K. : 245 658
  439.                 $pdf->SetFont('arial_tr'''10);
  440.                 $pdf->SetTextColor(000);
  441.                 $pdf->setY(133);
  442.                 $pdf->SetX(110);
  443.                 if ($dogrulamaAraci2 == 1) {
  444.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  445.                 } else {
  446.                     $pdf->MultiCell(904$this->fpdf_turkce('Üstte yazılı sorumlu telefon numarası tarafından doğrulama kodu ile doğrulanmıştır.'), 0'C'false); // Üstte yazılı sorumlu e-posta adresi tarafından doğrulama kodu ile doğrulanmıştır.
  447.                 }
  448.             }
  449.             $pdf->Output('F''gecici_yukleme/'.$belge,true);
  450.             $this->deleteFile($belge);
  451.             $this->uploadFile($belge);
  452.         }
  453.         return "";
  454.     }
  455.     public function replaceSpace($string)
  456.     {
  457.         $string preg_replace("/\s+/"" "$string);
  458.         $string trim($string);
  459.         return $string;
  460.     }
  461.     public function subeSay($id,$roles){
  462.         $sql "s.id is not null";
  463.         if ($roles=='ROLE_KULLANICI'){
  464.             $sql .= ' and k.id='.$id;
  465.         }
  466.         $em $this->getDoctrine()->getManager();
  467.         $qb $em->createQueryBuilder();
  468.         $veriler=$qb->select("s.id")
  469.             ->from('App:Subeler''s')
  470.             ->join('s.bolge','b')
  471.             ->join('b.kullanici','k')
  472.             ->where($sql)
  473.             ->getQuery()
  474.             ->getScalarResult();
  475.         return intval(@count($veriler));
  476.     }
  477.     public function basvuruSay($id,$roles){
  478.         $sql 'bas.id is not null and bas.basvuruNo is not null';
  479.         if ($roles=='ROLE_KULLANICI'){
  480.             $sql .= ' and k.id='.$id;
  481.         }
  482.         $em $this->getDoctrine()->getManager();
  483.         $qb $em->createQueryBuilder();
  484.         $veriler=$qb->select("bas.id")
  485.             ->from('App:Basvurular''bas')
  486.             ->join('bas.cihaz','c')
  487.             ->join('c.sube','s')
  488.             ->join('s.bolge','b')
  489.             ->join('b.kullanici','k')
  490.             ->where($sql)
  491.             ->addGroupBy('bas.basvuruNo')
  492.             ->getQuery()
  493.             ->getScalarResult();
  494.         return intval(@count($veriler));
  495.     }
  496.     public function muayeneSay($id,$roles){
  497.         $sql 'bas.id is not null and bas.muayeneNo is not null';
  498.         if ($roles=='ROLE_KULLANICI'){
  499.             $sql .= ' and k.id='.$id;
  500.         }
  501.         $em $this->getDoctrine()->getManager();
  502.         $qb $em->createQueryBuilder();
  503.         $veriler=$qb->select("bas.id")
  504.             ->from('App:Basvurular''bas')
  505.             ->join('bas.cihaz','c')
  506.             ->join('c.sube','s')
  507.             ->join('s.bolge','b')
  508.             ->join('b.kullanici','k')
  509.             ->where($sql)
  510.             ->addGroupBy('bas.muayeneNo')
  511.             ->getQuery()
  512.             ->getScalarResult();
  513.         return intval(@count($veriler));
  514.     }
  515.     public function kontrolSay($id,$roles){
  516.         $sql 'bas.id is not null and bas.kontrolNo is not null';
  517.         if ($roles=='ROLE_KULLANICI'){
  518.             $sql .= ' and k.id='.$id;
  519.         }
  520.         $em $this->getDoctrine()->getManager();
  521.         $qb $em->createQueryBuilder();
  522.         $veriler=$qb->select("bas.id")
  523.             ->from('App:Basvurular''bas')
  524.             ->join('bas.cihaz','c')
  525.             ->join('c.sube','s')
  526.             ->join('s.bolge','b')
  527.             ->join('b.kullanici','k')
  528.             ->where($sql)
  529.             ->addGroupBy('bas.kontrolNo')
  530.             ->getQuery()
  531.             ->getScalarResult();
  532.         return intval(@count($veriler));
  533.     }
  534.     public function bad_request($mesaj){
  535.         return $this->json([
  536.             'error' => $mesaj,
  537.         ], Response::HTTP_BAD_REQUEST);
  538.     }
  539.     public function ok_request(){
  540.         return $this->json([
  541.             'status' => 1,
  542.         ], Response::HTTP_OK);
  543.     }
  544.     public function sorumluSay($id){
  545.         $em $this->getDoctrine()->getManager();
  546.         $qb $em->createQueryBuilder();
  547.         $veriler=$qb->select("k.id")
  548.             ->from('App:User''k')
  549.             ->where("(k.roles like '%ROLE_ADMIN%' or k.roles like '%ROLE_KULLANICI%') and k.id not in(".$id.")")
  550.             ->getQuery()
  551.             ->getScalarResult();
  552.         return intval(@count($veriler));
  553.     }
  554.     public function bolgeSay($id,$roles){
  555.         $sql "b.id is not null";
  556.         if ($roles=='ROLE_KULLANICI'){
  557.             $sql .= ' and k.id='.$id;
  558.         }
  559.         $em $this->getDoctrine()->getManager();
  560.         $qb $em->createQueryBuilder();
  561.         $veriler=$qb->select("b.id")
  562.             ->from('App:Bolgeler''b')
  563.             ->join('b.kullanici','k')
  564.             ->where($sql)
  565.             ->getQuery()
  566.             ->getScalarResult();
  567.         return intval(@count($veriler));
  568.     }
  569.     public function cihazSay($id,$roles){
  570.         $sql "c.id is not null";
  571.         if ($roles=='ROLE_KULLANICI'){
  572.             $sql .= ' and k.id='.$id;
  573.         }
  574.         $em $this->getDoctrine()->getManager();
  575.         $qb $em->createQueryBuilder();
  576.         $veriler=$qb->select("c.id")
  577.             ->from('App:Cihazlar''c')
  578.             ->join('c.sube','s')
  579.             ->join('s.bolge','b')
  580.             ->join('b.kullanici','k')
  581.             ->where($sql)
  582.             ->getQuery()
  583.             ->getScalarResult();
  584.         return intval(@count($veriler));
  585.     }
  586.     public function kullaniciDetay($id,$alan)
  587.     {
  588.         if ($id!=''){
  589.             $em $this->getDoctrine()->getManager();
  590.             $qb $em->createQueryBuilder();
  591.             $ayarlar=$qb->select("e.$alan")
  592.                 ->from('App:User''e')
  593.                 ->where('e.id='.$id)
  594.                 ->getQuery()
  595.                 ->setResultCacheId($alan)
  596.                 ->setResultCacheLifetime(60)
  597.                 ->getScalarResult();
  598.             return $ayarlar[0][$alan];
  599.         }else{
  600.             return "";
  601.         }
  602.     }
  603.     function mobilBildirimGonder($baslik,$metin,$kullanici)
  604.     {
  605.         $em $this->getDoctrine()->getManager();
  606.         $token $this->kullaniciDetay($kullanici,'fbToken');
  607.         if($token!=""){
  608.             $qb $em->createQueryBuilder();
  609.             $bildirimSay=$qb->select("b.id")
  610.                 ->from('App:Bildirimler''b')
  611.                 ->join('b.kullanici','k')
  612.                 ->where('b.okuma = 0 and k.id='.$kullanici)
  613.                 ->getQuery()
  614.                 ->getScalarResult();
  615.             $factory = (new Factory)
  616.                 ->withServiceAccount('ozmenkalibrasyon-firebase-adminsdk-ek3dg-3edc106485.json')
  617.                 ->withDatabaseUri('firebase-adminsdk-ek3dg@ozmenkalibrasyon.iam.gserviceaccount.com');
  618.             $auth $factory->createAuth();
  619.             $cloudMessaging $factory->createMessaging();
  620.             $message CloudMessage::withTarget('token'$token)
  621.                 ->withNotification(Notification::create($baslik$metin)) // optional
  622.                 ->withData(['payload' => ""])
  623.                 ->withAndroidConfig(AndroidConfig::fromArray([
  624.                     'ttl' => '3600s',
  625.                     'priority' => 'normal',
  626.                     'notification' => [
  627.                         'color' => '#ff0000',
  628.                         'sound' => 'default',
  629.                     ],
  630.                 ]))
  631.                 ->withApnsConfig(ApnsConfig::fromArray([
  632.                     'headers' => [
  633.                         'apns-priority' => '10',
  634.                     ],
  635.                     'payload' => [
  636.                         'aps' => [
  637.                             'badge' => count($bildirimSay),
  638.                             'sound' => 'default',
  639.                         ],
  640.                     ],
  641.                 ]));
  642.             try {
  643.                 $cloudMessaging->send($message);
  644.             }catch (\Exception $e){}
  645.         }
  646.         return "";
  647.     }
  648.     function d2ArrayConvert($array){
  649.         $array  unserialize($array);
  650.         return $array;
  651.     }
  652. }