selectTemplate($q); $templatePathsData = $m->selectTemplatePaths($q); // plain svg for visualizer $templateTypes = $m->selectTemplateTypes(); $sportsList = $m1->getSportsName(); $printPatternList = $m2->selectAllPrintTemplate($q); return view('sub_pages.edit_template')->with('templatedata', $templateData)->with('templatepath', $templatePathsData)->with('sportsname', $sportsList)->with('templatetype', $templateTypes)->with('printpattern', $printPatternList); } public function getTemplates(Request $request) { $m = new TemplatesModel; $post = $request->all(); $data = $m->selectTemplates($post['id']); // /public/images/sports-thumbnails if (!empty($data)) { foreach ($data as $row) { ?>

TemplateName ?>

Thumbnail ?>" alt="Sports" height="400px;" class="img img-responsive product-center" />
alert("No available Template/s"); '; } } public function displayAddTemplatePage() { return view('sub_pages.add_template'); } public function getTemplateTypes() { //if(Request::ajax()){ $m = new TemplatesModel; $data = $m->selectTemplateTypes(); ?> TemplateType . '">' . $row->TemplateType . ''; } ?> selectTemplateLastId(); echo $templateCode = "TEMP-" . str_pad($data->Id + 1, 5, '0', STR_PAD_LEFT); } public function saveNewTemplates(Request $request) { $m = new TemplatesModel; $post = $request->all(); $templateCode = $post['templateCode']; $sportName = $post['sportName']; $templateName = $post['templateName']; $templateType = $post['templateType']; $numberOfTrims = $post['numberOfTrims']; $getSkins = $post['getSkins']; $tempateImage = $post['tempateImage']; $rawName = date('Ymd') . "-" . time() . '-' . $request->file('tempateImage')->getClientOriginalName(); $imageExt = $request->file('tempateImage')->getClientOriginalExtension(); $custom_file_name = str_replace(' ', '-', strtolower($rawName)); $custom_file_name = preg_replace("/\.[^.\s]{3,4}$/", "", $custom_file_name); $NewImageName = $custom_file_name . '.' . $imageExt; $thumbnail = "images/templates/thumbnail/" . $NewImageName; $data = array( 'SportsId' => $sportName, 'TemplateCode' => $templateCode, 'Thumbnail' => $thumbnail, 'TemplateName' => $templateName, 'TemplateType' => $templateType, 'Trim' => $numberOfTrims, 'PatternId' => $getSkins, 'IsActive' => 'TRUE' ); $i = $m->insertNewTempalte($data); if ($i) { $request->file('tempateImage')->move( base_path() . '/public/images/templates/thumbnail', $NewImageName ); //for front jersey if (!empty($request->file('svgJerseyFront')->getClientOriginalName())) { $svgName = $request->file('svgJerseyFront')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; //var_dump($svgThumbnail); $Templatedata = array( 'TemplateCode' => $templateCode, 'Type' => 'Jersey', 'Side' => 'Front', 'Path' => $svgThumbnail, 'IsActive' => 'TRUE' ); $i = $m->insertTempaltePaths($Templatedata); if ($i) { $request->file('svgJerseyFront')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } if (!empty($request->file('svgJerseyBack')->getClientOriginalName())) { $svgName = $request->file('svgJerseyBack')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'TemplateCode' => $templateCode, 'Type' => 'Jersey', 'Side' => 'Back', 'Path' => $svgThumbnail, 'IsActive' => 'TRUE' ); $i = $m->insertTempaltePaths($Templatedata); if ($i) { $request->file('svgJerseyBack')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } if (!empty($request->file('svgShortRight')->getClientOriginalName())) { $svgName = $request->file('svgShortRight')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'TemplateCode' => $templateCode, 'Type' => 'Shorts', 'Side' => 'Right', 'Path' => $svgThumbnail, 'IsActive' => 'TRUE' ); $i = $m->insertTempaltePaths($Templatedata); if ($i) { $request->file('svgShortRight')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } if (!empty($request->file('svgShortLeft')->getClientOriginalName())) { $svgName = $request->file('svgShortLeft')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'TemplateCode' => $templateCode, 'Type' => 'Shorts', 'Side' => 'Left', 'Path' => $svgThumbnail, 'IsActive' => 'TRUE' ); $i = $m->insertTempaltePaths($Templatedata); if ($i) { $request->file('svgShortLeft')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } echo '

Success!

Sports is successfully added.
'; } else { echo '

Error!

Failed to saved new sports.
'; } } public function updateTemplate(Request $request) { $m = new TemplatesModel; $post = $request->all(); // var_dump($post); // echo count($post); // var_dump($post); // var_dump(array_key_exists('svgShortRight', $post)); $templateCode = $post['templateCode']; $sportName = $post['sportName']; $templateName = $post['templateName']; $templateType = $post['templateType']; $numberOfTrims = $post['numberOfTrims']; $getSkins = $post['getSkins']; if (array_key_exists('tempateImage', $post)) { $tempateImage = $post['tempateImage']; $rawName = date('Ymd') . "-" . time() . '-' . $request->file('tempateImage')->getClientOriginalName(); $imageExt = $request->file('tempateImage')->getClientOriginalExtension(); $custom_file_name = str_replace(' ', '-', strtolower($rawName)); $custom_file_name = preg_replace("/\.[^.\s]{3,4}$/", "", $custom_file_name); $NewImageName = $custom_file_name . '.' . $imageExt; $thumbnail = "images/templates/thumbnail/" . $NewImageName; $data = array( 'SportsId' => trim($sportName), 'TemplateCode' => $templateCode, 'Thumbnail' => $thumbnail, 'TemplateName' => $templateName, 'TemplateType' => trim($templateType), 'Trim' => $numberOfTrims, 'PatternId' => $getSkins ); $request->file('tempateImage')->move( base_path() . '/public/images/templates/thumbnail', $NewImageName ); } else { $data = array( 'SportsId' => trim($sportName), 'TemplateCode' => $templateCode, //'Thumbnail' => $thumbnail, 'TemplateName' => $templateName, 'TemplateType' => trim($templateType), 'Trim' => $numberOfTrims, 'PatternId' => $getSkins ); } $i = $m->updateNewTemplate($data, $templateCode); if (array_key_exists('svgJerseyFront', $post)) { //echo 'meron jerset front'; $svgName = $request->file('svgJerseyFront')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'Type' => 'Jersey', 'Side' => 'Front', 'Path' => $svgThumbnail ); $i = $m->updateTemplatePaths($Templatedata, $post['id_svgJerseyFront']); if ($i) { $request->file('svgJerseyFront')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); //echo 'image move success'; } } if (array_key_exists('svgJerseyBack', $post)) { $svgName = $request->file('svgJerseyBack')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'Type' => 'Jersey', 'Side' => 'Back', 'Path' => $svgThumbnail ); $i = $m->updateTemplatePaths($Templatedata, $post['id_svgJerseyBack']); if ($i) { $request->file('svgJerseyBack')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } if (array_key_exists('svgShortRight', $post)) { $svgName = $request->file('svgShortRight')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'Type' => 'Shorts', 'Side' => 'Right', 'Path' => $svgThumbnail ); $i = $m->updateTemplatePaths($Templatedata, $post['id_svgShortRight']); if ($i) { $request->file('svgShortRight')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } if (array_key_exists('svgShortLeft', $post)) { $svgName = $request->file('svgShortLeft')->getClientOriginalName(); $svgThumbnail = "uniform-templates/" . $templateCode . "/DISPLAY/" . $svgName; $Templatedata = array( 'Type' => 'Shorts', 'Side' => 'Left', 'Path' => $svgThumbnail ); $i = $m->updateTemplatePaths($Templatedata, $post['id_svgShortLeft']); if ($i) { $request->file('svgShortLeft')->move( base_path() . '/public/images/uniform-templates/' . $templateCode . '/DISPLAY', $svgName ); } } echo '

Success!

Template is successfully updated.
'; } }