Ejemplo n.º 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'));
 }
Ejemplo n.º 2
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();
Ejemplo n.º 3
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 {
Ejemplo n.º 4
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'));
     }
 }
Ejemplo n.º 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $profil = Societe::findOrFail($id);
     $profil->update(['etat' => 0]);
     return redirect(route('societe.index'));
 }
Ejemplo n.º 6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $contacts = Societe::findOrFail($id)->contacts()->select('id')->where('etat', 1)->get();
     if (!empty($contacts->id)) {
         foreach ($contacts as $value) {
             $contact = Contact::findOrFail($value->id);
             $contact->update(['etat' => 0]);
         }
         foreach ($contact as $value) {
             $contact->update(['etat' => 0]);
         }
     }
     $profil = Societe::findOrFail($id);
     $profil->update(['etat' => 0]);
     return redirect(route('societe.index'));
 }