private function passData($id = null) { $products = new \App\Models\Products(); if (!is_null($id)) { $products = Products::findOrNew($id); } if (!is_null($id)) { $cProducts = Products::where("id_Product", "!=", $id)->whereNull("Deleted")->orderBy('Product_Title')->get()->toArray(); $attachments = $products->attachments()->get(); $productFocusSubTypeList = $products->focusSubType()->get(); $productCompetitors = $products->competitor()->get(); } else { $cProducts = Products::whereNull("Deleted")->orderBy('Product_Title')->get()->toArray(); if (!Session::has('ProductAttachments')) { Session::set('ProductAttachments', $products->attachments()->get()); } $attachments = Session::get("ProductAttachments"); if (!Session::has('ProductFocusSubType')) { Session::set('ProductFocusSubType', $products->focusSubType()->get()); } $productFocusSubTypeList = Session::get("ProductFocusSubType"); if (!Session::has('ProductCompetitors')) { Session::set('ProductCompetitors', $products->competitor()->get()); } $productCompetitors = Session::get("ProductCompetitors"); } //dd($productFocusSubTypeList); $pFocus = ProductFocus::all(); $pfType = ProductFocusType::where("id_Product_Focus", "=", $products->id_Product_Focus ? $products->id_Product_Focus : 1)->get()->toArray(); $pfsType = ProductFocusSubType::where("id_Product_Focus_Type", "=", $products->id_Product_Focus_Type ? $products->id_Product_Focus_Type : 1)->get()->toArray(); $pPos = Positions::all()->toArray(); $competitorProducts = []; foreach ($pFocus as $prFocus) { $productFocus[$prFocus["id_Product_Focus"]] = $prFocus["Product_Focus"]; } foreach ($pfType as $prfFocus) { $productFocusType[$prfFocus["id_Product_Focus_Type"]] = $prfFocus["Product_Focus_Type"]; } foreach ($pfsType as $prfsFocus) { $productFocusSubType[$prfsFocus["id_Product_Focus_Sub_Type"]] = $prfsFocus["Product_Focus_Sub_Type"]; } foreach ($cProducts as $cpProducts) { $competitorProducts[$cpProducts["id_Product"]] = $cpProducts["Product_Title"]; } foreach ($pPos as $prPos) { $positions[$prPos["id_Position"]] = $prPos["Position_Name"]; } $Companies = Companies::SelectOptionsModel(); $TargetEndUser = TargetEndUser::CheckboxesModel(); $TargetMarket = TargetMarket::CheckboxesModel(); $AssetClass = AssetClass::CheckboxesModel(); $AvailabilityTerritory = AvailabilityTerritory::CheckboxesModel(); $TargetEndUserSelection = $products->TargetEndUserSelection(); $TargetMarketSelection = $products->TargetMarketSelection(); $ClassAssetsSelection = $products->ClassAssetsSelection(); $TerritorySelection = $products->TerritorySelection(); return compact("products", "productFocus", "productFocusType", "productFocusSubType", "Companies", "TargetMarket", "TargetEndUser", "AssetClass", "competitorProducts", "AvailabilityTerritory", "positions", "attachments", "TerritorySelection", "TargetEndUserSelection", "TargetMarketSelection", "ClassAssetsSelection", "productFocusSubTypeList", "productCompetitors"); }
/** * Get statistic data. * * @return Response */ public function monthStatistic($month, $year, Request $request) { $statistics = new \stdClass(); $StatisticEndDate = Carbon::create($year, $month, 1, 0, 0, 0)->addMonth(1); $StatisticStartDate = Carbon::create($year, $month, 1, 0, 0, 0); $statistics->companies = [Companies::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), Companies::whereNull("Deleted")->get()->count()]; $statistics->products = [Products::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), Products::whereNull("Deleted")->get()->count()]; $statistics->news = [News::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), News::whereNull("Deleted")->get()->count()]; $statistics->people = [People::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), People::whereNull("Deleted")->get()->count()]; return json_encode($statistics); }
public function search(Request $request) { $paginationList = []; //$this->validate($request, Search::getValidatorRules()); $searchFilters = Companies::getCompaniesSearchBy(); $search = $request->get("search") ? $request->get("search") : Session::get('CompanySearch'); Session::set('CompanySearch', $search); $companiesList = DB::table('Company')->where("Deleted", "=", NULL)->orderBy('Company_Full_Name', 'asc'); if (count($searchFilters)) { $companiesList->where(function ($query) use($searchFilters, $search) { foreach ($searchFilters as $searchFilter) { $query->where($searchFilter, 'like', "%{$search}%", "OR"); } }); } if ($companiesList->count()) { foreach ($companiesList->get() as $company) { if (strlen($company->Company_Full_Name)) { $firstChar = strtolower(substr($company->Company_Full_Name, 0, 1)); if (!isset($paginationList[$firstChar])) { $paginationList[$firstChar] = 0; } $paginationList[$firstChar] += 1; } } $activePage = $request->page ? $request->page : null; $companies = DB::table('Company')->select('Company.id_Company', 'Company.Company_Full_Name', 'Company.Year_Founded', 'Company.Website', 'Company.id_Employee_Size', 'Employee_Size.Employee_Size', 'Addresses.City', 'Addresses.State', 'Country.Country', 'Revenue_Stage.Revenue_Stage')->leftJoin('Employee_Size', 'Company.id_Employee_Size', '=', 'Employee_Size.id_Employee_Size')->leftJoin('Headquarters_Information', 'Company.id_Company', '=', 'Headquarters_Information.id_Company')->leftJoin('Addresses', 'Headquarters_Information.AddressId', '=', 'Addresses.AddressId')->leftJoin('Country', 'Addresses.id_Country', '=', 'Country.id_Country')->leftJoin('Revenue_Stage', 'Company.id_Revenue_Stage', '=', 'Revenue_Stage.id_Revenue_Stage')->whereNull("Deleted")->groupBy("Headquarters_Information.AddressId")->groupBy("Company.id_Company")->orderBy('Company_Full_Name', 'asc'); if (count($searchFilters)) { $companies->where(function ($query) use($searchFilters, $search) { foreach ($searchFilters as $searchFilter) { $query->where($searchFilter, 'like', "%{$search}%", "OR"); } }); } if (!is_null($activePage) && $activePage != "all") { $companies->where("Company_Full_Name", "like", "{$activePage}%"); } } else { $companies = $companiesList; $activePage = ""; } //$products = Products::whereNull("Deleted"); $products = Products::whereNull("Deleted")->get(); $employeeSize = EmployeeSize::all(); $ProductsToShow = []; $ProductsToHide = []; foreach ($companies->get() as $company) { $ProductsToShow[$company->id_Company] = []; $ProductsToHide[$company->id_Company] = []; $itemQty = 0; foreach ($products as $product) { if ($product->id_Owner_Company == $company->id_Company) { $itemQty++; if ($itemQty > 1) { $ProductsToHide[$company->id_Company][] = ["id" => $product->id_Product, "title" => $product->Product_Title]; //link_to(URL::route("admin.products.edit", $product->id_Product), $product->Product_Title, ["target"=>"_blank"]); } else { $ProductsToShow[$company->id_Company][] = ["id" => $product->id_Product, "title" => $product->Product_Title]; } } } } $employeeSize = EmployeeSize::all(); return view("admin.companies.index", compact('companies', "products", "search", "employeeSize", "searchFilters", "paginationList", "activePage", "companiesSearchBy", "ProductsToHide", "ProductsToShow")); }
public function getTagsList($category) { switch ($category) { case 'Companies': return Companies::whereNull("Deleted")->orderBy('Company_Full_Name', 'asc')->get(['id_Company as id', 'Company_Full_Name as description'])->toJson(); case 'People': return People::whereNull("Deleted")->orderBy('First_Name', 'asc')->get(['id_People as id', 'First_Name as description'])->toJson(); case 'Vertical': return Vertical::all(['id_Vertical as id', 'Main_Description as description'])->toJson(); case 'Products': return Products::whereNull("Deleted")->orderBy('Product_Title', 'asc')->get(['id_Product as id', 'Product_Title as description'])->toArray(); case 'Events': return Event::all(['id_Event as id', 'Event_Title as description'])->toJson(); } }