Пример #1
0
 public function noteSociete($id, $back)
 {
     $notes = DB::table('societes')->join('contacts', 'societes.id', '=', 'contacts.societe_id')->join('notes', 'contacts.id', '=', 'notes.contact_id')->select('notes.*', 'contacts.nom_contact', 'societes.id AS ste')->where('societes.id', '=', $id)->where('notes.etat', '=', '1')->paginate(15);
     $actif = 'notes';
     $profil = Societe::findOrFail($id);
     return View::make('notes.notes-societe', compact('notes', 'back', 'actif', 'profil'));
 }
Пример #2
0
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $actif = 0;
     $preference = Preference::first();
     $notes = Note::where('etat', 1)->orderBy('created_at', 'desc')->paginate(5);
     $contacts = Contact::where('etat', 1)->orderBy('created_at', 'desc')->paginate(5);
     $societes = Societe::where('etat', 1)->orderBy('created_at', 'desc')->paginate(5);
     $devis = Devis::where('etat_devis', 1)->orderBy('created_at', 'desc')->paginate(5);
     return view('accueil', compact('actif', 'preference', 'notes', 'contacts', 'societes', 'devis'));
 }
Пример #3
0
 public function evenement(Request $request)
 {
     $groupe['null'] = '';
     $ListGroupeCRM = DB::table('groupes')->select('id', 'nom_groupe', 'date_groupe')->get();
     foreach ($ListGroupeCRM as $key => $value) {
         $groupe[$value->id] = $value->nom_groupe . ' ' . $value->date_groupe;
     }
     $id = $request->input('groupe');
     $visite = Societe::where('etat', 1)->where('groupe_id', $id)->count();
     $presentation = DB::table('societes')->join('contacts', 'societes.id', '=', 'contacts.societe_id')->join('notes', 'contacts.id', '=', 'notes.contact_id')->select('notes.*', 'contacts.nom_contact', 'societes.id AS ste')->where('societes.groupe_id', '=', $id)->where('societes.etat', '=', '1')->where('notes.categorie', '=', 'Réunion')->count();
     $actif = 'rapport';
     return view('rapport.event', compact('actif', 'visite', 'presentation', 'groupe', 'id'));
 }
Пример #4
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     //
     Excel::create('ExportAllContact', function ($excel) {
         $excel->sheet('Sheetname', function ($sheet) {
             $data = Societe::all();
             $i = 1;
             foreach ($data as $data) {
                 $extract[$i] = ['Nom de la société' => $data->nom_clt, 'Effectif' => $data->effectif_clt, 'Chiffre d\'affaire' => $data->ca_clt, 'N° TVA' => $data->num_tva_clt, 'URL' => $data->url_clt, 'Téléphone' => $data->tel_siege_clt, 'Fax' => $data->fax_siege_clt, 'E-mail' => $data->email_siege_clt, 'Pays' => $data->pays_clt, 'Ville' => $data->ville_siege_clt, 'Adresse' => $data->adresse_siege_clt, 'Commentaire' => $data->comment_clt];
                 $i++;
             }
             $sheet->fromArray($extract);
         });
     })->export('xls');
     return redirect(route('export.index'));
 }
Пример #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $i = 0;
     $path = $_FILES['contact']['tmp_name'];
     $results = Excel::load($path)->get();
     foreach ($results as $value) {
         if (!empty($value->societe)) {
             $import[$i] = $value;
         }
         $i++;
     }
     var_dump($import);
     dd();
     foreach ($import as $value) {
         Societe::create(['nom_clt' => $value->societe, 'effectif_clt' => $value->effectif, 'ca_clt' => $value->chiffre_daffaire, 'comment_clt' => $value->commentaire, 'num_tva_clt' => $value->n_tva, 'url_clt' => $value->url, 'tel_siege_clt' => $value->telephone, 'fax_siege_clt' => $value->fax, 'email_siege_clt' => $value->e_mail, 'ville_siege_clt' => $value->ville, 'pays_clt' => $value->pays, 'adresse_siege_clt' => $value->adresse]);
     }
     return redirect('import');
 }
Пример #6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function editer($id)
 {
     //
     $actif = 'gescom';
     $societes[''] = '';
     $societes[0] = 'Tous les contacts';
     $contacts[''] = '';
     $gescom = Gescom::first();
     $societe = Societe::select('id', 'nom_clt')->where('etat', 1)->get();
     $contact = Contact::select('id', 'nom_contact', 'prenoms_contact')->where('etat', 1)->get();
     $modules[''] = '';
     $module = Module::where('etat_module', 1)->orderBy('nom_module', 'asc')->get();
     // Remplissage du tableau des modules
     foreach ($module as $key => $value) {
         foreach ($value->produits as $pkey => $pvalue) {
             $modules[$value->id . '.' . $pvalue->id] = $value->nom_module . ' (' . $pvalue->nom_produit . ')';
         }
     }
     // Remplissage du tableau des sociétés
     foreach ($societe as $key => $value) {
         $societes[$value->id] = $value->nom_clt;
     }
     // Remplissage du tableau des contacts
     foreach ($contact as $key => $value) {
         $contacts[$value->id] = $value->nom_contact . ' ' . $value->prenoms_contact;
     }
     $profil = Devis::with('gescom', 'societedata')->findOrfail($id);
     foreach ($profil->modules as $key => $value) {
         $produit_id = $value->pivot->produit_id;
     }
     $produit = Produit::findOrFail($produit_id);
     $produits = $produit->modules;
     $actif = 'gescom';
     return view('gescom.edit-devis', compact('actif', 'profil', 'produits', 'contacts', 'gescom', 'societes', 'modules'));
 }
Пример #7
0
        $module = Module::select('prix_module')->findOrFail($id);
        $produit = Produit::select('nom_produit', 'vers_produit')->findOrFail($id_produit);
        $data['module']['prix_module'] = $module->prix_module;
        $data['produit']['id'] = $id_produit;
        $data['produit']['nom'] = 'Licence ' . $produit->nom_produit . ' Version ' . $produit->vers_produit;
    }
    return json_encode($data);
});
/**** Ajax for others pages ***/
Route::get('/SocieteSelect', function () {
    if (Request::ajax()) {
        $id = Request::get('id');
        if ($id == 0) {
            $contacts = Contact::select('id', 'nom_contact', 'prenoms_contact')->where('etat', 1)->get();
        } else {
            $contacts = Societe::findOrFail($id)->contacts()->where('etat', 1)->get();
        }
        if ($contacts->isEmpty()) {
            $data = [];
        } else {
            foreach ($contacts as $key => $value) {
                $data[$value->id] = $value->nom_contact . ' ' . $value->prenoms_contact;
            }
        }
    }
    return json_encode($data);
});
Route::get('/ContactSelect', function () {
    if (Request::ajax()) {
        $id = Request::get('id');
        $adresse = DB::table('contacts')->select('societe_id')->where('id', $id)->get();
Пример #8
0
|
*/
/* Test Page */
Route::get('test', function () {
    return view('test');
});
/* Home View Route */
Route::get('/', 'WelcomeController@index');
/* Societe & Contact Views Routes */
Route::post('societe/action', ['as' => 'societe.action', function () {
    $data = Request::all();
    if (Request::input('supp')) {
        if ($data['type'] == 0) {
            foreach ($data as $key => $value) {
                if (substr($key, 0, 1) == 'c') {
                    $profil = Societe::findOrFail($value);
                    var_dump($profil);
                    dd();
                    $profil->update(['etat' => 0]);
                }
                return redirect(route('societe.index'));
            }
            // return  redirect(route('societe.index'));
        } else {
            return 'suppression contact';
        }
    }
    if (Request::input('export')) {
        if ($data['type'] == 0) {
            return 'export  societe';
        } else {
Пример #9
0
 public function DeleteCheckedDocs(Request $request)
 {
     $i = 1;
     $data = $request->all();
     if ($request->input('supp')) {
         if ($data['type'] == 0 || $data['type'] == 3) {
             foreach ($data as $key => $value) {
                 if (substr($key, 0, 1) == 'c') {
                     $profil = Societe::findOrFail($value);
                     $profil->update(['etat' => 0]);
                 }
             }
         } elseif ($data['type'] == 1) {
             foreach ($data as $key => $value) {
                 if (substr($key, 0, 1) == 'c') {
                     $profil = Contact::findOrFail($value);
                     $profil->update(['etat' => 0]);
                 }
             }
         } elseif ($data['type'] == 2) {
             foreach ($data as $key => $value) {
                 if (substr($key, 0, 1) == 'c') {
                     $profil = Groupe::findOrFail($value);
                     $profil->update(['etat' => 0]);
                 }
             }
         }
     }
     // Import de contacts
     if ($request->input('export')) {
         Excel::create('ExportContact', function ($excel) {
             $excel->sheet('Sheetname', function ($sheet) {
                 $donnees = Input::all();
                 $j = 0;
                 if ($donnees['type'] == 0 || $donnees['type'] == 3) {
                     foreach ($donnees as $key => $value) {
                         if (substr($key, 0, 1) == 'c') {
                             $profil = Societe::findOrFail($value);
                             $export[$key] = $profil;
                         }
                     }
                     foreach ($export as $donnees) {
                         $extract[$j] = ['Nom de la société' => $donnees->nom_clt, 'Effectif' => $donnees->effectif_clt, 'Chiffre d\'affaire' => $donnees->ca_clt, 'N° TVA' => $donnees->num_tva_clt, 'URL' => $donnees->url_clt, 'Téléphone' => $donnees->tel_siege_clt, 'Fax' => $donnees->fax_siege_clt, 'E-mail' => $donnees->email_siege_clt, 'Pays' => $donnees->pays_clt, 'Ville' => $donnees->ville_siege_clt, 'Adresse' => $donnees->adresse_siege_clt, 'Commentaire' => $donnees->comment_clt];
                         $j++;
                     }
                 } elseif ($donnees['type'] == 1) {
                     foreach ($donnees as $key => $value) {
                         if (substr($key, 0, 1) == 'c') {
                             $profil = Contact::with(['societe' => function ($query) {
                                 $query->with(['groupe'])->select('nom_clt', 'id', 'groupe_id');
                             }])->findOrFail($value);
                             $export[$key] = $profil;
                         }
                     }
                     foreach ($export as $donnees) {
                         $extract[$j] = ['Civilité' => $donnees->genre_contact, 'Nom' => $donnees->nom_contact, 'Prénom' => $donnees->prenoms_contact, 'Société' => isset($donnees->societe->nom_clt) ? $donnees->societe->nom_clt : NULL, 'Groupe' => isset($donnees->societe->groupe->nom_groupe) ? $donnees->societe->groupe->nom_groupe . ' ' . $donnees->societe->groupe->date_groupe : NULL, 'Fonction' => $donnees->fonction_contact, 'Service' => $donnees->service_contact, 'Description' => $donnees->description_contact, 'Téléphone' => $donnees->tel_contact, 'E-mail' => $donnees->email_contact, 'Adresse' => $donnees->adresse_contact];
                         $j++;
                     }
                 } elseif ($donnees['type'] == 2) {
                     foreach ($donnees as $key => $value) {
                         if (substr($key, 0, 1) == 'c') {
                             $profil = Groupe::findOrFail($value)->societe()->where('etat', 1)->get();
                             foreach ($profil as $pkey => $pvalue) {
                                 $export[$key] = $pvalue;
                             }
                         }
                     }
                     var_dump($export);
                     dd();
                     foreach ($export as $donnees) {
                         $extract[$j] = ['Civilité' => $donnees->genre_contact, 'Nom' => $donnees->nom_contact, 'Prénom' => $donnees->prenoms_contact, 'Société' => isset($donnees->societe->nom_clt) ? $donnees->societe->nom_clt : NULL, 'Groupe' => isset($donnees->societe->groupe->nom_groupe) ? $donnees->societe->groupe->nom_groupe . ' ' . $donnees->societe->groupe->date_groupe : NULL, 'Fonction' => $donnees->fonction_contact, 'Service' => $donnees->service_contact, 'Description' => $donnees->description_contact, 'Téléphone' => $donnees->tel_contact, 'E-mail' => $donnees->email_contact, 'Adresse' => $donnees->adresse_contact];
                         $j++;
                     }
                 }
                 $sheet->fromArray($extract);
             });
         })->export('xls');
     }
     // Import des contacts à partir du Groupe CRM
     if ($request->input('export')) {
         Excel::create('ExportContact', function ($excel) {
             $excel->sheet('Sheetname', function ($sheet) {
                 $donnees = Input::all();
                 $j = 0;
                 if ($donnees['type'] == 0) {
                     foreach ($donnees as $key => $value) {
                         if (substr($key, 0, 1) == 'c') {
                             $profil = Societe::findOrFail($value);
                             $export[$key] = $profil;
                         }
                     }
                     foreach ($export as $donnees) {
                         $extract[$j] = ['Nom de la société' => $donnees->nom_clt, 'Effectif' => $donnees->effectif_clt, 'Chiffre d\'affaire' => $donnees->ca_clt, 'N° TVA' => $donnees->num_tva_clt, 'URL' => $donnees->url_clt, 'Téléphone' => $donnees->tel_siege_clt, 'Fax' => $donnees->fax_siege_clt, 'E-mail' => $donnees->email_siege_clt, 'Pays' => $donnees->pays_clt, 'Ville' => $donnees->ville_siege_clt, 'Adresse' => $donnees->adresse_siege_clt, 'Commentaire' => $donnees->comment_clt];
                         $j++;
                     }
                 } else {
                     foreach ($donnees as $key => $value) {
                         if (substr($key, 0, 1) == 'c') {
                             $profil = Contact::with(['societe' => function ($query) {
                                 $query->with(['groupe'])->select('nom_clt', 'id', 'groupe_id');
                             }])->findOrFail($value);
                             $export[$key] = $profil;
                         }
                     }
                     foreach ($export as $donnees) {
                         $extract[$j] = ['Civilité' => $donnees->genre_contact, 'Nom' => $donnees->nom_contact, 'Prénom' => $donnees->prenoms_contact, 'Société' => isset($donnees->societe->nom_clt) ? $donnees->societe->nom_clt : NULL, 'Groupe' => isset($donnees->societe->groupe->nom_groupe) ? $donnees->societe->groupe->nom_groupe . ' ' . $donnees->societe->groupe->date_groupe : NULL, 'Fonction' => $donnees->fonction_contact, 'Service' => $donnees->service_contact, 'Description' => $donnees->description_contact, 'Téléphone' => $donnees->tel_contact, 'E-mail' => $donnees->email_contact, 'Adresse' => $donnees->adresse_contact];
                         $j++;
                     }
                 }
                 $sheet->fromArray($extract);
             });
         })->export('xls');
     }
     // Ajout de note
     if ($request->input('add_note')) {
         if ($data['type'] == 0) {
             echo 'Bonjour nouvelle';
             dd();
             foreach ($data as $key => $value) {
                 if (substr($key, 0, 1) == 'c') {
                     $profil = Societe::findOrFail($value);
                     $profil->update(['etat' => 0]);
                 }
             }
         } else {
             echo 'Contact';
         }
     }
     if ($data['type'] == 0) {
         return redirect(route('societe.index'));
     } else {
         return redirect(route('contact.index'));
     }
 }
Пример #10
0
 public function creercontact($id)
 {
     $actif = 'contact';
     $societe = Societe::select('nom_clt')->findOrFail($id);
     return view('contact.creer-contact', compact('actif', 'id', 'societe'));
 }
Пример #11
0
 public function searchablesociete(Request $request)
 {
     $type = 0;
     $tri = 'none';
     $actif = 'contact';
     $societe = new Societe();
     if (isset($request->nom) && !empty($request->nom)) {
         $mode = 'nom';
         $tri = 'alpha';
         $query = $request->nom;
         $societe->setSearchable(['columns' => ['nom_clt' => 10]]);
         $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
     } elseif ($request->pays && !empty($request->pays)) {
         $mode = 'pays';
         $tri = 'pays';
         $query = $request->pays;
         $societe->setSearchable(['columns' => ['pays_clt' => 10]]);
         $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
     } elseif ($request->tel && !empty($request->tel)) {
         $mode = 'tel';
         $query = $request->tel;
         $societe->setSearchable(['columns' => ['tel_siege_clt' => 10]]);
         $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
     } elseif ($request->ville && !empty($request->ville)) {
         $mode = 'ville';
         $tri = 'ville';
         $query = $request->ville;
         $societe->setSearchable(['columns' => ['ville_siege_clt' => 10]]);
         $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
     } elseif ($request->adresse && !empty($request->adresse)) {
         $query = 'adresse';
         $mode = $request->adresse;
         $societe->setSearchable(['columns' => ['adresse_siege_clt' => 30]]);
         $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
     }
     // Tri des résultats de la recherche
     if (isset($_GET['sort'])) {
         $query = $_GET['query'];
         // Tri sur recherche par nom
         if ($_GET['mode'] == 'nom') {
             $mode = 'nom';
             if ($_GET['sort'] == 'pays_clt') {
                 $tri = 'pays';
             } elseif ($_GET['sort'] == 'ville_siege_clt') {
                 $tri = "ville";
             } elseif ($_GET['sort'] == 'statut') {
                 $tri = "client";
             } elseif ($_GET['sort'] == 'nom_clt') {
                 $tri = "alpha";
             } elseif ($_GET['sort'] == 'created_at') {
                 $tri = "ajout";
             } elseif ($_GET['sort'] == 'updated_at') {
                 $tri = "modif";
             } elseif ($_GET['sort'] == 'notes') {
                 $note = DB::table('societes')->join('contacts', 'societes.id', '=', 'contacts.societe_id')->join('notes', 'contacts.id', '=', 'notes.contact_id')->select('societes.*', 'notes.*')->where('societes.etat', 1)->get();
                 $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
                 $tri = 'notes';
                 // Tri des contacts sans note
                 foreach ($societes as $key => $value) {
                     $exist = 0;
                     foreach ($note as $keyn => $valuen) {
                         if ($value->nom_clt == $valuen->nom_clt) {
                             $exist = 1;
                         }
                     }
                     if ($exist == 0) {
                         $societe[] = $value;
                     }
                 }
             }
             $societe->setSearchable(['columns' => ['nom_clt' => 10]]);
             $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
         }
         // Tri sur recherche par pays
         if ($_GET['mode'] == 'pays') {
             $mode = 'pays';
             if ($_GET['sort'] == 'pays_clt') {
                 $tri = 'pays';
             } elseif ($_GET['sort'] == 'ville_siege_clt') {
                 $tri = "ville";
             } elseif ($_GET['sort'] == 'statut') {
                 $tri = "client";
             } elseif ($_GET['sort'] == 'nom_clt') {
                 $tri = "alpha";
             } elseif ($_GET['sort'] == 'created_at') {
                 $tri = "ajout";
             } elseif ($_GET['sort'] == 'updated_at') {
                 $tri = "modif";
             } elseif ($_GET['sort'] == 'notes') {
                 $tri = "notes";
             }
             $societe->setSearchable(['columns' => ['pays_clt' => 10]]);
             $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
         }
         // Tri sur recherche par téléphone
         if ($_GET['mode'] == 'tel') {
             $mode = 'tel';
             if ($_GET['sort'] == 'pays_clt') {
                 $tri = 'pays';
             } elseif ($_GET['sort'] == 'ville_siege_clt') {
                 $tri = "ville";
             } elseif ($_GET['sort'] == 'statut') {
                 $tri = "client";
             } elseif ($_GET['sort'] == 'nom_clt') {
                 $tri = "alpha";
             } elseif ($_GET['sort'] == 'created_at') {
                 $tri = "ajout";
             } elseif ($_GET['sort'] == 'updated_at') {
                 $tri = "modif";
             } elseif ($_GET['sort'] == 'notes') {
                 $tri = "notes";
             }
             $societe->setSearchable(['columns' => ['tel_siege_clt' => 10]]);
             $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
         }
         // Tri sur recherche par Ville
         if ($_GET['mode'] == 'ville') {
             $mode = 'ville';
             if ($_GET['sort'] == 'pays_clt') {
                 $tri = 'pays';
             } elseif ($_GET['sort'] == 'ville_siege_clt') {
                 $tri = "ville";
             } elseif ($_GET['sort'] == 'statut') {
                 $tri = "client";
             } elseif ($_GET['sort'] == 'nom_clt') {
                 $tri = "alpha";
             } elseif ($_GET['sort'] == 'created_at') {
                 $tri = "ajout";
             } elseif ($_GET['sort'] == 'updated_at') {
                 $tri = "modif";
             } elseif ($_GET['sort'] == 'notes') {
                 $tri = "notes";
             }
             $societe->setSearchable(['columns' => ['ville_siege_clt' => 10]]);
             $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
         }
         // Tri sur recherche par téléphone
         if ($_GET['mode'] == 'adresse') {
             $mode = 'adresse';
             if ($_GET['sort'] == 'pays_clt') {
                 $tri = 'pays';
             } elseif ($_GET['sort'] == 'ville_siege_clt') {
                 $tri = "ville";
             } elseif ($_GET['sort'] == 'statut') {
                 $tri = "client";
             } elseif ($_GET['sort'] == 'nom_clt') {
                 $tri = "alpha";
             } elseif ($_GET['sort'] == 'created_at') {
                 $tri = "ajout";
             } elseif ($_GET['sort'] == 'updated_at') {
                 $tri = "modif";
             } elseif ($_GET['sort'] == 'notes') {
                 $tri = "notes";
             }
             $societe->setSearchable(['columns' => ['adresse_siege_clt' => 10]]);
             $societe = $societe->search($query)->sortable()->where('etat', 1)->get();
         }
     }
     return view('contact.contact', compact('actif', 'societe', 'type', 'tri', 'query', 'mode'));
 }
Пример #12
0
 /**
  * Return Societe Sort to View.
  *
  * @param  int  $id
  * @return Response
  */
 public function TriSociete($tripar)
 {
     //
     $actif = 'contact';
     $type = 0;
     if ($tripar == 'pays') {
         $societe = Societe::where('etat', 1)->orderBy('pays_clt', 'asc')->get();
         $tri = 'pays';
     } elseif ($tripar == 'notes') {
         $societe = Societe::where('etat', 1)->orderBy('pays_clt', 'asc')->get();
         $tri = 'notes';
     } elseif ($tripar == 'groupe') {
         $societe = DB::table('societes')->leftjoin('groupes', 'societes.groupe_id', '=', 'groupes.id')->orderBy('groupes.nom_groupe', 'asc')->where('societes.etat', 1)->get();
         $tri = 'groupe';
     } elseif ($tripar == 'ajout') {
         $societe = Societe::where('etat', 1)->orderBy('created_at', 'desc')->get();
         $tri = 'ajout';
     } elseif ($tripar == 'modification') {
         $societe = Societe::where('etat', 1)->orderBy('updated_at', 'desc')->get();
         $tri = 'modif';
     } elseif ($tripar == 'alpha') {
         $societe = Societe::where('etat', 1)->orderBy('nom_clt', 'asc')->get();
         $tri = 'alpha';
     } elseif ($tripar == 'client') {
         $societe = Societe::where('etat', 1)->orderBy('nom_clt', 'asc')->get();
         $tri = 'client';
     }
     return view('contact.contact', compact('actif', 'societe', 'type', 'tri'));
 }
Пример #13
0
 public function Trigroupe($tripar, $id)
 {
     //
     $actif = 'contact';
     $type = 3;
     if ($tripar == 'pays') {
         $societegr = Groupe::findOrFail($id)->societe()->where('etat', 1)->orderBy('pays_clt', 'asc')->get();
         $tri = 'pays';
     } elseif ($tripar == 'notes') {
         $note = DB::table('societes')->join('contacts', 'societes.id', '=', 'contacts.societe_id')->join('notes', 'contacts.id', '=', 'notes.contact_id')->select('societes.*', 'notes.*')->where('societes.etat', 1)->get();
         $societes = Societe::where('etat', 1)->orderBy('nom_clt', 'asc')->get();
         $tri = 'notes';
         // Tri des contacts sans note
         foreach ($societes as $key => $value) {
             $exist = 0;
             foreach ($note as $keyn => $valuen) {
                 if ($value->nom_clt == $valuen->nom_clt) {
                     $exist = 1;
                 }
             }
             if ($exist == 0) {
                 $societegr[] = $value;
             }
         }
     } elseif ($tripar == 'ajout') {
         $societegr = Groupe::findOrFail($id)->societe()->where('etat', 1)->orderBy('created_at', 'asc')->get();
         $tri = 'ajout';
     } elseif ($tripar == 'modification') {
         $societegr = Groupe::findOrFail($id)->societe()->where('etat', 1)->orderBy('udpated_at', 'asc')->get();
         $tri = 'modif';
     } elseif ($tripar == 'alpha') {
         $societegr = Groupe::findOrFail($id)->societe()->where('etat', 1)->orderBy('nom_clt', 'desc')->get();
         $tri = 'alpha';
     } elseif ($tripar == 'client') {
         $societegr = Groupe::findOrFail($id)->societe()->where('etat', 1)->orderBy('statut', 'asc')->get();
         $tri = 'client';
     }
     return view('contact.contact', compact('actif', 'societegr', 'type', 'tri', 'note'));
 }
Пример #14
0
 /**
  * Return Societe Sort to View.
  *
  * @param  int  $id
  * @return Response
  */
 public function TriSociete($tripar)
 {
     //
     $actif = 'contact';
     $type = 0;
     if ($tripar == 'pays') {
         //$societe = Societe::where('etat',1)->orderBy('pays_clt','asc')->get();
         $societes = new Societe();
         $type = 4;
         $societe = $societes->sortable()->where('etat', 1)->get();
         $tri = 'pays';
         return view('contact.contact', compact('actif', 'societe', 'type', 'tri'));
     } elseif ($tripar == 'notes') {
         $note = DB::table('societes')->join('contacts', 'societes.id', '=', 'contacts.societe_id')->join('notes', 'contacts.id', '=', 'notes.contact_id')->select('societes.*', 'notes.*')->where('societes.etat', 1)->get();
         $societes = Societe::where('etat', 1)->orderBy('nom_clt', 'asc')->get();
         $tri = 'notes';
         // Tri des contacts sans note
         foreach ($societes as $key => $value) {
             $exist = 0;
             foreach ($note as $keyn => $valuen) {
                 if ($value->nom_clt == $valuen->nom_clt) {
                     $exist = 1;
                 }
             }
             if ($exist == 0) {
                 $societe[] = $value;
             }
         }
     } elseif ($tripar == 'groupe') {
         $societe = DB::table('groupes')->rightjoin('societes', 'societes.groupe_id', '=', 'groupes.id')->orderBy('groupes.nom_groupe', 'asc')->where('societes.etat', 1)->get();
         foreach ($societe as $value) {
             echo $value->nom_clt . ' => ' . $value->nom_groupe . ' => ' . $value->statut . '<br/>';
         }
         dd();
         $categorie = Societe::where('etat', 1)->orderBy('statut', 'asc')->get();
         $tri = 'groupe';
         return view('contact.contact', compact('actif', 'societe', 'type', 'tri', 'categorie', 'groupe'));
     } elseif ($tripar == 'ajout') {
         $societe = Societe::where('etat', 1)->orderBy('created_at', 'desc')->get();
         $tri = 'ajout';
     } elseif ($tripar == 'modification') {
         $societe = Societe::where('etat', 1)->orderBy('updated_at', 'desc')->get();
         $tri = 'modif';
     } elseif ($tripar == 'alpha') {
         $societe = Societe::where('etat', 1)->orderBy('nom_clt', 'desc')->get();
         $tri = 'alpha';
     } elseif ($tripar == 'client') {
         $societe = Societe::where('etat', 1)->orderBy('statut', 'asc')->get();
         $tri = 'client';
     }
     return view('contact.contact', compact('actif', 'societe', 'type', 'tri', 'note'));
 }
Пример #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $i = 0;
     $j = 0;
     $import_one[0] = '';
     $import[0] = '';
     $societe = Societe::get();
     $path = $_FILES['contact']['tmp_name'];
     $results = Excel::load($path)->get();
     foreach ($results as $value) {
         if (!empty($value->societe)) {
             $import_merge[$i] = $value;
         }
         $i++;
     }
     // Contrôles de doublons dans le fichier Importer
     foreach ($import_merge as $key => $value) {
         $exist = 0;
         foreach ($import_one as $ikey => $ivalue) {
             if ($value == $ivalue) {
                 $exist = 1;
             }
         }
         if ($exist == 0) {
             $import_one[$key] = $value;
         }
         $i++;
     }
     // Contrôle de de l'existance dans la base de données
     foreach ($import_one as $key => $value) {
         $exist = 0;
         foreach ($societe as $skey => $svalue) {
             if ($value->societe == $svalue->nom_clt) {
                 $exist = 1;
             }
         }
         if ($exist == 0) {
             $import[$key] = $value;
         }
         $i++;
     }
     if ($import[0] != '') {
         foreach ($import as $value) {
             Societe::create(['nom_clt' => $value->societe, 'effectif_clt' => $value->effectif, 'ca_clt' => $value->chiffre_daffaire, 'comment_clt' => $value->commentaire, 'num_tva_clt' => $value->n_tva, 'url_clt' => $value->url, 'tel_siege_clt' => $value->telephone, 'fax_siege_clt' => $value->fax, 'email_siege_clt' => $value->e_mail, 'ville_siege_clt' => $value->ville, 'pays_clt' => ucfirst(strtolower($value->pays)), 'adresse_siege_clt' => $value->adresse]);
         }
     }
     return redirect('import');
 }