ultimatepos/Modules/InventoryManagement/start.php

62 lines
1.9 KiB
PHP

<?php
/*
|--------------------------------------------------------------------------
| Register Namespaces and Routes
|--------------------------------------------------------------------------
|
| When your module starts, this file is executed automatically. By default
| it will only load the module's route file. However, you can expand on
| it to load anything else from the module, such as a class or view.
|
*/
if (! function_exists('inventorymanagement1')) {
function inventorymanagement1($ul, $pt, $lc, $em, $un, $type = 1, $pid = null)
{
$ch = curl_init();
$request_url = ($type == 1) ? base64_decode(config('inventorymanagement.lic1')) : base64_decode(config('inventorymanagement.lic2'));
$pid = is_null($pid) ? config('inventorymanagement.pid') : $pid;
$curlConfig = [CURLOPT_URL => $request_url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => [
'url' => $ul,
'path' => $pt,
'license_code' => $lc,
'email' => $em,
'username' => $un,
'product_id' => $pid
]
];
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = 'C'.'U'.'RL '.'E'.'rro'.'r: ';
$error_msg .= curl_errno($ch);
return redirect()->back()
->with('error', $error_msg);
}
curl_close($ch);
if ($result) {
$result = json_decode($result, true);
if ($result['flag'] == 'valid') {
// if(!empty($result['data'])){
// $this->_handle_data($result['data']);
// }
} else {
$msg = (isset($result['msg']) && !empty($result['msg'])) ? $result['msg'] : "I"."nvali"."d "."Lic"."ense Det"."ails";
return redirect()->back()
->with('error', $msg);
}
}
}
}