bug fixes, closed paperless
This commit is contained in:
@@ -12,7 +12,7 @@ use App\Jobs\SendNewNotesEmailAlert;
|
|||||||
use App\Jobs\SendOnboardingCompletedEmailAlert;
|
use App\Jobs\SendOnboardingCompletedEmailAlert;
|
||||||
use App\Http\Requests;
|
use App\Http\Requests;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use App\Libs\PaperLessNgx;
|
||||||
|
|
||||||
class ClientsController extends Controller
|
class ClientsController extends Controller
|
||||||
{
|
{
|
||||||
@@ -21,8 +21,7 @@ class ClientsController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(){
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
$client = Models\Client::find(3);
|
$client = Models\Client::find(3);
|
||||||
dd($client->client_services);
|
dd($client->client_services);
|
||||||
@@ -46,8 +45,7 @@ class ClientsController extends Controller
|
|||||||
];
|
];
|
||||||
return view('client.index-rawjs', $data);
|
return view('client.index-rawjs', $data);
|
||||||
}
|
}
|
||||||
public function getClientJson(Request $request)
|
public function getClientJson(Request $request){
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
$client_arr = new Models\Client;
|
$client_arr = new Models\Client;
|
||||||
$client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info', 'modified_by_info')->orderBy('name', 'ASC')->paginate(20);
|
$client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info', 'modified_by_info')->orderBy('name', 'ASC')->paginate(20);
|
||||||
@@ -142,8 +140,7 @@ class ClientsController extends Controller
|
|||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request){
|
||||||
{
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'name' => 'required|unique:clients,name',
|
'name' => 'required|unique:clients,name',
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
@@ -245,8 +242,7 @@ class ClientsController extends Controller
|
|||||||
Session::flash('success_message', 'Client successfully added');
|
Session::flash('success_message', 'Client successfully added');
|
||||||
return redirect(url('clients'));
|
return redirect(url('clients'));
|
||||||
}
|
}
|
||||||
public function notesStore(Request $request)
|
public function notesStore(Request $request){
|
||||||
{
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'client_id' => 'required',
|
'client_id' => 'required',
|
||||||
'notes_body' => 'required'
|
'notes_body' => 'required'
|
||||||
@@ -306,8 +302,7 @@ class ClientsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public function notesUpdate(Request $request)
|
public function notesUpdate(Request $request){
|
||||||
{
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'client_id' => 'required',
|
'client_id' => 'required',
|
||||||
'notes_body' => 'required'
|
'notes_body' => 'required'
|
||||||
@@ -421,8 +416,7 @@ class ClientsController extends Controller
|
|||||||
$this->logUsersActivity($type = 'staff', $content);
|
$this->logUsersActivity($type = 'staff', $content);
|
||||||
return response()->json($data, 200);
|
return response()->json($data, 200);
|
||||||
}
|
}
|
||||||
public function shortcodeStore(Request $request)
|
public function shortcodeStore(Request $request){
|
||||||
{
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'client_id' => 'required',
|
'client_id' => 'required',
|
||||||
'network' => 'required',
|
'network' => 'required',
|
||||||
@@ -818,8 +812,7 @@ class ClientsController extends Controller
|
|||||||
];
|
];
|
||||||
return view('client.show-readonly', $data);
|
return view('client.show-readonly', $data);
|
||||||
}
|
}
|
||||||
public function showservices($id)
|
public function showservices($id){
|
||||||
{
|
|
||||||
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
||||||
$data = [
|
$data = [
|
||||||
'page_title' => 'Show Services',
|
'page_title' => 'Show Services',
|
||||||
@@ -827,8 +820,7 @@ class ClientsController extends Controller
|
|||||||
];
|
];
|
||||||
return view('client.services', $data);
|
return view('client.services', $data);
|
||||||
}
|
}
|
||||||
public function editservice($id)
|
public function editservice($id){
|
||||||
{
|
|
||||||
$payment = Models\ClientCategory::find($id);
|
$payment = Models\ClientCategory::find($id);
|
||||||
$data = [
|
$data = [
|
||||||
'page_title' => 'Show Services',
|
'page_title' => 'Show Services',
|
||||||
@@ -890,8 +882,7 @@ class ClientsController extends Controller
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id){
|
||||||
{
|
|
||||||
$client = Models\Client::find($id);
|
$client = Models\Client::find($id);
|
||||||
$service_type = Models\Service::orderBy('name', 'ASC')->pluck('name', 'name');
|
$service_type = Models\Service::orderBy('name', 'ASC')->pluck('name', 'name');
|
||||||
$countries = Models\Country::orderBy('en_short_name', 'ASC')->pluck('en_short_name','en_short_name');
|
$countries = Models\Country::orderBy('en_short_name', 'ASC')->pluck('en_short_name','en_short_name');
|
||||||
@@ -1054,10 +1045,10 @@ class ClientsController extends Controller
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function update(Requests\UpdateClientRequest $request, $id)
|
public function update(Requests\UpdateClientRequest $request, $id){
|
||||||
{
|
// dump($request->all());
|
||||||
|
|
||||||
$client_update = Models\Client::find($id);
|
$client_update = Models\Client::find($id);
|
||||||
|
$paperless = new PaperLessNgx();
|
||||||
if ($client_update->progress_indicator != 'COMPLETED') {
|
if ($client_update->progress_indicator != 'COMPLETED') {
|
||||||
$current_pending_stage_details = Models\ClientOnboardingMainStage::where('stage', $request->current_pending_stage)->first();
|
$current_pending_stage_details = Models\ClientOnboardingMainStage::where('stage', $request->current_pending_stage)->first();
|
||||||
$get_stage_subs_items = Models\ClientOnboardingSubItem::where('stage_id', $current_pending_stage_details->stage_id)->get();
|
$get_stage_subs_items = Models\ClientOnboardingSubItem::where('stage_id', $current_pending_stage_details->stage_id)->get();
|
||||||
@@ -1100,6 +1091,7 @@ class ClientsController extends Controller
|
|||||||
dispatch(new SendOnboardingCompletedEmailAlert($client));
|
dispatch(new SendOnboardingCompletedEmailAlert($client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('document_one') && $request->has('document_one_name')) {
|
if ($request->has('document_one') && $request->has('document_one_name')) {
|
||||||
if ($request->file('document_one')->isValid()) {
|
if ($request->file('document_one')->isValid()) {
|
||||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||||
@@ -1107,6 +1099,10 @@ class ClientsController extends Controller
|
|||||||
$document_arr['file_path'] = $filename;
|
$document_arr['file_path'] = $filename;
|
||||||
$client_update->name = $request->name;
|
$client_update->name = $request->name;
|
||||||
|
|
||||||
|
$store_location = "client_files";
|
||||||
|
$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_name, $filename, $store_location);
|
||||||
|
// dd($top);
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document_one->extension();
|
$document_arr['file_extension'] = $request->document_one->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
$document_arr['name'] = $request->document_one_name;
|
$document_arr['name'] = $request->document_one_name;
|
||||||
@@ -1121,6 +1117,9 @@ class ClientsController extends Controller
|
|||||||
$request->document_two->storeAs('client_files', $filename, 'public');
|
$request->document_two->storeAs('client_files', $filename, 'public');
|
||||||
$document_arr['file_path'] = $filename;
|
$document_arr['file_path'] = $filename;
|
||||||
$client_update->name = $request->name;
|
$client_update->name = $request->name;
|
||||||
|
$store_location = "client_files";
|
||||||
|
$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_name, $filename, $store_location);
|
||||||
|
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document_two->extension();
|
$document_arr['file_extension'] = $request->document_two->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
@@ -1137,6 +1136,9 @@ class ClientsController extends Controller
|
|||||||
$document_arr['file_path'] = $filename;
|
$document_arr['file_path'] = $filename;
|
||||||
$client_update->name = $request->name;
|
$client_update->name = $request->name;
|
||||||
|
|
||||||
|
$store_location = "client_files";
|
||||||
|
$top = $paperless->processPaperlessFile($request->document_three_name, $request->document_three_name, $filename, $store_location);
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document_three->extension();
|
$document_arr['file_extension'] = $request->document_three->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
$document_arr['name'] = $request->document_three_name;
|
$document_arr['name'] = $request->document_three_name;
|
||||||
@@ -1152,6 +1154,9 @@ class ClientsController extends Controller
|
|||||||
$document_arr['file_path'] = $filename;
|
$document_arr['file_path'] = $filename;
|
||||||
$client_update->name = $request->name;
|
$client_update->name = $request->name;
|
||||||
|
|
||||||
|
$store_location = "client_files";
|
||||||
|
$top = $paperless->processPaperlessFile($request->other_document_name, $request->other_document_name, $filename, $store_location);
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->other_document->extension();
|
$document_arr['file_extension'] = $request->other_document->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
$document_arr['name'] = $request->document_three_name;
|
$document_arr['name'] = $request->document_three_name;
|
||||||
@@ -1161,6 +1166,8 @@ class ClientsController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$client_update->name = $request->name;
|
$client_update->name = $request->name;
|
||||||
$client_update->email = $request->email;
|
$client_update->email = $request->email;
|
||||||
$client_update->phone = $request->phone ?? "";
|
$client_update->phone = $request->phone ?? "";
|
||||||
@@ -1282,8 +1289,8 @@ class ClientsController extends Controller
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function storeFiles(AddFilesRequest $request)
|
public function storeFiles(AddFilesRequest $request){
|
||||||
{
|
|
||||||
$document_arr = $request->except('document');
|
$document_arr = $request->except('document');
|
||||||
if ($request->hasFile('document')) {
|
if ($request->hasFile('document')) {
|
||||||
if ($request->file('document')->isValid()) {
|
if ($request->file('document')->isValid()) {
|
||||||
@@ -1292,6 +1299,7 @@ class ClientsController extends Controller
|
|||||||
$document_arr['document'] = json_encode([$filename]);
|
$document_arr['document'] = json_encode([$filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document->extension();
|
$document_arr['file_extension'] = $request->document->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
$document_arr['last_modified_by'] = session('current_user.id');
|
$document_arr['last_modified_by'] = session('current_user.id');
|
||||||
@@ -1307,8 +1315,7 @@ class ClientsController extends Controller
|
|||||||
return response()->json($data, 200);
|
return response()->json($data, 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
public function getClientFile($id)
|
public function getClientFile($id){
|
||||||
{
|
|
||||||
$client_file = Models\ClientFile::with('client_info')->findOrFail($id);
|
$client_file = Models\ClientFile::with('client_info')->findOrFail($id);
|
||||||
//PDF file is stored under project/public/download/info.pdf
|
//PDF file is stored under project/public/download/info.pdf
|
||||||
$file = public_path('documents/client_files/') . $client_file->file_path;
|
$file = public_path('documents/client_files/') . $client_file->file_path;
|
||||||
|
|||||||
@@ -83,92 +83,4 @@ class Controller extends BaseController
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendToPaperless($file_path, $tags_arr, $created_at, $document_type, $title, $correspondent){
|
|
||||||
$dir = getcwd();
|
|
||||||
$prod_url = "http://206.225.84.201:8000/api/documents/post_document/";
|
|
||||||
$local_url = "http://192.168.68.152:8000/api/documents/post_document/";
|
|
||||||
// dd($ip);
|
|
||||||
if ($dir !== '/Users/kwesibanson/Sites/team_tracker') {
|
|
||||||
$url = $prod_url;
|
|
||||||
$auth = "";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$url = $local_url;
|
|
||||||
$auth = "cGxhZG1pbjpCcmFuY2gyMDAw";
|
|
||||||
}
|
|
||||||
// $pop = new \CURLFILE('/Users/kwesibanson/Documents/36-PropertyBillsRegister-2019.pdf');
|
|
||||||
// $curl_file = new \CURLFILE(public_path('documents/ultra_host.pdf'));
|
|
||||||
$curl_file = new \CURLFILE(public_path($file_path));
|
|
||||||
$curl = curl_init();
|
|
||||||
$data = [
|
|
||||||
"document" => $curl_file,
|
|
||||||
'title' => $title,
|
|
||||||
'correspondent' => $correspondent,
|
|
||||||
'created' => $created_at,
|
|
||||||
'document_type' => $document_type
|
|
||||||
];
|
|
||||||
if (count($tags_arr) > 0) {
|
|
||||||
foreach ($tags_arr as $tag) {
|
|
||||||
$data['tags'] = $tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// dd($data);
|
|
||||||
curl_setopt_array($curl, array(
|
|
||||||
CURLOPT_URL => $url,
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_ENCODING => '',
|
|
||||||
CURLOPT_MAXREDIRS => 10,
|
|
||||||
CURLOPT_TIMEOUT => 0,
|
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
|
||||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
||||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
||||||
CURLOPT_POSTFIELDS => $data, //['document' => $curl_file],
|
|
||||||
// CURLOPT_POSTFIELDS => array('document'=> new CURLFILE('/Users/kwesibanson/Documents/36-PropertyBillsRegister-2019.pdf')),
|
|
||||||
CURLOPT_HTTPHEADER => array(': ', 'Authorization: Basic ' . $auth),
|
|
||||||
));
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
// print_r(curl_getinfo($ch));
|
|
||||||
// dump(curl_errno($curl));
|
|
||||||
// dump(curl_error($curl));
|
|
||||||
curl_close($curl);
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
}
|
|
||||||
public function getToPaperlessParamValues($name){
|
|
||||||
// $name = "document_types/";
|
|
||||||
$dir = getcwd();
|
|
||||||
$prod_url = "http://206.225.84.201:8000/api/$name/";
|
|
||||||
$local_url = "http://192.168.68.152:8000/api/$name/";
|
|
||||||
// dd($ip);
|
|
||||||
if ($dir !== '/Users/kwesibanson/Sites/team_tracker') {
|
|
||||||
$url = $prod_url;
|
|
||||||
$auth = "";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$url = $local_url;
|
|
||||||
$auth = "cGxhZG1pbjpCcmFuY2gyMDAw";
|
|
||||||
}
|
|
||||||
// $pop = new \CURLFILE('/Users/kwesibanson/Documents/36-PropertyBillsRegister-2019.pdf');
|
|
||||||
// $curl_file = new \CURLFILE(public_path('documents/ultra_host.pdf'));
|
|
||||||
|
|
||||||
// dd($data);
|
|
||||||
$curl = curl_init();
|
|
||||||
curl_setopt_array($curl, array(
|
|
||||||
CURLOPT_URL => $url,
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_ENCODING => '',
|
|
||||||
CURLOPT_MAXREDIRS => 10,
|
|
||||||
CURLOPT_TIMEOUT => 0,
|
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
|
||||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
||||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
||||||
CURLOPT_HTTPHEADER => array(': ', 'Authorization: Basic ' . $auth),
|
|
||||||
));
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
curl_close($curl);
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ use Illuminate\Http\Request;
|
|||||||
use App\Models;
|
use App\Models;
|
||||||
use Session;
|
use Session;
|
||||||
use App\Http\Requests;
|
use App\Http\Requests;
|
||||||
|
use App\Libs\PaperLessNgx;
|
||||||
|
|
||||||
|
|
||||||
class GeneralDocumentsController extends Controller
|
class GeneralDocumentsController extends Controller
|
||||||
{
|
{
|
||||||
@@ -127,6 +129,7 @@ class GeneralDocumentsController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(Requests\GeneralDocumentsRequest $request){
|
public function store(Requests\GeneralDocumentsRequest $request){
|
||||||
// dd($request->all());
|
// dd($request->all());
|
||||||
|
$paperless = new PaperLessNgx();
|
||||||
if ($request->has('document_one') && $request->has('document_one_name') && $request->has('document_one_category')) {
|
if ($request->has('document_one') && $request->has('document_one_name') && $request->has('document_one_category')) {
|
||||||
if ($request->file('document_one')->isValid()) {
|
if ($request->file('document_one')->isValid()) {
|
||||||
//dd($request->all());
|
//dd($request->all());
|
||||||
@@ -135,16 +138,9 @@ class GeneralDocumentsController extends Controller
|
|||||||
$document_arr['filename'] = $filename;
|
$document_arr['filename'] = $filename;
|
||||||
$document_arr['category'] = $request->document_one_category;
|
$document_arr['category'] = $request->document_one_category;
|
||||||
|
|
||||||
# set parameters and push to paperless
|
#sendToPaperLess
|
||||||
$file_path = "documents/general_files/" . $filename; //"documents/oasl.pdf";
|
$store_location = "general_files";
|
||||||
$tags_arr = [1,2];
|
$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_category, $filename, $store_location);
|
||||||
$created_at = date('Y-m-d H:i:s');
|
|
||||||
$document_type = 1;
|
|
||||||
$correspondent = 1;
|
|
||||||
$title = $request->document_one_name;
|
|
||||||
$retval_paperless = $this->sendToPaperless($file_path, $tags_arr, $created_at, $document_type, $title, $correspondent);
|
|
||||||
\Log::info($retval_paperless);
|
|
||||||
|
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document_one->extension();
|
$document_arr['file_extension'] = $request->document_one->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
@@ -160,6 +156,10 @@ class GeneralDocumentsController extends Controller
|
|||||||
$document_arr['filename'] = $filename;
|
$document_arr['filename'] = $filename;
|
||||||
$document_arr['category'] = $request->document_two_category;
|
$document_arr['category'] = $request->document_two_category;
|
||||||
|
|
||||||
|
#sendToPaperLess
|
||||||
|
$store_location = "general_files";
|
||||||
|
$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_category, $filename, $store_location);
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document_two->extension();
|
$document_arr['file_extension'] = $request->document_two->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
$document_arr['name'] = $request->document_two_name;
|
$document_arr['name'] = $request->document_two_name;
|
||||||
@@ -174,6 +174,10 @@ class GeneralDocumentsController extends Controller
|
|||||||
$document_arr['filename'] = $filename;
|
$document_arr['filename'] = $filename;
|
||||||
$document_arr['category'] = $request->document_three_category;
|
$document_arr['category'] = $request->document_three_category;
|
||||||
|
|
||||||
|
#sendToPaperLess
|
||||||
|
$store_location = "general_files";
|
||||||
|
$top = $paperless->processPaperlessFile($request->document_three_name, $request->document_three_category, $filename, $store_location);
|
||||||
|
|
||||||
$document_arr['file_extension'] = $request->document_three->extension();
|
$document_arr['file_extension'] = $request->document_three->extension();
|
||||||
$document_arr['file_reff'] = time() . uniqid();
|
$document_arr['file_reff'] = time() . uniqid();
|
||||||
$document_arr['name'] = $request->document_three_name;
|
$document_arr['name'] = $request->document_three_name;
|
||||||
@@ -246,26 +250,5 @@ class GeneralDocumentsController extends Controller
|
|||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
public function getDocumentCorrespondent($category){
|
|
||||||
switch ($category) {
|
|
||||||
case 'sidwl':
|
|
||||||
// code...
|
|
||||||
break;
|
|
||||||
case 'api':
|
|
||||||
// code...
|
|
||||||
break;
|
|
||||||
case 'scfees':
|
|
||||||
// code...
|
|
||||||
break;
|
|
||||||
case 'presentations':
|
|
||||||
// code...
|
|
||||||
break;
|
|
||||||
case 'others':
|
|
||||||
// code...
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// code...
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class UtilityController extends Controller
|
|||||||
$retval = $this->getToPaperlessParamValues($name);
|
$retval = $this->getToPaperlessParamValues($name);
|
||||||
// dd($retval['results']);
|
// dd($retval['results']);
|
||||||
$tip = json_decode($retval);
|
$tip = json_decode($retval);
|
||||||
|
dd($tip);
|
||||||
foreach ($tip->results as $value) {
|
foreach ($tip->results as $value) {
|
||||||
dd($value);
|
dd($value);
|
||||||
}
|
}
|
||||||
|
|||||||
191
app/Libs/PaperLessNgx.php
Normal file
191
app/Libs/PaperLessNgx.php
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Libs;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use Log;
|
||||||
|
use App\Models;
|
||||||
|
class PaperLessNgx {
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
//nothingness
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendToPaperless($file_path, $tags_arr, $created_at, $document_type, $title, $correspondent){
|
||||||
|
$dir = getcwd();
|
||||||
|
// dd($dir);
|
||||||
|
$prod_url = "http://206.225.84.201:8000/api/documents/post_document/";
|
||||||
|
$local_url = "http://192.168.68.152:8000/api/documents/post_document/";
|
||||||
|
// dd($ip);
|
||||||
|
if ($dir !== '/Users/kwesibanson/Sites/team_tracker') {
|
||||||
|
$url = $prod_url;
|
||||||
|
$auth = "cGxjbGlja2FkbWluOkJyYW5jaDIwMDA=";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$url = $local_url;
|
||||||
|
$auth = "cGxhZG1pbjpCcmFuY2gyMDAw";
|
||||||
|
}
|
||||||
|
// dd($url);
|
||||||
|
// $pop = new \CURLFILE('/Users/kwesibanson/Documents/36-PropertyBillsRegister-2019.pdf');
|
||||||
|
// $curl_file = new \CURLFILE(public_path('documents/ultra_host.pdf'));
|
||||||
|
$curl_file = new \CURLFILE(public_path($file_path));
|
||||||
|
$curl = curl_init();
|
||||||
|
$data = [
|
||||||
|
"document" => $curl_file,
|
||||||
|
'title' => $title,
|
||||||
|
'tags' => $tags_arr,
|
||||||
|
'correspondent' => $correspondent,
|
||||||
|
'created' => $created_at,
|
||||||
|
'document_type' => $document_type,
|
||||||
|
'storage_path' => 1
|
||||||
|
];
|
||||||
|
|
||||||
|
if (count($tags_arr) > 0) {
|
||||||
|
foreach ($tags_arr as $tag) {
|
||||||
|
$data['tags'] = $tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\Log::info($data);
|
||||||
|
// dd($data);
|
||||||
|
curl_setopt_array($curl, array(
|
||||||
|
CURLOPT_URL => $url,
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_ENCODING => '',
|
||||||
|
CURLOPT_MAXREDIRS => 10,
|
||||||
|
CURLOPT_TIMEOUT => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||||
|
CURLOPT_POSTFIELDS => $data, //['document' => $curl_file],
|
||||||
|
// CURLOPT_POSTFIELDS => array('document'=> new CURLFILE('/Users/kwesibanson/Documents/36-PropertyBillsRegister-2019.pdf')),
|
||||||
|
CURLOPT_HTTPHEADER => array(': ', 'Authorization: Basic ' . $auth),
|
||||||
|
));
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
// print_r(curl_getinfo($ch));
|
||||||
|
// dump(curl_errno($curl));
|
||||||
|
// dump(curl_error($curl));
|
||||||
|
// curl_close($curl);
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
public function getToPaperlessParamValues($name){
|
||||||
|
// $name = "document_types/";
|
||||||
|
$dir = getcwd();
|
||||||
|
$prod_url = "http://206.225.84.201:8000/api/$name/";
|
||||||
|
$local_url = "http://192.168.68.152:8000/api/$name/";
|
||||||
|
// dd($ip);
|
||||||
|
if ($dir !== '/Users/kwesibanson/Sites/team_tracker') {
|
||||||
|
$url = $prod_url;
|
||||||
|
$auth = "cGxjbGlja2FkbWluOkJyYW5jaDIwMDA=";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$url = $local_url;
|
||||||
|
$auth = "cGxhZG1pbjpCcmFuY2gyMDAw";
|
||||||
|
}
|
||||||
|
// $pop = new \CURLFILE('/Users/kwesibanson/Documents/36-PropertyBillsRegister-2019.pdf');
|
||||||
|
// $curl_file = new \CURLFILE(public_path('documents/ultra_host.pdf'));
|
||||||
|
|
||||||
|
// curl --location 'http://206.225.84.201:8000/api/tags/' \
|
||||||
|
// --header 'Authorization: Basic cGxjbGlja2FkbWluOkJyYW5jaDIwMDA=' \
|
||||||
|
// --header 'Cookie: csrftoken=bDnOrmAk0cKFXwKEQ7LMl0fiTn8EZDqU'
|
||||||
|
|
||||||
|
// dd($data);
|
||||||
|
$curl = curl_init();
|
||||||
|
curl_setopt_array($curl, array(
|
||||||
|
CURLOPT_URL => $url,
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_ENCODING => '',
|
||||||
|
CURLOPT_MAXREDIRS => 10,
|
||||||
|
CURLOPT_TIMEOUT => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||||
|
CURLOPT_HTTPHEADER => array(': ', 'Authorization: Basic ' . $auth),
|
||||||
|
));
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
curl_close($curl);
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function processPaperlessFile($title, $category, $filename, $store_location){
|
||||||
|
# set parameters and push to paperless
|
||||||
|
$tags_correspondent = $this->getDocumentCorrespondent($category);
|
||||||
|
if ($store_location == "general_files") {
|
||||||
|
$file_path = "documents/general_files/" . $filename; //"documents/oasl.pdf";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$file_path = "documents/client_files/" . $filename; //"documents/oasl.pdf";
|
||||||
|
}
|
||||||
|
|
||||||
|
$tags_arr[] = $tags_correspondent['tags']; //[1,2];
|
||||||
|
$created_at = date('Y-m-d H:i:s');
|
||||||
|
$document_type = $tags_correspondent['document_type'];
|
||||||
|
$correspondent = $tags_correspondent['correspondent'];
|
||||||
|
$retval_paperless = $this->sendToPaperless($file_path, $tags_arr, $created_at, $document_type, $title, $correspondent);
|
||||||
|
\Log::info($retval_paperless);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public function getDocumentCorrespondent($category){
|
||||||
|
$category = strtolower($category);
|
||||||
|
switch ($category) {
|
||||||
|
case 'sidwl':
|
||||||
|
$correspondent = "2";
|
||||||
|
$tags = "9";
|
||||||
|
$document_type = "3";
|
||||||
|
break;
|
||||||
|
case 'api':
|
||||||
|
$correspondent = "1";
|
||||||
|
$tags = "7";
|
||||||
|
$document_type = "3";
|
||||||
|
break;
|
||||||
|
case 'contracts':
|
||||||
|
$correspondent = "3";
|
||||||
|
$tags = "8";
|
||||||
|
$document_type = "4";
|
||||||
|
break;
|
||||||
|
case 'scfees':
|
||||||
|
$correspondent = "2";
|
||||||
|
$tags = "9";
|
||||||
|
$document_type = "7";
|
||||||
|
break;
|
||||||
|
case 'presentations':
|
||||||
|
$correspondent = "3";
|
||||||
|
$tags = "1";
|
||||||
|
$document_type = "1";
|
||||||
|
break;
|
||||||
|
case 'proposal':
|
||||||
|
$correspondent = "3";
|
||||||
|
$tags = "2";
|
||||||
|
$document_type = "10";
|
||||||
|
break;
|
||||||
|
case 'rates':
|
||||||
|
// code...General
|
||||||
|
$correspondent = "6";
|
||||||
|
$tags = "3";
|
||||||
|
$document_type = "7";
|
||||||
|
break;
|
||||||
|
case 'non disclosure':
|
||||||
|
$correspondent = "3";
|
||||||
|
$tags = "8";
|
||||||
|
$document_type = "4";
|
||||||
|
break;
|
||||||
|
case 'technical document':
|
||||||
|
$correspondent = "1";
|
||||||
|
$tags = "10";
|
||||||
|
$document_type = "3";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$correspondent = "3";
|
||||||
|
$tags = "10";
|
||||||
|
$document_type = "11";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$data = ['correspondent' => $correspondent, 'tags' => $tags, 'document_type' => $document_type];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
BIN
public/documents/client_files/erp_1719930373ih2d8o.pdf
Normal file
BIN
public/documents/client_files/erp_1719930373ih2d8o.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_17199305295bN8Dv.pdf
Normal file
BIN
public/documents/client_files/erp_17199305295bN8Dv.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930529E6cYLs.xlsx
Normal file
BIN
public/documents/client_files/erp_1719930529E6cYLs.xlsx
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930529HtCjic.pdf
Normal file
BIN
public/documents/client_files/erp_1719930529HtCjic.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930529e8Gx0k.pdf
Normal file
BIN
public/documents/client_files/erp_1719930529e8Gx0k.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930572Ahr0VX.pdf
Normal file
BIN
public/documents/client_files/erp_1719930572Ahr0VX.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930756Vt6aoX.pdf
Normal file
BIN
public/documents/client_files/erp_1719930756Vt6aoX.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930816gwYBAL.pdf
Normal file
BIN
public/documents/client_files/erp_1719930816gwYBAL.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930874rVtTRA.pdf
Normal file
BIN
public/documents/client_files/erp_1719930874rVtTRA.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_17199308983zgAvW.pdf
Normal file
BIN
public/documents/client_files/erp_17199308983zgAvW.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930921twb1vc.pdf
Normal file
BIN
public/documents/client_files/erp_1719930921twb1vc.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719930921vv5Anc.pdf
Normal file
BIN
public/documents/client_files/erp_1719930921vv5Anc.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719931213VcT5D7.pdf
Normal file
BIN
public/documents/client_files/erp_1719931213VcT5D7.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719931215nBDNcA.pdf
Normal file
BIN
public/documents/client_files/erp_1719931215nBDNcA.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_1719931272drblRp.pdf
Normal file
BIN
public/documents/client_files/erp_1719931272drblRp.pdf
Normal file
Binary file not shown.
BIN
public/documents/client_files/erp_17199422509iDdRG.pdf
Normal file
BIN
public/documents/client_files/erp_17199422509iDdRG.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719926198GVpuIx.pdf
Normal file
BIN
public/documents/general_files/erp_1719926198GVpuIx.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719926627KsWWpC.pdf
Normal file
BIN
public/documents/general_files/erp_1719926627KsWWpC.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719926662qDPaQH.pdf
Normal file
BIN
public/documents/general_files/erp_1719926662qDPaQH.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719927227uuly84.pdf
Normal file
BIN
public/documents/general_files/erp_1719927227uuly84.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_17199272414lzNwA.pdf
Normal file
BIN
public/documents/general_files/erp_17199272414lzNwA.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719927260udZnvr.pdf
Normal file
BIN
public/documents/general_files/erp_1719927260udZnvr.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719927287uW6HTG.pdf
Normal file
BIN
public/documents/general_files/erp_1719927287uW6HTG.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719927308sGSw3o.pdf
Normal file
BIN
public/documents/general_files/erp_1719927308sGSw3o.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_17199274922b8Kd8.pdf
Normal file
BIN
public/documents/general_files/erp_17199274922b8Kd8.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719927493dIIzZC.pdf
Normal file
BIN
public/documents/general_files/erp_1719927493dIIzZC.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719927494Ed6Etx.pdf
Normal file
BIN
public/documents/general_files/erp_1719927494Ed6Etx.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719929137EkaoXx.pdf
Normal file
BIN
public/documents/general_files/erp_1719929137EkaoXx.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_1719929139yzLrfq.pdf
Normal file
BIN
public/documents/general_files/erp_1719929139yzLrfq.pdf
Normal file
Binary file not shown.
BIN
public/documents/general_files/erp_17199291403ypqpm.pdf
Normal file
BIN
public/documents/general_files/erp_17199291403ypqpm.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user