From fa585c660ad33a6610df10a196a99144aa8efd02 Mon Sep 17 00:00:00 2001 From: Romain Bonhomme Date: Thu, 29 Oct 2020 15:40:23 +0100 Subject: [PATCH] Ajout des templates de vue --- app/Http/Controllers/EnterCodeController.php | 48 + app/Http/Controllers/GainsController.php | 14 + app/Http/Controllers/HomeController.php | 3 +- app/Http/Controllers/HowToPlayController.php | 14 + app/Http/Controllers/LoginController.php | 66 + app/Http/Controllers/LooseController.php | 12 + app/Http/Controllers/PrizeWinController.php | 20 + app/Http/Controllers/RegisterController.php | 123 ++ .../Controllers/VerificationController.php | 21 + .../Controllers/bo/GainViewController.php | 25 +- .../Controllers/bo/InstantWinController.php | 1 - app/Http/Kernel.php | 1 + app/Http/Middleware/isAdmin.php | 24 + app/Mail/VerifyEmail.php | 34 + app/Providers/AppServiceProvider.php | 6 +- app/Providers/RouteServiceProvider.php | 2 +- app/User.php | 16 +- composer.json | 6 +- config/auth.php | 5 - config/crm.php | 9 + .../2014_10_12_000000_create_users_table.php | 16 +- ...2020_10_28_091935_create_participation.php | 44 + database/seeds/DatabaseSeeder.php | 1 + database/seeds/UserSeeder.php | 33 + ldccrm_client/CPCBon.class.php | 199 +++ ldccrm_client/CPCConnection.class.php | 1061 ++++++++++++++ ldccrm_client/CPCUser.class.php | 520 +++++++ ldccrm_client/CPCUserField.class.php | 95 ++ ldccrm_client/datatypes.inc.php | 43 + ldccrm_client/emailValidation.php | 206 +++ ldccrm_client/errors.inc.php | 53 + ldccrm_client/pi_barcode.php | 1290 +++++++++++++++++ ldccrm_client/platosclient.lib.php | 3 + package.json | 9 +- resources/js/app.js | 13 +- resources/js/components/ExampleComponent.vue | 23 + resources/js/components/Prizes.vue | 3 - resources/sass/_variables.scss | 5 - resources/sass/app.scss | 3 - .../views/front/basic/enter-code.blade.php | 24 + resources/views/front/basic/gain1.blade.php | 7 + resources/views/front/basic/gains.blade.php | 35 + resources/views/front/basic/home.blade.php | 10 +- .../views/front/basic/how-to-play.blade.php | 35 + resources/views/front/basic/layout.blade.php | 27 +- resources/views/front/basic/login.blade.php | 74 + resources/views/front/basic/loose.blade.php | 5 + .../views/front/basic/reduction.blade.php | 8 + .../views/front/basic/register-crm.blade.php | 100 ++ resources/views/front/basic/verify.blade.php | 28 + resources/views/home.blade.php | 23 + resources/views/layouts/app.blade.php | 80 + resources/views/layouts/bo.blade.php | 8 +- routes/web.php | 21 +- 54 files changed, 4484 insertions(+), 71 deletions(-) create mode 100644 app/Http/Controllers/EnterCodeController.php create mode 100644 app/Http/Controllers/GainsController.php create mode 100644 app/Http/Controllers/HowToPlayController.php create mode 100644 app/Http/Controllers/LoginController.php create mode 100644 app/Http/Controllers/LooseController.php create mode 100644 app/Http/Controllers/PrizeWinController.php create mode 100644 app/Http/Controllers/RegisterController.php create mode 100644 app/Http/Controllers/VerificationController.php create mode 100644 app/Http/Middleware/isAdmin.php create mode 100644 app/Mail/VerifyEmail.php create mode 100644 config/crm.php create mode 100644 database/migrations/2020_10_28_091935_create_participation.php create mode 100644 database/seeds/UserSeeder.php create mode 100644 ldccrm_client/CPCBon.class.php create mode 100644 ldccrm_client/CPCConnection.class.php create mode 100644 ldccrm_client/CPCUser.class.php create mode 100644 ldccrm_client/CPCUserField.class.php create mode 100644 ldccrm_client/datatypes.inc.php create mode 100644 ldccrm_client/emailValidation.php create mode 100644 ldccrm_client/errors.inc.php create mode 100644 ldccrm_client/pi_barcode.php create mode 100644 ldccrm_client/platosclient.lib.php create mode 100644 resources/js/components/ExampleComponent.vue create mode 100644 resources/views/front/basic/enter-code.blade.php create mode 100644 resources/views/front/basic/gain1.blade.php create mode 100644 resources/views/front/basic/gains.blade.php create mode 100644 resources/views/front/basic/how-to-play.blade.php create mode 100644 resources/views/front/basic/login.blade.php create mode 100644 resources/views/front/basic/loose.blade.php create mode 100644 resources/views/front/basic/reduction.blade.php create mode 100644 resources/views/front/basic/register-crm.blade.php create mode 100644 resources/views/front/basic/verify.blade.php create mode 100644 resources/views/home.blade.php create mode 100644 resources/views/layouts/app.blade.php 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;$characternext_token=substr($string,$found+1); + return(substr($string,0,$found)); + } + else + { + $this->next_token=""; + return($string); + } + } + + Function OutputDebug($message) + { + $message.="\n"; + if($this->html_debug) + $message=str_replace("\n","
\n",HtmlEntities($message)); + echo $message; + flush(); + } + + Function GetLine($connection) + { + for($line="";;) + { + if(feof($connection)) + return(0); + $line.=fgets($connection,100); + $length=strlen($line); + if($length>=2 + && substr($line,$length-2,2)=="\r\n") + { + $line=substr($line,0,$length-2); + if($this->debug) + $this->OutputDebug("S $line"); + return($line); + } + } + } + + Function PutLine($connection,$line) + { + if($this->debug) + $this->OutputDebug("C $line"); + return(fputs($connection,"$line\r\n")); + } + + Function ValidateEmailAddress($email) + { + return(eregi($this->email_regular_expression,$email)!=0); + } + + Function ValidateEmailHost($email,&$hosts) + { + if(!$this->ValidateEmailAddress($email)) + return(0); + $user=$this->Tokenize($email,"@"); + $domain=$this->Tokenize(""); + $hosts=$weights=array(); + $getmxrr=$this->getmxrr; + if(function_exists($getmxrr) + && $getmxrr($domain,$hosts,$weights)) + { + $mxhosts=array(); + for($host=0;$hostexclude_address)==0 + || strcmp(@gethostbyname($this->exclude_address),$ip))) + $hosts[]=$domain; + } + return(count($hosts)!=0); + } + + Function VerifyResultLines($connection,$code) + { + while(($line=$this->GetLine($connection))) + { + if(!strcmp($this->Tokenize($line," "),$code)) + return(1); + if(strcmp($this->Tokenize($line,"-"),$code)) + return(0); + } + return(-1); + } + + Function ValidateEmailBox($email) + { + if(!$this->ValidateEmailHost($email,$hosts)) + return(0); + if(!strcmp($localhost=$this->localhost,"") + && !strcmp($localhost=getenv("SERVER_NAME"),"") + && !strcmp($localhost=getenv("HOST"),"")) + $localhost="localhost"; + if(!strcmp($localuser=$this->localuser,"") + && !strcmp($localuser=getenv("USERNAME"),"") + && !strcmp($localuser=getenv("USER"),"")) + $localuser="root"; + for($host=0;$hostdebug) + $this->OutputDebug("Resolving host name \"".$hosts[$host]."\"..."); + if(!strcmp($ip=@gethostbyname($domain),$domain)) + { + if($this->debug) + $this->OutputDebug("Could not resolve host name \"".$hosts[$host]."\"."); + continue; + } + } + if(strlen($this->exclude_address) + && !strcmp(@gethostbyname($this->exclude_address),$ip)) + { + if($this->debug) + $this->OutputDebug("Host address of \"".$hosts[$host]."\" is the exclude address"); + continue; + } + if($this->debug) + $this->OutputDebug("Connecting to host address \"".$ip."\"..."); + if(($connection=($this->timeout ? @fsockopen($ip,25,$errno,$error,$this->timeout) : @fsockopen($ip,25)))) + { + $timeout=($this->data_timeout ? $this->data_timeout : $this->timeout); + if($timeout + && function_exists("socket_set_timeout")) + socket_set_timeout($connection,$timeout,0); + if($this->debug) + $this->OutputDebug("Connected."); + if($this->VerifyResultLines($connection,"220")>0 + && $this->PutLine($connection,"HELO $localhost") + && $this->VerifyResultLines($connection,"250")>0 + && $this->PutLine($connection,"MAIL FROM: <$localuser@$localhost>") + && $this->VerifyResultLines($connection,"250")>0 + && $this->PutLine($connection,"RCPT TO: <$email>") + && ($result=$this->VerifyResultLines($connection,"250"))>=0) + { + if($result + && $this->PutLine($connection,"DATA")) + $result=($this->VerifyResultLines($connection,"354")!=0); + if($this->debug) + $this->OutputDebug("This host states that the address is ".($result ? "" : "not ")."valid."); + fclose($connection); + if($this->debug) + $this->OutputDebug("Disconnected."); + return($result); + } + if($this->debug) + $this->OutputDebug("Unable to validate the address with this host."); + fclose($connection); + if($this->debug) + $this->OutputDebug("Disconnected."); + } + else + { + if($this->debug) + $this->OutputDebug("Failed."); + } + } + return(-1); + } +}; + +?> \ No newline at end of file diff --git a/ldccrm_client/errors.inc.php b/ldccrm_client/errors.inc.php new file mode 100644 index 0000000..62ed614 --- /dev/null +++ b/ldccrm_client/errors.inc.php @@ -0,0 +1,53 @@ + \ No newline at end of file diff --git a/ldccrm_client/pi_barcode.php b/ldccrm_client/pi_barcode.php new file mode 100644 index 0000000..549e986 --- /dev/null +++ b/ldccrm_client/pi_barcode.php @@ -0,0 +1,1290 @@ + "11011001100", 1 => "11001101100", 2 => "11001100110", + 3 => "10010011000", 4 => "10010001100", 5 => "10001001100", + 6 => "10011001000", 7 => "10011000100", 8 => "10001100100", + 9 => "11001001000", 10 => "11001000100", 11 => "11000100100", + 12 => "10110011100", 13 => "10011011100", 14 => "10011001110", + 15 => "10111001100", 16 => "10011101100", 17 => "10011100110", + 18 => "11001110010", 19 => "11001011100", 20 => "11001001110", + 21 => "11011100100", 22 => "11001110100", 23 => "11101101110", + 24 => "11101001100", 25 => "11100101100", 26 => "11100100110", + 27 => "11101100100", 28 => "11100110100", 29 => "11100110010", + 30 => "11011011000", 31 => "11011000110", 32 => "11000110110", + 33 => "10100011000", 34 => "10001011000", 35 => "10001000110", + 36 => "10110001000", 37 => "10001101000", 38 => "10001100010", + 39 => "11010001000", 40 => "11000101000", 41 => "11000100010", + 42 => "10110111000", 43 => "10110001110", 44 => "10001101110", + 45 => "10111011000", 46 => "10111000110", 47 => "10001110110", + 48 => "11101110110", 49 => "11010001110", 50 => "11000101110", + 51 => "11011101000", 52 => "11011100010", 53 => "11011101110", + 54 => "11101011000", 55 => "11101000110", 56 => "11100010110", + 57 => "11101101000", 58 => "11101100010", 59 => "11100011010", + 60 => "11101111010", 61 => "11001000010", 62 => "11110001010", + 63 => "10100110000", 64 => "10100001100", 65 => "10010110000", + 66 => "10010000110", 67 => "10000101100", 68 => "10000100110", + 69 => "10110010000", 70 => "10110000100", 71 => "10011010000", + 72 => "10011000010", 73 => "10000110100", 74 => "10000110010", + 75 => "11000010010", 76 => "11001010000", 77 => "11110111010", + 78 => "11000010100", 79 => "10001111010", 80 => "10100111100", + 81 => "10010111100", 82 => "10010011110", 83 => "10111100100", + 84 => "10011110100", 85 => "10011110010", 86 => "11110100100", + 87 => "11110010100", 88 => "11110010010", 89 => "11011011110", + 90 => "11011110110", 91 => "11110110110", 92 => "10101111000", + 93 => "10100011110", 94 => "10001011110", 95 => "10111101000", + 96 => "10111100010", 97 => "11110101000", 98 => "11110100010", + 99 => "10111011110", // 99 et 'c' sont identiques ne nous sert que pour le checksum + 100 => "10111101110", // 100 et 'b' sont identiques ne nous sert que pour le checksum + 101 => "11101011110", // 101 et 'a' sont identiques ne nous sert que pour le checksum + 102 => "11110101110", // 102 correspond � FNC1 ne nous sert que pour le checksum + 'c' => "10111011110", 'b' => "10111101110", 'a' => "11101011110", + 'A' => "11010000100", 'B' => "11010010000", 'C' => "11010011100", + 'S' => "1100011101011" + ); + + var $C25 = array( + 0 => "11331", 1 => "31113", + 2 => "13113", 3 => "33111", + 4 => "11313", 5 => "31311", + 6 => "13311", 7 => "11133", + 8 => "31131", 9 => "13131", + 'D' => "111011101", 'F' => "111010111", // Code 2 parmi 5 + 'd' => "1010", 'f' => "11101" // Code 2/5 entrelac� + ); + + var $C39 = array( + '0' => "101001101101", '1' => "110100101011", '2' => "101100101011", + '3' => "110110010101", '4' => "101001101011", '5' => "110100110101", + '6' => "101100110101", '7' => "101001011011", '8' => "110100101101", + '9' => "101100101101", 'A' => "110101001011", 'B' => "101101001011", + 'C' => "110110100101", 'D' => "101011001011", 'E' => "110101100101", + 'F' => "101101100101", 'G' => "101010011011", 'H' => "110101001101", + 'I' => "101101001101", 'J' => "101011001101", 'K' => "110101010011", + 'L' => "101101010011", 'M' => "110110101001", 'N' => "101011010011", + 'O' => "110101101001", 'P' => "101101101001", 'Q' => "101010110011", + 'R' => "110101011001", 'S' => "101101011001", 'T' => "101011011001", + 'U' => "110010101011", 'V' => "100110101011", 'W' => "110011010101", + 'X' => "100101101011", 'Y' => "110010110101", 'Z' => "100110110101", + '-' => "100101011011", '.' => "110010101101", ' ' => "100110101101", + '$' => "100100100101", '/' => "100100101001", '+' => "100101001001", + '%' => "101001001001", '*' => "100101101101" + ); + + var $codabar = array( + '0' => "101010011", '1' => "101011001", '2' => "101001011", + '3' => "110010101", '4' => "101101001", '5' => "110101001", + '6' => "100101011", '7' => "100101101", '8' => "100110101", + '9' => "110100101", '-' => "101001101", '$' => "101100101", + ':' => "1101011011", '/' => "1101101011", '.' => "1101101101", + '+' => "1011011011", 'A' => "1011001001", 'B' => "1010010011", + 'C' => "1001001011", 'D' => "1010011001" + ); + + var $MSI = array( + 0 => "100100100100", + 1 => "100100100110", + 2 => "100100110100", + 3 => "100100110110", + 4 => "100110100100", + 5 => "100110100110", + 6 => "100110110100", + 7 => "100110110110", + 8 => "110100100100", + 9 => "110100100110", + 'D' => "110", + 'F' => "1001" + ); + + var $C11 = array( + '0' => "101011", + '1' => "1101011", + '2' => "1001011", + '3' => "1100101", + '4' => "1011011", + '5' => "1101101", + '6' => "1001101", + '7' => "1010011", + '8' => "1101001", + '9' => "110101", + '-' => "101101", + 'S' => "1011001" + ); + + var $postnet = array( + '0' => "11000", + '1' => "00011", + '2' => "00101", + '3' => "00110", + '4' => "01001", + '5' => "01010", + '6' => "01100", + '7' => "10001", + '8' => "10010", + '9' => "10100" + ); + + var $kix = array( //0=haut, 1=bas, 2=milieu, 3=toute la hauteur + '0' => '2233', '1' => '2103', '2' => '2130', + '3' => '1203', '4' => '1230', '5' => '1100', + '6' => '2013', '7' => '2323', '8' => '2310', + '9' => '1023', 'A' => '1010', 'B' => '1320', + 'C' => '2031', 'D' => '2301', 'E' => '2332', + 'F' => '1001', 'G' => '1032', 'H' => '1302', + 'I' => '0213', 'J' => '0123', 'K' => '0110', + 'L' => '3223', '2' => '3210', 'N' => '3120', + 'O' => '0231', 'P' => '0101', 'Q' => '0132', + 'R' => '3201', 'S' => '3232', 'T' => '3102', + 'U' => '0011', 'V' => '0321', 'W' => '0312', + 'X' => '3021', 'Y' => '3021', 'Z' => '3322' + ); + + var $CMC7 = array( + 0 => "0,3-0,22|2,1-2,24|4,0-4,8|4,18-4,25|8,0-8,8|8,18-8,25|12,0-12,8|12,18-12,25|14,1-14,24|16,3-16,22", + 1 => "0,5-0,12|0,17-0,25|4,3-4,10|4,17-4,25|6,2-6,9|6,17-6,25|8,1-8,25|10,0-10,25|14,14-14,25|16,14-16,25", + 2 => "0,2-0,9|0,17-0,25|2,0-2,9|2,16-2,25|6,0-6,6|6,13-6,25|10,0-10,6|10,11-10,17|10,20-10,25|12,0-12,6|12,10-12,16|12,20-12,25|14,0-14,14|14,20-14,25|16,2-16,13|16,20-16,25", + 3 => "0,2-0,9|0,17-0,23|4,0-4,9|4,17-4,25|6,0-6,8|6,18-6,25|10,0-10,7|10,10-10,16|10,19-10,25|12,0-12,7|12,10-12,16|12,19-12,25|14,0-14,25|16,2-16,12|16,14-16,23", + 4 => "0,6-0,21|4,4-4,21|6,3-6,11|6,16-6,21|8,2-8,10|8,16-8,21|12,0-12,8|12,15-12,25|14,0-14,8|14,15-14,25|16,0-16,8|16,15-16,25", + 5 => "0,0-0,14|0,19-0,25|2,0-2,14|2,19-2,25|4,0-4,6|4,9-4,14|4,19-4,25|6,0-6,6|6,9-6,14|6,19-6,25|10,0-10,6|10,9-10,14|10,19-10,25|14,0-14,6|14,9-14,25|16,0-16,6|16,11-16,23", + 6 => "0,2-0,23|2,0-2,25|4,0-4,6|4,10-4,15|4,19-4,25|8,0-8,6|8,10-8,15|8,19-8,25|10,0-10,6|10,10-10,15|10,19-10,25|14,0-14,7|14,10-14,25|16,2-16,7|16,12-16,23", + 7 => "0,0-0,9|0,19-0,25|4,0-4,6|4,16-4,25|8,0-8,6|8,12-8,21|10,0-10,6|10,9-10,19|12,0-12,17|14,0-14,15|16,0-16,13", + 8 => "0,2-0,10|0,15-0,23|2,0-2,11|2,14-2,25|6,0-6,6|6,10-6,15|6,19-6,25|8,0-8,6|8,10-8,15|8,19-8,25|10,0-10,6|10,10-10,15|10,19-10,25|14,0-14,11|14,14-14,25|16,2-16,10|16,15-16,23", + 9 => "0,2-0,13|0,18-0,23|2,0-2,15|2,18-2,25|6,0-6,6|6,10-6,15|6,19-6,25|8,0-8,6|8,10-8,15|8,19-8,25|12,0-12,6|12,10-12,15|12,19-12,25|14,0-14,25|16,2-16,23", + 'A' => "0,4-0,15|0,19-0,24|2,4-2,15|2,19-2,24|4,4-4,15|4,19-4,24|8,4-8,15|8,19-8,24|10,4-10,15|10,19-10,24|12,4-12,15|12,19-12,24|16,4-16,15|16,19-16,24", + 'B' => "0,9-0,24|4,7-4,22|6,6-6,21|8,5-8,20|10,4-10,19|12,3-12,18|16,1-16,16", + 'C' => "0,4-0,12|0,16-0,24|2,4-2,12|2,16-2,24|4,4-4,12|4,16-4,24|6,4-6,12|6,16-6,24|10,7-10,21|12,7-12,21|16,7-16,21", + 'D' => "0,10-0,24|2,10-2,24|6,10-6,24|8,10-8,24|10,4-10,24|12,4-12,24|16,4-16,24", + 'E' => "0,7-0,12|0,16-0,25|2,5-2,23|4,3-4,21|6,1-6,19|8,0-8,18|12,3-12,21|16,7-16,12|16,16-16,25", + ); + + var $EANbars = array('A' => array( + 0 => "0001101", 1 => "0011001", + 2 => "0010011", 3 => "0111101", + 4 => "0100011", 5 => "0110001", + 6 => "0101111", 7 => "0111011", + 8 => "0110111", 9 => "0001011" + ), + 'B' => array( + 0 => "0100111", 1 => "0110011", + 2 => "0011011", 3 => "0100001", + 4 => "0011101", 5 => "0111001", + 6 => "0000101", 7 => "0010001", + 8 => "0001001", 9 => "0010111" + ), + 'C' => array( + 0 => "1110010", 1 => "1100110", + 2 => "1101100", 3 => "1000010", + 4 => "1011100", 5 => "1001110", + 6 => "1010000", 7 => "1000100", + 8 => "1001000", 9 => "1110100" + ) + ); + + var $EANparity = array( + 0 => array('A','A','A','A','A','A'), + 1 => array('A','A','B','A','B','B'), + 2 => array('A','A','B','B','A','B'), + 3 => array('A','A','B','B','B','A'), + 4 => array('A','B','A','A','B','B'), + 5 => array('A','B','B','A','A','B'), + 6 => array('A','B','B','B','A','A'), + 7 => array('A','B','A','B','A','B'), + 8 => array('A','B','A','B','B','A'), + 9 => array('A','B','B','A','B','A') + ); + + /** + * Constructeur // est appel� automatiquement � l'instanciation de l'objet + */ + function __construct() + { + $this->CODE = ''; + $this->FULLCODE = 'NO CODE SET'; + $this->TYPE = 'ERR'; + $this->HEIGHT = 15; + $this->WIDTH = 0; + $this->CALMZONE = 10; + $this->HR = 'AUTO'; + $this->SHOWTYPE = 'Y'; + $this->FOREGROUND = hexdec('#000000'); + $this->BACKGROUND = hexdec('#FFFFFF'); + $this->FILETYPE = 'PNG'; + $this->ENCODED = ''; + // detruire eventuellement l'image existante + if ($this->IH) imagedestroy($this->IH); + $this->IH = NULL; + } + + /** + * Set Barcode Type + */ + function setType($type) + { + $this->TYPE = $type; + } + /** + * Set Barcode String + */ + function setCode($code) + { + $this->CODE = $code; + } + /** + * Set Image Height and Extra-Width + */ + function setSize($height, $width=0, $calmZone=0) + { + $this->HEIGHT = ($height > 15 ? $height : 15); + $this->WIDTH = ($width > 0 ? $width : 0); + $this->CALMZONE = ($calmZone > 10 ? $calmZone : 10); + } + /** + * Set the Printed Text under Bars + */ + function setText($text='AUTO') + { + $this->HR = $text; + } + /** + * Disable CodeType printing + */ + function hideCodeType() + { + $this->SHOWTYPE = 'N'; + } + /** + * Set Colors + */ + function setColors($fg, $bg='#FFFFFF') + { + $this->FOREGROUND = hexdec($fg); + $this->BACKGROUND = hexdec($bg); + } + /** + * Set File Type (PNG, GIF or JPG) + */ + function setFiletype($ft='PNG') + { + $ft = strtoupper($ft); + $this->FILETYPE = ($ft == 'GIF' ? 'GIF' : ($ft == 'JPG' ? 'JPG' : 'PNG')); + } + + /** + * V�rification du Code + * + * calcul ou v�rification du Checksum + */ + function checkCode() + { + switch( $this->TYPE ) { + case "C128C" : + + if (preg_match("/^[0-9]{2,48}$/", $this->CODE)) + { + $tmp = strlen($this->CODE); + if (($tmp%2)!=0) $this->FULLCODE = '0'.$this->CODE; + else $this->FULLCODE = $this->CODE; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "CODE 128C REQUIRES DIGITS ONLY"; + break; + } + + case "C128" : + + $carok = true; + $long = strlen( $this->CODE ); + $i = 0; + while (($carok) && ($i<$long)) + { + $tmp = ord( $this->CODE{$i} ) ; + if (($tmp < 32) OR ($tmp > 126)) $carok = false; + $i++; + } + if ($carok) $this->FULLCODE = $this->CODE; + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "UNAUTHORIZED CHARS IN 128 CODE"; + } + + break; + case "UPC" : + + $this->CODE = '0'.$this->CODE; + $this->TYPE = 'EAN'; + + case "EAN" : + + $long = strlen( $this->CODE ) ; + $factor = 3; + $checksum = 0; + + if (preg_match("/^[0-9]{8}$/", $this->CODE) OR preg_match("/^[0-9]{13}$/", $this->CODE)) + { + + for ($index = ($long - 1); $index > 0; $index--) + { + $checksum += intval($this->CODE{$index-1}) * $factor ; + $factor = 4 - $factor ; + } + $cc = ( (1000 - $checksum) % 10 ) ; + + if ( substr( $this->CODE, -1, 1) != $cc ) + { + $this->TYPE = "ERR"; + $this->FULLCODE = "CHECKSUM ERROR IN EAN/UPC CODE"; + } + else $this->FULLCODE = $this->CODE; + + } + elseif (preg_match("/^[0-9]{7}$/", $this->CODE) OR preg_match("/^[0-9]{12}$/", $this->CODE)) + { + + for ($index = $long; $index > 0; $index--) { + $checksum += intval($this->CODE{$index-1}) * $factor ; + $factor = 4 - $factor ; + } + $cc = ( ( 1000 - $checksum ) % 10 ) ; + + $this->FULLCODE = $this->CODE.$cc ; + + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "THIS CODE IS NOT EAN/UPC TYPE"; + } + + break; + case "C25I" : + + $long = strlen($this->CODE); + if(($long%2)==0) $this->CODE = '0'.$this->CODE; + + case "C25" : + + if (preg_match("/^[0-9]{1,48}$/", $this->CODE)) + { + $checksum = 0; + $factor = 3; + $long = strlen($this->CODE); + for ($i = $long; $i > 0; $i--) { + $checksum += intval($this->CODE{$i-1}) * $factor; + $factor = 4-$factor; + } + $checksum = 10 - ($checksum % 10); + if ($checksum == 10) $checksum = 0; + $this->FULLCODE = $this->CODE.$checksum; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "CODE C25 REQUIRES DIGITS ONLY"; + } + + break; + case "C39" : + + if (preg_match("/^[0-9A-Z\-\.\$\/+% ]{1,48}$/i", $this->CODE)) + { + $this->FULLCODE = '*'.$this->CODE.'*'; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "UNAUTHORIZED CHARS IN CODE 39"; + } + + break; + case "CODABAR" : + + if (!preg_match("/^(A|B|C|D)[0-9\-\$:\/\.\+]{1,48}(A|B|C|D)$/i", $this->CODE)) + { + $this->TYPE = "ERR"; + $this->FULLCODE = "CODABAR START/STOP : ABCD"; + } + else $this->FULLCODE = $this->CODE; + + break; + case "MSI" : + + if (preg_match("/^[0-9]{1,48}$/", $this->CODE)) + { + $checksum = 0; + $factor = 1; + $tmp = strlen($this->CODE); + for ($i = 0; $i < $tmp; $i++) { + $checksum += intval($this->CODE{$i}) * $factor; + $factor++; + if ($factor > 10) $factor = 1; + } + $checksum = (1000 - $checksum) % 10; + $this->FULLCODE = $this->CODE.$checksum; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "CODE MSI REQUIRES DIGITS ONLY"; + } + + break; + case "C11" : + + if (preg_match("/^[0-9\-]{1,48}$/", $this->CODE)) + { + $checksum = 0; + $factor = 1; + $tmp = strlen($this->CODE); + for ($i = $tmp; $i > 0; $i--) { + $tmp = $this->CODE{$i-1}; + if ($tmp == "-") $tmp = 10; + else $tmp = intval($tmp); + $checksum += ($tmp * $factor); + $factor++; + if ($factor > 10) $factor=1; + } + $checksum = $checksum % 11; + if ($checksum == 10) $this->FULLCODE = $this->CODE . "-"; + else $this->FULLCODE .= $this->CODE.$checksum; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "UNAUTHORIZED CHARS IN CODE 11"; + } + + break; + case "POSTNET" : + + if (preg_match("/^[0-9]{5}$/", $this->CODE) OR preg_match("/^[0-9]{9}$/", $this->CODE) OR preg_match("/^[0-9]{11}$/", $this->CODE)) + { + $checksum = 0; + $tmp = strlen($this->CODE); + for ($i = $tmp; $i > 0; $i--) { + $checksum += intval($this->CODE{$i-1}); + } + $checksum = 10 - ($checksum % 10); + if($checksum == 10) $checksum = 0; + $this->FULLCODE = $this->CODE.$checksum; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "POSTNET MUST BE 5/9/11 DIGITS"; + } + + break; + case "KIX" : + + if (preg_match("/^[A-Z0-9]{1,50}$/", $this->CODE)) + { +/* ***** LE CODE KIX n'a pas de checksum (correction V2.02) + $checksum = 0; + $tmp = strlen("$this->CODE"); + for($i=$tmp-1; $i>=0; $i--) { + $checksum += intval(substr($this->CODE,$i,1)); + } + $checksum = 10-($checksum%10); + if($checksum==10) $checksum=0; + $this->CODE .= "$checksum"; +*/ + $this->FULLCODE = $this->CODE; + } + else + { + $this->TYPE = "ERR"; + $this->FULLCODE = "UNAUTHORIZED CHARS IN KIX CODE"; + } + + break; + case "CMC7" : + + if(!preg_match("/^[0-9A-E]{1,48}$/", $this->CODE)) { + $this->TYPE = "ERR"; + $this->FULLCODE = "CMC7 MUST BE NUMERIC or ABCDE"; + } + else $this->FULLCODE = $this->CODE; + + break; + default : + + $this->TYPE = "ERR"; + $this->FULLCODE = "UNKWOWN BARCODE TYPE"; + + break; + } + } + + /** + * Encodage + * + * Encode des symboles (a-Z, 0-9, ...) vers des barres + */ + function encode() + { + settype($this->FULLCODE, 'string'); + $lencode = strlen($this->FULLCODE); + + $encodedString = ''; + + // Copie de la chaine dans un tableau + $a_tmp = array(); + for($i = 0; $i < $lencode ; $i++) $a_tmp[$i] = $this->FULLCODE{$i}; + + switch( $this->TYPE ) { + + case "EAN" : + case "UPC" : + if ($lencode == 8) + { + $encodedString = '101'; //Premier s�parateur (101) + for ($i = 0; $i < 4; $i++) $encodedString .= $this->EANbars['A'][$a_tmp[$i]]; //Codage partie gauche (tous de classe A) + $encodedString .= '01010'; //S�parateur central (01010) //Codage partie droite (tous de classe C) + for ($i = 4; $i < 8; $i++) $encodedString .= $this->EANbars['C'][$a_tmp[$i]]; + $encodedString .= '101'; //Dernier s�parateur (101) + } + else + { + $parity = $this->EANparity[$a_tmp[0]]; //On r�cup�re la classe de codage de la partie qauche + $encodedString = '101'; //Premier s�parateur (101) + for ($i = 1; $i < 7; $i++) $encodedString .= $this->EANbars[$parity[$i-1]][$a_tmp[$i]]; //Codage partie gauche + $encodedString .= '01010'; //S�parateur central (01010) //Codage partie droite (tous de classe C) + for ($i = 7; $i < 13; $i++) $encodedString .= $this->EANbars['C'][$a_tmp[$i]]; + $encodedString .= '101'; //Dernier s�parateur (101) + } + + break; + case "C128C" : + $encodedString = $this->C128['C']; //Start + $checksum = 105 ; + $j = 1 ; + for ($i = 0; $i < $lencode; $i += 2) + { + $tmp = intval(substr($this->FULLCODE, $i, 2)) ; + $checksum += ( $j++ * $tmp ) ; + $encodedString .= $this->C128[$tmp]; + } + $checksum %= 103 ; + $encodedString .= $this->C128[$checksum]; + $encodedString .= $this->C128['S']; //Stop + break; + case "C128" : + $encodedString = $this->C128['B']; //Start + $checksum = 104 ; + $j = 1 ; + for ($i = 0; $i < $lencode; $i++) + { + $tmp = ord($a_tmp[$i]) - 32 ; + $checksum += ( $j++ * $tmp ) ; + $encodedString .= $this->C128[$tmp]; + } + $checksum %= 103 ; + $encodedString .= $this->C128[$checksum]; + $encodedString .= $this->C128['S']; //Stop + break; + case "C25" : + $encodedString = $this->C25['D']."0"; //Start + for ($i = 0; $i < $lencode; $i++) + { + $num = intval($a_tmp[$i]) ; + $tmp = $this->C25[$num]; + for ($j = 0; $j < 5; $j++) + { + $tmp2 = intval(substr($tmp,$j,1)) ; + for ($k = 1; $k <= $tmp2; $k++) $encodedString .= "1"; + $encodedString .= "0"; + } + } + $encodedString .= $this->C25['F']; //Stop + break; + case "C25I" : + $encodedString = $this->C25['d']; //Start + $checksum = 0; + for ($i = 0; $i < $lencode; $i += 2) + { + $num1 = intval($a_tmp[$i]) ; + $num2 = intval($a_tmp[$i+1]) ; + $checksum += ($num1+$num2); + $tmp1 = $this->C25[$num1]; + $tmp2 = $this->C25[$num2]; + for ($j = 0; $j < 5; $j++) + { + $t1 = intval(substr($tmp1, $j, 1)) ; + $t2 = intval(substr($tmp2, $j, 1)) ; + for ($k = 1; $k <= $t1; $k++) $encodedString .= "1"; + for ($k = 1; $k <= $t2; $k++) $encodedString .= "0"; + } + } + $encodedString .= $this->C25['f']; //Stop + break; + case "C39" : + for ($i = 0; $i < $lencode; $i++)$encodedString .= $this->C39[$a_tmp[$i]] . "0"; + $encodedString = substr($encodedString, 0, -1); + break; + case "CODABAR" : + for ($i = 0; $i < $lencode; $i++) $encodedString .= $this->codabar[$a_tmp[$i]] . "0"; + $encodedString = substr($encodedString, 0, -1); + break; + case "MSI" : + $encodedString = $this->MSI['D']; //Start + for ($i = 0; $i < $lencode; $i++) $encodedString .= $this->MSI[intval($a_tmp[$i])]; + $encodedString .= $this->MSI['F']; //Stop + break; + case "C11" : + $encodedString = $this->C11['S']."0"; //Start + for ($i = 0; $i < $lencode; $i++) $encodedString .= $this->C11[$a_tmp[$i]]."0"; + $encodedString .= $this->C11['S']; //Stop + break; + case "POSTNET" : + $encodedString = '1'; //Start + for ($i = 0; $i < $lencode; $i++) $encodedString .= $this->postnet[$a_tmp[$i]]; + $encodedString .= '1'; //Stop + + $this->CODEWIDTH = ( strlen($encodedString) * 4 ) - 4; + if( $this->HR != '' ) $this->HEIGHT = 32; + else $this->HEIGHT = 22; + break; + case "KIX" : +// $encodedString = "31"; //Start + for ($i = 0; $i < $lencode; $i++) $encodedString .= $this->kix[$a_tmp[$i]]; +// $encodedString .= "32"; //Stop + + $this->CODEWIDTH = ( strlen($encodedString) * 4 ) - 4; + if( $this->HR != '' ) $this->HEIGHT = 32; + else $this->HEIGHT = 22; + break; + case "CMC7" : + $encodedString = $this->FULLCODE; + + $this->CODEWIDTH = ( $lencode * 24 ) - 8; + $this->HEIGHT = 35; + break; + case "ERR" : + $encodedString = ''; + + $this->CODEWIDTH = (imagefontwidth(2) * $lencode); + $this->HEIGHT = max( $this->HEIGHT, 36 ); + break; + + } + + $this->generateBarcodeImage ($encodedString) ; + + + } + + /** + * G�n�ration de l'image du correspondant au code barre + * + */ + function generateBarcodeImage ($encodedString) + { + + $nb_elem = strlen($encodedString); + $this->CODEWIDTH = max( $this->CODEWIDTH, $nb_elem ); + $this->WIDTH = max( $this->WIDTH, $this->CODEWIDTH + ($this->CALMZONE*2) ); + $this->ENCODED = $encodedString; + + + /** + * Cr�ation de l'image du code + */ + + //Initialisation de l'image + $txtPosX = $posX = intval(($this->WIDTH - $this->CODEWIDTH)/2); // position X + $posY = 0; // position Y + $intL = 1; // largeur de la barre + + // detruire eventuellement l'image existante + if ($this->IH) imagedestroy($this->IH); + + $this->IH = imagecreate($this->WIDTH, $this->HEIGHT); + + // colors + $color[0] = ImageColorAllocate($this->IH, 0xFF & ($this->BACKGROUND >> 0x10), 0xFF & ($this->BACKGROUND >> 0x8), 0xFF & $this->BACKGROUND); + $color[1] = ImageColorAllocate($this->IH, 0xFF & ($this->FOREGROUND >> 0x10), 0xFF & ($this->FOREGROUND >> 0x8), 0xFF & $this->FOREGROUND); + $color[2] = ImageColorAllocate($this->IH, 160,160,160); // greyed + + imagefilledrectangle($this->IH, 0, 0, $this->WIDTH, $this->HEIGHT, $color[0]); + + + // Gravure du code + for ($i = 0; $i < $nb_elem; $i++) + { + + // Hauteur des barres dans l'image + $intH = $this->HEIGHT; + if( $this->HR != '' ) + { + switch ($this->TYPE) + { + case "EAN" : + case "UPC" : + if($i<=2 OR $i>=($nb_elem-3) OR ($i>=($nb_elem/2)-2 AND $i<=($nb_elem/2)+2)) $intH-=6; else $intH-=11; + break; + default : + if($i>0 AND $i<($nb_elem-1)) $intH-=11; + } + } + + // Gravure des barres + $fill_color = $this->ENCODED{$i}; + switch ($this->TYPE) + { + case "POSTNET" : + if($fill_color == "1") imagefilledrectangle($this->IH, $posX, ($posY+1), $posX+1, ($posY+20), $color[1]); + else imagefilledrectangle($this->IH, $posX, ($posY+12), $posX+1, ($posY+20), $color[1]); + $intL = 4 ; + break; + case "KIX" : + if($fill_color == "0") imagefilledrectangle($this->IH, $posX, ($posY+1), $posX+1, ($posY+13), $color[1]); + elseif($fill_color == "1") imagefilledrectangle($this->IH, $posX, ($posY+7), $posX+1, ($posY+19), $color[1]); + elseif($fill_color == "2") imagefilledrectangle($this->IH, $posX, ($posY+7), $posX+1, ($posY+13), $color[1]); + else imagefilledrectangle($this->IH, $posX, ($posY+1), $posX+1, ($posY+19), $color[1]); + $intL = 4 ; + break; + case "CMC7" : + $tmp = $this->CMC7[$fill_color]; + $coord = explode( "|", $tmp ); + + for ($j = 0; $j < sizeof($coord); $j++) + { + $pts = explode( "-", $coord[$j] ); + $deb = explode( ",", $pts[0] ); + $X1 = $deb[0] + $posX ; + $Y1 = $deb[1] + 5 ; + $fin = explode( ",", $pts[1] ); + $X2 = $fin[0] + $posX ; + $Y2 = $fin[1] + 5 ; + + imagefilledrectangle($this->IH, $X1, $Y1, $X2, $Y2, $color[1]); + } + $intL = 24 ; + break; + default : + if($fill_color == "1") imagefilledrectangle($this->IH, $posX, $posY, $posX, ($posY+$intH), $color[1]); + } + + //Deplacement du pointeur + $posX += $intL; + } + + // Ajout du texte + $ifw = imagefontwidth(3); + $ifh = imagefontheight(3) - 1; + + $text = ($this->HR == 'AUTO' ? $this->CODE : $this->HR); + + switch ($this->TYPE) + { + case "ERR" : + $ifw = imagefontwidth(3); + imagestring($this->IH, 3, floor( (($this->WIDTH)-($ifw * 7)) / 2 ), 1, "ERROR :", $color[1]); + imagestring($this->IH, 2, 10, 13, $this->FULLCODE, $color[1]); + $ifw = imagefontwidth(1); + imagestring($this->IH, 1, ($this->WIDTH)-($ifw * 9)-2, $this->HEIGHT - $ifh, "Pitoo.com", $color[2]); + break; + case "EAN" : + if ($text != '') if((strlen($this->FULLCODE) > 10) && ($this->FULLCODE{0} > 0)) imagestring($this->IH, 3, $txtPosX-7, $this->HEIGHT - $ifh, substr($this->FULLCODE,-13,1), $color[1]); + case "UPC" : + if ($text != '') + { + if(strlen($this->FULLCODE) > 10) { + imagestring($this->IH, 3, $txtPosX+4, $this->HEIGHT - $ifh, substr($this->FULLCODE,1,6), $color[1]); + imagestring($this->IH, 3, $txtPosX+50, $this->HEIGHT - $ifh, substr($this->FULLCODE,7,6), $color[1]); + } else { + imagestring($this->IH, 3, $txtPosX+4, $this->HEIGHT - $ifh, substr($this->FULLCODE,0,4), $color[1]); + imagestring($this->IH, 3, $txtPosX+36, $this->HEIGHT - $ifh, substr($this->FULLCODE,4,4), $color[1]); + } + } + break; + case "CMC7" : + break; + case "EAN128" : + if ($text != '') + { + imagestring ( + $this->IH, + 3, + intval ((($this->WIDTH) - ($ifw * strlen ($text))) / 2) + 1, + $this->HEIGHT - $ifh, + $text, + $color[1] + ) ; + } + break; + default : + if ($text != '') imagestring($this->IH, 3, intval((($this->WIDTH)-($ifw * strlen($text)))/2)+1, $this->HEIGHT - $ifh, $this->CODE, $color[1]); + } + + + } + + /** + * Show Image + */ + function showBarcodeImage() + { + $this->checkCode(); + $this->encode(); + + if ($this->FILETYPE == 'GIF') + { + Header( "Content-type: image/gif"); + imagegif($this->IH); + } + elseif ($this->FILETYPE == 'JPG') + { + Header( "Content-type: image/jpeg"); + imagejpeg($this->IH); + } + else + { + Header( "Content-type: image/png"); + imagepng($this->IH); + } + } + + /** + * Save Image + */ + function writeBarcodeFile($file) + { + $this->checkCode(); + $this->encode(); + + if ($this->FILETYPE == 'GIF') imagegif($this->IH, $file); + elseif ($this->FILETYPE == 'JPG') imagejpeg($this->IH, $file); + else imagepng($this->IH, $file); + } + + } + //Fin de la classe + + /** + * Classe pour la g�n�ration d'un code EAN-128 + * + * @name CBCEan128 + */ + class CBCEan128 extends pi_barcode + { + + /** + * Tableau des champs + */ + var $toFields ; + + /** + * Constructeur + * + */ + function __construct($_iWidth = 300, $_iHeight = 45) + { + parent::pi_barcode () ; + $this->setType ("EAN128") ; + $this->setSize ($_iHeight, $_iWidth) ; + $this->setFiletype ("JPG") ; + $this->toFields = array () ; + } + + /** + * V�rification du code + * + */ + function checkCode () + { + } + + /** + * Ajout d'un champ dans le code + * + * @param string $_zFieldAI Application Identifier du champs � rajouter + * @param string $_zFieldValue Contenu du champs + */ + function addField ($_zFieldAI, $_zFieldValue) + { + $this->toFields[$_zFieldAI] = $_zFieldValue ; + } + + /** + * Parsing d'un code brute + * + * @param string $_zInputHRCode Code brute + */ + function parseHumanReadableString ($_zInputHRCode) + { + $zInputCode = $_zInputHRCode ; + $toMatches = array () ; + $zRegexp = "(\([0-9]+\))([^\(\)]+)" ; + if (preg_match_all ("/" . $zRegexp . "/s", $zInputCode, $toMatches) !== false) + { + foreach ($toMatches[1] as $iAIKey => $zFieldAI) + { + $zFieldAI = str_replace ("(", "", $zFieldAI) ; + $zFieldAI = str_replace (")", "", $zFieldAI) ; + $this->addField ($zFieldAI, $toMatches[2][$iAIKey]) ; + } + } + } + + /** + * R�cup�ration du texte au format human readable + * + * @return string + */ + function getHumanReadableString () + { + $zRes = "" ; + foreach ($this->toFields as $zFieldAI => $zFieldValue) + { + $zRes .= "(" . $zFieldAI . ")" . $zFieldValue ; + } + return $zRes ; + } + + /** + * R�cup�ration d'un subset � utiliser par un AI + * + */ + function getAISubset ($_zFieldAI) + { + if ((strlen ($_zFieldAI) % 2) == 0) + { + return "C" ; + } + else + { + return "B" ; + } + } + + /** + * R�cup�ration d'un subset � utiliser par un AI + * + */ + function getFieldSubset ($_zFieldAI) + { + return "B" ; + } + + /** + * Encodage au format EAN128 + * + */ + function encode () + { + + $zEncodedString = "" ; + + $iFnc1Value = 102 ; + $zFnc1 = $this->C128[$iFnc1Value] ; + + $iCurrentPosition = 1 ; + $iIndexField = 0 ; + $iIndexChar = 1 ; + + $iCheckSum = 105 ; + + $zCurrentSubset = "C" ; + $zOldSubset = "C" ; + + foreach ($this->toFields as $zFieldAI => $zFieldValue) + { + + if ($iIndexField == 0) + { + + $zCurrentSubset = $this->getAISubset ($zFieldAI) ; + $zOldSubset = $zCurrentSubset ; + + $zEncodedString = $this->C128[$zCurrentSubset] ; + $iCheckSum = ord ($zCurrentSubset) + 38 ; + + } + else + { + $zOldSubset = $zCurrentSubset ; + $zCurrentSubset = $this->getAISubset ($zFieldAI) ; + } + + $zEncodedString .= $zFnc1 ; + $iCheckSum += ($iIndexChar++ * $iFnc1Value) ; + + if ($zCurrentSubset != $zOldSubset) + { + switch ($zCurrentSubset) + { + case 'B' : + $iCurrentValue = 100 ; + break ; + case 'C' : + $iCurrentValue = 99 ; + break ; + } + $iCheckSum += ($iIndexChar++ * $iCurrentValue) ; + $zEncodedString .= $this->C128[$iCurrentValue] ; + } + + switch ($zCurrentSubset) + { + case 'B' : + $iAILength = strlen ($zFieldAI) ; + for ($iIndex = 0 ; $iIndex < $iAILength ; $iIndex++) + { + $iCurrentValue = ord ($zFieldAI{$iIndex}) - 32 ; + $iCheckSum += ($iIndexChar++ * $iCurrentValue) ; + $zEncodedString .= $this->C128[$iCurrentValue] ; + } + break ; + + case 'C' : + $iAILength = strlen ($zFieldAI) ; + for ($iIndex = 0 ; $iIndex < $iAILength ; $iIndex += 2) + { + $iCurrentValue = intval (substr ($zFieldAI, $iIndex, 2)) ; + $iCheckSum += ($iIndexChar++ * $iCurrentValue) ; + $zEncodedString .= $this->C128[$iCurrentValue] ; + } + break ; + } + + $zOldSubset = $zCurrentSubset ; + $zCurrentSubset = $this->getFieldSubset ($zFieldAI) ; + + if ($zCurrentSubset != $zOldSubset) + { + switch ($zCurrentSubset) + { + case 'B' : + $iCurrentValue = 100 ; + break ; + case 'C' : + $iCurrentValue = 99 ; + break ; + } + $iCheckSum += ($iIndexChar++ * $iCurrentValue) ; + $zEncodedString .= $this->C128[$iCurrentValue] ; + } + + switch ($zCurrentSubset) + { + case 'B' : + $iAILength = strlen ($zFieldValue) ; + for ($iIndex = 0 ; $iIndex < $iAILength ; $iIndex++) + { + $iCurrentValue = ord ($zFieldValue{$iIndex}) - 32 ; + $iCheckSum += ($iIndexChar++ * $iCurrentValue) ; + $zEncodedString .= $this->C128[$iCurrentValue] ; + } + break ; + + case 'C' : + $iAILength = strlen ($zFieldValue) ; + for ($iIndex = 0 ; $iIndex < $iAILength ; $iIndex += 2) + { + $iCurrentValue = intval (substr ($zFieldValue, $iIndex, 2)) ; + $iCheckSum += ($iIndexChar++ * $iCurrentValue) ; + $zEncodedString .= $this->C128[$iCurrentValue] ; + } + break ; + } + + $iIndexField++ ; + + } + + $iCheckSum %= 103 ; + $zEncodedString .= $this->C128[$iCheckSum] ; + $zEncodedString .= $this->C128["S"] ; + + $this->setText ($this->getHumanReadableString ()) ; + + $this->generateBarcodeImage ($zEncodedString) ; + + } + + } + + +// } + + +/** +* Compatibilit� avec les versions precedentes +* +* si appel direct de la biblioth�que, g�n�rer l'image a la vol�e +*/ +/* +if (strpos($_SERVER['REQUEST_URI'], 'pi_barcode.php')) +{ + extract($_GET); + + // ***** Cr�ation de l'objet + + $type = strtoupper($type); + + if ($type != "EAN128") + { + + $objCode = new pi_barcode() ; + + + // ***** Hauteur / Largeur + if( isset($_GET['height']) || isset($_GET['width']) ) $objCode->setSize($_GET['height'], $_GET['width']); + + // ***** Autres arguments + if( $_GET['readable'] == 'N' ) $objCode->setText(''); + if( $_GET['showtype'] == 'N' ) $objCode->hideCodeType(); + + if( $_GET['color'] ) + { + if( $_GET['bgcolor'] ) $objCode->setColors($_GET['color'], $_GET['bgcolor']); + else $objCode->setColors($_GET['color']); + } + + + $objCode -> setType($_GET['type']) ; + $objCode -> setCode($_GET['code']) ; + + $objCode -> showBarcodeImage() ; + + } + else + { + $oCode = new CBCEan128 () ; + $oCode->parseHumanReadableString ($_GET['code']) ; + $oCode->showBarcodeImage () ; + } + +} +*/ + +?> diff --git a/ldccrm_client/platosclient.lib.php b/ldccrm_client/platosclient.lib.php new file mode 100644 index 0000000..118defd --- /dev/null +++ b/ldccrm_client/platosclient.lib.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/package.json b/package.json index e4b3dda..b81375b 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,15 @@ "axios": "^0.19", "bootstrap": "^4.0.0", "cross-env": "^7.0", + "jquery": "^3.2", "laravel-mix": "^5.0.1", "lodash": "^4.17.19", - "resolve-url-loader": "^3.1.2", - "sass": "^1.15.2", + "popper.js": "^1.12", + "resolve-url-loader": "^2.3.1", + "sass": "^1.20.1", "sass-loader": "^8.0.0", - "vue-template-compiler": "^2.6.12" + "vue": "^2.5.17", + "vue-template-compiler": "^2.6.10" }, "dependencies": { "jquery": "^3.5.1", diff --git a/resources/js/app.js b/resources/js/app.js index b75fde5..aa19e31 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -8,10 +8,6 @@ require('./bootstrap'); window.Vue = require('vue'); -import Clipboard from 'v-clipboard' - -Vue.use(Clipboard); - /** * The following block of code may be used to automatically register your * Vue components. It will recursively scan this directory for the Vue @@ -23,14 +19,7 @@ Vue.use(Clipboard); // const files = require.context('./', true, /\.vue$/i) // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)) -Vue.component('win-notification', require('./components/WinNotification.vue').default); -Vue.component('gain-views', require('./components/GainViews.vue').default); -Vue.component('prizes', require('./components/Prizes.vue').default); -Vue.component('instant-win', require('./components/InstantWin.vue').default); -Vue.component('codes-ean', require('./components/CodesEAN.vue').default); -Vue.component('banned-ip', require('./components/BannedIP.vue').default); -Vue.component('faq-themes', require('./components/FaqThemes.vue').default); -Vue.component('faq-questions', require('./components/FaqQuestions.vue').default); +Vue.component('example-component', require('./components/ExampleComponent.vue').default); /** * Next, we will create a fresh Vue application instance and attach it to diff --git a/resources/js/components/ExampleComponent.vue b/resources/js/components/ExampleComponent.vue new file mode 100644 index 0000000..3fb9f9a --- /dev/null +++ b/resources/js/components/ExampleComponent.vue @@ -0,0 +1,23 @@ + + + diff --git a/resources/js/components/Prizes.vue b/resources/js/components/Prizes.vue index c66414e..8859005 100644 --- a/resources/js/components/Prizes.vue +++ b/resources/js/components/Prizes.vue @@ -5,7 +5,6 @@
Lots
-
@@ -98,7 +97,6 @@ - Fichier actuel : {{item.pdf_winning_proof}} @@ -178,7 +176,6 @@ if (!files.length) return; - // File[0] car on le récupère toujours de l'event au dessus this.pdf_winning_proof[index] = files[0]; if (!this.pdf_winning_proof[index]) { diff --git a/resources/sass/_variables.scss b/resources/sass/_variables.scss index 5af6218..0407ab5 100644 --- a/resources/sass/_variables.scss +++ b/resources/sass/_variables.scss @@ -17,8 +17,3 @@ $yellow: #ffed4a; $green: #38c172; $teal: #4dc0b5; $cyan: #6cb2eb; -// Theme -$theme-colors: ( - "primary": #3176C4, - "secondary": #E7374B -); diff --git a/resources/sass/app.scss b/resources/sass/app.scss index b1faf1e..3193ffa 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -6,6 +6,3 @@ // Bootstrap @import '~bootstrap/scss/bootstrap'; - -// Style custom -@import 'app_custom'; diff --git a/resources/views/front/basic/enter-code.blade.php b/resources/views/front/basic/enter-code.blade.php new file mode 100644 index 0000000..55f3d38 --- /dev/null +++ b/resources/views/front/basic/enter-code.blade.php @@ -0,0 +1,24 @@ +@extends('front.basic.layout') + +@section('title', 'Saisie du code') + +@section('content') +

Code EAN actif ? {{$settings->use_ean_codes === 1 ? 'Oui' : 'Non'}}

+ @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
+ @csrf + @if ($settings->use_ean_codes === 1) + + @endif + + +
+@endsection diff --git a/resources/views/front/basic/gain1.blade.php b/resources/views/front/basic/gain1.blade.php new file mode 100644 index 0000000..acd0db2 --- /dev/null +++ b/resources/views/front/basic/gain1.blade.php @@ -0,0 +1,7 @@ +@extends('front.basic.layout') + +@section('title', 'BRAVO !') + +@section('content') +

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) :

+ + + + + + + + + + + + + + @foreach ($prizes as $p) + + + + + + + + + + + + @endforeach + +
ID ArcadiaLabel singulierLabel plurielQuantitéNotification activéFormulaire suppl.ID mail ArcadiaPdf preuve de gainLot par défaut
{{$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}}
+@endsection diff --git a/resources/views/front/basic/home.blade.php b/resources/views/front/basic/home.blade.php index 4e215bd..436f51f 100644 --- a/resources/views/front/basic/home.blade.php +++ b/resources/views/front/basic/home.blade.php @@ -3,5 +3,13 @@ @section('title', 'Accueil') @section('content') -

Accueil, aucune variable pour le moment

+

Société : {{$settingsGlobal->company}} et nom du jeu : {{$settingsGlobal->name}}

+

+ Test pour gain : +

+ @csrf + + +
+

@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) :

+ + + + + + + + + + + + + + @foreach ($prizes as $p) + + + + + + + + + + + + @endforeach + +
ID ArcadiaLabel singulierLabel plurielQuantitéNotification activéFormulaire suppl.ID mail ArcadiaPdf preuve de gainLot par défaut
{{$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}}
+@endsection diff --git a/resources/views/front/basic/layout.blade.php b/resources/views/front/basic/layout.blade.php index 0bf62e0..0517db5 100644 --- a/resources/views/front/basic/layout.blade.php +++ b/resources/views/front/basic/layout.blade.php @@ -1,7 +1,7 @@ - @yield('title') - {{ config('app.name', 'Laravel') }} + @yield('title') - {{$settingsGlobal->name}} @@ -22,10 +22,11 @@
+ {{-- Header --}}
+ {{-- Fin du header --}} + {{-- Contenu --}} +
+ @yield('content') +
+ {{-- Fin du contenu --}} + {{-- Footer --}} +
+
+ Footer {{$settingsGlobal->company}} +
+
+ {{-- Fin du footer --}} -
- @yield('content') -
+ + @yield('scripts') diff --git a/resources/views/front/basic/login.blade.php b/resources/views/front/basic/login.blade.php new file mode 100644 index 0000000..111bb5f --- /dev/null +++ b/resources/views/front/basic/login.blade.php @@ -0,0 +1,74 @@ +@extends('front.basic.layout') + +@section('title', 'Connexion') + +@section('content') +
+
+
+
+
{{ __('Login') }}
+ +
+
+ @csrf + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+
+
+ + + +
+
+
+ +
+
+ + Inscription + + @if (Route::has('password.request')) + + {{ __('Forgot Your Password?') }} + + @endif +
+
+
+
+
+
+
+
+@endsection + diff --git a/resources/views/front/basic/loose.blade.php b/resources/views/front/basic/loose.blade.php new file mode 100644 index 0000000..e7c5328 --- /dev/null +++ b/resources/views/front/basic/loose.blade.php @@ -0,0 +1,5 @@ +@extends('front.basic.layout') + +@section('content') +

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') +

+
+
+
+
Inscription
+ +
+ @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
+ @csrf +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+ +
+
+
+
+
+
+
+@endsection diff --git a/resources/views/front/basic/verify.blade.php b/resources/views/front/basic/verify.blade.php new file mode 100644 index 0000000..7ace03f --- /dev/null +++ b/resources/views/front/basic/verify.blade.php @@ -0,0 +1,28 @@ +@extends('front.basic.layout') + +@section('content') +
+
+
+
+
{{ __('Verify Your Email Address') }}
+ +
+ @if (session('resent')) + + @endif + + {{ __('Before proceeding, please check your email for a verification link.') }} + {{ __('If you did not receive the email') }}, +
+ @csrf + . +
+
+
+
+
+
+@endsection diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php new file mode 100644 index 0000000..1f34466 --- /dev/null +++ b/resources/views/home.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Dashboard') }}
+ +
+ @if (session('status')) + + @endif + + {{ __('You are logged in!') }} +
+
+
+
+
+@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 0000000..9e795f4 --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,80 @@ + + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + + + + + + +
+ + +
+ @yield('content') +
+
+ + diff --git a/resources/views/layouts/bo.blade.php b/resources/views/layouts/bo.blade.php index 274034f..b4f9ad9 100644 --- a/resources/views/layouts/bo.blade.php +++ b/resources/views/layouts/bo.blade.php @@ -45,11 +45,7 @@