src/Controller/ConfigurateurController.php line 76
<?phpnamespace App\Controller;use App\Services\DbMenu;use App\Services\DbPage;use App\Services\MailerHandler;use App\Controller\ConfigurateurController;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\HttpFoundation\JsonResponse;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;class ConfigurateurController extends AbstractController{const SHORCODE_REGEX = '/\[%\[([^<]*)\]%\]/';public static function get_configurator_between($string){preg_match_all(self::SHORCODE_REGEX, $string, $out);return $out[1];}public static function parseCMSContent($content){$parsed = ConfigurateurController::get_configurator_between($content);foreach ($parsed as $key => $value) {$valueArray = explode('|',$value);$content = str_replace("[%[".$value."]%]", "", $content);}return ["configurateurCode" => $valueArray[1], "content" => $content];}public function isAjaxCall($request){return ($request->isXmlHttpRequest() && $request->isMethod('POST'));}public function getJsonContent($request){return json_decode($request->getContent(), true);}public function prepareJsonResponse($data = array()){return array_merge(array('error' => false), $data);}public function mmToInche($inche, $number) {if ($inche) {return $number / 25.4;} else {return $number;}}#[Route(path: ['fr' => '/{_locale}/configurateurs-axes/{link}', 'en' => '/{_locale}/load-pins-configurator/{link}'],name: 'configurateur',requirements: ['_locale' => 'en|fr',],priority: 2,)]#[Route(path: ['fr' => '/{_locale}/configurateurs-tensiometres/{link}', 'en' => '/{_locale}/tensiometer-configurator/{link}'],name: 'configurateur_tensiometre',requirements: ['_locale' => 'en|fr',],priority: 2,)]public function configurateur(Request $request, DbPage $dbPage, $link = null): Response{if ($request->getLocale() == 'fr') {if ($request->attributes->get('_route') == 'configurateur_tensiometre') {$breadcrumb = array(['name' => 'Configurateurs tensiomètres', 'link_rewrite' => 'configurateurs-tensiometres']);} else {$breadcrumb = array(['name' => 'Configurateurs axes', 'link_rewrite' => 'configurateurs-axes']);}} else {if ($request->attributes->get('_route') == "configurateur_tensiometre") {$breadcrumb = array(['name' => 'Tensiometer-configurator', 'link_rewrite' => 'tensiometer-configurator']);} else {$breadcrumb = array(['name' => 'Load-pins configurator', 'link_rewrite' => 'load-pins-configurator']);}}$contents = $dbPage->getContent($link, $request->getLocale());$link = $dbPage->getLink($contents[0]['id_cms'], $request);$configurateurCodeArray = $this->parseCMSContent($contents[0]['content']);$contents[0]['content'] = $configurateurCodeArray["content"];$configurateurCode = $configurateurCodeArray["configurateurCode"];return $this->render('configurateur/configurateur.html.twig', ['contents' => $contents, 'link' => $link, 'configurateurCode' => $configurateurCode, 'breadcrumb' => $breadcrumb]);}#[Route(path: ['fr' => '/{_locale}/configurateurs-axes', 'en' => '/{_locale}/load-pins-configurator'],name: 'configurateur_menu',requirements: ['_locale' => 'en|fr',],priority: 1,)]#[Route(path: ['fr' => '/{_locale}/configurateurs-tensiometres', 'en' => '/{_locale}/tensiometer-configurator'],name: 'configurateur_tensiometre_menu',requirements: ['_locale' => 'en|fr',],priority: 1,)]public function configurateur_menu(Request $request, DbMenu $dbMenu): Response{if ($request->getLocale() == 'fr') {if ($request->attributes->get('_route') == 'configurateur_tensiometre_menu') {$breadcrumb = array(['name' => 'Configurateurs tensiomètres', 'link_rewrite' => 'configurateurs-tensiometres']);$link = '/en/tensiometer-configurator';} else {$breadcrumb = array(['name' => 'Configurateurs axes', 'link_rewrite' => 'configurateurs-axes']);$link = '/en/load-pins-configurator';}} else {if ($request->attributes->get('_route') == "configurateur_tensiometre_menu") {$breadcrumb = array(['name' => 'Tensiometer-configurator', 'link_rewrite' => 'tensiometer-configurator']);$link = '/fr/configurateurs-tensiometres';} else {$breadcrumb = array(['name' => 'Load-pins configurator', 'link_rewrite' => 'load-pins-configurator']);$link = '/fr/configurateurs-axes';}}$parent = $dbMenu->getContent($breadcrumb[0]["link_rewrite"], $request->getLocale());$menus = array();$menusCms = $dbMenu->getMenusCms($parent[0]['id_cms_category'], $request->getLocale());return $this->render('apropos/aproposmenu.html.twig', ['link' => $link, 'breadcrumb' => $breadcrumb, 'menus' => $menus, 'menusCms' => $menusCms]);}#[Route(path: ['fr' => '/configurateurs/mail', 'en' => '/configurator/mail'],name: 'configurateur_mail',requirements: ['_locale' => 'en|fr',],)]public function configurateur_mail(Request $request, MailerHandler $mailer): Response{if ($this->isAjaxCall($request)) {$content = $this->getJsonContent($request);$societe = $content["societe"];$quantite = $content["quantite"];$pays = $content["pays"];$telephone = $content["telephone"];$remarque = $content["remarque"];$nom = $content["nom"];$unite = $content["unite"];$trougraisse = $content["trougraisse"];$dunit = $content["dunit"];$da = $content["da"];$di = $content["di"];$daa = $content["daa"];$dd = $content["dd"];$nominal = $content["nominal"];$nominalunit = $content["nominalunit"];$signal = $content["signal"];$bridge = $content["bridge"];$cable = $content["cable"];$cableunit = $content["cableunit"];$temperature = $content["temperature"];$temperaturevalue = $content["temperaturevalue"];$temperatureunit = $content["temperatureunit"];$environnement = $content["environnement"];$profondeur = $content["profondeur"];$temps = $content["temps"];$tempsunit = $content["tempsunit"];$application = $content["application"];$protection = $content["protection"];$securite = $content["securite"];$autre = $content["autre"];$remarquecarac = $content["remarquecarac"];$designg = $content["designg"];$designr = $content["designr"];$product = $content["produit"];$capacite = $content["capacite"];$capaciteunit = $content["capaciteunit"];$diametres = $content["diametres"];$diametree = $content["diametree"];$diametreunite = $content["diametreunite"];$environnementt = $content["environnementt"];$type = $content["type"];$signalt = $content["signalt"];$securitet = $content["securitet"];$autret = $content["autret"];$mail = $content["mail"];$from = "info@sensy.com";$subject = 'SENSY simulation, the '.date('d/m/Y');$mailer->send([$mail], $from, $subject, 'mail/configurateur/configurateurclient.html.twig');$content = '<strong>Model:</strong> ' . $product . '<br/><br/>';if ($product == '5000' || $product == '5050') {$inche = false;$unit = '';if ($unite == 1) {$unit = 'mm';} else {$unit = 'inches';$inche = true;}$greasing_hole = '';if ($trougraisse == 1) {$greasing_hole = 'No';} else {$greasing_hole = 'Yes';}$D_unit = '';if ($dunit == 1) {$D_unit = 'h9';} else if ($dunit == 2) {$D_unit = 'h8';} else if ($dunit == 3) {$D_unit = 'h7';} else if ($dunit == 4) {$D_unit = 'h6';}//Calcul pour Load pins général$palier01 = $this->mmToInche($inche, 25);$palier02 = $this->mmToInche($inche, 40);$palier03 = $this->mmToInche($inche, 63);$palier04 = $this->mmToInche($inche, 100);$palier05 = $this->mmToInche($inche, 160);$H = 0;$b = 0;$data_D = $dd;if ($data_D < $palier01) {$H = $this->mmToInche($inche, 10);$b = $this->mmToInche($inche, 5);} else if ($data_D >= $palier01 && $data_D < $palier02) {$H = $this->mmToInche($inche, 12);$b = $this->mmToInche($inche, 6);} else if ($data_D >= $palier02 && $data_D < $palier03) {$H = $this->mmToInche($inche, 16);$b = $this->mmToInche($inche, 8);} else if ($data_D >= $palier03 && $data_D < $palier04) {$H = $this->mmToInche($inche, 20);$b = $this->mmToInche($inche, 10);} else if ($data_D >= $palier04 && $data_D < $palier05) {$H = $this->mmToInche($inche, 25);$b = $this->mmToInche($inche, 12);} else if ($data_D >= $palier05) {$H = $this->mmToInche($inche, 32);$b = $this->mmToInche($inche, 16);}$Long = $da + $di + $daa + $H + $this->mmToInche($inche, 45);if ($Long <= $this->mmToInche($inche, 55)) {$Long = 0;}$L = $da + $di + $daa;//Arrondie les chiffre à une décimal après la virgule$Long = round($Long, 1);$L = round($L, 1);$H = round($H, 1);$b = round($b, 1);//End Calcul pour Load pins général$content .= '<strong><u>General:</u></strong><br/><br/><strong>Unit: </strong>' . $unit . '<br/>';$content .= $product != '5050' ? '<strong>Greasing hole: </strong>' . $greasing_hole . '<br/>' : '';$content .= '<strong>A: </strong>' . $da . '<br/><strong>I: </strong>' . $di . '<br/><strong>A/A\': </strong>' . $daa . '<br/><strong>D: </strong>' . $dd. ' ' . $D_unit . '<br/><strong>Long: </strong>' . $Long . '<br/><strong>L: </strong>' . $L . '<br/><strong>H: </strong>' . $H . '<br/><strong>b: </strong>' . $b . '<br/><br/>';//END General section//Specification section$nominal_capacity_unit = '';if ($nominalunit == 1) {$nominal_capacity_unit = 't';} else if ($nominalunit == 2) {$nominal_capacity_unit = 'kN';} else if ($nominalunit == 3) {$nominal_capacity_unit = 'klbs';}$output_signal = '';if ($signal == 1) {$output_signal = 'mV/V';} else if ($signal == 2) {$output_signal = '4-20mA';} else if ($signal == 3) {$output_signal = '0-10V (force)';} else if ($signal == 4) {$output_signal = '1-10V';} else if ($signal == 5) {$output_signal = '1-5V';} else if ($signal == 6) {$output_signal = 'RS232';} else if ($signal == 7) {$output_signal = 'RS485';} else if ($signal == 8) {$output_signal = 'Wireless';} else if ($signal == 9) {$output_signal = 'Other';}$dual_bridge = '';if ($bridge == 1) {$dual_bridge = 'No';} else if ($bridge == 2) {$dual_bridge = 'Yes';}$cable_length_unit = '';if ($cableunit == 1) {$cable_length_unit = 'm';} else if ($cableunit == 2) {$cable_length_unit = 'ft';}$temperature = '';if ($temperature == 1) {$temperature = 'Standard';} else if ($temperature == 2) {$temperature = 'Other -> ';$temperature .= $temperaturevalue;if ($temperatureunit == 1) {$temperature .= ' °C';} else if ($temperatureunit == 2) {$temperature .= ' °F';}}$env = '';if ($environnement == 1) {$env = 'Normal';} else if ($environnement == 2) {$env = 'Marine';} else if ($environnement == 3) {$env = 'Subsea <br/>';$env .= ' -> Immersion depth (m): ' . $profondeur . '<br/>';$env .= ' -> Immersion time: ' . $temps . ' ' . $tempsunit . '<br/>';} else if ($environnement == 4) {$env = 'Corrosive';}$application_type = '';if ($application == 1) {$application_type = 'Hoisting (CE certified)';} else if ($application == 2) {$application_type = 'Force, static';} else if ($application == 3) {$application_type = 'Force, dynamic';}$protection_level = '';if ($protection == 1) {$protection_level = 'IP65';} else if ($protection == 2) {$protection_level = 'IP66';} else if ($protection == 3) {$protection_level = 'IP67';} else if ($protection == 4) {$protection_level = 'IP68';} else if ($protection == 5) {$protection_level = 'Other';}$intrinsically_safe = '';if ($securite == 1) {$intrinsically_safe = 'Not applicable';} else if ($securite == 2) {$intrinsically_safe = 'ATEX';} else if ($securite == 3) {$intrinsically_safe = 'IECEx / ATEX';} else if ($securite == 4) {$intrinsically_safe = 'CSA (US / Canada)';} else if ($securite == 5) {$intrinsically_safe = 'Triple certification';}$other = '';if ($autre == 1) {$other = 'No';} else if ($autre == 2) {$other = 'Biaxial load pin, directions X and Y';} else if ($autre == 3) {$other = 'Special Design';} else if ($autre == 4) {$other = 'Special environment';} else if ($autre == 5) {$other = 'Special connector and/or cable';}$content .= '<strong><u>Specifications:</u></strong><br/><br/><strong>Nominal capacity: </strong>' . $nominal . ' ' . $nominal_capacity_unit . '<br/><strong>Output signal: </strong>' . $output_signal . '<br/><strong>Dual bridge circuit: </strong>' . $dual_bridge . '<br/><strong>Cable length: </strong>' . $cableunit . ' ' . $cable_length_unit . '<br/><strong>Service temperature range: </strong>' . $temperature . '<br/><strong>Environment: </strong>' . $env . '<br/><strong>Type of application: </strong>' . $application_type . '<br/><strong>Protection level: </strong>' . $protection_level . '<br/><strong>Intrinsically Safe: </strong>' . $intrinsically_safe . '<br/><strong>Other: </strong>' . $other . '<br/><strong>Remarks: </strong>' . $remarquecarac . '<br/><br/>';//END Specification section// Available designs$content .= '<strong><u>Available designs:</u></strong><br/><br/><strong>Design start: </strong>' . $designg . '<br/><strong>Design end: </strong>' . $designr . '<br/><br/>';// END Available designs} else if ($product == '5560S' || $product == '5570-5575' || $product == '5580-5585') {$capacity_unit = '';if ($capacite == 1) {$capacity_unit = 't';} else if ($capacite == 2) {$capacity_unit = 'kN';} else if ($capacite == 3) {$capacity_unit = 'klbs';}$rope_diameter_unit = '';if ($diametreunite == 1) {$rope_diameter_unit = 'mm';} else if ($diametreunite == 2) {$rope_diameter_unit = 'inches';}$env = '';if ($environnementt == 1) {$env = 'Standard (IP 65)';} else if ($environnementt == 2) {$env = 'Marine';} else if ($environnementt == 3) {$env = 'Subsea';}$rope_type = '';if ($type == 1) {$rope_type = 'Steel';} else if ($type == 2) {$rope_type = 'Synthetic';} else if ($type == 3) {$rope_type = 'Carbon';}$output_signal = '';if ($signalt == 1) {$output_signal = 'mV/V';} else if ($signalt == 2) {$output_signal = '0-10V';} else if ($signalt == 3) {$output_signal = '4-20mA';} else if ($signalt == 4) {$output_signal = 'RS485-ASCII';}$safe = '';if ($securitet == 1) {$safe = 'Not applicable';} else if ($securitet == 2) {$safe = 'ATEX';} else if ($securitet == 3) {$safe = 'IECEx / ATEX';} else if ($securitet == 4) {$safe = 'CSA (US / Canada)';} else if ($securitet == 5) {$safe = 'Triple certification';}$content .= '<strong><u>General:</u></strong><br/><br/><strong>Capacity: </strong>' . $capacite . ' ' . $capacity_unit . '<br/><strong>Rope/line diameter(s): </strong>' . $diametres . ' to ' . $diametree . ' ' . $rope_diameter_unit . '<br/><strong>Environment: </strong>' . $env . '<br/><strong>Type of rope/line: </strong>' . $rope_type . '<br/><strong>Output signal: </strong>' . $output_signal . '<br/><strong>Intrinsically Safe: </strong>' . $safe . '<br/><strong>Other: </strong>' . $autret . '<br/><br/> ';}$content .= '<strong><u>Personal infos:</u></strong><br/><br/><strong>Company: </strong>' . $societe . '<br/><strong>Name: </strong>' . $nom . '<br/><strong>Email: </strong>' . $mail . '<br/><strong>Quantity: </strong>' . $quantite . '<br/><strong>Country: </strong>' . $pays . '<br/><strong>Phone: </strong>' . $telephone . '<br/><strong>Remark(s): </strong>' . $remarque . '<br/><br/> ';// $mail = ["jm@adevo.be"];$to = ["jm@adevo.be", "jeremymortier@hotmail.com"];// // $mail = ["fg@sensy.com", "cornil@sensy.com", "amo@sensy.com", "web@sensy.com", "giansante.fab@gmail.com"];$from = "noreply@sensy.com";$subject = 'Nouvelle demande par internet pour le modèle ' . $product . ', le ' . date('d/m/Y');$mailer->send($to, $from, $subject, 'mail/configurateur/configurateur.html.twig', ['content' => $content]);}return new JsonResponse();}}?>