diff --git a/app/Http/Controllers/EnterCodeController.php b/app/Http/Controllers/EnterCodeController.php new file mode 100644 index 0000000..f85af81 --- /dev/null +++ b/app/Http/Controllers/EnterCodeController.php @@ -0,0 +1,48 @@ +select('use_ean_codes')->first(); + return view('front.basic.enter-code', compact('settings')); + } + + public function participate(Request $request) { + $code = $request->code; + $settings = Settings::select('use_ean_codes')->first(); + if ($settings->use_ean_codes) { + $codeEan = $request->code_ean; + $eanExist = CodesEAN::where('code', $codeEan)->count(); + if ($eanExist === 0) { + return redirect()->back()->withErrors('Le code EAN entré est incorrect, veuillez réessayer.'); + } + } + $gagne = false; + // TODO : Traitement du code, instant gagnant etc + if ($gagne) { + // TODO : Retourne à la page du lot, ajouté le fait de donné l'id du lot avec + return redirect()->route('gagne'); + } else { + // Page perdu si jeu non 100% gagnant, reduction sinon + $perdant = false; + $nbDefaultPrize = Prizes::where('is_default', 1)->count(); + if ($nbDefaultPrize === 0 ) { + $perdant = true; + } + + if ($perdant) { + return redirect()->route('perdu'); + } else { + // TODO : Retourner la page de réduction avec la bonne réduction + return redirect()->route('reduction'); + } + } + } +} diff --git a/app/Http/Controllers/GainsController.php b/app/Http/Controllers/GainsController.php new file mode 100644 index 0000000..70fe2ab --- /dev/null +++ b/app/Http/Controllers/GainsController.php @@ -0,0 +1,14 @@ +middleware('guest')->except('logout'); + } + + public function index() { + return view('front.basic.login'); + } + + public function authenticate(Request $request) + { + $email = $request->email; + $password = $request->password; + $remember = $request->remember !== null ? true : false; + + $userLocal = User::where('email', $email)->first(); + + if ($userLocal) { + if ($userLocal->role !== 1) { + try { + $cpcConnect = new CPCConnection(config('crm.CRM_PLATOS_WSDL'), config('crm.WS_SERVCE_LOGIN'), config('crm.WS_SERVCE_PASSWORD')); + $cpcConnect->connect(); + try { + // ---- Authentification du user + $cpcConnect->authenticateUser ($email, $password); + } catch (Exception $e) { + return redirect()->back()->withInput($request->only("email", "password"))->withErrors("Email ou mot de passe incorrect."); + } + } catch (Exception $e) { + return redirect()->back()->withInput($request->only("email", "password"))->withErrors("La connexion est impossible pour le moment, veuillez réessayer plus tard."); + die(); + } + } + + if (Auth::attempt(["email" => $email, "password" => $password], $remember)) { + if ($userLocal->role === 1) + return redirect()->route('bo.dashboard'); + return redirect()->route('home'); + } else { + return redirect()->back()->withInput($request->only('email', 'remember'))->withErrors('Les identifiants entrés sont incorrects.'); + } + } else { + return redirect()->back()->withInput($request->only('email', 'remember'))->withErrors('Les identifiants entrés sont incorrects.'); + } + + + } + + public function logout() { + Auth::logout(); + return redirect()->route('home'); + } +} diff --git a/app/Http/Controllers/LooseController.php b/app/Http/Controllers/LooseController.php new file mode 100644 index 0000000..9a93e32 --- /dev/null +++ b/app/Http/Controllers/LooseController.php @@ -0,0 +1,12 @@ +prize; + $prize = Prizes::findOrFail($prizeId); + // TODO : Check que le participant à bien gagné avant de renvoyé la vue, sinon 404 + return view('front.basic.' . $prize->gain_view->file_name); + } + + public function reduction(Request $request) { + return view('front.basic.reduction'); + } +} diff --git a/app/Http/Controllers/RegisterController.php b/app/Http/Controllers/RegisterController.php new file mode 100644 index 0000000..edca3e1 --- /dev/null +++ b/app/Http/Controllers/RegisterController.php @@ -0,0 +1,123 @@ +middleware('guest'); + } + + public function index() { + return view('front.basic.register-crm'); + } + + public function register(Request $request) { + + $civility = $request->civility; + $lastname = filter_var($request->lastname, FILTER_SANITIZE_STRING); + $firstname = filter_var($request->firstname, FILTER_SANITIZE_STRING); + $birthDate = $request->birth_date; + $email = filter_var($request->email, FILTER_SANITIZE_EMAIL); + $username = filter_var($request->username, FILTER_SANITIZE_STRING); + $password = $request->password; + $address = filter_var($request->address, FILTER_SANITIZE_STRING); + $address2 = $request->address2 !== null ? filter_var($request->address2, FILTER_SANITIZE_STRING) : null; + $town = filter_var($request->town, FILTER_SANITIZE_STRING); + $postalCode = filter_var($request->postal_code, FILTER_SANITIZE_STRING); + $country = filter_var($request->country, FILTER_SANITIZE_STRING); + $news = $request->news !== null ? 1 : 0; + $tokenMail = Str::uuid(); + $request->validate([ + 'lastname' => 'required|string|max:255', + 'firstname' => 'required|string|max:255', + 'birth_date' => 'required|date|before_or_equal:' . Carbon::now()->subYear(18)->toDateString(), + 'email' => 'required|string|email|max:255|unique:users', + 'username' => 'required|string|min:3|max:255', + 'password' => 'required|string|min:8|confirmed', + 'address' => 'required|string|max:255', + 'address2' => 'max:255', + 'town' => 'required|string|max:255', + 'postal_code' => 'required|string|max:255', + 'country' => 'required|string|max:255', + ]); + + $crmId = null; + + try { + $cpcConnect = new CPCConnection(config('crm.CRM_PLATOS_WSDL'), config('crm.WS_SERVCE_LOGIN'), config('crm.WS_SERVCE_PASSWORD')); + $cpcConnect->connect(); + + try { + $oCrmUser = new CPCUser(); + $oCrmUser->zCivilite = $civility; + $oCrmUser->zNom = $lastname ; + $oCrmUser->zPrenom = $firstname ; + $oCrmUser->zDateNaissance = $birthDate; + $oCrmUser->zVille = $town ; + $oCrmUser->zCodePostal = $postalCode ; + $oCrmUser->addField ("pays", FIELDTYPE_TEXT, "", $country); + $oCrmUser->zLogin = $email ; + $oCrmUser->zEmail = $email; + $oCrmUser->zPassword = $password; + if($news == 1) $oCrmUser->iInscritNewLetter = $news ; + $oCrmUser->iId = $cpcConnect->createUser($oCrmUser, 0); + $crmId = $oCrmUser->iId; + // TODO : Envoi de mail pour confirmation + + } catch (Exception $e) { + return redirect()->back() + ->withInput($request->only("lastname","firstname","birth_date","email","username", "address", "address2", "town", "postal_code", "country")) + ->withErrors("Un compte utilisateur est déjà associé à votre email. Modifiez votre email ou connectez vous avec ce compte."); + } + } catch (Exception $e) { + return redirect()->back() + ->withInput($request->only("lastname","firstname","birth_date","email","username", "address", "address2", "town", "postal_code", "country")) + ->withErrors("Une erreur est survenue, merci de recommencer."); + } + + User::create([ + 'crm_id' => $crmId, + 'civility' => $civility, + 'firstname' => $firstname, + 'lastname' => $lastname, + 'birth_date' => $birthDate, + 'email' => $email, + 'username' => $username, + 'password' => Hash::make($password), + 'address' => $address, + 'address2' => $address2, + 'town' => $town, + 'postal_code' => $postalCode, + 'country' => $country, + 'email_verify_token' => $tokenMail, + ]); + + $credentials = $request->only('email', 'password'); + + if (Auth::attempt($credentials)) { + return redirect()->route('home'); + } + + return redirect()->route('home'); + } +} diff --git a/app/Http/Controllers/VerificationController.php b/app/Http/Controllers/VerificationController.php new file mode 100644 index 0000000..cd04ba5 --- /dev/null +++ b/app/Http/Controllers/VerificationController.php @@ -0,0 +1,21 @@ +first(); + if ($user != null) { + $user->email_verified_at = now(); + $user->save(); + return true; + } else { + return false; + } + } +} diff --git a/app/Http/Controllers/bo/GainViewController.php b/app/Http/Controllers/bo/GainViewController.php index eea79c6..0611d8b 100644 --- a/app/Http/Controllers/bo/GainViewController.php +++ b/app/Http/Controllers/bo/GainViewController.php @@ -30,22 +30,17 @@ class GainViewController extends Controller public function saveDatas(Request $request) { $gv = $request->gainViews; - try { - for ($i = 0; $i < count($gv); $i++) { - if (isset($gv[$i]["id"])) { - $g = GainView::findOrFail($gv[$i]["id"]); - $g->name = $gv[$i]["name"]; - $g->file_name = $gv[$i]["file_name"]; - $g->slug_route = $gv[$i]["slug_route"]; - $g->save(); - } else { - $g = GainView::updateOrCreate(['name' => $gv[$i]["name"], 'file_name' => $gv[$i]["file_name"], 'slug_route' => $gv[$i]["slug_route"]]); - $gv[$i]["id"] = $g->id; - } + for ($i = 0; $i < count($gv); $i++) { + if (isset($gv[$i]["id"])) { + $g = GainView::findOrFail($gv[$i]["id"]); + $g->name = $gv[$i]["name"]; + $g->file_name = $gv[$i]["file_name"]; + $g->slug_route = $gv[$i]["slug_route"]; + $g->save(); + } else { + $g = GainView::updateOrCreate(['name' => $gv[$i]["name"], 'file_name' => $gv[$i]["file_name"], 'slug_route' => $gv[$i]["slug_route"]]); + $gv[$i]["id"] = $g->id; } - } catch (Exception $e) { - // TODO : Retour erreur correct - $e->getTraceAsString(); } return $gv; diff --git a/app/Http/Controllers/bo/InstantWinController.php b/app/Http/Controllers/bo/InstantWinController.php index f5571b4..78ead3a 100644 --- a/app/Http/Controllers/bo/InstantWinController.php +++ b/app/Http/Controllers/bo/InstantWinController.php @@ -41,7 +41,6 @@ class InstantWinController extends Controller $begin = new \DateTime( $start_date ); $end = new \DateTime( $end_date ); - $end = $end->modify( '+1 day' ); $interval = new \DateInterval('P1D'); $daterange = new \DatePeriod($begin, $interval ,$end); $dateGlobal = []; diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 36ced13..0ac12a2 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -59,6 +59,7 @@ class Kernel extends HttpKernel 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'is-admin' => \App\Http\Middleware\isAdmin::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, diff --git a/app/Http/Middleware/isAdmin.php b/app/Http/Middleware/isAdmin.php new file mode 100644 index 0000000..627fbc6 --- /dev/null +++ b/app/Http/Middleware/isAdmin.php @@ -0,0 +1,24 @@ +role; + if ($role === 1) + return $next($request); + abort(404, "Cette page n'existe pas."); + } +} diff --git a/app/Mail/VerifyEmail.php b/app/Mail/VerifyEmail.php new file mode 100644 index 0000000..07a6a41 --- /dev/null +++ b/app/Mail/VerifyEmail.php @@ -0,0 +1,34 @@ +view('view.name'); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ee8ca5b..3cb1b06 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,8 @@ namespace App\Providers; +use App\Models\Settings; +use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -23,6 +25,8 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - // + // On ramène le nom du jeu et le nom de la société sur toute les pages + $settingsGlobal = Settings::find(1)->select('name', 'company')->first(); + View::share('settingsGlobal', $settingsGlobal); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 540d17b..3a816d8 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -21,7 +21,7 @@ class RouteServiceProvider extends ServiceProvider * * @var string */ - public const HOME = '/home'; + public const HOME = '/'; /** * Define your route model bindings, pattern filters, etc. diff --git a/app/User.php b/app/User.php index e79dab7..b28996a 100644 --- a/app/User.php +++ b/app/User.php @@ -16,7 +16,21 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'email', 'password', + 'crm_id', + 'civility', + 'firstname', + 'lastname', + 'birth_date', + 'email', + 'username', + 'password', + 'address', + 'address2', + 'town', + 'postal_code', + 'country', + 'email_verify_token', + 'email_verified' ]; /** diff --git a/composer.json b/composer.json index 7115b20..03316e6 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^6.3", "laravel/framework": "^7.24", - "laravel/tinker": "^2.0" + "laravel/tinker": "^2.0", + "laravel/ui": "2.4" }, "require-dev": { "facade/ignition": "^2.0", @@ -38,7 +39,8 @@ }, "classmap": [ "database/seeds", - "database/factories" + "database/factories", + "ldccrm_client" ] }, "autoload-dev": { diff --git a/config/auth.php b/config/auth.php index aaf982b..3739176 100644 --- a/config/auth.php +++ b/config/auth.php @@ -70,11 +70,6 @@ return [ 'driver' => 'eloquent', 'model' => App\User::class, ], - - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], ], /* diff --git a/config/crm.php b/config/crm.php new file mode 100644 index 0000000..1fec34b --- /dev/null +++ b/config/crm.php @@ -0,0 +1,9 @@ + env('CRM_PLATOS_WSDL'), + 'WS_SERVCE_LOGIN' => env('WS_SERVCE_LOGIN'), + 'WS_SERVCE_PASSWORD' => env('WS_SERVCE_PASSWORD'), + +]; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 621a24e..6f4b394 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,10 +15,22 @@ class CreateUsersTable extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->integer('crm_id')->nullable(); + $table->integer('civility'); + $table->string('firstname'); + $table->string('lastname'); + $table->date('birth_date'); $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); + $table->string('username'); $table->string('password'); + $table->string('address'); + $table->string('address2')->nullable(); + $table->string('town'); + $table->string('postal_code'); + $table->string('country'); + $table->string('email_verify_token'); + $table->boolean('email_verified')->default(0); + $table->integer('role')->default(2); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2020_10_28_091935_create_participation.php b/database/migrations/2020_10_28_091935_create_participation.php new file mode 100644 index 0000000..c02ef61 --- /dev/null +++ b/database/migrations/2020_10_28_091935_create_participation.php @@ -0,0 +1,44 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->foreignId('prize_id')->constrained('prizes'); + $table->string('address')->nullable(); + $table->string('address2')->nullable(); + $table->string('town')->nullable(); + $table->string('postal_code')->nullable(); + $table->string('country')->nullable(); + $table->string('phone')->nullable(); + $table->string('sticker')->nullable(); + $table->string('ticker')->nullable(); + $table->string('barcode')->nullable(); + $table->string('browser'); + $table->string('device'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('participation'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index b636659..61cb331 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -13,5 +13,6 @@ class DatabaseSeeder extends Seeder { $this->call(SettingsSeeder::class); $this->call(ContentSeeder::class); + $this->call(UserSeeder::class); } } diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php new file mode 100644 index 0000000..015caf2 --- /dev/null +++ b/database/seeds/UserSeeder.php @@ -0,0 +1,33 @@ +civility = 1; + $user->firstname = "Romain"; + $user->lastname = "Bonhomme"; + $user->birth_date = now(); + $user->email = "romain.bonhomme@ldc.fr"; + $user->username = "RomainB"; + $user->password = Hash::make("@v1tZ!r_24cA"); + $user->address = "-"; + $user->town = "Le Mans"; + $user->postal_code = "72000"; + $user->country = "France"; + $user->email_verify_token = "-"; + $user->email_verified = 1; + $user->role = 1; + $user->save(); + } +} diff --git a/ldccrm_client/CPCBon.class.php b/ldccrm_client/CPCBon.class.php new file mode 100644 index 0000000..8389be5 --- /dev/null +++ b/ldccrm_client/CPCBon.class.php @@ -0,0 +1,199 @@ +zEan128 == "") + { + throw new Exception ("Code EAN 128 vide") ; + } + return true ; + } + + /** + * Génération du code barre pour l'EAN 128 + * + */ + public function printEAN128BarCode ($_iWidth = 300, $_iHeight = 40) + { + if ($this->zEan128 != "") + { + $oCode = new CBCEan128 ($_iWidth, $_iHeight) ; + $oCode->parseHumanReadableString ($this->zEan128) ; + $oCode->showBarcodeImage () ; + } + else + { + throw new Exception ("Code EAN 128 vide") ; + } + } + + + /** + * Vérification du code pour l'EAN 13 de l'opération + * + */ + public function checkEAN13Code () + { + if ($this->zEan13 != "") + { + + $oCode = new pi_barcode () ; + $oCode->setType ("EAN") ; + $oCode->setCode ($this->zEan13) ; + + $oCode->checkCode () ; + + if ($oCode->TYPE == "ERR") + { + throw new Exception ($oCode->FULLCODE) ; + } + + } + else + { + throw new Exception ("Code EAN 128 vide") ; + } + } + + /** + * Génération du code barre pour l'EAN 13 de l'opération + * + */ + public function printEAN13BarCode ($_iWidth = 125, $_iHeight = 40) + { + if ($this->zEan13 != "") + { + + $oCode = new pi_barcode () ; + $oCode->setType ("EAN") ; + $oCode->setSize ($_iHeight, $_iWidth) ; + $oCode->setCode ($this->zEan13) ; + + $oCode->checkCode () ; + + if ($oCode->TYPE == "ERR") + { + throw new Exception ($oCode->FULLCODE) ; + } + + $oCode->showBarcodeImage () ; + + } + else + { + throw new Exception ("Code EAN 128 vide") ; + } + } + + +} + +?> \ No newline at end of file diff --git a/ldccrm_client/CPCConnection.class.php b/ldccrm_client/CPCConnection.class.php new file mode 100644 index 0000000..339baa0 --- /dev/null +++ b/ldccrm_client/CPCConnection.class.php @@ -0,0 +1,1061 @@ +zWsdlURI = $_zWsdlURI ; + // ---- Connexion auto au WS principal gérant les comptes FB des marques + if(isset($_SESSION["SESS_FB_USER"]) && $_SESSION["SESS_FB_USER"] == true && defined('CRM_WS_FB_USER') && defined('CRM_WS_FB_PWD') ){ + $this->zServiceLogin = CRM_WS_FB_USER ; + $this->zServicePassword = CRM_WS_FB_PWD ; + }else{ + $this->zServiceLogin = $_zServiceLogin ; + $this->zServicePassword = $_zServicePassword ; + } + $this->bSecured = $_bSecured ; + $this->oSoapClient = null ; + $this->bEncodeData = $_bEncodeData ; + } + + /** + * Etablissement de la connexion + * + * @return bool Statut de l'�tablissement de connexion + */ + public function connect () + { + + $bRet = true ; + try + { + $this->oSoapClient = new SoapClient ( + $this->zWsdlURI, + array ( + 'trace' => 1, + 'soap_version' => SOAP_1_1, + 'login' => $this->zServiceLogin, + 'password' => $this->zServicePassword + ) + ) ; + $bRet = true ; + } + catch (SoapFault $_eSoapFault) + { + $this->oSoapClient = null ; + $bRet = false ; + @libxml_set_streams_context () ; + throw new Exception ($_eSoapFault->getMessage ()) ; + } + + return $bRet ; + + } + + /** + * Fermeture de la connexion + * + */ + public function disconnect () + { + $this->oSoapClient = null ; + } + + /** + * Cr�ation d'un utilisateur sur la plate-forme + * + * @param CPCUser $_oNewUser L'objet utilisateur � cr�er sur la plate-forme + * @param int $_iCreationMode Mode de cr�ation avec ou sans fiabilisation E-Mail + * @return int L'identifiant de l'utilisateur � cr�er sur la plate-forme + */ + public function createUser ($_oNewUser, $_iCreationMode = CREATION_MODE_WITHOUT_CONFIRMATION_EMAIL) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $_oNewUser->check () ; + $oNewPlatosUser = $this->castUserObjectToPlatos ($_oNewUser) ; + try + { + $iRet = $this->oSoapClient->__soapCall ("createUser", array ($oNewPlatosUser, $_iCreationMode)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + catch (Exception $_eException) + { + throw new Exception ($_eException->getMessage ()) ; + } + } + catch (Exception $_oException) + { + throw new Exception ($_oException->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + + } + + /** + * Inscription au newsletter + * + * @param string $_zEmail email de l'user + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function newsletterSubscribe ($_zEmail) + { + if (is_object ($this->oSoapClient)) + { + try + { + return $this->oSoapClient->__soapCall ("newsletterSubscribe", array ($_zEmail)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + } + + + /** + * Description au newsletter + * + * @param string $_zEmail email de l'user + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function newsletterUnsubscribe ($_zEmail) + { + if (is_object ($this->oSoapClient)) + { + try + { + return $this->oSoapClient->__soapCall ("newsletterUnsubscribe", array ($_zEmail)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + } + + + /** + * Sauvegarde d'un utilisateur sur la plate-forme + * + * @param CPCUser $_oUser L'objet utilisateur � cr�er sur la plate-forme + * @return bool Statut de l'op�ration de sauvegarde + */ + public function saveUser ($_oUser) + { + + $bRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $_oUser->check () ; + $oPlatosUser = $this->castUserObjectToPlatos ($_oUser) ; + try + { + $iRet = $this->oSoapClient->__soapCall ("saveUser", array ($oPlatosUser)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + catch (Exception $_eException) + { + throw new Exception ($_eException->getMessage ()) ; + } + } + catch (Exception $_oException) + { + throw new Exception ($_oException->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $bRet ; + + } + + /** + * Chargement d'un utilisateur depuis la plate-forme + * + * @param int $_iUserId Identifiant de l'utilisateur � charger + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function getUser ($_iUserId) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ("getUser", array ($_iUserId)) ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + /** + * Chargement d'un utilisateur depuis la plate-forme + * + * @param string $_zEmail email de l'utilisateur � charger + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function getUserByEmail ($_zEmail) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ("getUserByEmail", array ($_zEmail)) ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + /** + * Chargement d'un utilisateur depuis la plate-forme + * + * @param string $_zHashCode hashcode de l'utilisateur � charger + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function getUserByHashCode ($_zHashCode) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ("getUserByHashCode", array ($_zHashCode)) ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + /** + * Chargement d'un utilisateur depuis la plate-forme + * + * @param string $_zUserHashcode Hash code de l'utilisateur � charger + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function authenticateByHashCodeUser ($_zUserHashcode) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ("authenticateByHashCodeUser", array ($_zUserHashcode)) ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + /** + * Authentification d'un utilisateur sur la plate-forme + * + * @param string $_zUserLogin Login de l'utilisateur + * @param string $_zUserPassword Mot de passe de l'utilisateur + * @return CPCUser L'objet utilisateur authentifi� ou FALSE si erreur + */ + public function authenticateUser ($_zUserLogin, $_zUserPassword) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ( + "authenticateUser", + array ( + $this->strEnvDecode ($_zUserLogin), + $this->strEnvDecode ($_zUserPassword) + ) + ) ; + //echo "
" ; + //print_r ($this->oSoapClient) ; + //echo "" ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + //echo "
" ; + //print_r ($this->oSoapClient) ; + //echo "" ; + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + /** + * Authentification d'un utilisateur sur la plate-forme + * + * @param string $_zUserHashCode Hashcode de l'utilisateur + * @return CPCUser L'objet utilisateur authentifi� ou FALSE si erreur + */ + public function authenticateUserByHashCode ($_zUserHashCode) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ( + "authenticateByHashCodeUser", + array ($this->strEnvDecode ($_zUserHashCode)) + ) ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + /** + * Activation d'un utilisateur sur la plate-forme + * + * @param int $_iUserId Identifiant de l'utilisateur � charger + * @return bool Statut de l'op�ration d'activation + */ + public function activateUser ($_iUserId) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ("activateUser", array ($_iUserId)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + + } + + /** + * Suppression d'un utilisateur sur la plate-forme + * + * @param int $_iUserId Identifiant de l'utilisateur � supprimer + * @return bool Statut de l'op�ration de suppresion + */ + public function deleteUser ($_iUserId) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ("deleteUser", array ($_iUserId)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + + } + + /** + * Changement de mot de passe d'un utilisateur sur la plate-forme + * + * @param int $_iUserId Identifiant de l'utilisateur + * @param string $_zNewPassword Nouveau mot de passe de l'utilisateur + * @return bool Statut de l'op�ration de mise � jour + */ + public function changePassword ($_iUserId, $_zNewPassword) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ( + "changePassword", + array ( + $_iUserId, + $this->strEnvDecode ($_zNewPassword) + ) + ) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + + } + + /** + * Envoi d'un email de changement de mot de passe + * + * @param int $_iUserId Identifiant de l'utilisateur + * @return bool Statut de l'op�ration + */ + public function sendChangePasswordEmail ($_iUserId) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ("sendChangePasswordEmail", array ($_iUserId)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + + } + + /** + * Ce service permet de r�cup�rer les informations n�c�ssaire � la g�n�ration d'un bon de r�duction + * + * @param int $_iUserId Utilisateur demandant le bon de reduction + * @param string $_zTypeBon Nom du type de bon + * @return CPlatosOperation Structure de couponning operation + */ + public function getBon ($_iUserId, $_zTypeBon) + { + + $oPlatosOperation = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $zTypeBon = $_zTypeBon ; + if ($this->bEncodeData) + { + $zTypeBon = $this->strEnvDecode ($zTypeBon) ; + } + $oPlatosOperation = $this->oSoapClient->__soapCall ("getBon", array ($_iUserId, $zTypeBon)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $this->castBDRFromPlatos ($oPlatosOperation) ; + + } + + + /** + * Ce service permet de fixer le statut d'un bon � "imprim�" + * + * @param int $_iUserId Utilisateur demandant l'impression du bon de reduction + * @param int $_iBonId Identifiant du bon de redution � imprimer + * @return int Resultat de l'impression + */ + public function printBon ($_iUserId, $_iBonId) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ("printBon", array ($_iUserId, $_iBonId)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + + } + + /** + * Ce service permet de cr�er un nouvel courrier entrant + * + * @param int $iUserId id de l'utilisateur + * @param int $iSujetId id du Sujet de courrier + * @param string $zCommentaire Commentaire + * @param int $iStatusId id du statut de courrier + * + * @return int Identifiant num�rique du nouveau courrier + */ + public function createInCourrier ($_iUserId, $_iSujetId, $_zCommentaire, $_iStatusId) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ("createInCourrier", array ($_iUserId, $_iSujetId, $_zCommentaire, $_iStatusId)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + } + + /** + * Ce service permet de cr�er un nouvel courrier sortant + * + * @param int $iUserId id de l'utilisateur + * @param int $iSujetId id du Sujet de courrier + * @param string $zCommentaire Commentaire + * + * @return int Identifiant num�rique du nouveau courrier + */ + public function createOutCourrier ($_iUserId, $_iSujetId, $_zCommentaire) + { + + $iRet = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $iRet = $this->oSoapClient->__soapCall ("createOutCourrier", array ($_iUserId, $_iSujetId, $_zCommentaire)) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $iRet ; + } + + /** + * Ce service permet de recup�rer les infos concernant l'utilisateur pour tous services confondus + * + * @param int $_iUserId Identifiant de l'utilisateur � charger + * @return CPCUser L'objet utilisateur r�cup�r� ou FALSE si erreur + */ + public function getAllToFieldsByUser ($_iUserId) + { + + $oCPCUser = false ; + + if (is_object ($this->oSoapClient)) + { + try + { + $oPlatosUser = $this->oSoapClient->__soapCall ("getAllToFieldsByUser", array ($_iUserId)) ; + $oCPCUser = $this->castUserObjectFromPlatos ($oPlatosUser) ; + } + catch (SoapFault $_eSoapFault) + { + throw new Exception ($_eSoapFault->getMessage ()) ; + } + } + else + { + throw new Exception ("Connexion non �tablie") ; + } + + return $oCPCUser ; + + } + + + /** + * Conversion d'un objet CPCUser en CPlatosUser + * + * @param CPCUser& $_oInputCPCUser Objet Utilisateur au format de l'API Client + * @return CPlatosUser Objet Utilisateur au format de PLATOS + */ + private function castUserObjectToPlatos (&$_oInputCPCUser) + { + $oPlatosUser = new CPlatosUser () ; + $oPlatosUser->iId = $_oInputCPCUser->iId ; + $oPlatosUser->zEmail = $this->strEnvEncode ($_oInputCPCUser->zEmail) ; + $oPlatosUser->zLogin = $this->strEnvEncode ($_oInputCPCUser->zLogin) ; + $oPlatosUser->zPassword = $this->strEnvEncode ($_oInputCPCUser->zPassword) ; + $oPlatosUser->zHashCode = $this->strEnvEncode ($_oInputCPCUser->zHashCode) ; + + $oPlatosUser->zCivilite = $this->strEnvEncode ($_oInputCPCUser->zCivilite) ; + $oPlatosUser->zNom = $this->strEnvEncode ($_oInputCPCUser->zNom) ; + $oPlatosUser->zPrenom = $this->strEnvEncode ($_oInputCPCUser->zPrenom) ; + $oPlatosUser->zDateNaissance = $this->strEnvEncode ($_oInputCPCUser->zDateNaissance) ; + $oPlatosUser->zAdresse1 = $this->strEnvEncode ($_oInputCPCUser->zAdresse1) ; + $oPlatosUser->zAdresse2 = $this->strEnvEncode ($_oInputCPCUser->zAdresse2) ; + $oPlatosUser->zCodePostal = $this->strEnvEncode ($_oInputCPCUser->zCodePostal) ; + $oPlatosUser->zVille = $this->strEnvEncode ($_oInputCPCUser->zVille) ; + $oPlatosUser->iInscritNewLetter = $_oInputCPCUser->iInscritNewLetter ; + $oPlatosUser->zEan128 = $this->strEnvEncode ($_oInputCPCUser->zEan128) ; + + $tzFieldCodes = $_oInputCPCUser->getDynamicFieldsList () ; + $toFields = $_oInputCPCUser->getFields () ; + + if (count ($tzFieldCodes) > 0) + { + foreach ($tzFieldCodes as $zFieldCode) + { + if ($toFields[$zFieldCode]->iType == FIELDTYPE_CHECKBOX) + { + $zValue = $_oInputCPCUser->getField ($zFieldCode) ; + + if (is_array ($zValue)) + { + $zValue = serialize ($zValue) ; + } + $oPlatosUser->toFields[$zFieldCode] = $zValue ; + } + else + { + $oPlatosUser->toFields[$zFieldCode] = $this->strEnvEncode ($_oInputCPCUser->getField ($zFieldCode)) ; + } + } + } + + return $oPlatosUser ; + } + + /** + * Conversion d'un objet CPlatosUser en CPCUser + * + * @param CPlatosUser& $_oInputPlatosUser Objet Utilisateur au format de PLATOS + * @return CPCUser Objet Utilisateur au format de l'API Client + */ + private function castUserObjectFromPlatos (&$_oInputPlatosUser) + { + + $oCPCUser = new CPCUser () ; + $oCPCUser->iId = $_oInputPlatosUser->iId ; + $oCPCUser->zEmail = $this->strEnvDecode ($_oInputPlatosUser->zEmail) ; + $oCPCUser->zLogin = $this->strEnvDecode ($_oInputPlatosUser->zLogin) ; + $oCPCUser->zPassword = $this->strEnvDecode ($_oInputPlatosUser->zPassword) ; + $oCPCUser->zHashCode = $this->strEnvDecode ($_oInputPlatosUser->zHashCode) ; + + $oCPCUser->zCivilite = $this->strEnvDecode ($_oInputPlatosUser->zCivilite) ; + $oCPCUser->zNom = $this->strEnvDecode ($_oInputPlatosUser->zNom) ; + $oCPCUser->zPrenom = $this->strEnvDecode ($_oInputPlatosUser->zPrenom) ; + $oCPCUser->zDateNaissance = $this->strEnvDecode ($_oInputPlatosUser->zDateNaissance) ; + $oCPCUser->zAdresse1 = $this->strEnvDecode ($_oInputPlatosUser->zAdresse1) ; + $oCPCUser->zAdresse2 = $this->strEnvDecode ($_oInputPlatosUser->zAdresse2) ; + $oCPCUser->zCodePostal = $this->strEnvDecode ($_oInputPlatosUser->zCodePostal) ; + $oCPCUser->zVille = $this->strEnvDecode ($_oInputPlatosUser->zVille) ; + $oCPCUser->iInscritNewLetter = $_oInputPlatosUser->iInscritNewLetter ; + $oCPCUser->zEan128 = $this->strEnvDecode ($_oInputPlatosUser->zEan128) ; + + if (isset ($_oInputPlatosUser->toFields)) + { + foreach ($_oInputPlatosUser->toFields as $zFieldCode => $zFieldValue) + { + if (array_key_exists ($zFieldCode, $_oInputPlatosUser->toFieldsConfig)) + { + if ($_oInputPlatosUser->toFieldsConfig[$zFieldCode]->iFieldType == FIELDTYPE_CHECKBOX) + { + $zFieldValue = unserialize ($zFieldValue) ; + $oCPCUser->addField ($zFieldCode, $_oInputPlatosUser->toFieldsConfig[$zFieldCode]->iFieldType, "", $zFieldValue) ; + } + else + { + $oCPCUser->addField ($zFieldCode, $_oInputPlatosUser->toFieldsConfig[$zFieldCode]->iFieldType, $_oInputPlatosUser->toFieldsConfig[$zFieldCode]->zPattern, $this->strEnvDecode ($zFieldValue)) ; + } + } + } + } + + if (isset ($_oInputPlatosUser->toFieldsConfig)) + { + foreach ($_oInputPlatosUser->toFieldsConfig as $zFieldCode => $oFieldConfig) + { + $oCPCUser->addFieldConfig ($zFieldCode, $oFieldConfig) ; + } + } + + if (isset ($_oInputPlatosUser->toServices)) + { + foreach ($_oInputPlatosUser->toServices as $oServices) + { + $oCPCUser->addServiceCorresponding ($oServices) ; + } + } + + return $oCPCUser ; + + } + + /** + * Conversion d'un objet CPlatosOperation en CPCBon + * + * @param CPlatosOperation& $_oInputPlatosOperation Objet Operation au format de PLATOS + * @return CPCBon Objet Bon de reduction + */ + private function castBDRFromPlatos (&$_oInputPlatosOperation) + { + + $oCPCBon = new CPCBon () ; + + $oCPCBon->iId = $_oInputPlatosOperation->iId ; + $oCPCBon->zTypeBon = $_oInputPlatosOperation->zTypeBon ; + $oCPCBon->zMontant = $_oInputPlatosOperation->zMontant ; + $oCPCBon->zEan13 = $_oInputPlatosOperation->zEan13 ; + $oCPCBon->zDebutValidite = $_oInputPlatosOperation->zDebutValidite ; + $oCPCBon->zFinValidite = $_oInputPlatosOperation->zFinValidite ; + $oCPCBon->zNomMarque = $_oInputPlatosOperation->zNomMarque ; + $oCPCBon->zAdresseMarque = $_oInputPlatosOperation->zAdresseMarque ; + $oCPCBon->zRcsMarque = $_oInputPlatosOperation->zRcsMarque ; + $oCPCBon->zConditionValidite = $_oInputPlatosOperation->zConditionValidite ; + $oCPCBon->zListeProduits = $_oInputPlatosOperation->zListeProduits ; + $oCPCBon->zLimitationGeographique = $_oInputPlatosOperation->zLimitationGeographique ; + $oCPCBon->iNombreBons = $_oInputPlatosOperation->iNombreBons ; + $oCPCBon->zEan128 = $_oInputPlatosOperation->zEan128 ; + $oCPCBon->iBonId = $_oInputPlatosOperation->iBonId ; + + return $oCPCBon ; + + } + + /** + * Fonction d'encodage + */ + private function strEnvEncode ($_zInputStr) + { + if ($this->bEncodeData) + { + return utf8_encode ($_zInputStr) ; + } + else + { + return $_zInputStr ; + } + } + + private function strEnvDecode ($_zInputStr) + { + if ($this->bEncodeData) + { + return utf8_decode ($_zInputStr) ; + } + else + { + return $_zInputStr ; + } + } + +} + + +/** +* Classe faisant d'une valeur autoris� pour un champs +*/ +class CPlatosFieldAttribute +{ + public $iId ; + public $zLabel ; +} + +/** +* Classe faisant abstraction d'une liste de valeur autoris� pour un champs (Type liste) +*/ +class CPlatosFieldConfig +{ + public $zFieldId ; + public $iFieldType ; + public $zLabel ; + public $zPattern ; + public $toAttributes = array () ; +} + +/** + * Classe conventionnelle pour les �changes de donn�es avec PLATOS + * + * @package PlatosClient + * @name CPlatosUser + * @access public + */ +class CPlatosUser +{ + + public $iId ; + public $zEmail ; + public $zLogin ; + public $zPassword ; + public $zHashCode ; + public $zLangageCode ; + public $toFields ; + public $toFieldsConfig ; + public $toServices ; + + public $zCivilite ; + public $zNom ; + public $zPrenom ; + public $zDateNaissance ; + public $zAdresse1 ; + public $zAdresse2 ; + public $zCodePostal ; + public $zVille ; + public $iInscritNewLetter ; + public $zEan128 ; + + + public function __construct() + { + $this->iId = 0 ; + $this->zEmail = "" ; + $this->zLogin = "" ; + $this->zPassword = "" ; + $this->zHashCode = "" ; + + $this->zCivilite = "" ; + $this->zNom = "" ; + $this->zPrenom = "" ; + $this->zDateNaissance = "" ; + $this->zAdresse1 = "" ; + $this->zAdresse2 = "" ; + $this->zVille = "" ; + $this->zCodePostal = 0 ; + $this->iInscritNewLetter = 0 ; + $this->zEan128 = "" ; + + $this->toFields = array () ; + $this->toFieldsConfig = array () ; + $this->toServices = array () ; + + } + +} + +/** + * Classe conventionnelle pour les �changes de donn�es avec PLATOS + * + * @package PlatosClient + * @name CPlatosOperation + * @access private + */ +class CPlatosOperation +{ + + public $iId ; + public $zTypeBon ; + public $zMontant ; + public $zEan13 ; + public $zDebutValidite ; + public $zFinValidite ; + public $zNomMarque ; + public $zAdresseMarque ; + public $zRcsMarque ; + public $zConditionValidite ; + public $zListeProduits ; + public $zLimitationGeographique ; + public $iNombreBons ; + public $zEan128 ; + public $iBonId ; + +} + + +?> diff --git a/ldccrm_client/CPCUser.class.php b/ldccrm_client/CPCUser.class.php new file mode 100644 index 0000000..1a0b802 --- /dev/null +++ b/ldccrm_client/CPCUser.class.php @@ -0,0 +1,520 @@ +iId = $_iId ; + $this->zEmail = "" ; + $this->zLogin = "" ; + $this->zPassword = "" ; + $this->zHashCode = "" ; + $this->zLanguageCode = "" ; + + $this->zCivilite = "" ; + $this->zNom = "" ; + $this->zPrenom = "" ; + $this->zDateNaissance = "" ; + $this->zAdresse1 = "" ; + $this->zAdresse2 = "" ; + $this->zVille = "" ; + $this->zCodePostal = 0 ; + $this->iInscritNewLetter = 0 ; + $this->zEan128 = "" ; + + $this->toFields = array () ; + $this->toFieldsConfig = array () ; + $this->toServices = array () ; + + } + + /** + * Liste les champs dynamiques d?finis par cet utilisateur + * + * @return array Liste des codes des champs d?finis par l'utilisateur + */ + public function getDynamicFieldsList () + { + if ( isset ($this->toFields) ) + { + return array_keys ($this->toFields) ; + } + else + { + return 0 ; + } + } + + /** + * Ajoute un nouveau champ dans l'utilisateur + * + * @param string $_zFieldCode Code du champ + * @param int $_iFieldType Type du champ + * @param string $_zFieldPattern Motif de v?rification du champ + * @param string $_zFieldValue Valeur du champ + */ + public function addField ($_zFieldCode, $_iFieldType = FIELDTYPE_TEXT, $_zFieldPattern = "", $_zFieldValue = "") + { + $oNewField = new CPCUserField ($_zFieldCode, $_iFieldType, $_zFieldPattern, $_zFieldValue) ; + $this->toFields[$_zFieldCode] = $oNewField ; + } + + /** + * Ajoute un nouveau champ dans l'utilisateur + * + * @param string $_zFieldCode Code du champ + * @param string $_zFieldValue Valeur du champ + */ + public function setField ($_zFieldCode, $_zFieldValue = 0) + { + if (!array_key_exists ($_zFieldCode, $this->toFields)) + { + $this->addField ($_zFieldCode) ; + } + $this->toFields[$_zFieldCode]->zValue = $_zFieldValue ; + } + + /** + * R�cup�re la valeur d'un champ dynamique utilisateur + * + * @param string $_zFieldCode Code du champ + * @return string Valeur du champ ou FALSE si champ inexsitant + */ + public function getField ($_zFieldCode) + { + $zRet = false ; + if (array_key_exists ($_zFieldCode, $this->toFields)) + { + $zRet = $this->toFields[$_zFieldCode]->zValue ; + } + else + { + return null ; + } + return $zRet ; + } + + /** + * V?rificaion de la conformit? interne du champs + * + * @return bool R?sultat de la v?rification de conformit? + */ + public function check () + { + + $bRet = true ; + + if (!$this->checkEmailFormat ($this->zEmail)) + { + $bRet = false ; + throw new Exception ("Format d'Email invalide : [" . $this->zEmail . "]") ; + } + + try + { + $this->checkEmailOnMX ($this->zEmail) ; + } + catch (Exception $_eInvalideMail) + { + $bRet = false ; + } + + if ($bRet) + { + foreach ($this->toFields as $oField) + { + try + { + $bRet = $bRet && $oField->check(); + } + catch (Exception $_oException) + { + $bRet = false ; + throw new Exception ($_oException->getMessage ()) ; + } + } + } + + return $bRet ; + + } + + /** + * Fonction de v?rification d'un email + * + * @param string $_zInputEmail l'Adresse email ? v?rifier + * @return bool R?sultat de la v?rification du format + */ + public function checkEmailOnMX ($_zInputEmail, $_zLocalUser = "root", $_zLocalHost = "localhost") + { + + $bRes = true ; + + /* + if (isset ($_zInputEmail)) + { + + $oEmailValidator = new email_validation_class () ; + + $oEmailValidator->timeout = 5 ; + $oEmailValidator->data_timeout = 0 ; + $oEmailValidator->localuser = $_zLocalUser ; + $oEmailValidator->localhost = $_zLocalHost ; + $oEmailValidator->debug = 0 ; + $oEmailValidator->html_debug = 0 ; + $oEmailValidator->exclude_address = "" ; + + if (!$oEmailValidator->ValidateEmailBox ($_zInputEmail)) + { + $bRes = false ; + throw new Exception ("Email non reconnu par le serveur : [" . $_zInputEmail . "]") ; + } + + } + */ + + return $bRes ; + + } + + + /** + * Fonction de v?rification du format d'un email + * + * @param string $_zInputEmail l'Adresse email ? v?rifier + * @return bool R?sultat de la v?rification du format + */ + public function checkEmailFormat ($_zInputEmail) + { + $zPattern2 = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i" ; + $bRet = (preg_match ($zPattern2, $_zInputEmail)) ; + return $bRet ; + } + + /** + * Liste les champs dynamiques d�finis par la configuration de l'utilisateur + * + * @return array Liste des codes des champs par la configuration de l'utilisateur + */ + public function getFieldsConfig () + { + if (isset ($this->toFieldsConfig)) + { + $toResults = array_keys ($this->toFieldsConfig) ; + if (count ($toResults) > 0) + { + return $toResults ; + } + else + { + return null ; + } + } + else + { + return null ; + } + } + + /** + * Liste des services correspondant � l'utilisateur + * + * @return array Liste des services + */ + public function getAllServicesCorresponding () + { + if (isset ($this->toServices)) + { + $toResults = $this->toServices ; + if (count ($toResults) > 0) + { + return $toResults ; + } + else + { + return null ; + } + } + else + { + return null ; + } + } + + /** + * Fonction d'ajout d'une configuration de champs + * + * @param string $_zFieldCode + * @param CPlatosFieldConfig $_oFieldConfig ; + */ + public function addFieldConfig ($_zFieldCode, $_oFieldConfig) + { + $oNewFieldConfig = new CPCFieldConfig () ; + $oNewFieldConfig->zFieldId = $_oFieldConfig->zFieldId ; + $oNewFieldConfig->iFieldType = $_oFieldConfig->iFieldType ; + $oNewFieldConfig->zLabel = $_oFieldConfig->zLabel ; + foreach ($_oFieldConfig->toAttributes as $oAttr) + { + $oNewAttr = new CPCFieldAttribute () ; + $oNewAttr->iId = $oAttr->iId ; + $oNewAttr->zLabel = $oAttr->zLabel ; + array_push ($oNewFieldConfig->toAttributes, $oNewAttr) ; + } + $this->toFieldsConfig[$_zFieldCode] = $oNewFieldConfig ; + } + + /** + * R�cup�ration du lib�ll� d'un champ + * + * @param string $_zFieldCode + * @return string|null Type du champ + */ + public function getFieldLabel ($_zFieldCode) + { + if (array_key_exists ($_zFieldCode, $this->toFieldsConfig)) + { + return $this->toFieldsConfig[$_zFieldCode]->zLabel ; + } + else + { + return null ; + } + } + + /** + * R�cup�ration du type d'un champ + * + * @param string $_zFieldCode + * @return int|null Type du champ + */ + public function getFieldType ($_zFieldCode) + { + if (array_key_exists ($_zFieldCode, $this->toFieldsConfig)) + { + return $this->toFieldsConfig[$_zFieldCode]->iFieldType ; + } + else + { + return null ; + } + } + + /** + * R�cup�ration du type d'un champ + * + * @param string $_zFieldCode + * @return array|null Type du champ + */ + public function getFieldAttributes ($_zFieldCode) + { + if (array_key_exists ($_zFieldCode, $this->toFieldsConfig)) + { + $tzResults = array () ; + foreach ($this->toFieldsConfig[$_zFieldCode]->toAttributes as $oAttr) + { + $tzResults[$oAttr->iId] = $oAttr->zLabel ; + } + return $tzResults ; + } + else + { + return null ; + } + } + + /** + * Fonction d'ajout des services correspondants + * + * @param CPlatosServices $_oServices + */ + public function addServiceCorresponding ($_oServices) + { + $oServices = new CPCServices () ; + $oServices->iServiceId = $_oServices->iServiceId ; + $oServices->zServiceName = $_oServices->zServiceName ; + + array_push ($this->toServices, $oServices) ; + } + + /** + * Recuperation des champs + * @return array Liste des champs + */ + public function getFields () + { + return $this->toFields ; + } + +} + +/** +* Classe faisant d'une valeur autoris� pour un champs +*/ +class CPCFieldAttribute +{ + public $iId ; + public $zLabel ; +} + +/** +* Classe faisant abstraction d'une liste de valeur autoris� pour un champs (Type liste) +*/ +class CPCFieldConfig +{ + public $zFieldId ; + public $iFieldType ; + public $zLabel ; + public $zPattern ; + public $toAttributes = array () ; +} + +/** +* Classe faisant abstraction d'un service +*/ +class CPCServices +{ + + public $iServiceId ; + public $zServiceName ; +} + +?> diff --git a/ldccrm_client/CPCUserField.class.php b/ldccrm_client/CPCUserField.class.php new file mode 100644 index 0000000..4eebd29 --- /dev/null +++ b/ldccrm_client/CPCUserField.class.php @@ -0,0 +1,95 @@ +zCode = $_zCode ; + $this->iType = $_iType ; + $this->zPattern = $_zPattern ; + $this->zValue = $_zValue ; + } + + /** + * V�rificaion de la conformit� interne du champs + * + * @return bool R�sultat de la v�rification de conformit� + */ + public function check () + { + $bRet = true ; + if (preg_match ("/^[a-zA-Z0-9_]+$/", $this->zCode) === false) + { + $bRet = false ; + throw new Exception ("[FIELD : " . $this->zCode . "] >> Code de champ incorrect : [" . $this->zCode . "]") ; + } + if (trim ($this->zPattern) != "") + { + if (ereg ($this->zPattern, $this->zValue) === false) + { + $bRet = false ; + throw new Exception ("[FIELD : " . $this->zCode . "] >> Valeur de champ incorrect par rapport au motif") ; + } + } + if ($this->iType == FIELDTYPE_LIST) + { + if (ereg ("^[0-9]+$", $this->zValue) === false) + { + $bRet = false ; + throw new Exception ("[FIELD : " . $this->zCode . "] >> Valeur de champ incorrect pour un type LISTE") ; + } + } + return $bRet ; + } + +} + +?> diff --git a/ldccrm_client/datatypes.inc.php b/ldccrm_client/datatypes.inc.php new file mode 100644 index 0000000..d132dbe --- /dev/null +++ b/ldccrm_client/datatypes.inc.php @@ -0,0 +1,43 @@ + \ No newline at end of file diff --git a/ldccrm_client/emailValidation.php b/ldccrm_client/emailValidation.php new file mode 100644 index 0000000..be44977 --- /dev/null +++ b/ldccrm_client/emailValidation.php @@ -0,0 +1,206 @@ +next_token; + } + for($character=0;$character
Code EAN actif ? {{$settings->use_ean_codes === 1 ? 'Oui' : 'Non'}}
+ @if ($errors->any()) +C'est gagné !
+@endsection diff --git a/resources/views/front/basic/gains.blade.php b/resources/views/front/basic/gains.blade.php new file mode 100644 index 0000000..5b6da0b --- /dev/null +++ b/resources/views/front/basic/gains.blade.php @@ -0,0 +1,35 @@ +@extends('front.basic.layout') + +@section('title', 'Les gains') + +@section('content') +Lots (valeur à 0 ou 1 : 0 = faux, 1 = vrai) :
+| ID Arcadia | +Label singulier | +Label pluriel | +Quantité | +Notification activé | +Formulaire suppl. | +ID mail Arcadia | +Pdf preuve de gain | +Lot par défaut | + + + @foreach ($prizes as $p) +
|---|---|---|---|---|---|---|---|---|
| {{$p->arcadia_id}} | +{{$p->label_one}} | +{{$p->label_many}} | +{{$p->quantity}} | +{{$p->notifications}} | +{{$p->additional_form}} | +{{$p->arcadia_mail_id}} | +{{$p->pdf_winning_proof}} | +{{$p->is_default}} | +
Accueil, aucune variable pour le moment
+Société : {{$settingsGlobal->company}} et nom du jeu : {{$settingsGlobal->name}}
++ Test pour gain : +
+ @endsection diff --git a/resources/views/front/basic/how-to-play.blade.php b/resources/views/front/basic/how-to-play.blade.php new file mode 100644 index 0000000..387c1e6 --- /dev/null +++ b/resources/views/front/basic/how-to-play.blade.php @@ -0,0 +1,35 @@ +@extends('front.basic.layout') + +@section('title', 'Comment jouer') + +@section('content') +Lots (valeur à 0 ou 1 : 0 = faux, 1 = vrai) :
+| ID Arcadia | +Label singulier | +Label pluriel | +Quantité | +Notification activé | +Formulaire suppl. | +ID mail Arcadia | +Pdf preuve de gain | +Lot par défaut | + + + @foreach ($prizes as $p) +
|---|---|---|---|---|---|---|---|---|
| {{$p->arcadia_id}} | +{{$p->label_one}} | +{{$p->label_many}} | +{{$p->quantity}} | +{{$p->notifications}} | +{{$p->additional_form}} | +{{$p->arcadia_mail_id}} | +{{$p->pdf_winning_proof}} | +{{$p->is_default}} | +
C'est perdu
+@endsection diff --git a/resources/views/front/basic/reduction.blade.php b/resources/views/front/basic/reduction.blade.php new file mode 100644 index 0000000..0641f3d --- /dev/null +++ b/resources/views/front/basic/reduction.blade.php @@ -0,0 +1,8 @@ +@extends('front.basic.layout') + +@section('title', 'Réduction') + +@section('content') +Gain d'une réduction
+Rejouer ! +@endsection diff --git a/resources/views/front/basic/register-crm.blade.php b/resources/views/front/basic/register-crm.blade.php new file mode 100644 index 0000000..59870ce --- /dev/null +++ b/resources/views/front/basic/register-crm.blade.php @@ -0,0 +1,100 @@ +@extends('front.basic.layout') + +@section('title', 'Connexion') + +@section('content') +