Пример #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateSocieteRequest $request)
 {
     //
     $client = new Client();
     $params = array();
     Societe::create($request->all());
     $id = DB::table('societes')->select('id')->orderBy('id', 'desc')->first();
     foreach ($id as $value) {
         $id = $value;
     }
     $params['body'] = ['nom' => $request->input('nom_clt'), 'pays' => $request->input('pays_clt')];
     $params['index'] = 'ftz';
     $params['type'] = 'societes';
     $params['id'] = $id;
     $indexes = $client->index($params);
     $actif = 'contact';
     return redirect('societe');
 }
Пример #2
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');
 }
Пример #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateSocieteRequest $request)
 {
     //
     $client = new Client();
     $params = array();
     $societecheck = $request->input('nom_clt');
     $check = DB::table('societes')->select('nom_clt')->where('nom_clt', $societecheck)->count();
     if ($check == 0) {
         $data = $request->except(['groupe_id', 'add_contact']);
         $societe = Societe::create($data);
         $societe->groupes()->sync($request->input('groupe_id'));
         $id = DB::table('societes')->select('id')->orderBy('id', 'desc')->first();
         foreach ($id as $value) {
             $id = $value;
         }
         // $params['body']  = ['nom'=>$request->input('nom_clt'),'pays'=>$request->input('pays_clt')];
         // $params['index'] = 'ftz';
         // $params['type']  = 'societes';
         // $params['id']    = $id;
         // $indexes = $client->index($params);
         $actif = 'contact';
         if ($request->input('add_contact')) {
             return redirect(route('creer.contact', $id));
         } else {
             return redirect(route('societe.show', $id));
         }
     } else {
         return redirect('creer-societe')->withInput()->withErrors('Société Déjà existante');
     }
 }
Пример #4
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');
 }